Skip to content

Ghidra is a software reverse engineering (SRE) framework

GP-579: Trashing SCTL and related AsyncComm stuff.

Dan3a550a8979a9
diff --git a/Ghidra/Debug/Debugger-gadp/src/test/java/ghidra/dbg/gadp/client/GadpClientTest.java b/Ghidra/Debug/Debugger-gadp/src/test/java/ghidra/dbg/gadp/client/GadpClientTest.java
index d1818ffd2f..f011285d65 100644
--- a/Ghidra/Debug/Debugger-gadp/src/test/java/ghidra/dbg/gadp/client/GadpClientTest.java
+++ b/Ghidra/Debug/Debugger-gadp/src/test/java/ghidra/dbg/gadp/client/GadpClientTest.java
@@ -32,8 +32,6 @@ import org.junit.Test;
import generic.Unique;
import ghidra.async.AsyncUtils;
import ghidra.async.TypeSpec;
-import ghidra.comm.packet.err.PacketDecodeException;
-import ghidra.comm.packet.err.PacketEncodeException;
import ghidra.dbg.attributes.TargetObjectRef;
import ghidra.dbg.gadp.GadpVersion;
import ghidra.dbg.gadp.protocol.Gadp;
@@ -92,8 +90,7 @@ public class GadpClientTest {
this.cli = srv.accept();
}
- public void expect(Gadp.RootMessage msg)
- throws IOException, PacketDecodeException, PacketEncodeException {
+ public void expect(Gadp.RootMessage msg) throws IOException {
Msg.debug(this, "Expecting: " + msg);
while (true) {
@@ -121,8 +118,7 @@ public class GadpClientTest {
}
}
- public void send(Gadp.RootMessage msg)
- throws PacketEncodeException, IOException {
+ public void send(Gadp.RootMessage msg) throws IOException {
Msg.debug(this, "Server Sending: " + msg);
outbuf.clear();
AsyncProtobufMessageChannel.marshall(msg, outbuf);
@@ -135,8 +131,7 @@ public class GadpClientTest {
}
}
- public void handleConnect(GadpVersion version)
- throws IOException, PacketDecodeException, PacketEncodeException {
+ public void handleConnect(GadpVersion version) throws IOException {
expect(Gadp.RootMessage.newBuilder()
.setSequence(seqno)
.setConnectRequest(GadpVersion.makeRequest())
@@ -153,8 +148,7 @@ public class GadpClientTest {
seqno++;
}
- public void handlePing()
- throws IOException, PacketDecodeException, PacketEncodeException {
+ public void handlePing() throws IOException {
expect(Gadp.RootMessage.newBuilder()
.setSequence(seqno)
.setPingRequest(Gadp.PingRequest.newBuilder()
diff --git a/Ghidra/Debug/Debugger-sctl/Module.manifest b/Ghidra/Debug/Debugger-sctl/Module.manifest
deleted file mode 100644
index e69de29bb2..0000000000
diff --git a/Ghidra/Debug/Debugger-sctl/build.gradle b/Ghidra/Debug/Debugger-sctl/build.gradle
deleted file mode 100644
index 412bedff7c..0000000000
--- a/Ghidra/Debug/Debugger-sctl/build.gradle
+++ /dev/null
@@ -1,21 +0,0 @@
-apply from: "${rootProject.projectDir}/gradle/javaProject.gradle"
-apply from: "${rootProject.projectDir}/gradle/jacocoProject.gradle"
-apply from: "${rootProject.projectDir}/gradle/javaTestProject.gradle"
-apply from: "${rootProject.projectDir}/gradle/distributableGhidraModule.gradle"
-
-apply plugin: 'eclipse'
-eclipse.project.name = 'Debug Debugger-sctl'
-
-dependencies {
- compile project(':Framework-AsyncComm')
- compile project(':Framework-Debugging')
- compile project(':ProposedUtils')
-
- testCompile project(path: ':Framework-Debugging', configuration: 'testArtifacts')
-}
-
-test {
- if ("linux64".equals(getCurrentPlatformName())) {
- dependsOn(":Framework-Debugging:testSpecimenLinux64")
- }
-}
diff --git a/Ghidra/Debug/Debugger-sctl/certification.manifest b/Ghidra/Debug/Debugger-sctl/certification.manifest
deleted file mode 100644
index f97a3aacc3..0000000000
--- a/Ghidra/Debug/Debugger-sctl/certification.manifest
+++ /dev/null
@@ -1,5 +0,0 @@
-##VERSION: 2.0
-.classpath||NONE||reviewed||END|
-.project||NONE||reviewed||END|
-Module.manifest||GHIDRA||||END|
-build.gradle||GHIDRA||||END|
diff --git a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/client/SctlClient.java b/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/client/SctlClient.java
deleted file mode 100644
index 2851ab1587..0000000000
--- a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/client/SctlClient.java
+++ /dev/null
@@ -1,1824 +0,0 @@
-/* ###
- * 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 ghidra.dbg.sctl.client;
-
-import static ghidra.async.AsyncUtils.loop;
-import static ghidra.async.AsyncUtils.sequence;
-import static ghidra.lifecycle.Unfinished.TODO;
-
-import java.io.EOFException;
-import java.io.InvalidObjectException;
-import java.nio.channels.*;
-import java.util.*;
-import java.util.concurrent.*;
-import java.util.concurrent.atomic.AtomicReference;
-
-import org.apache.commons.lang3.StringUtils;
-
-import com.google.common.cache.RemovalNotification;
-
-import ghidra.async.*;
-import ghidra.comm.packet.AsynchronousPacketChannel;
-import ghidra.comm.packet.AsynchronousPacketDebugChannel;
-import ghidra.dbg.DebuggerModelClosedReason;
-import ghidra.dbg.agent.AbstractDebuggerObjectModel;
-import ghidra.dbg.sctl.client.depr.DebuggerAddressMapper;
-import ghidra.dbg.sctl.client.depr.DefaultDebuggerAddressMapper;
-import ghidra.dbg.sctl.client.err.*;
-import ghidra.dbg.sctl.dialect.SctlDialect;
-import ghidra.dbg.sctl.err.SctlError;
-import ghidra.dbg.sctl.protocol.*;
-import ghidra.dbg.sctl.protocol.common.*;
-import ghidra.dbg.sctl.protocol.common.notify.*;
-import ghidra.dbg.sctl.protocol.common.notify.AbstractSctlListsLibrariesEventNotification.PathBase;
-import ghidra.dbg.sctl.protocol.common.reply.*;
-import ghidra.dbg.sctl.protocol.common.request.*;
-import ghidra.dbg.sctl.protocol.v2012base.Sctl2012SnapNotification;
-import ghidra.dbg.sctl.protocol.v2012ext.SctlExecuteReply;
-import ghidra.dbg.sctl.protocol.v2012ext.SctlExecuteRequest;
-import ghidra.dbg.sctl.protocol.v2012ext.x86.linux.Sctl2012ExtLinuxX86Dialect;
-import ghidra.dbg.sctl.protocol.v2018base.*;
-import ghidra.dbg.target.TargetExecutionStateful.TargetExecutionState;
-import ghidra.dbg.target.TargetObject;
-import ghidra.dbg.target.TargetObject.TargetObjectListener;
-import ghidra.dbg.target.TargetSymbol;
-import ghidra.dbg.util.PathUtils;
-import ghidra.lifecycle.Internal;
-import ghidra.program.model.address.*;
-import ghidra.util.Msg;
-import ghidra.util.datastruct.ListenerSet;
-
-/**
- * A debugger client implementation that communicates with an external debugger via SCTL-bus
- *
- * SCTL-bus, created by the GHIDRA team, is an extension to SCTL. The SCTL protocol is specified for
- * Cinquecento. Details are available at their website
- * <a href="http://cqctworld.org">cqctworld.org</a>. Details for the SCTL-bus extension are
- * available within {@link Sctl2012ExtLinuxX86Dialect}. It is backward compatible with standard
- * SCTL, so this client can control the sctl process control server for Linux out-of-box.
- *
- * This fully implements the Ghidra debugging API with some notable limitations, including but
- * certainly not limited to the following:
- *
- * 1) The step command is not properly confirmed. The SCTL protocol's {@code Tstep} command requires
- * the step to complete before the {@code Rstep} response is given. Thus, it is difficult to tell if
- * the command was dropped, or if the step is taking a long time. This can happen if, e.g., the
- * stepped instruction is a system call. As a result, the step instruction may time out, even though
- * the target thread has entered the {@link TargetExecutionState#RUNNING} state. A better model is
- * exemplified by GDB, which may provide a model for extending SCTL further. The step should
- * complete as soon as the target is running. When the step completes, a stop notification should be
- * sent indicating "step completed" as the reason. This is a minor issue, though. As a workaround,
- * this implementation assumes the thread is {@link TargetExecutionState#RUNNING} immediately after
- * {@code Tstep} is sent. Once the result is returned (whether successful, erroneous, or timed out),
- * the thread re-enters the {@link TargetExecutionState#STOPPED} state. In most circumstances, this
- * workaround is unnoticeable. When it does time out, it is usually because the remote thread is
- * actually running. When it times out, the client will go out of sync. However, when the step
- * completes on the remote side, it will generate a notification. The reason may not make sense, but
- * at least the client and server will be back in sync.
- *
- * 2) It may not be possible to attach to a multi-threaded process. SCTL's {@code Tattach} request
- * accepts only a PID, not a thread ID, but it {@code Rattach} response only gives a single CTLID,
- * which corresponds to a single thread. Thus, it's impossible to attach to a multi-threaded process
- * without a workaround. For the standard sctl server, there is no workaround. In fact, the server
- * behaves oddly and may crash in these circumstances. A workaround if SCTL-bus is used is for the
- * server to synthesize additional {@code Tattach} requests for the same PID, providing a unique
- * CTLID in the {@code Rattach} for each thread. This may seem odd, though, since the repeated
- * requests all look identical, but it works well.
- *
- * 3) Ghidra does not (yet) support or understand the snapshot command. This is one of the hallmarks
- * of SCTL, but this feature is not necessary to synchronize the GUI with the debugger's CLI. This
- * client implementation does, however, correctly interpret snapshot requests, replies, and
- * notifications sent by other clients on the SCTL-bus. It will create a copy of the target, as
- * specified by SCTL, but it will be presented to Ghidra as a fork event. Use of this feature would
- * require a SCTL-bus to standard SCTL proxy, or a bus-aware process control server that implements
- * snapshots.
- *
- * 4) SCTL only transfers a fixed set of x86 registers. It currently provides no mechanism to
- * request other arbitrary registers. As a result, this client only supports x86 architectures
- * (including x86_64), and only those specific registers may be read or written. Future versions
- * will likely introduce a more generic "dialect" of SCTL, permitting the client to control targets
- * of any architecture and access all known registers. The protocol is also currently limited to
- * registers of at most 64 bits.
- *
- * 5) SCTL only allows reading and writing bytes to a single memory. Granted, there is a lot of
- * flexibility in mapping addresses to a single spaces, esp. with 64 address bits, but this can lead
- * to confusion if the client and server do not agree on the mapping scheme. Currently, this is not
- * an issue, since x86 supports only one memory. As new architectures are added, this design
- * limitation must be addressed. Notably, the {@code Tread} request has an {@code fd[8]} field,
- * which might be used to encode alternative address spaces.
- *
- * 6) SCTL allows the client to request any arbitrary type known to a given namespace. The Ghidra
- * {@link LegacyDebuggerClient} API does not support this. A type can only be retrieved via a
- * {@link TargetSymbol} object or by requesting all types. Thus, a type that is never used cannot be
- * retrieved singly.
- *
- * 7) This client introduces two assumptions to Ghidra's debugging model. Threads belonging to the
- * same process share the same memory and namespaces. Suppose a process contains threads A and B. If
- * A loads a new library, that same library is assumed to be available in B. If memory is read from
- * A, it is stored in a cache shared with B. This assumption should be true for processes on x86
- * Linux. When other systems are supported, these assumptions may need to be re-addressed.
- *
- * 8) SCTL provides a means of transferring data types and their definitions, if available, from the
- * target. It even provides descriptions of the base C data types. Currently, those base
- * descriptions are ignored in favor of what is defined by Ghidra's language modules. Furthermore,
- * bit fields are not yet supported by Ghidra, yet SCTL can describe them, so they are simply not
- * converted.
- */
-public class SctlClient extends AbstractDebuggerObjectModel {
- private static final int MAX_OUTSTANDING_REQUESTS = 1000;
- private static final int REQUEST_TIMEOUT_MILLIS = Integer.MAX_VALUE; // TODO: Consider no timeout
-
- private enum ConnectionState {
- INITIAL(false, false),
- CONNECTING(true, false),
- CONNECTED(true, false),
- DISCONNECTED(false, true);
-
- final boolean isOpen;
- final boolean isTerminate;
-
- ConnectionState(boolean isOpen, boolean isTerminate) {
- this.isOpen = isOpen;
- this.isTerminate = isTerminate;
- }
- }
-
- protected class SctlPairingCache extends AsyncPairingCache<Integer, SctlPacket> {
- public SctlPairingCache() {
- super(4, REQUEST_TIMEOUT_MILLIS, MAX_OUTSTANDING_REQUESTS);
- }
-
- @Override
- protected void resultRemoved(RemovalNotification<Integer, SctlPacket> rn) {
- if (rn.wasEvicted()) {
- Msg.error(this,
- "Received SCTL reply for unmatched tag: " + rn.getKey());
- }
- }
-
- @Override
- protected void promiseRemoved(
- RemovalNotification<Integer, CompletableFuture<SctlPacket>> rn) {
- if (rn.wasEvicted()) {
- String message =
- "Command with tag " + rn.getKey() + " evicted because " + rn.getCause();
- Msg.error(this, message);
- // This thread may hold a lock. Offload completion to avoid deadlocks.
- AsyncUtils.FRAMEWORK_EXECUTOR.execute(
- () -> rn.getValue().completeExceptionally(new TimeoutException(message)));
- }
- }
- }
-
- private Collection<SctlDialect> restrictedDialects = SctlVersionInfo.KNOWN_DIALECTS;
-
- private ConnectionState connectionState = ConnectionState.INITIAL;
- private final String description;
- private final AsynchronousPacketChannel<AbstractSelSctlPacket, AbstractSelSctlPacket> packetChannel;
- private final SctlMarshaller marshaller = new SctlMarshaller();
-
- private SctlDialect activeDialect = SctlDialect.NULL_DIALECT;
-
- private int idOnBus = 0;
- private int nextTag = 0;
-
- // TODO: These are meant to be per-object, not global
- protected final ListenerSet<TargetObjectListener> listenersObject =
- new ListenerSet<>(TargetObjectListener.class);
-
- protected final SctlTargetSession session;
-
- private final SctlPairingCache packetMatcher = new SctlPairingCache();
-
- @Internal
- public final DebuggerAddressMapper addrMapper;
-
- /**
- * Construct a new client on the given channel with the given address mapper
- *
- * SCTL is usually carried over TCP/IP. More than likely, {@code channel} should be an instance
- * of {@link AsynchronousSocketChannel} that is already connected to the server. Though the TCP
- * connection should already be established, no other messages should be sent before the channel
- * is given to the client. The client will perform the SCTL version negotiation upon calling
- * {@link #connect()}. To close the SCTL connection, simply close the channel. By
- * {@link LegacyDebuggerClient} convention, {@link #disconnect()} should be called before
- * closing the channel.
- *
- * @param channel a channel connected to the process control server
- * @param addrMapper a mapper of Ghidra addresses to debugger addresses
- */
- public SctlClient(String description, AsynchronousByteChannel channel,
- DebuggerAddressMapper addrMapper) {
- this.description = description;
- this.packetChannel = new AsynchronousPacketDebugChannel<>(channel, marshaller);
- marshaller.setPacketFactory(activeDialect.getPacketFactory());
- this.addrMapper = addrMapper;
- this.session = new SctlTargetSession(this);
- }
-
- /**
- * Construct a new client on the given channel with the default address mapper
- *
- * @see #SctlClient(AsynchronousByteChannel, DebuggerAddressMapper)
- * @param channel a channel connected to the process control server
- */
- public SctlClient(String description, AsynchronousByteChannel channel) {
- this(description, channel, DefaultDebuggerAddressMapper.INSTANCE);
- }
-
- public SctlClient setDialects(SctlDialect... dialects) {
- return this.setDialects(Arrays.asList(dialects));
- }
-
- public SctlClient setDialects(Collection<SctlDialect> dialects) {
- this.restrictedDialects = dialects;
- return this;
- }
-
- /**
- * Change the client's SCTL-bus ID
- *
- * This concept is an extension to SCTL. When multiple clients are issuing commands, the bus ID
- * allows each client to identify the other clients. This does not often need to be changed.
- * Future versions may incorporate a mechanism for changing this automatically to avoid ID
- * conflicts among multiple clients.
- *
- * @param idOnBus the new ID
- */
- public void setIdOnBus(int idOnBus) {
- this.idOnBus = idOnBus;
- }
-
- /**
- * Get the client's SCTL-bus ID
- *
- * @see #setIdOnBus(int)
- * @return the current bus ID
- */
- public int getIdOnBus() {
- return idOnBus;
- }
-
- @Override
- public boolean isAlive() {
- return connectionState == ConnectionState.CONNECTED;
- }
-
- protected void checkOpen() {
- if (!connectionState.isOpen) {
- throw new SctlError("Connection is not open");
- }
- }
-
- protected void fireConnectionEstablished() {
- connectionState = ConnectionState.CONNECTED;
- listeners.fire.modelOpened();
- }
-
- protected void fireConnectionClosed(DebuggerModelClosedReason reason) {
- connectionState = ConnectionState.DISCONNECTED;
- packetMatcher.flush(new SctlError("Client disconnected while waiting for reply"));
- listeners.fire.modelClosed(reason);
- }
-
- protected <T> T reportOthersErrors(Throwable exc) {
- Msg.info(this, "Ignoring an error caused by another controller: " + exc);
- return null;
- }
-
- /**
- * Handle a request sent by another client
- *
- * This just prepares the client to receive the server's response and process both as if this
- * client sent the original request.
- *
- * @param tag the tag of the request
- * @param sel the request
- */
- private void processBusRequest(int tag, AbstractSctlRequest sel) {
- //Msg.debug(this, "Bus: " + sel);
- if (!activeDialect.isBusSupported()) {
- Msg.error(this,
- "This SCTL channel is not a bus. Nevertheless, the controller received a request.");
- return;
- }
-
- int id = (tag >> 24) & 0x0ff;
- if (id == idOnBus) {
- Msg.warn(this,
- "There appears to be another controller with my id (" + id + ") on this bus");
- }
- //Msg.info(this, "Controller " + id + " sent: " + sel);
- final CompletableFuture<?> future;
- if (sel instanceof SctlVersionRequest) {
- future = processBusConnect(tag, (SctlVersionRequest) sel);
- }
- else if (sel instanceof SctlPingRequest) {
- future = processBusPing(tag, (SctlPingRequest) sel);
- }
- else if (sel instanceof SctlExecuteRequest) {
- future = processBusExecute(tag, (SctlExecuteRequest) sel);
- }
- else if (sel instanceof SctlProcessListRequest) {
- future = processBusListAttachable(tag, (SctlProcessListRequest) sel);
- }
- else if (sel instanceof SctlStatusRequest) {
- future = processBusStat(tag, (SctlStatusRequest) sel);
- }
- else if (sel instanceof SctlAttachRequest) {
- future = processBusAttach(tag, (SctlAttachRequest) sel);
- }
- else if (sel instanceof SctlLaunchRequest) {
- future = processBusLaunch(tag, (SctlLaunchRequest) sel);
- }
- else if (sel instanceof SctlContinueRequest) {
- future = processBusResume(tag, (SctlContinueRequest) sel);
- }
- else if (sel instanceof SctlStepRequest) {
- future = processBusStep(tag, (SctlStepRequest) sel);
- }
- else if (sel instanceof SctlSnapshotRequest) {
- future = processBusSnap(tag, (SctlSnapshotRequest) sel);
- }
- else if (sel instanceof SctlStopRequest) {
- future = processBusInterrupt(tag, (SctlStopRequest) sel);
- }
- else if (sel instanceof SctlReadRequest) {
- future = processBusReadMemory(tag, (SctlReadRequest) sel);
- }
- else if (sel instanceof SctlWriteRequest) {
- future = processBusWriteMemory(tag, (SctlWriteRequest) sel);
- }
- else if (sel instanceof SctlGetContextRequest) {
- future = processBusGetContext(tag, (SctlGetContextRequest) sel);
- }
- else if (sel instanceof SctlSetContextRequest) {
- future = processBusSetContext(tag, (SctlSetContextRequest) sel);
- }
- else if (sel instanceof SctlEnumerateContextRequest) {
- future = processBusEnumerateContext(tag, (SctlEnumerateContextRequest) sel);
- }
- else if (sel instanceof SctlChooseContextRequest) {
- future = processBusChooseContext(tag, (SctlChooseContextRequest) sel);
- }
- else if (sel instanceof SctlSetTrapRequest) {
- future = processBusSetTrap(id, tag, (SctlSetTrapRequest) sel);
- }
- else if (sel instanceof SctlClearTrapRequest) {
- future = processBusClearTrap(tag, (SctlClearTrapRequest) sel);
- }
- else if (sel instanceof SctlDetachRequest) {
- future = processBusDetachThread(tag, (SctlDetachRequest) sel);
- }
- else if (sel instanceof SctlKillRequest) {
- future = processBusKillThread(tag, (SctlKillRequest) sel);
- }
- else if (sel instanceof SctlTraceRequest) {
- future = processBusTraceEvents(tag, (SctlTraceRequest) sel);
- }
- else if (sel instanceof SctlLookupSymbolRequest) {
- SctlLookupSymbolRequest looksym = (SctlLookupSymbolRequest) sel;
- SctlTargetModule ns = session.processes.getModule(looksym.nsid);
- if (ns == null) {
- future = processUnknownNSID(id, tag, looksym.nsid, sel);
- }
- else {
- future = ns.symbols.processBusGetSymbol(tag, looksym);
- }
- }
- else if (sel instanceof SctlEnumerateSymbolsRequest) {
- SctlEnumerateSymbolsRequest enumsym = (SctlEnumerateSymbolsRequest) sel;
- SctlTargetModule ns = session.processes.getModule(enumsym.nsid);
- if (ns == null) {
- future = processUnknownNSID(id, tag, enumsym.nsid, sel);
- }
- else {
- future = ns.symbols.processBusGetAllSymbols(tag, enumsym);
- }
- }
- else if (sel instanceof SctlLookupTypeRequest) {
- SctlLookupTypeRequest looktype = (SctlLookupTypeRequest) sel;
- SctlTargetModule ns = session.processes.getModule(looktype.nsid);
- if (ns == null) {
- future = processUnknownNSID(id, tag, looktype.nsid, sel);
- }
- else {
- future = ns.types.processBusGetTypeDef(tag, looktype);
- }
- }
- else if (sel instanceof SctlEnumerateSymbolsRequest) {
- SctlEnumerateTypesRequest enumtype = (SctlEnumerateTypesRequest) sel;
- SctlTargetModule ns = session.processes.getModule(enumtype.nsid);
- if (ns == null) {
- future = processUnknownNSID(id, tag, enumtype.nsid, sel);
- }
- else {
- future = ns.types.processBusGetAllTypeDefs(tag, enumtype);
- }
- }
- else if (sel instanceof SctlFocusRequest) {
- future = processBusFocusThread(tag, (SctlFocusRequest) sel);
- }
- else if (sel instanceof SctlGetAttributesRequest) {
- future = processBusGetAttributes(tag, (SctlGetAttributesRequest) sel);
- }
- else if (sel instanceof SctlGetElementsRequest) {
- future = processBusGetElements(tag, (SctlGetElementsRequest) sel);
- }
- else {
- future = processBusUnknown(id, tag, sel);
- }
- future.exceptionally(this::reportOthersErrors);
- }
-
- private void processEventNotifyListsLibraries(long ctlid, TargetExecutionState state,
- AbstractSctlListsLibrariesEventNotification lists) {
-
- // Use module names to decide whether or not to invalidate our stat
- List<String> moduleNames = new ArrayList<>();
- for (PathBase lib : lists.libs) {
- moduleNames.add(lib.path.str);
- }
-
- SctlTargetThread thread = session.processes.requireThread(ctlid);
- try {
- thread.registers.updateContextIfPresent(lists.getCtx());
-
- // NOTE: no nsids are provided with the lib paths, so just re-stat
- if (!thread.process.modules.getCachedElements().keySet().containsAll(moduleNames)) {
- thread.process.invalidateStat();
- }
- }
- finally {
- thread.setState(state);
- }
- }
-
- private void processEventNotifyForkClone(long ctlid, TargetExecutionState state,
- AbstractSctlForkCloneNotification fc, String reason) {
- SctlTargetThread thread = session.processes.requireThread(ctlid);
- try {
- thread.registers.updateContextIfPresent(fc.getCtx());
-
- SctlTargetProcess spwnProc;
- if (fc instanceof AbstractSctlForkNotification) {
- AbstractSctlForkNotification forked = (AbstractSctlForkNotification) fc;
- Long pid = forked.supportsProcessID() ? forked.getProcessID() : null;
- spwnProc = session.processes.create(forked.spwnid, pid, thread.process.platform);
- }
- else {
- spwnProc = thread.process;
- }
- SctlTargetThread spwnThread = spwnProc.createThread(fc.spwnid, reason);
- spwnThread.registers.updateContextIfPresent(fc.spwnctx);
- spwnThread.copyBreakpointsFrom(thread);
- // NOTE: Adding a breakpoint action post-clone/-fork, applies only to one thread
- }
- finally {
- thread.setState(state);
- }
- }
-
- private void processEventNotifyTrap(long ctlid, TargetExecutionState state,
- SctlTrapNotification trapped) {
- SctlTargetThread thread = session.processes.requireThread(ctlid);
- try {
- thread.registers.updateContextIfPresent(trapped.getCtx());
-
- SctlTargetBreakpoint bpt = thread.breakpoints.getByTrpid(trapped.trpid);
- if (bpt == null) {
- throw new NoSuchElementException("Trap " + trapped.trpid + " is not known");
- }
- bpt.hit();
- }
- finally {
- thread.setState(state);
- }
- }
-
- private void processEventNotifySnap(long ctlid, TargetExecutionState state,
- AbstractSctlSnapNotification snapped) {
- SctlTargetThread thread = session.processes.requireThread(ctlid);
- try {
- thread.registers.updateContextIfPresent(snapped.getCtx());
- Long pid = snapped.supportsProcessID() ? snapped.getProcessID() : null;
-
- // Create a handle for the new process and thread
- SctlTargetProcess snapProc =
- session.processes.create(snapped.spwnid, pid, thread.process.platform);
- SctlTargetThread snapThread = snapProc.createThread(snapped.spwnid, "Snapshotted");
- // The two should have the same context, so no spwnctx
- snapThread.registers.updateContextIfPresent(snapped.getCtx());
-
- // Snap events happen because of "snap points"
- SctlTargetBreakpoint bpt = thread.breakpoints.getByTrpid(snapped.trpid);
- if (bpt == null) {
- throw new NoSuchElementException("Trap " + snapped.trpid + " is not known");
- }
- bpt.hit();
- }
- finally {
- thread.setState(state);
- }
- }
-
- private void processEventNotifyExit(long ctlid, TargetExecutionState state,
- SctlExitNotification exit) {
- SctlTargetThread thread = session.processes.requireThread(ctlid);
- try {
- thread.registers.updateContextIfPresent(exit.getCtx());
-
- thread.setExitStatusCode(exit.status);
- thread.destroy("Exited");
- }
- finally {
- thread.setState(state);
- }
- }
-
- private void processEventNotifyExec(long ctlid, TargetExecutionState state,
- SctlExecNotification exec) {
- SctlTargetThread thread = session.processes.requireThread(ctlid);
- try {
- thread.registers.updateContextIfPresent(exec.getCtx());
-
- // Destroy all but the calling thread, according to execve man page
- // NOTE: Sctl assumes the client knows that exec destroys all other threads
- thread.process.threads.removeOthers(thread, "Other execed");
- thread.process.invalidateStat(); // my best guess based on what exec does
- thread.breakpoints.clear(); // From the SCTL manual
- }
- finally {
- thread.setState(state);
- }
- }
-
- private void processEventNotifySignal(long ctlid, TargetExecutionState state,
- SctlSignalNotification signal) {
- SctlTargetThread thread = session.processes.requireThread(ctlid);
- try {
- thread.registers.updateContextIfPresent(signal.getCtx());
- }
- finally {
- thread.setState(state);
- }
- }
-
- private void processEventNotifySyscall(long ctlid, TargetExecutionState state,
- SctlSyscallNotification syscall) {
- SctlTargetThread thread = session.processes.requireThread(ctlid);
- try {
- thread.registers.updateContextIfPresent(syscall.getCtx());
- }
- finally {
- thread.setState(state);
- }
- }
-
- private void processEventNotify(SctlEventNotify sel) {
- //Msg.debug(this, "Event: " + sel);
-
- Set<AbstractSctlEventNotification> events = sel.getAllEvents();
- if (events.size() > 1) {
- Msg.warn(this, "More than one event in a notification....: " + events);
- }
- AbstractSctlEventNotification details = events.iterator().next();
- TargetExecutionState state = activeDialect.stateAfterEvent(sel.flags);
- if (details instanceof AbstractSctlListsLibrariesEventNotification) {
- processEventNotifyListsLibraries(sel.ctlid, state,
- (AbstractSctlListsLibrariesEventNotification) details);
- }
- else if (details instanceof AbstractSctlForkNotification) {
- processEventNotifyForkClone(sel.ctlid, state,
- (AbstractSctlForkNotification) details, "Forked");
- }
- else if (details instanceof SctlCloneNotification) {
- processEventNotifyForkClone(sel.ctlid, state,
- (SctlCloneNotification) details, "Cloned");
- }
- else if (details instanceof SctlTrapNotification) {
- processEventNotifyTrap(sel.ctlid, state, (SctlTrapNotification) details);
- }
- else if (details instanceof Sctl2012SnapNotification) {
- processEventNotifySnap(sel.ctlid, state, (Sctl2012SnapNotification) details);
- }
- else if (details instanceof SctlExitNotification) {
- processEventNotifyExit(sel.ctlid, state, (SctlExitNotification) details);
- }
- else if (details instanceof SctlExecNotification) {
- processEventNotifyExec(sel.ctlid, state, (SctlExecNotification) details);
- }
- else if (details instanceof SctlSignalNotification) {
- processEventNotifySignal(sel.ctlid, state, (SctlSignalNotification) details);
- }
- else if (details instanceof SctlSyscallNotification) {
- processEventNotifySyscall(sel.ctlid, state, (SctlSyscallNotification) details);
- }
- else {
- throw new IllegalArgumentException("details of type " + details.getClass().toString());
- }
- }
-
- /**
- * Generate the next tag
- *
- * This always generates a tag in the SCTL-bus form. Even in non-bus dialects. Since the server
- * need only echo the same tag in the reply, this should be backward compatible.
- *
- * @return the next tag
- */
- @SctlExtension("This generates bus tags, but they are compatible with non-bus tags")
- private synchronized int tag() {
- int result = nextTag;
- nextTag++;
- // This scheme should not cause a problem for non-bus implementations
- // TODO: Should I just incorporate this directly into the packet structure?
- nextTag &= 0x00ffffff;
- return result | (idOnBus << 24);
- }
-
- /**
- * Performs generic checks on a SCTL reply
- *
- * Namely, this checks if the reply is an {@code Rerror}. If it is, it copies the message and
- * throws a {@link SctlError}. Then, it checks if the reply is of the expected type. If not, it
- * throws a {@link SctlIncorrectReply}. Otherwise, it returns the reply cast to the expected
- * type.
- *
- * @param cmd the command whose tag matches that of the reply
- * @param pktType the expected type of the reply
- * @param reply the reply actually received
- * @return the reply cast to the expected type
- * @throws SctlError if the reply is an {@code Rerror}
- * @throws SctlIncorrectReply if the reply is not of the expected type
- */
- protected static <R extends SctlPacket> R checkReply(SctlPacket cmd, Class<R> pktType,
- SctlPacket reply) {
- if (reply instanceof SctlErrorReply) {
- throw new SctlError((SctlErrorReply) reply);
- }
- if (pktType.isAssignableFrom(reply.getClass())) {
- return pktType.cast(reply);
- }
- throw new SctlIncorrectReply(cmd, reply);
- }
-
- /*
- * Methods for Tversion
- */
-
- public CompletableFuture<Void> connect() {
- SctlVersionRequest req = SctlVersionInfo.makeRequest(restrictedDialects);
- return sequence(TypeSpec.VOID).then((seq) -> {
- if (connectionState != ConnectionState.INITIAL) {
- throw new SctlError("Client has already connected");
- }
- Msg.trace(this, "Connecting");
-
- connectionState = ConnectionState.CONNECTING;
- CompletableFuture<SctlPacket> cmd = sendCommand(req);
- cmd.handle(seq::next);
- // receive loop is not yet running, so receive exactly the version reply in parallel
- packetChannel.read(AbstractSelSctlPacket.class).thenAccept((pkt) -> {
- packetMatcher.fulfill(pkt.tag, pkt.sel);
- });
- }, TypeSpec.cls(SctlPacket.class)).then((reply, seq) -> {
- SctlVersionReply version = finishConnect(req, reply);
- // This doesn't go in finishConnect, because a bus connect is not our connect
- SctlDialect dialect = SctlVersionInfo.agreeDialect(version.version);
- synchronized (this) {
- activeDialect = dialect;
- marshaller.setPacketFactory(dialect.getPacketFactory());
- }
- receiveLoop(); // in parallel. Performs command callbacks
- fireConnectionEstablished();
- seq.exit();
- }).finish();
- }
-
- private CompletableFuture<Void> processBusConnect(int tag, SctlVersionRequest req) {
- return sequence(TypeSpec.VOID).then((seq) -> {
- recvTag(tag).handle(seq::next);
- }, TypeSpec.cls(SctlPacket.class)).then((reply, seq) -> {
- finishConnect(req, reply);
- seq.exit();
- }).finish();
- }
-
- private SctlVersionReply finishConnect(SctlVersionRequest req, SctlPacket reply) {
- return checkReply(req, SctlVersionReply.class, reply);
- }
-
- /*
- * Misc message-handling
- */
-
- private void receiveLoop() {
- loop(TypeSpec.VOID, (loop) -> {
- if (connectionState.isTerminate) {
- loop.exit();
- return;
- }
- //Msg.trace(this, "Queueing receive");
- packetChannel.read(AbstractSelSctlPacket.class).handle(loop::consume);
- }, TypeSpec.cls(AbstractSelSctlPacket.class), (rcvd, loop) -> {
- loop.repeat(); // Don't get hung up servicing listeners before processing next packet
- //Msg.debug(this, "Received: " + rcvd);
-
- if (rcvd.sel instanceof SctlEventNotify) {
- processEventNotify((SctlEventNotify) rcvd.sel);
- }
- else if (rcvd.sel instanceof AbstractSctlRequest) {
- processBusRequest(rcvd.tag, (AbstractSctlRequest) rcvd.sel);
- }
- else {
- packetMatcher.fulfill(rcvd.tag, rcvd.sel);
- }
- }).exceptionally((exc) -> {
- if (exc instanceof CompletionException) {
- exc = exc.getCause();
- }
- if (exc instanceof NotYetConnectedException) {
- throw new AssertionError("INTERNAL: Connect first, please", exc);
- }
- else if (exc instanceof EOFException) {
- Msg.error(this, "Server closed connection");
- fireConnectionClosed(DebuggerModelClosedReason.abnormal(exc));
- }
- else if (exc instanceof ClosedChannelException) {
- Msg.info(this, "Client closed connection");
- connectionState = ConnectionState.DISCONNECTED;
- }
- else if (exc instanceof CancelledKeyException) {
- Msg.info(this, "Terminating receive loop: Connection closed.");
- connectionState = ConnectionState.DISCONNECTED;
- }
- else {
- Msg.error(this, "Receive failed for an unknown reason", exc);
- fireConnectionClosed(DebuggerModelClosedReason.abnormal(exc));
- }
- return null;
- });
- }
-
- @Override
- public CompletableFuture<Void> close() {
- connectionState = ConnectionState.DISCONNECTED;
- fireConnectionClosed(DebuggerModelClosedReason.normal());
- // No close notifications to send, and I'm not responsible to close the channel
- return AsyncUtils.NIL;
- }
-
- /**
- * Send the given command and wait on its reply
- *
- * The method follows the asynchronous pattern: It immediately returns a future that will
- * complete at a later time. It completes with the corresponding reply received from the server.
- * This is accomplished using an {@link AsyncPairingCache} on the tag. A tag is assigned
- * automatically, and the cache matches it to that of the received reply. If the reply is not
- * received within a given timeout, the returned future is completed exceptionally. Multiple
- * commands may be sent before any reply is received.
- *
- * @param cmd the command to send
- * @return a future that completes with the corresponding reply
- */
- protected CompletableFuture<SctlPacket> sendCommand(SctlPacket cmd) {
- AbstractSelSctlPacket pkt = activeDialect.createSel(tag(), cmd);
- //Msg.debug(this, "Sending: " + pkt);
- checkOpen();
- return packetChannel.write(pkt).thenCompose(__ -> {
- //Msg.trace(this, "Sent tag " + pkt.tag);
- checkOpen();
- return packetMatcher.waitOn(pkt.tag);
- });
- }
-
- /**
- * Wait for a reply to a command that is not sent by this client
- *
- * This method is used for bus commands. It can also be used in circumstances where the command
- * is sent by some means other than {@link #sendCommand(SctlPacket)}. It does the same thing
- * without sending any command. It returns a future which completes with the reply having the
- * given tag.
- *
- * @param tag the tag from the command
- * @return a future that completes with the corresponding reply
- */
- protected CompletableFuture<SctlPacket> recvTag(int tag) {
- return sequence(TypeSpec.cls(SctlPacket.class)).then(seq -> {
- checkOpen();
- packetMatcher.waitOn(tag).handle(seq::exit);
- }).finish();
- }
-
- /*
- * Methods for Tping
- */
-
- @Override
- public CompletableFuture<Void> ping(String content) {
- SctlPingRequest req = new SctlPingRequest(content);
- return sequence(TypeSpec.VOID).then((seq) -> {
- sendCommand(req).handle(seq::next);
- }, TypeSpec.cls(SctlPacket.class)).then((reply, seq) -> {
- finishPing(req, reply);
- seq.exit();
- }).finish();
- }
-
- private CompletableFuture<Void> processBusPing(int tag, SctlPingRequest req) {
- return sequence(TypeSpec.VOID).then((seq) -> {
- recvTag(tag).handle(seq::next);
- }, TypeSpec.cls(SctlPacket.class)).then((reply, seq) -> {
- finishPing(req, reply);
- seq.exit();
- }).finish();
- }
-
- protected void finishPing(SctlPingRequest req, SctlPacket reply) {
- SctlPingReply pinged = checkReply(req, SctlPingReply.class, reply);
- int expected = req.bytes.length;
- if (pinged.cnt != expected) {
- throw new SctlIncorrectPingResponse(req.bytes, expected, (int) pinged.cnt);
- }
- }
-
- /*
- * Methods for Texec
- *
- * NOTE: This command is not actually part of the SCTL specification.
- */
-
- @SctlExtension("requests execution of a CLI command")
- protected CompletableFuture<String> executeCapture(String cmd) {
- SctlExecuteRequest req = new SctlExecuteRequest(cmd);
- return sequence(TypeSpec.STRING).then((seq) -> {
- sendCommand(req).handle(seq::next);
- }, TypeSpec.cls(SctlPacket.class)).then((reply, seq) -> {
- seq.exit(finishExecute(req, reply));
- }).finish();
- }
-
- private CompletableFuture<String> processBusExecute(int tag, SctlExecuteRequest req) {
- return sequence(TypeSpec.STRING).then((seq) -> {
- recvTag(tag).handle(seq::next);
- }, TypeSpec.cls(SctlPacket.class)).then((reply, seq) -> {
- seq.exit(finishExecute(req, reply));
- }).finish();
- }
-
- protected String finishExecute(SctlExecuteRequest req, SctlPacket reply) {
- SctlExecuteReply executed = SctlClient.checkReply(req, SctlExecuteReply.class, reply);
- return executed.out.str;
- }
-
- /*
- * Methods for Tps
- */
- protected CompletableFuture<List<SctlTargetAttachable>> listAttachable() {
- SctlProcessListRequest req = new SctlProcessListRequest();
- return sequence(TypeSpec.cls(SctlTargetAttachable.class).list()).then((seq) -> {
- sendCommand(req).handle(seq::next);
- }, TypeSpec.cls(SctlPacket.class)).then((reply, seq) -> {
- seq.exit(finishListAttachable(req, reply));
- }).finish();
- }
-
- protected List<SctlTargetAttachable> finishListAttachable(SctlProcessListRequest req,
- SctlPacket reply) {
- SctlProcessListReply procs = SctlClient.checkReply(req, SctlProcessListReply.class, reply);
- return readProcessList(procs);
- }
-
- private CompletableFuture<List<SctlTargetAttachable>> processBusListAttachable(int tag,
- SctlProcessListRequest req) {
- return sequence(TypeSpec.cls(SctlTargetAttachable.class).list()).then((seq) -> {
- recvTag(tag).handle(seq::next);
- }, TypeSpec.cls(SctlPacket.class)).then((reply, seq) -> {
- seq.exit(finishListAttachable(req, reply));
- }).finish();
- }
-
- protected List<SctlTargetAttachable> readProcessList(SctlProcessListReply reply) {
- List<? extends AbstractSctlProcessEntry> procList = reply.pslist.getProcesses();
- List<SctlTargetAttachable> result = new ArrayList<>(procList.size());
- for (AbstractSctlProcessEntry procEnt : procList) {
- result.add(new SctlTargetAttachable(session.attachable, procEnt.getProcessID(),
- procEnt.getCommand()));
- }
- session.attachable.changeElements(List.of(), result, "Retreived process list");
- return result;
- }
-
- /*
- * Methods for Tstat
- */
-
- // Doesn't return anything, rather updates internal info
- protected CompletableFuture<Void> stat(long ctlid) {
- SctlStatusRequest req = new SctlStatusRequest(ctlid);
- return sequence(TypeSpec.VOID).then((seq) -> {
- sendCommand(req).handle(seq::next);
- }, TypeSpec.cls(SctlPacket.class)).then((reply, seq) -> {
- finishStat(req, reply);
- seq.exit();
- }).finish();
- }
-
- private CompletableFuture<Void> processBusStat(int tag, SctlStatusRequest req) {
- return sequence(TypeSpec.VOID).then((seq) -> {
- recvTag(tag).handle(seq::next);
- }, TypeSpec.cls(SctlPacket.class)).then((reply, seq) -> {
- finishStat(req, reply);
- seq.exit();
- }).finish();
- }
-
- protected void finishStat(SctlStatusRequest req, SctlPacket reply) {
- SctlStatusReply stats = checkReply(req, SctlStatusReply.class, reply);
- //Msg.info(this, stats);
- synchronized (this) {
- SctlTargetProcess proc = session.processes.getByCtlid(req.ctlid);
- if (proc == null) {
- Msg.warn(this, "Process removed before stat reply: ctlid=" + req.ctlid);
- return;
- }
- populateStat(proc, stats.status);
- }
- }
-
- protected void populateStat(SctlTargetProcess proc, AbstractSctlStatus status) {
- if (status.supportsProcessID()) {
- proc.setPid(status.getProcessID());
- }
-
- for (AbstractSctlRegion region : status.getRegions()) {
- try {
- proc.createMemoryRegion(region.getName(), region.getAddress(), region.getLength(),
- region.getProtections());
- }
- catch (AddressOverflowException e) {
- Msg.error(this, "Invalid region in SCTL response: " + region.getName() + ": " + e);
- }
- }
-
- for (AbstractSctlBinary bin : status.getBinaries()) {
- Address base = null;
- if (bin.supportsBase()) {
- base = addrMapper.mapOffsetToAddress(bin.getBase());
- }
- SctlTargetModule mod =
- proc.modules.create(bin.getNamespaceID(), bin.getPath(), base, bin.isExecutable());
- if (bin.supportsSections()) {
- for (AbstractSctlSection s : bin.getSections()) {
- Address start = addrMapper.mapOffsetToAddress(s.getAddress());
- mod.addSection(s.getName(), start, s.getLength());
- }
- mod.updateRange();
- }
- }
- }
-
- /*
- * Methods for Tattach
- */
-
- protected CompletableFuture<SctlTargetThread> attach(long pid) {
- SctlAttachRequest req = new SctlAttachRequest(pid);
- return sequence(TypeSpec.cls(SctlTargetThread.class)).then((seq) -> {
- sendCommand(req).handle(seq::next);
- }, TypeSpec.cls(SctlPacket.class)).then((reply, seq) -> {
- seq.exit(finishAttach(req, reply));
- }).finish();
- }
-
- private CompletableFuture<SctlTargetThread> processBusAttach(int tag, SctlAttachRequest req) {
- return sequence(TypeSpec.cls(SctlTargetThread.class)).then((seq) -> {
- recvTag(tag).handle(seq::next);
- }, TypeSpec.cls(SctlPacket.class)).then((reply, seq) -> {
- seq.exit(finishAttach(req, reply));
- }).finish();
- }
-
- protected SctlTargetThread finishAttach(SctlAttachRequest req, SctlPacket reply) {
- AbstractSctlAttachReply attached = checkReply(req, AbstractSctlAttachReply.class, reply);
- SctlTargetProcess proc = session.processes.getByPid(req.pid);
- if (proc == null) {
- String platform = attached.supportsPlatform() ? attached.getPlatform()
- : activeDialect.getSolePlatform();
- proc = session.processes.create(attached.ctlid, req.pid, platform);
- }
- SctlTargetThread newThread = proc.createThread(attached.ctlid, "Attached");
- newThread.registers.updateContextIfPresent(attached.ctx);
- return newThread;
- }
-
- /*
- * Methods for Tlaunch
- */
-
- protected CompletableFuture<SctlTargetThread> launch(List<String> args) {
- SctlLaunchRequest req = new SctlLaunchRequest(args);
- return sequence(TypeSpec.cls(SctlTargetThread.class)).then((seq) -> {
- sendCommand(req).handle(seq::next);
- }, TypeSpec.cls(SctlPacket.class)).then((reply, seq) -> {
- seq.exit(finishLaunch(req, reply));
- }).finish();
- }
-
- private CompletableFuture<SctlTargetThread> processBusLaunch(int tag, SctlLaunchRequest req) {
- return sequence(TypeSpec.cls(SctlTargetThread.class)).then((seq) -> {
- recvTag(tag).handle(seq::next);
- }, TypeSpec.cls(SctlPacket.class)).then((reply, seq) -> {
- seq.exit(finishLaunch(req, reply));
- }).finish();
- }
-
- protected SctlTargetThread finishLaunch(SctlLaunchRequest req, SctlPacket reply) {
- AbstractSctlLaunchReply launched = checkReply(req, AbstractSctlLaunchReply.class, reply);
- long ctlid = launched.ctlid;
- Long pid = launched.supportsProcessID() ? launched.getProcessID() : null;
- String platform = launched.supportsPlatform() ? launched.getPlatform()
- : activeDialect.getSolePlatform();
- SctlTargetProcess newProc = session.processes.create(ctlid, pid, platform);
- SctlTargetThread newThread = newProc.createThread(ctlid, "Launched");
- newThread.registers.updateContextIfPresent(launched.ctx);
- return newThread;
- }
-
- /*
- * Methods for Tcont
- */
-
- protected CompletableFuture<Void> resume(long ctlid) {
- SctlContinueRequest req = new SctlContinueRequest(ctlid);
- return sequence(TypeSpec.VOID).then((seq) -> {
- sendCommand(req).handle(seq::next);
- }, TypeSpec.cls(SctlPacket.class)).then((reply, seq) -> {
- finishResume(req, reply);
- seq.exit();
- }).finish();
- }
-
- private CompletableFuture<Void> processBusResume(int tag, SctlContinueRequest req) {
- return sequence(TypeSpec.VOID).then((seq) -> {
- recvTag(tag).handle(seq::next);
- }, TypeSpec.cls(SctlPacket.class)).then((reply, seq) -> {
- finishResume(req, reply);
- seq.exit();
- }).finish();
- }
-
- protected void finishResume(SctlContinueRequest req, SctlPacket reply) {
- checkReply(req, SctlContinueReply.class, reply);
- session.processes.requireThread(req.ctlid).setState(TargetExecutionState.RUNNING);
- }
-
- /*
- * Methods for Tstep
- */
-
- CompletableFuture<Void> step(long ctlid) {
- SctlStepRequest req = new SctlStepRequest(ctlid);
- return sequence(TypeSpec.VOID).then((seq) -> {
- sendCommand(req).handle(seq::next);
- // Assume it's running at this point, but I don't really know
- session.processes.requireThread(ctlid).setState(TargetExecutionState.RUNNING);
- }, TypeSpec.cls(SctlPacket.class)).then((reply, seq) -> {
- finishStep(req, reply);
- seq.exit();
- }).finish();
- }
-
- private CompletableFuture<Void> processBusStep(int tag, SctlStepRequest req) {
- return sequence(TypeSpec.VOID).then((seq) -> {
- // Assume it's running at this point, but I don't really know
- session.processes.requireThread(req.ctlid).setState(TargetExecutionState.RUNNING);
- recvTag(tag).handle(seq::next);
- }, TypeSpec.cls(SctlPacket.class)).then((reply, seq) -> {
- finishStep(req, reply);
- seq.exit();
- }).finish();
- }
-
- protected void finishStep(SctlStepRequest req, SctlPacket reply) {
- SctlTargetThread thread = session.processes.requireThread(req.ctlid);
- try {
- SctlStepReply stepped = checkReply(req, SctlStepReply.class, reply);
- thread.registers.updateContextIfPresent(stepped.ctx);
- }
- finally {
- // Assume we're stopped whether or not there's an error
- thread.setState(TargetExecutionState.STOPPED);
- }
- }
-
- /*
- * Methods for Tsnap
- */
-
- protected CompletableFuture<SctlTargetThread> snap(long ctlid) {
- SctlSnapshotRequest req = new SctlSnapshotRequest(ctlid);
- return sequence(TypeSpec.cls(SctlTargetThread.class)).then((seq) -> {
- sendCommand(req).handle(seq::next);
- }, TypeSpec.cls(SctlPacket.class)).then((reply, seq) -> {
- seq.exit(finishSnap(req, reply));
- }).finish();
- }
-
- private CompletableFuture<SctlTargetThread> processBusSnap(int tag,
- SctlSnapshotRequest req) {
- return sequence(TypeSpec.cls(SctlTargetThread.class)).then((seq) -> {
- recvTag(tag).handle(seq::next);
- }, TypeSpec.cls(SctlPacket.class)).then((reply, seq) -> {
- seq.exit(finishSnap(req, reply));
- }).finish();
- }
-
- protected SctlTargetThread finishSnap(SctlSnapshotRequest req, SctlPacket reply) {
- AbstractSctlSnapshotReply snapped = checkReply(req, AbstractSctlSnapshotReply.class, reply);
- SctlTargetThread origThread = session.processes.requireThread(req.ctlid);
- // snap is implemented via fork, so a new process!
- Long pid = snapped.supportsProcessID() ? snapped.getProcessID() : null;
- SctlTargetProcess newProc =
- session.processes.create(snapped.spwnid, pid, origThread.process.platform);
- SctlTargetThread newThread = newProc.createThread(snapped.spwnid, "Snapshotted");
- newThread.registers.updateContextIfPresent(snapped.ctx);
- return newThread;
- }
-
- /*
- * Methods for Tstop
- */
-
- protected CompletableFuture<Void> interrupt(long ctlid) {
- SctlStopRequest req = new SctlStopRequest(ctlid);
- return sequence(TypeSpec.VOID).then((seq) -> {
- sendCommand(req).handle(seq::next);
- }, TypeSpec.cls(SctlPacket.class)).then((reply, seq) -> {
- finishInterrupt(req, reply);
- seq.exit();
- }).finish();
- }
-
- private CompletableFuture<Void> processBusInterrupt(int tag, SctlStopRequest req) {
- return sequence(TypeSpec.VOID).then((seq) -> {
- recvTag(tag).handle(seq::next);
- }, TypeSpec.cls(SctlPacket.class)).then((reply, seq) -> {
- finishInterrupt(req, reply);
- seq.exit();
- }).finish();
- }
-
- protected void finishInterrupt(SctlStopRequest req, SctlPacket reply) {
- checkReply(req, SctlStopReply.class, reply);
- session.processes.requireThread(req.ctlid).setState(TargetExecutionState.STOPPED);
- }
-
- /*
- * Methods for Tread
- */
-
- protected CompletableFuture<byte[]> readMemory(long ctlid, long addr, int len) {
- SctlReadRequest req = new SctlReadRequest(ctlid, -1, addr, len);
- return sequence(TypeSpec.BYTE_ARRAY).then((seq) -> {
- sendCommand(req).handle(seq::next);
- }, TypeSpec.cls(SctlPacket.class)).then((reply, seq) -> {
- seq.exit(finishReadMemory(req, reply));
- }).finish();
- }
-
- private CompletableFuture<byte[]> processBusReadMemory(int tag, SctlReadRequest req) {
- return sequence(TypeSpec.BYTE_ARRAY).then((seq) -> {
- recvTag(tag).handle(seq::next);
- }, TypeSpec.cls(SctlPacket.class)).then((reply, seq) -> {
- byte[] data = finishReadMemory(req, reply);
- SctlTargetThread thread = session.processes.requireThread(req.ctlid);
- thread.process.memory.notifyUpdate(req.offset, data);
- seq.exit(data);
- }).finish();
- }
-
- protected byte[] finishReadMemory(SctlReadRequest req, SctlPacket reply) {
- SctlReadReply read = checkReply(req, SctlReadReply.class, reply);
- return read.bytes;
- }
-
- /*
- * Methods for Twrite
- */
-
- protected CompletableFuture<Void> writeMemory(long ctlid, long addr, byte[] data) {
- SctlWriteRequest req = new SctlWriteRequest(ctlid, -1, addr, data);
- return sequence(TypeSpec.VOID).then((seq) -> {
- sendCommand(req).handle(seq::next);
- }, TypeSpec.cls(SctlPacket.class)).then((reply, seq) -> {
- finishWriteMemory(req, reply);
- seq.exit();
- }).finish();
- }
-
- private CompletableFuture<Void> processBusWriteMemory(int tag, SctlWriteRequest req) {
- return sequence(TypeSpec.VOID).then((seq) -> {
- recvTag(tag).handle(seq::next);
- }, TypeSpec.cls(SctlPacket.class)).then((reply, seq) -> {
- finishWriteMemory(req, reply);
- SctlTargetThread thread = session.processes.requireThread(req.ctlid);
- thread.process.memory.notifyUpdate(req.offset, req.bytes);
- seq.exit();
- }).finish();
- }
-
- protected void finishWriteMemory(SctlWriteRequest req, SctlPacket reply) {
- SctlWriteReply written = checkReply(req, SctlWriteReply.class, reply);
- if (req.bytes.length != written.cnt) {
- throw new SctlPartialWriteException(req.bytes, (int) written.cnt);
- }
- }
-
- /*
- * Methods for Tgetctx
- *
- * Actually, these use the context sent by the last notification message
- */
-
- private Map<String, byte[]> checkCtxAvail(SctlTargetThread thread) {
- if (!thread.registers.hasContextSinceStop() ||
- thread.getExecutionState() != TargetExecutionState.STOPPED) {
- throw new IllegalStateException("Thread is not stopped, or has no valid context");
- }
- return thread.registers.getContext();
- }
-
- protected CompletableFuture<Map<String, byte[]>> getContext(long ctlid) {
- SctlGetContextRequest req = new SctlGetContextRequest(ctlid);
- SctlTargetThread thread = session.processes.requireThread(ctlid);
- return sequence(TypeSpec.map(String.class, byte[].class)).then(seq -> {
- sendCommand(req).handle(seq::next);
- }, TypeSpec.cls(SctlPacket.class)).then((reply, seq) -> {
- finishGetContext(req, reply);
- seq.exit(thread.registers.getContext());
- }).finish();
- }
-
- private CompletableFuture<Void> processBusGetContext(int tag, SctlGetContextRequest req) {
- return sequence(TypeSpec.VOID).then(seq -> {
- recvTag(tag).handle(seq::next);
- }, TypeSpec.cls(SctlPacket.class)).then((reply, seq) -> {
- finishGetContext(req, reply);
- seq.exit();
- }).finish();
- }
-
- protected void finishGetContext(SctlGetContextRequest req, SctlPacket reply) {
- SctlGetContextReply get = checkReply(req, SctlGetContextReply.class, reply);
- SctlTargetThread thread = session.processes.requireThread(req.ctlid);
- thread.registers.updateContextIfPresent(get.ctx);
- }
-
- protected void checkRegisterSelectionSupported() {
- if (!activeDialect.isRegisterSelectionSupported()) {
- throw new IllegalStateException(
- activeDialect.getFullVersion() + " does not support register selection");
- }
- }
-
- protected CompletableFuture<Map<String, SctlRegisterDefinition>> enumerateContext(long ctlid) {
- checkRegisterSelectionSupported();
- SctlEnumerateContextRequest req = new SctlEnumerateContextRequest(ctlid);
- return sequence(TypeSpec.map(String.class, SctlRegisterDefinition.class)).then(seq -> {
- sendCommand(req).handle(seq::next);
- }, TypeSpec.cls(SctlPacket.class)).then((reply, seq) -> {
- seq.exit(finishEnumerateContext(req, reply));
- }).finish();
- }
-
- private CompletableFuture<Void> processBusEnumerateContext(int tag,
- SctlEnumerateContextRequest req) {
- checkRegisterSelectionSupported(); // If not, we might be in deep deep doo doo
- // The server ought to also reject it, so we'll log it and pretend it didn't happen.
- SctlTargetThread thread = session.processes.requireThread(req.ctlid);
- return sequence(thread.registers.lazyRegDefs.provide()).then(seq -> {
- recvTag(tag).handle(seq::next);
- }, TypeSpec.cls(SctlPacket.class)).then((reply, seq) -> {
- seq.exit(finishEnumerateContext(req, reply));
- }).finish().thenApply(t -> null);
- }
-
- protected Map<String, SctlRegisterDefinition> finishEnumerateContext(
- SctlEnumerateContextRequest req, SctlPacket reply) {
- SctlEnumerateContextReply enumed = checkReply(req, SctlEnumerateContextReply.class, reply);
- Map<String, SctlRegisterDefinition> result = new LinkedHashMap<>();
- for (SctlRegisterDefinition def : enumed.regdefs) {
- result.put(def.name.str, def);
- }
- return result;
- }
-
- protected synchronized CompletableFuture<Void> chooseContext(long ctlid,
- Set<SctlTargetRegisterDescription> descs) {
- checkRegisterSelectionSupported();
- SctlTargetThread thread = session.processes.requireThread(ctlid);
- SctlChooseContextRequest req = new SctlChooseContextRequest(ctlid);
- List<SctlRegisterDefinition> selDefs = new ArrayList<>();
- return sequence(TypeSpec.VOID).then(seq -> {
- thread.registers.lazyRegDefs.request().handle(seq::next);
- }, TypeSpec.map(String.class, SctlRegisterDefinition.class)).then((defs, seq) -> {
- for (SctlTargetRegisterDescription trd : descs) {
- String name = trd.getName();
- SctlRegisterDefinition d = defs.get(name);
- if (d == null) {
- throw new IllegalArgumentException("No register with name " + name);
- }
- req.regids.add(d.regid);
- selDefs.add(d);
- }
- sendCommand(req).handle(seq::next);
- }, TypeSpec.cls(SctlPacket.class)).then((reply, seq) -> {
- finishChooseContext(req, reply, selDefs, descs, null, null);
- seq.exit();
- }).finish();
- }
-
- private CompletableFuture<Void> processBusChooseContext(int tag, SctlChooseContextRequest req) {
- checkRegisterSelectionSupported(); // If not, we might be in deep deep doo doo
- // The server ought to also reject it, so we'll log it and pretend it didn't happen.
- AtomicReference<SctlPacket> recvd = new AtomicReference<>();
- AtomicReference<Map<Long, SctlRegisterDefinition>> defsById = new AtomicReference<>();
- AtomicReference<Map<String, SctlTargetRegisterDescription>> descsByName =
- new AtomicReference<>();
- SctlTargetThread thread = session.processes.requireThread(req.ctlid);
- return sequence(TypeSpec.VOID).then(seq -> {
- AsyncFence fence = new AsyncFence();
- fence.include(recvTag(tag).thenAccept(recvd::set));
- fence.include(thread.registers.lazyRegDefsById.request().thenAccept(defsById::set));
- fence.include(thread.registers.lazyRegDescs.request().thenAccept(descsByName::set));
- fence.ready().handle(seq::next);
- }).then(seq -> {
- finishChooseContext(req, recvd.get(), null, null, defsById.get(), descsByName.get());
- seq.exit();
- }).finish();
- }
-
- void finishChooseContext(SctlChooseContextRequest req, SctlPacket reply,
- List<SctlRegisterDefinition> selDefs, Set<SctlTargetRegisterDescription> descs,
- Map<Long, SctlRegisterDefinition> defsById,
- Map<String, SctlTargetRegisterDescription> descsByName) {
- SctlChooseContextReply choose = checkReply(req, SctlChooseContextReply.class, reply);
- if (selDefs == null) {
- selDefs = new ArrayList<>();
- descs = new LinkedHashSet<>();
- for (long id : req.regids) {
- SctlRegisterDefinition def = defsById.get(id);
- if (def == null) {
- throw new AssertionError("Bus client chose a non-existent register id");
- }
- selDefs.add(def);
- SctlTargetRegisterDescription trd = descsByName.get(def.name.str);
- if (trd == null) {
- throw new AssertionError(); // INTERNAL consistency check
- }
- descs.add(trd);
- }
- }
- SctlTargetThread thread = session.processes.requireThread(req.ctlid);
- thread.registers.setSelectedRegisters(selDefs);
- thread.registers.updateContextIfPresent(choose.ctx);
- }
-
- protected CompletableFuture<Map<String, byte[]>> readRegisters(long ctlid) {
- SctlTargetThread thread = session.processes.requireThread(ctlid);
- if (thread.getExecutionState() == TargetExecutionState.RUNNING) {
- return CompletableFuture.failedFuture(new IllegalStateException("Thread is running"));
- }
- if (thread.registers.hasContextSinceStop()) {
- return CompletableFuture.completedFuture(thread.registers.getContext());
- }
- return getContext(ctlid);
- }
-
- protected CompletableFuture<byte[]> readSingleRegister(long ctlid, String regname) {
- return sequence(TypeSpec.BYTE_ARRAY).then(seq -> {
- readRegisters(ctlid).handle(seq::next);
- }, TypeSpec.map(String.class, byte[].class)).then((regs, seq) -> {
- byte[] val = regs.get(regname);
- if (val == null) {
- throw new IllegalArgumentException(
- "Register " + regname + " is not in the context");
- }
- seq.exit(val);
- }).finish();
- }
-
- /*
- * Methods for Tsetctx
- */
-
- protected CompletableFuture<Void> setContext(long ctlid, AbstractSctlContext ctx) {
- SctlSetContextRequest req = new SctlSetContextRequest(ctlid, ctx);
- return sequence(TypeSpec.VOID).then((seq) -> {
- sendCommand(req).handle(seq::next);
- }, TypeSpec.cls(SctlPacket.class)).then((reply, seq) -> {
- finishSetContext(req, reply);
- seq.exit();
- }).finish();
- }
-
- private CompletableFuture<Void> processBusSetContext(int tag, SctlSetContextRequest req) {
- return sequence(TypeSpec.VOID).then((seq) -> {
- recvTag(tag).handle(seq::next);
- }, TypeSpec.cls(SctlPacket.class)).then((reply, seq) -> {
- finishSetContext(req, reply);
- seq.exit();
- }).finish();
- }
-
- protected void finishSetContext(SctlSetContextRequest req, SctlPacket reply) {
- checkReply(req, SctlSetContextReply.class, reply);
- session.processes.requireThread(req.ctlid).registers.updateContextIfPresent(req.ctx);
- }
-
- protected CompletableFuture<Void> writeRegisters(long ctlid, Map<String, byte[]> vals) {
- try {
- SctlTargetThread thread = session.processes.requireThread(ctlid);
- AbstractSctlContext ctx = activeDialect.create(AbstractSctlContext.class);
- ctx.setSelectedRegisters(thread.registers.getSelectedRegisters());
-
- if (!vals.keySet().containsAll(ctx.getRegisterNames())) {
- ctx.updateFromMap(checkCtxAvail(thread));
- }
- ctx.updateFromMap(vals);
- return setContext(ctlid, ctx);
- }
- catch (Exception e) {
- return CompletableFuture.failedFuture(e);
- }
- }
-
- synchronized CompletableFuture<Void> writeSingleRegister(long ctlid, String regname,
- byte[] data) {
- try {
- SctlTargetThread thread = session.processes.requireThread(ctlid);
- AbstractSctlContext ctx = activeDialect.create(AbstractSctlContext.class);
- ctx.setSelectedRegisters(thread.registers.getSelectedRegisters());
-
- ctx.updateFromMap(checkCtxAvail(thread));
- ctx.update(regname, data);
- return setContext(ctlid, ctx);
- }
- catch (Exception e) {
- return CompletableFuture.failedFuture(e);
- }
- }
-
- /*
- * Methods for Tsettrap
- */
-
- protected CompletableFuture<SctlTargetBreakpoint> setTrap(long ctlid, Address address,
- long length, boolean read, boolean write, boolean execute) {
- AbstractSctlTrapSpec spec = activeDialect.create(AbstractSctlTrapSpec.class);
- long offset = addrMapper.mapAddressToOffset(address);
- spec.setActionStop();
- spec.setAddress(offset);
- spec.setLength(length);
- spec.setHardware(read, write, execute);
- SctlSetTrapRequest req = new SctlSetTrapRequest(ctlid, spec);
- return sequence(TypeSpec.cls(SctlTargetBreakpoint.class)).then(seq -> {
- sendCommand(req).handle(seq::next);
- }, TypeSpec.cls(SctlPacket.class)).then((reply, seq) -> {
- seq.exit(finishSetTrap(req, reply));
- }).finish();
- }
-
- private CompletableFuture<SctlTargetBreakpoint> processBusSetTrap(int id, int tag,
- SctlSetTrapRequest req) {
- return sequence(TypeSpec.cls(SctlTargetBreakpoint.class)).then((seq) -> {
- recvTag(tag).handle(seq::next);
- }, TypeSpec.cls(SctlPacket.class)).then((reply, seq) -> {
- SctlTargetBreakpoint bpt = finishSetTrap(req, reply);
- seq.exit(bpt);
- }).finish();
- }
-
- protected SctlTargetBreakpoint finishSetTrap(SctlSetTrapRequest req, SctlPacket reply) {
- SctlSetTrapReply set = checkReply(req, SctlSetTrapReply.class, reply);
- SctlTargetThread thread = session.processes.requireThread(req.ctlid);
- SctlTargetBreakpoint bpt = thread.createBreakpoint(set.trpid, req.spec.getAddress());
- return bpt;
- }
-
- /*
- * Methods for Tclrtrap
- */
-
- protected CompletableFuture<Void> clearTrap(long ctlid, long trpid) {
- SctlClearTrapRequest req = new SctlClearTrapRequest(ctlid, trpid);
- return sequence(TypeSpec.VOID).then((seq) -> {
- sendCommand(req).handle(seq::next);
- }, TypeSpec.cls(SctlPacket.class)).then((reply, seq) -> {
- finishClearTrap(req, reply);
- seq.exit();
- }).finish();
- }
-
- private CompletableFuture<Void> processBusClearTrap(int tag, SctlClearTrapRequest req) {
- return sequence(TypeSpec.VOID).then((seq) -> {
- recvTag(tag).handle(seq::next);
- }, TypeSpec.cls(SctlPacket.class)).then((reply, seq) -> {
- finishClearTrap(req, reply);
- seq.exit();
- }).finish();
- }
-
- protected void finishClearTrap(SctlClearTrapRequest req, SctlPacket reply) {
- checkReply(req, SctlClearTrapReply.class, reply);
- session.processes.requireThread(req.ctlid).destroyBreakpoint(req.trpid);
- }
-
- /*
- * Methods for Tdetach
- */
-
- protected CompletableFuture<Void> detachThread(long ctlid) {
- SctlDetachRequest req = new SctlDetachRequest(ctlid);
- return sequence(TypeSpec.VOID).then((seq) -> {
- sendCommand(req).handle(seq::next);
- }, TypeSpec.cls(SctlPacket.class)).then((reply, seq) -> {
- finishDetach(req, reply);
- seq.exit();
- }).finish();
- }
-
- private CompletableFuture<Void> processBusDetachThread(int tag, SctlDetachRequest req) {
- return sequence(TypeSpec.VOID).then((seq) -> {
- recvTag(tag).handle(seq::next);
- }, TypeSpec.cls(SctlPacket.class)).then((reply, seq) -> {
- finishDetach(req, reply);
- seq.exit();
- }).finish();
- }
-
- protected void finishDetach(SctlDetachRequest req, SctlPacket reply) {
- checkReply(req, SctlDetachReply.class, reply);
- session.processes.destroyThread(req.ctlid, "Detached");
- }
-
- /*
- * Methods for Tkill
- */
-
- protected CompletableFuture<Void> killThread(long ctlid) {
- SctlKillRequest req = new SctlKillRequest(ctlid);
- return sequence(TypeSpec.VOID).then((seq) -> {
- sendCommand(req).handle(seq::next);
- }, TypeSpec.cls(SctlPacket.class)).then((reply, seq) -> {
- finishKill(req, reply);
- seq.exit();
- }).finish();
- }
-
- private CompletableFuture<Void> processBusKillThread(int tag, SctlKillRequest req) {
- return sequence(TypeSpec.VOID).then((seq) -> {
- recvTag(tag).handle(seq::next);
- }, TypeSpec.cls(SctlPacket.class)).then((reply, seq) -> {
- finishKill(req, reply);
- seq.exit();
- }).finish();
- }
-
- protected void finishKill(SctlKillRequest req, SctlPacket reply) {
- checkReply(req, SctlKillReply.class, reply);
- session.processes.destroyThread(req.ctlid, "Killed");
- }
-
- @SctlExtension("Cause the debugger to select a given thread")
- protected CompletableFuture<Void> focusThread(long ctlid) {
- SctlFocusRequest req = new SctlFocusRequest(ctlid);
- return sequence(TypeSpec.VOID).then(seq -> {
- sendCommand(req).handle(seq::next);
- }, TypeSpec.cls(SctlPacket.class)).then((reply, seq) -> {
- finishFocus(req, reply);
- seq.exit();
- }).finish();
- }
-
- private CompletableFuture<Void> processBusFocusThread(int tag, SctlFocusRequest req) {
- return sequence(TypeSpec.VOID).then(seq -> {
- recvTag(tag).handle(seq::next);
- }, TypeSpec.cls(SctlPacket.class)).then((reply, seq) -> {
- finishFocus(req, reply);
- seq.exit();
- }).finish();
- }
-
- protected void finishFocus(SctlFocusRequest req, SctlPacket reply) {
- checkReply(req, SctlFocusReply.class, reply);
- SctlTargetThread thread = session.processes.requireThread(req.ctlid);
- session.fireFocused(thread);
- }
-
- /**
- * The given path must be relative to the "Objects" sub-tree
- *
- * @param path the path, relative to ["Objects"]
- * @return the attributes of the object at the given path
- */
- protected CompletableFuture<Map<String, TargetObject>> getAttributes(List<String> path) {
- String joinedPath = StringUtils.join(path, SctlTargetObject.PATH_SEPARATOR_STRING);
- SctlGetAttributesRequest req = new SctlGetAttributesRequest(joinedPath);
- return sequence(TypeSpec.map(String.class, TargetObject.class)).then(seq -> {
- sendCommand(req).handle(seq::next);
- }, TypeSpec.cls(SctlPacket.class)).then((reply, seq) -> {
- seq.exit(finishGetAttributes(req, reply));
- }).finish();
- }
-
- private CompletableFuture<Void> processBusGetAttributes(int tag,
- SctlGetAttributesRequest req) {
- return sequence(TypeSpec.VOID).then(seq -> {
- recvTag(tag).handle(seq::next);
- }, TypeSpec.cls(SctlPacket.class)).then((reply, seq) -> {
- finishGetAttributes(req, reply);
- seq.exit(null, null);
- }).finish();
- }
-
- protected Map<String, TargetObject> finishGetAttributes(SctlGetAttributesRequest req,
- SctlPacket reply) {
- SctlGetAttributesReply attr = checkReply(req, SctlGetAttributesReply.class, reply);
- Map<String, TargetObject> map = new LinkedHashMap<String, TargetObject>();
- for (AbstractSctlObjectEntry obj : attr.attributes) {
- String joinedPath = obj.getPath().str;
- List<String> path = new ArrayList<>();
- path.addAll(session.objects.getPath());
- path.addAll(List.of(joinedPath.split(SctlTargetObject.PATH_SEPARATOR_REGEX)));
- SctlTargetObject tobj;
- try {
- tobj = session.objects.create(obj.getKey().str, path, obj.getKind().str,
- obj.getValue().str, obj.getType().str);
- }
- catch (InvalidObjectException e) {
- Msg.error(this, e);
- return map;
- }
- map.put(obj.getKey().str, tobj);
- }
- session.objects.notifyAttributes(req.path.str, map);
- return map;
- }
-
- protected CompletableFuture<Map<String, TargetObject>> getElements(List<String> path) {
- String joinedPath = StringUtils.join(path, SctlTargetObject.PATH_SEPARATOR_STRING);
- SctlGetElementsRequest req = new SctlGetElementsRequest(joinedPath);
- return sequence(TypeSpec.map(String.class, TargetObject.class)).then(seq -> {
- sendCommand(req).handle(seq::next);
- }, TypeSpec.cls(SctlPacket.class)).then((reply, seq) -> {
- seq.exit(finishGetElements(req, reply));
- }).finish();
- }
-
- private CompletableFuture<Void> processBusGetElements(int tag, SctlGetElementsRequest req) {
- return sequence(TypeSpec.VOID).then(seq -> {
- recvTag(tag).handle(seq::next);
- }, TypeSpec.cls(SctlPacket.class)).then((reply, seq) -> {
- finishGetElements(req, reply);
- seq.exit(null, null);
- }).finish();
- }
-
- protected Map<String, TargetObject> finishGetElements(SctlGetElementsRequest req,
- SctlPacket reply) {
- SctlGetElementsReply result = checkReply(req, SctlGetElementsReply.class, reply);
- Map<String, TargetObject> map = new LinkedHashMap<>();
- for (AbstractSctlObjectEntry obj : result.elements) {
- String joinedPath = obj.getPath().str;
- List<String> path = new ArrayList<>();
- for (String str : joinedPath.split(SctlTargetObject.PATH_SEPARATOR_REGEX)) {
- path.add(str);
- }
- SctlTargetObject tobj;
- try {
- tobj = session.objects.create(obj.getKey().str, path, obj.getKind().str,
- obj.getValue().str, obj.getType().str);
- }
- catch (InvalidObjectException e) {
- Msg.error(this, e);
- return map;
- }
- map.put(tobj.getName(), tobj);
- }
- session.objects.notifyElements(req.path.str, map);
- return map;
- }
-
- /*
- * Methods for Ttrace
- */
-
- CompletableFuture<Void> traceEvents(long ctlid, SctlTrace.Mode mode,
- Set<SctlTrace.Event> events) {
- SctlTraceRequest req = new SctlTraceRequest(ctlid, SctlTrace.toFlags(mode, events));
- return sequence(TypeSpec.VOID).then((seq) -> {
- //Msg.debug(this, "TraceRequest: " + req);
- sendCommand(req).handle(seq::next);
- }, TypeSpec.cls(SctlPacket.class)).then((reply, seq) -> {
- finishTraceEvents(req, reply);
- seq.exit();
- }).finish();
- }
-
- private CompletableFuture<Void> processBusTraceEvents(int tag, SctlTraceRequest req) {
- return sequence(TypeSpec.VOID).then((seq) -> {
- recvTag(tag).handle(seq::next);
- }, TypeSpec.cls(SctlPacket.class)).then((reply, seq) -> {
- finishTraceEvents(req, reply);
- seq.exit();
- }).finish();
- }
-
- private void finishTraceEvents(SctlTraceRequest req, SctlPacket reply) {
- checkReply(req, SctlTraceReply.class, reply);
- }
-
- /*
- * Methods for handling errors apparently generated by other clients on the bus
- */
-
- private CompletableFuture<Void> processUnknownNSID(int id, int tag, long nsid, SctlPacket req) {
- return sequence(TypeSpec.VOID).then((seq) -> {
- Msg.warn(this, "Client " + id + " is talking about nsid " + nsid +
- ", which is unknown to this client: \n --(" + tag + ")-> " + req);
- recvTag(tag).handle(seq::next);
- }, TypeSpec.cls(SctlPacket.class)).then((reply, seq) -> {
- Msg.warn(this, " <-(" + tag + ")-- " + reply);
- seq.exit();
- }).finish();
- }
-
- private CompletableFuture<Void> processBusUnknown(int id, int tag, SctlPacket req) {
- return sequence(TypeSpec.VOID).then((seq) -> {
- Msg.warn(this, "Do not know how to process command from controller " + id +
- ":\n --(" + tag + ")-> " + req);
- recvTag(tag).handle(seq::next);
- }, TypeSpec.cls(SctlPacket.class)).then((reply, seq) -> {
- Msg.warn(this, " <-(" + tag + ")-- " + reply);
- seq.exit();
- }).finish();
- }
-
- /*
- * Misc
- */
-
- @Override
- public String toString() {
- String status = connectionState.name().toLowerCase();
- return "<SctlClient desc=" + description + ",dialect=" + activeDialect.getClass() +
- ",status=" + status + ">";
- }
-
- @Override
- public String getBrief() {
- String diaStr = activeDialect.getSysVersion();
- String status = connectionState.name().toLowerCase();
- return description + " via SCTL " + diaStr + " (" + status + ")";
- }
-
- @Override
- public CompletableFuture<? extends TargetObject> fetchModelRoot() {
- return CompletableFuture.completedFuture(session);
- }
-
- @Override
- public CompletableFuture<? extends TargetObject> fetchModelObject(List<String> path) {
- if (PathUtils.isAncestor(session.objects.getPath(), path)) {
- List<String> sub = path.subList(session.objects.getPath().size(), path.size());
- return session.objects.fetchSuccessor(sub);
- }
- return super.fetchModelObject(path);
- }
-
- @Override
- public AddressFactory getAddressFactory() {
- return addrMapper.getAddressFactory();
- }
-
- @Override
- public void invalidateAllLocalCaches() {
- TODO();
- }
-}
diff --git a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/client/SctlExtension.java b/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/client/SctlExtension.java
deleted file mode 100644
index 3bb22dd985..0000000000
--- a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/client/SctlExtension.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/* ###
- * 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 ghidra.dbg.sctl.client;
-
-import static java.lang.annotation.ElementType.*;
-
-import java.lang.annotation.*;
-
-/**
- * Indicates that some portion of the code implements a feature not part of the standard SCTL spec
- *
- * This is for documentation purposes only
- */
-@Documented
-@Retention(RetentionPolicy.CLASS)
-@Target({ TYPE, FIELD, METHOD, CONSTRUCTOR, ANNOTATION_TYPE, PACKAGE })
-public @interface SctlExtension {
- /**
- * Describe the extension, very briefly
- *
- * @return the description
- */
- String value();
-}
diff --git a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/client/SctlMemoryProtection.java b/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/client/SctlMemoryProtection.java
deleted file mode 100644
index 5708365f95..0000000000
--- a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/client/SctlMemoryProtection.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/* ###
- * 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 ghidra.dbg.sctl.client;
-
-import ghidra.comm.util.BitmaskUniverse;
-
-public enum SctlMemoryProtection implements BitmaskUniverse {
- PROT_READ(1 << 0), PROT_WRITE(1 << 1), PROT_EXEC(1 << 2);
-
- private final long mask;
-
- SctlMemoryProtection(long mask) {
- this.mask = mask;
- }
-
- @Override
- public long getMask() {
- return mask;
- }
-}
diff --git a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/client/SctlTargetAttachable.java b/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/client/SctlTargetAttachable.java
deleted file mode 100644
index ec0bd4d692..0000000000
--- a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/client/SctlTargetAttachable.java
+++ /dev/null
@@ -1,73 +0,0 @@
-/* ###
- * 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 ghidra.dbg.sctl.client;
-
-import java.util.List;
-import java.util.Map;
-
-import ghidra.dbg.agent.DefaultTargetObject;
-import ghidra.dbg.target.TargetAttachable;
-import ghidra.dbg.target.TargetObject;
-import ghidra.dbg.util.PathUtils;
-
-/**
- * A process which can be attached via SCTL
- */
-public class SctlTargetAttachable
- extends DefaultTargetObject<TargetObject, SctlTargetAttachableContainer>
- implements TargetAttachable<SctlTargetAttachable> {
-
- protected static String indexAttachable(long pid) {
- return PathUtils.makeIndex(pid);
- }
-
- protected static String keyAttachable(long pid) {
- return PathUtils.makeKey(indexAttachable(pid));
- }
-
- protected final SctlClient client;
-
- protected final long pid;
- protected final String cmdLine;
-
- /**
- * Construct an attachable process
- *
- * @param container the parent object (associated with the same client)
- * @param pid the PID of the process
- * @param cmdLine command line
- */
- public SctlTargetAttachable(SctlTargetAttachableContainer container, long pid, String cmdLine) {
- super(container.client, container, keyAttachable(pid), "AttachableProcess");
- this.client = container.client;
-
- this.pid = pid;
- this.cmdLine = cmdLine;
-
- changeAttributes(List.of(), List.of(), Map.of( //
- "pid", pid, //
- "cmd_line", cmdLine //
- ), "Initialized");
- }
-
- public long getPid() {
- return pid;
- }
-
- public String getCommandLine() {
- return cmdLine;
- }
-}
diff --git a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/client/SctlTargetAttachableContainer.java b/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/client/SctlTargetAttachableContainer.java
deleted file mode 100644
index e81897fa95..0000000000
--- a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/client/SctlTargetAttachableContainer.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/* ###
- * 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 ghidra.dbg.sctl.client;
-
-import java.util.concurrent.CompletableFuture;
-
-import ghidra.dbg.agent.DefaultTargetObject;
-
-public class SctlTargetAttachableContainer
- extends DefaultTargetObject<SctlTargetAttachable, SctlTargetSession> {
-
- protected final SctlClient client;
-
- public SctlTargetAttachableContainer(SctlTargetSession session) {
- super(session.client, session, "Attachable", "AttachableContainer");
- this.client = session.client;
- }
-
- @Override
- public CompletableFuture<Void> requestElements(boolean refresh) {
- return client.listAttachable().thenApply(__ -> null);
- }
-}
diff --git a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/client/SctlTargetBreakpoint.java b/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/client/SctlTargetBreakpoint.java
deleted file mode 100644
index 1c3a00de1b..0000000000
--- a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/client/SctlTargetBreakpoint.java
+++ /dev/null
@@ -1,181 +0,0 @@
-/* ###
- * 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 ghidra.dbg.sctl.client;
-
-import java.util.*;
-import java.util.concurrent.CompletableFuture;
-
-import ghidra.async.AsyncUtils;
-import ghidra.dbg.agent.DefaultTargetObject;
-import ghidra.dbg.attributes.TypedTargetObjectRef;
-import ghidra.dbg.target.*;
-import ghidra.dbg.target.TargetBreakpointContainer.TargetBreakpointKindSet;
-import ghidra.dbg.util.PathUtils;
-import ghidra.program.model.address.Address;
-import ghidra.util.datastruct.ListenerSet;
-
-public class SctlTargetBreakpoint
- extends DefaultTargetObject<SctlTargetBreakpoint, SctlTargetBreakpointContainer>
- implements TargetBreakpointSpec<SctlTargetBreakpoint>,
- TargetDeletable<SctlTargetBreakpoint>,
- TargetBreakpointLocation<SctlTargetBreakpoint> {
-
- protected static String keyBreakpoint(long trpid) {
- return PathUtils.makeKey(indexBreakpoint(trpid));
- }
-
- protected static String indexBreakpoint(long trpid) {
- return PathUtils.makeIndex(trpid);
- }
-
- protected final SctlClient client;
- protected final SctlTargetThread thread;
-
- protected final long trpid;
- protected final long offset;
- protected final Address address;
- protected final String expression;
-
- protected final ListenerSet<TargetBreakpointAction> actions =
- new ListenerSet<>(TargetBreakpointAction.class) {
- // Strong references
- protected Map<TargetBreakpointAction, TargetBreakpointAction> createMap() {
- return Collections.synchronizedMap(new LinkedHashMap<>());
- };
- };
- protected boolean cleared = false;
-
- public SctlTargetBreakpoint(SctlTargetBreakpointContainer breakpoints, SctlTargetThread thread,
- long trpid, long offset) {
- super(breakpoints.client, breakpoints, keyBreakpoint(trpid), "Breakpoint");
- this.client = breakpoints.client;
- this.thread = thread;
-
- this.trpid = trpid;
- this.offset = offset;
- this.address = client.addrMapper.mapOffsetToAddress(offset);
- this.expression = "0x" + Long.toHexString(offset);
-
- /**
- * TODO: Can AFFECTS be elided since the container exists in one thread? It's a conventional
- * question we should consider for all implementations. If/when the container is moved to
- * the process, does the idea still apply? Either way, it seems appropriate to have the
- * affects attribute provide here, i.e., implement the convention in the breakpoint rather
- * than everywhere else.
- */
- changeAttributes(List.of(), Map.of(
- SPEC_ATTRIBUTE_NAME, this,
- ADDRESS_ATTRIBUTE_NAME, address,
- LENGTH_ATTRIBUTE_NAME, 1,
- EXPRESSION_ATTRIBUTE_NAME, expression,
- KINDS_ATTRIBUTE_NAME, SctlTargetBreakpointContainer.SOFTWARE_ONLY,
- ENABLED_ATTRIBUTE_NAME, true //
- ), "Initialized");
- }
-
- /**
- * Duplicate this breakpoint into another thread's container
- *
- * This list of actions is copied, but each action is copied by reference. Generally, actions
- * are immutable. As a consequence, if a user adds an action to a copied breakpoint, that action
- * does not get applied to the original breakpoint. Thus, when a thread is forked or cloned, its
- * breakpoints are all copied, but adding an action to a breakpoint will only affect the
- * breakpoint active on the designated thread. To affect all threads having that breakpoint, the
- * action must be added explicitly to each copy.
- *
- * @see SctlTargetThread#copyBreakpointsFrom(SctlTargetThread)
- * @param that the breakpoint to copy
- * @param to the container (of another thread) into which the copy will be placed
- */
- protected SctlTargetBreakpoint(SctlTargetBreakpoint that, SctlTargetBreakpointContainer to) {
- this(to, that.thread, that.trpid, that.offset);
- this.actions.addAll(that.actions);
- }
-
- @Override
- public Address getAddress() {
- return address;
- }
-
- @Override
- public Integer getLength() {
- return 1;
- }
-
- @Override
- public TypedTargetObjectRef<? extends TargetBreakpointSpec<?>> getSpecification() {
- return this;
- }
-
- @Override
- public String getExpression() {
- return expression;
- }
-
- @Override
- public TargetBreakpointKindSet getKinds() {
- return SctlTargetBreakpointContainer.SOFTWARE_ONLY;
- }
-
- @Override
- public boolean isEnabled() {
- return true;
- }
-
- @Override
- public void addAction(TargetBreakpointAction action) {
- if (cleared) {
- throw new IllegalStateException("Breakpoint is cleared");
- }
- actions.add(action);
- }
-
- @Override
- public void removeAction(TargetBreakpointAction action) {
- if (cleared) {
- throw new IllegalStateException("Breakpoint is cleared");
- }
- actions.remove(action);
- }
-
- @Override
- public CompletableFuture<Void> delete() {
- if (cleared) {
- return CompletableFuture
- .failedFuture(new IllegalStateException("Breakpoint is already cleared"));
- }
- actions.clear(); // Expedite gc
- return client.clearTrap(thread.ctlid, trpid);
- }
-
- @Override
- public CompletableFuture<Void> disable() {
- // SCTL breakpoints are always enabled, so disable by deleting
- // TODO: Consider keeping a record in the client, permitting it to be easily re-enabled.
- return delete();
- }
-
- @Override
- public CompletableFuture<Void> enable() {
- // SCTL breakpoints are always enabled, or they're absent
- return AsyncUtils.NIL;
- }
-
- protected void hit() {
- parent.breakpointHit(this);
- actions.fire.breakpointHit(this, thread, null, this);
- }
-}
diff --git a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/client/SctlTargetBreakpointContainer.java b/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/client/SctlTargetBreakpointContainer.java
deleted file mode 100644
index 31eb5624d3..0000000000
--- a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/client/SctlTargetBreakpointContainer.java
+++ /dev/null
@@ -1,132 +0,0 @@
-/* ###
- * 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 ghidra.dbg.sctl.client;
-
-import java.util.*;
-import java.util.concurrent.CompletableFuture;
-
-import ghidra.dbg.agent.DefaultTargetObject;
-import ghidra.dbg.target.TargetBreakpointContainer;
-import ghidra.dbg.target.TargetBreakpointSpec.TargetBreakpointKind;
-import ghidra.dbg.util.PathUtils;
-import ghidra.program.model.address.Address;
-import ghidra.program.model.address.AddressRange;
-
-/**
- * TODO: Document me
- *
- * TODO: Should this be a child of the process instead? Would be much easier than copying
- * breakpoints around, if in fact, one set of breaks is shared by all ctls of the same process.
- */
-public class SctlTargetBreakpointContainer
- extends DefaultTargetObject<SctlTargetBreakpoint, SctlTargetThread>
- implements TargetBreakpointContainer<SctlTargetBreakpointContainer> {
-
- protected static final TargetBreakpointKindSet SOFTWARE_ONLY =
- TargetBreakpointKindSet.of(TargetBreakpointKind.SOFTWARE);
-
- protected final SctlClient client;
-
- private final Map<Long, SctlTargetBreakpoint> breaksByTrpid = new LinkedHashMap<>();
-
- public SctlTargetBreakpointContainer(SctlTargetThread thread) {
- super(thread.client, thread, "Breakpoints", "BreakpointContainer");
- this.client = thread.client;
-
- changeAttributes(List.of(), Map.of( //
- SUPPORTED_BREAK_KINDS_ATTRIBUTE_NAME, SOFTWARE_ONLY //
- ), "Initialized");
- }
-
- protected void put(long trpid, SctlTargetBreakpoint bpt) {
- synchronized (this) {
- breaksByTrpid.put(trpid, bpt);
- }
- changeElements(List.of(), List.of(bpt), "Placed");
- }
-
- protected void putAll(Map<Long, SctlTargetBreakpoint> map) {
- synchronized (this) {
- breaksByTrpid.putAll(map);
- }
- changeElements(List.of(), map.values(), "Placed");
- }
-
- protected Collection<SctlTargetBreakpoint> getAll() {
- return breaksByTrpid.values();
- }
-
- protected synchronized SctlTargetBreakpoint getByTrpid(long trpid) {
- return breaksByTrpid.get(trpid);
- }
-
- protected SctlTargetBreakpoint removeByTrpid(long trpid) {
- SctlTargetBreakpoint removed;
- synchronized (this) {
- removed = breaksByTrpid.remove(trpid);
- }
- if (removed != null) {
- changeElements(List.of(PathUtils.makeIndex(trpid)), List.of(), "Removed");
- }
- return removed;
- }
-
- protected void clear() {
- synchronized (this) {
- breaksByTrpid.clear();
- }
- setElements(List.of(), "Cleared");
- }
-
- @Override
- public CompletableFuture<Void> placeBreakpoint(String expression,
- Set<TargetBreakpointKind> kinds) {
- if (!Objects.equals(kinds, SOFTWARE_ONLY)) {
- throw new UnsupportedOperationException("SCTL supports software breakpoints only");
- }
- long offset;
- try {
- if (expression.startsWith("0x")) {
- offset = Long.parseLong(expression.substring(2), 16);
- }
- else {
- offset = Long.parseLong(expression, 10);
- }
- }
- catch (NumberFormatException e) {
- throw new IllegalArgumentException("SCTL requires address as 0x[hex] or [dec]");
- }
- Address address = client.addrMapper.mapOffsetToAddress(offset);
- return parent.setBreakpoint(address).thenApply(__ -> null);
- }
-
- @Override
- public CompletableFuture<Void> placeBreakpoint(AddressRange range,
- Set<TargetBreakpointKind> kinds) {
- if (!Objects.equals(kinds, SOFTWARE_ONLY)) {
- throw new UnsupportedOperationException("SCTL supports software breakpoints only");
- }
- if (range.getLength() != 1) {
- throw new UnsupportedOperationException(
- "SCTL supports single-address breakpoints only");
- }
- return parent.setBreakpoint(range.getMinAddress()).thenApply(__ -> null);
- }
-
- public void breakpointHit(SctlTargetBreakpoint bpt) {
- listeners.fire(TargetBreakpointListener.class).breakpointHit(this, parent, null, bpt, bpt);
- }
-}
diff --git a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/client/SctlTargetCompositeDataType.java b/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/client/SctlTargetCompositeDataType.java
deleted file mode 100644
index ee036cafb9..0000000000
--- a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/client/SctlTargetCompositeDataType.java
+++ /dev/null
@@ -1,56 +0,0 @@
-/* ###
- * 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 ghidra.dbg.sctl.client;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.concurrent.CompletableFuture;
-
-import ghidra.async.AsyncFence;
-import ghidra.dbg.sctl.protocol.types.*;
-
-public class SctlTargetCompositeDataType<T extends SctlTargetCompositeDataType<T>>
- extends SctlTargetNamedDataType<T, SctlTargetCompositeField> {
-
- // TODO: Dispose of this once converted?
- protected final AbstractSctlAggregateTypeDefinition tdef;
-
- protected SctlTargetCompositeDataType(SctlTargetDataTypeNamespace types,
- AbstractSctlTaggedTypeName tname, AbstractSctlAggregateTypeDefinition tdef,
- NamedDataTypeKind kind, String typeHint) {
- super(types, tname, kind, typeHint);
- this.tdef = tdef;
- }
-
- protected CompletableFuture<Void> collectFields() {
- AsyncFence fence = new AsyncFence();
- List<SctlTargetCompositeField> elems = new ArrayList<>(tdef.fields.size());
- for (int i = 0; i < tdef.fields.size(); i++) {
- int pos = i;
- SctlAggregateField field = tdef.fields.get(i);
- fence.include(parent.getType(field.tname.sel).thenAccept(t -> {
- SctlTargetCompositeField f =
- new SctlTargetCompositeField(this, pos, field.off, field.id.str, t);
- synchronized (elems) {
- elems.add(f);
- }
- }));
- }
- return fence.ready().thenAccept(__ -> {
- changeElements(List.of(), elems, "Initialized");
- });
- }
-}
diff --git a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/client/SctlTargetCompositeField.java b/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/client/SctlTargetCompositeField.java
deleted file mode 100644
index 11a58e0d9a..0000000000
--- a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/client/SctlTargetCompositeField.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/* ###
- * 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 ghidra.dbg.sctl.client;
-
-import ghidra.dbg.attributes.TargetDataType;
-import ghidra.dbg.util.PathUtils;
-
-public class SctlTargetCompositeField extends SctlTargetDataTypeMember {
-
- protected static String indexField(long position) {
- return PathUtils.makeIndex(position);
- }
-
- protected static String keyField(long position) {
- return PathUtils.makeKey(indexField(position));
- }
-
- public SctlTargetCompositeField(SctlTargetNamedDataType<?, ?> type, int position, long offset,
- String memberName, TargetDataType dataType) {
- super(type, keyField(position), position, offset, memberName, dataType, "TypeField");
- }
-
- @Override
- public String toString() {
- return "<" + getClass().getSimpleName() + " " + getName() + " " + parent.getIndex() + "." +
- getMemberName() + " @+" + getOffset() + ">";
- }
-}
diff --git a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/client/SctlTargetDataTypeMember.java b/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/client/SctlTargetDataTypeMember.java
deleted file mode 100644
index e1f5626053..0000000000
--- a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/client/SctlTargetDataTypeMember.java
+++ /dev/null
@@ -1,71 +0,0 @@
-/* ###
- * 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 ghidra.dbg.sctl.client;
-
-import java.util.List;
-import java.util.Map;
-
-import ghidra.dbg.agent.DefaultTargetObject;
-import ghidra.dbg.attributes.TargetDataType;
-import ghidra.dbg.target.TargetDataTypeMember;
-import ghidra.dbg.target.TargetObject;
-
-public class SctlTargetDataTypeMember
- extends DefaultTargetObject<TargetObject, SctlTargetNamedDataType<?, ?>>
- implements TargetDataTypeMember<SctlTargetDataTypeMember> {
-
- protected final int position;
- protected final long offset;
- protected final String memberName;
- protected final TargetDataType dataType;
-
- public SctlTargetDataTypeMember(SctlTargetNamedDataType<?, ?> type, String key, int position,
- long offset, String memberName, TargetDataType dataType, String typeHint) {
- super(type.client, type, key, typeHint);
-
- this.position = position;
- this.offset = offset;
- this.memberName = memberName;
- this.dataType = dataType;
-
- changeAttributes(List.of(), Map.of( //
- POSITION_ATTRIBUTE_NAME, position, //
- MEMBER_NAME_ATTRIBUTE_NAME, memberName, //
- OFFSET_ATTRIBUTE_NAME, offset, //
- DATA_TYPE_ATTRIBUTE_NAME, dataType //
- ), "Initialized");
- }
-
- @Override
- public int getPosition() {
- return position;
- }
-
- @Override
- public String getMemberName() {
- return memberName;
- }
-
- @Override
- public long getOffset() {
- return offset;
- }
-
- @Override
- public TargetDataType getDataType() {
- return dataType;
- }
-}
diff --git a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/client/SctlTargetDataTypeNamespace.java b/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/client/SctlTargetDataTypeNamespace.java
deleted file mode 100644
index 149eafd749..0000000000
--- a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/client/SctlTargetDataTypeNamespace.java
+++ /dev/null
@@ -1,240 +0,0 @@
-/* ###
- * 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 ghidra.dbg.sctl.client;
-
-import static ghidra.async.AsyncUtils.sequence;
-
-import java.util.*;
-import java.util.concurrent.CompletableFuture;
-
-import ghidra.async.*;
-import ghidra.dbg.agent.DefaultTargetObject;
-import ghidra.dbg.attributes.*;
-import ghidra.dbg.attributes.TargetArrayDataType.DefaultTargetArrayDataType;
-import ghidra.dbg.attributes.TargetBitfieldDataType.DefaultTargetBitfieldDataType;
-import ghidra.dbg.attributes.TargetPointerDataType.DefaultTargetPointerDataType;
-import ghidra.dbg.attributes.TargetPrimitiveDataType.DefaultTargetPrimitiveDataType;
-import ghidra.dbg.sctl.protocol.SctlPacket;
-import ghidra.dbg.sctl.protocol.common.reply.SctlEnumerateTypesReply;
-import ghidra.dbg.sctl.protocol.common.reply.SctlLookupTypeReply;
-import ghidra.dbg.sctl.protocol.common.request.SctlEnumerateTypesRequest;
-import ghidra.dbg.sctl.protocol.common.request.SctlLookupTypeRequest;
-import ghidra.dbg.sctl.protocol.consts.Cbase;
-import ghidra.dbg.sctl.protocol.types.*;
-import ghidra.dbg.target.TargetDataTypeNamespace;
-
-public class SctlTargetDataTypeNamespace
- extends DefaultTargetObject<SctlTargetNamedDataType<?, ?>, SctlTargetModule>
- implements TargetDataTypeNamespace<SctlTargetDataTypeNamespace> {
-
- protected static final CompletableFuture<TargetDataType> COMPLETED_TYPE_VOID =
- CompletableFuture.completedFuture(TargetPrimitiveDataType.VOID);
-
- protected final SctlClient client;
-
- protected final AsyncLazyMap<AbstractSctlTypeName, SelSctlTypeDefinition> lazyDefs =
- new AsyncLazyMap<>(new HashMap<>(), this::doGetTypeDef);
- protected final AsyncLazyValue<Map<AbstractSctlTypeName, SelSctlTypeDefinition>> allDefs =
- new AsyncLazyValue<>(this::doGetAllTypeDefs);
-
- protected final AsyncLazyMap<AbstractSctlTypeName, TargetDataType> lazyTypes =
- new AsyncLazyMap<>(new HashMap<>(), this::doGetType);
- protected final AsyncLazyValue<Collection<TargetDataType>> allTypes =
- new AsyncLazyValue<>(this::doGetAllTypes);
-
- public SctlTargetDataTypeNamespace(SctlTargetModule module) {
- super(module.client, module, "Types", "DataTypeNamespace");
- this.client = module.client;
- }
-
- public CompletableFuture<SelSctlTypeDefinition> getTypeDef(AbstractSctlTypeName tname) {
- return lazyDefs.get(tname);
- }
-
- protected CompletableFuture<SelSctlTypeDefinition> doGetTypeDef(AbstractSctlTypeName tname) {
- SctlLookupTypeRequest req = new SctlLookupTypeRequest(parent.nsid, tname);
- return sequence(TypeSpec.cls(SelSctlTypeDefinition.class)).then((seq) -> {
- client.sendCommand(req).handle(seq::next);
- }, TypeSpec.cls(SctlPacket.class)).then((reply, seq) -> {
- seq.exit(finishGetTypeDef(req, reply));
- }).finish();
- }
-
- protected CompletableFuture<SelSctlTypeDefinition> processBusGetTypeDef(int tag,
- SctlLookupTypeRequest req) {
- CompletableFuture<SelSctlTypeDefinition> promise = lazyDefs.put(req.tname.sel);
- return sequence(TypeSpec.cls(SelSctlTypeDefinition.class)).then((seq) -> {
- client.recvTag(tag).handle(seq::next);
- }, TypeSpec.cls(SctlPacket.class)).then((reply, seq) -> {
- SelSctlTypeDefinition tdef = finishGetTypeDef(req, reply);
- promise.complete(tdef);
- seq.exit(tdef);
- }).finish();
- }
-
- protected SelSctlTypeDefinition finishGetTypeDef(SctlLookupTypeRequest req,
- SctlPacket reply) {
- SctlLookupTypeReply lookedup = SctlClient.checkReply(req, SctlLookupTypeReply.class, reply);
- return lookedup.tdef;
- }
-
- protected CompletableFuture<Map<AbstractSctlTypeName, SelSctlTypeDefinition>> doGetAllTypeDefs() {
- SctlEnumerateTypesRequest req = new SctlEnumerateTypesRequest(parent.nsid);
- return sequence(TypeSpec.future(this::doGetAllTypeDefs)).then((seq) -> {
- client.sendCommand(req).handle(seq::next);
- }, TypeSpec.cls(SctlPacket.class)).then((reply, seq) -> {
- seq.exit(finishGetAllTypeDefs(req, reply));
- }).finish();
- }
-
- protected CompletableFuture<Map<AbstractSctlTypeName, SelSctlTypeDefinition>> processBusGetAllTypeDefs(
- int tag, SctlEnumerateTypesRequest req) {
- CompletableFuture<Map<AbstractSctlTypeName, SelSctlTypeDefinition>> promise =
- allDefs.provide();
- return sequence(TypeSpec.future(this::processBusGetAllTypeDefs)).then((seq) -> {
- client.recvTag(tag).handle(seq::next);
- }, TypeSpec.cls(SctlPacket.class)).then((reply, seq) -> {
- Map<AbstractSctlTypeName, SelSctlTypeDefinition> replies =
- finishGetAllTypeDefs(req, reply);
- promise.complete(replies);
- seq.exit(replies);
- }).finish();
- }
-
- protected Map<AbstractSctlTypeName, SelSctlTypeDefinition> finishGetAllTypeDefs(
- SctlEnumerateTypesRequest req, SctlPacket reply) {
- SctlEnumerateTypesReply enumed =
- SctlClient.checkReply(req, SctlEnumerateTypesReply.class, reply);
- synchronized (lazyDefs) {
- for (SelSctlTypeDefinition tdef : enumed.tdefs) {
- final AbstractSctlTypeName tname = tdef.getTypeName();
- lazyDefs.put(tname, tdef);
- }
- return lazyDefs.getCompletedMap();
- }
- }
-
- public CompletableFuture<TargetDataType> getType(AbstractSctlTypeName tname) {
- return lazyTypes.get(tname);
- }
-
- protected CompletableFuture<TargetDataType> doGetType(AbstractSctlTypeName tname) {
- if (tname instanceof SctlArrayTypeName) {
- SctlArrayTypeName nArray = (SctlArrayTypeName) tname;
- return getType(nArray.tname.sel).thenApply(tElem -> {
- return new DefaultTargetArrayDataType(tElem, (int) nArray.nelem);
- });
- }
- if (tname instanceof SctlBaseTypeName) {
- SctlBaseTypeName tBase = (SctlBaseTypeName) tname;
- if (tBase.base == Cbase.Vvoid) {
- return COMPLETED_TYPE_VOID;
- }
- return getTypeDef(tname).thenApply(d -> {
- SctlBaseTypeDefinition dBase = (SctlBaseTypeDefinition) d.sel;
- return new DefaultTargetPrimitiveDataType(dBase.rep.getKind(),
- dBase.rep.getByteLength());
- });
- }
- if (tname instanceof SctlBitfieldTypeName) {
- SctlBitfieldTypeName nBitfield = (SctlBitfieldTypeName) tname;
- return getType(nBitfield.tname.sel).thenApply(tField -> {
- return new DefaultTargetBitfieldDataType(tField, Byte.toUnsignedInt(nBitfield.pos),
- Byte.toUnsignedInt(nBitfield.width));
- });
- }
- if (tname instanceof SctlEnumConstTypeName) {
- // Just let it take the enum type, perhaps with a "const" modifier, if Ghidra supports it
- SctlEnumConstTypeName nEnumConst = (SctlEnumConstTypeName) tname;
- return getType(nEnumConst.tname.sel).thenApply(tEnum -> {
- return tEnum; // TODO: Some indicator of being constant?
- });
- }
- if (tname instanceof SctlEnumTypeName) {
- SctlEnumTypeName nEnum = (SctlEnumTypeName) tname;
- return CompletableFuture.completedFuture(new SctlTargetEnumDataType.Ref(this, nEnum));
- }
- if (tname instanceof SctlFunctionTypeName) {
- SctlFunctionTypeName nFunction = (SctlFunctionTypeName) tname;
- SctlTargetFunctionDataType tFunction = new SctlTargetFunctionDataType(this, nFunction);
- return tFunction.collectMembers().thenApply(__ -> {
- changeElements(List.of(), List.of(tFunction), "Fetched");
- return tFunction;
- });
- }
- if (tname instanceof SctlPointerTypeName) {
- SctlPointerTypeName nPointer = (SctlPointerTypeName) tname;
- return getType(nPointer.tname.sel).thenApply(tReferent -> {
- return new DefaultTargetPointerDataType(tReferent);
- });
- }
- if (tname instanceof SctlStructTypeName) {
- SctlStructTypeName nStruct = (SctlStructTypeName) tname;
- return CompletableFuture
- .completedFuture(new SctlTargetStructDataType.Ref(this, nStruct));
- }
- if (tname instanceof SctlTypedefTypeName) {
- SctlTypedefTypeName nTypedef = (SctlTypedefTypeName) tname;
- return CompletableFuture
- .completedFuture(new SctlTargetTypedefDataType.Ref(this, nTypedef));
- }
- if (tname instanceof SctlUndefinedTypeName) {
- SctlUndefinedTypeName nUndefined = (SctlUndefinedTypeName) tname;
- // Just pass it through, perhaps with some modifier
- return getType(nUndefined.tname.sel).thenApply(tUndefined -> {
- return tUndefined; // TODO: Some indicator of being undefined?
- });
- }
- if (tname instanceof SctlUnionTypeName) {
- SctlUnionTypeName nUnion = (SctlUnionTypeName) tname;
- return CompletableFuture.completedFuture(new SctlTargetUnionDataType.Ref(this, nUnion));
- }
- throw new AssertionError("Unrecognized SCTL type name: " + tname);
- }
-
- protected CompletableFuture<Collection<TargetDataType>> doGetAllTypes() {
- return sequence(TypeSpec.future(this::doGetAllTypes)).then(seq -> {
- allDefs.request().handle(seq::next);
- }, TypeSpec.map(AbstractSctlTypeName.class, SelSctlTypeDefinition.class)).then((m, seq) -> {
- AsyncFence fence = new AsyncFence();
- for (AbstractSctlTypeName tname : m.keySet()) {
- fence.include(lazyTypes.get(tname));
- }
- fence.ready().handle(seq::next);
- }).then((seq) -> {
- seq.exit(lazyTypes.getCompletedMap().values());
- }).finish();
- }
-
- @Override
- public CompletableFuture<Void> requestElements(boolean refresh) {
- return getAllTypes().thenCompose(all -> {
- AsyncFence fence = new AsyncFence();
- // NOTE: Some derived data types get added as we process children of named ones
- for (TargetDataType t : new ArrayList<>(all)) {
- if (t instanceof TargetNamedDataTypeRef<?>) {
- TargetNamedDataTypeRef<?> ref = (TargetNamedDataTypeRef<?>) t;
- fence.include(ref.fetch()); // Get should cause the element to get added
- }
- }
- return fence.ready();
- });
- }
-
- public CompletableFuture<Collection<TargetDataType>> getAllTypes() {
- return allTypes.request();
- }
-}
diff --git a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/client/SctlTargetEnumConstant.java b/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/client/SctlTargetEnumConstant.java
deleted file mode 100644
index 6cc9a9fcfc..0000000000
--- a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/client/SctlTargetEnumConstant.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/* ###
- * 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 ghidra.dbg.sctl.client;
-
-import ghidra.dbg.util.PathUtils;
-
-public class SctlTargetEnumConstant extends SctlTargetDataTypeMember {
- protected static String indexConst(long value) {
- return PathUtils.makeIndex(value);
- }
-
- protected static String keyConst(int position) {
- return PathUtils.makeKey(indexConst(position));
- }
-
- public SctlTargetEnumConstant(SctlTargetNamedDataType<?, ?> type, int position, long value,
- String memberName) {
- super(type, keyConst(position), position, value, memberName, type, "EnumConstant");
- }
-
- @Override
- public String toString() {
- String[] parts = parent.module.getIndex().split("/");
- return String.format("<SCTL enum constant: %s::%s = %d>", parts[parts.length - 1],
- memberName, position);
- }
-}
diff --git a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/client/SctlTargetEnumDataType.java b/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/client/SctlTargetEnumDataType.java
deleted file mode 100644
index 81b49f0295..0000000000
--- a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/client/SctlTargetEnumDataType.java
+++ /dev/null
@@ -1,72 +0,0 @@
-/* ###
- * 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 ghidra.dbg.sctl.client;
-
-import java.util.*;
-import java.util.concurrent.CompletableFuture;
-
-import ghidra.async.AsyncUtils;
-import ghidra.async.TypeSpec;
-import ghidra.dbg.sctl.protocol.types.*;
-
-public class SctlTargetEnumDataType
- extends SctlTargetNamedDataType<SctlTargetEnumDataType, SctlTargetEnumConstant> {
-
- public static class Ref extends AbstractRef<SctlTargetEnumDataType> {
- protected final SctlEnumTypeName nEnum;
-
- protected Ref(SctlTargetDataTypeNamespace types, SctlEnumTypeName nEnum) {
- super(types, nEnum);
- this.nEnum = nEnum;
- }
-
- @Override
- protected CompletableFuture<? extends SctlTargetEnumDataType> doGet() {
- return AsyncUtils.sequence(TypeSpec.cls(SctlTargetEnumDataType.class)).then(seq -> {
- types.getTypeDef(nEnum).handle(seq::next);
- }, TypeSpec.cls(SelSctlTypeDefinition.class)).then((def, seq) -> {
- SctlEnumTypeDefinition dEnum = (SctlEnumTypeDefinition) def.sel;
- SctlTargetEnumDataType tEnum = new SctlTargetEnumDataType(types, nEnum, dEnum);
- types.changeElements(List.of(), List.of(tEnum), "Fetched");
- seq.exit(tEnum);
- }).finish();
- }
- }
-
- // TODO: Dispose of this once converted?
- protected final SctlEnumTypeDefinition dEnum;
-
- protected final int byteLength;
-
- public SctlTargetEnumDataType(SctlTargetDataTypeNamespace types, SctlEnumTypeName tname,
- SctlEnumTypeDefinition dEnum) {
- super(types, tname, NamedDataTypeKind.ENUM, "EnumType");
- this.dEnum = dEnum;
-
- this.byteLength = dEnum.rep.getByteLength();
-
- changeAttributes(List.of(), Map.of( //
- ENUM_BYTE_LENGTH_ATTRIBUTE_NAME, byteLength //
- ), "Initialized");
-
- List<SctlTargetEnumConstant> elems = new ArrayList<>(dEnum.consts.size());
- for (int i = 0; i < dEnum.consts.size(); i++) {
- SctlEnumConstant c = dEnum.consts.get(i);
- elems.add(new SctlTargetEnumConstant(this, i, c.value, c.id.str));
- }
- changeElements(List.of(), elems, "Initialized");
- }
-}
diff --git a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/client/SctlTargetFunctionDataType.java b/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/client/SctlTargetFunctionDataType.java
deleted file mode 100644
index 0460cf8805..0000000000
--- a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/client/SctlTargetFunctionDataType.java
+++ /dev/null
@@ -1,63 +0,0 @@
-/* ###
- * 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 ghidra.dbg.sctl.client;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.concurrent.CompletableFuture;
-
-import ghidra.async.AsyncFence;
-import ghidra.dbg.sctl.protocol.types.SctlFunctionParameter;
-import ghidra.dbg.sctl.protocol.types.SctlFunctionTypeName;
-
-public class SctlTargetFunctionDataType
- extends SctlTargetNamedDataType<SctlTargetFunctionDataType, SctlTargetFunctionParameter> {
-
- // TODO: Dispose of this once converted?
- protected final SctlFunctionTypeName nFunction;
-
- public SctlTargetFunctionDataType(SctlTargetDataTypeNamespace types,
- SctlFunctionTypeName nFunction) {
- super(types, nFunction, NamedDataTypeKind.FUNCTION, "FunctionType");
- this.nFunction = nFunction;
- }
-
- public CompletableFuture<Void> collectMembers() {
- AsyncFence fence = new AsyncFence();
- List<SctlTargetFunctionParameter> elems = new ArrayList<>(nFunction.params.size());
- fence.include(parent.getType(nFunction.tname.sel).thenAccept(t -> {
- SctlTargetFunctionParameter r =
- new SctlTargetFunctionParameter(this, -1, "<return>", t);
- synchronized (elems) {
- elems.add(r);
- }
- }));
- for (int i = 0; i < nFunction.params.size(); i++) {
- int pos = i;
- SctlFunctionParameter param = nFunction.params.get(i);
- fence.include(parent.getType(param.tname.sel).thenAccept(t -> {
- SctlTargetFunctionParameter p =
- new SctlTargetFunctionParameter(this, pos, param.pname.str, t);
- synchronized (elems) {
- elems.add(p);
- }
- }));
- }
- return fence.ready().thenAccept(__ -> {
- changeElements(List.of(), elems, "Initialized");
- });
- }
-}
diff --git a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/client/SctlTargetFunctionParameter.java b/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/client/SctlTargetFunctionParameter.java
deleted file mode 100644
index 9bedea3be2..0000000000
--- a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/client/SctlTargetFunctionParameter.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/* ###
- * 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 ghidra.dbg.sctl.client;
-
-import ghidra.dbg.attributes.TargetDataType;
-import ghidra.dbg.target.TargetNamedDataType;
-import ghidra.dbg.util.PathUtils;
-
-public class SctlTargetFunctionParameter
- extends SctlTargetDataTypeMember {
-
- protected static String keyParameter(long position) {
- return PathUtils.makeKey(indexParameter(position));
- }
-
- protected static String indexParameter(long position) {
- if (position == -1) {
- return TargetNamedDataType.FUNCTION_RETURN_INDEX;
- }
- if (position >= 0) {
- return TargetNamedDataType.FUNCTION_PARAMETER_DIM + "," + position;
- }
- throw new IllegalArgumentException("position = " + position);
- }
-
- public SctlTargetFunctionParameter(SctlTargetFunctionDataType function, int position,
- String paramName, TargetDataType dataType) {
- super(function, keyParameter(position), position, -1, paramName, dataType,
- position == -1 ? "Return" : "Parameter");
- }
-}
diff --git a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/client/SctlTargetMemory.java b/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/client/SctlTargetMemory.java
deleted file mode 100644
index cc5d2e5d07..0000000000
--- a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/client/SctlTargetMemory.java
+++ /dev/null
@@ -1,97 +0,0 @@
-/* ###
- * 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 ghidra.dbg.sctl.client;
-
-import java.util.List;
-import java.util.concurrent.CompletableFuture;
-
-import ghidra.async.AsyncUtils;
-import ghidra.dbg.agent.DefaultTargetObject;
-import ghidra.dbg.memory.*;
-import ghidra.dbg.target.TargetMemory;
-import ghidra.program.model.address.Address;
-
-public class SctlTargetMemory extends DefaultTargetObject<SctlTargetMemoryRegion, SctlTargetProcess>
- implements TargetMemory<SctlTargetMemory> {
-
- protected final SctlClient client;
-
- private final CachedMemory memCache =
- new CachedMemory(this::rawReadMemory, this::rawWriteMemory);
- private final MemoryWriter memWriter = memCache;
- private final MemoryReader memReader = memCache;
-
- public SctlTargetMemory(SctlTargetProcess process) {
- super(process.client, process, "Memory", "Memory");
- this.client = process.client;
- }
-
- @Override
- public CompletableFuture<Void> requestElements(boolean refresh) {
- if (refresh) {
- parent.lazyStat.forget();
- }
- return parent.lazyStat.request();
- }
-
- @Override
- public CompletableFuture<byte[]> readMemory(Address address, int length) {
- return memReader.readMemory(client.addrMapper.mapAddressToOffset(address), length);
- }
-
- private CompletableFuture<byte[]> rawReadMemory(long offset, int length) {
- return client.readMemory(parent.primaryCtlid, offset, length).thenApply(data -> {
- notifyUpdate(offset, data);
- return data;
- });
- }
-
- @Override
- public CompletableFuture<Void> writeMemory(Address address, byte[] data) {
- return memWriter.writeMemory(client.addrMapper.mapAddressToOffset(address), data);
- }
-
- private CompletableFuture<Void> rawWriteMemory(long offset, byte[] data) {
- return client.writeMemory(parent.primaryCtlid, offset, data).thenAccept(__ -> {
- notifyUpdate(offset, data);
- });
- }
-
- protected void notifyUpdate(long offset, byte[] data) {
- Address address = client.addrMapper.mapOffsetToAddress(offset);
- listeners.fire(TargetMemoryListener.class).memoryUpdated(this, address, data);
- }
-
- @Override
- public CompletableFuture<Void> invalidateCaches() {
- memCache.clear();
- return AsyncUtils.NIL;
- }
-
- protected void clearRegions() {
- setElements(List.of(), "Refreshing");
- }
-
- protected void addRegion(SctlTargetMemoryRegion region) {
- // TODO: Rewrite this to use setElements after all regions are collected
- changeElements(List.of(), List.of(region), "Refreshed");
- }
-
- protected void invalidateMemoryCaches() {
- memCache.clear();
- listeners.fire.invalidateCacheRequested(this);
- }
-}
diff --git a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/client/SctlTargetMemoryRegion.java b/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/client/SctlTargetMemoryRegion.java
deleted file mode 100644
index 18bc48e9a8..0000000000
--- a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/client/SctlTargetMemoryRegion.java
+++ /dev/null
@@ -1,96 +0,0 @@
-/* ###
- * 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 ghidra.dbg.sctl.client;
-
-import java.util.List;
-import java.util.Map;
-
-import ghidra.comm.util.BitmaskSet;
-import ghidra.dbg.agent.DefaultTargetObject;
-import ghidra.dbg.target.TargetMemoryRegion;
-import ghidra.dbg.target.TargetObject;
-import ghidra.dbg.util.PathUtils;
-import ghidra.program.model.address.*;
-
-public class SctlTargetMemoryRegion extends DefaultTargetObject<TargetObject, SctlTargetMemory>
- implements TargetMemoryRegion<SctlTargetMemoryRegion> {
- protected static final String FILE_ATTRIBUTE_NAME = PREFIX_INVISIBLE + "file";
-
- protected static String keyRegion(Address address) {
- return PathUtils.makeKey(indexRegion(address));
- }
-
- protected static String indexRegion(Address address) {
- return address.toString();
- }
-
- protected final SctlClient client;
-
- protected final String file;
- protected final AddressRange range;
- protected final BitmaskSet<SctlMemoryProtection> protections;
-
- public SctlTargetMemoryRegion(SctlTargetMemory memory, String file, Address address,
- long length, BitmaskSet<SctlMemoryProtection> protections)
- throws AddressOverflowException {
- super(memory.client, memory, keyRegion(address), "MemoryRegion");
- this.client = memory.client;
-
- this.file = file;
- this.range = new AddressRangeImpl(address, address.addNoWrap(length - 1));
- this.protections = protections;
-
- changeAttributes(List.of(), Map.of( //
- FILE_ATTRIBUTE_NAME, file, //
- RANGE_ATTRIBUTE_NAME, range, //
- READABLE_ATTRIBUTE_NAME, isReadable(), //
- WRITABLE_ATTRIBUTE_NAME, isWritable(), //
- EXECUTABLE_ATTRIBUTE_NAME, isExecutable() //
- ), "Initialized");
- }
-
- @Override
- public String getDisplay() {
- if (file != null) {
- return range.getMinAddress() + " (" + file + ")";
- }
- return range.getMinAddress().toString();
- }
-
- @Override
- public AddressRange getRange() {
- return range;
- }
-
- public String getFile() {
- return file;
- }
-
- @Override
- public boolean isReadable() {
- return protections.contains(SctlMemoryProtection.PROT_READ);
- }
-
- @Override
- public boolean isWritable() {
- return protections.contains(SctlMemoryProtection.PROT_WRITE);
- }
-
- @Override
- public boolean isExecutable() {
- return protections.contains(SctlMemoryProtection.PROT_EXEC);
- }
-}
diff --git a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/client/SctlTargetModule.java b/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/client/SctlTargetModule.java
deleted file mode 100644
index 7cef1ed4eb..0000000000
--- a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/client/SctlTargetModule.java
+++ /dev/null
@@ -1,116 +0,0 @@
-/* ###
- * 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 ghidra.dbg.sctl.client;
-
-import java.util.*;
-
-import ghidra.async.AsyncLazyMap;
-import ghidra.dbg.agent.DefaultTargetObject;
-import ghidra.dbg.sctl.protocol.consts.Mkind;
-import ghidra.dbg.target.TargetModule;
-import ghidra.dbg.target.TargetObject;
-import ghidra.dbg.util.PathUtils;
-import ghidra.program.model.address.*;
-
-/**
- * A namespace on the SCTL server
- *
- * Typically, a namespace belongs to a single target, but it is possible, e.g., if two targets share
- * a common library, for a single namespace to belong to multiple targets. SCTL also generates a
- * namespace on a {@code Tnames} command, which is not associated with any particular CTLID.
- *
- * The symbols and types from a namespace are cached for the lifetime of this proxy object, because
- * they should never change during the life of the CTLID or NSID. This is accomplished using an
- * {@link AsyncLazyMap}
- */
-public class SctlTargetModule
- extends DefaultTargetObject<TargetObject, SctlTargetModuleContainer>
- implements TargetModule<SctlTargetModule> {
-
- protected static String keyModule(String filepath) {
- return PathUtils.makeKey(indexModule(filepath));
- }
-
- protected static String indexModule(String filepath) {
- return filepath;
- }
-
- protected final SctlClient client;
- protected final long nsid;
- protected final String filepath;
- protected final Address base;
- protected AddressRangeImpl range;
- protected final boolean executable;
-
- protected final SctlTargetSectionContainer sections;
- protected final SctlTargetSymbolNamespace symbols;
- protected final SctlTargetDataTypeNamespace types;
-
- /**
- * Construct a module proxy
- *
- * The given path is used as the name of the module.
- *
- * @see SctlClient#createModule(long, String, Address)
- * @param process the SCTL process to which the namespace belongs
- * @param nsid the SCTL-assigned nsid "namespace ID"
- * @param path the path from the {@link Mkind#Tnames} or {@link Mkind#Rstat} message
- * @param executable true if this is the executable image (not a library)
- */
- public SctlTargetModule(SctlTargetModuleContainer modules, long nsid, String filepath,
- Address base, boolean executable) {
- super(modules.client, modules, keyModule(filepath), "Module");
- this.client = modules.client;
- this.nsid = nsid;
- this.filepath = filepath;
- this.base = base;
- range = new AddressRangeImpl(base, base);
- this.executable = executable;
-
- this.sections = new SctlTargetSectionContainer(this);
- this.symbols = new SctlTargetSymbolNamespace(this);
- this.types = new SctlTargetDataTypeNamespace(this);
-
- changeAttributes(List.of(), Map.of( //
- RANGE_ATTRIBUTE_NAME, range, //
- sections.getName(), sections, //
- symbols.getName(), symbols, //
- types.getName(), types //
- ), "Initialized");
- }
-
- @Override
- public AddressRange getRange() {
- return range;
- }
-
- protected void addSection(String name, Address start, long length) {
- sections.add(name, start, length);
- }
-
- public void updateRange() {
- Address max = sections.getCachedElements()
- .values()
- .stream()
- .map(s -> s.getRange().getMaxAddress())
- .max(Comparator.naturalOrder())
- .orElse(null);
- range = new AddressRangeImpl(base, max);
- changeAttributes(List.of(), Map.of(
- RANGE_ATTRIBUTE_NAME, range),
- "Have sections");
- }
-}
diff --git a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/client/SctlTargetModuleContainer.java b/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/client/SctlTargetModuleContainer.java
deleted file mode 100644
index 4a387afc81..0000000000
--- a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/client/SctlTargetModuleContainer.java
+++ /dev/null
@@ -1,83 +0,0 @@
-/* ###
- * 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 ghidra.dbg.sctl.client;
-
-import java.util.*;
-import java.util.concurrent.CompletableFuture;
-
-import ghidra.dbg.agent.DefaultTargetObject;
-import ghidra.lifecycle.Internal;
-import ghidra.program.model.address.Address;
-
-public class SctlTargetModuleContainer
- extends DefaultTargetObject<SctlTargetModule, SctlTargetProcess> {
-
- protected final SctlClient client;
-
- private final Map<Long, SctlTargetModule> modulesByNsid = new LinkedHashMap<>();
-
- public SctlTargetModuleContainer(SctlTargetProcess process) {
- super(process.client, process, "Modules", "ModuleContainer");
- this.client = process.client;
- }
-
- /**
- * Create a module proxy
- *
- * This is preferred to calling {@link SctlTargetModule(SctlClient, long, String, boolean)}
- * directly, since this will add the module to the client's container.
- *
- * @param nsid the SCTL-assigned NSID "namespace ID"
- * @param filepath the path given in {@code Tnames}
- * @param executable the module is the executable image defining this process
- * @return the new module proxy
- */
- @Internal
- public SctlTargetModule create(long nsid, String filepath, Address base, boolean executable) {
- SctlTargetModule ns =
- new SctlTargetModule(this, nsid, filepath, base, executable);
- client.session.processes.putModule(nsid, ns);
- modulesByNsid.put(nsid, ns);
- changeElements(List.of(), List.of(ns), "Refreshed");
- return ns;
- }
-
- @Override
- public CompletableFuture<Void> requestElements(boolean refresh) {
- if (refresh) {
- parent.lazyStat.forget();
- }
- return parent.lazyStat.request();
- }
-
- protected void clear() {
- // TODO: For refreshing, would rather collect and the use setElements
- synchronized (this) {
- client.session.processes.removeAllModules(modulesByNsid);
- modulesByNsid.clear();
- }
- setElements(List.of(), "Refreshing");
- }
-
- protected String getExecutablePath() {
- for (SctlTargetModule module : modulesByNsid.values()) {
- if (module.executable) {
- return module.filepath;
- }
- }
- return null;
- }
-}
diff --git a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/client/SctlTargetNamedDataType.java b/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/client/SctlTargetNamedDataType.java
deleted file mode 100644
index 8e718179b1..0000000000
--- a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/client/SctlTargetNamedDataType.java
+++ /dev/null
@@ -1,134 +0,0 @@
-/* ###
- * 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 ghidra.dbg.sctl.client;
-
-import java.util.List;
-import java.util.Map;
-import java.util.concurrent.CompletableFuture;
-
-import ghidra.async.AsyncLazyValue;
-import ghidra.dbg.DebuggerObjectModel;
-import ghidra.dbg.agent.DefaultTargetObject;
-import ghidra.dbg.attributes.TargetNamedDataTypeRef;
-import ghidra.dbg.sctl.protocol.types.*;
-import ghidra.dbg.target.TargetNamedDataType;
-import ghidra.dbg.util.PathUtils;
-
-public abstract class SctlTargetNamedDataType<T extends SctlTargetNamedDataType<T, M>, M extends SctlTargetDataTypeMember>
- extends DefaultTargetObject<M, SctlTargetDataTypeNamespace>
- implements TargetNamedDataType<T> {
-
- protected static String indexStruct(SctlStructTypeName tStruct) {
- return "struct " + tStruct.tag.str;
- }
-
- protected static String indexUnion(SctlUnionTypeName tUnion) {
- return "union " + tUnion.tag.str;
- }
-
- protected static String indexEnum(SctlEnumTypeName tEnum) {
- return "enum " + tEnum.tag.str;
- }
-
- protected static String indexTypedef(SctlTypedefTypeName tTypedef) {
- return "typedef " + tTypedef.tid.str;
- }
-
- protected static String indexFunction(SctlFunctionTypeName tFunction) {
- // SCTL does not name these. It'd be nice to have something more stable
- return "function " + "sig" + System.identityHashCode(tFunction);
- }
-
- protected static String indexType(AbstractSctlTypeName tname) {
- if (tname instanceof SctlStructTypeName) {
- return indexStruct((SctlStructTypeName) tname);
- }
- if (tname instanceof SctlUnionTypeName) {
- return indexUnion((SctlUnionTypeName) tname);
- }
- if (tname instanceof SctlEnumTypeName) {
- return indexEnum((SctlEnumTypeName) tname);
- }
- if (tname instanceof SctlTypedefTypeName) {
- return indexTypedef((SctlTypedefTypeName) tname);
- }
- if (tname instanceof SctlFunctionTypeName) {
- return indexFunction((SctlFunctionTypeName) tname);
- }
- throw new AssertionError("Unrecognized SCTL type kind: " + tname);
- }
-
- protected static String keyType(AbstractSctlTypeName tname) {
- return PathUtils.makeKey(indexType(tname));
- }
-
- public static abstract class AbstractRef<T extends SctlTargetNamedDataType<T, ?>>
- implements TargetNamedDataTypeRef<T> {
- protected final SctlTargetDataTypeNamespace types;
- protected final List<String> path;
- protected final AsyncLazyValue<? extends T> t = new AsyncLazyValue<>(this::doGet);
-
- protected AbstractRef(SctlTargetDataTypeNamespace types, AbstractSctlTypeName tname) {
- this.types = types;
- this.path = PathUtils.index(types.getPath(), SctlTargetNamedDataType.indexType(tname));
- }
-
- protected abstract CompletableFuture<? extends T> doGet();
-
- @Override
- public CompletableFuture<? extends T> fetch() {
- return t.request();
- }
-
- @Override
- public DebuggerObjectModel getModel() {
- return types.client;
- }
-
- @Override
- public List<String> getPath() {
- return path;
- }
- }
-
- protected final SctlClient client;
- protected final SctlTargetModule module;
-
- protected final NamedDataTypeKind kind;
-
- protected SctlTargetNamedDataType(SctlTargetDataTypeNamespace types,
- AbstractSctlTypeName tname, NamedDataTypeKind kind, String typeHint) {
- super(types.client, types, keyType(tname), typeHint);
- this.client = types.client;
- this.module = types.getImplParent();
-
- this.kind = kind;
-
- changeAttributes(List.of(), Map.of( //
- NAMED_DATA_TYPE_KIND_ATTRIBUTE_NAME, kind //
- ), "Initialized");
- }
-
- @Override
- public String toString() {
- return "<" + getClass().getSimpleName() + " " + getIndex() + ">";
- }
-
- @Override
- public NamedDataTypeKind getTypeKind() {
- return kind;
- }
-}
diff --git a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/client/SctlTargetObject.java b/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/client/SctlTargetObject.java
deleted file mode 100644
index 4aa487d89b..0000000000
--- a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/client/SctlTargetObject.java
+++ /dev/null
@@ -1,210 +0,0 @@
-/* ###
- * 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 ghidra.dbg.sctl.client;
-
-import java.util.*;
-import java.util.concurrent.CompletableFuture;
-
-import org.apache.commons.lang3.StringUtils;
-
-import ghidra.async.AsyncLazyValue;
-import ghidra.dbg.attributes.TargetObjectRef;
-import ghidra.dbg.sctl.protocol.common.AbstractSctlObjectEntry;
-import ghidra.dbg.target.TargetObject;
-import ghidra.dbg.util.CollectionUtils.Delta;
-import ghidra.dbg.util.PathUtils;
-import ghidra.dbg.util.PathUtils.TargetObjectKeyComparator;
-import ghidra.util.datastruct.ListenerSet;
-
-/**
- * A target thread on the SCTL server
- */
-public class SctlTargetObject implements TargetObject {
- public static final String PATH_SEPARATOR_STRING = "|";
- public static final String PATH_SEPARATOR_REGEX = "\\|";
-
- private final SctlClient client;
- private final String joinedPath;
- private final List<String> path;
- private final int hash;
- boolean valid = true;
-
- final AsyncLazyValue<Map<String, TargetObject>> lazyAttributes =
- new AsyncLazyValue<>(this::doGetAttributes);
- final AsyncLazyValue<Map<String, TargetObject>> lazyElements =
- new AsyncLazyValue<>(this::doGetChildren);
- private String kind;
- private String value;
- private String type;
- // NOTE: 'key' is last element of the path. The method getName() retrieves it.
-
- // TODO: Create one of these per object proxy, and ensure users act accordingly
- // For now, aliasing to client.listenersObject
- protected final ListenerSet<TargetObjectListener> listeners;
-
- public SctlTargetObject(SctlClient client, SctlTargetObjectsContainer objects,
- List<String> path, String kind, String value, String type) {
- this.client = client;
- this.joinedPath = StringUtils.join(path, PATH_SEPARATOR_STRING);
- this.path = PathUtils.extend(objects.getPath(), path);
- this.hash = computeHashCode();
- this.kind = kind;
- this.value = value;
- this.type = type;
-
- this.listeners = client.listenersObject;
- }
-
- public SctlTargetObject(SctlClient client, AbstractSctlObjectEntry entry) {
- this.client = client;
- this.joinedPath = entry.getPath().str;
- this.path = List.of(joinedPath.split(PATH_SEPARATOR_REGEX));
- this.hash = computeHashCode();
- this.kind = entry.getKind().str;
- this.value = entry.getValue().str;
- this.type = entry.getType().str;
-
- this.listeners = client.listenersObject;
- }
-
- @Override
- public boolean equals(Object obj) {
- return doEquals(obj);
- }
-
- @Override
- public int hashCode() {
- return hash;
- }
-
- protected void checkValid() {
- if (!valid) {
- throw new IllegalStateException(
- "This thread handle is no longer valid, i.e., the thread has been destroyed.");
- }
- }
-
- protected CompletableFuture<Map<String, TargetObject>> doGetAttributes() {
- return lazyAttributes.request();
- }
-
- protected CompletableFuture<Map<String, TargetObject>> doGetChildren() {
- return lazyElements.request();
- }
-
- @Override
- public SctlClient getModel() {
- return client;
- }
-
- @Override
- public Object getProtocolID() {
- return path;
- }
-
- @Override
- public List<String> getPath() {
- return path;
- }
-
- @Override
- public String getDisplay() {
- if (value != null && !value.equals("")) {
- if (type != null && !type.equals("")) {
- return value + ":" + type;
- }
- return value;
- }
- return "";
- //return getName() + " " + kind + " " + value + " " + type;
- }
-
- @Override
- public String getTypeHint() {
- return kind;
- }
-
- @Override
- public boolean isValid() {
- return valid;
- }
-
- @Override
- public CompletableFuture<? extends Map<String, ? extends TargetObject>> fetchElements() {
- return getModel().getElements(path);
- }
-
- @Override
- public CompletableFuture<? extends Map<String, ?>> fetchAttributes() {
- return getModel().getAttributes(path);
- }
-
- @Override
- public void addListener(TargetObjectListener l) {
- listeners.add(l);
- }
-
- @Override
- public void removeListener(TargetObjectListener l) {
- listeners.remove(l);
- }
-
- public String getJoinedPath() {
- return joinedPath;
- }
-
- @Override
- public synchronized Map<String, ? extends TargetObjectRef> getCachedElements() {
- if (lazyElements.isDone()) {
- return lazyElements.request().getNow(null);
- }
- return Map.of();
- }
-
- @Override
- public synchronized Map<String, ?> getCachedAttributes() {
- if (lazyAttributes.isDone()) {
- return lazyAttributes.request().getNow(null);
- }
- return Map.of();
- }
-
- protected void notifyAttributes(Map<String, TargetObject> map) {
- Delta<TargetObject, TargetObject> delta;
- synchronized (this) {
- CompletableFuture<Map<String, TargetObject>> future = lazyAttributes.provide();
- if (!future.isDone()) {
- future.complete(new TreeMap<>(TargetObjectKeyComparator.ATTRIBUTE));
- }
- Map<String, TargetObject> attrs = future.getNow(null);
- delta = Delta.computeAndSet(attrs, map, Delta.EQUAL);
- }
- listeners.fire.attributesChanged(this, delta.getKeysRemoved(), delta.added);
- }
-
- protected void notifyElements(Map<String, TargetObject> map) {
- Delta<TargetObject, TargetObject> delta;
- synchronized (this) {
- CompletableFuture<Map<String, TargetObject>> future = lazyElements.provide();
- if (!future.isDone()) {
- future.complete(new TreeMap<>(TargetObjectKeyComparator.ELEMENT));
- }
- Map<String, TargetObject> elems = future.getNow(null);
- delta = Delta.computeAndSet(elems, map, Delta.SAME);
- }
- listeners.fire.elementsChanged(this, delta.getKeysRemoved(), delta.added);
- }
-}
diff --git a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/client/SctlTargetObjectsContainer.java b/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/client/SctlTargetObjectsContainer.java
deleted file mode 100644
index d91a27a84e..0000000000
--- a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/client/SctlTargetObjectsContainer.java
+++ /dev/null
@@ -1,118 +0,0 @@
-/* ###
- * 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 ghidra.dbg.sctl.client;
-
-import java.io.InvalidObjectException;
-import java.util.*;
-import java.util.concurrent.CompletableFuture;
-import java.util.stream.Collectors;
-
-import org.apache.commons.lang3.StringUtils;
-
-import ghidra.dbg.agent.DefaultTargetObject;
-import ghidra.dbg.target.TargetObject;
-import ghidra.dbg.util.PathUtils;
-
-public class SctlTargetObjectsContainer
- extends DefaultTargetObject<SctlTargetObject, SctlTargetSession> {
-
- protected final Map<String, SctlTargetObject> objectsByJoined = new LinkedHashMap<>();
- protected final SctlClient client;
-
- public SctlTargetObjectsContainer(SctlTargetSession session) {
- super(session.client, session, "Objects", "ObjectsContainer");
- this.client = session.client;
- }
-
- /**
- * Create an object
- *
- * This is preferred to calling
- * {@link SctlTargetObject#SctlTargetObject(SctlClient, String, String, String, String, String)}
- * directly, since this will add the object to the client container.
- *
- * Note this does not check if another object already exists at the given path
- *
- * @param key the id for the object
- * @param sub the path used to identify the object terminating in the key
- * @param kind the generic container type
- * @params value the value of the object if it exists
- * @params type the type of the object if it exists
- * @return the new object proxy
- * @throws InvalidObjectException
- */
- protected SctlTargetObject create(String key, List<String> sub, String kind,
- String value, String type) throws InvalidObjectException {
- assert key.equals(PathUtils.getKey(sub));
- if (sub == null || sub.isEmpty()) {
- throw new IllegalArgumentException("sub cannot be null or empty");
- }
- List<String> fullPath = PathUtils.extend(getPath(), sub);
- List<String> parentPath = PathUtils.parent(fullPath);
- String joinedParent = StringUtils.join(parentPath, SctlTargetObject.PATH_SEPARATOR_STRING);
- TargetObject newParent =
- parentPath.equals(getPath()) ? this : objectsByJoined.get(joinedParent);
- if (newParent == null) {
- throw new IllegalArgumentException(
- "parent of newPath=" + newParent + ", which does not exist");
- }
-
- SctlTargetObject object = new SctlTargetObject(client, this, sub, kind, value, type);
- if (object.getTypeHint().equals("OBJECT_ERROR")) {
- throw new InvalidObjectException(object.getDisplay());
- }
- objectsByJoined.put(StringUtils.join(sub, SctlTargetObject.PATH_SEPARATOR_STRING), object);
- return object;
- }
-
- protected List<TargetObject> findObjectByKey(String key) {
- return objectsByJoined.values()
- .stream()
- .filter(o -> key.equals(o.getName()))
- .collect(Collectors.toList());
- }
-
- @Override
- public CompletableFuture<? extends TargetObject> fetchSuccessor(List<String> sub) {
- if (sub.isEmpty()) {
- return CompletableFuture.completedFuture(this);
- }
- String joinedSub = StringUtils.join(sub, SctlTargetObject.PATH_SEPARATOR_STRING);
- return CompletableFuture.completedFuture(getObject(joinedSub));
- }
-
- protected SctlTargetObject getObject(String sub) {
- return objectsByJoined.get(sub);
- }
-
- protected SctlTargetObject require(String sub) {
- SctlTargetObject object = objectsByJoined.get(sub);
- if (object == null) {
- throw new IllegalArgumentException("No such object: path=" + path);
- }
- return object;
- }
-
- protected void notifyAttributes(String sub, Map<String, TargetObject> map) {
- SctlTargetObject obj = require(sub);
- obj.notifyAttributes(map);
- }
-
- protected void notifyElements(String sub, Map<String, TargetObject> map) {
- SctlTargetObject obj = require(sub);
- obj.notifyElements(map);
- }
-}
diff --git a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/client/SctlTargetProcess.java b/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/client/SctlTargetProcess.java
deleted file mode 100644
index f98ca547d9..0000000000
--- a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/client/SctlTargetProcess.java
+++ /dev/null
@@ -1,278 +0,0 @@
-/* ###
- * 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 ghidra.dbg.sctl.client;
-
-import java.util.List;
-import java.util.Map;
-import java.util.concurrent.CompletableFuture;
-
-import ghidra.async.AsyncLazyValue;
-import ghidra.comm.util.BitmaskSet;
-import ghidra.dbg.agent.DefaultTargetObject;
-import ghidra.dbg.target.*;
-import ghidra.dbg.util.PathUtils;
-import ghidra.lifecycle.Internal;
-import ghidra.program.model.address.Address;
-import ghidra.program.model.address.AddressOverflowException;
-import ghidra.util.Msg;
-
-/**
- * A target process on the SCTL server
- */
-public class SctlTargetProcess extends DefaultTargetObject<TargetObject, SctlTargetProcessContainer>
- implements TargetProcess<SctlTargetProcess>, TargetAggregate,
- TargetExecutionStateful<SctlTargetProcess> {
- //protected static int READ_COALESCE_DELAY_MS = 100;
- //protected static int READ_PAGE_SIZE = 4096; // TODO: Make this configurable
-
- protected static final String PID_ATTRIBUTE_NAME = PREFIX_INVISIBLE + "pid";
- protected static final String PLATFORM_ATTRIBUTE_NAME = PREFIX_INVISIBLE + "platform";
-
- protected static String keyProcess(long ctlid) {
- return PathUtils.makeKey(indexProcess(ctlid));
- }
-
- protected static String indexProcess(long ctlid) {
- return PathUtils.makeIndex(ctlid);
- }
-
- protected final SctlClient client;
-
- protected final long primaryCtlid; // CTLID of "primary" thread
-
- protected final AsyncLazyValue<Void> lazyStat = new AsyncLazyValue<>(this::doStat);
- protected Long pid;
- protected final String platform;
-
- protected final SctlTargetThreadContainer threads;
- protected final SctlTargetModuleContainer modules;
- protected final SctlTargetMemory memory;
-
- /**
- * Construct a process
- *
- * SCTL does not have a distinct process object, so this is not technically a proxy object. It
- * is simply a container to help track threads and properly implement Ghidra's debugging model.
- *
- * @see SctlClient#createProcess(long, long)
- * @param client the client controlling the process
- * @param primaryCtlid any CTLID, preferably the first observed, belonging to the process
- * @param pid the PID, if known, of the process, or -1
- */
- protected SctlTargetProcess(SctlTargetProcessContainer processes, long primaryCtlid, Long pid,
- String platform) {
- super(processes.client, processes, keyProcess(primaryCtlid), "ProcessCTL");
- this.client = processes.client;
- this.primaryCtlid = primaryCtlid;
- this.pid = pid;
- this.platform = platform;
-
- this.memory = new SctlTargetMemory(this);
- this.modules = new SctlTargetModuleContainer(this);
- this.threads = new SctlTargetThreadContainer(this);
-
- changeAttributes(List.of(), Map.of( //
- PLATFORM_ATTRIBUTE_NAME, platform, // TODO: Use an environment object?
- memory.getName(), memory, //
- modules.getName(), modules, //
- threads.getName(), threads //
- ), "Initialized");
- if (pid != null) {
- changeAttributes(List.of(), Map.of( //
- PID_ATTRIBUTE_NAME, pid //
- ), "Fetched");
- }
- invalidateStat();
- }
-
- @Override
- public String getName() {
- return "Process CTL " + primaryCtlid;
- }
-
- @Override
- public SctlClient getModel() {
- return client;
- }
-
- /**
- * Create a thread proxy
- *
- * This is preferred to calling
- * {@link SctlTargetThread#SctlTargetThread(SctlTargetProcess, long, TargetThreadDisposition)}
- * directly, since this will add the thread to the process's and client's containers.
- *
- * @param ctlid the SCTL-assigned CTLID "control ID"
- * @param reason an explanation of the thread's existence
- * @return the new thread
- */
- protected SctlTargetThread createThread(long ctlid, String reason) {
- SctlTargetThread newThread = new SctlTargetThread(threads, this, ctlid);
- threads.put(ctlid, newThread, reason);
- return newThread;
- }
-
- protected void checkValid() {
- if (!valid) {
- throw new IllegalStateException(
- "This process handle is no longer valid, i.e., the process has been destroyed.");
- }
- }
-
- /**
- * Create a memory region
- *
- * This is preferred to calling
- * {@link SctlMemoryRegion#SctlMemoryRegion(SctlTargetProcess, String, Address, long, BitmaskSet)}
- * directly, since this will add the region to the process's container.
- *
- * @param file the name of the file defining the region
- * @param addr the starting address (VMA) of the region
- * @param len the length, in bytes, of the region
- * @param flags the permission flags of the region from the protocol message
- * @return the new region
- * @throws AddressOverflowException if the region exceeds the bounds of the memory space
- */
- @Internal
- public SctlTargetMemoryRegion createMemoryRegion(String file, long addr, long len,
- BitmaskSet<SctlMemoryProtection> flags) throws AddressOverflowException {
- Address start = client.addrMapper.mapOffsetToAddress(addr);
- SctlTargetMemoryRegion region = new SctlTargetMemoryRegion(memory, file, start, len, flags);
- memory.addRegion(region);
- return region;
- }
-
- protected void setThreadState(SctlTargetThread thread, TargetExecutionState state) {
- if (state == TargetExecutionState.RUNNING) {
- memory.invalidateMemoryCaches();
- }
- if (thread.getExecutionState() == TargetExecutionState.RUNNING) {
- if (state != TargetExecutionState.RUNNING) {
- // Forget what to do here....
- }
- }
- thread.setExecutionStateInternal(state);
- TargetExecutionState procState =
- isAnyThreadRunning() ? TargetExecutionState.RUNNING : TargetExecutionState.STOPPED;
- changeAttributes(List.of(), Map.of( //
- STATE_ATTRIBUTE_NAME, procState //
- ), "State changed");
- listeners.fire(TargetExecutionStateListener.class).executionStateChanged(this, procState);
- }
-
- protected boolean isAnyThreadRunning() {
- for (SctlTargetThread thread : threads.getCachedElements().values()) {
- if (thread.isRunning()) {
- return true;
- }
- }
- return false;
- }
-
- /**
- * Destroy a thread, invoking listeners
- *
- * @param ctlid the CTLID of the thread
- */
- protected void destroyThread(long ctlid, String reason) {
- SctlTargetThread removed = threads.removeByCtlid(ctlid, reason);
- if (removed == null) {
- return;
- }
- if (threads.getCachedElements().isEmpty()) {
- parent.destroy(primaryCtlid, reason);
- }
- }
-
- /**
- * Clear and re-request stat
- */
- protected void invalidateStat() {
- lazyStat.forget();
- modules.clear();
- memory.clearRegions();
- lazyStat.request().exceptionally(e -> {
- Msg.error(this, "Could not stat", e);
- return null;
- });
- }
-
- /**
- * Set the PID of this process
- *
- * Unfortunately, SCTL's {@code Rlaunch} does not provide the PID of the newly-launched process.
- * However, it can be retrieved via a {@code Tstat}. Thus overall, the PID an come from multiple
- * places. The client does not actively seek a PID, but will store it opportunistically. When a
- * process is created via {@code Tattach}, the PID is immediately known from the command and
- * stored. In other circumstances, the PID is stored if/when {@code Rstat} is observed. A call
- * to {@link #getPid()} will send a {@code Tstat} if the PID is not already known.
- *
- * Due to code organization, this method must be public, which is not ideal. Ghidra's
- * {@link TargetProcess} does not include this method, so it cannot be accessed without a cast,
- * but it can be accessed without reflection.
- *
- * Implementation note: The official sctl process control server tends to use the PID as the
- * CTLID; however, that appears to be an implementation decision on their part as nothing in the
- * specification requires it. Also, a second thread in the same process has a CTLID different
- * than the PID. Granted, its PID would be the same as its spawning thread.
- *
- * @param pid the PID
- */
- @Internal
- public void setPid(long pid) {
- this.pid = pid;
- parent.notifyProcPid(this, pid);
- changeAttributes(List.of(), Map.of( //
- PID_ATTRIBUTE_NAME, pid, //
- DISPLAY_ATTRIBUTE_NAME, getDisplay() //
- ), "Fetched");
- }
-
- protected CompletableFuture<Void> doStat() {
- // NOTE: Client populates fields on completion
- return client.stat(primaryCtlid);
- }
-
- public Long getPid() {
- return pid;
- }
-
- public String getPlatform() {
- return platform;
- }
-
- // TODO: Ensure someone calls stat
-
- @Override
- public String toString() {
- if (!valid) {
- return "<SCTL process (INVALID)>";
- }
- return "<SCTL process ctlid=" + primaryCtlid + ", pid=" + pid + ">";
- }
-
- @Override
- public synchronized String getDisplay() {
- if (!valid) {
- return "Process INVALID";
- }
- String exec = modules.getExecutablePath();
- if (exec == null) {
- return "Process " + pid;
- }
- return "Process " + pid + " " + exec;
- }
-}
diff --git a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/client/SctlTargetProcessContainer.java b/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/client/SctlTargetProcessContainer.java
deleted file mode 100644
index 3a5ad5f6a6..0000000000
--- a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/client/SctlTargetProcessContainer.java
+++ /dev/null
@@ -1,156 +0,0 @@
-/* ###
- * 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 ghidra.dbg.sctl.client;
-
-import java.util.*;
-
-import ghidra.dbg.agent.DefaultTargetObject;
-import ghidra.dbg.target.TargetExecutionStateful.TargetExecutionState;
-
-public class SctlTargetProcessContainer
- extends DefaultTargetObject<SctlTargetProcess, SctlTargetSession> {
-
- protected final SctlClient client;
-
- // ID proc by CTLID of its main thread, because PID is not always known
- private final Map<Long, SctlTargetProcess> procsByCtlid = new LinkedHashMap<>();
- private final Map<Long, SctlTargetProcess> procsByPid = new LinkedHashMap<>();
-
- // Manage the global lists here, but dole them out by proc
- private final Map<Long, SctlTargetThread> threadsByCtlid = new LinkedHashMap<>();
- private final Map<Long, SctlTargetModule> modulesByNsid = new LinkedHashMap<>();
-
- public SctlTargetProcessContainer(SctlTargetSession session) {
- super(session.client, session, "Processes", "ProcessContainer");
- this.client = session.client;
- }
-
- /**
- * Create a process
- *
- * This is preferred to calling
- * {@link SctlTargetProcess#SctlTargetProcess(SctlClient, long, long)} directly, since this will
- * add the process to the client container.
- *
- * @param ctlid the CTLID of the primary thread
- * @param pid the PID
- * @return the new process proxy
- */
- protected SctlTargetProcess create(long ctlid, Long pid, String platform) {
- SctlTargetProcess proc = new SctlTargetProcess(this, ctlid, pid, platform);
- procsByCtlid.put(ctlid, proc);
- changeElements(List.of(), List.of(proc), "Created");
- if (pid == null) {
- return proc;
- }
- notifyProcPid(proc, pid);
- return proc;
- }
-
- protected synchronized SctlTargetProcess getByCtlid(long ctlid) {
- return procsByCtlid.get(ctlid);
- }
-
- protected synchronized SctlTargetProcess require(long ctlid) {
- SctlTargetProcess proc = procsByCtlid.get(ctlid);
- if (proc == null) {
- throw new NoSuchElementException("No such process: primary ctlid=" + ctlid);
- }
- return proc;
- }
-
- protected synchronized void notifyProcPid(SctlTargetProcess proc, long pid) {
- SctlTargetProcess collision = procsByPid.put(pid, proc);
- if (collision != null && collision != proc) {
- throw new AssertionError("Process " + pid + " is already known");
- }
- }
-
- protected synchronized SctlTargetProcess getByPid(long pid) {
- return procsByPid.get(pid);
- }
-
- /**
- * Destroy a process
- *
- * This does not generate any SCTL command.
- *
- * @param ctlid the CTLID of the primary thread
- */
- protected SctlTargetProcess destroy(long ctlid, String reason) {
- SctlTargetProcess proc;
- synchronized (this) {
- proc = procsByCtlid.remove(ctlid);
- }
- if (proc == null) {
- throw new AssertionError("No such process: ctlid=" + ctlid);
- }
- Long pid = proc.getPid();
- if (pid != null) {
- synchronized (this) {
- proc = procsByPid.remove(pid);
- }
- if (proc == null) {
- throw new AssertionError("procByPid out of sync with procsByCtlid");
- }
- }
- changeElements(List.of(proc.getIndex()), List.of(), reason);
- return proc;
- }
-
- protected synchronized void putThread(long ctlid, SctlTargetThread thread) {
- threadsByCtlid.put(ctlid, thread);
- }
-
- protected synchronized SctlTargetThread requireThread(long ctlid) {
- SctlTargetThread thread = threadsByCtlid.get(ctlid);
- if (thread == null) {
- throw new NoSuchElementException("No such thread: ctlid=" + ctlid);
- }
- return thread;
- }
-
- protected void setThreadState(long ctlid, TargetExecutionState state) {
- SctlTargetThread thread = requireThread(ctlid);
- thread.setState(state);
- }
-
- protected synchronized SctlTargetThread removeThread(long ctlid) {
- return threadsByCtlid.remove(ctlid);
- }
-
- /**
- * Destroy a thread, invoking listeners
- *
- * @param ctlid the CTLID of the thread
- */
- protected void destroyThread(long ctlid, String reason) {
- SctlTargetThread thread = requireThread(ctlid);
- thread.process.destroyThread(ctlid, reason);
- }
-
- protected synchronized void putModule(long nsid, SctlTargetModule module) {
- modulesByNsid.put(nsid, module);
- }
-
- protected synchronized SctlTargetModule getModule(long nsid) {
- return modulesByNsid.get(nsid);
- }
-
- protected synchronized void removeAllModules(Map<Long, SctlTargetModule> modules) {
- modulesByNsid.keySet().removeAll(modules.keySet());
- }
-}
diff --git a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/client/SctlTargetRegisterDescription.java b/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/client/SctlTargetRegisterDescription.java
deleted file mode 100644
index 2e65d6449f..0000000000
--- a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/client/SctlTargetRegisterDescription.java
+++ /dev/null
@@ -1,56 +0,0 @@
-/* ###
- * 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 ghidra.dbg.sctl.client;
-
-import java.util.List;
-import java.util.Map;
-
-import ghidra.dbg.agent.DefaultTargetObject;
-import ghidra.dbg.target.TargetObject;
-import ghidra.dbg.target.TargetRegister;
-import ghidra.dbg.util.PathUtils;
-
-public class SctlTargetRegisterDescription
- extends DefaultTargetObject<TargetObject, SctlTargetRegisters>
- implements TargetRegister<SctlTargetRegisterDescription> {
-
- protected static String indexRegister(String name) {
- return name;
- }
-
- protected static String keyRegister(String name) {
- return PathUtils.makeKey(indexRegister(name));
- }
-
- protected final String name;
- protected final int bitLength;
-
- public SctlTargetRegisterDescription(SctlTargetRegisters registers, String name,
- int bitLength) {
- super(registers.client, registers, keyRegister(name), "Register");
- this.name = name;
- this.bitLength = bitLength;
-
- changeAttributes(List.of(), Map.of( //
- LENGTH_ATTRIBUTE_NAME, bitLength //
- ), "Initialized");
- }
-
- @Override
- public int getBitLength() {
- return bitLength;
- }
-}
diff --git a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/client/SctlTargetRegisters.java b/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/client/SctlTargetRegisters.java
deleted file mode 100644
index ee72bf62f6..0000000000
--- a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/client/SctlTargetRegisters.java
+++ /dev/null
@@ -1,187 +0,0 @@
-/* ###
- * 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 ghidra.dbg.sctl.client;
-
-import java.util.*;
-import java.util.concurrent.CompletableFuture;
-
-import ghidra.async.AsyncLazyValue;
-import ghidra.async.AsyncUtils;
-import ghidra.dbg.agent.DefaultTargetObject;
-import ghidra.dbg.sctl.protocol.common.AbstractSctlContext;
-import ghidra.dbg.sctl.protocol.common.SctlRegisterDefinition;
-import ghidra.dbg.target.*;
-import ghidra.dbg.util.CollectionUtils.Delta;
-
-public class SctlTargetRegisters
- extends DefaultTargetObject<SctlTargetRegisterDescription, SctlTargetThread> implements
- TargetRegisterBank<SctlTargetRegisters>, TargetRegisterContainer<SctlTargetRegisters> {
-
- protected final SctlClient client;
-
- protected final AsyncLazyValue<Map<String, SctlRegisterDefinition>> lazyRegDefs =
- new AsyncLazyValue<>(this::doGetRegDefs);
- protected final AsyncLazyValue<Map<Long, SctlRegisterDefinition>> lazyRegDefsById =
- new AsyncLazyValue<>(this::doGetRegDefsById);
- protected final AsyncLazyValue<Map<String, SctlTargetRegisterDescription>> lazyRegDescs =
- new AsyncLazyValue<>(this::doGetRegDescs);
-
- private final List<SctlRegisterDefinition> selectedRegisters = new ArrayList<>();
-
- private Map<String, byte[]> ctx = new LinkedHashMap<>();
- private boolean hasCtx = false;
-
- public SctlTargetRegisters(SctlTargetThread thread) {
- super(thread.client, thread, "Registers", "RegisterBank");
- this.client = thread.client;
-
- changeAttributes(List.of(), Map.of( //
- // TODO: Probably have one container for the whole client
- DESCRIPTIONS_ATTRIBUTE_NAME, this //
- ), "Initialized");
- }
-
- @Override
- public CompletableFuture<Void> requestElements(boolean refresh) {
- if (refresh) {
- lazyRegDescs.forget();
- lazyRegDefsById.forget();
- lazyRegDefs.forget();
- }
- return lazyRegDescs.request().thenApply(__ -> null);
- }
-
- @Override
- public CompletableFuture<? extends Map<String, byte[]>> readRegistersNamed(
- Collection<String> names) {
- parent.checkValid();
- return client.readRegisters(parent.ctlid);
- }
-
- @Override
- public CompletableFuture<Void> writeRegistersNamed(Map<String, byte[]> values) {
- parent.checkValid();
- return client.writeRegisters(parent.ctlid, values);
- }
-
- protected CompletableFuture<Void> selectRegisters(Set<SctlTargetRegisterDescription> descs) {
- // TODO: What if one of these is already executing?
- Set<String> curNames = new HashSet<>();
- Set<String> newNames = new HashSet<>();
- for (SctlRegisterDefinition def : selectedRegisters) {
- curNames.add(def.name.str);
- }
- for (TargetRegister<?> reg : descs) {
- newNames.add(reg.getName());
- }
- if (curNames.equals(newNames)) {
- return AsyncUtils.NIL;
- }
- return parent.process.client.chooseContext(parent.ctlid, descs);
- }
-
- protected CompletableFuture<Map<String, SctlRegisterDefinition>> doGetRegDefs() {
- return client.enumerateContext(parent.ctlid);
- }
-
- protected CompletableFuture<Map<Long, SctlRegisterDefinition>> doGetRegDefsById() {
- return lazyRegDefs.request().thenApply(this::reKeyDefsById);
- }
-
- protected Map<Long, SctlRegisterDefinition> reKeyDefsById(
- Map<String, SctlRegisterDefinition> defsByName) {
- Map<Long, SctlRegisterDefinition> result = new HashMap<>();
- for (SctlRegisterDefinition def : defsByName.values()) {
- result.put(def.regid, def);
- }
- return result;
- }
-
- protected CompletableFuture<Map<String, SctlTargetRegisterDescription>> doGetRegDescs() {
- return lazyRegDefs.request().thenApply(this::convertDefsToDescs);
- }
-
- protected Map<String, SctlTargetRegisterDescription> convertDefsToDescs(
- Map<String, SctlRegisterDefinition> defs) {
- Map<String, SctlTargetRegisterDescription> result = new LinkedHashMap<>();
- for (SctlRegisterDefinition def : defs.values()) {
- result.put(def.name.str,
- new SctlTargetRegisterDescription(this, def.name.str, (int) def.nbits));
- }
- changeElements(List.of(), result.values(), "Fetched");
- return result;
- }
-
- protected void updateContextIfPresent(AbstractSctlContext newCtx) {
- if (newCtx == null) {
- return;
- }
- newCtx.setSelectedRegisters(selectedRegisters);
- Map<String, byte[]> newAsMap = newCtx.toMap();
- Delta<byte[], byte[]> delta;
- synchronized (ctx) {
- delta = Delta.computeAndSet(ctx, newAsMap, Arrays::equals);
- }
- if (delta.added.isEmpty()) {
- return;
- }
- listeners.fire(TargetRegisterBankListener.class).registersUpdated(this, delta.added);
- }
-
- protected boolean hasContextSinceStop() {
- return hasCtx;
- }
-
- protected Map<String, byte[]> getContext() {
- synchronized (ctx) {
- return Map.copyOf(ctx);
- }
- }
-
- protected List<SctlRegisterDefinition> getSelectedRegisters() {
- return selectedRegisters;
- }
-
- protected void setSelectedRegisters(Collection<SctlRegisterDefinition> selectedRegisters) {
- if (!this.selectedRegisters.containsAll(selectedRegisters)) {
- this.hasCtx = false;
- }
- this.selectedRegisters.clear();
- this.selectedRegisters.addAll(selectedRegisters);
- }
-
- @Override
- public Map<String, byte[]> getCachedRegisters() {
- return getContext();
- }
-
- @Override
- public CompletableFuture<Void> invalidateCaches() {
- synchronized (ctx) {
- hasCtx = false;
- ctx.clear();
- }
- return super.invalidateCaches();
- }
-
- protected void invalidateCtx() {
- synchronized (ctx) {
- hasCtx = false;
- ctx.clear();
- }
- listeners.fire.invalidateCacheRequested(this);
- }
-}
diff --git a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/client/SctlTargetSection.java b/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/client/SctlTargetSection.java
deleted file mode 100644
index 065add5957..0000000000
--- a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/client/SctlTargetSection.java
+++ /dev/null
@@ -1,66 +0,0 @@
-/* ###
- * 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 ghidra.dbg.sctl.client;
-
-import java.util.List;
-import java.util.Map;
-
-import ghidra.dbg.agent.DefaultTargetObject;
-import ghidra.dbg.attributes.TypedTargetObjectRef;
-import ghidra.dbg.target.*;
-import ghidra.dbg.util.PathUtils;
-import ghidra.program.model.address.AddressRange;
-
-public class SctlTargetSection extends DefaultTargetObject<TargetObject, TargetObject>
- implements TargetSection<SctlTargetSection> {
-
- protected static String keySection(String name) {
- return PathUtils.makeKey(indexSection(name));
- }
-
- protected static String indexSection(String name) {
- return name;
- }
-
- protected final SctlClient client;
-
- protected final SctlTargetModule module;
- protected final AddressRange range;
-
- public SctlTargetSection(SctlTargetSectionContainer sections, SctlTargetModule module,
- String name, AddressRange range) {
- super(sections.client, sections, keySection(name), "Section");
- this.client = sections.client;
-
- this.module = module;
- this.range = range;
-
- changeAttributes(List.of(), Map.of( //
- MODULE_ATTRIBUTE_NAME, module, //
- RANGE_ATTRIBUTE_NAME, range //
- ), "Initialized");
- }
-
- @Override
- public TypedTargetObjectRef<? extends TargetModule<?>> getModule() {
- return module;
- }
-
- @Override
- public AddressRange getRange() {
- return range;
- }
-}
diff --git a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/client/SctlTargetSectionContainer.java b/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/client/SctlTargetSectionContainer.java
deleted file mode 100644
index 0f131efda2..0000000000
--- a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/client/SctlTargetSectionContainer.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/* ###
- * 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 ghidra.dbg.sctl.client;
-
-import java.util.List;
-
-import ghidra.dbg.agent.DefaultTargetObject;
-import ghidra.program.model.address.*;
-import ghidra.util.Msg;
-
-public class SctlTargetSectionContainer
- extends DefaultTargetObject<SctlTargetSection, SctlTargetModule> {
-
- protected final SctlClient client;
-
- public SctlTargetSectionContainer(SctlTargetModule module) {
- super(module.client, module, "Sections", "SectionContainer");
- this.client = module.client;
- }
-
- protected void add(String name, Address start, long length) {
- if (length == 0) {
- Msg.trace(this, "Ignoring 0-length section: " + name);
- return;
- }
-
- AddressRange range;
- try {
- range = new AddressRangeImpl(start, length);
- }
- catch (AddressOverflowException e) {
- throw new IllegalArgumentException(e);
- }
- SctlTargetSection section = new SctlTargetSection(this, parent, name, range);
- changeElements(List.of(), List.of(section), "Fetched");
- }
-}
diff --git a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/client/SctlTargetSession.java b/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/client/SctlTargetSession.java
deleted file mode 100644
index 5445c2e488..0000000000
--- a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/client/SctlTargetSession.java
+++ /dev/null
@@ -1,133 +0,0 @@
-/* ###
- * 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 ghidra.dbg.sctl.client;
-
-import java.util.*;
-import java.util.concurrent.CompletableFuture;
-
-import org.apache.commons.lang3.exception.ExceptionUtils;
-
-import ghidra.async.AsyncUtils;
-import ghidra.async.TypeSpec;
-import ghidra.dbg.agent.DefaultTargetModelRoot;
-import ghidra.dbg.attributes.TargetObjectRef;
-import ghidra.dbg.attributes.TypedTargetObjectRef;
-import ghidra.dbg.error.DebuggerModelNoSuchPathException;
-import ghidra.dbg.error.DebuggerModelTypeException;
-import ghidra.dbg.target.*;
-import ghidra.dbg.target.TargetConsole.Channel;
-import ghidra.dbg.target.TargetLauncher.TargetCmdLineLauncher;
-import ghidra.dbg.util.PathUtils;
-
-public class SctlTargetSession extends DefaultTargetModelRoot implements
- TargetAttacher<SctlTargetSession>,
- TargetFocusScope<SctlTargetSession>,
- TargetInterpreter<SctlTargetSession>,
- TargetCmdLineLauncher<SctlTargetSession> {
-
- protected final SctlClient client;
-
- protected final SctlTargetAttachableContainer attachable;
- protected final SctlTargetProcessContainer processes;
- protected final SctlTargetObjectsContainer objects;
-
- public SctlTargetSession(SctlClient client) {
- super(client, "Session");
- this.client = client;
-
- attachable = new SctlTargetAttachableContainer(this);
- processes = new SctlTargetProcessContainer(this);
- objects = new SctlTargetObjectsContainer(this);
-
- changeAttributes(List.of(), Map.of( //
- attachable.getName(), attachable, //
- processes.getName(), processes, //
- objects.getName(), objects //
- ), "Initialized");
- }
-
- @Override
- public CompletableFuture<Void> attach(long pid) {
- return client.attach(pid).thenApply(__ -> null);
- }
-
- @Override
- public CompletableFuture<Void> attach(TypedTargetObjectRef<? extends TargetAttachable<?>> ref) {
- client.assertMine(TargetObjectRef.class, ref);
- // NOTE: These can change at any time. Just use the path to derive the target PID
- if (!Objects.equals(PathUtils.parent(ref.getPath()), attachable.getPath())) {
- throw new DebuggerModelTypeException(
- "Target of attach must be a child of " + attachable.getPath());
- }
- long pid;
- try {
- pid = Long.parseLong(ref.getIndex());
- }
- catch (IllegalArgumentException e) {
- throw new DebuggerModelNoSuchPathException("Badly-formatted PID", e);
- }
- return client.attach(pid).thenApply(__ -> null);
- }
-
- @Override
- public CompletableFuture<Void> execute(String cmd) {
- return executeCapture(cmd).thenAccept((out) -> {
- // TODO/HACK: This (re)direction should be done by the agent, not the client
- // TODO: Need a flag in EXEC command indicating capture
- listeners.fire(TargetInterpreterListener.class)
- .consoleOutput(this, Channel.STDOUT, out);
- }).exceptionally(e -> {
- // TODO: Again, non-captured error output should be sent via Aevent by agent
- listeners.fire(TargetInterpreterListener.class)
- .consoleOutput(this, Channel.STDERR, e.getMessage() + "\n");
- return ExceptionUtils.rethrow(e);
- });
- }
-
- @Override
- public CompletableFuture<String> executeCapture(String cmd) {
- return client.executeCapture(cmd);
- }
-
- @Override
- public CompletableFuture<Void> launch(List<String> args) {
- return client.launch(args).thenApply(__ -> null);
- }
-
- @Override
- public CompletableFuture<Void> requestFocus(TargetObjectRef ref) {
- return AsyncUtils.sequence(TypeSpec.VOID).then(seq -> {
- getModel().fetchModelObject(ref.getPath()).handle(seq::next);
- }, TypeSpec.cls(TargetObject.class)).then((obj, seq) -> {
- if (!(obj instanceof SctlTargetThread)) {
- throw new DebuggerModelTypeException("Can only focus threads");
- }
- SctlTargetThread thread = (SctlTargetThread) obj;
- thread.process.client.focusThread(thread.ctlid).handle(seq::exit);
- }).finish();
- }
-
- protected void fireConsoleOutput(Channel channel, String out) {
- listeners.fire(TargetInterpreterListener.class).consoleOutput(this, channel, out);
- }
-
- protected void fireFocused(TargetObject focused) {
- changeAttributes(List.of(), Map.of( //
- FOCUS_ATTRIBUTE_NAME, focused //
- ), "Focus changed");
- listeners.fire(TargetFocusScopeListener.class).focusChanged(this, focused);
- }
-}
diff --git a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/client/SctlTargetStructDataType.java b/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/client/SctlTargetStructDataType.java
deleted file mode 100644
index bd010992ce..0000000000
--- a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/client/SctlTargetStructDataType.java
+++ /dev/null
@@ -1,56 +0,0 @@
-/* ###
- * 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 ghidra.dbg.sctl.client;
-
-import java.util.List;
-import java.util.concurrent.CompletableFuture;
-
-import ghidra.async.AsyncUtils;
-import ghidra.async.TypeSpec;
-import ghidra.dbg.sctl.protocol.types.*;
-
-public class SctlTargetStructDataType
- extends SctlTargetCompositeDataType<SctlTargetStructDataType> {
-
- public static class Ref extends AbstractRef<SctlTargetStructDataType> {
- protected final SctlStructTypeName nStruct;
-
- public Ref(SctlTargetDataTypeNamespace types, SctlStructTypeName nStruct) {
- super(types, nStruct);
- this.nStruct = nStruct;
- }
-
- @Override
- protected CompletableFuture<? extends SctlTargetStructDataType> doGet() {
- return AsyncUtils.sequence(TypeSpec.cls(SctlTargetStructDataType.class)).then(seq -> {
- types.getTypeDef(nStruct).handle(seq::next);
- }, TypeSpec.cls(SelSctlTypeDefinition.class)).then((def, seq) -> {
- SctlStructTypeDefinition dStruct = (SctlStructTypeDefinition) def.sel;
- SctlTargetStructDataType tStruct =
- new SctlTargetStructDataType(types, nStruct, dStruct);
- tStruct.collectFields().thenApply(__ -> tStruct).handle(seq::next);
- }, TypeSpec.cls(SctlTargetStructDataType.class)).then((tStruct, seq) -> {
- types.changeElements(List.of(), List.of(tStruct), "Fetched");
- seq.exit(tStruct);
- }).finish();
- }
- }
-
- protected SctlTargetStructDataType(SctlTargetDataTypeNamespace types,
- SctlStructTypeName nStruct, SctlStructTypeDefinition dStruct) {
- super(types, nStruct, dStruct, NamedDataTypeKind.STRUCT, "StructType");
- }
-}
diff --git a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/client/SctlTargetSymbol.java b/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/client/SctlTargetSymbol.java
deleted file mode 100644
index bd02b65158..0000000000
--- a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/client/SctlTargetSymbol.java
+++ /dev/null
@@ -1,118 +0,0 @@
-/* ###
- * 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 ghidra.dbg.sctl.client;
-
-import java.util.List;
-import java.util.Map;
-import java.util.concurrent.CompletableFuture;
-
-import ghidra.comm.util.BitmaskSet;
-import ghidra.dbg.agent.DefaultTargetObject;
-import ghidra.dbg.attributes.TargetDataType;
-import ghidra.dbg.sctl.client.depr.DebuggerAddressMapper;
-import ghidra.dbg.sctl.protocol.common.SctlSymbol;
-import ghidra.dbg.sctl.protocol.consts.Stype;
-import ghidra.dbg.sctl.protocol.types.SelSctlTypeName;
-import ghidra.dbg.target.TargetObject;
-import ghidra.dbg.target.TargetSymbol;
-import ghidra.dbg.util.PathUtils;
-import ghidra.program.model.address.Address;
-
-/**
- * A symbol retrieved by the SCTL client
- *
- * Implementation note: The type of the symbol is lazily requested.
- */
-public class SctlTargetSymbol extends DefaultTargetObject<TargetObject, SctlTargetSymbolNamespace>
- implements TargetSymbol<SctlTargetSymbol> {
-
- protected static String keySymbol(SctlSymbol sym) {
- return PathUtils.makeKey(indexSymbol(sym));
- }
-
- protected static String indexSymbol(SctlSymbol sym) {
- return sym.name.str;
- }
-
- protected final SctlClient client;
-
- protected final SctlTargetModule module;
- protected final BitmaskSet<Stype> flags;
- protected final SelSctlTypeName tname;
- protected TargetDataType dataType;
- protected final Address value;
- protected final long size;
-
- /**
- * Construct a new symbol description
- *
- * @param module the namespace containing the symbol
- * @param sym the symbol description from the protocol message
- * @param mapper the client's address mapper
- */
- public SctlTargetSymbol(SctlTargetSymbolNamespace symbols, SctlTargetModule module,
- SctlSymbol sym, DebuggerAddressMapper mapper) {
- super(symbols.client, symbols, keySymbol(sym), "Symbol");
- this.client = symbols.client;
-
- this.module = module;
- this.flags = sym.flags;
- this.tname = sym.tname;
- if (isConstant()) {
- this.value = mapper.getAddressFactory().getConstantAddress(sym.val);
- }
- else {
- this.value = mapper.mapOffsetToAddress(sym.val);
- }
- this.size = sym.size;
-
- changeAttributes(List.of(), Map.of(
- VALUE_ATTRIBUTE_NAME, value,
- DATA_TYPE_ATTRIBUTE_NAME, dataType,
- SIZE_ATTRIBUTE_NAME, size //
- ), "Initialized");
- }
-
- protected CompletableFuture<SctlTargetSymbol> init() {
- return module.types.getType(tname.sel).thenApply(t -> {
- dataType = t;
- changeAttributes(List.of(), Map.of( //
- DATA_TYPE_ATTRIBUTE_NAME, t //
- ), "Initialized");
- return this;
- });
- }
-
- @Override
- public TargetDataType getDataType() {
- return dataType;
- }
-
- @Override
- public boolean isConstant() {
- return flags.contains(Stype.Senum);
- }
-
- @Override
- public Address getValue() {
- return value;
- }
-
- @Override
- public long getSize() {
- return size;
- }
-}
diff --git a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/client/SctlTargetSymbolNamespace.java b/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/client/SctlTargetSymbolNamespace.java
deleted file mode 100644
index f9e0ab61b5..0000000000
--- a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/client/SctlTargetSymbolNamespace.java
+++ /dev/null
@@ -1,139 +0,0 @@
-/* ###
- * 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 ghidra.dbg.sctl.client;
-
-import static ghidra.async.AsyncUtils.sequence;
-
-import java.util.*;
-import java.util.concurrent.CompletableFuture;
-
-import ghidra.async.*;
-import ghidra.dbg.agent.DefaultTargetObject;
-import ghidra.dbg.sctl.protocol.SctlPacket;
-import ghidra.dbg.sctl.protocol.common.SctlSymbol;
-import ghidra.dbg.sctl.protocol.common.reply.SctlEnumerateSymbolsReply;
-import ghidra.dbg.sctl.protocol.common.reply.SctlLookupSymbolReply;
-import ghidra.dbg.sctl.protocol.common.request.SctlEnumerateSymbolsRequest;
-import ghidra.dbg.sctl.protocol.common.request.SctlLookupSymbolRequest;
-import ghidra.dbg.target.TargetSymbolNamespace;
-
-public class SctlTargetSymbolNamespace
- extends DefaultTargetObject<SctlTargetSymbol, SctlTargetModule>
- implements TargetSymbolNamespace<SctlTargetSymbolNamespace> {
-
- protected final SctlClient client;
-
- private final AsyncLazyMap<String, SctlTargetSymbol> lazySymbols =
- new AsyncLazyMap<>(new HashMap<>(), this::doGetSymbol);
- private final AsyncLazyValue<Map<String, SctlTargetSymbol>> allSymbols =
- new AsyncLazyValue<>(this::doGetAllSymbols);
-
- public SctlTargetSymbolNamespace(SctlTargetModule module) {
- super(module.client, module, "Symbols", "SymbolNamespace");
- this.client = module.client;
- }
-
- public CompletableFuture<SctlTargetSymbol> getSymbol(String name) {
- return lazySymbols.get(name);
- }
-
- protected CompletableFuture<SctlTargetSymbol> doGetSymbol(String name) {
- SctlLookupSymbolRequest req = new SctlLookupSymbolRequest(parent.nsid, name);
- return sequence(TypeSpec.cls(SctlTargetSymbol.class)).then((seq) -> {
- client.sendCommand(req).handle(seq::next);
- }, TypeSpec.cls(SctlPacket.class)).then((reply, seq) -> {
- SctlTargetSymbol sym = finishGetSymbol(req, reply);
- sym.init().handle(seq::exit);
- }).finish();
- }
-
- protected CompletableFuture<SctlTargetSymbol> processBusGetSymbol(int tag,
- SctlLookupSymbolRequest req) {
- CompletableFuture<SctlTargetSymbol> promise = lazySymbols.put(req.name.str);
- return sequence(TypeSpec.cls(SctlTargetSymbol.class)).then((seq) -> {
- client.recvTag(tag).handle(seq::next);
- }, TypeSpec.cls(SctlPacket.class)).then((reply, seq) -> {
- SctlTargetSymbol sym = finishGetSymbol(req, reply);
- sym.init().handle(seq::next);
- }, TypeSpec.cls(SctlTargetSymbol.class)).then((sym, seq) -> {
- promise.complete(sym);
- seq.exit(sym);
- }).finish();
- }
-
- protected SctlTargetSymbol finishGetSymbol(SctlLookupSymbolRequest req, SctlPacket reply) {
- SctlLookupSymbolReply lookedup =
- SctlClient.checkReply(req, SctlLookupSymbolReply.class, reply);
- SctlTargetSymbol sym = new SctlTargetSymbol(this, parent, lookedup.sym, client.addrMapper);
- changeElements(List.of(), List.of(sym), "Fetched");
- return sym;
- }
-
- /*
- * Methods for Tenumsym
- */
-
- @Override
- public CompletableFuture<Void> requestElements(boolean refresh) {
- if (refresh) {
- allSymbols.forget();
- lazySymbols.clear();
- }
- return allSymbols.request().thenApply(__ -> null);
- }
-
- @Override
- public CompletableFuture<SctlTargetSymbol> fetchElement(String index) {
- return lazySymbols.get(index);
- }
-
- private CompletableFuture<Map<String, SctlTargetSymbol>> doGetAllSymbols() {
- SctlEnumerateSymbolsRequest req = new SctlEnumerateSymbolsRequest(parent.nsid);
- return sequence(TypeSpec.map(String.class, SctlTargetSymbol.class)).then((seq) -> {
- client.sendCommand(req).handle(seq::next);
- }, TypeSpec.cls(SctlPacket.class)).then((reply, seq) -> {
- seq.exit(finishGetAllSymbols(req, reply));
- }).finish();
- }
-
- CompletableFuture<Map<String, SctlTargetSymbol>> processBusGetAllSymbols(int tag,
- SctlEnumerateSymbolsRequest req) {
- CompletableFuture<Map<String, SctlTargetSymbol>> promise = allSymbols.provide();
- return sequence(TypeSpec.map(String.class, SctlTargetSymbol.class)).then((seq) -> {
- client.recvTag(tag).handle(seq::next);
- }, TypeSpec.cls(SctlPacket.class)).then((reply, seq) -> {
- Map<String, SctlTargetSymbol> syms = finishGetAllSymbols(req, reply);
- promise.complete(syms);
- seq.exit(syms);
- }).finish();
- }
-
- Map<String, SctlTargetSymbol> finishGetAllSymbols(SctlEnumerateSymbolsRequest req,
- SctlPacket reply) {
- SctlEnumerateSymbolsReply enumed =
- SctlClient.checkReply(req, SctlEnumerateSymbolsReply.class, reply);
- synchronized (lazySymbols) {
- for (SctlSymbol sym : enumed.syms) {
- SctlTargetSymbol symbol =
- new SctlTargetSymbol(this, parent, sym, client.addrMapper);
- lazySymbols.put(sym.name.str, symbol);
- }
- }
- Map<String, SctlTargetSymbol> result = lazySymbols.getCompletedMap();
- changeElements(List.of(), result.values(), "Fetched");
- return result;
- }
-}
diff --git a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/client/SctlTargetThread.java b/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/client/SctlTargetThread.java
deleted file mode 100644
index ce426e3530..0000000000
--- a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/client/SctlTargetThread.java
+++ /dev/null
@@ -1,278 +0,0 @@
-/* ###
- * 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 ghidra.dbg.sctl.client;
-
-import java.util.*;
-import java.util.concurrent.CompletableFuture;
-
-import ghidra.dbg.agent.DefaultTargetObject;
-import ghidra.dbg.sctl.protocol.consts.Mkind;
-import ghidra.dbg.target.*;
-import ghidra.dbg.util.PathUtils;
-import ghidra.program.model.address.Address;
-import ghidra.util.Msg;
-
-/**
- * A target thread on the SCTL server
- */
-public class SctlTargetThread extends DefaultTargetObject<TargetObject, SctlTargetThreadContainer>
- implements TargetThread<SctlTargetThread>, TargetDetachable<SctlTargetThread>,
- TargetExecutionStateful<SctlTargetThread>, TargetInterruptible<SctlTargetThread>,
- TargetKillable<SctlTargetThread>, TargetResumable<SctlTargetThread>,
- TargetSteppable<SctlTargetThread> {
- private static final String EXIT_STATUS_ATTRIBUTE_NAME = PREFIX_INVISIBLE + "exit_status";
-
- protected static String keyThread(long ctlid) {
- return PathUtils.makeKey(indexThread(ctlid));
- }
-
- protected static String indexThread(long ctlid) {
- return PathUtils.makeIndex(ctlid);
- }
-
- protected final SctlClient client;
-
- protected final SctlTargetProcess process;
- protected final long ctlid;
-
- private TargetExecutionState state = TargetExecutionState.STOPPED;
-
- protected final SctlTargetBreakpointContainer breakpoints;
- protected final SctlTargetRegisters registers;
-
- /**
- * Construct a thread proxy
- *
- * @see SctlTargetProcess#createThread(long, TargetThreadDisposition)
- * @param process the process owning the thread
- * @param ctlid the SCTL-assigned CTLID "control ID"
- * @param disposition an explanation of the thread's existence
- */
- SctlTargetThread(SctlTargetThreadContainer threads, SctlTargetProcess process, long ctlid) {
- super(threads.client, threads, keyThread(ctlid), "Thread");
- this.client = threads.client;
- this.process = process;
- this.ctlid = ctlid;
-
- this.breakpoints = new SctlTargetBreakpointContainer(this);
- this.registers = new SctlTargetRegisters(this);
-
- changeAttributes(List.of(), Map.of( //
- STATE_ATTRIBUTE_NAME, state, //
- breakpoints.getName(), breakpoints, //
- registers.getName(), registers //
- ), "Initialized");
- }
-
- protected void checkValid() {
- if (!valid) {
- throw new IllegalStateException(
- "This thread handle is no longer valid, i.e., the thread has been destroyed.");
- }
- }
-
- @Override
- public TargetExecutionState getExecutionState() {
- return state;
- }
-
- /**
- * Change the thread's state, invoking thread and/or process listeners
- *
- * @param state the new state
- */
- protected void setState(TargetExecutionState state) {
- process.setThreadState(this, state);
- }
-
- protected boolean isRunning() {
- return state == TargetExecutionState.RUNNING;
- }
-
- /**
- * Create a breakpoint proxy
- *
- * This does not generate a {@link Mkind#Tsettrap} command. This only creates the proxy and
- * stores it in the thread's container.
- *
- * This is preferred to calling
- * {@link SctlBreakpoint#SctlBreakpoint(SctlTargetThread, long, long)} directly, since this will
- * add the breakpoint to the thread's container.
- *
- * @param trpid the SCTL-assigned TRPID "trap ID"
- * @param addr the address of the trap
- * @return the new breakpoint
- */
- protected SctlTargetBreakpoint createBreakpoint(long trpid, long addr) {
- SctlTargetBreakpoint bpt = new SctlTargetBreakpoint(breakpoints, this, trpid, addr);
- breakpoints.put(trpid, bpt);
- return bpt;
- }
-
- /**
- * Destroy a breakpoint proxy
- *
- * This simply removes the specified proxy from the thread's container and sets the breakpoint's
- * state to cleared. This does not generate a {@code Tclrtrap} command. It is merely a tracking
- * mechanism.
- *
- * @param trpid the SCTL-assigned TRPID "trap ID"
- * @return the removed breakpoint
- */
- protected SctlTargetBreakpoint destroyBreakpoint(long trpid) {
- SctlTargetBreakpoint bkpt = breakpoints.removeByTrpid(trpid);
- if (bkpt == null) {
- Msg.warn(this, "No such SCTL trap: " + trpid);
- return null;
- }
- bkpt.cleared = true;
- return bkpt;
- }
-
- /**
- * Copy all breakpoints from a given thread's container into this one's container
- *
- * @param src the thread whose breakpoints to copy
- */
- protected void copyBreakpointsFrom(SctlTargetThread src) {
- Map<Long, SctlTargetBreakpoint> copied = new LinkedHashMap<>();
- synchronized (src.breakpoints) {
- for (SctlTargetBreakpoint b : src.breakpoints.getAll()) {
- SctlTargetBreakpoint c = new SctlTargetBreakpoint(b, breakpoints);
- copied.put(c.trpid, c);
- }
- }
- breakpoints.putAll(copied);
- }
-
- protected void setExecutionStateInternal(TargetExecutionState state) {
- this.state = state;
- if (state == TargetExecutionState.STOPPED) {
- registers.invalidateCtx();
- }
- changeAttributes(List.of(), Map.of( //
- STATE_ATTRIBUTE_NAME, state //
- ), "State changed");
- listeners.fire(TargetExecutionStateListener.class).executionStateChanged(this, state);
- }
-
- @Override
- public CompletableFuture<Void> resume() {
- checkValid();
- return process.client.resume(ctlid);
- }
-
- @Override
- public CompletableFuture<Void> step(TargetStepKind kind) {
- if (kind != TargetStepKind.INTO) {
- throw new UnsupportedOperationException("step kind = " + kind);
- }
- checkValid();
- return process.client.step(ctlid);
- }
-
- // SCTL-only
- /**
- * Snapshot a thread
- *
- * Creates an exact copy of this thread in a new process. It is unclear what happens if there
- * are other threads in the source process. See {@code Tsnap} in the SCTL documentation.
- *
- * @return a proxy to the new copy
- */
- public CompletableFuture<SctlTargetThread> snap() {
- checkValid();
- return process.client.snap(ctlid);
- }
-
- @Override
- public CompletableFuture<Void> interrupt() {
- checkValid();
- return process.client.interrupt(ctlid);
- }
-
- protected CompletableFuture<SctlTargetBreakpoint> setBreakpoint(Address address) {
- checkValid();
- return process.client.setTrap(ctlid, address, 1, false, false, false);
- }
-
- @Override
- public CompletableFuture<Void> detach() {
- checkValid();
- return process.client.detachThread(ctlid);
- }
-
- @Override
- public CompletableFuture<Void> kill() {
- checkValid();
- return process.client.killThread(ctlid);
- }
-
- // SCTL-only
- /**
- * Select which events cause a thread to stop
- *
- * This allows trapping on events other than breakpoints. See {@code Ttrace} in the SCTL
- * documentation.
- *
- * @param mode indicates whether to enable or disable the given events
- * @param events the events to enable or disable
- * @return a future which completes when the request is confirmed
- */
- public CompletableFuture<Void> traceEvents(SctlTrace.Mode mode, Set<SctlTrace.Event> events) {
- checkValid();
- return process.client.traceEvents(ctlid, mode, events);
- }
-
- @Override
- public String toString() {
- StringBuilder sb = new StringBuilder();
- sb.append("<SCTL thread ");
- if (!valid) {
- sb.append("(INVALID) ");
- }
- sb.append("ctlid=");
- sb.append(ctlid);
- sb.append(", pid=");
- sb.append(process.getPid());
- sb.append(", state=");
- sb.append(state);
- sb.append(">");
- return sb.toString();
- }
-
- @Override
- public String getDisplay() {
- if (!valid) {
- return "Thread INVALID CTL";
- }
- return "Thread CTL " + ctlid + " (" + state + ")";
- }
-
- /**
- * Destroy this thread
- */
- protected void destroy(String reason) {
- process.destroyThread(ctlid, reason);
- }
-
- protected void setExitStatusCode(long status) {
- // NOTE: I hope the user has a listener. Otherwise, it's gone in an instant.
- changeAttributes(List.of(), Map.of( //
- EXIT_STATUS_ATTRIBUTE_NAME, status //
- ), "Exited");
- }
-}
diff --git a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/client/SctlTargetThreadContainer.java b/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/client/SctlTargetThreadContainer.java
deleted file mode 100644
index 8ee4993803..0000000000
--- a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/client/SctlTargetThreadContainer.java
+++ /dev/null
@@ -1,68 +0,0 @@
-/* ###
- * 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 ghidra.dbg.sctl.client;
-
-import java.util.*;
-import java.util.stream.Collectors;
-
-import ghidra.dbg.agent.DefaultTargetObject;
-import ghidra.dbg.util.PathUtils;
-
-public class SctlTargetThreadContainer
- extends DefaultTargetObject<SctlTargetThread, SctlTargetProcess> {
-
- protected final SctlClient client;
-
- private final Map<Long, SctlTargetThread> threadsByCtlid = new LinkedHashMap<>();
-
- public SctlTargetThreadContainer(SctlTargetProcess process) {
- super(process.client, process, "Threads", "ThreadContainer");
- this.client = process.client;
- }
-
- protected void put(long ctlid, SctlTargetThread newThread, String reason) {
- synchronized (this) {
- threadsByCtlid.put(ctlid, newThread);
- client.session.processes.putThread(ctlid, newThread);
- }
- changeElements(List.of(), List.of(newThread), reason);
- }
-
- protected synchronized SctlTargetThread getByCtlid(long ctlid) {
- return threadsByCtlid.get(ctlid);
- }
-
- protected SctlTargetThread removeByCtlid(long ctlid, String reason) {
- SctlTargetThread removed;
- synchronized (this) {
- removed = threadsByCtlid.remove(ctlid);
- client.session.processes.removeThread(ctlid);
- }
- if (removed != null) {
- changeElements(List.of(PathUtils.makeIndex(ctlid)), List.of(), reason);
- }
- return removed;
- }
-
- protected void removeOthers(SctlTargetThread but, String reason) {
- Set<String> others = threadsByCtlid.keySet()
- .stream()
- .map(PathUtils::makeIndex)
- .filter(i -> i != but.getIndex())
- .collect(Collectors.toSet());
- changeElements(others, List.of(), reason);
- }
-}
diff --git a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/client/SctlTargetTypedefDataType.java b/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/client/SctlTargetTypedefDataType.java
deleted file mode 100644
index 6b6011af33..0000000000
--- a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/client/SctlTargetTypedefDataType.java
+++ /dev/null
@@ -1,67 +0,0 @@
-/* ###
- * 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 ghidra.dbg.sctl.client;
-
-import java.util.List;
-import java.util.concurrent.CompletableFuture;
-
-import ghidra.async.AsyncUtils;
-import ghidra.async.TypeSpec;
-import ghidra.dbg.sctl.protocol.types.*;
-
-public class SctlTargetTypedefDataType
- extends SctlTargetNamedDataType<SctlTargetTypedefDataType, SctlTargetTypedefDef> {
-
- public static class Ref extends AbstractRef<SctlTargetTypedefDataType> {
- protected final SctlTypedefTypeName nTypedef;
-
- public Ref(SctlTargetDataTypeNamespace types, SctlTypedefTypeName nTypedef) {
- super(types, nTypedef);
- this.nTypedef = nTypedef;
- }
-
- @Override
- protected CompletableFuture<? extends SctlTargetTypedefDataType> doGet() {
- return AsyncUtils.sequence(TypeSpec.cls(SctlTargetTypedefDataType.class)).then(seq -> {
- types.getTypeDef(nTypedef).handle(seq::next);
- }, TypeSpec.cls(SelSctlTypeDefinition.class)).then((def, seq) -> {
- SctlTypedefTypeDefinition dTypedef = (SctlTypedefTypeDefinition) def.sel;
- SctlTargetTypedefDataType tTypedef =
- new SctlTargetTypedefDataType(types, nTypedef, dTypedef);
- tTypedef.collectDef().thenApply(__ -> tTypedef).handle(seq::next);
- }, TypeSpec.cls(SctlTargetTypedefDataType.class)).then((tTypedef, seq) -> {
- types.changeElements(List.of(), List.of(tTypedef), "Fetched");
- seq.exit(tTypedef);
- }).finish();
- }
- }
-
- // TODO: Dispose of this once converted?
- protected final AbstractSctlTypeName nDef;
-
- public SctlTargetTypedefDataType(SctlTargetDataTypeNamespace types, SctlTypedefTypeName tname,
- SctlTypedefTypeDefinition dTypedef) {
- super(types, tname, NamedDataTypeKind.TYPEDEF, "TypedefType");
- this.nDef = dTypedef.tname.sel;
- }
-
- protected CompletableFuture<Void> collectDef() {
- return parent.getType(nDef).thenAccept(tDef -> {
- SctlTargetTypedefDef def = new SctlTargetTypedefDef(this, tDef);
- changeElements(List.of(), List.of(def), "Initialized");
- });
- }
-}
diff --git a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/client/SctlTargetTypedefDef.java b/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/client/SctlTargetTypedefDef.java
deleted file mode 100644
index de6bec578e..0000000000
--- a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/client/SctlTargetTypedefDef.java
+++ /dev/null
@@ -1,24 +0,0 @@
-/* ###
- * 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 ghidra.dbg.sctl.client;
-
-import ghidra.dbg.attributes.TargetDataType;
-
-public class SctlTargetTypedefDef extends SctlTargetDataTypeMember {
- public SctlTargetTypedefDef(SctlTargetTypedefDataType typedef, TargetDataType dataType) {
- super(typedef, "[def]", -1, -1, "def", dataType, "TypedefDef");
- }
-}
diff --git a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/client/SctlTargetUnionDataType.java b/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/client/SctlTargetUnionDataType.java
deleted file mode 100644
index f6fa9f50d8..0000000000
--- a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/client/SctlTargetUnionDataType.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/* ###
- * 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 ghidra.dbg.sctl.client;
-
-import java.util.List;
-import java.util.concurrent.CompletableFuture;
-
-import ghidra.async.AsyncUtils;
-import ghidra.async.TypeSpec;
-import ghidra.dbg.sctl.protocol.types.*;
-
-public class SctlTargetUnionDataType extends SctlTargetCompositeDataType<SctlTargetUnionDataType> {
-
- public static class Ref extends AbstractRef<SctlTargetUnionDataType> {
- protected final SctlUnionTypeName nUnion;
-
- public Ref(SctlTargetDataTypeNamespace types, SctlUnionTypeName nUnion) {
- super(types, nUnion);
- this.nUnion = nUnion;
- }
-
- @Override
- protected CompletableFuture<? extends SctlTargetUnionDataType> doGet() {
- return AsyncUtils.sequence(TypeSpec.cls(SctlTargetUnionDataType.class)).then(seq -> {
- types.getTypeDef(nUnion).handle(seq::next);
- }, TypeSpec.cls(SelSctlTypeDefinition.class)).then((def, seq) -> {
- SctlUnionTypeDefinition dUnion = (SctlUnionTypeDefinition) def.sel;
- SctlTargetUnionDataType tStruct =
- new SctlTargetUnionDataType(types, nUnion, dUnion);
- tStruct.collectFields().thenApply(__ -> tStruct).handle(seq::next);
- }, TypeSpec.cls(SctlTargetUnionDataType.class)).then((tUnion, seq) -> {
- types.changeElements(List.of(), List.of(tUnion), "Fetched");
- seq.exit(tUnion);
- }).finish();
- }
- }
-
- protected SctlTargetUnionDataType(SctlTargetDataTypeNamespace types, SctlUnionTypeName nUnion,
- SctlUnionTypeDefinition dUnion) {
- super(types, nUnion, dUnion, NamedDataTypeKind.UNION, "UnionType");
- }
-}
diff --git a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/client/SctlTcpDebuggerModelFactory.java b/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/client/SctlTcpDebuggerModelFactory.java
deleted file mode 100644
index 95eda870d0..0000000000
--- a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/client/SctlTcpDebuggerModelFactory.java
+++ /dev/null
@@ -1,76 +0,0 @@
-/* ###
- * 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 ghidra.dbg.sctl.client;
-
-import java.io.IOException;
-import java.net.InetSocketAddress;
-import java.nio.channels.AsynchronousSocketChannel;
-import java.util.concurrent.CompletableFuture;
-
-import ghidra.async.AsyncUtils;
-import ghidra.async.TypeSpec;
-import ghidra.dbg.DebuggerModelFactory;
-import ghidra.dbg.util.ConfigurableFactory.FactoryDescription;
-
-@FactoryDescription( //
- brief = "SCTL connection over TCP", //
- htmlDetails = "Connect to an optionally remote agent via SCTL/TCP." //
-)
-public class SctlTcpDebuggerModelFactory implements DebuggerModelFactory {
-
- private String host = "localhost";
- @FactoryOption("Agent network address")
- public final Property<String> agentAddressOption =
- Property.fromAccessors(String.class, this::getAgentAddress, this::setAgentAddress);
-
- private int port = 12345;
- @FactoryOption("Agent TCP port")
- public final Property<Integer> agentPortOption =
- Property.fromAccessors(Integer.class, this::getAgentPort, this::setAgentPort);
-
- @Override
- public CompletableFuture<SctlClient> build() {
- try {
- AsynchronousSocketChannel channel = AsynchronousSocketChannel.open();
- return AsyncUtils.sequence(TypeSpec.cls(SctlClient.class)).then(seq -> {
- AsyncUtils.completable(TypeSpec.VOID, channel::connect,
- new InetSocketAddress(host, port)).handle(seq::next);
- }).then(seq -> {
- SctlClient client = new SctlClient(host + ":" + port, channel);
- client.connect().thenApply(__ -> client).handle(seq::exit);
- }).finish();
- }
- catch (IOException e) {
- return CompletableFuture.failedFuture(e);
- }
- }
-
- public String getAgentAddress() {
- return host;
- }
-
- public void setAgentAddress(String host) {
- this.host = host;
- }
-
- public int getAgentPort() {
- return port;
- }
-
- public void setAgentPort(int port) {
- this.port = port;
- }
-}
diff --git a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/client/SctlTrace.java b/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/client/SctlTrace.java
deleted file mode 100644
index 0d35a02bdc..0000000000
--- a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/client/SctlTrace.java
+++ /dev/null
@@ -1,118 +0,0 @@
-/* ###
- * 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 ghidra.dbg.sctl.client;
-
-import java.util.Set;
-
-import ghidra.comm.util.BitmaskSet;
-import ghidra.dbg.sctl.protocol.consts.Evkind;
-
-/**
- * Utilities for calling {@link SctlTargetThread#traceEvents(Mode, Set)}
- */
-public interface SctlTrace {
- /**
- * Constants specifying "enable" or "disable"
- */
- public enum Mode {
- /**
- * Disable events
- */
- CLEAR(Evkind.Eclear),
- /**
- * Enable events
- */
- SET(Evkind.Eset);
-
- public final Evkind kind;
-
- Mode(Evkind kind) {
- this.kind = kind;
- }
- }
-
- /**
- * Events to select from
- */
- public enum Event {
- /**
- * Immediately preceding and following system calls
- */
- SYSCALL(Evkind.Esyscall),
- /**
- * Immediately following POSIX {@code exec()}
- */
- EXEC(Evkind.Eexec),
- /**
- * Immediately following POSIX {@code fork()}
- */
- FORK(Evkind.Efork),
- /**
- * Immediately following Linux (@code clone()}
- */
- CLONE(Evkind.Eclone),
- /**
- * Pending a signal
- */
- SIGNAL(Evkind.Esignal),
- /**
- * Upon exit
- */
- EXIT(Evkind.Eexit),
- /**
- * Immediately upon a trap point
- */
- TRAP(Evkind.Etrap),
- /**
- * Immediately upon a snap point
- */
- SNAP(Evkind.Esnap),
- /**
- * Enable context transfer after a step
- */
- STEPCTX(Evkind.Estepctx),
- /**
- * Immediately following a module load
- */
- LOAD(Evkind.Eload),
- /**
- * Immediately following a module unload
- */
- UNLOAD(Evkind.Eunload);
-
- public final Evkind kind;
-
- Event(Evkind kind) {
- this.kind = kind;
- }
- }
-
- /**
- * Convert mode and event selections to protocol flags
- *
- * @param mode whether to enable or disable the events
- * @param events the events to enable to disable
- * @return the set of flags
- */
- public static BitmaskSet<Evkind> toFlags(Mode mode, Set<Event> events) {
- BitmaskSet<Evkind> flags = BitmaskSet.of();
- flags.add(mode.kind);
- for (Event ev : events) {
- flags.add(ev.kind);
- }
- return flags;
- }
-}
diff --git a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/client/depr/DebuggerAddressMapper.java b/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/client/depr/DebuggerAddressMapper.java
deleted file mode 100644
index d5ae6355c0..0000000000
--- a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/client/depr/DebuggerAddressMapper.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/* ###
- * 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 ghidra.dbg.sctl.client.depr;
-
-import ghidra.program.model.address.Address;
-import ghidra.program.model.address.AddressFactory;
-
-/**
- * A bijection of debugger addresses to offsets
- *
- * <p>
- * Some debuggers and/or debugging protocols map multiple address spaces into a single offset space.
- * This interface provides the conversion functions between the two. The offset is typically used to
- * communicate to the debugger. The address objects are used by Ghidra identify a location within
- * the target's memory model.
- */
-public interface DebuggerAddressMapper {
-
- /**
- * Convert an offset to an address
- *
- * @param offset the offset
- * @return the address
- */
- public Address mapOffsetToAddress(long offset);
-
- /**
- * Convert an address to an offset
- *
- * @param address the address
- * @return the offset
- */
- public long mapAddressToOffset(Address address);
-
- /**
- * Get the factory to create addresses in the target's memory model
- *
- * @return the factory
- */
- public AddressFactory getAddressFactory();
-}
diff --git a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/client/depr/DefaultDebuggerAddressMapper.java b/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/client/depr/DefaultDebuggerAddressMapper.java
deleted file mode 100644
index 2ce7d7e738..0000000000
--- a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/client/depr/DefaultDebuggerAddressMapper.java
+++ /dev/null
@@ -1,56 +0,0 @@
-/* ###
- * 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 ghidra.dbg.sctl.client.depr;
-
-import ghidra.program.model.address.*;
-
-/**
- * A singleton default implementation of {@link DebuggerAddressMapper}
- *
- * This implements the minimum required to provide an address factory, which simply maps the entire
- * offset space into single address space ("RAM") on the target.
- */
-public class DefaultDebuggerAddressMapper implements DebuggerAddressMapper {
- /**
- * The singleton instance
- */
- public static final DefaultDebuggerAddressMapper INSTANCE = new DefaultDebuggerAddressMapper();
-
- protected final AddressSpace constant =
- new GenericAddressSpace("const", 64, AddressSpace.TYPE_CONSTANT, 0);
- protected final AddressSpace ram =
- new GenericAddressSpace("ram", 64, AddressSpace.TYPE_RAM, 1);
- protected final AddressFactory factory =
- new DefaultAddressFactory(new AddressSpace[] { ram, constant });
-
- protected DefaultDebuggerAddressMapper() {
- }
-
- @Override
- public Address mapOffsetToAddress(long offset) {
- return ram.getAddress(offset);
- }
-
- @Override
- public long mapAddressToOffset(Address address) {
- return address.getOffset();
- }
-
- @Override
- public AddressFactory getAddressFactory() {
- return factory;
- }
-}
diff --git a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/client/err/SctlIncorrectPingResponse.java b/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/client/err/SctlIncorrectPingResponse.java
deleted file mode 100644
index 7cecc03ee0..0000000000
--- a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/client/err/SctlIncorrectPingResponse.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/* ###
- * 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 ghidra.dbg.sctl.client.err;
-
-import ghidra.util.NumericUtilities;
-
-/**
- * Thrown when a ping response does not follow the spec
- *
- * It should respond with a count of the bytes sent in the request.
- */
-public class SctlIncorrectPingResponse extends SctlProtocolSequenceException {
- public SctlIncorrectPingResponse(byte[] content, int expected, int got) {
- super("SCTL server gave incorrect ping reply for '" +
- NumericUtilities.convertBytesToString(content) + "'. Expected " + expected + ". Got " +
- got);
- }
-}
diff --git a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/client/err/SctlIncorrectReply.java b/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/client/err/SctlIncorrectReply.java
deleted file mode 100644
index c2945b654c..0000000000
--- a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/client/err/SctlIncorrectReply.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/* ###
- * 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 ghidra.dbg.sctl.client.err;
-
-import ghidra.dbg.sctl.protocol.SctlPacket;
-
-/**
- * Thrown when the server responds with an unexpected type
- *
- * A {@code Tx} request should have an {@code Rx} or {@code Rerror} response, as correlated by the
- * tag.
- */
-public class SctlIncorrectReply extends SctlProtocolSequenceException {
- public SctlIncorrectReply(SctlPacket cmd, SctlPacket reply) {
- super("Unexpected reply for " + cmd + ": " + reply);
- }
-}
diff --git a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/client/err/SctlIncorrectVersionRequest.java b/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/client/err/SctlIncorrectVersionRequest.java
deleted file mode 100644
index fc0b50f5fb..0000000000
--- a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/client/err/SctlIncorrectVersionRequest.java
+++ /dev/null
@@ -1,25 +0,0 @@
-/* ###
- * 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 ghidra.dbg.sctl.client.err;
-
-/**
- * Throw when the client offers an invalid version
- */
-public class SctlIncorrectVersionRequest extends SctlProtocolSequenceException {
- public SctlIncorrectVersionRequest(String message) {
- super(message);
- }
-}
diff --git a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/client/err/SctlIncorrectVersionResponse.java b/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/client/err/SctlIncorrectVersionResponse.java
deleted file mode 100644
index c8ae957a1e..0000000000
--- a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/client/err/SctlIncorrectVersionResponse.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/* ###
- * 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 ghidra.dbg.sctl.client.err;
-
-import ghidra.dbg.sctl.protocol.consts.Mkind;
-
-/**
- * Thrown when the server selects an invalid version
- *
- * The {@link Mkind#Rversion} reply must select a version from those listed in the
- * {@link Mkind#Tversion} request.
- */
-public class SctlIncorrectVersionResponse extends SctlProtocolSequenceException {
- public SctlIncorrectVersionResponse(String message) {
- super(message);
- }
-}
diff --git a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/client/err/SctlPartialWriteException.java b/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/client/err/SctlPartialWriteException.java
deleted file mode 100644
index 9f55fc83b5..0000000000
--- a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/client/err/SctlPartialWriteException.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/* ###
- * 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 ghidra.dbg.sctl.client.err;
-
-import ghidra.dbg.sctl.err.SctlRuntimeException;
-import ghidra.util.NumericUtilities;
-
-/**
- * Thrown when fewer bytes than those given are written by the server
- *
- * The {@code Rwrite} reply contains a field for the server to report how many bytes of data from a
- * {@code Twrite} request were actually written. Ideally, all bytes are written, so this is thrown
- * if fewer are reported.
- */
-public class SctlPartialWriteException extends SctlRuntimeException {
- public SctlPartialWriteException(byte[] data, int len) {
- super("Only wrote " + len + " bytes of " + NumericUtilities.convertBytesToString(data));
- }
-}
diff --git a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/client/err/SctlProtocolSequenceException.java b/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/client/err/SctlProtocolSequenceException.java
deleted file mode 100644
index b0f6344478..0000000000
--- a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/client/err/SctlProtocolSequenceException.java
+++ /dev/null
@@ -1,27 +0,0 @@
-/* ###
- * 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 ghidra.dbg.sctl.client.err;
-
-import ghidra.dbg.sctl.err.SctlRuntimeException;
-
-/**
- * A super class for exceptions resulting from unexpected or incorrect messages
- */
-public class SctlProtocolSequenceException extends SctlRuntimeException {
- public SctlProtocolSequenceException(String message) {
- super(message);
- }
-}
diff --git a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/dialect/HasOptionalPlatform.java b/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/dialect/HasOptionalPlatform.java
deleted file mode 100644
index 36e4d45afc..0000000000
--- a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/dialect/HasOptionalPlatform.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/* ###
- * 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 ghidra.dbg.sctl.dialect;
-
-public interface HasOptionalPlatform {
- /**
- * Check if the format contains a platform field
- *
- * @return true if supported, false otherwise
- */
- boolean supportsPlatform();
-
- /**
- * Set the platform
- *
- * @param platform the platform
- */
- void setPlatform(String platform);
-
- /**
- * Get the platform
- *
- * @return the platform
- */
- String getPlatform();
-}
diff --git a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/dialect/HasOptionalProcessID.java b/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/dialect/HasOptionalProcessID.java
deleted file mode 100644
index 3590a9faa2..0000000000
--- a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/dialect/HasOptionalProcessID.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/* ###
- * 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 ghidra.dbg.sctl.dialect;
-
-public interface HasOptionalProcessID {
- /**
- * Check if the format contains a process ID field
- *
- * @return true if supported, false otherwise
- */
- boolean supportsProcessID();
-
- /**
- * Set the process ID
- *
- * @param pid the process ID
- */
- void setProcessID(long pid);
-
- /**
- * Get the process ID
- *
- * @return the process ID
- */
- long getProcessID();
-}
diff --git a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/dialect/SctlDialect.java b/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/dialect/SctlDialect.java
deleted file mode 100644
index d329241aba..0000000000
--- a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/dialect/SctlDialect.java
+++ /dev/null
@@ -1,119 +0,0 @@
-/* ###
- * 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 ghidra.dbg.sctl.dialect;
-
-import java.lang.reflect.InvocationTargetException;
-import java.util.Set;
-
-import ghidra.comm.packet.Packet;
-import ghidra.comm.packet.PacketFactory;
-import ghidra.dbg.sctl.protocol.*;
-import ghidra.dbg.sctl.protocol.consts.Evkind;
-import ghidra.dbg.target.TargetExecutionStateful.TargetExecutionState;
-
-/**
- * An interface for a SCTL dialect
- *
- * To handle different versions and variants, SCTL supports the notion dialects. When negotiating a
- * connection, the client lists its version and dialects, and the server selects from those offered.
- * The client supports multiple dialects, each implementing this interface.
- */
-public interface SctlDialect {
- public SctlDialect NULL_DIALECT = SctlNullDialect.INSTANCE;
-
- /**
- * Get the system version string to offer in version negotiation
- *
- * @return the system version string
- */
- public String getSysVersion();
-
- /**
- * Get the full version string to offer in version negotiation
- *
- * @return the full version string
- */
- public default String getFullVersion() {
- return SctlVersionInfo.SCTL_VERSION + ":" + getSysVersion();
- }
-
- /**
- * Get the packet factory that provides dialect-specific packet formats
- *
- * @return the packet factory for this dialect
- */
- public PacketFactory getPacketFactory();
-
- /**
- * Check whether this dialect is aware of other clients using the same server
- *
- * @return true if supported, false otherwise
- */
- public boolean isBusSupported();
-
- /**
- * Check whether this dialect supports register selection
- *
- * @return true if supported, false otherwise
- */
- public boolean isRegisterSelectionSupported();
-
- /**
- * Get the state of a CTL (thread) after an event is reported
- *
- * @param events the flags describing the event
- * @return the state of the CTL
- */
- public TargetExecutionState stateAfterEvent(Set<Evkind> events);
-
- /**
- * If the dialect supports only one platform, get that platform
- *
- * @return the platform
- * @throws UnsupportedOperationException if the dialect supports multiple platforms
- */
- public String getSolePlatform();
-
- /**
- * Create the root packet type for this dialect
- *
- * @param tag the tag
- * @param cmd the command
- * @return the packet
- */
- default public AbstractSelSctlPacket createSel(int tag, SctlPacket cmd) {
- AbstractSelSctlPacket pkt = create(AbstractSelSctlPacket.class);
- pkt.tag = tag;
- pkt.sel = cmd;
- return pkt;
- }
-
- /**
- * A convenience for invoking the dialect's packet factory
- *
- * @param cls the packet class to instantiate
- * @return the new packet
- */
- default public <T extends Packet> T create(Class<T> cls) {
- try {
- return getPacketFactory().newPacket(cls);
- }
- catch (InstantiationException | IllegalAccessException | IllegalArgumentException
- | InvocationTargetException | NoSuchMethodException | SecurityException e) {
- throw new AssertionError(e);
- }
- }
-}
diff --git a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/dialect/SctlNullDialect.java b/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/dialect/SctlNullDialect.java
deleted file mode 100644
index 87338da9c4..0000000000
--- a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/dialect/SctlNullDialect.java
+++ /dev/null
@@ -1,67 +0,0 @@
-/* ###
- * 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 ghidra.dbg.sctl.dialect;
-
-import java.util.Set;
-
-import ghidra.comm.packet.AbstractPacketFactory;
-import ghidra.comm.packet.PacketFactory;
-import ghidra.dbg.sctl.protocol.AbstractSelSctlPacket;
-import ghidra.dbg.sctl.protocol.consts.Evkind;
-import ghidra.dbg.target.TargetExecutionStateful.TargetExecutionState;
-
-public enum SctlNullDialect implements SctlDialect {
- INSTANCE;
-
- public static class SctlNullPacketFactory extends AbstractPacketFactory {
- {
- useFor(AbstractSelSctlPacket.class, SelSctlNullDialectPacket.class);
- }
- }
-
- public static final String SYS_VERSION = "(negotiating)";
- private static final PacketFactory FACTORY = new SctlNullPacketFactory();
-
- @Override
- public String getSysVersion() {
- return SYS_VERSION;
- }
-
- @Override
- public PacketFactory getPacketFactory() {
- return FACTORY;
- }
-
- @Override
- public boolean isBusSupported() {
- return false;
- }
-
- @Override
- public boolean isRegisterSelectionSupported() {
- throw new IllegalStateException("Dialect has not been negotiated");
- }
-
- @Override
- public TargetExecutionState stateAfterEvent(Set<Evkind> events) {
- throw new IllegalStateException("Dialect has not been negotiated");
- }
-
- @Override
- public String getSolePlatform() {
- throw new IllegalStateException("Dialect has not been negotiated");
- }
-}
diff --git a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/dialect/SelSctlNullDialectPacket.java b/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/dialect/SelSctlNullDialectPacket.java
deleted file mode 100644
index 3e248dce7a..0000000000
--- a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/dialect/SelSctlNullDialectPacket.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/* ###
- * 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 ghidra.dbg.sctl.dialect;
-
-import java.util.Map;
-
-import ghidra.dbg.sctl.protocol.AbstractSelSctlPacket;
-import ghidra.dbg.sctl.protocol.SctlPacket;
-import ghidra.dbg.sctl.protocol.common.reply.*;
-import ghidra.dbg.sctl.protocol.common.request.SctlPingRequest;
-import ghidra.dbg.sctl.protocol.common.request.SctlVersionRequest;
-import ghidra.dbg.sctl.protocol.consts.Mkind;
-
-public class SelSctlNullDialectPacket extends AbstractSelSctlPacket {
- public static final Map<Mkind, Class<? extends SctlPacket>> METHOD_MAP =
- typeMap(Mkind.class, SctlPacket.class) //
- .put(Mkind.Rerror, SctlErrorReply.class) //
- .put(Mkind.Tversion, SctlVersionRequest.class) //
- .put(Mkind.Rversion, SctlVersionReply.class) //
- .put(Mkind.Tping, SctlPingRequest.class) //
- .put(Mkind.Rping, SctlPingReply.class) //
- .build();
-}
diff --git a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/err/SctlError.java b/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/err/SctlError.java
deleted file mode 100644
index 1804eaafb3..0000000000
--- a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/err/SctlError.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/* ###
- * 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 ghidra.dbg.sctl.err;
-
-import ghidra.dbg.sctl.protocol.common.reply.SctlErrorReply;
-
-/**
- * An exception to describe errors detected by the SCTL server
- *
- * On the client side, this exception is thrown whenever an {@code Rerror} message is received.
- * Usually, this results in a future completing exceptionally.
- *
- * For server implementations using this module, this exception can be thrown within request
- * handlers. This will cause the client handler to generate an {@code Rerror} for the request that
- * was being handled.
- */
-public class SctlError extends SctlRuntimeException {
-
- /**
- * Server side: Construct an exception to generate {@code Rerror}
- *
- * @param message a human-readable description of the error
- */
- public SctlError(String message) {
- super(message);
- }
-
- /**
- * Client side: Construct an exception for a received {@code Rerror}
- *
- * @param reply the received {@code Rerror}
- */
- public SctlError(SctlErrorReply reply) {
- super("Server reported error: " + reply.msg);
- }
-}
diff --git a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/err/SctlRuntimeException.java b/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/err/SctlRuntimeException.java
deleted file mode 100644
index 32d8d24a94..0000000000
--- a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/err/SctlRuntimeException.java
+++ /dev/null
@@ -1,25 +0,0 @@
-/* ###
- * 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 ghidra.dbg.sctl.err;
-
-/**
- * A base exception for SCTL-related exceptions
- */
-public class SctlRuntimeException extends RuntimeException {
- public SctlRuntimeException(String message) {
- super(message);
- }
-}
diff --git a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/AbstractSctlNotify.java b/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/AbstractSctlNotify.java
deleted file mode 100644
index b6c885b2c3..0000000000
--- a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/AbstractSctlNotify.java
+++ /dev/null
@@ -1,26 +0,0 @@
-/* ###
- * 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 ghidra.dbg.sctl.protocol;
-
-/**
- * A base class for all {@code A}-type SCTL messages
- *
- * There is only one {@code A}-type message, so this class exists to follow the same convention as
- * the {@code T}- and {@code R}-type messages.
- */
-public abstract class AbstractSctlNotify extends SctlPacket {
- // Empty
-}
diff --git a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/AbstractSctlReply.java b/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/AbstractSctlReply.java
deleted file mode 100644
index 2d7dc3081c..0000000000
--- a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/AbstractSctlReply.java
+++ /dev/null
@@ -1,23 +0,0 @@
-/* ###
- * 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 ghidra.dbg.sctl.protocol;
-
-/**
- * A base class for all {@code R}-type SCTL messages
- */
-public abstract class AbstractSctlReply extends SctlPacket {
- // Empty
-}
diff --git a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/AbstractSctlRequest.java b/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/AbstractSctlRequest.java
deleted file mode 100644
index 7778467e16..0000000000
--- a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/AbstractSctlRequest.java
+++ /dev/null
@@ -1,23 +0,0 @@
-/* ###
- * 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 ghidra.dbg.sctl.protocol;
-
-/**
- * A base class for all {@code T}-type SCTL messages
- */
-public abstract class AbstractSctlRequest extends SctlPacket {
- // Empty
-}
diff --git a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/AbstractSelSctlPacket.java b/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/AbstractSelSctlPacket.java
deleted file mode 100644
index 5dcbd1d102..0000000000
--- a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/AbstractSelSctlPacket.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/* ###
- * 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 ghidra.dbg.sctl.protocol;
-
-import ghidra.comm.packet.Packet;
-import ghidra.comm.packet.annot.TypedByField;
-import ghidra.comm.packet.fields.PacketField;
-import ghidra.dbg.sctl.protocol.consts.Mkind;
-
-public abstract class AbstractSelSctlPacket extends Packet {
- /**
- * For unmarshalling
- */
- public AbstractSelSctlPacket() {
- }
-
- /**
- * Construct a SCTL message with the given tag and message
- *
- * @param tag the tag
- * @param sel the message
- */
- public AbstractSelSctlPacket(int tag, SctlPacket sel) {
- this.tag = tag;
- this.sel = sel;
- }
-
- @PacketField
- public Mkind op;
-
- @PacketField
- public int tag;
-
- @PacketField
- @TypedByField(by = "op", map = "METHOD_MAP")
- public SctlPacket sel;
-}
diff --git a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/SctlMarshaller.java b/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/SctlMarshaller.java
deleted file mode 100644
index 1a7f5f6db2..0000000000
--- a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/SctlMarshaller.java
+++ /dev/null
@@ -1,103 +0,0 @@
-/* ###
- * 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 ghidra.dbg.sctl.protocol;
-
-import java.nio.*;
-
-import ghidra.comm.packet.AbstractPacketMarshaller;
-import ghidra.comm.packet.PacketCodec;
-import ghidra.comm.packet.binary.ByteBufferPacketCodec;
-import ghidra.comm.packet.err.PacketDecodeException;
-import ghidra.comm.packet.err.PacketEncodeException;
-import ghidra.util.Msg;
-import ghidra.util.NumericUtilities;
-
-/**
- * The marshaller for SCTL messages
- *
- * This implements the {@code size[8]} portion of the messages, because that is used to delineate
- * each message from the following message. The remaining packet fields are implemented in
- * {@link SelSctlPacket} and its constituents.
- *
- * This only marshalls and unmarshalls {@link SelSctlPacket}s to and from {@link ByteBuffer}s. It is
- * powered by the {@link ByteBufferPacketCodec}.
- */
-public class SctlMarshaller
- extends AbstractPacketMarshaller<AbstractSelSctlPacket, AbstractSelSctlPacket, ByteBuffer> {
- final static boolean DEBUG = false;
- final static PacketCodec<ByteBuffer> BB_CODEC = ByteBufferPacketCodec.getInstance();
-
- /**
- * Construct a SCTL packet marshaller
- */
- public SctlMarshaller() {
- super(BB_CODEC, AbstractSelSctlPacket.class);
- }
-
- protected void printBuf(ByteBuffer buf) {
- if (DEBUG) {
- byte[] b = new byte[buf.remaining()];
- int p = buf.position();
- buf.get(b);
- buf.position(p);
- Msg.debug(this, NumericUtilities.convertBytesToString(b, ":"));
- }
- }
-
- @Override
- public void marshall(ByteBuffer outbuf, AbstractSelSctlPacket pkt)
- throws PacketEncodeException {
- int pos = outbuf.position();
- try {
- outbuf.order(ByteOrder.LITTLE_ENDIAN);
- outbuf.putLong(0); // Placeholder
- BB_CODEC.encodePacket(outbuf, pkt);
-
- // Backfill the length
- int end = outbuf.position();
- int len = end - pos - Long.BYTES;
- outbuf.putLong(pos, len);
- }
- catch (Exception e) {
- outbuf.position(pos);
- throw e;
- }
- }
-
- @Override
- public <R extends AbstractSelSctlPacket> R unmarshall(Class<R> pktType, ByteBuffer inbuf)
- throws PacketDecodeException {
- int origPos = inbuf.position();
- int origLimit = inbuf.limit();
- try {
- inbuf.order(ByteOrder.LITTLE_ENDIAN);
- int len = (int) inbuf.getLong() + Long.BYTES;
- if (inbuf.limit() < len) {
- throw new BufferUnderflowException();
- }
- inbuf.limit(len);
- R rcvd = BB_CODEC.decodePacket(pktType, inbuf, factory);
- return rcvd;
- }
- catch (Exception e) {
- inbuf.position(origPos);
- throw e;
- }
- finally {
- inbuf.limit(origLimit);
- }
- }
-}
diff --git a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/SctlPacket.java b/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/SctlPacket.java
deleted file mode 100644
index 60bb269303..0000000000
--- a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/SctlPacket.java
+++ /dev/null
@@ -1,25 +0,0 @@
-/* ###
- * 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 ghidra.dbg.sctl.protocol;
-
-import ghidra.comm.packet.Packet;
-
-/**
- * A base type for all SCTL requests, replies, and notifications
- */
-public abstract class SctlPacket extends Packet {
- // Empty
-}
diff --git a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/SctlVersionInfo.java b/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/SctlVersionInfo.java
deleted file mode 100644
index d5cd0ea2eb..0000000000
--- a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/SctlVersionInfo.java
+++ /dev/null
@@ -1,149 +0,0 @@
-/* ###
- * 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 ghidra.dbg.sctl.protocol;
-
-import java.util.*;
-
-import ghidra.dbg.sctl.client.err.SctlIncorrectVersionRequest;
-import ghidra.dbg.sctl.client.err.SctlIncorrectVersionResponse;
-import ghidra.dbg.sctl.dialect.SctlDialect;
-import ghidra.dbg.sctl.protocol.common.request.SctlVersionRequest;
-import ghidra.dbg.sctl.protocol.consts.Mkind;
-import ghidra.dbg.sctl.protocol.v2012base.x86.linux.Sctl2012LinuxX86Dialect;
-import ghidra.dbg.sctl.protocol.v2012base.x86.win.Sctl2012WindowsX86Dialect;
-import ghidra.dbg.sctl.protocol.v2012ext.x86.linux.Sctl2012ExtLinuxX86Dialect;
-import ghidra.dbg.sctl.protocol.v2012ext.x86.win.Sctl2012ExtWindowsX86Dialect;
-import ghidra.dbg.sctl.protocol.v2018base.any.Sctl2018AnyAnyDialect;
-
-/**
- * A static-only class for listing the versions and dialects of SCTL understood by this client
- *
- * This class cannot be instantiated. It only has static utility methods.
- */
-public final class SctlVersionInfo {
- public static final List<SctlDialect> KNOWN_DIALECTS = Arrays.asList(new SctlDialect[] { //
- Sctl2018AnyAnyDialect.INSTANCE, //
- Sctl2012ExtLinuxX86Dialect.INSTANCE, //
- Sctl2012ExtWindowsX86Dialect.INSTANCE, //
- Sctl2012LinuxX86Dialect.INSTANCE, //
- Sctl2012WindowsX86Dialect.INSTANCE, //
- });
- public static final Map<String, SctlDialect> DIALECTS_BY_NAME = makeDialectMap();
- public static final String SCTL_VERSION = "sctl-2012";
-
- // Static only
- private SctlVersionInfo() {
- }
-
- /**
- * Obtain the dialect to which a server agreed
- *
- * This method presumes that the server has replied to a {@code Tversion} request generated by
- * {@link #makeRequest()}. The request lists all known dialects from which the server must
- * choose one. This method checks that the response is one of the known dialects and returns an
- * instance of that dialect.
- *
- * @param reply the reply from the server
- * @return the agreed-upon dialect
- * @throws SctlIncorrectVersionResponse if the selected dialect is not known
- */
- public static SctlDialect agreeDialect(String selected) throws SctlIncorrectVersionResponse {
- // TODO: Spec says multiple dialects may be chosen.... I only take the highest in my list
-
- String[] parts = selected.split(":");
- if (parts.length != 2) {
- throw new SctlIncorrectVersionResponse(
- "Server responded with malformed version: " + selected);
- }
- if (!SCTL_VERSION.equals(parts[0])) {
- throw new SctlIncorrectVersionResponse(
- "Server ctl version does not match offer: " + parts[0]);
- }
- Set<String> versions = new HashSet<>(Arrays.asList(parts[1].split(",")));
- // Take the "best", and check that it was in the offer
- // Everything in KNOWN_DIALECT ought to have been in the offer
- for (SctlDialect dialect : KNOWN_DIALECTS) {
- if (versions.contains(dialect.getSysVersion())) {
- return dialect;
- }
- }
- throw new SctlIncorrectVersionResponse(
- "Server requested unknown system dialects: " + parts[1]);
- }
-
- private static Map<String, SctlDialect> makeDialectMap() {
- Map<String, SctlDialect> map = new LinkedHashMap<>();
- for (SctlDialect dialect : KNOWN_DIALECTS) {
- map.put(dialect.getSysVersion(), dialect);
- }
- return Collections.unmodifiableMap(map);
- }
-
- /**
- * Generate a {@link Mkind#Tversion} request listing the given dialects
- *
- * @param dialects the supported dialects
- * @return the request
- */
- public static SctlVersionRequest makeRequest(Collection<SctlDialect> dialects) {
- StringBuilder sb = new StringBuilder();
- sb.append(SCTL_VERSION);
- sb.append(':');
- boolean first = true;
- for (SctlDialect dialect : dialects) {
- if (!first) {
- sb.append(',');
- }
- else {
- first = false;
- }
- sb.append(dialect.getSysVersion());
- }
- return new SctlVersionRequest(sb.toString());
- }
-
- /**
- * Generate a {@link Mkind#Tversion} request listing all dialects known to the client
- *
- * @return the request
- */
- public static SctlVersionRequest makeRequest() {
- return makeRequest(KNOWN_DIALECTS);
- }
-
- public static Set<SctlDialect> collectSupported(String offered) {
- String parts[] = offered.split(":");
- if (parts.length != 2) {
- throw new SctlIncorrectVersionRequest("Client offered a malformed version: " + offered);
- }
- if (!SCTL_VERSION.equals(parts[0])) {
- throw new SctlIncorrectVersionRequest(
- "Client ctl version is not supported: " + parts[0]);
- }
- Set<SctlDialect> supported = new LinkedHashSet<>();
- for (String version : parts[1].split(",")) {
- SctlDialect dialect = DIALECTS_BY_NAME.get(version);
- if (dialect != null) {
- supported.add(dialect);
- }
- }
- if (supported.isEmpty()) {
- throw new SctlIncorrectVersionRequest(
- "No versions offered by the client are supported: " + offered);
- }
- return supported;
- }
-}
diff --git a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/common/AbstractByLongFieldsSctlContext.java b/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/common/AbstractByLongFieldsSctlContext.java
deleted file mode 100644
index e7378e7fb9..0000000000
--- a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/common/AbstractByLongFieldsSctlContext.java
+++ /dev/null
@@ -1,86 +0,0 @@
-/* ###
- * 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 ghidra.dbg.sctl.protocol.common;
-
-import java.lang.reflect.Field;
-import java.nio.ByteBuffer;
-import java.nio.ByteOrder;
-import java.util.*;
-
-public abstract class AbstractByLongFieldsSctlContext extends AbstractSctlContext {
-
- @Override
- public Map<String, byte[]> toMap() {
- Map<String, byte[]> result = new LinkedHashMap<>();
- ByteBuffer buf = ByteBuffer.allocate(Long.BYTES);
- buf.order(ByteOrder.BIG_ENDIAN);
- for (Field fld : getClass().getFields()) {
- try {
- buf.putLong(0, fld.getLong(this));
- }
- catch (IllegalArgumentException | IllegalAccessException e) {
- throw new AssertionError(e);
- }
- result.put(fld.getName(), Arrays.copyOf(buf.array(), Long.BYTES));
- }
- return result;
- }
-
- @Override
- public Set<String> getRegisterNames() {
- Set<String> result = new LinkedHashSet<>();
- for (Field fld : getClass().getFields()) {
- result.add(fld.getName());
- }
- return result;
- }
-
- @Override
- public void updateFromMap(Map<String, byte[]> values) {
- try {
- Class<?> cls = getClass();
- ByteBuffer buf = ByteBuffer.allocate(Long.BYTES);
- buf.order(ByteOrder.BIG_ENDIAN);
- for (Map.Entry<String, byte[]> ent : values.entrySet()) {
- buf.putLong(0, 0);
- buf.position(0);
- byte[] val = ent.getValue();
- buf.put(val, Long.BYTES - val.length, val.length);
- Field fld = cls.getField(ent.getKey());
- fld.setLong(this, buf.getLong(0));
- }
- }
- catch (NoSuchFieldException | SecurityException | IllegalArgumentException
- | IllegalAccessException e) {
- throw new AssertionError(e);
- }
- }
-
- @Override
- public void update(String name, byte[] value) {
- try {
- Class<?> cls = getClass();
- ByteBuffer buf = ByteBuffer.allocate(Long.BYTES);
- buf.order(ByteOrder.BIG_ENDIAN);
- buf.put(value, Long.BYTES - value.length, value.length);
- Field fld = cls.getField(name);
- fld.setLong(this, buf.getLong(0));
- }
- catch (NoSuchFieldException | IllegalArgumentException | IllegalAccessException e) {
- throw new AssertionError(e);
- }
- }
-}
diff --git a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/common/AbstractSctlBinary.java b/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/common/AbstractSctlBinary.java
deleted file mode 100644
index a4a7e19eae..0000000000
--- a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/common/AbstractSctlBinary.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/* ###
- * 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 ghidra.dbg.sctl.protocol.common;
-
-import java.util.List;
-
-import ghidra.comm.packet.Packet;
-
-public abstract class AbstractSctlBinary extends Packet {
- public abstract void setNamespaceID(long nsid);
-
- public abstract long getNamespaceID();
-
- public abstract void setPath(String path);
-
- public abstract String getPath();
-
- public abstract void setExecutable(boolean isexe);
-
- public abstract boolean isExecutable();
-
- public abstract boolean supportsBase();
-
- public abstract void setBase(long base);
-
- public abstract long getBase();
-
- public abstract boolean supportsSections();
-
- public abstract AbstractSctlSection addSection();
-
- public abstract List<? extends AbstractSctlSection> getSections();
-}
diff --git a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/common/AbstractSctlContext.java b/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/common/AbstractSctlContext.java
deleted file mode 100644
index d849f78aaa..0000000000
--- a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/common/AbstractSctlContext.java
+++ /dev/null
@@ -1,68 +0,0 @@
-/* ###
- * 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 ghidra.dbg.sctl.protocol.common;
-
-import java.util.*;
-
-import ghidra.comm.packet.Packet;
-
-/**
- * A base type for contexts
- *
- * This is a dialect-defined format.
- *
- * The default implementation assumes each register is stored in a field named after that register.
- */
-public abstract class AbstractSctlContext extends Packet {
- /**
- * Convert this context to a register-value map as used in the Debugging API.
- *
- * @return the map
- */
- public abstract Map<String, byte[]> toMap();
-
- /**
- * List the registers represented within this context
- *
- * @return the set of register names
- */
- public abstract Set<String> getRegisterNames();
-
- /**
- * Set the selected registers
- *
- * If the context has already been loaded with data, i.e., parsed from the channel, then this
- * may re-parse the individual registers.
- *
- * @param regdefs the list of selected register definitions
- */
- public abstract void setSelectedRegisters(List<SctlRegisterDefinition> regdefs);
-
- /**
- * Update the fields from a register-value map as used in the Debugging API.
- *
- * @param values the map
- */
- public abstract void updateFromMap(Map<String, byte[]> values);
-
- /**
- * Update a field by name using bytes in big-endian order
- *
- * @param name the register name
- * @param value the register value
- */
- public abstract void update(String name, byte[] value);
-}
diff --git a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/common/AbstractSctlObjectEntry.java b/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/common/AbstractSctlObjectEntry.java
deleted file mode 100644
index e62e241d8e..0000000000
--- a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/common/AbstractSctlObjectEntry.java
+++ /dev/null
@@ -1,96 +0,0 @@
-/* ###
- * 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 ghidra.dbg.sctl.protocol.common;
-
-import ghidra.comm.packet.Packet;
-
-/**
- * An attachable target process entry
- *
- * This is a dialect-defined format.
- */
-public abstract class AbstractSctlObjectEntry extends Packet {
- /**
- * Get the object path
- *
- * @return path the object path
- */
- public abstract SctlString getPath();
-
- /**
- * Set the object path
- *
- * @param path the object path
- */
- public abstract void setPath(SctlString path);
-
- /**
- * Get the object path
- *
- * @return path the object path
- */
- public abstract SctlString getKey();
-
- /**
- * Set the object path
- *
- * @param path the object path
- */
- public abstract void setKey(SctlString key);
-
- /**
- * Get the object kind
- *
- * @return path the object kind
- */
- public abstract SctlString getKind();
-
- /**
- * Set the object kind
- *
- * @param path the object kind
- */
- public abstract void setKind(SctlString kind);
-
- /**
- * Get the object value
- *
- * @return path the object value
- */
- public abstract SctlString getValue();
-
- /**
- * Set the object value if it exists
- *
- * @param path the object value
- */
- public abstract void setValue(SctlString value);
-
- /**
- * Get the object type
- *
- * @return path the object type
- */
- public abstract SctlString getType();
-
- /**
- * Set the object type if it exists
- *
- * @param path the object type
- */
- public abstract void setType(SctlString sctlString);
-
-}
diff --git a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/common/AbstractSctlProcessEntry.java b/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/common/AbstractSctlProcessEntry.java
deleted file mode 100644
index 9904f7101c..0000000000
--- a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/common/AbstractSctlProcessEntry.java
+++ /dev/null
@@ -1,73 +0,0 @@
-/* ###
- * 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 ghidra.dbg.sctl.protocol.common;
-
-import java.util.List;
-
-import ghidra.comm.packet.Packet;
-
-/**
- * An attachable target process entry
- *
- * This is a dialect-defined format.
- */
-public abstract class AbstractSctlProcessEntry extends Packet {
- /**
- * Get the process ID
- *
- * @return the process ID
- */
- public abstract long getProcessID();
-
- /**
- * Set the process ID
- *
- * @param pid the process ID
- */
- public abstract void setProcessID(long pid);
-
- /**
- * Get the command that launched the process
- *
- * Alternatively, this may be any textual description of the process
- *
- * @return the command
- */
- public abstract String getCommand();
-
- /**
- * Set the command that launched the process
- *
- * Alternatively, this may be any textual description of the process
- *
- * @param cmd the command
- */
- public abstract void setCommand(String cmd);
-
- /**
- * Get the threads in the process
- *
- * @return a list of thread entries
- */
- public abstract List<? extends AbstractSctlThreadEntry> getThreads();
-
- /**
- * Add a thread to the thread list
- *
- * @return the new, empty thread entry
- */
- public abstract AbstractSctlThreadEntry addThread();
-}
diff --git a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/common/AbstractSctlProcessList.java b/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/common/AbstractSctlProcessList.java
deleted file mode 100644
index bb10cc7f67..0000000000
--- a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/common/AbstractSctlProcessList.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/* ###
- * 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 ghidra.dbg.sctl.protocol.common;
-
-import java.util.List;
-
-import ghidra.comm.packet.Packet;
-
-/**
- * A list of attachable target processes
- *
- * This is a dialect-defined format.
- */
-public abstract class AbstractSctlProcessList extends Packet {
- /**
- * Get the list of attachable target processes
- *
- * @return the list of process entries
- */
- public abstract List<? extends AbstractSctlProcessEntry> getProcesses();
-
- /**
- * Add a new process to the list
- *
- * @return the new, empty process entry
- */
- public abstract AbstractSctlProcessEntry addProcess();
-}
diff --git a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/common/AbstractSctlRegion.java b/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/common/AbstractSctlRegion.java
deleted file mode 100644
index 7044d17773..0000000000
--- a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/common/AbstractSctlRegion.java
+++ /dev/null
@@ -1,84 +0,0 @@
-/* ###
- * 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 ghidra.dbg.sctl.protocol.common;
-
-import ghidra.comm.packet.Packet;
-import ghidra.comm.util.BitmaskSet;
-import ghidra.dbg.sctl.client.SctlMemoryProtection;
-
-public abstract class AbstractSctlRegion extends Packet {
- /**
- * Set the name of the region
- *
- * This may be a file path describing the module loaded here or any textual description of the
- * region.
- *
- * @param name the name
- */
- public abstract void setName(String name);
-
- /**
- * Get the name of the region
- *
- * This may be a file path describing the module loaded here or any textual description of the
- * region.
- *
- * @return the name
- */
- public abstract String getName();
-
- /**
- * Set the start address of the region
- *
- * @param address the address
- */
- public abstract void setAddress(long address);
-
- /**
- * Get the start address of the region
- *
- * @return
- */
- public abstract long getAddress();
-
- /**
- * Set the length, in bytes, of the region
- *
- * @param length the length
- */
- public abstract void setLength(long length);
-
- /**
- * Get the length, in bytes, of the region
- *
- * @return the length
- */
- public abstract long getLength();
-
- /**
- * Set the region's protections (permissions)
- *
- * @param flags the flags enumerating the protections
- */
- public abstract void setProtections(BitmaskSet<SctlMemoryProtection> flags);
-
- /**
- * Get the region's protections (permissions)
- *
- * @return the flags enumerating the protections
- */
- public abstract BitmaskSet<SctlMemoryProtection> getProtections();
-}
diff --git a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/common/AbstractSctlSection.java b/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/common/AbstractSctlSection.java
deleted file mode 100644
index 609fa096c7..0000000000
--- a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/common/AbstractSctlSection.java
+++ /dev/null
@@ -1,62 +0,0 @@
-/* ###
- * 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 ghidra.dbg.sctl.protocol.common;
-
-import ghidra.comm.packet.Packet;
-
-public abstract class AbstractSctlSection extends Packet {
- /**
- * Set the starting address of the section as loaded
- *
- * @param address the address
- */
- public abstract void setAddress(long address);
-
- /**
- * Get the starting address of the section as loaded
- *
- * @return the address
- */
- public abstract long getAddress();
-
- /**
- * Set the length, in bytes, of the section
- *
- * @param length the length
- */
- public abstract void setLength(long length);
-
- /**
- * Get the length, in bytes, of the section
- *
- * @return
- */
- public abstract long getLength();
-
- /**
- * Set the name of the section
- *
- * @param name the name
- */
- public abstract void setName(String name);
-
- /**
- * Get the name of the section
- *
- * @return the name
- */
- public abstract String getName();
-}
diff --git a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/common/AbstractSctlStatus.java b/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/common/AbstractSctlStatus.java
deleted file mode 100644
index b39c2f5e03..0000000000
--- a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/common/AbstractSctlStatus.java
+++ /dev/null
@@ -1,56 +0,0 @@
-/* ###
- * 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 ghidra.dbg.sctl.protocol.common;
-
-import java.util.List;
-
-import ghidra.comm.packet.Packet;
-import ghidra.dbg.sctl.dialect.HasOptionalProcessID;
-
-/**
- * The status of a CTL
- *
- * This is a dialect-defined format.
- */
-public abstract class AbstractSctlStatus extends Packet implements HasOptionalProcessID {
- /**
- * Add a memory region
- *
- * @return the new, empty memory region entry
- */
- public abstract AbstractSctlRegion addRegion();
-
- /**
- * Get the list of memory regions
- *
- * @return the regions
- */
- public abstract List<? extends AbstractSctlRegion> getRegions();
-
- /**
- * Add a binary module
- *
- * @return the new, empty binary module entry
- */
- public abstract AbstractSctlBinary addBinary();
-
- /**
- * Get the list of binary modules
- *
- * @return the binaries
- */
- public abstract List<? extends AbstractSctlBinary> getBinaries();
-}
diff --git a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/common/AbstractSctlThreadEntry.java b/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/common/AbstractSctlThreadEntry.java
deleted file mode 100644
index 2d84955765..0000000000
--- a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/common/AbstractSctlThreadEntry.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/* ###
- * 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 ghidra.dbg.sctl.protocol.common;
-
-import ghidra.comm.packet.Packet;
-
-/**
- * A thread entry of an attachable target process
- */
-public abstract class AbstractSctlThreadEntry extends Packet {
- /**
- * Get the thread ID
- *
- * @return the thread ID
- */
- public abstract long getThreadID();
-
- /**
- * Set the thread ID
- *
- * @param tid the thread ID
- */
- public abstract void setThreadID(long tid);
-}
diff --git a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/common/AbstractSctlTrapSpec.java b/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/common/AbstractSctlTrapSpec.java
deleted file mode 100644
index 13cd0bb6ce..0000000000
--- a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/common/AbstractSctlTrapSpec.java
+++ /dev/null
@@ -1,58 +0,0 @@
-/* ###
- * 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 ghidra.dbg.sctl.protocol.common;
-
-import ghidra.comm.packet.Packet;
-
-/**
- * A trap specification
- *
- * This is a dialect-defined format. This is effectively an interface defining the union of options
- * for all supported dialects. If a dialect does not support an option, it must throw an
- * {@link UnsupportedOperationException}. For {@code get} operations, the dialect should return what
- * is implied by the restrictions of the dialect.
- */
-public abstract class AbstractSctlTrapSpec extends Packet {
- public abstract void setAddress(long address);
-
- public abstract long getAddress();
-
- public abstract void setLength(long length);
-
- public abstract long getLength();
-
- public abstract void setActionStop();
-
- public abstract boolean isActionStop();
-
- public abstract void setActionSnap();
-
- public abstract boolean isActionSnap();
-
- public abstract void setSoftwareExecute();
-
- public abstract boolean isSoftwareExecute();
-
- public abstract void setHardware(boolean read, boolean write, boolean execute);
-
- public abstract boolean isHardware();
-
- public abstract boolean isHardwareRead();
-
- public abstract boolean isHardwareWrite();
-
- public abstract boolean isHardwareExecute();
-}
diff --git a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/common/SctlRegisterDefinition.java b/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/common/SctlRegisterDefinition.java
deleted file mode 100644
index c2d6336e2d..0000000000
--- a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/common/SctlRegisterDefinition.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/* ###
- * 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 ghidra.dbg.sctl.protocol.common;
-
-import ghidra.comm.packet.Packet;
-import ghidra.comm.packet.fields.PacketField;
-
-public class SctlRegisterDefinition extends Packet {
- public SctlRegisterDefinition() {
- }
-
- public SctlRegisterDefinition(long regid, String name, long nbits) {
- this.regid = regid;
- this.name = new SctlString(name);
- this.nbits = nbits;
- }
-
- @PacketField
- public long regid;
-
- @PacketField
- public SctlString name;
-
- // TODO: Consider a type name instead/in addition?
- @PacketField
- public long nbits;
-}
diff --git a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/common/SctlString.java b/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/common/SctlString.java
deleted file mode 100644
index ec976d571b..0000000000
--- a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/common/SctlString.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/* ###
- * 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 ghidra.dbg.sctl.protocol.common;
-
-import ghidra.comm.packet.Packet;
-import ghidra.comm.packet.annot.SizedByField;
-import ghidra.comm.packet.fields.PacketField;
-
-/**
- * A string in {@code size[8]str[size]} format
- */
-public class SctlString extends Packet {
- /**
- * For unmarshalling
- */
- public SctlString() {
- }
-
- /**
- * Wrap a string for SCTL packets
- *
- * @param str the string
- */
- public SctlString(String str) {
- this.str = str;
- }
-
- @PacketField
- public long len;
-
- @PacketField
- @SizedByField("len")
- public String str;
-
- @Override
- public String toString() {
- return "\"" + str + "\"";
- }
-}
diff --git a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/common/SctlSymbol.java b/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/common/SctlSymbol.java
deleted file mode 100644
index 0830c63d1c..0000000000
--- a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/common/SctlSymbol.java
+++ /dev/null
@@ -1,73 +0,0 @@
-/* ###
- * 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 ghidra.dbg.sctl.protocol.common;
-
-import ghidra.comm.packet.Packet;
-import ghidra.comm.packet.annot.BitmaskEncoded;
-import ghidra.comm.packet.fields.PacketField;
-import ghidra.comm.util.BitmaskSet;
-import ghidra.dbg.sctl.protocol.consts.Stype;
-import ghidra.dbg.sctl.protocol.types.SctlAttributes;
-import ghidra.dbg.sctl.protocol.types.SelSctlTypeName;
-
-/**
- * The format of {@code sym}
- */
-public class SctlSymbol extends Packet {
- /**
- * For unmarshalling
- */
- public SctlSymbol() {
- }
-
- /**
- * Construct the symbol portion of a message
- *
- * @param name the name
- * @param flags the Stype flags
- * @param val the value (address or constant)
- * @param size the size, in bytes
- * @param tname the type name
- */
- public SctlSymbol(String name, BitmaskSet<Stype> flags, long val, long size,
- SelSctlTypeName tname) {
- this.name = new SctlString(name);
- this.flags = flags;
- this.val = val;
- this.attrs = SctlAttributes.empty();
- this.size = size;
- this.tname = tname;
- }
-
- @PacketField
- public SctlString name;
-
- @PacketField
- @BitmaskEncoded(type = Byte.class)
- public BitmaskSet<Stype> flags;
-
- @PacketField
- public long val;
-
- @PacketField
- public SctlAttributes attrs;
-
- @PacketField
- public long size;
-
- @PacketField
- public SelSctlTypeName tname;
-}
diff --git a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/common/notify/AbstractSctlEventNotification.java b/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/common/notify/AbstractSctlEventNotification.java
deleted file mode 100644
index b427b785a4..0000000000
--- a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/common/notify/AbstractSctlEventNotification.java
+++ /dev/null
@@ -1,26 +0,0 @@
-/* ###
- * 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 ghidra.dbg.sctl.protocol.common.notify;
-
-import ghidra.comm.packet.Packet;
-import ghidra.dbg.sctl.protocol.common.AbstractSctlContext;
-
-/**
- * A base class for all {@code Aevent} (event notification) SCTL messages
- */
-public abstract class AbstractSctlEventNotification extends Packet {
- public abstract AbstractSctlContext getCtx();
-}
diff --git a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/common/notify/AbstractSctlForkCloneNotification.java b/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/common/notify/AbstractSctlForkCloneNotification.java
deleted file mode 100644
index 6d7fcf283a..0000000000
--- a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/common/notify/AbstractSctlForkCloneNotification.java
+++ /dev/null
@@ -1,51 +0,0 @@
-/* ###
- * 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 ghidra.dbg.sctl.protocol.common.notify;
-
-import ghidra.comm.packet.annot.OptionalField;
-import ghidra.comm.packet.fields.PacketField;
-import ghidra.dbg.sctl.protocol.common.AbstractSctlContext;
-
-/**
- * Factored common parts for {@code Efork} and {@code Eclone} SCTL events
- */
-public abstract class AbstractSctlForkCloneNotification extends AbstractSctlEventNotification {
- public AbstractSctlForkCloneNotification() {
- }
-
- public AbstractSctlForkCloneNotification(long spwnid, AbstractSctlContext ctx,
- AbstractSctlContext spwnctx) {
- this.spwnid = spwnid;
- this.ctx = ctx;
- this.spwnctx = spwnctx;
- }
-
- @Override
- public AbstractSctlContext getCtx() {
- return ctx;
- }
-
- @PacketField
- public long spwnid;
-
- @PacketField
- @OptionalField
- public AbstractSctlContext ctx;
-
- @PacketField
- @OptionalField
- public AbstractSctlContext spwnctx;
-}
diff --git a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/common/notify/AbstractSctlForkNotification.java b/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/common/notify/AbstractSctlForkNotification.java
deleted file mode 100644
index f8ebb6bf70..0000000000
--- a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/common/notify/AbstractSctlForkNotification.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/* ###
- * 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 ghidra.dbg.sctl.protocol.common.notify;
-
-import ghidra.dbg.sctl.dialect.HasOptionalProcessID;
-import ghidra.dbg.sctl.protocol.common.AbstractSctlContext;
-
-public abstract class AbstractSctlForkNotification extends AbstractSctlForkCloneNotification
- implements HasOptionalProcessID {
- public AbstractSctlForkNotification() {
- super();
- }
-
- public AbstractSctlForkNotification(long spwnid, AbstractSctlContext ctx,
- AbstractSctlContext spwnctx) {
- super(spwnid, ctx, spwnctx);
- }
-}
diff --git a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/common/notify/AbstractSctlListsLibrariesEventNotification.java b/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/common/notify/AbstractSctlListsLibrariesEventNotification.java
deleted file mode 100644
index 9a0f9c671f..0000000000
--- a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/common/notify/AbstractSctlListsLibrariesEventNotification.java
+++ /dev/null
@@ -1,74 +0,0 @@
-/* ###
- * 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 ghidra.dbg.sctl.protocol.common.notify;
-
-import java.util.List;
-
-import ghidra.comm.packet.Packet;
-import ghidra.comm.packet.annot.*;
-import ghidra.comm.packet.fields.PacketField;
-import ghidra.dbg.sctl.protocol.common.AbstractSctlContext;
-import ghidra.dbg.sctl.protocol.common.SctlString;
-
-/**
- * Factored common parts for {@code Eload} and {@code Eunload} SCTL events
- */
-public abstract class AbstractSctlListsLibrariesEventNotification
- extends AbstractSctlEventNotification {
-
- public AbstractSctlListsLibrariesEventNotification() {
- }
-
- public AbstractSctlListsLibrariesEventNotification(List<PathBase> libs,
- AbstractSctlContext ctx) {
- this.libs = libs;
- this.ctx = ctx;
- }
-
- @PacketField
- public long nl;
-
- @PacketField
- @RepeatedField
- @CountedByField("nl")
- public List<PathBase> libs;
-
- // TODO: Modify this for any-any-2018. May just remove base....
- public static class PathBase extends Packet {
- public PathBase() {
- }
-
- public PathBase(String path, long base) {
- this.path = new SctlString(path);
- this.base = base;
- }
-
- @PacketField
- public SctlString path;
-
- @PacketField
- public long base;
- }
-
- @PacketField
- @OptionalField
- public AbstractSctlContext ctx;
-
- @Override
- public AbstractSctlContext getCtx() {
- return ctx;
- }
-}
diff --git a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/common/notify/AbstractSctlOnlyCtxEventNotification.java b/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/common/notify/AbstractSctlOnlyCtxEventNotification.java
deleted file mode 100644
index cbcd0ce7a0..0000000000
--- a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/common/notify/AbstractSctlOnlyCtxEventNotification.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/* ###
- * 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 ghidra.dbg.sctl.protocol.common.notify;
-
-import ghidra.comm.packet.annot.OptionalField;
-import ghidra.comm.packet.fields.PacketField;
-import ghidra.dbg.sctl.protocol.common.AbstractSctlContext;
-
-/**
- * Factored common parts for SCTL events providing only the context registers
- *
- * Those are {@code Eexec}, {@code Esignal}, and {@code Esyscall}.
- */
-public abstract class AbstractSctlOnlyCtxEventNotification extends AbstractSctlEventNotification {
- public AbstractSctlOnlyCtxEventNotification() {
- }
-
- public AbstractSctlOnlyCtxEventNotification(AbstractSctlContext ctx) {
- this.ctx = ctx;
- }
-
- @PacketField
- @OptionalField
- public AbstractSctlContext ctx;
-
- @Override
- public AbstractSctlContext getCtx() {
- return ctx;
- }
-}
diff --git a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/common/notify/AbstractSctlSnapNotification.java b/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/common/notify/AbstractSctlSnapNotification.java
deleted file mode 100644
index fa708ebcda..0000000000
--- a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/common/notify/AbstractSctlSnapNotification.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/* ###
- * 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 ghidra.dbg.sctl.protocol.common.notify;
-
-import ghidra.comm.packet.annot.OptionalField;
-import ghidra.comm.packet.fields.PacketField;
-import ghidra.dbg.sctl.dialect.HasOptionalProcessID;
-import ghidra.dbg.sctl.protocol.common.AbstractSctlContext;
-
-public abstract class AbstractSctlSnapNotification extends AbstractSctlEventNotification
- implements HasOptionalProcessID {
- @PacketField
- public long trpid;
-
- @PacketField
- public long spwnid;
-
- @PacketField
- @OptionalField
- public AbstractSctlContext ctx;
-
- @Override
- public AbstractSctlContext getCtx() {
- return ctx;
- }
-}
diff --git a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/common/notify/SctlCloneNotification.java b/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/common/notify/SctlCloneNotification.java
deleted file mode 100644
index 63aaa9cdc1..0000000000
--- a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/common/notify/SctlCloneNotification.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/* ###
- * 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 ghidra.dbg.sctl.protocol.common.notify;
-
-import ghidra.dbg.sctl.protocol.common.AbstractSctlContext;
-
-/**
- * Format for the {@code Eclone} SCTL event
- */
-public class SctlCloneNotification extends AbstractSctlForkCloneNotification {
- public SctlCloneNotification() {
- }
-
- public SctlCloneNotification(long spwnid, AbstractSctlContext ctx,
- AbstractSctlContext spwnctx) {
- super(spwnid, ctx, spwnctx);
- }
-}
diff --git a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/common/notify/SctlEventNotify.java b/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/common/notify/SctlEventNotify.java
deleted file mode 100644
index e64f796ba2..0000000000
--- a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/common/notify/SctlEventNotify.java
+++ /dev/null
@@ -1,190 +0,0 @@
-/* ###
- * 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 ghidra.dbg.sctl.protocol.common.notify;
-
-import java.util.LinkedHashSet;
-import java.util.Set;
-
-import ghidra.comm.packet.annot.BitmaskEncoded;
-import ghidra.comm.packet.annot.WithFlag;
-import ghidra.comm.packet.fields.PacketField;
-import ghidra.comm.util.BitmaskSet;
-import ghidra.dbg.sctl.protocol.AbstractSctlNotify;
-import ghidra.dbg.sctl.protocol.consts.Evkind;
-
-/**
- * Format for the {@code Aevent} SCTL message
- *
- * This parses the flags and each applicable event. It is unclear how many events can be present in
- * one message. Though, the documentation seems to imply exactly one must be present.
- */
-public class SctlEventNotify extends AbstractSctlNotify {
- /**
- * For unmarshalling
- */
- public SctlEventNotify() {
- }
-
- /**
- * Construct an {@code Aevent} message with the one given event details
- *
- * Additional events may be added using {@link #addOrSetDetails(AbstractSctlEventNotification)}.
- * Note that more than one event may not be within the official specification. The proper flags
- * will be set during message encoding.
- *
- * @param ctlid the CTLID of the affected thread
- * @param details the event details
- */
- public SctlEventNotify(long ctlid, AbstractSctlEventNotification details) {
- this(ctlid, details, null);
- }
-
- /**
- * Construct an {@code Aevent} message with the one given event details and additional flags
- *
- * The event flags will be set during message encoding. The provided flags are set in addition
- * to required event flag(s). Note: If an event flag is provided in {@code addFlags}, but that
- * event is not actually present in the details, it will be cleared while encoding.
- *
- * @param ctlid the CTLID of the affected thread
- * @param details the event details
- * @param addFlags additional flags to set
- */
- public SctlEventNotify(long ctlid, AbstractSctlEventNotification details,
- BitmaskSet<Evkind> addFlags) {
- this.ctlid = ctlid;
- this.flags = addFlags;
- addOrSetDetails(details);
- }
-
- public void clearDetails() {
- syscall = null;
- trap = null;
- snap = null;
- fork = null;
- clone = null;
- exec = null;
- exit = null;
- signal = null;
- load = null;
- unload = null;
- }
-
- public void addOrSetDetails(AbstractSctlEventNotification details) {
- if (details == null) {
- return;
- }
- else if (details instanceof SctlSyscallNotification) {
- syscall = (SctlSyscallNotification) details;
- }
- else if (details instanceof SctlTrapNotification) {
- trap = (SctlTrapNotification) details;
- }
- else if (details instanceof AbstractSctlSnapNotification) {
- snap = (AbstractSctlSnapNotification) details;
- }
- else if (details instanceof AbstractSctlForkNotification) {
- fork = (AbstractSctlForkNotification) details;
- }
- else if (details instanceof SctlCloneNotification) {
- clone = (SctlCloneNotification) details;
- }
- else if (details instanceof SctlExecNotification) {
- exec = (SctlExecNotification) details;
- }
- else if (details instanceof SctlExitNotification) {
- exit = (SctlExitNotification) details;
- }
- else if (details instanceof SctlSignalNotification) {
- signal = (SctlSignalNotification) details;
- }
- else if (details instanceof SctlLoadNotification) {
- load = (SctlLoadNotification) details;
- }
- else if (details instanceof SctlUnloadNotification) {
- unload = (SctlUnloadNotification) details;
- }
- }
-
- private static <T> void addIfNotNull(Set<T> set, T t) {
- if (t != null) {
- set.add(t);
- }
- }
-
- // There should really only be one anyway
- public Set<AbstractSctlEventNotification> getAllEvents() {
- Set<AbstractSctlEventNotification> all = new LinkedHashSet<>();
- addIfNotNull(all, syscall);
- addIfNotNull(all, trap);
- addIfNotNull(all, snap);
- addIfNotNull(all, fork);
- addIfNotNull(all, clone);
- addIfNotNull(all, exec);
- addIfNotNull(all, exit);
- addIfNotNull(all, signal);
- addIfNotNull(all, load);
- addIfNotNull(all, unload);
- return all;
- }
-
- @PacketField
- public long ctlid;
-
- @PacketField
- @BitmaskEncoded(universe = Evkind.class)
- public BitmaskSet<Evkind> flags;
-
- @PacketField
- @WithFlag(by = "flags", flag = "Esyscall")
- public SctlSyscallNotification syscall;
-
- @PacketField
- @WithFlag(by = "flags", flag = "Etrap")
- public SctlTrapNotification trap;
-
- @PacketField
- @WithFlag(by = "flags", flag = "Esnap")
- public AbstractSctlSnapNotification snap;
-
- @PacketField
- @WithFlag(by = "flags", flag = "Efork")
- public AbstractSctlForkNotification fork;
-
- @PacketField
- @WithFlag(by = "flags", flag = "Eclone")
- public SctlCloneNotification clone;
-
- @PacketField
- @WithFlag(by = "flags", flag = "Eexec")
- public SctlExecNotification exec;
-
- @PacketField
- @WithFlag(by = "flags", flag = "Eexit")
- public SctlExitNotification exit;
-
- @PacketField
- @WithFlag(by = "flags", flag = "Esignal")
- public SctlSignalNotification signal;
-
- @PacketField
- @WithFlag(by = "flags", flag = "Eload")
- public SctlLoadNotification load;
-
- @PacketField
- @WithFlag(by = "flags", flag = "Eunload")
- public SctlUnloadNotification unload;
-}
diff --git a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/common/notify/SctlExecNotification.java b/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/common/notify/SctlExecNotification.java
deleted file mode 100644
index 353b6dba92..0000000000
--- a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/common/notify/SctlExecNotification.java
+++ /dev/null
@@ -1,23 +0,0 @@
-/* ###
- * 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 ghidra.dbg.sctl.protocol.common.notify;
-
-/**
- * Format for the {@code Eexec} SCTL event
- */
-public class SctlExecNotification extends AbstractSctlOnlyCtxEventNotification {
- // No content
-}
diff --git a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/common/notify/SctlExitNotification.java b/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/common/notify/SctlExitNotification.java
deleted file mode 100644
index 2dc252a3bf..0000000000
--- a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/common/notify/SctlExitNotification.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/* ###
- * 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 ghidra.dbg.sctl.protocol.common.notify;
-
-import ghidra.comm.packet.annot.OptionalField;
-import ghidra.comm.packet.fields.PacketField;
-import ghidra.dbg.sctl.protocol.common.AbstractSctlContext;
-
-/**
- * Format for the {@code Eexit} SCTL event
- */
-public class SctlExitNotification extends AbstractSctlEventNotification {
- public SctlExitNotification() {
- }
-
- public SctlExitNotification(long status, AbstractSctlContext ctx) {
- this.status = status;
- this.ctx = ctx;
- }
-
- @PacketField
- public long status;
-
- @PacketField
- @OptionalField
- public AbstractSctlContext ctx;
-
- @Override
- public AbstractSctlContext getCtx() {
- return ctx;
- }
-}
diff --git a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/common/notify/SctlLoadNotification.java b/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/common/notify/SctlLoadNotification.java
deleted file mode 100644
index c11cd5e257..0000000000
--- a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/common/notify/SctlLoadNotification.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/* ###
- * 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 ghidra.dbg.sctl.protocol.common.notify;
-
-import java.util.List;
-
-import ghidra.dbg.sctl.protocol.common.AbstractSctlContext;
-
-/**
- * Format for the {@code Eload} SCTL event
- */
-public class SctlLoadNotification extends AbstractSctlListsLibrariesEventNotification {
- public SctlLoadNotification() {
- }
-
- public SctlLoadNotification(List<PathBase> libs, AbstractSctlContext ctx) {
- super(libs, ctx);
- }
-}
diff --git a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/common/notify/SctlSignalNotification.java b/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/common/notify/SctlSignalNotification.java
deleted file mode 100644
index e2178ea718..0000000000
--- a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/common/notify/SctlSignalNotification.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/* ###
- * 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 ghidra.dbg.sctl.protocol.common.notify;
-
-import ghidra.dbg.sctl.protocol.common.AbstractSctlContext;
-
-/**
- * Format for the {@code Esignal} SCTL event
- */
-public class SctlSignalNotification extends AbstractSctlOnlyCtxEventNotification {
- public SctlSignalNotification() {
- }
-
- public SctlSignalNotification(AbstractSctlContext ctx) {
- super(ctx);
- }
-}
diff --git a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/common/notify/SctlSyscallNotification.java b/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/common/notify/SctlSyscallNotification.java
deleted file mode 100644
index 15c44a8c53..0000000000
--- a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/common/notify/SctlSyscallNotification.java
+++ /dev/null
@@ -1,23 +0,0 @@
-/* ###
- * 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 ghidra.dbg.sctl.protocol.common.notify;
-
-/**
- * Format for the {@code Esyscall} SCTL event
- */
-public class SctlSyscallNotification extends AbstractSctlOnlyCtxEventNotification {
- // No content
-}
diff --git a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/common/notify/SctlTrapNotification.java b/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/common/notify/SctlTrapNotification.java
deleted file mode 100644
index ad175d60ac..0000000000
--- a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/common/notify/SctlTrapNotification.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/* ###
- * 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 ghidra.dbg.sctl.protocol.common.notify;
-
-import ghidra.comm.packet.annot.OptionalField;
-import ghidra.comm.packet.fields.PacketField;
-import ghidra.dbg.sctl.protocol.common.AbstractSctlContext;
-
-/**
- * Format for the {@code Etrap} SCTL event
- */
-public class SctlTrapNotification extends AbstractSctlEventNotification {
- public SctlTrapNotification() {
- }
-
- public SctlTrapNotification(long trpid, AbstractSctlContext ctx) {
- this.trpid = trpid;
- this.ctx = ctx;
- }
-
- @PacketField
- public long trpid;
-
- @PacketField
- @OptionalField
- public AbstractSctlContext ctx;
-
- @Override
- public AbstractSctlContext getCtx() {
- return ctx;
- }
-}
diff --git a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/common/notify/SctlUnloadNotification.java b/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/common/notify/SctlUnloadNotification.java
deleted file mode 100644
index 12e6dbdc60..0000000000
--- a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/common/notify/SctlUnloadNotification.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/* ###
- * 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 ghidra.dbg.sctl.protocol.common.notify;
-
-import java.util.List;
-
-import ghidra.dbg.sctl.protocol.common.AbstractSctlContext;
-
-/**
- * Format for the {@code Eclone} SCTL event
- */
-public class SctlUnloadNotification extends AbstractSctlListsLibrariesEventNotification {
- public SctlUnloadNotification() {
- }
-
- public SctlUnloadNotification(List<PathBase> libs, AbstractSctlContext ctx) {
- super(libs, ctx);
- }
-}
diff --git a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/common/reply/AbstractSctlAttachReply.java b/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/common/reply/AbstractSctlAttachReply.java
deleted file mode 100644
index 0775b47b3e..0000000000
--- a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/common/reply/AbstractSctlAttachReply.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/* ###
- * 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 ghidra.dbg.sctl.protocol.common.reply;
-
-import ghidra.comm.packet.annot.OptionalField;
-import ghidra.comm.packet.fields.PacketField;
-import ghidra.dbg.sctl.dialect.HasOptionalPlatform;
-import ghidra.dbg.sctl.protocol.AbstractSctlReply;
-import ghidra.dbg.sctl.protocol.common.AbstractSctlContext;
-
-/**
- * Format for the {@code Rattach} SCTL message
- */
-public abstract class AbstractSctlAttachReply extends AbstractSctlReply
- implements HasOptionalPlatform {
- public AbstractSctlAttachReply() {
- }
-
- public AbstractSctlAttachReply(long ctlid, AbstractSctlContext ctx) {
- this.ctlid = ctlid;
- this.ctx = ctx;
- }
-
- @PacketField
- public long ctlid;
-
- @PacketField
- @OptionalField
- public AbstractSctlContext ctx;
-}
diff --git a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/common/reply/AbstractSctlLaunchReply.java b/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/common/reply/AbstractSctlLaunchReply.java
deleted file mode 100644
index a1eededeed..0000000000
--- a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/common/reply/AbstractSctlLaunchReply.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/* ###
- * 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 ghidra.dbg.sctl.protocol.common.reply;
-
-import ghidra.comm.packet.annot.OptionalField;
-import ghidra.comm.packet.fields.PacketField;
-import ghidra.dbg.sctl.dialect.HasOptionalPlatform;
-import ghidra.dbg.sctl.dialect.HasOptionalProcessID;
-import ghidra.dbg.sctl.protocol.AbstractSctlReply;
-import ghidra.dbg.sctl.protocol.common.AbstractSctlContext;
-
-public abstract class AbstractSctlLaunchReply extends AbstractSctlReply
- implements HasOptionalProcessID, HasOptionalPlatform {
- @PacketField
- public long ctlid;
-
- @PacketField
- @OptionalField
- public AbstractSctlContext ctx;
-}
diff --git a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/common/reply/AbstractSctlSnapshotReply.java b/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/common/reply/AbstractSctlSnapshotReply.java
deleted file mode 100644
index 07f3dc38ec..0000000000
--- a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/common/reply/AbstractSctlSnapshotReply.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/* ###
- * 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 ghidra.dbg.sctl.protocol.common.reply;
-
-import ghidra.comm.packet.annot.OptionalField;
-import ghidra.comm.packet.fields.PacketField;
-import ghidra.dbg.sctl.dialect.HasOptionalProcessID;
-import ghidra.dbg.sctl.protocol.AbstractSctlReply;
-import ghidra.dbg.sctl.protocol.common.AbstractSctlContext;
-
-/**
- * Format for the {@code Rsnap} SCTL message
- */
-public abstract class AbstractSctlSnapshotReply extends AbstractSctlReply
- implements HasOptionalProcessID {
- @PacketField
- public long spwnid;
-
- @PacketField
- @OptionalField
- public AbstractSctlContext ctx;
-}
diff --git a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/common/reply/SctlClearTrapReply.java b/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/common/reply/SctlClearTrapReply.java
deleted file mode 100644
index da4aa5d0ab..0000000000
--- a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/common/reply/SctlClearTrapReply.java
+++ /dev/null
@@ -1,25 +0,0 @@
-/* ###
- * 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 ghidra.dbg.sctl.protocol.common.reply;
-
-import ghidra.dbg.sctl.protocol.AbstractSctlReply;
-
-/**
- * Format for the {@code Rclrtrap} SCTL message
- */
-public class SctlClearTrapReply extends AbstractSctlReply {
- // Empty
-}
diff --git a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/common/reply/SctlContinueReply.java b/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/common/reply/SctlContinueReply.java
deleted file mode 100644
index dbc3070889..0000000000
--- a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/common/reply/SctlContinueReply.java
+++ /dev/null
@@ -1,25 +0,0 @@
-/* ###
- * 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 ghidra.dbg.sctl.protocol.common.reply;
-
-import ghidra.dbg.sctl.protocol.AbstractSctlReply;
-
-/**
- * Format for the {@code Rcont} SCTL message
- */
-public class SctlContinueReply extends AbstractSctlReply {
- // Empty
-}
diff --git a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/common/reply/SctlDetachReply.java b/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/common/reply/SctlDetachReply.java
deleted file mode 100644
index 4e5482357c..0000000000
--- a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/common/reply/SctlDetachReply.java
+++ /dev/null
@@ -1,25 +0,0 @@
-/* ###
- * 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 ghidra.dbg.sctl.protocol.common.reply;
-
-import ghidra.dbg.sctl.protocol.AbstractSctlReply;
-
-/**
- * Format for the {@code Rdetach} SCTL message
- */
-public class SctlDetachReply extends AbstractSctlReply {
- // Empty
-}
diff --git a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/common/reply/SctlEnumerateLocalsReply.java b/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/common/reply/SctlEnumerateLocalsReply.java
deleted file mode 100644
index da74c692ef..0000000000
--- a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/common/reply/SctlEnumerateLocalsReply.java
+++ /dev/null
@@ -1,119 +0,0 @@
-/* ###
- * 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 ghidra.dbg.sctl.protocol.common.reply;
-
-import java.util.List;
-import java.util.Map;
-
-import ghidra.comm.packet.Packet;
-import ghidra.comm.packet.annot.*;
-import ghidra.comm.packet.fields.PacketField;
-import ghidra.dbg.sctl.protocol.AbstractSctlReply;
-import ghidra.dbg.sctl.protocol.common.SctlString;
-import ghidra.dbg.sctl.protocol.consts.Lkind;
-import ghidra.dbg.sctl.protocol.consts.Vkind;
-import ghidra.dbg.sctl.protocol.types.SelSctlTypeName;
-
-/**
- * Format for the {@code Renumloc} SCTL message
- */
-public class SctlEnumerateLocalsReply extends AbstractSctlReply {
- // This is currently untested, i.e., I do not know how reference sctl behaves.
-
- @PacketField
- public long nl;
-
- @PacketField
- @RepeatedField
- @CountedByField("nl")
- public List<Local> locs;
-
- public static class Local extends Packet {
- @PacketField
- public SctlString id;
-
- @PacketField
- public SelSctlTypeName tname;
-
- @PacketField
- public Vkind kind;
-
- @PacketField
- public SelLocalExpr lexpr;
- }
-
- public static abstract class AbstractLocalExpr extends Packet {
- // Empty
- }
-
- public static class SelLocalExpr extends Packet {
- public static final Map<Lkind, Class<? extends AbstractLocalExpr>> KIND_MAP =
- typeMap(Lkind.class, AbstractLocalExpr.class) //
- .put(Lkind.Lreg, LocalRegisterExpr.class) //
- .put(Lkind.Lderef, LocalDereferenceExpr.class) //
- .put(Lkind.Ladd, LocalAddExpr.class) //
- .put(Lkind.Lsub, LocalSubExpr.class) //
- .put(Lkind.Lulit, LocalUnsignedLiteralExpr.class) //
- .put(Lkind.Lslit, LocalSignedLiteralExpr.class) //
- .build();
-
- @PacketField
- public Lkind kind;
-
- @PacketField
- @TypedByField(by = "kind", map = "KIND_MAP")
- public AbstractLocalExpr expr;
- }
-
- public static class LocalRegisterExpr extends AbstractLocalExpr {
- @PacketField
- public byte no; // register number, target-dependent
- }
-
- public static class LocalDereferenceExpr extends AbstractLocalExpr {
- @PacketField
- public SelLocalExpr lexpr;
- }
-
- public static class AbstractLocalBiExpr extends AbstractLocalExpr {
- @PacketField
- public SelLocalExpr lexpr1;
-
- @PacketField
- public SelLocalExpr lexpr2;
- }
-
- public static class LocalAddExpr extends AbstractLocalBiExpr {
- // No content
- }
-
- public static class LocalSubExpr extends AbstractLocalBiExpr {
- // No content
- }
-
- public static abstract class AbstractLocalLiteralExpr extends AbstractLocalExpr {
- @PacketField
- public long val;
- }
-
- public static class LocalUnsignedLiteralExpr extends AbstractLocalLiteralExpr {
- // No content
- }
-
- public static class LocalSignedLiteralExpr extends AbstractLocalLiteralExpr {
- // No content
- }
-}
diff --git a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/common/reply/SctlEnumerateSegmentsReply.java b/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/common/reply/SctlEnumerateSegmentsReply.java
deleted file mode 100644
index 62b7f48e00..0000000000
--- a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/common/reply/SctlEnumerateSegmentsReply.java
+++ /dev/null
@@ -1,25 +0,0 @@
-/* ###
- * 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 ghidra.dbg.sctl.protocol.common.reply;
-
-import ghidra.dbg.sctl.protocol.AbstractSctlReply;
-
-/**
- * Format for the {@code Renumseg} SCTL message
- */
-public class SctlEnumerateSegmentsReply extends AbstractSctlReply {
- // This seems to lack documentation online
-}
diff --git a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/common/reply/SctlEnumerateSymbolsReply.java b/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/common/reply/SctlEnumerateSymbolsReply.java
deleted file mode 100644
index 3a9e44c67c..0000000000
--- a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/common/reply/SctlEnumerateSymbolsReply.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/* ###
- * 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 ghidra.dbg.sctl.protocol.common.reply;
-
-import java.util.List;
-
-import ghidra.comm.packet.annot.CountedByField;
-import ghidra.comm.packet.annot.RepeatedField;
-import ghidra.comm.packet.fields.PacketField;
-import ghidra.dbg.sctl.protocol.AbstractSctlReply;
-import ghidra.dbg.sctl.protocol.common.SctlSymbol;
-
-/**
- * Format for the {@code Renumsym} SCTL message
- */
-public class SctlEnumerateSymbolsReply extends AbstractSctlReply {
- @PacketField
- public long ns; // NOTE: "number of symbols", not "namespace"
-
- @PacketField
- @RepeatedField
- @CountedByField("ns")
- public List<SctlSymbol> syms;
-}
diff --git a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/common/reply/SctlEnumerateTypesReply.java b/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/common/reply/SctlEnumerateTypesReply.java
deleted file mode 100644
index c353928b99..0000000000
--- a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/common/reply/SctlEnumerateTypesReply.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/* ###
- * 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 ghidra.dbg.sctl.protocol.common.reply;
-
-import java.util.List;
-
-import ghidra.comm.packet.annot.CountedByField;
-import ghidra.comm.packet.annot.RepeatedField;
-import ghidra.comm.packet.fields.PacketField;
-import ghidra.dbg.sctl.protocol.AbstractSctlReply;
-import ghidra.dbg.sctl.protocol.types.SelSctlTypeDefinition;
-
-/**
- * Format for the {@code Renumtype} SCTL message
- */
-public class SctlEnumerateTypesReply extends AbstractSctlReply {
- @PacketField
- public long nt;
-
- @PacketField
- @RepeatedField
- @CountedByField("nt")
- public List<SelSctlTypeDefinition> tdefs;
-}
diff --git a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/common/reply/SctlErrorReply.java b/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/common/reply/SctlErrorReply.java
deleted file mode 100644
index 688d2a98fc..0000000000
--- a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/common/reply/SctlErrorReply.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/* ###
- * 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 ghidra.dbg.sctl.protocol.common.reply;
-
-import ghidra.comm.packet.fields.PacketField;
-import ghidra.dbg.sctl.protocol.AbstractSctlReply;
-
-/**
- * Format for the {@code Rerror} SCTL message
- */
-public class SctlErrorReply extends AbstractSctlReply {
- public SctlErrorReply() {
- }
-
- public SctlErrorReply(String msg) {
- this.msg = msg;
- }
-
- @PacketField
- public String msg;
-}
diff --git a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/common/reply/SctlGetContextReply.java b/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/common/reply/SctlGetContextReply.java
deleted file mode 100644
index fc9c623931..0000000000
--- a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/common/reply/SctlGetContextReply.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/* ###
- * 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 ghidra.dbg.sctl.protocol.common.reply;
-
-import ghidra.comm.packet.fields.PacketField;
-import ghidra.dbg.sctl.protocol.AbstractSctlReply;
-import ghidra.dbg.sctl.protocol.common.AbstractSctlContext;
-import ghidra.dbg.sctl.protocol.consts.Mkind;
-
-/**
- * Format for the {@link Mkind#Rgetctx} SCTL message
- */
-public class SctlGetContextReply extends AbstractSctlReply {
- public SctlGetContextReply() {
- }
-
- public SctlGetContextReply(AbstractSctlContext ctx) {
- this.ctx = ctx;
- }
-
- @PacketField
- public AbstractSctlContext ctx;
-}
diff --git a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/common/reply/SctlKillReply.java b/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/common/reply/SctlKillReply.java
deleted file mode 100644
index 170281fa52..0000000000
--- a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/common/reply/SctlKillReply.java
+++ /dev/null
@@ -1,25 +0,0 @@
-/* ###
- * 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 ghidra.dbg.sctl.protocol.common.reply;
-
-import ghidra.dbg.sctl.protocol.AbstractSctlReply;
-
-/**
- * Format for the {@code Rkill} SCTL message
- */
-public class SctlKillReply extends AbstractSctlReply {
- // Empty
-}
diff --git a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/common/reply/SctlLookupAddressReply.java b/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/common/reply/SctlLookupAddressReply.java
deleted file mode 100644
index 07cf672626..0000000000
--- a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/common/reply/SctlLookupAddressReply.java
+++ /dev/null
@@ -1,28 +0,0 @@
-/* ###
- * 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 ghidra.dbg.sctl.protocol.common.reply;
-
-import ghidra.comm.packet.fields.PacketField;
-import ghidra.dbg.sctl.protocol.AbstractSctlReply;
-import ghidra.dbg.sctl.protocol.common.SctlSymbol;
-
-/**
- * Format for the {@code Rlookaddr} SCTL message
- */
-public class SctlLookupAddressReply extends AbstractSctlReply {
- @PacketField
- public SctlSymbol sym;
-}
diff --git a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/common/reply/SctlLookupProgramCounterReply.java b/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/common/reply/SctlLookupProgramCounterReply.java
deleted file mode 100644
index 322a5c91f7..0000000000
--- a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/common/reply/SctlLookupProgramCounterReply.java
+++ /dev/null
@@ -1,27 +0,0 @@
-/* ###
- * 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 ghidra.dbg.sctl.protocol.common.reply;
-
-import ghidra.comm.packet.fields.PacketField;
-import ghidra.dbg.sctl.protocol.AbstractSctlReply;
-
-/**
- * Format for the {@code Rlookpc} SCTL message
- */
-public class SctlLookupProgramCounterReply extends AbstractSctlReply {
- @PacketField
- public long addr;
-}
diff --git a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/common/reply/SctlLookupSourceReply.java b/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/common/reply/SctlLookupSourceReply.java
deleted file mode 100644
index b4bdf141f0..0000000000
--- a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/common/reply/SctlLookupSourceReply.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/* ###
- * 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 ghidra.dbg.sctl.protocol.common.reply;
-
-import ghidra.comm.packet.fields.PacketField;
-import ghidra.dbg.sctl.protocol.AbstractSctlReply;
-import ghidra.dbg.sctl.protocol.common.SctlString;
-
-/**
- * Format for the {@code Rlooksrc} SCTL message
- */
-public class SctlLookupSourceReply extends AbstractSctlReply {
- @PacketField
- public SctlString file;
-
- @PacketField
- public int line;
-
- @PacketField
- public int col;
-}
diff --git a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/common/reply/SctlLookupSymbolReply.java b/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/common/reply/SctlLookupSymbolReply.java
deleted file mode 100644
index dd743bdfb3..0000000000
--- a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/common/reply/SctlLookupSymbolReply.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/* ###
- * 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 ghidra.dbg.sctl.protocol.common.reply;
-
-import ghidra.comm.packet.fields.PacketField;
-import ghidra.dbg.sctl.protocol.AbstractSctlReply;
-import ghidra.dbg.sctl.protocol.common.SctlSymbol;
-
-/**
- * Format for the {@code Rlooksym} SCTL message
- */
-public class SctlLookupSymbolReply extends AbstractSctlReply {
- public SctlLookupSymbolReply() {
- }
-
- public SctlLookupSymbolReply(SctlSymbol sym) {
- this.sym = sym;
- }
-
- @PacketField
- public SctlSymbol sym;
-}
diff --git a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/common/reply/SctlLookupTypeReply.java b/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/common/reply/SctlLookupTypeReply.java
deleted file mode 100644
index 184e623d7c..0000000000
--- a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/common/reply/SctlLookupTypeReply.java
+++ /dev/null
@@ -1,28 +0,0 @@
-/* ###
- * 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 ghidra.dbg.sctl.protocol.common.reply;
-
-import ghidra.comm.packet.fields.PacketField;
-import ghidra.dbg.sctl.protocol.AbstractSctlReply;
-import ghidra.dbg.sctl.protocol.types.SelSctlTypeDefinition;
-
-/**
- * Format for the {@code Rlooktype} SCTL message
- */
-public class SctlLookupTypeReply extends AbstractSctlReply {
- @PacketField
- public SelSctlTypeDefinition tdef;
-}
diff --git a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/common/reply/SctlNamesReply.java b/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/common/reply/SctlNamesReply.java
deleted file mode 100644
index 7720b1c0d9..0000000000
--- a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/common/reply/SctlNamesReply.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/* ###
- * 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 ghidra.dbg.sctl.protocol.common.reply;
-
-import ghidra.comm.packet.fields.PacketField;
-import ghidra.dbg.sctl.protocol.AbstractSctlReply;
-
-/**
- * Format for the {@code Rnames} SCTL message
- */
-public class SctlNamesReply extends AbstractSctlReply {
- public SctlNamesReply() {
- }
-
- public SctlNamesReply(long nsid) {
- this.nsid = nsid;
- }
-
- @PacketField
- public long nsid;
-}
diff --git a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/common/reply/SctlPingReply.java b/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/common/reply/SctlPingReply.java
deleted file mode 100644
index b52b3b52ab..0000000000
--- a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/common/reply/SctlPingReply.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/* ###
- * 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 ghidra.dbg.sctl.protocol.common.reply;
-
-import ghidra.comm.packet.fields.PacketField;
-import ghidra.dbg.sctl.protocol.AbstractSctlReply;
-
-/**
- * Format for the {@code Rping} SCTL message
- */
-public class SctlPingReply extends AbstractSctlReply {
- public SctlPingReply() {
- }
-
- public SctlPingReply(long cnt) {
- this.cnt = cnt;
- }
-
- @PacketField
- public long cnt;
-}
diff --git a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/common/reply/SctlProcessListReply.java b/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/common/reply/SctlProcessListReply.java
deleted file mode 100644
index c1741a7c27..0000000000
--- a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/common/reply/SctlProcessListReply.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/* ###
- * 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 ghidra.dbg.sctl.protocol.common.reply;
-
-import ghidra.comm.packet.fields.PacketField;
-import ghidra.dbg.sctl.protocol.AbstractSctlReply;
-import ghidra.dbg.sctl.protocol.common.AbstractSctlProcessList;
-
-/**
- * Format for the {@code Rps} SCTL message
- */
-public class SctlProcessListReply extends AbstractSctlReply {
- public SctlProcessListReply() {
- }
-
- public SctlProcessListReply(AbstractSctlProcessList pslist) {
- this.pslist = pslist;
- }
-
- // TODO: If a dialect arises where this format differs, I will need to re-factor.
- @PacketField
- public AbstractSctlProcessList pslist;
-}
diff --git a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/common/reply/SctlReadReply.java b/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/common/reply/SctlReadReply.java
deleted file mode 100644
index 47e29d10ae..0000000000
--- a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/common/reply/SctlReadReply.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/* ###
- * 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 ghidra.dbg.sctl.protocol.common.reply;
-
-import ghidra.comm.packet.fields.PacketField;
-import ghidra.dbg.sctl.protocol.AbstractSctlReply;
-
-/**
- * Format for the {@code Rread} SCTL message
- */
-public class SctlReadReply extends AbstractSctlReply {
- public SctlReadReply() {
- }
-
- public SctlReadReply(byte[] bytes) {
- this.bytes = bytes;
- }
-
- @PacketField
- public byte[] bytes;
-}
diff --git a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/common/reply/SctlSetContextReply.java b/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/common/reply/SctlSetContextReply.java
deleted file mode 100644
index 2188241e15..0000000000
--- a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/common/reply/SctlSetContextReply.java
+++ /dev/null
@@ -1,25 +0,0 @@
-/* ###
- * 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 ghidra.dbg.sctl.protocol.common.reply;
-
-import ghidra.dbg.sctl.protocol.AbstractSctlReply;
-
-/**
- * Format for the {@code Rsetctx} SCTL message
- */
-public class SctlSetContextReply extends AbstractSctlReply {
- // Empty
-}
diff --git a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/common/reply/SctlSetTrapReply.java b/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/common/reply/SctlSetTrapReply.java
deleted file mode 100644
index da68ea62a5..0000000000
--- a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/common/reply/SctlSetTrapReply.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/* ###
- * 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 ghidra.dbg.sctl.protocol.common.reply;
-
-import ghidra.comm.packet.fields.PacketField;
-import ghidra.dbg.sctl.protocol.AbstractSctlReply;
-
-/**
- * Format for the {@code Rsettrap} SCTL message
- */
-public class SctlSetTrapReply extends AbstractSctlReply {
-
- public SctlSetTrapReply() {
- }
-
- public SctlSetTrapReply(long trpid) {
- this.trpid = trpid;
- }
-
- @PacketField
- public long trpid;
-}
diff --git a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/common/reply/SctlStatusReply.java b/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/common/reply/SctlStatusReply.java
deleted file mode 100644
index 4c856166e6..0000000000
--- a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/common/reply/SctlStatusReply.java
+++ /dev/null
@@ -1,28 +0,0 @@
-/* ###
- * 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 ghidra.dbg.sctl.protocol.common.reply;
-
-import ghidra.comm.packet.fields.PacketField;
-import ghidra.dbg.sctl.protocol.AbstractSctlReply;
-import ghidra.dbg.sctl.protocol.common.AbstractSctlStatus;
-
-/**
- * Format for the {@code Rstat} SCTL message
- */
-public class SctlStatusReply extends AbstractSctlReply {
- @PacketField
- public AbstractSctlStatus status;
-}
diff --git a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/common/reply/SctlStepReply.java b/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/common/reply/SctlStepReply.java
deleted file mode 100644
index a4258d7819..0000000000
--- a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/common/reply/SctlStepReply.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/* ###
- * 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 ghidra.dbg.sctl.protocol.common.reply;
-
-import ghidra.comm.packet.annot.OptionalField;
-import ghidra.comm.packet.fields.PacketField;
-import ghidra.dbg.sctl.protocol.AbstractSctlReply;
-import ghidra.dbg.sctl.protocol.common.AbstractSctlContext;
-
-/**
- * Format for the {@code Rstep} SCTL message
- */
-public class SctlStepReply extends AbstractSctlReply {
- public SctlStepReply() {
- }
-
- public SctlStepReply(AbstractSctlContext ctx) {
- this.ctx = ctx;
- }
-
- @PacketField
- @OptionalField
- public AbstractSctlContext ctx;
-}
diff --git a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/common/reply/SctlStopReply.java b/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/common/reply/SctlStopReply.java
deleted file mode 100644
index 533720ab3c..0000000000
--- a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/common/reply/SctlStopReply.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/* ###
- * 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 ghidra.dbg.sctl.protocol.common.reply;
-
-import ghidra.comm.packet.annot.OptionalField;
-import ghidra.comm.packet.fields.PacketField;
-import ghidra.dbg.sctl.protocol.AbstractSctlReply;
-import ghidra.dbg.sctl.protocol.common.AbstractSctlContext;
-
-/**
- * Format for the {@code Rstop} SCTL message
- */
-public class SctlStopReply extends AbstractSctlReply {
- public SctlStopReply() {
- }
-
- public SctlStopReply(AbstractSctlContext ctx) {
- this.ctx = ctx;
- }
-
- @PacketField
- @OptionalField
- public AbstractSctlContext ctx;
-}
diff --git a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/common/reply/SctlTraceReply.java b/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/common/reply/SctlTraceReply.java
deleted file mode 100644
index 14423545b3..0000000000
--- a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/common/reply/SctlTraceReply.java
+++ /dev/null
@@ -1,25 +0,0 @@
-/* ###
- * 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 ghidra.dbg.sctl.protocol.common.reply;
-
-import ghidra.dbg.sctl.protocol.AbstractSctlReply;
-
-/**
- * Format for the {@code Rtrace} SCTL message
- */
-public class SctlTraceReply extends AbstractSctlReply {
- // Empty
-}
diff --git a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/common/reply/SctlUnwindOneFrameReply.java b/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/common/reply/SctlUnwindOneFrameReply.java
deleted file mode 100644
index 5bc49f7247..0000000000
--- a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/common/reply/SctlUnwindOneFrameReply.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/* ###
- * 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 ghidra.dbg.sctl.protocol.common.reply;
-
-import java.util.List;
-
-import ghidra.comm.packet.Packet;
-import ghidra.comm.packet.annot.CountedByField;
-import ghidra.comm.packet.annot.RepeatedField;
-import ghidra.comm.packet.fields.PacketField;
-import ghidra.dbg.sctl.protocol.AbstractSctlReply;
-import ghidra.dbg.sctl.protocol.consts.Rulekind;
-
-/**
- * Format for the {@code Runwind1} SCTL message
- */
-public class SctlUnwindOneFrameReply extends AbstractSctlReply {
- @PacketField
- public long nr;
-
- @PacketField
- @RepeatedField
- @CountedByField("nr")
- public List<Rule> rules;
-
- // The docs refer to DWARF 3.0 spec Section 6.4, but I can't tell which subset, precisely.
- public static class Rule extends Packet {
- @PacketField
- public Rulekind kind;
-
- @PacketField
- public long reg;
-
- @PacketField
- public long no;
- }
-}
diff --git a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/common/reply/SctlVersionReply.java b/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/common/reply/SctlVersionReply.java
deleted file mode 100644
index 1c156af85a..0000000000
--- a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/common/reply/SctlVersionReply.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/* ###
- * 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 ghidra.dbg.sctl.protocol.common.reply;
-
-import ghidra.comm.packet.fields.PacketField;
-import ghidra.dbg.sctl.protocol.AbstractSctlReply;
-
-/**
- * Format for the {@code Rversion} SCTL message
- */
-public class SctlVersionReply extends AbstractSctlReply {
- public SctlVersionReply() {
- }
-
- public SctlVersionReply(String version) {
- this.version = version;
- }
-
- @PacketField
- public String version;
-}
diff --git a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/common/reply/SctlWriteReply.java b/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/common/reply/SctlWriteReply.java
deleted file mode 100644
index 22da6bfc90..0000000000
--- a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/common/reply/SctlWriteReply.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/* ###
- * 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 ghidra.dbg.sctl.protocol.common.reply;
-
-import ghidra.comm.packet.fields.PacketField;
-import ghidra.dbg.sctl.protocol.AbstractSctlReply;
-
-/**
- * Format for the {@code Rwrite} SCTL message
- */
-public class SctlWriteReply extends AbstractSctlReply {
- public SctlWriteReply() {
- }
-
- public SctlWriteReply(long cnt) {
- this.cnt = cnt;
- }
-
- @PacketField
- public long cnt;
-}
diff --git a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/common/request/SctlAttachRequest.java b/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/common/request/SctlAttachRequest.java
deleted file mode 100644
index 5964d12a16..0000000000
--- a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/common/request/SctlAttachRequest.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/* ###
- * 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 ghidra.dbg.sctl.protocol.common.request;
-
-import ghidra.comm.packet.fields.PacketField;
-import ghidra.dbg.sctl.protocol.AbstractSctlRequest;
-
-/**
- * Format for the {@code Tattach} SCTL message
- */
-public class SctlAttachRequest extends AbstractSctlRequest {
- public SctlAttachRequest() {
- }
-
- public SctlAttachRequest(long pid) {
- this.pid = pid;
- }
-
- @PacketField
- public long pid;
-}
diff --git a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/common/request/SctlClearTrapRequest.java b/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/common/request/SctlClearTrapRequest.java
deleted file mode 100644
index 11b5b2b1a4..0000000000
--- a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/common/request/SctlClearTrapRequest.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/* ###
- * 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 ghidra.dbg.sctl.protocol.common.request;
-
-import ghidra.comm.packet.fields.PacketField;
-import ghidra.dbg.sctl.protocol.AbstractSctlRequest;
-
-/**
- * Format for the {@code Tclrtrap} SCTL message
- */
-public class SctlClearTrapRequest extends AbstractSctlRequest {
- public SctlClearTrapRequest() {
- }
-
- public SctlClearTrapRequest(long ctlid, long trpid) {
- this.ctlid = ctlid;
- this.trpid = trpid;
- }
-
- @PacketField
- public long ctlid;
-
- @PacketField
- public long trpid;
-}
diff --git a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/common/request/SctlContinueRequest.java b/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/common/request/SctlContinueRequest.java
deleted file mode 100644
index e370cb1115..0000000000
--- a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/common/request/SctlContinueRequest.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/* ###
- * 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 ghidra.dbg.sctl.protocol.common.request;
-
-import ghidra.comm.packet.fields.PacketField;
-import ghidra.dbg.sctl.protocol.AbstractSctlRequest;
-
-/**
- * Format for the {@code Tcont} SCTL message
- */
-public class SctlContinueRequest extends AbstractSctlRequest {
- public SctlContinueRequest() {
- }
-
- public SctlContinueRequest(long ctlid) {
- this.ctlid = ctlid;
- }
-
- @PacketField
- public long ctlid;
-}
diff --git a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/common/request/SctlDetachRequest.java b/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/common/request/SctlDetachRequest.java
deleted file mode 100644
index b4be2c5687..0000000000
--- a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/common/request/SctlDetachRequest.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/* ###
- * 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 ghidra.dbg.sctl.protocol.common.request;
-
-import ghidra.comm.packet.fields.PacketField;
-import ghidra.dbg.sctl.protocol.AbstractSctlRequest;
-
-/**
- * Format for the {@code Tdetach} SCTL message
- */
-public class SctlDetachRequest extends AbstractSctlRequest {
- public SctlDetachRequest() {
- }
-
- public SctlDetachRequest(long ctlid) {
- this.ctlid = ctlid;
- }
-
- @PacketField
- public long ctlid;
-}
diff --git a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/common/request/SctlEnumerateLocalsRequest.java b/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/common/request/SctlEnumerateLocalsRequest.java
deleted file mode 100644
index df6b24cd44..0000000000
--- a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/common/request/SctlEnumerateLocalsRequest.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/* ###
- * 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 ghidra.dbg.sctl.protocol.common.request;
-
-import ghidra.comm.packet.fields.PacketField;
-import ghidra.dbg.sctl.protocol.AbstractSctlRequest;
-
-/**
- * Format for the {@code Tenumloc} SCTL message
- */
-public class SctlEnumerateLocalsRequest extends AbstractSctlRequest {
- @PacketField
- public long nsid;
-
- @PacketField
- public long addr;
-}
diff --git a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/common/request/SctlEnumerateSegmentsRequest.java b/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/common/request/SctlEnumerateSegmentsRequest.java
deleted file mode 100644
index eb39eb3538..0000000000
--- a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/common/request/SctlEnumerateSegmentsRequest.java
+++ /dev/null
@@ -1,25 +0,0 @@
-/* ###
- * 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 ghidra.dbg.sctl.protocol.common.request;
-
-import ghidra.dbg.sctl.protocol.AbstractSctlRequest;
-
-/**
- * Format for the {@code Tenumseq} SCTL message
- */
-public class SctlEnumerateSegmentsRequest extends AbstractSctlRequest {
- // No content
-}
diff --git a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/common/request/SctlEnumerateSymbolsRequest.java b/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/common/request/SctlEnumerateSymbolsRequest.java
deleted file mode 100644
index 2af6df3c50..0000000000
--- a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/common/request/SctlEnumerateSymbolsRequest.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/* ###
- * 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 ghidra.dbg.sctl.protocol.common.request;
-
-import ghidra.comm.packet.fields.PacketField;
-import ghidra.dbg.sctl.protocol.AbstractSctlRequest;
-
-/**
- * Format for the {@code Tenumsym} SCTL message
- */
-public class SctlEnumerateSymbolsRequest extends AbstractSctlRequest {
- public SctlEnumerateSymbolsRequest() {
- }
-
- public SctlEnumerateSymbolsRequest(long nsid) {
- this.nsid = nsid;
- }
-
- @PacketField
- public long nsid;
-}
diff --git a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/common/request/SctlEnumerateTypesRequest.java b/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/common/request/SctlEnumerateTypesRequest.java
deleted file mode 100644
index e35a637a27..0000000000
--- a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/common/request/SctlEnumerateTypesRequest.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/* ###
- * 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 ghidra.dbg.sctl.protocol.common.request;
-
-import ghidra.comm.packet.fields.PacketField;
-import ghidra.dbg.sctl.protocol.AbstractSctlRequest;
-
-/**
- * Format for the {@code Tenumtype} SCTL message
- */
-public class SctlEnumerateTypesRequest extends AbstractSctlRequest {
- public SctlEnumerateTypesRequest() {
- }
-
- public SctlEnumerateTypesRequest(long nsid) {
- this.nsid = nsid;
- }
-
- @PacketField
- public long nsid;
-}
diff --git a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/common/request/SctlGetContextRequest.java b/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/common/request/SctlGetContextRequest.java
deleted file mode 100644
index f374475cb7..0000000000
--- a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/common/request/SctlGetContextRequest.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/* ###
- * 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 ghidra.dbg.sctl.protocol.common.request;
-
-import ghidra.comm.packet.fields.PacketField;
-import ghidra.dbg.sctl.protocol.AbstractSctlRequest;
-
-/**
- * Format for the {@code Tgetctx} SCTL message
- */
-public class SctlGetContextRequest extends AbstractSctlRequest {
- public SctlGetContextRequest() {
- }
-
- public SctlGetContextRequest(long ctlid) {
- this.ctlid = ctlid;
- }
-
- @PacketField
- public long ctlid;
-}
diff --git a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/common/request/SctlKillRequest.java b/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/common/request/SctlKillRequest.java
deleted file mode 100644
index 17e32878de..0000000000
--- a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/common/request/SctlKillRequest.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/* ###
- * 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 ghidra.dbg.sctl.protocol.common.request;
-
-import ghidra.comm.packet.fields.PacketField;
-import ghidra.dbg.sctl.protocol.AbstractSctlRequest;
-
-/**
- * Format for the {@code Tkill} SCTL message
- */
-public class SctlKillRequest extends AbstractSctlRequest {
- public SctlKillRequest() {
- }
-
- public SctlKillRequest(long ctlid) {
- this.ctlid = ctlid;
- }
-
- @PacketField
- public long ctlid;
-}
diff --git a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/common/request/SctlLaunchRequest.java b/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/common/request/SctlLaunchRequest.java
deleted file mode 100644
index 54a9986121..0000000000
--- a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/common/request/SctlLaunchRequest.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/* ###
- * 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 ghidra.dbg.sctl.protocol.common.request;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import ghidra.comm.packet.annot.CountedByField;
-import ghidra.comm.packet.annot.RepeatedField;
-import ghidra.comm.packet.fields.PacketField;
-import ghidra.dbg.sctl.protocol.AbstractSctlRequest;
-import ghidra.dbg.sctl.protocol.common.SctlString;
-
-/**
- * Format for the {@code Tlaunch} SCTL message
- *
- * Technically, this should be dialect dependent, but it appears both dialects in the reference
- * implementations use this same format.
- */
-// TODO: Use an abstract placeholder if this turns out to be a dialect-dependent extension point
-public class SctlLaunchRequest extends AbstractSctlRequest {
- public SctlLaunchRequest() {
- }
-
- public SctlLaunchRequest(List<String> args) {
- this.args = new ArrayList<>();
- for (String arg : args) {
- this.args.add(new SctlString(arg));
- }
- }
-
- @PacketField
- public long flags;
-
- @PacketField
- public long narg;
-
- @PacketField
- @RepeatedField
- @CountedByField("narg")
- public List<SctlString> args;
-}
diff --git a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/common/request/SctlLookupAddressRequest.java b/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/common/request/SctlLookupAddressRequest.java
deleted file mode 100644
index e1e0d18ba8..0000000000
--- a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/common/request/SctlLookupAddressRequest.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/* ###
- * 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 ghidra.dbg.sctl.protocol.common.request;
-
-import ghidra.comm.packet.fields.PacketField;
-import ghidra.dbg.sctl.protocol.AbstractSctlRequest;
-
-/**
- * Format for the {@code Tlookaddr} SCTL message
- */
-public class SctlLookupAddressRequest extends AbstractSctlRequest {
- @PacketField
- public long nsid;
-
- @PacketField
- public long addr;
-}
diff --git a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/common/request/SctlLookupProgramCounterRequest.java b/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/common/request/SctlLookupProgramCounterRequest.java
deleted file mode 100644
index 54d0802a65..0000000000
--- a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/common/request/SctlLookupProgramCounterRequest.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/* ###
- * 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 ghidra.dbg.sctl.protocol.common.request;
-
-import ghidra.comm.packet.fields.PacketField;
-import ghidra.dbg.sctl.protocol.AbstractSctlRequest;
-import ghidra.dbg.sctl.protocol.common.SctlString;
-
-/**
- * Format for the {@code Tlookpc} SCTL message
- */
-public class SctlLookupProgramCounterRequest extends AbstractSctlRequest {
- @PacketField
- public long nsid;
-
- @PacketField
- public SctlString file;
-
- @PacketField
- public int line;
-}
diff --git a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/common/request/SctlLookupSourceRequest.java b/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/common/request/SctlLookupSourceRequest.java
deleted file mode 100644
index 3aa5a9e6a9..0000000000
--- a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/common/request/SctlLookupSourceRequest.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/* ###
- * 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 ghidra.dbg.sctl.protocol.common.request;
-
-import ghidra.comm.packet.fields.PacketField;
-import ghidra.dbg.sctl.protocol.AbstractSctlRequest;
-
-/**
- * Format for the {@code Tlooksrc} SCTL message
- */
-public class SctlLookupSourceRequest extends AbstractSctlRequest {
- @PacketField
- public long nsid;
-
- @PacketField
- public long addr;
-}
diff --git a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/common/request/SctlLookupSymbolRequest.java b/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/common/request/SctlLookupSymbolRequest.java
deleted file mode 100644
index f7c7015426..0000000000
--- a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/common/request/SctlLookupSymbolRequest.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/* ###
- * 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 ghidra.dbg.sctl.protocol.common.request;
-
-import ghidra.comm.packet.fields.PacketField;
-import ghidra.dbg.sctl.protocol.AbstractSctlRequest;
-import ghidra.dbg.sctl.protocol.common.SctlString;
-
-/**
- * Format for the {@code Tlooksym} SCTL message
- */
-public class SctlLookupSymbolRequest extends AbstractSctlRequest {
- public SctlLookupSymbolRequest() {
- }
-
- public SctlLookupSymbolRequest(long nsid, String name) {
- this.nsid = nsid;
- this.name = new SctlString(name);
- }
-
- @PacketField
- public long nsid;
-
- @PacketField
- public SctlString name;
-}
diff --git a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/common/request/SctlLookupTypeRequest.java b/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/common/request/SctlLookupTypeRequest.java
deleted file mode 100644
index 57af0d3f40..0000000000
--- a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/common/request/SctlLookupTypeRequest.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/* ###
- * 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 ghidra.dbg.sctl.protocol.common.request;
-
-import ghidra.comm.packet.fields.PacketField;
-import ghidra.dbg.sctl.protocol.AbstractSctlRequest;
-import ghidra.dbg.sctl.protocol.types.AbstractSctlTypeName;
-import ghidra.dbg.sctl.protocol.types.SelSctlTypeName;
-
-/**
- * Format for the {@code Tlooktype} SCTL message
- */
-public class SctlLookupTypeRequest extends AbstractSctlRequest {
- public SctlLookupTypeRequest() {
- }
-
- public SctlLookupTypeRequest(long nsid, AbstractSctlTypeName tname) {
- this.nsid = nsid;
- this.tname = new SelSctlTypeName(tname);
- }
-
- @PacketField
- public long nsid;
-
- @PacketField
- public SelSctlTypeName tname;
-}
diff --git a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/common/request/SctlNamesRequest.java b/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/common/request/SctlNamesRequest.java
deleted file mode 100644
index bf0d6dfa42..0000000000
--- a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/common/request/SctlNamesRequest.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/* ###
- * 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 ghidra.dbg.sctl.protocol.common.request;
-
-import ghidra.comm.packet.fields.PacketField;
-import ghidra.dbg.sctl.protocol.AbstractSctlRequest;
-import ghidra.dbg.sctl.protocol.common.SctlString;
-
-/**
- * Format for the {@code Tnames} SCTL message
- *
- * Note this just binds a namespace. The {@code Tenum/look}<em>x</em> requests then retrieve the
- * names.
- */
-// "bind namespace"
-public class SctlNamesRequest extends AbstractSctlRequest {
- @PacketField
- public SctlString path;
-}
diff --git a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/common/request/SctlPingRequest.java b/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/common/request/SctlPingRequest.java
deleted file mode 100644
index 2c6cb1c16a..0000000000
--- a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/common/request/SctlPingRequest.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/* ###
- * 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 ghidra.dbg.sctl.protocol.common.request;
-
-import ghidra.comm.packet.fields.PacketField;
-import ghidra.dbg.sctl.protocol.AbstractSctlRequest;
-
-/**
- * Format for the {@code Tping} SCTL message
- */
-public class SctlPingRequest extends AbstractSctlRequest {
- public SctlPingRequest() {
- }
-
- public SctlPingRequest(String string) {
- bytes = string.getBytes();
- }
-
- @PacketField
- public byte[] bytes;
-}
diff --git a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/common/request/SctlProcessListRequest.java b/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/common/request/SctlProcessListRequest.java
deleted file mode 100644
index e36107ec40..0000000000
--- a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/common/request/SctlProcessListRequest.java
+++ /dev/null
@@ -1,25 +0,0 @@
-/* ###
- * 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 ghidra.dbg.sctl.protocol.common.request;
-
-import ghidra.dbg.sctl.protocol.AbstractSctlRequest;
-
-/**
- * Format for the {@code Tps} SCTL message
- */
-public class SctlProcessListRequest extends AbstractSctlRequest {
- // No content
-}
diff --git a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/common/request/SctlReadRequest.java b/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/common/request/SctlReadRequest.java
deleted file mode 100644
index fe4a009f41..0000000000
--- a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/common/request/SctlReadRequest.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/* ###
- * 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 ghidra.dbg.sctl.protocol.common.request;
-
-import ghidra.comm.packet.fields.PacketField;
-import ghidra.dbg.sctl.protocol.AbstractSctlRequest;
-
-/**
- * Format for the {@code Tread} SCTL message
- */
-public class SctlReadRequest extends AbstractSctlRequest {
- public SctlReadRequest() {
- }
-
- public SctlReadRequest(long ctlid, long fd, long offset, long cnt) {
- this.ctlid = ctlid;
- this.fd = fd;
- this.offset = offset;
- this.cnt = cnt;
- }
-
- @PacketField
- public long ctlid;
-
- @PacketField
- public long fd;
-
- @PacketField
- public long offset;
-
- @PacketField
- public long cnt;
-}
diff --git a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/common/request/SctlSetContextRequest.java b/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/common/request/SctlSetContextRequest.java
deleted file mode 100644
index 73d58131c8..0000000000
--- a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/common/request/SctlSetContextRequest.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/* ###
- * 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 ghidra.dbg.sctl.protocol.common.request;
-
-import ghidra.comm.packet.fields.PacketField;
-import ghidra.dbg.sctl.protocol.AbstractSctlRequest;
-import ghidra.dbg.sctl.protocol.common.AbstractSctlContext;
-
-/**
- * Format for the {@code Tsetctx} SCTL message
- */
-public class SctlSetContextRequest extends AbstractSctlRequest {
- public SctlSetContextRequest() {
- }
-
- public SctlSetContextRequest(long ctlid, AbstractSctlContext ctx) {
- this.ctlid = ctlid;
- this.ctx = ctx;
- }
-
- @PacketField
- public long ctlid;
-
- @PacketField
- public AbstractSctlContext ctx;
-}
diff --git a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/common/request/SctlSetTrapRequest.java b/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/common/request/SctlSetTrapRequest.java
deleted file mode 100644
index 14446ccb00..0000000000
--- a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/common/request/SctlSetTrapRequest.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/* ###
- * 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 ghidra.dbg.sctl.protocol.common.request;
-
-import ghidra.comm.packet.fields.PacketField;
-import ghidra.dbg.sctl.protocol.AbstractSctlRequest;
-import ghidra.dbg.sctl.protocol.common.AbstractSctlTrapSpec;
-
-/**
- * Format for the {@code Tsettrap} SCTL message
- */
-public class SctlSetTrapRequest extends AbstractSctlRequest {
- public SctlSetTrapRequest() {
- }
-
- public SctlSetTrapRequest(long ctlid, AbstractSctlTrapSpec spec) {
- this.ctlid = ctlid;
- this.spec = spec;
- }
-
- @PacketField
- public long ctlid;
-
- @PacketField
- public AbstractSctlTrapSpec spec;
-}
diff --git a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/common/request/SctlSnapshotRequest.java b/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/common/request/SctlSnapshotRequest.java
deleted file mode 100644
index e3d92fca4c..0000000000
--- a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/common/request/SctlSnapshotRequest.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/* ###
- * 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 ghidra.dbg.sctl.protocol.common.request;
-
-import ghidra.comm.packet.fields.PacketField;
-import ghidra.dbg.sctl.protocol.AbstractSctlRequest;
-
-/**
- * Format for the {@code Tsnap} SCTL message
- */
-public class SctlSnapshotRequest extends AbstractSctlRequest {
- public SctlSnapshotRequest() {
- }
-
- public SctlSnapshotRequest(long ctlid) {
- this.ctlid = ctlid;
- }
-
- @PacketField
- public long ctlid;
-}
diff --git a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/common/request/SctlStatusRequest.java b/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/common/request/SctlStatusRequest.java
deleted file mode 100644
index e0ab4293df..0000000000
--- a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/common/request/SctlStatusRequest.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/* ###
- * 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 ghidra.dbg.sctl.protocol.common.request;
-
-import ghidra.comm.packet.fields.PacketField;
-import ghidra.dbg.sctl.protocol.AbstractSctlRequest;
-
-/**
- * Format for the {@code Tstatus} SCTL message
- */
-public class SctlStatusRequest extends AbstractSctlRequest {
- public SctlStatusRequest() {
- }
-
- public SctlStatusRequest(long ctlid) {
- this.ctlid = ctlid;
- }
-
- @PacketField
- public long ctlid;
-}
diff --git a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/common/request/SctlStepRequest.java b/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/common/request/SctlStepRequest.java
deleted file mode 100644
index 17baea8c16..0000000000
--- a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/common/request/SctlStepRequest.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/* ###
- * 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 ghidra.dbg.sctl.protocol.common.request;
-
-import ghidra.comm.packet.fields.PacketField;
-import ghidra.dbg.sctl.protocol.AbstractSctlRequest;
-
-/**
- * Format for the {@code Tstep} SCTL message
- */
-public class SctlStepRequest extends AbstractSctlRequest {
- public SctlStepRequest() {
- }
-
- public SctlStepRequest(long ctlid) {
- this.ctlid = ctlid;
- }
-
- @PacketField
- public long ctlid;
-}
diff --git a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/common/request/SctlStopRequest.java b/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/common/request/SctlStopRequest.java
deleted file mode 100644
index d1c25b5cb2..0000000000
--- a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/common/request/SctlStopRequest.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/* ###
- * 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 ghidra.dbg.sctl.protocol.common.request;
-
-import ghidra.comm.packet.fields.PacketField;
-import ghidra.dbg.sctl.protocol.AbstractSctlRequest;
-
-/**
- * Format for the {@code Tstop} SCTL message
- */
-public class SctlStopRequest extends AbstractSctlRequest {
- public SctlStopRequest() {
- }
-
- public SctlStopRequest(long ctlid) {
- this.ctlid = ctlid;
- }
-
- @PacketField
- public long ctlid;
-}
diff --git a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/common/request/SctlTraceRequest.java b/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/common/request/SctlTraceRequest.java
deleted file mode 100644
index 50e5217404..0000000000
--- a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/common/request/SctlTraceRequest.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/* ###
- * 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 ghidra.dbg.sctl.protocol.common.request;
-
-import ghidra.comm.packet.annot.BitmaskEncoded;
-import ghidra.comm.packet.fields.PacketField;
-import ghidra.comm.util.BitmaskSet;
-import ghidra.dbg.sctl.protocol.AbstractSctlRequest;
-import ghidra.dbg.sctl.protocol.consts.Evkind;
-
-/**
- * Format for the {@code Ttrace} SCTL message
- */
-public class SctlTraceRequest extends AbstractSctlRequest {
- public SctlTraceRequest() {
- }
-
- public SctlTraceRequest(long ctlid, BitmaskSet<Evkind> flags) {
- this.ctlid = ctlid;
- this.flags = flags;
- }
-
- @PacketField
- public long ctlid;
-
- @PacketField
- @BitmaskEncoded(universe = Evkind.class)
- public BitmaskSet<Evkind> flags;
-}
diff --git a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/common/request/SctlUnwindOneFrameRequest.java b/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/common/request/SctlUnwindOneFrameRequest.java
deleted file mode 100644
index 5a192f5fb4..0000000000
--- a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/common/request/SctlUnwindOneFrameRequest.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/* ###
- * 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 ghidra.dbg.sctl.protocol.common.request;
-
-import ghidra.comm.packet.fields.PacketField;
-import ghidra.dbg.sctl.protocol.AbstractSctlRequest;
-
-/**
- * Format for the {@code Tunwind1} SCTL message
- */
-public class SctlUnwindOneFrameRequest extends AbstractSctlRequest {
- @PacketField
- public long nsid;
-
- @PacketField
- public long addr;
-}
diff --git a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/common/request/SctlVersionRequest.java b/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/common/request/SctlVersionRequest.java
deleted file mode 100644
index 6f04500902..0000000000
--- a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/common/request/SctlVersionRequest.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/* ###
- * 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 ghidra.dbg.sctl.protocol.common.request;
-
-import ghidra.comm.packet.fields.PacketField;
-import ghidra.dbg.sctl.protocol.AbstractSctlRequest;
-
-/**
- * Format for the {@code Tversion} SCTL message
- */
-public class SctlVersionRequest extends AbstractSctlRequest {
- public SctlVersionRequest() {
- }
-
- public SctlVersionRequest(String version) {
- this.version = version;
- }
-
- @PacketField
- public String version;
-}
diff --git a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/common/request/SctlWriteRequest.java b/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/common/request/SctlWriteRequest.java
deleted file mode 100644
index 1a026c0d34..0000000000
--- a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/common/request/SctlWriteRequest.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/* ###
- * 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 ghidra.dbg.sctl.protocol.common.request;
-
-import ghidra.comm.packet.fields.PacketField;
-import ghidra.dbg.sctl.protocol.AbstractSctlRequest;
-
-/**
- * Format for the {@code Twrite} SCTL message
- */
-public class SctlWriteRequest extends AbstractSctlRequest {
- public SctlWriteRequest() {
- }
-
- public SctlWriteRequest(long ctlid, long fd, long offset, byte[] bytes) {
- this.ctlid = ctlid;
- this.fd = fd;
- this.offset = offset;
- this.bytes = bytes;
- }
-
- @PacketField
- public long ctlid;
-
- @PacketField
- public long fd;
-
- @PacketField
- public long offset;
-
- @PacketField
- public byte[] bytes;
-}
diff --git a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/consts/Attrval.java b/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/consts/Attrval.java
deleted file mode 100644
index 5fe01450db..0000000000
--- a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/consts/Attrval.java
+++ /dev/null
@@ -1,23 +0,0 @@
-/* ###
- * 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 ghidra.dbg.sctl.protocol.consts;
-
-/**
- * See the SCTL documentation
- */
-public enum Attrval {
- Astr, Acid, Auint;
-}
diff --git a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/consts/Cbase.java b/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/consts/Cbase.java
deleted file mode 100644
index f6ca7994d7..0000000000
--- a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/consts/Cbase.java
+++ /dev/null
@@ -1,57 +0,0 @@
-/* ###
- * 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 ghidra.dbg.sctl.protocol.consts;
-
-/**
- * See the SCTL documentation
- */
-public enum Cbase {
- Vundef("undef"),
- Vbool("_Bool"),
- Vchar("char"),
- Vshort("short"),
- Vint("int"),
- Vlong("long"),
- Vvlong("long long"),
- Vuchar("unsigned char"),
- Vushort("unsigned short"),
- Vuint("unsigned int"),
- Vulong("unsigned long"),
- Vuvlong("unsigned long long"),
- Vfloat("float"),
- Vdouble("double"),
- Vlongdouble("long double"),
- Vcomplex("float complex"),
- Vdoublex("double complex"),
- Vlongdoublex("long double complex"),
- Vptr("ptr"),
- Vvoid("void");
-
- private String cname;
-
- Cbase(String cname) {
- this.cname = cname;
- }
-
- @Override
- public String toString() {
- return "Cbase:" + cname;
- }
-
- public String getCName() {
- return cname;
- }
-}
diff --git a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/consts/Evkind.java b/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/consts/Evkind.java
deleted file mode 100644
index 66076c3537..0000000000
--- a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/consts/Evkind.java
+++ /dev/null
@@ -1,64 +0,0 @@
-/* ###
- * 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 ghidra.dbg.sctl.protocol.consts;
-
-import ghidra.comm.util.BitmaskUniverse;
-import ghidra.dbg.sctl.client.SctlExtension;
-
-/**
- * Taken from Evkind in the SCTL documentation
- *
- * Two extra bits have been added to make the protocol more orthogonal, but remain backward
- * compatible. The {@link #Estopped} bit indicates that the target has been stopped as part of this
- * trace event. This is the usual case except for {@link #Efork} and {@link #Eclone} on Windows. The
- * {@link #Erunning} bit indicates the opposite: the target is still running, despite issuing this
- * trace event. Servers supporting this mechanism must set exactly one of these bits. If neither is
- * present, the client must assume the server does not support the extension, and use the dialect
- * default. To set both is an error.
- *
- * For now, this modification has been rolled into the SCTL-Bus extension. However, a server cannot
- * use this extension with a non-bus client.
- */
-public enum Evkind implements BitmaskUniverse {
- Eclear(0 << 0),
- Eset(1 << 0),
- Esyscall(1 << 1), // Not valid on Windows
- Eexec(1 << 2), // Not valid on Windows
- Efork(1 << 3),
- Eclone(1 << 4),
- Esignal(1 << 5),
- Eexit(1 << 6),
- Etrap(1 << 7),
- Esnap(1 << 8),
- Estepctx(1 << 9),
- Eload(1 << 10),
- Eunload(1 << 11),
- @SctlExtension("The target has stopped")
- Estopped(1 << 12),
- @SctlExtension("The target is still running")
- Erunning(1 << 13);
-
- public final long mask;
-
- private Evkind(long mask) {
- this.mask = mask;
- }
-
- @Override
- public long getMask() {
- return mask;
- }
-}
diff --git a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/consts/Lkind.java b/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/consts/Lkind.java
deleted file mode 100644
index 14695fed61..0000000000
--- a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/consts/Lkind.java
+++ /dev/null
@@ -1,23 +0,0 @@
-/* ###
- * 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 ghidra.dbg.sctl.protocol.consts;
-
-/**
- * See the SCTL documentation
- */
-public enum Lkind {
- Lreg, Lderef, Ladd, Lsub, Lulit, Lslit;
-}
diff --git a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/consts/Mkind.java b/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/consts/Mkind.java
deleted file mode 100644
index a7cac238d2..0000000000
--- a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/consts/Mkind.java
+++ /dev/null
@@ -1,102 +0,0 @@
-/* ###
- * 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 ghidra.dbg.sctl.protocol.consts;
-
-import ghidra.dbg.sctl.client.SctlExtension;
-
-/**
- * See the SCTL documentation
- */
-public enum Mkind {
- Reserved0,
- Rerror,
- Reserved2,
- Aevent,
- Tversion,
- Rversion,
- Tping,
- Rping,
- Tps,
- Rps,
- Tlaunch,
- Rlaunch,
- Tattach,
- Rattach,
- Tstat,
- Rstat,
- Tcont,
- Rcont,
- Tstop,
- Rstop,
- Tstep,
- Rstep,
- Tsnap,
- Rsnap,
- Tkill,
- Rkill,
- Tdetach,
- Rdetach,
- Ttrace,
- Rtrace,
- Tsettrap,
- Rsettrap,
- Tclrtrap,
- Rclrtrap,
- Tgetctx,
- Rgetctx,
- Tsetctx,
- Rsetctx,
- Tread,
- Rread,
- Twrite,
- Rwrite,
- Tlooksym,
- Rlooksym,
- Tenumsym,
- Renumsym,
- Tlooktype,
- Rlooktype,
- Tenumtype,
- Renumtype,
- Tlookaddr,
- Rlookaddr,
- Tenumloc,
- Renumloc,
- Tenumseg,
- Renumseg,
- Tnames,
- Rnames,
- Tunwind1,
- Runwind1,
- Tlooksrc,
- Rlooksrc,
- Tlookpc,
- Rlookpc,
- @SctlExtension("Execute a CLI command")
- Texec,
- @SctlExtension("CLI Command output")
- Rexec,
- Tenumctx,
- Renumctx,
- Tchoosectx,
- Rchoosectx,
- Tfocus,
- Rfocus,
- Tgetchildren,
- Rgetchildren,
- Tgetattributes,
- Rgetattributes,
-}
diff --git a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/consts/Rkind.java b/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/consts/Rkind.java
deleted file mode 100644
index 891fba7abe..0000000000
--- a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/consts/Rkind.java
+++ /dev/null
@@ -1,70 +0,0 @@
-/* ###
- * 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 ghidra.dbg.sctl.protocol.consts;
-
-import ghidra.dbg.attributes.TargetPrimitiveDataType.PrimitiveKind;
-
-/**
- * See the SCTL documentation
- */
-public enum Rkind {
- Rundef(1, PrimitiveKind.UNDEFINED),
- // Unsigned little-endian
- Ru08le(1, PrimitiveKind.UINT),
- Ru16le(2, PrimitiveKind.UINT),
- Ru32le(4, PrimitiveKind.UINT),
- Ru64le(8, PrimitiveKind.UINT),
- // Signed little-endian
- Rs08le(1, PrimitiveKind.SINT),
- Rs16le(2, PrimitiveKind.SINT),
- Rs32le(4, PrimitiveKind.SINT),
- Rs64le(8, PrimitiveKind.SINT),
- // Unsigned big-endian
- Ru08be(1, PrimitiveKind.UINT),
- Ru16be(2, PrimitiveKind.UINT),
- Ru32be(4, PrimitiveKind.UINT),
- Ru64be(8, PrimitiveKind.UINT),
- // Signed big-endian
- Rs08be(1, PrimitiveKind.SINT),
- Rs16be(2, PrimitiveKind.SINT),
- Rs32be(4, PrimitiveKind.SINT),
- Rs64be(8, PrimitiveKind.SINT),
- // Floating-point
- Rf32(4, PrimitiveKind.FLOAT),
- Rf64(8, PrimitiveKind.FLOAT),
- Rf96(12, PrimitiveKind.FLOAT),
- Rf128(16, PrimitiveKind.FLOAT),
- // Complex floating-point
- Rx64(8, PrimitiveKind.COMPLEX),
- Rx128(16, PrimitiveKind.COMPLEX),
- Rx192(24, PrimitiveKind.COMPLEX);
-
- private final int byteLength;
- private final PrimitiveKind kind;
-
- Rkind(int byteLength, PrimitiveKind kind) {
- this.byteLength = byteLength;
- this.kind = kind;
- }
-
- public int getByteLength() {
- return byteLength;
- }
-
- public PrimitiveKind getKind() {
- return kind;
- }
-}
diff --git a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/consts/Rulekind.java b/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/consts/Rulekind.java
deleted file mode 100644
index 6513edd226..0000000000
--- a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/consts/Rulekind.java
+++ /dev/null
@@ -1,23 +0,0 @@
-/* ###
- * 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 ghidra.dbg.sctl.protocol.consts;
-
-/**
- * See the SCTL documentation
- */
-public enum Rulekind {
- Rnone, Rcfaro, Rcfae, Rsame, Roff, Rvoff, Rreg, Rexp, Rvexp;
-}
diff --git a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/consts/Stype.java b/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/consts/Stype.java
deleted file mode 100644
index 8365eb0b11..0000000000
--- a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/consts/Stype.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/* ###
- * 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 ghidra.dbg.sctl.protocol.consts;
-
-import ghidra.comm.util.BitmaskUniverse;
-
-/**
- * See the SCTL documentation
- */
-public enum Stype implements BitmaskUniverse {
- Sundef(1 << 0), Sdata(1 << 1), Stext(1 << 2), Sro(1 << 3), Senum(1 << 4), Sinline(1 << 5);
-
- public final long mask;
-
- private Stype(long mask) {
- this.mask = mask;
- }
-
- @Override
- public long getMask() {
- return mask;
- }
-}
diff --git a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/consts/Tkind.java b/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/consts/Tkind.java
deleted file mode 100644
index d913a93393..0000000000
--- a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/consts/Tkind.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/* ###
- * 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 ghidra.dbg.sctl.protocol.consts;
-
-/**
- * See the SCTL documentation
- */
-public enum Tkind {
- Tvoid("void"),
- Tbase("base"),
- Tstruct("struct"),
- Tunion("union"),
- Tenum("enum"),
- Tptr("pointer"),
- Tarr("array"),
- Tfun("function"),
- Ttypedef("typedef"),
- Tbitfield("bitfield"),
- Tconst("constant"),
- Txaccess("xaccess"),
- Tundef("undef");
-
- private String str;
-
- Tkind(String str) {
- this.str = str;
- }
-
- @Override
- public String toString() {
- return "Tkind:" + str;
- }
-}
diff --git a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/consts/Vkind.java b/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/consts/Vkind.java
deleted file mode 100644
index 9a32bd5afd..0000000000
--- a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/consts/Vkind.java
+++ /dev/null
@@ -1,23 +0,0 @@
-/* ###
- * 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 ghidra.dbg.sctl.protocol.consts;
-
-/**
- * See the SCTL documentation
- */
-public enum Vkind {
- Vlocal, Vparam;
-}
diff --git a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/types/AbstractSctlAggregateTypeDefinition.java b/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/types/AbstractSctlAggregateTypeDefinition.java
deleted file mode 100644
index 1fda4cec4e..0000000000
--- a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/types/AbstractSctlAggregateTypeDefinition.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/* ###
- * 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 ghidra.dbg.sctl.protocol.types;
-
-import java.util.List;
-
-import ghidra.comm.packet.annot.CountedByField;
-import ghidra.comm.packet.annot.RepeatedField;
-import ghidra.comm.packet.fields.PacketField;
-import ghidra.dbg.sctl.protocol.common.SctlString;
-
-/**
- * The format for aggregate type definitions in SCTL
- */
-public abstract class AbstractSctlAggregateTypeDefinition extends AbstractSctlTypeDefinition {
- @PacketField
- public SctlString tag;
-
- @PacketField
- public long size;
-
- @PacketField
- public SctlAttributes attrs;
-
- @PacketField
- public long nfield;
-
- @PacketField
- @RepeatedField
- @CountedByField("nfield")
- public List<SctlAggregateField> fields;
-}
diff --git a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/types/AbstractSctlTaggedTypeName.java b/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/types/AbstractSctlTaggedTypeName.java
deleted file mode 100644
index b42547ee11..0000000000
--- a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/types/AbstractSctlTaggedTypeName.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/* ###
- * 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 ghidra.dbg.sctl.protocol.types;
-
-import ghidra.comm.packet.fields.PacketField;
-import ghidra.dbg.sctl.protocol.common.SctlString;
-
-/**
- * The format for tagged type names in SCTL
- */
-public abstract class AbstractSctlTaggedTypeName extends AbstractSctlTypeName {
- public AbstractSctlTaggedTypeName() {
- }
-
- public AbstractSctlTaggedTypeName(SctlString tag) {
- this.tag = tag;
- }
-
- @PacketField
- public SctlString tag;
-}
diff --git a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/types/AbstractSctlTypeDefinition.java b/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/types/AbstractSctlTypeDefinition.java
deleted file mode 100644
index dd491f7e5f..0000000000
--- a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/types/AbstractSctlTypeDefinition.java
+++ /dev/null
@@ -1,25 +0,0 @@
-/* ###
- * 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 ghidra.dbg.sctl.protocol.types;
-
-import ghidra.comm.packet.Packet;
-
-/**
- * A based type for each kind of {@code tdef[]} in SCTL
- */
-public abstract class AbstractSctlTypeDefinition extends Packet {
- public abstract AbstractSctlTypeName getTypeName();
-}
diff --git a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/types/AbstractSctlTypeName.java b/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/types/AbstractSctlTypeName.java
deleted file mode 100644
index 8951351472..0000000000
--- a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/types/AbstractSctlTypeName.java
+++ /dev/null
@@ -1,25 +0,0 @@
-/* ###
- * 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 ghidra.dbg.sctl.protocol.types;
-
-import ghidra.comm.packet.Packet;
-
-/**
- * A based type for each kind of {@code tname[]} in SCTL
- */
-public class AbstractSctlTypeName extends Packet {
- // No contents
-}
diff --git a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/types/SctlAggregateField.java b/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/types/SctlAggregateField.java
deleted file mode 100644
index 297c2953d6..0000000000
--- a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/types/SctlAggregateField.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/* ###
- * 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 ghidra.dbg.sctl.protocol.types;
-
-import ghidra.comm.packet.Packet;
-import ghidra.comm.packet.fields.PacketField;
-import ghidra.dbg.sctl.protocol.common.SctlString;
-
-/**
- * The format for each {@code field[]} in SCTL aggregate type definitions
- */
-public class SctlAggregateField extends Packet {
- @PacketField
- public long off;
-
- @PacketField
- public SctlAttributes attrs;
-
- @PacketField
- public SctlString id;
-
- @PacketField
- public SelSctlTypeName tname;
-}
diff --git a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/types/SctlArrayTypeName.java b/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/types/SctlArrayTypeName.java
deleted file mode 100644
index 7ccaa383fe..0000000000
--- a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/types/SctlArrayTypeName.java
+++ /dev/null
@@ -1,29 +0,0 @@
-/* ###
- * 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 ghidra.dbg.sctl.protocol.types;
-
-import ghidra.comm.packet.fields.PacketField;
-
-/**
- * The format for array type names in SCTL
- */
-public class SctlArrayTypeName extends AbstractSctlTypeName {
- @PacketField
- public long nelem;
-
- @PacketField
- public SelSctlTypeName tname;
-}
diff --git a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/types/SctlAtom.java b/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/types/SctlAtom.java
deleted file mode 100644
index 22f782ebcf..0000000000
--- a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/types/SctlAtom.java
+++ /dev/null
@@ -1,25 +0,0 @@
-/* ###
- * 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 ghidra.dbg.sctl.protocol.types;
-
-import ghidra.comm.packet.Packet;
-
-/**
- * A base class for any key or value in a SCTL attribute
- */
-public abstract class SctlAtom extends Packet {
- // No content
-}
diff --git a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/types/SctlAttributeKeyVal.java b/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/types/SctlAttributeKeyVal.java
deleted file mode 100644
index 1134b33f31..0000000000
--- a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/types/SctlAttributeKeyVal.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/* ###
- * 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 ghidra.dbg.sctl.protocol.types;
-
-import java.util.Map;
-
-import ghidra.comm.packet.Packet;
-import ghidra.comm.packet.annot.TypedByField;
-import ghidra.comm.packet.fields.PacketField;
-import ghidra.dbg.sctl.protocol.consts.Attrval;
-
-/**
- * The format for SCTL key-value pairs in attributes
- */
-public class SctlAttributeKeyVal extends Packet {
- public static final Map<Attrval, Class<? extends SctlAtom>> ATOM_MAP =
- typeMap(Attrval.class, SctlAtom.class) //
- .put(Attrval.Astr, SctlStringAtom.class) //
- .put(Attrval.Acid, SctlSymbolAtom.class) //
- .put(Attrval.Auint, SctlUIntAtom.class) //
- .build();
-
- @PacketField
- public Attrval keyKind;
-
- @PacketField
- @TypedByField(by = "keyKind", map = "ATOM_MAP")
- public SctlAtom key;
-
- @PacketField
- public Attrval valKind;
-
- @PacketField
- @TypedByField(by = "valKind", map = "ATOM_MAP")
- public SctlAtom val;
-}
diff --git a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/types/SctlAttributes.java b/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/types/SctlAttributes.java
deleted file mode 100644
index 29934711f6..0000000000
--- a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/types/SctlAttributes.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/* ###
- * 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 ghidra.dbg.sctl.protocol.types;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import ghidra.comm.packet.Packet;
-import ghidra.comm.packet.annot.CountedByField;
-import ghidra.comm.packet.annot.RepeatedField;
-import ghidra.comm.packet.fields.PacketField;
-
-/**
- * The format for {@code attrs} in SCTL
- */
-public class SctlAttributes extends Packet {
- public static SctlAttributes empty() {
- SctlAttributes attrs = new SctlAttributes();
- attrs.pairs = new ArrayList<>();
- return attrs;
- }
-
- @PacketField
- public long na;
-
- @PacketField
- @RepeatedField
- @CountedByField("na")
- public List<SctlAttributeKeyVal> pairs;
-}
diff --git a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/types/SctlBaseTypeDefinition.java b/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/types/SctlBaseTypeDefinition.java
deleted file mode 100644
index a146929394..0000000000
--- a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/types/SctlBaseTypeDefinition.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/* ###
- * 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 ghidra.dbg.sctl.protocol.types;
-
-import ghidra.comm.packet.fields.PacketField;
-import ghidra.dbg.sctl.protocol.consts.Cbase;
-import ghidra.dbg.sctl.protocol.consts.Rkind;
-
-/**
- * The format for base type definitions in SCTL
- */
-public class SctlBaseTypeDefinition extends AbstractSctlTypeDefinition {
- @PacketField
- public Cbase base;
-
- @PacketField
- public Rkind rep;
-
- @Override
- public AbstractSctlTypeName getTypeName() {
- return new SctlBaseTypeName(base);
- }
-}
diff --git a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/types/SctlBaseTypeName.java b/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/types/SctlBaseTypeName.java
deleted file mode 100644
index 23a208c171..0000000000
--- a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/types/SctlBaseTypeName.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/* ###
- * 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 ghidra.dbg.sctl.protocol.types;
-
-import ghidra.comm.packet.fields.PacketField;
-import ghidra.dbg.sctl.protocol.consts.Cbase;
-
-/**
- * The format for base type names in SCTL
- */
-public class SctlBaseTypeName extends AbstractSctlTypeName {
- public SctlBaseTypeName() {
- }
-
- public SctlBaseTypeName(Cbase base) {
- this.base = base;
- }
-
- @PacketField
- public Cbase base;
-}
diff --git a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/types/SctlBitfieldTypeName.java b/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/types/SctlBitfieldTypeName.java
deleted file mode 100644
index aeb508d4c1..0000000000
--- a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/types/SctlBitfieldTypeName.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/* ###
- * 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 ghidra.dbg.sctl.protocol.types;
-
-import ghidra.comm.packet.fields.PacketField;
-
-/**
- * The format for bitfield type names in SCTL
- */
-public class SctlBitfieldTypeName extends AbstractSctlTypeName {
- @PacketField
- public byte width;
-
- @PacketField
- public byte pos;
-
- @PacketField
- public SelSctlTypeName tname;
-}
diff --git a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/types/SctlEnumConstTypeName.java b/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/types/SctlEnumConstTypeName.java
deleted file mode 100644
index c63e96402a..0000000000
--- a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/types/SctlEnumConstTypeName.java
+++ /dev/null
@@ -1,26 +0,0 @@
-/* ###
- * 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 ghidra.dbg.sctl.protocol.types;
-
-import ghidra.comm.packet.fields.PacketField;
-
-/**
- * The format for enumeration constant type names in SCTL
- */
-public class SctlEnumConstTypeName extends AbstractSctlTypeName {
- @PacketField
- public SelSctlTypeName tname; // name of enum type
-}
diff --git a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/types/SctlEnumConstant.java b/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/types/SctlEnumConstant.java
deleted file mode 100644
index 6c4f341aca..0000000000
--- a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/types/SctlEnumConstant.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/* ###
- * 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 ghidra.dbg.sctl.protocol.types;
-
-import ghidra.comm.packet.Packet;
-import ghidra.comm.packet.fields.PacketField;
-import ghidra.dbg.sctl.protocol.common.SctlString;
-
-/**
- * The format for {@code const[]} in SCTL enumeration type definitions in SCTL
- */
-public class SctlEnumConstant extends Packet {
- @PacketField
- public SctlString id;
-
- @PacketField
- public long value;
-}
diff --git a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/types/SctlEnumTypeDefinition.java b/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/types/SctlEnumTypeDefinition.java
deleted file mode 100644
index 5f3811c0f3..0000000000
--- a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/types/SctlEnumTypeDefinition.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/* ###
- * 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 ghidra.dbg.sctl.protocol.types;
-
-import java.util.List;
-
-import ghidra.comm.packet.annot.CountedByField;
-import ghidra.comm.packet.annot.RepeatedField;
-import ghidra.comm.packet.fields.PacketField;
-import ghidra.dbg.sctl.protocol.common.SctlString;
-import ghidra.dbg.sctl.protocol.consts.Rkind;
-
-/**
- * The format for enumerate type definitions in SCTL
- */
-public class SctlEnumTypeDefinition extends AbstractSctlTypeDefinition {
- @PacketField
- public SctlString tag;
-
- @PacketField
- public Rkind rep;
-
- @PacketField
- public long nconst;
-
- @PacketField
- @RepeatedField
- @CountedByField("nconst")
- public List<SctlEnumConstant> consts;
-
- @Override
- public AbstractSctlTypeName getTypeName() {
- return new SctlEnumTypeName(tag);
- }
-}
diff --git a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/types/SctlEnumTypeName.java b/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/types/SctlEnumTypeName.java
deleted file mode 100644
index 7d059499ec..0000000000
--- a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/types/SctlEnumTypeName.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/* ###
- * 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 ghidra.dbg.sctl.protocol.types;
-
-import ghidra.dbg.sctl.protocol.common.SctlString;
-
-/**
- * The format for enumeration type names in SCTL
- */
-public class SctlEnumTypeName extends AbstractSctlTaggedTypeName {
- public SctlEnumTypeName() {
- }
-
- public SctlEnumTypeName(SctlString tag) {
- super(tag);
- }
-}
diff --git a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/types/SctlFunctionParameter.java b/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/types/SctlFunctionParameter.java
deleted file mode 100644
index 19ff5fb9ff..0000000000
--- a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/types/SctlFunctionParameter.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/* ###
- * 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 ghidra.dbg.sctl.protocol.types;
-
-import ghidra.comm.packet.Packet;
-import ghidra.comm.packet.fields.PacketField;
-import ghidra.dbg.sctl.protocol.common.SctlString;
-
-/**
- * The format for {@code param[]} of function type names in SCTL
- */
-public class SctlFunctionParameter extends Packet {
- @PacketField
- public SctlAttributes attrs;
-
- @PacketField
- public SctlString pname;
-
- @PacketField
- public SelSctlTypeName tname;
-}
diff --git a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/types/SctlFunctionTypeName.java b/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/types/SctlFunctionTypeName.java
deleted file mode 100644
index bee5a0ea31..0000000000
--- a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/types/SctlFunctionTypeName.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/* ###
- * 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 ghidra.dbg.sctl.protocol.types;
-
-import java.util.List;
-
-import ghidra.comm.packet.annot.CountedByField;
-import ghidra.comm.packet.annot.RepeatedField;
-import ghidra.comm.packet.fields.PacketField;
-
-/**
- * The format for function type names in SCTL
- */
-public class SctlFunctionTypeName extends AbstractSctlTypeName {
- @PacketField
- public SelSctlTypeName tname; // return type
-
- @PacketField
- public long np;
-
- @PacketField
- @RepeatedField
- @CountedByField("np")
- public List<SctlFunctionParameter> params;
-}
diff --git a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/types/SctlPointerTypeName.java b/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/types/SctlPointerTypeName.java
deleted file mode 100644
index 66e9103996..0000000000
--- a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/types/SctlPointerTypeName.java
+++ /dev/null
@@ -1,26 +0,0 @@
-/* ###
- * 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 ghidra.dbg.sctl.protocol.types;
-
-import ghidra.comm.packet.fields.PacketField;
-
-/**
- * The format for pointer type names in SCTL
- */
-public class SctlPointerTypeName extends AbstractSctlTypeName {
- @PacketField
- public SelSctlTypeName tname;
-}
diff --git a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/types/SctlStringAtom.java b/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/types/SctlStringAtom.java
deleted file mode 100644
index 649d7d8977..0000000000
--- a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/types/SctlStringAtom.java
+++ /dev/null
@@ -1,27 +0,0 @@
-/* ###
- * 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 ghidra.dbg.sctl.protocol.types;
-
-import ghidra.comm.packet.fields.PacketField;
-import ghidra.dbg.sctl.protocol.common.SctlString;
-
-/**
- * A string key or value in SCTL attributes
- */
-public class SctlStringAtom extends SctlAtom {
- @PacketField
- public SctlString str;
-}
diff --git a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/types/SctlStructTypeDefinition.java b/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/types/SctlStructTypeDefinition.java
deleted file mode 100644
index be25ff31ec..0000000000
--- a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/types/SctlStructTypeDefinition.java
+++ /dev/null
@@ -1,26 +0,0 @@
-/* ###
- * 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 ghidra.dbg.sctl.protocol.types;
-
-/**
- * The format for a struct type definition in SCTL
- */
-public class SctlStructTypeDefinition extends AbstractSctlAggregateTypeDefinition {
- @Override
- public AbstractSctlTypeName getTypeName() {
- return new SctlStructTypeName(tag);
- }
-}
diff --git a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/types/SctlStructTypeName.java b/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/types/SctlStructTypeName.java
deleted file mode 100644
index 9c8550cbce..0000000000
--- a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/types/SctlStructTypeName.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/* ###
- * 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 ghidra.dbg.sctl.protocol.types;
-
-import ghidra.dbg.sctl.protocol.common.SctlString;
-
-/**
- * The format for a struct type name in SCTL
- */
-public class SctlStructTypeName extends AbstractSctlTaggedTypeName {
- public SctlStructTypeName() {
- }
-
- public SctlStructTypeName(SctlString tag) {
- super(tag);
- }
-}
diff --git a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/types/SctlSymbolAtom.java b/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/types/SctlSymbolAtom.java
deleted file mode 100644
index 1983178157..0000000000
--- a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/types/SctlSymbolAtom.java
+++ /dev/null
@@ -1,27 +0,0 @@
-/* ###
- * 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 ghidra.dbg.sctl.protocol.types;
-
-import ghidra.comm.packet.fields.PacketField;
-import ghidra.dbg.sctl.protocol.common.SctlString;
-
-/**
- * A symbol key or value in SCTL attributes
- */
-public class SctlSymbolAtom extends SctlAtom {
- @PacketField
- public SctlString sym;
-}
diff --git a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/types/SctlTypedefTypeDefinition.java b/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/types/SctlTypedefTypeDefinition.java
deleted file mode 100644
index 87adda49e7..0000000000
--- a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/types/SctlTypedefTypeDefinition.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/* ###
- * 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 ghidra.dbg.sctl.protocol.types;
-
-import ghidra.comm.packet.fields.PacketField;
-import ghidra.dbg.sctl.protocol.common.SctlString;
-
-/**
- * The format for a {@code typedef} type definition in SCTL
- */
-public class SctlTypedefTypeDefinition extends AbstractSctlTypeDefinition {
- @PacketField
- public SctlString tid;
-
- @PacketField
- public SelSctlTypeName tname;
-
- @Override
- public AbstractSctlTypeName getTypeName() {
- return new SctlTypedefTypeName(tid);
- }
-}
diff --git a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/types/SctlTypedefTypeName.java b/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/types/SctlTypedefTypeName.java
deleted file mode 100644
index b89d6b0f9a..0000000000
--- a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/types/SctlTypedefTypeName.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/* ###
- * 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 ghidra.dbg.sctl.protocol.types;
-
-import ghidra.comm.packet.fields.PacketField;
-import ghidra.dbg.sctl.protocol.common.SctlString;
-
-/**
- * The format for a {@code typedef} type name in SCTL
- */
-public class SctlTypedefTypeName extends AbstractSctlTypeName {
- public SctlTypedefTypeName() {
- }
-
- public SctlTypedefTypeName(SctlString tid) {
- this.tid = tid;
- }
-
- @PacketField
- public SctlString tid;
-}
diff --git a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/types/SctlUIntAtom.java b/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/types/SctlUIntAtom.java
deleted file mode 100644
index 35c37ae297..0000000000
--- a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/types/SctlUIntAtom.java
+++ /dev/null
@@ -1,26 +0,0 @@
-/* ###
- * 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 ghidra.dbg.sctl.protocol.types;
-
-import ghidra.comm.packet.fields.PacketField;
-
-/**
- * A 64-bit numerical key or value in SCTL attributes
- */
-public class SctlUIntAtom extends SctlAtom {
- @PacketField
- public long uint;
-}
diff --git a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/types/SctlUndefinedTypeName.java b/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/types/SctlUndefinedTypeName.java
deleted file mode 100644
index 894bf7e9d5..0000000000
--- a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/types/SctlUndefinedTypeName.java
+++ /dev/null
@@ -1,26 +0,0 @@
-/* ###
- * 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 ghidra.dbg.sctl.protocol.types;
-
-import ghidra.comm.packet.fields.PacketField;
-
-/**
- * The format for an undefined type name in SCTL
- */
-public class SctlUndefinedTypeName extends AbstractSctlTypeName {
- @PacketField
- public SelSctlTypeName tname;
-}
diff --git a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/types/SctlUnionTypeDefinition.java b/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/types/SctlUnionTypeDefinition.java
deleted file mode 100644
index 7dedba265e..0000000000
--- a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/types/SctlUnionTypeDefinition.java
+++ /dev/null
@@ -1,26 +0,0 @@
-/* ###
- * 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 ghidra.dbg.sctl.protocol.types;
-
-/**
- * The format for a union type definition in SCTL
- */
-public class SctlUnionTypeDefinition extends AbstractSctlAggregateTypeDefinition {
- @Override
- public AbstractSctlTypeName getTypeName() {
- return new SctlUnionTypeName(tag);
- }
-}
diff --git a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/types/SctlUnionTypeName.java b/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/types/SctlUnionTypeName.java
deleted file mode 100644
index f5223f0d7c..0000000000
--- a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/types/SctlUnionTypeName.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/* ###
- * 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 ghidra.dbg.sctl.protocol.types;
-
-import ghidra.dbg.sctl.protocol.common.SctlString;
-
-/**
- * The format for a union type name in SCTL
- */
-public class SctlUnionTypeName extends AbstractSctlTaggedTypeName {
- public SctlUnionTypeName() {
- }
-
- public SctlUnionTypeName(SctlString tag) {
- super(tag);
- }
-}
diff --git a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/types/SelSctlTypeDefinition.java b/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/types/SelSctlTypeDefinition.java
deleted file mode 100644
index 5519977117..0000000000
--- a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/types/SelSctlTypeDefinition.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/* ###
- * 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 ghidra.dbg.sctl.protocol.types;
-
-import java.util.Map;
-
-import ghidra.comm.packet.Packet;
-import ghidra.comm.packet.annot.TypedByField;
-import ghidra.comm.packet.fields.PacketField;
-import ghidra.dbg.sctl.protocol.consts.Tkind;
-
-/**
- * The format for {@code tdef[]} in SCTL
- *
- * This parses {@code Tkind} and selects the appropriate kind of type definition
- */
-public class SelSctlTypeDefinition extends Packet {
- public static final Map<Tkind, Class<? extends AbstractSctlTypeDefinition>> KIND_MAP =
- typeMap(Tkind.class, AbstractSctlTypeDefinition.class) //
- .put(Tkind.Tbase, SctlBaseTypeDefinition.class) // 1. base type
- .put(Tkind.Tstruct, SctlStructTypeDefinition.class) // 2. aggregate types
- .put(Tkind.Tunion, SctlUnionTypeDefinition.class) // 2. ...
- .put(Tkind.Tenum, SctlEnumTypeDefinition.class) // 3. enum type
- .put(Tkind.Ttypedef, SctlTypedefTypeDefinition.class) // 4. typedef type
- .build();
-
- @PacketField
- public Tkind kind;
-
- @PacketField
- @TypedByField(by = "kind", map = "KIND_MAP")
- public AbstractSctlTypeDefinition sel;
-
- public AbstractSctlTypeName getTypeName() {
- return sel.getTypeName();
- }
-}
diff --git a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/types/SelSctlTypeName.java b/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/types/SelSctlTypeName.java
deleted file mode 100644
index 8422dd5427..0000000000
--- a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/types/SelSctlTypeName.java
+++ /dev/null
@@ -1,59 +0,0 @@
-/* ###
- * 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 ghidra.dbg.sctl.protocol.types;
-
-import java.util.Map;
-
-import ghidra.comm.packet.Packet;
-import ghidra.comm.packet.annot.TypedByField;
-import ghidra.comm.packet.fields.PacketField;
-import ghidra.dbg.sctl.protocol.consts.Tkind;
-
-/**
- * The format for {@code tname} in SCTL
- *
- * This parses {@code Tkind} and selects the appropriate kind of type name
- */
-public class SelSctlTypeName extends Packet {
- public SelSctlTypeName() {
- }
-
- public SelSctlTypeName(AbstractSctlTypeName sel) {
- this.sel = sel;
- }
-
- public static final Map<Tkind, Class<? extends AbstractSctlTypeName>> KIND_MAP =
- typeMap(Tkind.class, AbstractSctlTypeName.class) //
- .put(Tkind.Tbase, SctlBaseTypeName.class) // 1. base type
- .put(Tkind.Tstruct, SctlStructTypeName.class) // 2. tagged type
- .put(Tkind.Tunion, SctlUnionTypeName.class) // 2. ...
- .put(Tkind.Tenum, SctlEnumTypeName.class) // 2. ...
- .put(Tkind.Ttypedef, SctlTypedefTypeName.class) // 3. typedef type
- .put(Tkind.Tptr, SctlPointerTypeName.class) // 4. pointer type
- .put(Tkind.Tarr, SctlArrayTypeName.class) // 5. array type
- .put(Tkind.Tfun, SctlFunctionTypeName.class) // 6. function type
- .put(Tkind.Tbitfield, SctlBitfieldTypeName.class) // 7. bitfield type
- .put(Tkind.Tconst, SctlEnumConstTypeName.class) // 8. enumeration constant type
- .put(Tkind.Tundef, SctlUndefinedTypeName.class) // 9. undefined
- .build();
-
- @PacketField
- public Tkind kind;
-
- @PacketField
- @TypedByField(by = "kind", map = "KIND_MAP")
- public AbstractSctlTypeName sel;
-}
diff --git a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/v2012base/Sctl2012AttachReply.java b/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/v2012base/Sctl2012AttachReply.java
deleted file mode 100644
index cce85f3975..0000000000
--- a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/v2012base/Sctl2012AttachReply.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/* ###
- * 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 ghidra.dbg.sctl.protocol.v2012base;
-
-import ghidra.dbg.sctl.protocol.common.reply.AbstractSctlAttachReply;
-
-public class Sctl2012AttachReply extends AbstractSctlAttachReply {
- @Override
- public boolean supportsPlatform() {
- return false;
- }
-
- @Override
- public void setPlatform(String platform) {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public String getPlatform() {
- throw new UnsupportedOperationException();
- }
-}
diff --git a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/v2012base/Sctl2012ForkNotification.java b/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/v2012base/Sctl2012ForkNotification.java
deleted file mode 100644
index 4923b24b26..0000000000
--- a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/v2012base/Sctl2012ForkNotification.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/* ###
- * 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 ghidra.dbg.sctl.protocol.v2012base;
-
-import ghidra.dbg.sctl.protocol.common.AbstractSctlContext;
-import ghidra.dbg.sctl.protocol.common.notify.AbstractSctlForkNotification;
-
-/**
- * Format for the {@code Efork} SCTL event
- */
-public class Sctl2012ForkNotification extends AbstractSctlForkNotification {
- public Sctl2012ForkNotification() {
- super();
- }
-
- public Sctl2012ForkNotification(long spwnid, AbstractSctlContext ctx,
- AbstractSctlContext spwnctx) {
- super(spwnid, ctx, spwnctx);
- }
-
- @Override
- public boolean supportsProcessID() {
- return false;
- }
-
- @Override
- public void setProcessID(long pid) {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public long getProcessID() {
- throw new UnsupportedOperationException();
- }
-}
diff --git a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/v2012base/Sctl2012LaunchReply.java b/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/v2012base/Sctl2012LaunchReply.java
deleted file mode 100644
index 0602fd3b96..0000000000
--- a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/v2012base/Sctl2012LaunchReply.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/* ###
- * 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 ghidra.dbg.sctl.protocol.v2012base;
-
-import ghidra.dbg.sctl.protocol.common.reply.AbstractSctlLaunchReply;
-
-/**
- * Format for the {@code Rlaunch} SCTL message
- */
-public class Sctl2012LaunchReply extends AbstractSctlLaunchReply {
- @Override
- public boolean supportsProcessID() {
- return false;
- }
-
- @Override
- public void setProcessID(long pid) {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public long getProcessID() {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public boolean supportsPlatform() {
- return false;
- }
-
- @Override
- public void setPlatform(String platform) {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public String getPlatform() {
- throw new UnsupportedOperationException();
- }
-}
diff --git a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/v2012base/Sctl2012SnapNotification.java b/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/v2012base/Sctl2012SnapNotification.java
deleted file mode 100644
index ccb8a2ee00..0000000000
--- a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/v2012base/Sctl2012SnapNotification.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/* ###
- * 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 ghidra.dbg.sctl.protocol.v2012base;
-
-import ghidra.dbg.sctl.protocol.common.notify.AbstractSctlSnapNotification;
-
-/**
- * Format for the {@code Esnap} SCTL event
- */
-public class Sctl2012SnapNotification extends AbstractSctlSnapNotification {
- @Override
- public boolean supportsProcessID() {
- return false;
- }
-
- @Override
- public void setProcessID(long pid) {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public long getProcessID() {
- throw new UnsupportedOperationException();
- }
-}
diff --git a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/v2012base/Sctl2012SnapshotReply.java b/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/v2012base/Sctl2012SnapshotReply.java
deleted file mode 100644
index 0d4f18d11a..0000000000
--- a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/v2012base/Sctl2012SnapshotReply.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/* ###
- * 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 ghidra.dbg.sctl.protocol.v2012base;
-
-import ghidra.dbg.sctl.protocol.common.reply.AbstractSctlSnapshotReply;
-
-public class Sctl2012SnapshotReply extends AbstractSctlSnapshotReply {
- @Override
- public boolean supportsProcessID() {
- return false;
- }
-
- @Override
- public void setProcessID(long pid) {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public long getProcessID() {
- throw new UnsupportedOperationException();
- }
-}
diff --git a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/v2012base/SelSctl2012Packet.java b/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/v2012base/SelSctl2012Packet.java
deleted file mode 100644
index 3394fc98e6..0000000000
--- a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/v2012base/SelSctl2012Packet.java
+++ /dev/null
@@ -1,98 +0,0 @@
-/* ###
- * 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 ghidra.dbg.sctl.protocol.v2012base;
-
-import java.util.Map;
-
-import ghidra.dbg.sctl.dialect.SelSctlNullDialectPacket;
-import ghidra.dbg.sctl.protocol.AbstractSelSctlPacket;
-import ghidra.dbg.sctl.protocol.SctlPacket;
-import ghidra.dbg.sctl.protocol.common.notify.SctlEventNotify;
-import ghidra.dbg.sctl.protocol.common.reply.*;
-import ghidra.dbg.sctl.protocol.common.request.*;
-import ghidra.dbg.sctl.protocol.consts.Mkind;
-
-public class SelSctl2012Packet extends AbstractSelSctlPacket {
- public SelSctl2012Packet() {
- super();
- }
-
- public SelSctl2012Packet(int tag, SctlPacket sel) {
- super(tag, sel);
- }
-
- public static final Map<Mkind, Class<? extends SctlPacket>> METHOD_MAP =
- typeMap(Mkind.class, SctlPacket.class) //
- .putAll(SelSctlNullDialectPacket.METHOD_MAP) //
- .put(Mkind.Aevent, SctlEventNotify.class) //
- .put(Mkind.Tps, SctlProcessListRequest.class) //
- .put(Mkind.Rps, SctlProcessListReply.class) //
- .put(Mkind.Tlaunch, SctlLaunchRequest.class) //
- .put(Mkind.Rlaunch, AbstractSctlLaunchReply.class) //
- .put(Mkind.Tattach, SctlAttachRequest.class) //
- .put(Mkind.Rattach, AbstractSctlAttachReply.class) //
- .put(Mkind.Tstat, SctlStatusRequest.class) //
- .put(Mkind.Rstat, SctlStatusReply.class) //
- .put(Mkind.Tcont, SctlContinueRequest.class) //
- .put(Mkind.Rcont, SctlContinueReply.class) //
- .put(Mkind.Tstop, SctlStopRequest.class) //
- .put(Mkind.Rstop, SctlStopReply.class) //
- .put(Mkind.Tstep, SctlStepRequest.class) //
- .put(Mkind.Rstep, SctlStepReply.class) //
- .put(Mkind.Tsnap, SctlSnapshotRequest.class) //
- .put(Mkind.Rsnap, AbstractSctlSnapshotReply.class) //
- .put(Mkind.Tkill, SctlKillRequest.class) //
- .put(Mkind.Rkill, SctlKillReply.class) //
- .put(Mkind.Tdetach, SctlDetachRequest.class) //
- .put(Mkind.Rdetach, SctlDetachReply.class) //
- .put(Mkind.Ttrace, SctlTraceRequest.class) //
- .put(Mkind.Rtrace, SctlTraceReply.class) //
- .put(Mkind.Tsettrap, SctlSetTrapRequest.class) //
- .put(Mkind.Rsettrap, SctlSetTrapReply.class) //
- .put(Mkind.Tclrtrap, SctlClearTrapRequest.class) //
- .put(Mkind.Rclrtrap, SctlClearTrapReply.class) //
- .put(Mkind.Tgetctx, SctlGetContextRequest.class) //
- .put(Mkind.Rgetctx, SctlGetContextReply.class) //
- .put(Mkind.Tsetctx, SctlSetContextRequest.class) //
- .put(Mkind.Rsetctx, SctlSetContextReply.class) //
- .put(Mkind.Tread, SctlReadRequest.class) //
- .put(Mkind.Rread, SctlReadReply.class) //
- .put(Mkind.Twrite, SctlWriteRequest.class) //
- .put(Mkind.Rwrite, SctlWriteReply.class) //
- .put(Mkind.Tlooksym, SctlLookupSymbolRequest.class) //
- .put(Mkind.Rlooksym, SctlLookupSymbolReply.class) //
- .put(Mkind.Tenumsym, SctlEnumerateSymbolsRequest.class) //
- .put(Mkind.Renumsym, SctlEnumerateSymbolsReply.class) //
- .put(Mkind.Tlooktype, SctlLookupTypeRequest.class) //
- .put(Mkind.Rlooktype, SctlLookupTypeReply.class) //
- .put(Mkind.Tenumtype, SctlEnumerateTypesRequest.class) //
- .put(Mkind.Renumtype, SctlEnumerateTypesReply.class) //
- .put(Mkind.Tlookaddr, SctlLookupAddressRequest.class) //
- .put(Mkind.Rlookaddr, SctlLookupAddressReply.class) //
- .put(Mkind.Tenumloc, SctlEnumerateLocalsRequest.class) //
- .put(Mkind.Renumloc, SctlEnumerateLocalsReply.class) //
- .put(Mkind.Tenumseg, SctlEnumerateSegmentsRequest.class) //
- .put(Mkind.Renumseg, SctlEnumerateSegmentsReply.class) //
- .put(Mkind.Tnames, SctlNamesRequest.class) //
- .put(Mkind.Rnames, SctlNamesReply.class) //
- .put(Mkind.Tunwind1, SctlUnwindOneFrameRequest.class) //
- .put(Mkind.Runwind1, SctlUnwindOneFrameReply.class) //
- .put(Mkind.Tlooksrc, SctlLookupSourceRequest.class) //
- .put(Mkind.Rlooksrc, SctlLookupSourceReply.class) //
- .put(Mkind.Tlookpc, SctlLookupProgramCounterRequest.class) //
- .put(Mkind.Rlookpc, SctlLookupProgramCounterReply.class) //
- .build();
-}
diff --git a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/v2012base/x86/SctlX86Context.java b/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/v2012base/x86/SctlX86Context.java
deleted file mode 100644
index 585020d169..0000000000
--- a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/v2012base/x86/SctlX86Context.java
+++ /dev/null
@@ -1,87 +0,0 @@
-/* ###
- * 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 ghidra.dbg.sctl.protocol.v2012base.x86;
-
-import java.util.List;
-
-import ghidra.comm.packet.fields.PacketField;
-import ghidra.dbg.sctl.protocol.common.AbstractByLongFieldsSctlContext;
-import ghidra.dbg.sctl.protocol.common.SctlRegisterDefinition;
-
-/**
- * The context packet for SCTL's x86 dialect
- */
-public class SctlX86Context extends AbstractByLongFieldsSctlContext {
- @PacketField
- public long r15;
- @PacketField
- public long r14;
- @PacketField
- public long r13;
- @PacketField
- public long r12;
- @PacketField
- public long rbp;
- @PacketField
- public long rbx;
- @PacketField
- public long r11;
- @PacketField
- public long r10;
- @PacketField
- public long r9;
- @PacketField
- public long r8;
- @PacketField
- public long rax;
- @PacketField
- public long rcx;
- @PacketField
- public long rdx;
- @PacketField
- public long rsi;
- @PacketField
- public long rdi;
- @PacketField
- public long orig_rax;
- @PacketField
- public long rip;
- @PacketField
- public long cs;
- @PacketField
- public long eflags;
- @PacketField
- public long rsp;
- @PacketField
- public long ss;
- @PacketField
- public long fs_base;
- @PacketField
- public long gs_base;
- @PacketField
- public long ds;
- @PacketField
- public long es;
- @PacketField
- public long fs;
- @PacketField
- public long gs;
-
- @Override
- public void setSelectedRegisters(List<SctlRegisterDefinition> regdefs) {
- // Has no effect
- }
-}
diff --git a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/v2012base/x86/linux/Sctl2012LinuxBinary.java b/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/v2012base/x86/linux/Sctl2012LinuxBinary.java
deleted file mode 100644
index 8fc8b708c2..0000000000
--- a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/v2012base/x86/linux/Sctl2012LinuxBinary.java
+++ /dev/null
@@ -1,98 +0,0 @@
-/* ###
- * 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 ghidra.dbg.sctl.protocol.v2012base.x86.linux;
-
-import java.util.List;
-
-import ghidra.comm.packet.fields.PacketField;
-import ghidra.dbg.sctl.protocol.common.*;
-
-/**
- * Format of SCTL's {@code bin} for Linux dialects
- */
-public class Sctl2012LinuxBinary extends AbstractSctlBinary {
- @Override
- public void setNamespaceID(long nsid) {
- this.nsid = nsid;
- }
-
- @Override
- public long getNamespaceID() {
- return nsid;
- }
-
- @Override
- public void setPath(String path) {
- this.path = new SctlString(path);
- }
-
- @Override
- public String getPath() {
- return path.str;
- }
-
- @Override
- public void setExecutable(boolean isexe) {
- this.isexe = isexe;
- }
-
- @Override
- public boolean isExecutable() {
- return isexe;
- }
-
- @Override
- public boolean supportsBase() {
- return true;
- }
-
- @Override
- public void setBase(long base) {
- this.base = base;
- }
-
- @Override
- public long getBase() {
- return base;
- }
-
- @Override
- public boolean supportsSections() {
- return false;
- }
-
- @Override
- public AbstractSctlSection addSection() {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public List<? extends AbstractSctlSection> getSections() {
- throw new UnsupportedOperationException();
- }
-
- @PacketField
- public long nsid;
-
- @PacketField
- public long base;
-
- @PacketField
- public boolean isexe;
-
- @PacketField
- public SctlString path;
-}
diff --git a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/v2012base/x86/linux/Sctl2012LinuxProcessEntry.java b/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/v2012base/x86/linux/Sctl2012LinuxProcessEntry.java
deleted file mode 100644
index cce00a0791..0000000000
--- a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/v2012base/x86/linux/Sctl2012LinuxProcessEntry.java
+++ /dev/null
@@ -1,76 +0,0 @@
-/* ###
- * 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 ghidra.dbg.sctl.protocol.v2012base.x86.linux;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import ghidra.comm.packet.annot.CountedByField;
-import ghidra.comm.packet.annot.RepeatedField;
-import ghidra.comm.packet.fields.PacketField;
-import ghidra.dbg.sctl.protocol.common.AbstractSctlProcessEntry;
-import ghidra.dbg.sctl.protocol.common.SctlString;
-
-/**
- * The format for each process of {@code bytes[]} of SCTL's {@code Rps} reply for Linux dialects
- */
-public class Sctl2012LinuxProcessEntry extends AbstractSctlProcessEntry {
- @PacketField
- public long pid;
-
- @PacketField
- public SctlString cmd;
-
- @PacketField
- public long nt;
-
- @PacketField
- @RepeatedField
- @CountedByField("nt")
- public List<Sctl2012LinuxThreadEntry> threads = new ArrayList<>();
-
- @Override
- public long getProcessID() {
- return pid;
- }
-
- @Override
- public void setProcessID(long pid) {
- this.pid = pid;
- }
-
- @Override
- public String getCommand() {
- return cmd.str;
- }
-
- @Override
- public void setCommand(String cmd) {
- this.cmd = new SctlString(cmd);
- }
-
- @Override
- public List<Sctl2012LinuxThreadEntry> getThreads() {
- return threads;
- }
-
- @Override
- public Sctl2012LinuxThreadEntry addThread() {
- Sctl2012LinuxThreadEntry t = new Sctl2012LinuxThreadEntry();
- threads.add(t);
- return t;
- }
-}
diff --git a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/v2012base/x86/linux/Sctl2012LinuxProcessList.java b/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/v2012base/x86/linux/Sctl2012LinuxProcessList.java
deleted file mode 100644
index b2038028df..0000000000
--- a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/v2012base/x86/linux/Sctl2012LinuxProcessList.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/* ###
- * 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 ghidra.dbg.sctl.protocol.v2012base.x86.linux;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import ghidra.comm.packet.annot.CountedByField;
-import ghidra.comm.packet.annot.RepeatedField;
-import ghidra.comm.packet.fields.PacketField;
-import ghidra.dbg.sctl.protocol.common.AbstractSctlProcessEntry;
-import ghidra.dbg.sctl.protocol.common.AbstractSctlProcessList;
-
-/**
- * The format for {@code bytes[]} of SCTL's {@code Rps} reply for Linux dialects
- */
-public class Sctl2012LinuxProcessList extends AbstractSctlProcessList {
- @PacketField
- public long ntarg;
-
- @PacketField
- @RepeatedField
- @CountedByField("ntarg")
- public List<Sctl2012LinuxProcessEntry> processes = new ArrayList<>();
-
- @Override
- public List<? extends AbstractSctlProcessEntry> getProcesses() {
- return processes;
- }
-
- @Override
- public Sctl2012LinuxProcessEntry addProcess() {
- Sctl2012LinuxProcessEntry proc = new Sctl2012LinuxProcessEntry();
- processes.add(proc);
- return proc;
- }
-}
diff --git a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/v2012base/x86/linux/Sctl2012LinuxRegion.java b/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/v2012base/x86/linux/Sctl2012LinuxRegion.java
deleted file mode 100644
index b25df2dd68..0000000000
--- a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/v2012base/x86/linux/Sctl2012LinuxRegion.java
+++ /dev/null
@@ -1,81 +0,0 @@
-/* ###
- * 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 ghidra.dbg.sctl.protocol.v2012base.x86.linux;
-
-import ghidra.comm.packet.annot.BitmaskEncoded;
-import ghidra.comm.packet.fields.PacketField;
-import ghidra.comm.util.BitmaskSet;
-import ghidra.dbg.sctl.client.SctlMemoryProtection;
-import ghidra.dbg.sctl.protocol.common.AbstractSctlRegion;
-import ghidra.dbg.sctl.protocol.common.SctlString;
-
-/**
- * The format of {@code region} in SCTL's Linux dialects
- */
-public class Sctl2012LinuxRegion extends AbstractSctlRegion {
- @Override
- public void setName(String name) {
- this.file = new SctlString(name);
- }
-
- @Override
- public String getName() {
- return file.str;
- }
-
- @Override
- public void setAddress(long address) {
- this.addr = address;
- }
-
- @Override
- public long getAddress() {
- return addr;
- }
-
- @Override
- public void setLength(long length) {
- this.len = length;
- }
-
- @Override
- public long getLength() {
- return len;
- }
-
- @Override
- public void setProtections(BitmaskSet<SctlMemoryProtection> flags) {
- this.flags = flags;
- }
-
- @Override
- public BitmaskSet<SctlMemoryProtection> getProtections() {
- return flags;
- }
-
- @PacketField
- public SctlString file;
-
- @PacketField
- public long addr;
-
- @PacketField
- public long len;
-
- @PacketField
- @BitmaskEncoded(universe = SctlMemoryProtection.class)
- public BitmaskSet<SctlMemoryProtection> flags;
-}
diff --git a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/v2012base/x86/linux/Sctl2012LinuxStatus.java b/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/v2012base/x86/linux/Sctl2012LinuxStatus.java
deleted file mode 100644
index 3ba1b59825..0000000000
--- a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/v2012base/x86/linux/Sctl2012LinuxStatus.java
+++ /dev/null
@@ -1,87 +0,0 @@
-/* ###
- * 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 ghidra.dbg.sctl.protocol.v2012base.x86.linux;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import ghidra.comm.packet.annot.CountedByField;
-import ghidra.comm.packet.annot.RepeatedField;
-import ghidra.comm.packet.fields.PacketField;
-import ghidra.dbg.sctl.protocol.common.AbstractSctlStatus;
-
-/**
- * The format of {@code stat[]} in SCTL's Linux dialects
- */
-public class Sctl2012LinuxStatus extends AbstractSctlStatus {
- @Override
- public boolean supportsProcessID() {
- return true;
- }
-
- @Override
- public void setProcessID(long pid) {
- this.pid = pid;
- }
-
- @Override
- public long getProcessID() {
- return pid;
- }
-
- @Override
- public Sctl2012LinuxRegion addRegion() {
- Sctl2012LinuxRegion r = new Sctl2012LinuxRegion();
- regions.add(r);
- return r;
- }
-
- @Override
- public List<Sctl2012LinuxRegion> getRegions() {
- return regions;
- }
-
- @Override
- public Sctl2012LinuxBinary addBinary() {
- Sctl2012LinuxBinary b = new Sctl2012LinuxBinary();
- bins.add(b);
- return b;
- }
-
- @Override
- public List<Sctl2012LinuxBinary> getBinaries() {
- return bins;
- }
-
- @PacketField
- public long pid;
-
- @PacketField
- public long nr;
-
- @PacketField
- @RepeatedField
- @CountedByField("nr")
- public List<Sctl2012LinuxRegion> regions = new ArrayList<>();
-
- @PacketField
- public long nb;
-
- @PacketField
- @RepeatedField
- @CountedByField("nb")
- public List<Sctl2012LinuxBinary> bins = new ArrayList<>();
-}
diff --git a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/v2012base/x86/linux/Sctl2012LinuxThreadEntry.java b/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/v2012base/x86/linux/Sctl2012LinuxThreadEntry.java
deleted file mode 100644
index 00c5991ca5..0000000000
--- a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/v2012base/x86/linux/Sctl2012LinuxThreadEntry.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/* ###
- * 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 ghidra.dbg.sctl.protocol.v2012base.x86.linux;
-
-import ghidra.comm.packet.fields.PacketField;
-import ghidra.dbg.sctl.protocol.common.AbstractSctlThreadEntry;
-
-/**
- * The format for each thread in SCTL's {@code Rps} for Linux dialects
- */
-public class Sctl2012LinuxThreadEntry extends AbstractSctlThreadEntry {
- @PacketField
- public long tid;
-
- @Override
- public long getThreadID() {
- return tid;
- }
-
- @Override
- public void setThreadID(long tid) {
- this.tid = tid;
- }
-}
diff --git a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/v2012base/x86/linux/Sctl2012LinuxTrapSpec.java b/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/v2012base/x86/linux/Sctl2012LinuxTrapSpec.java
deleted file mode 100644
index 5a6c83fa63..0000000000
--- a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/v2012base/x86/linux/Sctl2012LinuxTrapSpec.java
+++ /dev/null
@@ -1,141 +0,0 @@
-/* ###
- * 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 ghidra.dbg.sctl.protocol.v2012base.x86.linux;
-
-import ghidra.comm.packet.annot.BitmaskEncoded;
-import ghidra.comm.packet.fields.PacketField;
-import ghidra.comm.util.BitmaskSet;
-import ghidra.comm.util.BitmaskUniverse;
-import ghidra.dbg.sctl.protocol.common.AbstractSctlTrapSpec;
-
-/**
- * The format of {@code bytes[]} in SCTL's {@code Tsettrap} for Linux dialects
- */
-public class Sctl2012LinuxTrapSpec extends AbstractSctlTrapSpec {
- public enum Flag implements BitmaskUniverse {
- ACTION_STOP(0), ACTION_SNAP(1 << 0);
-
- private final long mask;
-
- Flag(long mask) {
- this.mask = mask;
- }
-
- @Override
- public long getMask() {
- return mask;
- }
- }
-
- public Sctl2012LinuxTrapSpec() {
- this.mode = BitmaskSet.of();
- }
-
- public Sctl2012LinuxTrapSpec(BitmaskSet<Flag> mode, long addr) {
- this.mode = mode;
- this.addr = addr;
- }
-
- @Override
- public void setAddress(long address) {
- this.addr = address;
- }
-
- @Override
- public long getAddress() {
- return addr;
- }
-
- @Override
- public void setLength(long length) {
- if (length == 1) {
- // Yeah
- return;
- }
- throw new UnsupportedOperationException();
- }
-
- @Override
- public long getLength() {
- return 1;
- }
-
- @Override
- public void setActionStop() {
- mode.remove(Flag.ACTION_SNAP);
- }
-
- @Override
- public boolean isActionStop() {
- return !mode.contains(Flag.ACTION_SNAP);
- }
-
- @Override
- public void setActionSnap() {
- mode.add(Flag.ACTION_SNAP);
- }
-
- @Override
- public boolean isActionSnap() {
- return mode.contains(Flag.ACTION_SNAP);
- }
-
- @Override
- public void setSoftwareExecute() {
- // Yeah
- }
-
- @Override
- public boolean isSoftwareExecute() {
- return true;
- }
-
- @Override
- public void setHardware(boolean read, boolean write, boolean execute) {
- if (!read && !write && !execute) {
- // Yeah
- return;
- }
- throw new UnsupportedOperationException();
- }
-
- @Override
- public boolean isHardware() {
- return false;
- }
-
- @Override
- public boolean isHardwareRead() {
- return false;
- }
-
- @Override
- public boolean isHardwareWrite() {
- return false;
- }
-
- @Override
- public boolean isHardwareExecute() {
- return false;
- }
-
- @PacketField
- @BitmaskEncoded(universe = Flag.class)
- public BitmaskSet<Flag> mode;
-
- @PacketField
- public long addr;
-}
diff --git a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/v2012base/x86/linux/Sctl2012LinuxX86Dialect.java b/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/v2012base/x86/linux/Sctl2012LinuxX86Dialect.java
deleted file mode 100644
index f36e687583..0000000000
--- a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/v2012base/x86/linux/Sctl2012LinuxX86Dialect.java
+++ /dev/null
@@ -1,93 +0,0 @@
-/* ###
- * 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 ghidra.dbg.sctl.protocol.v2012base.x86.linux;
-
-import java.util.Set;
-
-import ghidra.comm.packet.AbstractPacketFactory;
-import ghidra.comm.packet.PacketFactory;
-import ghidra.dbg.sctl.dialect.SctlDialect;
-import ghidra.dbg.sctl.protocol.AbstractSelSctlPacket;
-import ghidra.dbg.sctl.protocol.common.*;
-import ghidra.dbg.sctl.protocol.common.notify.AbstractSctlForkNotification;
-import ghidra.dbg.sctl.protocol.common.notify.AbstractSctlSnapNotification;
-import ghidra.dbg.sctl.protocol.common.reply.*;
-import ghidra.dbg.sctl.protocol.consts.Evkind;
-import ghidra.dbg.sctl.protocol.v2012base.*;
-import ghidra.dbg.sctl.protocol.v2012base.x86.SctlX86Context;
-import ghidra.dbg.target.TargetExecutionStateful.TargetExecutionState;
-
-/**
- * The "x86-linux-2012" SCTL dialect
- */
-public enum Sctl2012LinuxX86Dialect implements SctlDialect {
- INSTANCE;
-
- public static class Sctl2012LinuxX86PacketFactory extends AbstractPacketFactory {
- {
- useFor(AbstractSelSctlPacket.class, SelSctl2012Packet.class);
-
- useFor(AbstractSctlAttachReply.class, Sctl2012AttachReply.class);
- useFor(AbstractSctlLaunchReply.class, Sctl2012LaunchReply.class);
- useFor(AbstractSctlSnapshotReply.class, Sctl2012SnapshotReply.class);
-
- useFor(AbstractSctlForkNotification.class, Sctl2012ForkNotification.class);
- useFor(AbstractSctlSnapNotification.class, Sctl2012SnapNotification.class);
-
- useFor(AbstractSctlContext.class, SctlX86Context.class);
- useFor(AbstractSctlProcessList.class, Sctl2012LinuxProcessList.class);
- useFor(AbstractSctlStatus.class, Sctl2012LinuxStatus.class);
- useFor(AbstractSctlTrapSpec.class, Sctl2012LinuxTrapSpec.class);
- }
- }
-
- public static final String SYS_VERSION = "x86-linux-2012";
- public static final String PLATFORM = "linux-x86_64";
- private static final PacketFactory FACTORY = new Sctl2012LinuxX86PacketFactory();
-
- @Override
- public String getSysVersion() {
- return SYS_VERSION;
- }
-
- @Override
- public PacketFactory getPacketFactory() {
- return FACTORY;
- }
-
- @Override
- public boolean isBusSupported() {
- return false;
- }
-
- @Override
- public boolean isRegisterSelectionSupported() {
- return false;
- }
-
- @Override
- public TargetExecutionState stateAfterEvent(Set<Evkind> events) {
- if (events.contains(Evkind.Eexit)) {
- return TargetExecutionState.TERMINATED;
- }
- return TargetExecutionState.STOPPED;
- }
-
- @Override
- public String getSolePlatform() {
- return PLATFORM;
- }
-}
diff --git a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/v2012base/x86/win/Sctl2012WindowsX86Context.java b/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/v2012base/x86/win/Sctl2012WindowsX86Context.java
deleted file mode 100644
index fcdf8d90cd..0000000000
--- a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/v2012base/x86/win/Sctl2012WindowsX86Context.java
+++ /dev/null
@@ -1,27 +0,0 @@
-/* ###
- * 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 ghidra.dbg.sctl.protocol.v2012base.x86.win;
-
-import ghidra.comm.packet.fields.PacketField;
-import ghidra.dbg.sctl.protocol.v2012base.x86.SctlX86Context;
-
-/**
- * The context packet for SCTL's x86-win dialect
- */
-public class Sctl2012WindowsX86Context extends SctlX86Context {
- @PacketField(after = "gs")
- public long sig;
-}
diff --git a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/v2012base/x86/win/Sctl2012WindowsX86Dialect.java b/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/v2012base/x86/win/Sctl2012WindowsX86Dialect.java
deleted file mode 100644
index d3f7ebf0a4..0000000000
--- a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/v2012base/x86/win/Sctl2012WindowsX86Dialect.java
+++ /dev/null
@@ -1,84 +0,0 @@
-/* ###
- * 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 ghidra.dbg.sctl.protocol.v2012base.x86.win;
-
-import java.util.Set;
-
-import ghidra.comm.packet.AbstractPacketFactory;
-import ghidra.comm.packet.PacketFactory;
-import ghidra.dbg.sctl.dialect.SctlDialect;
-import ghidra.dbg.sctl.protocol.common.AbstractSctlContext;
-import ghidra.dbg.sctl.protocol.consts.Evkind;
-import ghidra.dbg.target.TargetExecutionStateful.TargetExecutionState;
-
-/**
- * The "x86-win-2012" SCTL dialect
- *
- * Note that support for Windows was nascent when the specification was implemented. In many cases,
- * the packet formats are the same as those from Linux. In other cases, the specs say things are
- * undefined, but the reference stub behaves as it does on Linux, anyway. Reasonable guesses are
- * implemented here, but this client has not been tested with the official SCTL process controller
- * for Windows.
- */
-public enum Sctl2012WindowsX86Dialect implements SctlDialect {
- INSTANCE;
-
- public static class Sctl2012WindowsX86PacketFactory extends AbstractPacketFactory {
- {
- useFor(AbstractSctlContext.class, Sctl2012WindowsX86Context.class);
- }
- }
-
- public static final String SYS_VERSION = "x86-win-2012";
- public static final String PLATFORM = "win-x64";
- private static final PacketFactory FACTORY = new Sctl2012WindowsX86PacketFactory();
-
- @Override
- public String getSysVersion() {
- return SYS_VERSION;
- }
-
- @Override
- public PacketFactory getPacketFactory() {
- return FACTORY;
- }
-
- @Override
- public boolean isBusSupported() {
- return false;
- }
-
- @Override
- public boolean isRegisterSelectionSupported() {
- return false;
- }
-
- @Override
- public TargetExecutionState stateAfterEvent(Set<Evkind> events) {
- if (events.contains(Evkind.Efork)) {
- return TargetExecutionState.RUNNING;
- }
- if (events.contains(Evkind.Eclone)) {
- return TargetExecutionState.RUNNING;
- }
- return TargetExecutionState.STOPPED;
- }
-
- @Override
- public String getSolePlatform() {
- return PLATFORM;
- }
-}
diff --git a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/v2012ext/SctlExecuteReply.java b/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/v2012ext/SctlExecuteReply.java
deleted file mode 100644
index 9e7493651a..0000000000
--- a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/v2012ext/SctlExecuteReply.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/* ###
- * 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 ghidra.dbg.sctl.protocol.v2012ext;
-
-import ghidra.comm.packet.fields.PacketField;
-import ghidra.dbg.sctl.client.SctlExtension;
-import ghidra.dbg.sctl.protocol.AbstractSctlReply;
-import ghidra.dbg.sctl.protocol.common.SctlString;
-
-/**
- * Format for the "{@code Rexec}" SCTL message
- *
- * There is no {@code Texec} or {@code Rexec} in the official SCTL protocol. It is an extension for
- * Ghidra to issue CLI commands to a connected interactive debugger.
- */
-@SctlExtension("Response to CLI command in remote debugger")
-public class SctlExecuteReply extends AbstractSctlReply {
- public SctlExecuteReply() {
- }
-
- public SctlExecuteReply(String out) {
- this.out = new SctlString(out);
- }
-
- @PacketField
- public SctlString out;
-}
diff --git a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/v2012ext/SctlExecuteRequest.java b/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/v2012ext/SctlExecuteRequest.java
deleted file mode 100644
index d00ad063b0..0000000000
--- a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/v2012ext/SctlExecuteRequest.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/* ###
- * 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 ghidra.dbg.sctl.protocol.v2012ext;
-
-import ghidra.comm.packet.fields.PacketField;
-import ghidra.dbg.sctl.client.SctlExtension;
-import ghidra.dbg.sctl.protocol.AbstractSctlRequest;
-import ghidra.dbg.sctl.protocol.common.SctlString;
-
-/**
- * Format for the "{@code Texec}" SCTL message
- *
- * There is no {@code Texec} or {@code Rexec} in the official SCTL protocol. It is an extension for
- * Ghidra to issue CLI commands to a connected interactive debugger.
- */
-@SctlExtension("Execute a CLI command in the remote debugger")
-public class SctlExecuteRequest extends AbstractSctlRequest {
- public SctlExecuteRequest() {
- }
-
- public SctlExecuteRequest(String cmd) {
- this.cmd = new SctlString(cmd);
- }
-
- @PacketField
- public SctlString cmd;
-}
diff --git a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/v2012ext/SelSctl2012ExtPacket.java b/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/v2012ext/SelSctl2012ExtPacket.java
deleted file mode 100644
index 2117b843c3..0000000000
--- a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/v2012ext/SelSctl2012ExtPacket.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/* ###
- * 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 ghidra.dbg.sctl.protocol.v2012ext;
-
-import java.util.Map;
-
-import ghidra.dbg.sctl.protocol.AbstractSelSctlPacket;
-import ghidra.dbg.sctl.protocol.SctlPacket;
-import ghidra.dbg.sctl.protocol.consts.Mkind;
-import ghidra.dbg.sctl.protocol.v2012base.SelSctl2012Packet;
-
-public class SelSctl2012ExtPacket extends AbstractSelSctlPacket {
- public SelSctl2012ExtPacket() {
- super();
- }
-
- public SelSctl2012ExtPacket(int tag, SctlPacket sel) {
- super(tag, sel);
- }
-
- public static final Map<Mkind, Class<? extends SctlPacket>> METHOD_MAP =
- typeMap(Mkind.class, SctlPacket.class) //
- .putAll(SelSctl2012Packet.METHOD_MAP) //
- .put(Mkind.Texec, SctlExecuteRequest.class) //
- .put(Mkind.Rexec, SctlExecuteReply.class) //
- .build();
-}
diff --git a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/v2012ext/x86/linux/Sctl2012ExtLinuxX86Dialect.java b/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/v2012ext/x86/linux/Sctl2012ExtLinuxX86Dialect.java
deleted file mode 100644
index 9f5e764f9a..0000000000
--- a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/v2012ext/x86/linux/Sctl2012ExtLinuxX86Dialect.java
+++ /dev/null
@@ -1,165 +0,0 @@
-/* ###
- * 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 ghidra.dbg.sctl.protocol.v2012ext.x86.linux;
-
-import java.util.Set;
-
-import ghidra.comm.packet.PacketFactory;
-import ghidra.dbg.sctl.client.SctlExtension;
-import ghidra.dbg.sctl.dialect.SctlDialect;
-import ghidra.dbg.sctl.protocol.AbstractSelSctlPacket;
-import ghidra.dbg.sctl.protocol.consts.Evkind;
-import ghidra.dbg.sctl.protocol.v2012base.x86.linux.Sctl2012LinuxX86Dialect;
-import ghidra.dbg.sctl.protocol.v2012base.x86.linux.Sctl2012LinuxX86Dialect.Sctl2012LinuxX86PacketFactory;
-import ghidra.dbg.sctl.protocol.v2012ext.SelSctl2012ExtPacket;
-import ghidra.dbg.target.TargetExecutionStateful.TargetExecutionState;
-
-/**
- * "Bus" extension to SCTL's Linux x86 2012 dialect.
- *
- * SCTL-Bus is an extension (read "hack") added by Ghidra's implementation of SCTL. Since SCTL was
- * designed to give L1 complete and <em>exclusive</em> control of a remote process, asynchronous
- * notifications were only required for execution events. The "Bus" variant allows multiple
- * controllers to cooperate and stay in sync. The controller must now also listen for requests from
- * other controllers as well as for the responses those requests generate.
- *
- * To distinguish each controller, the tag field is structured as follows:
- *
- * <pre>
- * 31-24 23-0
- * +--------+------------------------+
- * | ID | Tag |
- * +--------+------------------------+
- * </pre>
- *
- * Where ID (the highest-order byte) identifies the controller and the remaining bits uniquely
- * identify the request. Each client should be assigned its ID statically. No method of dynamic
- * selection has been explored, though random selection may be available in future versions.
- *
- * The extension provides more flexibility in debugger connections than is immediately apparent.
- * First, the setup is backward compatible with non-bus SCTL. A client can offer both variants, and
- * a non-bus SCTL server ought to select the non-bus variant. Furthermore, a bus-enabled stub can
- * agree to a non-bus controller without any changes in protocol, except to give the controller
- * exclusive access to the bus.
- *
- * Second, a non-bus stub need not be aware that multiple controllers are present. A proxy bus can
- * be placed in front of the stub. It need only negotiate the versions. So long as all controllers
- * speak the same version, it can just forward all packets on all connections -- as a bus should.
- *
- * Third, for stubs that operate by integrating a host debugger, the stub may pretend the debugger's
- * UI is another controller on the bus. This enables it to keep the connected controller(s) in sync
- * with commands issued directly in the debugger's UI.
- *
- * For terminology, consider the typical example setup for debugging on Linux with Ghidra:
- *
- * <pre>
- * +--------+ +------+ +-----+ +-----------+
- * | Ghidra |-SCTL-| stub |-pty:GDB/MI-| gdb |-ptrace-| /bin/echo |
- * +--------+ +------+ +-----+ +-----------+
- * </pre>
- *
- * Ghidra, a.k.a, the Ghidra debugger, is acting as the SCTL client. gdb is the external or remote
- * debugger. A custom SCTL stub controls gdb via a pty with GDB/MI. As an example,
- * <code>/bin/echo</code> is the program image for the target process.
- *
- * In this setup, Ghidra does not have exclusive control of the target process. Ghidra cooperates
- * with the external debugger, so there is a need to communicate to Ghidra control commands issued
- * by the user to the external debugger. In this case, the stub should prefer to use SCTL's defined
- * notification commands where applicable. For example, if a process forks, the stub ought to issue
- * the fork notification rather than synthesizing a launch command. When the stub synthesizes a
- * control command, it must also synthesize the successful reply. It would synthesize these commands
- * using incrementing tags and a bus ID different than the client's ID.
- *
- * The requests that may be synthesized by the stub include:
- * <ul>
- * <li><b>launch</b> - to notify the clients of a launched process, excluding those created by fork
- * or clone, since those already have defined notifications.</li>
- * <li><b>attach</b> - to notify the clients of an attached process, excluding those created by fork
- * or clone, since those already have defined notifications.</li>
- * <li><b>step</b> - to notify the clients that a step was issued externally.</li>
- * <li><b>stop</b> - to notify the clients that a stop was issued externally.</li>
- * <li><b>cont</b> - to notify the clients that a continue was issued externally.</li>
- * <li><b>kill</b> - to notify the clients that a kill was issued externally. This need only be sent
- * if a process is explicitly terminated by the debugger. For processes that exit in the usual way,
- * use the usual SCTL notify message.</li>
- * <li><b>detach</b> - to notify the clients that a detach was issued externally. This need only be
- * sent if the user explicitly detached from a process. For processes that exit in the usual way,
- * use the usual SCTL notify message.</li>
- * <li><b>settrap</b> - to notify the clients that the user created a breakpoint.</li>
- * <li><b>clrtrap</b> - to notify the clients that the user deleted a breakpoint.</li>
- * <li><b>setctx</b> - to notify the clients that the user modified one or more registers.</li>
- * </ul>
- *
- * These rules are designed to prevent a stub from giving a client any false impressions. They need
- * not be followed precisely. For example, if a stop is implemented by sending the target SIGINT,
- * then it is acceptable for the stub to send a signal notification even if the stop was requested
- * from the debugger's UI.
- *
- * If bus mode is available, the stub ought to sync the client to its current state. If a proxy is
- * used, and it keeps a log, it could replay it on any new channel. If it is smart, it can cull that
- * log to eliminate messages that are no longer relevant to the current state. A stub that is also a
- * controller ought to synthesize the necessary control commands upon connection.
- */
-@SctlExtension("Bus or bidirectional requests")
-public enum Sctl2012ExtLinuxX86Dialect implements SctlDialect {
- INSTANCE;
-
- public static class Sctl2012BusLinuxX86PacketFactory extends Sctl2012LinuxX86PacketFactory {
- {
- useFor(AbstractSelSctlPacket.class, SelSctl2012ExtPacket.class);
- }
- }
-
- public static final String SYS_VERSION = Sctl2012LinuxX86Dialect.SYS_VERSION + "-bus";
- public static final String PLATFORM = Sctl2012LinuxX86Dialect.PLATFORM;
- private static final PacketFactory FACTORY = new Sctl2012BusLinuxX86PacketFactory();
-
- @Override
- public String getSysVersion() {
- return SYS_VERSION;
- }
-
- @Override
- public PacketFactory getPacketFactory() {
- return FACTORY;
- }
-
- @Override
- public boolean isBusSupported() {
- return true;
- }
-
- @Override
- public boolean isRegisterSelectionSupported() {
- return false;
- }
-
- @Override
- public TargetExecutionState stateAfterEvent(Set<Evkind> events) {
- if (events.contains(Evkind.Erunning)) {
- return TargetExecutionState.RUNNING;
- }
- if (events.contains(Evkind.Estopped)) {
- return TargetExecutionState.STOPPED;
- }
- return Sctl2012LinuxX86Dialect.INSTANCE.stateAfterEvent(events);
- }
-
- @Override
- public String getSolePlatform() {
- return PLATFORM;
- }
-}
diff --git a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/v2012ext/x86/win/Sctl2012ExtWindowsX86Dialect.java b/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/v2012ext/x86/win/Sctl2012ExtWindowsX86Dialect.java
deleted file mode 100644
index ae18264324..0000000000
--- a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/v2012ext/x86/win/Sctl2012ExtWindowsX86Dialect.java
+++ /dev/null
@@ -1,85 +0,0 @@
-/* ###
- * 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 ghidra.dbg.sctl.protocol.v2012ext.x86.win;
-
-import java.util.Set;
-
-import ghidra.comm.packet.PacketFactory;
-import ghidra.dbg.sctl.client.SctlExtension;
-import ghidra.dbg.sctl.dialect.SctlDialect;
-import ghidra.dbg.sctl.protocol.AbstractSelSctlPacket;
-import ghidra.dbg.sctl.protocol.consts.Evkind;
-import ghidra.dbg.sctl.protocol.v2012base.x86.win.Sctl2012WindowsX86Dialect;
-import ghidra.dbg.sctl.protocol.v2012base.x86.win.Sctl2012WindowsX86Dialect.Sctl2012WindowsX86PacketFactory;
-import ghidra.dbg.sctl.protocol.v2012ext.SelSctl2012ExtPacket;
-import ghidra.dbg.sctl.protocol.v2012ext.x86.linux.Sctl2012ExtLinuxX86Dialect;
-import ghidra.dbg.target.TargetExecutionStateful.TargetExecutionState;
-
-/**
- * "Bidirectional" extension to the Windows x86 2012 SCTL dialect.
- *
- * @see Sctl2012ExtLinuxX86Dialect
- */
-@SctlExtension("Bus or bidirectional requests")
-public enum Sctl2012ExtWindowsX86Dialect implements SctlDialect {
- INSTANCE;
-
- public static class Sctl2012BusWindowsX86PacketFactory extends Sctl2012WindowsX86PacketFactory {
- {
- useFor(AbstractSelSctlPacket.class, SelSctl2012ExtPacket.class);
- }
- }
-
- public static final String SYS_VERSION = Sctl2012WindowsX86Dialect.SYS_VERSION + "-bus";
- public static final String PLATFORM = Sctl2012WindowsX86Dialect.PLATFORM;
- private static final PacketFactory FACTORY = new Sctl2012BusWindowsX86PacketFactory();
-
- @Override
- public String getSysVersion() {
- return SYS_VERSION;
- }
-
- @Override
- public PacketFactory getPacketFactory() {
- return FACTORY;
- }
-
- @Override
- public boolean isBusSupported() {
- return true;
- }
-
- @Override
- public boolean isRegisterSelectionSupported() {
- return false;
- }
-
- @Override
- public TargetExecutionState stateAfterEvent(Set<Evkind> events) {
- if (events.contains(Evkind.Erunning)) {
- return TargetExecutionState.RUNNING;
- }
- if (events.contains(Evkind.Estopped)) {
- return TargetExecutionState.STOPPED;
- }
- return Sctl2012WindowsX86Dialect.INSTANCE.stateAfterEvent(events);
- }
-
- @Override
- public String getSolePlatform() {
- return PLATFORM;
- }
-}
diff --git a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/v2018base/Sctl2018AttachReply.java b/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/v2018base/Sctl2018AttachReply.java
deleted file mode 100644
index 933a108bb4..0000000000
--- a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/v2018base/Sctl2018AttachReply.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/* ###
- * 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 ghidra.dbg.sctl.protocol.v2018base;
-
-import ghidra.comm.packet.fields.PacketField;
-import ghidra.dbg.sctl.protocol.common.SctlString;
-import ghidra.dbg.sctl.protocol.common.reply.AbstractSctlAttachReply;
-
-public class Sctl2018AttachReply extends AbstractSctlAttachReply {
- @Override
- public boolean supportsPlatform() {
- return true;
- }
-
- @Override
- public void setPlatform(String platform) {
- this.platform = new SctlString(platform);
- }
-
- @Override
- public String getPlatform() {
- return platform.str;
- }
-
- @PacketField(after = "ctlid", before = "ctx")
- public SctlString platform;
-}
diff --git a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/v2018base/Sctl2018ForkNotification.java b/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/v2018base/Sctl2018ForkNotification.java
deleted file mode 100644
index 30f6c9a40e..0000000000
--- a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/v2018base/Sctl2018ForkNotification.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/* ###
- * 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 ghidra.dbg.sctl.protocol.v2018base;
-
-import ghidra.comm.packet.fields.PacketField;
-import ghidra.dbg.sctl.protocol.common.AbstractSctlContext;
-import ghidra.dbg.sctl.protocol.common.notify.AbstractSctlForkNotification;
-
-public class Sctl2018ForkNotification extends AbstractSctlForkNotification {
- public Sctl2018ForkNotification() {
- super();
- }
-
- public Sctl2018ForkNotification(long spwnid, AbstractSctlContext ctx,
- AbstractSctlContext spwnctx) {
- super(spwnid, ctx, spwnctx);
- }
-
- @Override
- public boolean supportsProcessID() {
- return true;
- }
-
- @Override
- public long getProcessID() {
- return pid;
- }
-
- @Override
- public void setProcessID(long pid) {
- this.pid = pid;
- }
-
- @PacketField(after = "spwnid", before = "ctx")
- public long pid;
-}
diff --git a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/v2018base/Sctl2018LaunchReply.java b/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/v2018base/Sctl2018LaunchReply.java
deleted file mode 100644
index fe2b5e3e19..0000000000
--- a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/v2018base/Sctl2018LaunchReply.java
+++ /dev/null
@@ -1,58 +0,0 @@
-/* ###
- * 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 ghidra.dbg.sctl.protocol.v2018base;
-
-import ghidra.comm.packet.fields.PacketField;
-import ghidra.dbg.sctl.protocol.common.SctlString;
-import ghidra.dbg.sctl.protocol.common.reply.AbstractSctlLaunchReply;
-
-public class Sctl2018LaunchReply extends AbstractSctlLaunchReply {
- @Override
- public boolean supportsProcessID() {
- return true;
- }
-
- @Override
- public void setProcessID(long pid) {
- this.pid = pid;
- }
-
- @Override
- public long getProcessID() {
- return pid;
- }
-
- @Override
- public boolean supportsPlatform() {
- return true;
- }
-
- @Override
- public void setPlatform(String platform) {
- this.platform = new SctlString(platform);
- }
-
- @Override
- public String getPlatform() {
- return platform.str;
- }
-
- @PacketField(after = "ctlid")
- public long pid;
-
- @PacketField(before = "ctx")
- public SctlString platform;
-}
diff --git a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/v2018base/Sctl2018SnapNotification.java b/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/v2018base/Sctl2018SnapNotification.java
deleted file mode 100644
index 896b00e6e3..0000000000
--- a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/v2018base/Sctl2018SnapNotification.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/* ###
- * 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 ghidra.dbg.sctl.protocol.v2018base;
-
-import ghidra.comm.packet.fields.PacketField;
-import ghidra.dbg.sctl.protocol.common.notify.AbstractSctlSnapNotification;
-
-public class Sctl2018SnapNotification extends AbstractSctlSnapNotification {
-
- @Override
- public boolean supportsProcessID() {
- return true;
- }
-
- @Override
- public void setProcessID(long pid) {
- this.pid = pid;
- }
-
- @Override
- public long getProcessID() {
- return pid;
- }
-
- @PacketField(after = "spwnid", before = "ctx")
- public long pid;
-}
diff --git a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/v2018base/Sctl2018SnapshotReply.java b/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/v2018base/Sctl2018SnapshotReply.java
deleted file mode 100644
index 113ee33b80..0000000000
--- a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/v2018base/Sctl2018SnapshotReply.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/* ###
- * 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 ghidra.dbg.sctl.protocol.v2018base;
-
-import ghidra.comm.packet.fields.PacketField;
-import ghidra.dbg.sctl.protocol.common.reply.AbstractSctlSnapshotReply;
-
-public class Sctl2018SnapshotReply extends AbstractSctlSnapshotReply {
- @Override
- public boolean supportsProcessID() {
- return true;
- }
-
- @Override
- public void setProcessID(long pid) {
- this.pid = pid;
- }
-
- @Override
- public long getProcessID() {
- return pid;
- }
-
- @PacketField(after = "spwnid", before = "ctx")
- public long pid;
-}
diff --git a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/v2018base/SctlChooseContextReply.java b/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/v2018base/SctlChooseContextReply.java
deleted file mode 100644
index 8867ac0bce..0000000000
--- a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/v2018base/SctlChooseContextReply.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/* ###
- * 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 ghidra.dbg.sctl.protocol.v2018base;
-
-import ghidra.dbg.sctl.protocol.common.AbstractSctlContext;
-import ghidra.dbg.sctl.protocol.common.reply.SctlGetContextReply;
-import ghidra.dbg.sctl.protocol.consts.Mkind;
-
-/**
- * Format for the {@link Mkind#Rchoosectx} SCTL message
- */
-public class SctlChooseContextReply extends SctlGetContextReply {
- public SctlChooseContextReply() {
- }
-
- public SctlChooseContextReply(AbstractSctlContext ctx) {
- super(ctx);
- }
-}
diff --git a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/v2018base/SctlChooseContextRequest.java b/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/v2018base/SctlChooseContextRequest.java
deleted file mode 100644
index 4eee90d838..0000000000
--- a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/v2018base/SctlChooseContextRequest.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/* ###
- * 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 ghidra.dbg.sctl.protocol.v2018base;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import ghidra.comm.packet.annot.CountedByField;
-import ghidra.comm.packet.annot.RepeatedField;
-import ghidra.comm.packet.fields.PacketField;
-import ghidra.dbg.sctl.protocol.AbstractSctlRequest;
-
-public class SctlChooseContextRequest extends AbstractSctlRequest {
- public SctlChooseContextRequest() {
- super();
- }
-
- public SctlChooseContextRequest(long ctlid) {
- this.ctlid = ctlid;
- }
-
- @PacketField
- public long ctlid;
-
- @PacketField
- public long nreg;
-
- @RepeatedField
- @CountedByField("nreg")
- @PacketField
- public List<Long> regids = new ArrayList<>();
-}
diff --git a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/v2018base/SctlEnumerateContextReply.java b/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/v2018base/SctlEnumerateContextReply.java
deleted file mode 100644
index a48a2eba14..0000000000
--- a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/v2018base/SctlEnumerateContextReply.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/* ###
- * 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 ghidra.dbg.sctl.protocol.v2018base;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import ghidra.comm.packet.annot.CountedByField;
-import ghidra.comm.packet.annot.RepeatedField;
-import ghidra.comm.packet.fields.PacketField;
-import ghidra.dbg.sctl.protocol.AbstractSctlReply;
-import ghidra.dbg.sctl.protocol.common.SctlRegisterDefinition;
-
-public class SctlEnumerateContextReply extends AbstractSctlReply {
- @PacketField
- public long nreg;
-
- @RepeatedField
- @CountedByField("nreg")
- @PacketField
- public List<SctlRegisterDefinition> regdefs = new ArrayList<>();
-}
diff --git a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/v2018base/SctlEnumerateContextRequest.java b/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/v2018base/SctlEnumerateContextRequest.java
deleted file mode 100644
index 0421c8188d..0000000000
--- a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/v2018base/SctlEnumerateContextRequest.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/* ###
- * 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 ghidra.dbg.sctl.protocol.v2018base;
-
-import ghidra.comm.packet.fields.PacketField;
-import ghidra.dbg.sctl.protocol.AbstractSctlRequest;
-
-public class SctlEnumerateContextRequest extends AbstractSctlRequest {
- public SctlEnumerateContextRequest() {
- }
-
- public SctlEnumerateContextRequest(long ctlid) {
- this.ctlid = ctlid;
- }
-
- @PacketField
- public long ctlid;
-}
diff --git a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/v2018base/SctlFocusReply.java b/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/v2018base/SctlFocusReply.java
deleted file mode 100644
index 60193e8f1f..0000000000
--- a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/v2018base/SctlFocusReply.java
+++ /dev/null
@@ -1,21 +0,0 @@
-/* ###
- * 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 ghidra.dbg.sctl.protocol.v2018base;
-
-import ghidra.dbg.sctl.protocol.AbstractSctlReply;
-
-public class SctlFocusReply extends AbstractSctlReply {
-}
diff --git a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/v2018base/SctlFocusRequest.java b/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/v2018base/SctlFocusRequest.java
deleted file mode 100644
index 29fc46d4dd..0000000000
--- a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/v2018base/SctlFocusRequest.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/* ###
- * 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 ghidra.dbg.sctl.protocol.v2018base;
-
-import ghidra.comm.packet.fields.PacketField;
-import ghidra.dbg.sctl.protocol.AbstractSctlRequest;
-
-public class SctlFocusRequest extends AbstractSctlRequest {
- public SctlFocusRequest() {
- }
-
- public SctlFocusRequest(long ctlid) {
- this.ctlid = ctlid;
- }
-
- @PacketField
- public long ctlid;
-}
diff --git a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/v2018base/SctlGetAttributesReply.java b/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/v2018base/SctlGetAttributesReply.java
deleted file mode 100644
index 87a7de9d51..0000000000
--- a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/v2018base/SctlGetAttributesReply.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/* ###
- * 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 ghidra.dbg.sctl.protocol.v2018base;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import ghidra.comm.packet.annot.CountedByField;
-import ghidra.comm.packet.annot.RepeatedField;
-import ghidra.comm.packet.fields.PacketField;
-import ghidra.dbg.sctl.protocol.AbstractSctlReply;
-import ghidra.dbg.sctl.protocol.common.AbstractSctlObjectEntry;
-
-public class SctlGetAttributesReply extends AbstractSctlReply {
-
- @PacketField
- public long nattributes;
-
- @PacketField
- @RepeatedField
- @CountedByField("nattributes")
- public List<AbstractSctlObjectEntry> attributes = new ArrayList<>();
-}
diff --git a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/v2018base/SctlGetAttributesRequest.java b/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/v2018base/SctlGetAttributesRequest.java
deleted file mode 100644
index 4d4195498b..0000000000
--- a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/v2018base/SctlGetAttributesRequest.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/* ###
- * 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 ghidra.dbg.sctl.protocol.v2018base;
-
-import ghidra.comm.packet.fields.PacketField;
-import ghidra.dbg.sctl.protocol.AbstractSctlRequest;
-import ghidra.dbg.sctl.protocol.common.SctlString;
-
-public class SctlGetAttributesRequest extends AbstractSctlRequest {
-
- public SctlGetAttributesRequest() {
- }
-
- public SctlGetAttributesRequest(String path) {
- this.path = new SctlString(path);
- }
-
- @PacketField
- public SctlString path;
-
-}
diff --git a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/v2018base/SctlGetElementsReply.java b/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/v2018base/SctlGetElementsReply.java
deleted file mode 100644
index ab226aa997..0000000000
--- a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/v2018base/SctlGetElementsReply.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/* ###
- * 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 ghidra.dbg.sctl.protocol.v2018base;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import ghidra.comm.packet.annot.CountedByField;
-import ghidra.comm.packet.annot.RepeatedField;
-import ghidra.comm.packet.fields.PacketField;
-import ghidra.dbg.sctl.protocol.AbstractSctlReply;
-import ghidra.dbg.sctl.protocol.common.AbstractSctlObjectEntry;
-
-public class SctlGetElementsReply extends AbstractSctlReply {
-
- @PacketField
- public long nelements;
-
- @PacketField
- @RepeatedField
- @CountedByField("nelements")
- public List<AbstractSctlObjectEntry> elements = new ArrayList<>();
-}
diff --git a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/v2018base/SctlGetElementsRequest.java b/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/v2018base/SctlGetElementsRequest.java
deleted file mode 100644
index ac32f47ad3..0000000000
--- a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/v2018base/SctlGetElementsRequest.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/* ###
- * 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 ghidra.dbg.sctl.protocol.v2018base;
-
-import ghidra.comm.packet.fields.PacketField;
-import ghidra.dbg.sctl.protocol.AbstractSctlRequest;
-import ghidra.dbg.sctl.protocol.common.SctlString;
-
-public class SctlGetElementsRequest extends AbstractSctlRequest {
-
- public SctlGetElementsRequest() {
- }
-
- public SctlGetElementsRequest(String path) {
- this.path = new SctlString(path);
- }
-
- @PacketField
- public SctlString path;
-}
diff --git a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/v2018base/SctlStepIntoReply.java b/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/v2018base/SctlStepIntoReply.java
deleted file mode 100644
index 66749711d1..0000000000
--- a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/v2018base/SctlStepIntoReply.java
+++ /dev/null
@@ -1,20 +0,0 @@
-/* ###
- * 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 ghidra.dbg.sctl.protocol.v2018base;
-
-public class SctlStepIntoReply {
-
-}
diff --git a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/v2018base/SctlStepIntoRequest.java b/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/v2018base/SctlStepIntoRequest.java
deleted file mode 100644
index 3aa67cebc2..0000000000
--- a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/v2018base/SctlStepIntoRequest.java
+++ /dev/null
@@ -1,20 +0,0 @@
-/* ###
- * 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 ghidra.dbg.sctl.protocol.v2018base;
-
-public class SctlStepIntoRequest {
-
-}
diff --git a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/v2018base/SctlStepOutReply.java b/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/v2018base/SctlStepOutReply.java
deleted file mode 100644
index 3f71677209..0000000000
--- a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/v2018base/SctlStepOutReply.java
+++ /dev/null
@@ -1,20 +0,0 @@
-/* ###
- * 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 ghidra.dbg.sctl.protocol.v2018base;
-
-public class SctlStepOutReply {
-
-}
diff --git a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/v2018base/SctlStepOutRequest.java b/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/v2018base/SctlStepOutRequest.java
deleted file mode 100644
index adcba61aff..0000000000
--- a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/v2018base/SctlStepOutRequest.java
+++ /dev/null
@@ -1,20 +0,0 @@
-/* ###
- * 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 ghidra.dbg.sctl.protocol.v2018base;
-
-public class SctlStepOutRequest {
-
-}
diff --git a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/v2018base/SctlStepOverReply.java b/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/v2018base/SctlStepOverReply.java
deleted file mode 100644
index 9271cd6544..0000000000
--- a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/v2018base/SctlStepOverReply.java
+++ /dev/null
@@ -1,20 +0,0 @@
-/* ###
- * 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 ghidra.dbg.sctl.protocol.v2018base;
-
-public class SctlStepOverReply {
-
-}
diff --git a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/v2018base/SctlStepOverRequest.java b/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/v2018base/SctlStepOverRequest.java
deleted file mode 100644
index ed25bf1d40..0000000000
--- a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/v2018base/SctlStepOverRequest.java
+++ /dev/null
@@ -1,20 +0,0 @@
-/* ###
- * 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 ghidra.dbg.sctl.protocol.v2018base;
-
-public class SctlStepOverRequest {
-
-}
diff --git a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/v2018base/SelSctl2018Packet.java b/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/v2018base/SelSctl2018Packet.java
deleted file mode 100644
index fd2cc87378..0000000000
--- a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/v2018base/SelSctl2018Packet.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/* ###
- * 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 ghidra.dbg.sctl.protocol.v2018base;
-
-import java.util.Map;
-
-import ghidra.dbg.sctl.protocol.AbstractSelSctlPacket;
-import ghidra.dbg.sctl.protocol.SctlPacket;
-import ghidra.dbg.sctl.protocol.consts.Mkind;
-import ghidra.dbg.sctl.protocol.v2012ext.SelSctl2012ExtPacket;
-
-public class SelSctl2018Packet extends AbstractSelSctlPacket {
- public static final Map<Mkind, Class<? extends SctlPacket>> METHOD_MAP =
- typeMap(Mkind.class, SctlPacket.class) //
- .putAll(SelSctl2012ExtPacket.METHOD_MAP) //
- .put(Mkind.Tenumctx, SctlEnumerateContextRequest.class) //
- .put(Mkind.Renumctx, SctlEnumerateContextReply.class) //
- .put(Mkind.Tchoosectx, SctlChooseContextRequest.class) //
- .put(Mkind.Rchoosectx, SctlChooseContextReply.class) //
- .put(Mkind.Tfocus, SctlFocusRequest.class) //
- .put(Mkind.Rfocus, SctlFocusReply.class) //
- .put(Mkind.Tgetchildren, SctlGetElementsRequest.class) //
- .put(Mkind.Rgetchildren, SctlGetElementsReply.class) //
- .put(Mkind.Tgetattributes, SctlGetAttributesRequest.class) //
- .put(Mkind.Rgetattributes, SctlGetAttributesReply.class) //
- .build();
-}
diff --git a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/v2018base/any/Sctl2018AnyAnyDialect.java b/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/v2018base/any/Sctl2018AnyAnyDialect.java
deleted file mode 100644
index 5cb8c9e6e3..0000000000
--- a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/v2018base/any/Sctl2018AnyAnyDialect.java
+++ /dev/null
@@ -1,90 +0,0 @@
-/* ###
- * 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 ghidra.dbg.sctl.protocol.v2018base.any;
-
-import java.util.Set;
-
-import ghidra.comm.packet.AbstractPacketFactory;
-import ghidra.comm.packet.PacketFactory;
-import ghidra.dbg.sctl.dialect.SctlDialect;
-import ghidra.dbg.sctl.protocol.AbstractSelSctlPacket;
-import ghidra.dbg.sctl.protocol.common.*;
-import ghidra.dbg.sctl.protocol.common.notify.AbstractSctlForkNotification;
-import ghidra.dbg.sctl.protocol.common.notify.AbstractSctlSnapNotification;
-import ghidra.dbg.sctl.protocol.common.reply.*;
-import ghidra.dbg.sctl.protocol.consts.Evkind;
-import ghidra.dbg.sctl.protocol.v2018base.*;
-import ghidra.dbg.target.TargetExecutionStateful.TargetExecutionState;
-
-public enum Sctl2018AnyAnyDialect implements SctlDialect {
- INSTANCE;
-
- protected static class Sctl2018BusAnyAnyPacketFactory extends AbstractPacketFactory {
- {
- useFor(AbstractSelSctlPacket.class, SelSctl2018Packet.class);
-
- useFor(AbstractSctlAttachReply.class, Sctl2018AttachReply.class);
- useFor(AbstractSctlLaunchReply.class, Sctl2018LaunchReply.class);
- useFor(AbstractSctlSnapshotReply.class, Sctl2018SnapshotReply.class);
-
- useFor(AbstractSctlForkNotification.class, Sctl2018ForkNotification.class);
- useFor(AbstractSctlSnapNotification.class, Sctl2018SnapNotification.class);
-
- useFor(AbstractSctlContext.class, Sctl2018Context.class);
- useFor(AbstractSctlProcessList.class, Sctl2018ProcessList.class);
- useFor(AbstractSctlStatus.class, Sctl2018Status.class);
- useFor(AbstractSctlTrapSpec.class, Sctl2018TrapSpec.class);
-
- useFor(AbstractSctlObjectEntry.class, Sctl2018ObjectEntry.class);
- }
- }
-
- public static final String SYS_VERSION = "any-any-2018";
- private static final PacketFactory FACTORY = new Sctl2018BusAnyAnyPacketFactory();
-
- @Override
- public String getSysVersion() {
- return SYS_VERSION;
- }
-
- @Override
- public PacketFactory getPacketFactory() {
- return FACTORY;
- }
-
- @Override
- public boolean isBusSupported() {
- return true;
- }
-
- @Override
- public boolean isRegisterSelectionSupported() {
- return true;
- }
-
- @Override
- public TargetExecutionState stateAfterEvent(Set<Evkind> events) {
- if (events.contains(Evkind.Erunning)) {
- return TargetExecutionState.RUNNING;
- }
- return TargetExecutionState.STOPPED;
- }
-
- @Override
- public String getSolePlatform() {
- throw new UnsupportedOperationException();
- }
-}
diff --git a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/v2018base/any/Sctl2018Binary.java b/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/v2018base/any/Sctl2018Binary.java
deleted file mode 100644
index 06a317b9a7..0000000000
--- a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/v2018base/any/Sctl2018Binary.java
+++ /dev/null
@@ -1,106 +0,0 @@
-/* ###
- * 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 ghidra.dbg.sctl.protocol.v2018base.any;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import ghidra.comm.packet.annot.CountedByField;
-import ghidra.comm.packet.annot.RepeatedField;
-import ghidra.comm.packet.fields.PacketField;
-import ghidra.dbg.sctl.protocol.common.AbstractSctlBinary;
-import ghidra.dbg.sctl.protocol.common.SctlString;
-
-public class Sctl2018Binary extends AbstractSctlBinary {
- @Override
- public void setNamespaceID(long nsid) {
- this.nsid = nsid;
- }
-
- @Override
- public long getNamespaceID() {
- return nsid;
- }
-
- @Override
- public void setPath(String path) {
- this.path = new SctlString(path);
- }
-
- @Override
- public String getPath() {
- return path.str;
- }
-
- @Override
- public void setExecutable(boolean isexe) {
- this.isexe = isexe;
- }
-
- @Override
- public boolean isExecutable() {
- return isexe;
- }
-
- @Override
- public boolean supportsBase() {
- return false;
- }
-
- @Override
- public void setBase(long base) {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public long getBase() {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public boolean supportsSections() {
- return true;
- }
-
- @Override
- public Sctl2018Section addSection() {
- Sctl2018Section s = new Sctl2018Section();
- sections.add(s);
- return s;
- }
-
- @Override
- public List<Sctl2018Section> getSections() {
- return sections;
- }
-
- @PacketField
- public long nsid;
-
- @PacketField
- public boolean isexe;
-
- @PacketField
- public SctlString path;
-
- @PacketField
- public long ns;
-
- @PacketField
- @RepeatedField
- @CountedByField("ns")
- public List<Sctl2018Section> sections = new ArrayList<>();
-}
diff --git a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/v2018base/any/Sctl2018Context.java b/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/v2018base/any/Sctl2018Context.java
deleted file mode 100644
index 5cc0296e38..0000000000
--- a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/v2018base/any/Sctl2018Context.java
+++ /dev/null
@@ -1,141 +0,0 @@
-/* ###
- * 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 ghidra.dbg.sctl.protocol.v2018base.any;
-
-import java.util.*;
-
-import ghidra.comm.packet.fields.PacketField;
-import ghidra.dbg.sctl.protocol.common.AbstractSctlContext;
-import ghidra.dbg.sctl.protocol.common.SctlRegisterDefinition;
-
-public class Sctl2018Context extends AbstractSctlContext {
- protected class RegisterCodec {
- final int start;
- final int byteLen;
-
- public RegisterCodec(int start, int byteLen) {
- this.start = start;
- this.byteLen = byteLen;
- }
-
- public void encode(byte[] val) {
- System.arraycopy(val, 0, data, start, byteLen);
- }
-
- public void decode(byte[] val) {
- System.arraycopy(data, start, val, 0, byteLen);
- }
-
- public byte[] decode() {
- byte[] val = new byte[byteLen];
- decode(val);
- return val;
- }
- }
-
- //private final List<SctlRegisterDefinition> regdefs;
- private final Map<String, RegisterCodec> codecsByName = new LinkedHashMap<>();
- private final Set<String> names = new LinkedHashSet<>();
- private final Set<String> namesView =
- Collections.unmodifiableSet(names);
- private final Map<String, byte[]> valuesByName = new LinkedHashMap<>();
- private final Map<String, byte[]> valuesView = Collections.unmodifiableMap(valuesByName);
-
- private int totalLen;
-
- public Sctl2018Context() {
- }
-
- @Override
- public void setSelectedRegisters(List<SctlRegisterDefinition> regdefs) {
- int byteLoc = 0;
- codecsByName.clear();
- for (SctlRegisterDefinition def : regdefs) {
- int byteLen = (int) ((def.nbits + 7) / 8);
- codecsByName.put(def.name.str, new RegisterCodec(byteLoc, byteLen));
- names.add(def.name.str);
- byteLoc += byteLen;
- }
- totalLen = byteLoc;
- checkData();
- parseData();
- }
-
- public void setData(byte[] data) {
- if (totalLen != data.length) {
- throw new IllegalArgumentException(
- "data length must match total from selected registers");
- }
- System.arraycopy(data, 0, this.data, 0, totalLen);
- parseData();
- }
-
- protected void parseData() {
- valuesByName.clear();
- if (data == null) {
- return;
- }
- for (Map.Entry<String, RegisterCodec> ent : codecsByName.entrySet()) {
- valuesByName.put(ent.getKey(), ent.getValue().decode());
- }
- }
-
- @Override
- public Map<String, byte[]> toMap() {
- return valuesView;
- }
-
- @Override
- public Set<String> getRegisterNames() {
- return namesView;
- }
-
- protected void checkData() {
- if (data == null) {
- data = new byte[totalLen];
- }
- }
-
- @Override
- public void updateFromMap(Map<String, byte[]> values) {
- for (Map.Entry<String, byte[]> ent : values.entrySet()) {
- String name = ent.getKey();
- byte[] value = ent.getValue();
- doUpdate(name, value);
- }
- }
-
- protected void doUpdate(String name, byte[] value) {
- RegisterCodec codec = codecsByName.get(name);
- if (codec == null) {
- throw new IllegalArgumentException("Register invalid or not selected: " + name);
- }
- if (value.length != codec.byteLen) {
- throw new IllegalArgumentException("Register value for " + name +
- " has incorrect length: " + value.length + ". Expected " + codec.byteLen);
- }
- codec.encode(value);
- valuesByName.put(name, value);
- }
-
- @Override
- public void update(String name, byte[] value) {
- doUpdate(name, value);
- }
-
- @PacketField
- public byte[] data;
-}
diff --git a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/v2018base/any/Sctl2018ObjectEntry.java b/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/v2018base/any/Sctl2018ObjectEntry.java
deleted file mode 100644
index bbf6a34a54..0000000000
--- a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/v2018base/any/Sctl2018ObjectEntry.java
+++ /dev/null
@@ -1,91 +0,0 @@
-/* ###
- * 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 ghidra.dbg.sctl.protocol.v2018base.any;
-
-import ghidra.comm.packet.fields.PacketField;
-import ghidra.dbg.sctl.protocol.common.AbstractSctlObjectEntry;
-import ghidra.dbg.sctl.protocol.common.SctlString;
-
-/**
- * The format for each process of {@code bytes[]} of SCTL's {@code Rps} reply for Linux dialects
- */
-public class Sctl2018ObjectEntry extends AbstractSctlObjectEntry {
- @PacketField
- public SctlString path;
-
- @PacketField
- public SctlString key;
-
- @PacketField
- public SctlString kind;
-
- @PacketField
- public SctlString value;
-
- @PacketField
- public SctlString type;
-
- @Override
- public SctlString getPath() {
- return path;
- }
-
- @Override
- public void setPath(SctlString path) {
- this.path = path;
- }
-
- @Override
- public SctlString getKey() {
- return key;
- }
-
- @Override
- public void setKey(SctlString key) {
- this.key = key;
- }
-
- @Override
- public SctlString getKind() {
- return kind;
- }
-
- @Override
- public void setKind(SctlString kind) {
- this.kind = kind;
- }
-
- @Override
- public SctlString getValue() {
- return value;
- }
-
- @Override
- public void setValue(SctlString value) {
- this.value = value;
- }
-
- @Override
- public SctlString getType() {
- return type;
- }
-
- @Override
- public void setType(SctlString type) {
- this.type = type;
- }
-
-}
diff --git a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/v2018base/any/Sctl2018ProcessEntry.java b/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/v2018base/any/Sctl2018ProcessEntry.java
deleted file mode 100644
index be3ddb7487..0000000000
--- a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/v2018base/any/Sctl2018ProcessEntry.java
+++ /dev/null
@@ -1,76 +0,0 @@
-/* ###
- * 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 ghidra.dbg.sctl.protocol.v2018base.any;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import ghidra.comm.packet.annot.CountedByField;
-import ghidra.comm.packet.annot.RepeatedField;
-import ghidra.comm.packet.fields.PacketField;
-import ghidra.dbg.sctl.protocol.common.AbstractSctlProcessEntry;
-import ghidra.dbg.sctl.protocol.common.SctlString;
-
-/**
- * The format for each process of {@code bytes[]} of SCTL's {@code Rps} reply for Linux dialects
- */
-public class Sctl2018ProcessEntry extends AbstractSctlProcessEntry {
- @PacketField
- public long pid;
-
- @PacketField
- public SctlString cmd;
-
- @PacketField
- public long nt;
-
- @PacketField
- @RepeatedField
- @CountedByField("nt")
- public List<Sctl2018ThreadEntry> threads = new ArrayList<>();
-
- @Override
- public long getProcessID() {
- return pid;
- }
-
- @Override
- public void setProcessID(long pid) {
- this.pid = pid;
- }
-
- @Override
- public String getCommand() {
- return cmd.str;
- }
-
- @Override
- public void setCommand(String cmd) {
- this.cmd = new SctlString(cmd);
- }
-
- @Override
- public List<Sctl2018ThreadEntry> getThreads() {
- return threads;
- }
-
- @Override
- public Sctl2018ThreadEntry addThread() {
- Sctl2018ThreadEntry t = new Sctl2018ThreadEntry();
- threads.add(t);
- return t;
- }
-}
diff --git a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/v2018base/any/Sctl2018ProcessList.java b/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/v2018base/any/Sctl2018ProcessList.java
deleted file mode 100644
index 20673fd51b..0000000000
--- a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/v2018base/any/Sctl2018ProcessList.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/* ###
- * 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 ghidra.dbg.sctl.protocol.v2018base.any;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import ghidra.comm.packet.annot.CountedByField;
-import ghidra.comm.packet.annot.RepeatedField;
-import ghidra.comm.packet.fields.PacketField;
-import ghidra.dbg.sctl.protocol.common.AbstractSctlProcessList;
-
-/**
- * The format for {@code bytes[]} of SCTL's {@code Rps} reply for Linux dialects
- */
-public class Sctl2018ProcessList extends AbstractSctlProcessList {
- @PacketField
- public long ntarg;
-
- @PacketField
- @RepeatedField
- @CountedByField("ntarg")
- public List<Sctl2018ProcessEntry> processes = new ArrayList<>();
-
- @Override
- public List<Sctl2018ProcessEntry> getProcesses() {
- return processes;
- }
-
- @Override
- public Sctl2018ProcessEntry addProcess() {
- Sctl2018ProcessEntry proc = new Sctl2018ProcessEntry();
- processes.add(proc);
- return proc;
- }
-}
diff --git a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/v2018base/any/Sctl2018Region.java b/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/v2018base/any/Sctl2018Region.java
deleted file mode 100644
index fef80c64a4..0000000000
--- a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/v2018base/any/Sctl2018Region.java
+++ /dev/null
@@ -1,78 +0,0 @@
-/* ###
- * 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 ghidra.dbg.sctl.protocol.v2018base.any;
-
-import ghidra.comm.packet.annot.BitmaskEncoded;
-import ghidra.comm.packet.fields.PacketField;
-import ghidra.comm.util.BitmaskSet;
-import ghidra.dbg.sctl.client.SctlMemoryProtection;
-import ghidra.dbg.sctl.protocol.common.AbstractSctlRegion;
-import ghidra.dbg.sctl.protocol.common.SctlString;
-
-public class Sctl2018Region extends AbstractSctlRegion {
- @Override
- public void setName(String name) {
- this.name = new SctlString(name);
- }
-
- @Override
- public String getName() {
- return name.str;
- }
-
- @Override
- public void setAddress(long address) {
- this.addr = address;
- }
-
- @Override
- public long getAddress() {
- return addr;
- }
-
- @Override
- public void setLength(long length) {
- this.len = length;
- }
-
- @Override
- public long getLength() {
- return len;
- }
-
- @Override
- public void setProtections(BitmaskSet<SctlMemoryProtection> flags) {
- this.flags = flags;
- }
-
- @Override
- public BitmaskSet<SctlMemoryProtection> getProtections() {
- return flags;
- }
-
- @PacketField
- public SctlString name;
-
- @PacketField
- public long addr;
-
- @PacketField
- public long len;
-
- @PacketField
- @BitmaskEncoded(universe = SctlMemoryProtection.class)
- public BitmaskSet<SctlMemoryProtection> flags;
-}
diff --git a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/v2018base/any/Sctl2018Section.java b/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/v2018base/any/Sctl2018Section.java
deleted file mode 100644
index 0b739c6b5d..0000000000
--- a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/v2018base/any/Sctl2018Section.java
+++ /dev/null
@@ -1,61 +0,0 @@
-/* ###
- * 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 ghidra.dbg.sctl.protocol.v2018base.any;
-
-import ghidra.comm.packet.fields.PacketField;
-import ghidra.dbg.sctl.protocol.common.AbstractSctlSection;
-import ghidra.dbg.sctl.protocol.common.SctlString;
-
-public class Sctl2018Section extends AbstractSctlSection {
- @Override
- public void setAddress(long address) {
- this.addr = address;
- }
-
- @Override
- public long getAddress() {
- return addr;
- }
-
- @Override
- public void setLength(long length) {
- this.len = length;
- }
-
- @Override
- public long getLength() {
- return len;
- }
-
- @Override
- public void setName(String name) {
- this.name = new SctlString(name);
- }
-
- @Override
- public String getName() {
- return name.str;
- }
-
- @PacketField
- public long addr;
-
- @PacketField
- public long len;
-
- @PacketField
- public SctlString name;
-}
diff --git a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/v2018base/any/Sctl2018Status.java b/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/v2018base/any/Sctl2018Status.java
deleted file mode 100644
index 4e8d4a7142..0000000000
--- a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/v2018base/any/Sctl2018Status.java
+++ /dev/null
@@ -1,81 +0,0 @@
-/* ###
- * 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 ghidra.dbg.sctl.protocol.v2018base.any;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import ghidra.comm.packet.annot.CountedByField;
-import ghidra.comm.packet.annot.RepeatedField;
-import ghidra.comm.packet.fields.PacketField;
-import ghidra.dbg.sctl.protocol.common.AbstractSctlStatus;
-
-public class Sctl2018Status extends AbstractSctlStatus {
- @Override
- public boolean supportsProcessID() {
- return false;
- }
-
- @Override
- public void setProcessID(long pid) {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public long getProcessID() {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public Sctl2018Region addRegion() {
- Sctl2018Region r = new Sctl2018Region();
- regions.add(r);
- return r;
- }
-
- @Override
- public List<Sctl2018Region> getRegions() {
- return regions;
- }
-
- @Override
- public Sctl2018Binary addBinary() {
- Sctl2018Binary b = new Sctl2018Binary();
- bins.add(b);
- return b;
- }
-
- @Override
- public List<Sctl2018Binary> getBinaries() {
- return bins;
- }
-
- @PacketField
- public long nr;
-
- @PacketField
- @RepeatedField
- @CountedByField("nr")
- public List<Sctl2018Region> regions = new ArrayList<>();
-
- @PacketField
- public long nb;
-
- @PacketField
- @RepeatedField
- @CountedByField("nb")
- public List<Sctl2018Binary> bins = new ArrayList<>();
-}
diff --git a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/v2018base/any/Sctl2018ThreadEntry.java b/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/v2018base/any/Sctl2018ThreadEntry.java
deleted file mode 100644
index 32efb87bc3..0000000000
--- a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/v2018base/any/Sctl2018ThreadEntry.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/* ###
- * 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 ghidra.dbg.sctl.protocol.v2018base.any;
-
-import ghidra.comm.packet.fields.PacketField;
-import ghidra.dbg.sctl.protocol.common.AbstractSctlThreadEntry;
-
-/**
- * The format for each thread in SCTL's {@code Rps} for Linux dialects
- */
-public class Sctl2018ThreadEntry extends AbstractSctlThreadEntry {
- @PacketField
- public long tid;
-
- @Override
- public long getThreadID() {
- return tid;
- }
-
- @Override
- public void setThreadID(long tid) {
- this.tid = tid;
- }
-}
diff --git a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/v2018base/any/Sctl2018TrapSpec.java b/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/v2018base/any/Sctl2018TrapSpec.java
deleted file mode 100644
index 7755ad7e10..0000000000
--- a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/protocol/v2018base/any/Sctl2018TrapSpec.java
+++ /dev/null
@@ -1,178 +0,0 @@
-/* ###
- * 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 ghidra.dbg.sctl.protocol.v2018base.any;
-
-import ghidra.comm.packet.annot.BitmaskEncoded;
-import ghidra.comm.packet.fields.PacketField;
-import ghidra.comm.util.BitmaskSet;
-import ghidra.comm.util.BitmaskUniverse;
-import ghidra.dbg.sctl.protocol.common.AbstractSctlTrapSpec;
-
-public class Sctl2018TrapSpec extends AbstractSctlTrapSpec {
- public static final BitmaskSet<Flag> FLAGS_HARDWARE =
- BitmaskSet.of(Flag.TRAP_HR, Flag.TRAP_HW, Flag.TRAP_HX);
-
- public enum Flag implements BitmaskUniverse {
- /** Suspend execution when trapped */
- ACTION_STOP(0),
- /** Snapshot target when trapped */
- ACTION_SNAP(1 << 0),
- /** Trap on execute using a software breakpoint */
- TRAP_SW(0),
- /** Trap on read using a hardware breakpoint */
- TRAP_HR(1 << 1),
- /** Trap on write using a hardware breakpoint */
- TRAP_HW(1 << 2),
- /** Trap on execute using a hardware breakpoint */
- TRAP_HX(1 << 3);
-
- private final long mask;
-
- Flag(long mask) {
- this.mask = mask;
- }
-
- @Override
- public long getMask() {
- return mask;
- }
- }
-
- public Sctl2018TrapSpec() {
- }
-
- @Override
- public void setAddress(long addr) {
- this.addr = addr;
- }
-
- @Override
- public long getAddress() {
- return addr;
- }
-
- @Override
- public void setLength(long len) {
- this.len = len;
- }
-
- @Override
- public long getLength() {
- return len;
- }
-
- @Override
- public void setActionStop() {
- mode.remove(Flag.ACTION_SNAP);
- }
-
- @Override
- public boolean isActionStop() {
- return !mode.contains(Flag.ACTION_SNAP);
- }
-
- @Override
- public void setActionSnap() {
- mode.add(Flag.ACTION_SNAP);
- }
-
- @Override
- public boolean isActionSnap() {
- return mode.contains(Flag.ACTION_SNAP);
- }
-
- @Override
- public void setSoftwareExecute() {
- mode.removeAll(FLAGS_HARDWARE);
- }
-
- @Override
- public boolean isSoftwareExecute() {
- return !mode.containsAny(FLAGS_HARDWARE);
- }
-
- @Override
- public void setHardware(boolean read, boolean write, boolean execute) {
- if (read) {
- mode.add(Flag.TRAP_HR);
- }
- else {
- mode.remove(Flag.TRAP_HR);
- }
- if (write) {
- mode.add(Flag.TRAP_HW);
- }
- else {
- mode.remove(Flag.TRAP_HW);
- }
- if (execute) {
- mode.add(Flag.TRAP_HX);
- }
- else {
- mode.remove(Flag.TRAP_HX);
- }
- }
-
- @Override
- public boolean isHardware() {
- return mode.containsAny(FLAGS_HARDWARE);
- }
-
- @Override
- public boolean isHardwareRead() {
- return mode.contains(Flag.TRAP_HR);
- }
-
- @Override
- public boolean isHardwareWrite() {
- return mode.contains(Flag.TRAP_HW);
- }
-
- @Override
- public boolean isHardwareExecute() {
- return mode.contains(Flag.TRAP_HX);
- }
-
- /**
- * Flags identifying when to trap and what action to take
- *
- * Note that {@link Flag#ACTION_STOP} and {@link Flag#ACTION_SNAP} are mutually exclusive. Note
- * also, that {@link Flag#TRAP_SW} is mutually exclusive with the {@link Flag#TRAP_HR},
- * {@link Flag#TRAP_HW}, and {@link Flag#TRAP_HX} flags. The hardware trap flags may be used in
- * combination, and the server must accept such requests.
- */
- @PacketField
- @BitmaskEncoded(universe = Flag.class)
- public BitmaskSet<Flag> mode = BitmaskSet.of();
-
- /**
- * The address of the (start of) the trap
- *
- * Note that different platforms may place different restrictions on the address and length of
- * hardware traps.
- */
- @PacketField
- public long addr;
-
- /**
- * For hardware breakpoints, the length of the trap
- *
- * Note that different platforms may place different restrictions on the address and length of
- * hardware traps.
- */
- @PacketField
- public long len;
-}
diff --git a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/server/AbstractSctlClientHandler.java b/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/server/AbstractSctlClientHandler.java
deleted file mode 100644
index 03c209cf40..0000000000
--- a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/server/AbstractSctlClientHandler.java
+++ /dev/null
@@ -1,281 +0,0 @@
-/* ###
- * 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 ghidra.dbg.sctl.server;
-
-import static ghidra.async.AsyncUtils.loop;
-import static ghidra.async.AsyncUtils.sequence;
-
-import java.nio.channels.AsynchronousSocketChannel;
-import java.util.LinkedHashSet;
-import java.util.Set;
-import java.util.concurrent.CompletableFuture;
-
-import ghidra.async.*;
-import ghidra.comm.packet.AsynchronousPacketChannel;
-import ghidra.comm.service.AbstractAsyncClientHandler;
-import ghidra.dbg.sctl.client.err.SctlIncorrectVersionRequest;
-import ghidra.dbg.sctl.dialect.SctlDialect;
-import ghidra.dbg.sctl.dialect.SctlNullDialect;
-import ghidra.dbg.sctl.err.SctlError;
-import ghidra.dbg.sctl.protocol.*;
-import ghidra.dbg.sctl.protocol.common.reply.*;
-import ghidra.dbg.sctl.protocol.common.request.SctlPingRequest;
-import ghidra.dbg.sctl.protocol.common.request.SctlVersionRequest;
-import ghidra.dbg.sctl.protocol.consts.Mkind;
-import ghidra.dbg.util.HandlerMap;
-import ghidra.util.Msg;
-
-/**
- * A base class for SCTL servers to handle a single client
- *
- * This is a bare-bones base class for handling SCTL clients on the server side. This instantiates
- * the marshaller, creates a handler map, and provides version/dialect negotiation and ping response
- * logic. If any exception is thrown in a handler, it automatically produces a {@code Rerror}
- * response. Throwing a {@code SctlError} provides the given message verbatim. Any other exception
- * will include the exception class name in the transmitted response, and it will log a stacktrace.
- *
- * This class anticipates supporting a single dialect. If that is not the case, the implementor must
- * override {@link #processVersion(SctlVersionRequest, int)} or provide an alternative handler for
- * {@link SctlVersionRequest}.
- */
-public abstract class AbstractSctlClientHandler
- extends AbstractAsyncClientHandler<AbstractSctlServer, AbstractSctlClientHandler> {
- private static final boolean PRINT_STACK_TRACES_FOR_ERROR_REPLIES = true;
- protected final AsynchronousPacketChannel<AbstractSelSctlPacket, AbstractSelSctlPacket> channel;
- private final SctlMarshaller marshaller;
- private SctlDialect dialect = SctlDialect.NULL_DIALECT;
-
- protected final HandlerMap<AbstractSctlRequest, Integer, CompletableFuture<Void>> handlerMap =
- new HandlerMap<>();
-
- /**
- * Create a new SCTL client handler with the given server
- *
- * @param server the server handling the client
- * @param sock a connection to the client
- */
- public AbstractSctlClientHandler(AbstractSctlServer server, AsynchronousSocketChannel sock) {
- super(server, sock);
- marshaller = new SctlMarshaller();
- marshaller.setPacketFactory(dialect.getPacketFactory());
- channel = new AsynchronousPacketChannel<>(sock, marshaller);
-
- defaultHandlers();
- }
-
- /**
- * Get the dialects known to the server, in order of preference
- *
- * NOTE: Use {@link LinkedHashSet} to control the order
- *
- * @return the ordered set of known dialects
- */
- protected abstract Set<SctlDialect> getKnownDialects();
-
- /**
- * Choose the dialect for this handler from those offered by the client
- *
- * Ordinarily, every dialect offered by the client is provided in the {@code supported} set. If
- * another client is connected and completed negotiation, then the set can only contain the
- * current dialect. If the client does not offer the same dialect, the client will be rejected.
- * Override {@link #chooseDialect(String)} to change that behavior.
- *
- * By default, this implementation will take the intersection of supported dialects and the set
- * returned by {@link #getKnownDialects()}, taking the most-preferred dialect. Note that the set
- * of dialects known to this server is typically a subset of those known to the SCTL framework.
- *
- * @param supported the dialects supported by the client and the SCTL framework
- * @return the chosen dialect
- * @throws SctlError if the server cannot support the client
- */
- protected SctlDialect chooseDialect(Set<SctlDialect> supported) {
- for (SctlDialect preferred : getKnownDialects()) {
- if (supported.contains(preferred)) {
- return preferred;
- }
- }
- throw new SctlError("Server does not support any offered dialects.");
- }
-
- /**
- * Choose the dialect for this handler from the version string in the client's request
- *
- * It is preferred that you override {@link #chooseDialect(Set)} or {@link #getKnownDialects()}.
- *
- * @param offered the version string presented by the client, including the ctl version
- * @return the chosen dialect
- * @throws SctlError if the server cannot support the client
- */
- protected SctlDialect chooseDialect(String offered) {
- Set<SctlDialect> supported = SctlVersionInfo.collectSupported(offered);
- SctlDialect curDialect = server.getDialect();
- if (curDialect != SctlDialect.NULL_DIALECT) {
- if (!supported.contains(curDialect)) {
- throw new SctlIncorrectVersionRequest(
- "Client does not support the version active on the bus: " +
- curDialect.getFullVersion());
- }
- supported.clear();
- supported.add(curDialect);
- // Pass it through chooseDialect instead of returning it
- // May not be necessary, but at least gives the implementation a chance
- }
- return chooseDialect(supported);
- }
-
- /**
- * Get the chosen dialect, or the {@link SctlNullDialect} if still negotiating
- *
- * @return the current dialect
- */
- protected SctlDialect getDialect() {
- return dialect;
- }
-
- /**
- * Install the basic request handlers
- *
- * The client handler uses the {@link HandlerMap} utility to match each packet type to its
- * respective handler. This implementation provides handlers for {@link Mkind#Tversion} and
- * {@code Tping}. More than likely, an implementor should override this method, but call the
- * superclass's method immediately. The overriding method can then modify the handler map
- * freely.
- *
- * All handlers have nearly the same signature:
- *
- * <pre>
- * CompletableFuture<Void> processX(X req, int tag)
- * </pre>
- *
- * The handler is called upon receiving a request having exactly type {@code X} (not a subtype).
- * The tag is given as the extra argument. The handler must immediately return (no blocking on
- * {@code send}) a future which completes when the reply has been sent. Please use
- * {@link #reply(AsyncLock.Hold, int, SctlPacket)}. This satisfies the requirement to return
- * immediately, and it ensures all clients receive a copy of the reply.
- */
- protected void defaultHandlers() {
- handlerMap.put(SctlVersionRequest.class, this::processVersion);
- handlerMap.put(SctlPingRequest.class, this::processPing);
- }
-
- /**
- * Upon receiving a {@link Mkind#Tversion} request, negotiate the version for the connection
- *
- * @param req the request
- * @param tag the tag of the request
- * @return a future which completes when the {@link Mkind#Rversion} reply has been sent
- */
- protected CompletableFuture<Void> processVersion(SctlVersionRequest req, int tag) {
- SctlDialect newDialect = chooseDialect(req.version);
- server.setDialect(newDialect);
- marshaller.setPacketFactory(newDialect.getPacketFactory());
- dialect = newDialect;
- return reply(null, tag, new SctlVersionReply(newDialect.getFullVersion()));
- }
-
- /**
- * Respond to a {@code Tping} request
- *
- * @param req the request
- * @param tag the tag of the request
- * @return a future which completes when the {@link Mkind#Rping} reply has been sent
- */
- protected CompletableFuture<Void> processPing(SctlPingRequest req, int tag) {
- return reply(null, tag, new SctlPingReply(req.bytes.length));
- }
-
- /**
- * Send an error reply for a tag and given throwable
- *
- * Implementors should not call this method directly. Throwing an exception, particularly a
- * {@link SctlError}, from within a handler will cause the handler to send an error response
- * using this method.
- *
- * @param tag the tag of the request causing the exception
- * @param e the error the request caused
- * @return a future which completes when the {@link Mkind#Rerror} reply has been sent
- */
- protected CompletableFuture<Void> replyErr(int tag, Throwable e) {
- Throwable t = AsyncUtils.unwrapThrowable(e);
- String msg;
- if (t instanceof SctlError) {
- msg = t.getMessage();
- }
- else {
- if (PRINT_STACK_TRACES_FOR_ERROR_REPLIES) {
- Msg.debug(this, "Error caused by request " + tag, e);
- }
- else {
- Msg.debug(this, "Error caused by request " + tag + ": " + e);
- }
- msg = t.getClass() + ": " + t.getMessage();
- }
- // TODO: Should this subvert the server's sendLock?
- return reply(null, tag, new SctlErrorReply(msg));
- }
-
- @Override
- protected CompletableFuture<Void> launchAsync() {
- return loop(TypeSpec.VOID, (loop) -> {
- if (sock.isOpen()) {
- channel.read(AbstractSelSctlPacket.class).handle(loop::consume);
- }
- else {
- server.removeHandler(this);
- loop.exit();
- }
- }, TypeSpec.cls(AbstractSelSctlPacket.class), (pkt, loop) -> {
- loop.repeat();
- sequence(TypeSpec.VOID).then((seq) -> {
- server.broadcast(null, pkt, this).handle(seq::next);
- }).then((seq) -> {
- if (pkt.sel instanceof AbstractSctlRequest) {
- handlerMap.handle((AbstractSctlRequest) pkt.sel, pkt.tag).handle(seq::next);
- }
- else {
- throw new SctlError("Client can only send requests.");
- }
- }).finish().exceptionally((e) -> {
- replyErr(pkt.tag, e).exceptionally((ee) -> {
- Msg.error(this, "Could not send error reply: " + ee);
- return null;
- });
- return null;
- });
- });
- }
-
- /**
- * Send a reply to a request
- *
- * The reply is broadcast to all connected clients. To ensure that replies are sent in order, a
- * handler may acquire the server's send lock outside of this method.
- *
- * @param hold a hold on the server's send lock, if applicable, to reenter
- * @param tag the tag of the request to which this reply corresponds
- * @param reply the reply to send
- * @return a future which completes when the reply has been sent
- */
- protected CompletableFuture<Void> reply(AsyncLock.Hold hold, int tag, AbstractSctlReply reply) {
- AbstractSelSctlPacket pkt = dialect.createSel(tag, reply);
- return server.sendLock.with(TypeSpec.VOID, hold).then((newHold, seq) -> {
- AsyncFence fence = new AsyncFence();
- fence.include(channel.write(pkt));
- fence.include(server.broadcast(newHold, pkt, this));
- fence.ready().handle(seq::nextIgnore);
- }).finish();
- }
-}
diff --git a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/server/AbstractSctlServer.java b/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/server/AbstractSctlServer.java
deleted file mode 100644
index 33625c9d41..0000000000
--- a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/server/AbstractSctlServer.java
+++ /dev/null
@@ -1,155 +0,0 @@
-/* ###
- * 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 ghidra.dbg.sctl.server;
-
-import java.io.IOException;
-import java.net.SocketAddress;
-import java.nio.channels.AsynchronousSocketChannel;
-import java.util.concurrent.CompletableFuture;
-import java.util.concurrent.CompletionException;
-
-import ghidra.async.AsyncLock;
-import ghidra.async.TypeSpec;
-import ghidra.comm.service.AbstractAsyncServer;
-import ghidra.comm.util.BitmaskSet;
-import ghidra.dbg.sctl.dialect.SctlDialect;
-import ghidra.dbg.sctl.protocol.AbstractSelSctlPacket;
-import ghidra.dbg.sctl.protocol.common.notify.AbstractSctlEventNotification;
-import ghidra.dbg.sctl.protocol.common.notify.SctlEventNotify;
-import ghidra.dbg.sctl.protocol.consts.Evkind;
-import ghidra.util.Msg;
-
-/**
- * A base class for SCTL servers
- *
- * This class and the base {@link AbstractSctlClientHandler} implement all of the socket operations,
- * message parsing, message forwarding, etc., of a SCTL-bus-compliant server. Implementors need only
- * override {@link #newHandler(AsynchronousSocketChannel)} to provide a concrete handler. The
- * handler implementation is where all of the message processing occurs.
- */
-public abstract class AbstractSctlServer
- extends AbstractAsyncServer<AbstractSctlServer, AbstractSctlClientHandler> {
- private SctlDialect activeDialect = SctlDialect.NULL_DIALECT;
-
- public final AsyncLock sendLock = new AsyncLock();
-
- /**
- * Start a SCTL server bound to the given address
- *
- * @param addr the socket address to bind
- * @throws IOException if the socket bind or listen fails
- */
- public AbstractSctlServer(SocketAddress addr) throws IOException {
- super(addr);
- }
-
- @Override
- protected void removeHandler(AbstractSctlClientHandler handler) {
- super.removeHandler(handler);
- if (handlers.isEmpty()) {
- // Allow another client to freely re-negotiate.
- activeDialect = SctlDialect.NULL_DIALECT;
- }
- }
-
- protected void setDialect(SctlDialect dialect) {
- if (activeDialect != SctlDialect.NULL_DIALECT && dialect != activeDialect) {
- throw new IllegalStateException("Server cannot speak multiple dialects on the bus");
- }
- activeDialect = dialect;
- }
-
- protected SctlDialect getDialect() {
- return activeDialect;
- }
-
- @Override
- protected boolean checkAcceptable(AsynchronousSocketChannel sock) {
- if (!handlers.isEmpty() && activeDialect != SctlDialect.NULL_DIALECT &&
- !activeDialect.isBusSupported()) {
- Msg.error(this, "Rejected connection. Current client is not bus aware.");
- return false;
- }
- return true;
- }
-
- protected CompletableFuture<Integer> sendTo(AbstractSctlClientHandler to,
- AbstractSelSctlPacket pkt) {
- return to.channel.write(pkt).exceptionally((exc) -> {
- if (exc instanceof CompletionException) {
- exc = exc.getCause();
- }
- if (exc instanceof IOException) {
- Msg.info(this, "Send failed: " + exc.getMessage() +
- ". Probably the client closed the connection");
- removeHandler(to);
- }
- else {
- Msg.error(this, "Send failed for unknown reason", exc);
- }
- return null;
- });
- }
-
- /**
- * Broadcast a message to all clients except an optional source
- *
- * To ensure replies are sent in order, a handler may acquire the server's send lock outside of
- * this method.
- *
- * @param hold a hold on the server's send lock, if applicable, to reenter
- * @param pkt the packet to broadcast
- * @param from the source client, if applicable, to exclude from the broadcast
- * @return a future which completes when the packet has been sent
- */
- protected CompletableFuture<Void> broadcast(AsyncLock.Hold hold, AbstractSelSctlPacket pkt,
- AbstractSctlClientHandler from) {
- return sendLock.with(TypeSpec.VOID, hold).then((newHold, seq) -> allHandlers(to -> {
- if (to == from) {
- return null;
- }
- return sendTo(to, pkt);
- }).handle(seq::exit)).finish();
- }
-
- /**
- * Broadcast a notification to all clients about a thread event
- *
- * @param hold a hold on the server's send lock, if applicable, to reenter
- * @param ctlid the CTLID of the thread producing the event
- * @param notification the notification about the event
- * @return a future which completes when the notification has been sent
- */
- public CompletableFuture<Void> notify(AsyncLock.Hold hold, long ctlid,
- AbstractSctlEventNotification notification) {
- return notify(hold, ctlid, notification, BitmaskSet.of());
- }
-
- /**
- * Broadcast a notification with extra flags to all clients about a thread event
- *
- * @param hold a hold on the server's send lock, if applicable, to reenter
- * @param ctlid the CTLID of the thread producing the event
- * @param notification the notification about the event
- * @param addFlags the extra (non-event) flags to include
- * @return a future which completes when the notification has been sent
- */
- public CompletableFuture<Void> notify(AsyncLock.Hold hold, long ctlid,
- AbstractSctlEventNotification notification, BitmaskSet<Evkind> addFlags) {
- return broadcast(hold,
- activeDialect.createSel(0, new SctlEventNotify(ctlid, notification, addFlags)), null);
- }
-}
diff --git a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/server/SctlSyntheticClient.java b/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/server/SctlSyntheticClient.java
deleted file mode 100644
index 4f85ae2f86..0000000000
--- a/Ghidra/Debug/Debugger-sctl/src/main/java/ghidra/dbg/sctl/server/SctlSyntheticClient.java
+++ /dev/null
@@ -1,208 +0,0 @@
-/* ###
- * 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 ghidra.dbg.sctl.server;
-
-import java.util.List;
-
-import org.apache.commons.lang3.StringUtils;
-
-import ghidra.async.AsyncLock;
-import ghidra.dbg.sctl.client.SctlTargetObject;
-import ghidra.dbg.sctl.dialect.SctlDialect;
-import ghidra.dbg.sctl.protocol.common.AbstractSctlContext;
-import ghidra.dbg.sctl.protocol.common.AbstractSctlTrapSpec;
-import ghidra.dbg.sctl.protocol.common.reply.*;
-import ghidra.dbg.sctl.protocol.common.request.*;
-import ghidra.dbg.sctl.protocol.v2018base.*;
-
-public class SctlSyntheticClient {
- private final AbstractSctlServer server;
-
- private final byte busId;
- private int tagPart = 0;
-
- public SctlSyntheticClient(AbstractSctlServer server, byte busId) {
- this.server = server;
- this.busId = busId;
- }
-
- /**
- * Generate a tag for the synthesized client
- *
- * @return
- */
- public int tag() {
- int tag = (busId << 24) | tagPart;
- tagPart++;
- tagPart %= 0x00ffffff;
- return tag;
- }
-
- /**
- * Synthesize an attach command
- *
- * @param hold an optional hold for re-entry
- * @param pid the PID of the target process
- * @param ctlid the CTLID for the response
- * @param ctx the context for the response
- */
- public void synthAttach(AsyncLock.Hold hold, long pid, long ctlid, String platform,
- AbstractSctlContext ctx) {
- int tag = tag();
- SctlDialect dialect = server.getDialect();
- server.broadcast(hold, dialect.createSel(tag, new SctlAttachRequest(pid)), null);
- AbstractSctlAttachReply reply = dialect.create(AbstractSctlAttachReply.class);
- reply.ctlid = ctlid;
- reply.ctx = ctx;
- if (reply.supportsPlatform()) {
- reply.setPlatform(platform);
- }
- server.broadcast(hold, dialect.createSel(tag, reply), null);
- }
-
- /**
- * Synthesize a detach command
- *
- * @param hold an optional hold for re-entry
- * @param ctlid the CTLID for the command
- */
- public void synthDetach(AsyncLock.Hold hold, long ctlid) {
- int tag = tag();
- SctlDialect dialect = server.getDialect();
- server.broadcast(hold, dialect.createSel(tag, new SctlDetachRequest(ctlid)), null);
- server.broadcast(hold, dialect.createSel(tag, new SctlDetachReply()), null);
- }
-
- /**
- * Synthesize a continue command
- *
- * @param hold an optional hold for re-entry
- * @param ctlid the CTLID for the command
- */
- public void synthContinue(AsyncLock.Hold hold, long ctlid) {
- int tag = tag();
- SctlDialect dialect = server.getDialect();
- server.broadcast(hold, dialect.createSel(tag, new SctlContinueRequest(ctlid)), null);
- server.broadcast(hold, dialect.createSel(tag, new SctlContinueReply()), null);
- }
-
- /**
- * Synthesize a stop command
- *
- * @param hold an optional hold for re-entry
- * @param ctlid the CTLID for the command
- * @param ctx the context to include in the synthesized reply
- */
- public void synthStop(AsyncLock.Hold hold, long ctlid, AbstractSctlContext ctx) {
- int tag = tag();
- SctlDialect dialect = server.getDialect();
- server.broadcast(hold, dialect.createSel(tag, new SctlStopRequest(ctlid)), null);
- server.broadcast(hold, dialect.createSel(tag, new SctlStopReply(ctx)), null);
- }
-
- /**
- * Synthesize a kill command
- *
- * @param hold an optional hold for re-entry
- * @param ctlid the CTLID for the command
- */
- public void synthKill(AsyncLock.Hold hold, long ctlid) {
- int tag = tag();
- SctlDialect dialect = server.getDialect();
- server.broadcast(hold, dialect.createSel(tag, new SctlKillRequest(ctlid)), null);
- server.broadcast(hold, dialect.createSel(tag, new SctlKillReply()), null);
- }
-
- /**
- * Synthesize a focus command
- *
- * @param hold an optional hold for re-entry
- * @param ctlid the CTLID for the command
- */
- public void synthFocus(AsyncLock.Hold hold, int ctlid) {
- int tag = tag();
- SctlDialect dialect = server.getDialect();
- server.broadcast(hold, dialect.createSel(tag, new SctlFocusRequest(ctlid)), null);
- server.broadcast(hold, dialect.createSel(tag, new SctlFocusReply()), null);
- }
-
- /**
- * Synthesize a set trap command
- *
- * @param hold an optional hold for re-entry
- * @param ctlid the CTLID for the command
- * @param spec the trap specification for the command
- * @param trpid the TRPID for the response
- */
- public void synthSetTrap(AsyncLock.Hold hold, long ctlid, AbstractSctlTrapSpec spec,
- long trpid) {
- int tag = tag();
- SctlDialect dialect = server.getDialect();
- //Msg.debug(this, "Synthesizing set trap thread=" + threadId + ",trap=" + trapId);
- server.broadcast(hold, dialect.createSel(tag, new SctlSetTrapRequest(ctlid, spec)), null);
- server.broadcast(hold, dialect.createSel(tag, new SctlSetTrapReply(trpid)), null);
- }
-
- /**
- * Synthesize a clear trap command
- *
- * @param hold an optional hold for re-entry
- * @param ctlid the CTLID for the command
- * @param trpid the TRPID for the command
- */
- public void synthClearTrap(AsyncLock.Hold hold, long ctlid, long trpid) {
- int tag = tag();
- SctlDialect dialect = server.getDialect();
- //Msg.debug(this, "Synthesizing clear trap thread=" + threadId + ",trap=" + trapId);
- server.broadcast(hold, dialect.createSel(tag, new SctlClearTrapRequest(ctlid, trpid)),
- null);
- server.broadcast(hold, dialect.createSel(tag, new SctlClearTrapReply()), null);
- }
-
- /**
- * Synthesize a get children command
- *
- * @param hold an optional hold for re-entry
- * @param path the tree path identifying the object
- */
- // TODO: It'd be better to use an event than command synthesis here
- public void synthGetChildren(AsyncLock.Hold hold, List<String> path) {
- int tag = tag();
- SctlDialect dialect = server.getDialect();
- //Msg.debug(this, "Synthesizing clear trap thread=" + threadId + ",trap=" + trapId);
- String joinedPath = StringUtils.join(path, SctlTargetObject.PATH_SEPARATOR_STRING);
- server.broadcast(hold, dialect.createSel(tag, new SctlGetElementsRequest(joinedPath)),
- null);
- server.broadcast(hold, dialect.createSel(tag, new SctlGetElementsReply()), null);
- }
-
- /**
- * Synthesize a get attributes command
- *
- * @param hold an optional hold for re-entry
- * @param path the tree path identifying the object
- */
- // TODO: It'd be better to use an event than command synthesis here
- public void synthGetAttributes(AsyncLock.Hold hold, List<String> path) {
- int tag = tag();
- SctlDialect dialect = server.getDialect();
- //Msg.debug(this, "Synthesizing clear trap thread=" + threadId + ",trap=" + trapId);
- String joinedPath = StringUtils.join(path, SctlTargetObject.PATH_SEPARATOR_STRING);
- server.broadcast(hold, dialect.createSel(tag, new SctlGetAttributesRequest(joinedPath)),
- null);
- server.broadcast(hold, dialect.createSel(tag, new SctlGetAttributesReply()), null);
- }
-}
diff --git a/Ghidra/Debug/Debugger-sctl/src/test/java/ghidra/dbg/sctl/client/SctlClientTest.java b/Ghidra/Debug/Debugger-sctl/src/test/java/ghidra/dbg/sctl/client/SctlClientTest.java
deleted file mode 100644
index d9514973f0..0000000000
--- a/Ghidra/Debug/Debugger-sctl/src/test/java/ghidra/dbg/sctl/client/SctlClientTest.java
+++ /dev/null
@@ -1,380 +0,0 @@
-/* ###
- * 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 ghidra.dbg.sctl.client;
-
-import static ghidra.async.AsyncUtils.completable;
-import static ghidra.async.AsyncUtils.sequence;
-import static org.junit.Assert.assertEquals;
-
-import java.io.IOException;
-import java.net.InetSocketAddress;
-import java.nio.BufferUnderflowException;
-import java.nio.ByteBuffer;
-import java.nio.channels.*;
-import java.util.ArrayList;
-import java.util.Random;
-import java.util.concurrent.*;
-import java.util.concurrent.atomic.AtomicReference;
-
-import org.apache.commons.lang3.exception.ExceptionUtils;
-import org.junit.Test;
-
-import ghidra.async.AsyncFence;
-import ghidra.async.TypeSpec;
-import ghidra.comm.packet.binary.ByteBufferPacketCodec;
-import ghidra.comm.packet.err.PacketDecodeException;
-import ghidra.comm.packet.err.PacketEncodeException;
-import ghidra.dbg.DebuggerObjectModel;
-import ghidra.dbg.attributes.TypedTargetObjectRef;
-import ghidra.dbg.sctl.dialect.SctlDialect;
-import ghidra.dbg.sctl.protocol.*;
-import ghidra.dbg.sctl.protocol.common.reply.*;
-import ghidra.dbg.sctl.protocol.common.request.*;
-import ghidra.dbg.sctl.protocol.v2012base.x86.SctlX86Context;
-import ghidra.dbg.sctl.protocol.v2012base.x86.linux.Sctl2012LinuxStatus;
-import ghidra.dbg.target.*;
-import ghidra.dbg.util.PathUtils;
-import ghidra.util.Msg;
-import ghidra.util.SystemUtilities;
-
-public class SctlClientTest {
- private static final String DEFAULT_PROTOCOL_VERSION = "sctl-2012:x86-linux-2012";
- private static final String EXPECT_VERSIONS =
- "sctl-2012:any-any-2018,x86-linux-2012-bus,x86-win-2012-bus,x86-linux-2012,x86-win-2012";
- private static final long TIMEOUT_MILLISECONDS =
- SystemUtilities.isInTestingBatchMode() ? 1000 : Long.MAX_VALUE;
-
- protected static <T> T waitOn(TestServerThread srv, CompletableFuture<T> future)
- throws Throwable {
- try {
- AsyncFence fence = new AsyncFence();
- fence.include(srv);
- fence.include(future.exceptionally(exc -> {
- // Cheating, but I want to see the real exception
- srv.completeExceptionally(exc); // srv.cancel(true);
- return ExceptionUtils.rethrow(exc);
- }));
- fence.ready().get(TIMEOUT_MILLISECONDS, TimeUnit.MILLISECONDS);
- return future.getNow(null);
- }
- catch (ExecutionException e) {
- throw e.getCause();
- }
- }
-
- interface TestClientHandler {
- void handle(SocketChannel cli, SctlDialect dialect) throws Exception;
- }
-
- class TestServerThread extends CompletableFuture<Void> implements AutoCloseable {
- private final TestClientHandler handler;
- private final int port;
- private final String version;
- private final SctlDialect dialect;
- private final Thread thread;
-
- public TestServerThread(TestClientHandler handler, int port, String version) {
- this.handler = handler;
- this.port = port;
- this.version = version;
- this.dialect = SctlVersionInfo.agreeDialect(version);
- this.thread = new Thread(this::run);
- }
-
- @Override
- public void close() throws Exception {
- thread.interrupt();
- thread.join(500);
- }
-
- private void run() {
- try (ServerSocketChannel srv = ServerSocketChannel.open()) {
- synchronized (this) {
- srv.bind(new InetSocketAddress("localhost", port));
- notifyAll();
- }
- SocketChannel cli = srv.accept();
- handleVersion(cli, version);
- handler.handle(cli, dialect);
- complete(null);
- }
- catch (ClosedByInterruptException e) {
- complete(null);
- return;
- }
- catch (Throwable e) {
- completeExceptionally(e);
- e.printStackTrace();
- }
- }
-
- public void start() {
- thread.start();
- }
- }
-
- private static final String HELLO_WORLD = "Hello, World!";
-
- private static final String TEST_HOST = "localhost";
- private static int PORT = new Random().nextInt(2000) + 1024;
- private static InetSocketAddress ADDR;
-
- private static final int TEST_CTLID = 1234;
- private static final int TEST_PID = 5678;
-
- private final SctlMarshaller marshaller = new SctlMarshaller();
- private final ByteBuffer inbuf = ByteBuffer.allocate(1024);
- private final ByteBuffer outbuf = ByteBuffer.allocate(1024);
-
- protected void expect(SocketChannel cli, SctlDialect dialect, AbstractSelSctlPacket pkt)
- throws IOException, PacketDecodeException, PacketEncodeException {
- // Ensure the packet can be encoded, and initialize meta fields
- Msg.trace(this, "Expecting: " + pkt);
- marshaller.setPacketFactory(dialect.getPacketFactory());
- ByteBufferPacketCodec.getInstance().encodePacket(pkt);
-
- // Now, receive the expected packet
- while (true) {
- try {
- inbuf.flip();
- AbstractSelSctlPacket recv = marshaller.unmarshall(inbuf);
- inbuf.compact();
-
- Msg.debug(this, "Server Received: " + recv);
- assertEquals(pkt, recv);
- return;
- }
- catch (BufferUnderflowException e) {
- inbuf.compact();
- Msg.trace(this, "Waiting for data. Currently have " + inbuf.position());
- if (Thread.interrupted()) {
- return;
- }
- int len = cli.read(inbuf);
- Msg.trace(this, "Read " + len + " bytes");
- }
- }
- }
-
- protected void handleAttach(SocketChannel cli, SctlDialect dialect, int tag)
- throws IOException, PacketDecodeException, PacketEncodeException {
- expect(cli, dialect, dialect.createSel(tag, new SctlAttachRequest(TEST_PID)));
- SctlX86Context ctx = new SctlX86Context();
- ctx.rax = 0x1122334455667788L;
- AbstractSctlAttachReply reply = dialect.create(AbstractSctlAttachReply.class);
- reply.ctlid = TEST_CTLID;
- reply.ctx = ctx;
- send(cli, dialect, dialect.createSel(tag, reply));
- }
-
- protected void handleStat(SocketChannel cli, SctlDialect dialect, int tag)
- throws IOException, PacketDecodeException, PacketEncodeException {
- expect(cli, dialect, dialect.createSel(tag, new SctlStatusRequest(TEST_CTLID)));
- SctlStatusReply reply = new SctlStatusReply();
- Sctl2012LinuxStatus status = new Sctl2012LinuxStatus();
- reply.status = status;
- status.pid = TEST_PID;
- status.bins = new ArrayList<>();
- status.regions = new ArrayList<>();
- send(cli, dialect, dialect.createSel(tag, reply));
- }
-
- protected void handleContinue(SocketChannel cli, SctlDialect dialect, int tag)
- throws IOException, PacketDecodeException, PacketEncodeException {
- expect(cli, dialect, dialect.createSel(tag, new SctlContinueRequest(TEST_CTLID)));
- send(cli, dialect, dialect.createSel(tag, new SctlContinueReply()));
- }
-
- protected void handleDetach(SocketChannel cli, SctlDialect dialect, int tag)
- throws IOException, PacketDecodeException, PacketEncodeException {
- expect(cli, dialect, dialect.createSel(tag, new SctlDetachRequest(TEST_CTLID)));
- send(cli, dialect, dialect.createSel(tag, new SctlDetachReply()));
- }
-
- protected void handlePing(SocketChannel cli, SctlDialect dialect, int tag)
- throws IOException, PacketDecodeException, PacketEncodeException {
- expect(cli, dialect, dialect.createSel(tag, new SctlPingRequest(HELLO_WORLD)));
- send(cli, dialect,
- dialect.createSel(tag, new SctlPingReply(HELLO_WORLD.getBytes().length)));
- }
-
- protected void handleVersion(SocketChannel cli, String version)
- throws IOException, PacketDecodeException, PacketEncodeException {
- SctlDialect dialect = SctlDialect.NULL_DIALECT;
- expect(cli, dialect, dialect.createSel(0, new SctlVersionRequest(EXPECT_VERSIONS)));
- send(cli, dialect, dialect.createSel(0, new SctlVersionReply(version)));
- }
-
- protected TestServerThread runServer(TestClientHandler handler) throws InterruptedException {
- return runServer(handler, DEFAULT_PROTOCOL_VERSION);
- }
-
- protected TestServerThread runServer(TestClientHandler handler, String version)
- throws InterruptedException {
- PORT++;
- ADDR = new InetSocketAddress(TEST_HOST, PORT);
- TestServerThread result = new TestServerThread(handler, PORT, version);
- result.start();
- synchronized (result) {
- result.wait();
- }
- return result;
- }
-
- protected void send(SocketChannel cli, SctlDialect dialect, AbstractSelSctlPacket pkt)
- throws PacketEncodeException, IOException {
- Msg.debug(this, "Server Sending: " + pkt);
- marshaller.setPacketFactory(dialect.getPacketFactory());
- marshaller.marshall(outbuf, pkt);
- outbuf.flip();
- while (outbuf.hasRemaining()) {
- if (Thread.interrupted()) {
- return;
- }
- cli.write(outbuf);
- }
- outbuf.clear();
- }
-
- protected void seqAttachContinueDetach(SocketChannel cli, SctlDialect dialect)
- throws IOException, PacketDecodeException, PacketEncodeException {
- handleAttach(cli, dialect, 1);
- handleStat(cli, dialect, 2);
- handleContinue(cli, dialect, 3);
- handleDetach(cli, dialect, 4);
- }
-
- private static String keyInt(int i) {
- return PathUtils.makeKey(PathUtils.makeIndex(i));
- }
-
- private static TypedTargetObjectRef<? extends TargetAttachable<?>> refPid(
- DebuggerObjectModel model, int pid) {
- return model.createRef("Attachable", keyInt(pid)).as(TargetAttachable.tclass);
- }
-
- @Test
- public void testAttachContinueDetach() throws Throwable {
- try (TestServerThread srv = runServer(this::seqAttachContinueDetach)) {
- AsynchronousSocketChannel socket = AsynchronousSocketChannel.open();
- SctlClient client = new SctlClient("Test", socket);
- AtomicReference<TargetObject> root = new AtomicReference<>();
- AtomicReference<TargetObject> thread = new AtomicReference<>();
- waitOn(srv, sequence(TypeSpec.VOID).then(seq -> {
- completable(TypeSpec.VOID, socket::connect, ADDR).handle(seq::next);
- }).then(seq -> {
- Msg.debug(this, "Connecting");
- client.connect().handle(seq::next);
- }).then(seq -> {
- Msg.debug(this, "Getting model root");
- client.fetchModelRoot().handle(seq::next);
- }, root).then(seq -> {
- Msg.debug(this, "Attaching");
- TargetAttacher<?> attacher = root.get().as(TargetAttacher.tclass);
- attacher.attach(refPid(client, TEST_PID)).handle(seq::nextIgnore);
- }).then(seq -> {
- Msg.debug(this, "Getting created thread");
- client.fetchModelObject("Processes", keyInt(TEST_CTLID), "Threads",
- keyInt(TEST_CTLID)).handle(seq::next);
- }, thread).then(seq -> {
- Msg.debug(this, "Continuing");
- TargetResumable<?> resumable = thread.get().as(TargetResumable.tclass);
- resumable.resume().handle(seq::next);
- }).then(seq -> {
- Msg.debug(this, "Detaching");
- TargetDetachable<?> detachable = thread.get().as(TargetDetachable.tclass);
- detachable.detach().handle(seq::next);
- }).then(seq -> {
- Msg.debug(this, "Disconnecting");
- client.close().handle(seq::next);
- }).finish());
- socket.close();
- }
- }
-
- protected void seqAttachDetach(SocketChannel cli, SctlDialect dialect)
- throws IOException, PacketDecodeException, PacketEncodeException {
- handleAttach(cli, dialect, 1);
- handleStat(cli, dialect, 2);
- handleDetach(cli, dialect, 3);
- }
-
- @Test
- public void testAttachDetach() throws Throwable {
- try (TestServerThread srv = runServer(this::seqAttachDetach)) {
- AsynchronousSocketChannel socket = AsynchronousSocketChannel.open();
- SctlClient client = new SctlClient("Test", socket);
- AtomicReference<TargetObject> root = new AtomicReference<>();
- AtomicReference<TargetObject> thread = new AtomicReference<>();
- waitOn(srv, sequence(TypeSpec.VOID).then(seq -> {
- completable(TypeSpec.VOID, socket::connect, ADDR).handle(seq::next);
- }).then(seq -> {
- Msg.debug(this, "Connecting");
- client.connect().handle(seq::next);
- }).then(seq -> {
- Msg.debug(this, "Getting model root");
- client.fetchModelRoot().handle(seq::next);
- }, root).then(seq -> {
- Msg.debug(this, "Attaching");
- TargetAttacher<?> attacher = root.get().as(TargetAttacher.tclass);
- attacher.attach(refPid(client, TEST_PID)).handle(seq::nextIgnore);
- }).then(seq -> {
- Msg.debug(this, "Getting created thread");
- client.fetchModelObject("Processes", keyInt(TEST_CTLID), "Threads",
- keyInt(TEST_CTLID)).handle(seq::next);
- }, thread).then(seq -> {
- Msg.debug(this, "Detaching");
- TargetDetachable<?> detachable = thread.get().as(TargetDetachable.tclass);
- detachable.detach().handle(seq::next);
- }).then(seq -> {
- Msg.debug(this, "Disconnecting");
- client.close().handle(seq::next);
- }).finish());
- socket.close();
- }
- }
-
- protected void seqPing(SocketChannel cli, SctlDialect dialect)
- throws IOException, PacketDecodeException, PacketEncodeException {
- handlePing(cli, dialect, 1);
- }
-
- @Test
- public void testPing() throws Throwable {
- try (TestServerThread srv = runServer(this::seqPing)) {
- AsynchronousSocketChannel socket = AsynchronousSocketChannel.open();
- SctlClient client = new SctlClient("Test", socket);
- waitOn(srv, sequence(TypeSpec.VOID).then(seq -> {
- completable(TypeSpec.VOID, socket::connect, ADDR).handle(seq::next);
- }).then(seq -> {
- Msg.debug(this, "Connecting");
- client.connect().handle(seq::next);
- }).then(seq -> {
- Msg.debug(this, "Pinging");
- client.ping(HELLO_WORLD).handle(seq::next);
- }).then(seq -> {
- Msg.debug(this, "Disconnecting");
- client.close().handle(seq::next);
- }).finish());
- socket.close();
- }
- }
-
- /**
- * NOTE: I'm no longer testing the "bus" stuff, since pretty much all extension we made to SCTL
- * are now deprecated by GADP.
- */
-}
diff --git a/Ghidra/Debug/Debugger-sctl/src/test/java/ghidra/dbg/sctl/client/SctlOnReferenceTest.java b/Ghidra/Debug/Debugger-sctl/src/test/java/ghidra/dbg/sctl/client/SctlOnReferenceTest.java
deleted file mode 100644
index e2842dba61..0000000000
--- a/Ghidra/Debug/Debugger-sctl/src/test/java/ghidra/dbg/sctl/client/SctlOnReferenceTest.java
+++ /dev/null
@@ -1,1455 +0,0 @@
-/* ###
- * 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 ghidra.dbg.sctl.client;
-
-import static ghidra.async.AsyncUtils.completable;
-import static ghidra.async.AsyncUtils.sequence;
-import static org.junit.Assert.*;
-import static org.junit.Assume.assumeNoException;
-
-import java.io.IOException;
-import java.io.PrintWriter;
-import java.lang.ProcessBuilder.Redirect;
-import java.net.InetSocketAddress;
-import java.nio.ByteBuffer;
-import java.nio.ByteOrder;
-import java.nio.channels.AsynchronousSocketChannel;
-import java.util.*;
-import java.util.concurrent.*;
-import java.util.concurrent.atomic.AtomicReference;
-import java.util.function.BiFunction;
-import java.util.function.Predicate;
-
-import org.junit.Ignore;
-import org.junit.Test;
-
-import ghidra.async.*;
-import ghidra.dbg.DebugModelConventions;
-import ghidra.dbg.DebuggerObjectModel;
-import ghidra.dbg.attributes.*;
-import ghidra.dbg.sctl.err.SctlError;
-import ghidra.dbg.target.*;
-import ghidra.dbg.target.TargetBreakpointContainer.TargetBreakpointListener;
-import ghidra.dbg.target.TargetBreakpointSpec.TargetBreakpointKind;
-import ghidra.dbg.target.TargetExecutionStateful.TargetExecutionState;
-import ghidra.dbg.target.TargetExecutionStateful.TargetExecutionStateListener;
-import ghidra.dbg.target.TargetLauncher.TargetCmdLineLauncher;
-import ghidra.dbg.target.TargetObject.TargetObjectListener;
-import ghidra.dbg.testutil.DummyProc;
-import ghidra.dbg.util.PathUtils;
-import ghidra.dbg.util.TargetDataTypeConverter;
-import ghidra.framework.Application;
-import ghidra.program.model.address.Address;
-import ghidra.program.model.data.*;
-import ghidra.test.AbstractGhidraHeadlessIntegrationTest;
-import ghidra.util.*;
-import ghidra.util.database.UndoableTransaction;
-import ghidra.util.task.TaskMonitor;
-
-@Ignore("Not high priority")
-public class SctlOnReferenceTest extends AbstractGhidraHeadlessIntegrationTest {
- private static final long TIMEOUT_MILLISECONDS =
- SystemUtilities.isInTestingBatchMode() ? 1000 : Long.MAX_VALUE;
-
- static class SctlStub implements AutoCloseable {
- static int nextPort = 0;
- static final boolean USER_LAUNCHED = false;
-
- static synchronized int nextPort() {
- return nextPort++;
- }
-
- final int port = USER_LAUNCHED ? 12345 : nextPort() + 12345;
- final InetSocketAddress addr = new InetSocketAddress("localhost", port);
- final Process process;
-
- SctlStub() throws IOException {
- if (!USER_LAUNCHED) {
- String sctl = Application.getOSFile("sctl").getAbsolutePath();
- process = new ProcessBuilder(sctl, "-p", "" + port)
- .redirectError(Redirect.INHERIT)
- .redirectOutput(Redirect.INHERIT)
- .start();
- }
- else {
- Msg.info(this, "Test is expecting user-launched sctl at " + addr);
- process = null;
- }
- }
-
- @Override
- public void close() throws Exception {
- if (!USER_LAUNCHED) {
- process.destroyForcibly().waitFor();
- }
- }
- }
-
- SctlStub runSctl() throws IOException {
- try {
- SctlStub stub = new SctlStub();
- return stub;
- }
- catch (IOException e) {
- assumeNoException("Could not launch sctl. Is it installed and in the path?", e);
- return null;
- }
- }
-
- protected static <T> Void handleFailure(T result, Throwable exc) {
- if (exc != null) {
- fail(exc.getMessage());
- }
- return null;
- }
-
- protected static final BiFunction<Object, Throwable, ?> NOP_OR_FAIL =
- SctlOnReferenceTest::handleFailure;
-
- protected static <T> T waitOn(CompletableFuture<T> future) throws Throwable {
- try {
- return future.get(TIMEOUT_MILLISECONDS, TimeUnit.MILLISECONDS);
- }
- catch (ExecutionException e) {
- throw e.getCause();
- }
- }
-
- @Test
- public void testConnect() throws Throwable {
- try (SctlStub stub = runSctl()) {
- AsynchronousSocketChannel socket = AsynchronousSocketChannel.open();
- SctlClient client = new SctlClient("Test", socket);
-
- waitOn(sequence(TypeSpec.VOID).then(seq -> {
- Msg.debug(this, "Connecting...");
- completable(TypeSpec.VOID, socket::connect, stub.addr).handle(seq::next);
- }).then(seq -> {
- Msg.debug(this, "Negotiating...");
- client.connect().handle(seq::next);
- }).finish());
- }
- }
-
- @Test
- public void testPing() throws Throwable {
- try (SctlStub stub = runSctl()) {
- AsynchronousSocketChannel socket = AsynchronousSocketChannel.open();
- SctlClient client = new SctlClient("Test", socket);
-
- waitOn(sequence(TypeSpec.VOID).then(seq -> {
- Msg.debug(this, "Connecting...");
- completable(TypeSpec.VOID, socket::connect, stub.addr).handle(seq::next);
- }).then(seq -> {
- Msg.debug(this, "Negotiating...");
- client.connect().handle(seq::next);
- }).then(seq -> {
- Msg.debug(this, "Pinging...");
- client.ping("Hello, SCTL!").handle(seq::next);
- }).finish());
- }
- }
-
- @Test
- public void testListAttachable() throws Throwable {
- try (DummyProc expCloneSpin = DummyProc.run("expCloneSpin"); SctlStub stub = runSctl()) {
- AsynchronousSocketChannel socket = AsynchronousSocketChannel.open();
- SctlClient client = new SctlClient("Test", socket);
- waitOn(sequence(TypeSpec.VOID).then(seq -> {
- Msg.debug(this, "Connecting...");
- completable(TypeSpec.VOID, socket::connect, stub.addr).handle(seq::next);
- }).then(seq -> {
- Msg.debug(this, "Negotiating...");
- client.connect().handle(seq::next);
- }).then(seq -> {
- Msg.debug(this, "Getting process list");
- client.fetchObjectElements("Attachable")
- .thenCompose(DebugModelConventions::fetchAll)
- .handle(seq::next);
- }, DebuggerObjectModel.ELEMENT_MAP_TYPE).then((elems, seq) -> {
- Msg.debug(this, "Got repsonse");
- for (TargetObject proc : elems.values()) {
- if (Objects.equals(proc.getIndex(), Long.toString(expCloneSpin.pid))) {
- assertEquals("expCloneSpin",
- proc.getTypedAttributeNowByName("cmd_line", String.class, null));
- seq.exit();
- return;
- }
- }
- fail("Did not find expected PID");
- }).finish());
- }
- }
-
- protected static class ThreadTracker {
- protected static ThreadTracker strongRef;
-
- protected static class BreakHit {
- final TargetObjectRef trapped;
- final TypedTargetObjectRef<? extends TargetBreakpointSpec<?>> spec;
-
- public BreakHit(TargetObjectRef trapped,
- TypedTargetObjectRef<? extends TargetBreakpointSpec<?>> spec) {
- this.trapped = trapped;
- this.spec = spec;
- }
- }
-
- protected final AsyncReference<TargetObjectRef, Void> lastThreadRef =
- new AsyncReference<>();
- protected final AsyncReference<TargetObjectRef, Void> lastThreadRemoved =
- new AsyncReference<>();
- protected final AsyncReference<TargetObjectRef, Void> lastProcRef = new AsyncReference<>();
- protected final AsyncReference<Long, Void> lastExitCode = new AsyncReference<>();
- protected final AsyncReference<Integer, Void> exitCount = new AsyncReference<>(0);
- protected final AsyncReference<BreakHit, Void> lastBreakHit = new AsyncReference<>();
- protected final TargetObject root;
- protected TargetObject processes;
-
- protected final ListenerForProcesses listenerForProcesses = new ListenerForProcesses();
- protected final ListenerForThreads listenerForThreads = new ListenerForThreads();
- protected final ListenerForExit listenerForExit = new ListenerForExit();
- protected final ListenerForBreak listenerForBreak = new ListenerForBreak();
-
- class ListenerForProcesses implements TargetObjectListener {
- @Override
- public void elementsChanged(TargetObject parent, Collection<String> removed,
- Map<String, ? extends TargetObjectRef> added) {
- for (TargetObjectRef ref : added.values()) {
- lastProcRef.set(ref, null);
- ref.getSuccessor("Threads").fetch().thenAccept(t -> {
- t.addListener(listenerForThreads);
- for (TargetObjectRef last : t.getCachedElements().values()) {
- lastThreadRef.set(last, null);
- }
- }).exceptionally(exc -> {
- Msg.error(this, "Could not get new process's Thread container: ", exc);
- return null;
- });
- }
- }
- }
-
- class ListenerForThreads implements TargetObjectListener {
- @Override
- public void elementsChanged(TargetObject parent, Collection<String> removed,
- Map<String, ? extends TargetObjectRef> added) {
- for (TargetObjectRef ref : added.values()) {
- lastThreadRef.set(ref, null);
- ref.fetch().thenAccept(t -> {
- t.addListener(listenerForExit);
- }).exceptionally(exc -> {
- Msg.error(this, "Could not get new process: ", exc);
- return null;
- });
- ref.fetchSuccessor("Breakpoints").thenAccept(b -> {
- b.addListener(listenerForBreak);
- }).exceptionally(exc -> {
- Msg.error(this, "Could not get break container: ", exc);
- return null;
- });
- }
- for (String name : removed) {
- lastThreadRemoved.set(parent.getSuccessor(name), null);
- }
- }
- }
-
- class ListenerForExit implements TargetObjectListener {
- @Override
- public void attributesChanged(TargetObject parent, Collection<String> removed,
- Map<String, ?> added) {
- Object exitCode = added.get("exit_code");
- if (exitCode != null) {
- Msg.debug(this, "Object " + parent + " exited with code " + exitCode);
- lastExitCode.set((Long) exitCode, null);
- exitCount.compute(c -> c + 1, null);
- }
- }
- }
-
- class ListenerForBreak implements TargetBreakpointListener {
- @Override
- public void breakpointHit(TargetBreakpointContainer<?> container,
- TargetObjectRef trapped,
- TypedTargetObjectRef<? extends TargetStackFrame<?>> frame,
- TypedTargetObjectRef<? extends TargetBreakpointSpec<?>> spec,
- TypedTargetObjectRef<? extends TargetBreakpointLocation<?>> breakpoint) {
- lastBreakHit.set(new BreakHit(trapped, spec), null);
- }
- }
-
- public ThreadTracker(TargetObject root) {
- strongRef = this;
- this.root = root;
- }
-
- protected CompletableFuture<Void> init() {
- return root.fetchSuccessor("Processes").thenAccept(p -> {
- this.processes = p;
- processes.addListener(listenerForProcesses);
- });
- }
- }
-
- protected ThreadTracker trackThreads(TargetObject root) {
- return new ThreadTracker(root);
- }
-
- protected static class WhileResumer extends CompletableFuture<Void>
- implements TargetExecutionStateListener {
- protected static WhileResumer strongRef;
-
- protected final TargetResumable<?> resumable;
- protected final Predicate<? super TargetObject> predicate;
-
- public WhileResumer(TargetObject thread, Predicate<? super TargetObject> predicate) {
- strongRef = this;
- thread.addListener(this);
- resumable = thread.as(TargetResumable.tclass);
- this.predicate = predicate;
- TargetExecutionStateful<?> stateful = thread.as(TargetExecutionStateful.tclass);
- doState(stateful.getExecutionState());
- }
-
- @Override
- public void executionStateChanged(TargetExecutionStateful<?> object,
- TargetExecutionState state) {
- doState(state);
- }
-
- protected void doState(TargetExecutionState state) {
- Msg.debug(this, "Thread " + resumable + " now " + state);
- if (predicate.test(resumable)) {
- if (state == TargetExecutionState.STOPPED) {
- resumable.resume().exceptionally(exc -> {
- resumable.removeListener(this);
- completeExceptionally(exc);
- return null;
- });
- }
- else if (state == TargetExecutionState.TERMINATED) {
- resumable.removeListener(this);
- complete(null);
- }
- }
- else {
- resumable.removeListener(this);
- complete(null);
- }
- }
- }
-
- protected CompletableFuture<Void> resumeWhile(TargetObject thread,
- Predicate<? super TargetObject> predicate) {
- return new WhileResumer(thread, predicate);
- }
-
- protected static String keyInt(int i) {
- return PathUtils.makeKey(PathUtils.makeIndex(i));
- }
-
- protected static TypedTargetObjectRef<? extends TargetAttachable<?>> refPid(
- DebuggerObjectModel model, int pid) {
- return model.createRef("Attachable", keyInt(pid)).as(TargetAttachable.tclass);
- }
-
- static void stupidSleep(long millis) {
- try {
- Thread.sleep(millis);
- }
- catch (InterruptedException e) {
- // Whatever
- }
- }
-
- @Test
- public void testLaunchCont() throws Throwable {
- try (SctlStub stub = runSctl()) {
- AsynchronousSocketChannel socket = AsynchronousSocketChannel.open();
- SctlClient client = new SctlClient("Test", socket);
- AtomicReference<TargetObject> root = new AtomicReference<>();
- long status = waitOn(sequence(TypeSpec.LONG).then(seq -> {
- Msg.debug(this, "Connecting...");
- completable(TypeSpec.VOID, socket::connect, stub.addr).handle(seq::next);
- }).then(seq -> {
- Msg.debug(this, "Negotiating...");
- client.connect().handle(seq::next);
- }).then(seq -> {
- Msg.debug(this, "Getting model root");
- client.fetchModelRoot().handle(seq::next);
- }, root).then(seq -> {
- Msg.debug(this, "Initializing thread tracker");
- trackThreads(root.get()).init().handle(seq::next);
- }).then(seq -> {
- Msg.debug(this, "Launching...");
- TargetLauncher<?> launcher = root.get().as(TargetLauncher.tclass);
- launcher.launch(Map.of(TargetCmdLineLauncher.CMDLINE_ARGS_NAME,
- DummyProc.which("echo") + " test")).handle(seq::next);
- }).then(seq -> {
- Msg.debug(this, "Waiting for thread");
- ThreadTracker.strongRef.lastThreadRef.waitUntil(r -> r != null).handle(seq::next);
- }, TypeSpec.cls(TargetObjectRef.class)).then((threadRef, seq) -> {
- Msg.debug(this, "Got thread ref: " + threadRef);
- threadRef.fetch().handle(seq::next);
- }, TypeSpec.cls(TargetObject.class)).then((thread, seq) -> {
- Msg.debug(this, "Continuing until exit...");
- resumeWhile(thread, t -> true).handle(seq::next);
- }).then(seq -> {
- Msg.debug(this, "Waiting for exit code...");
- ThreadTracker.strongRef.lastExitCode.waitUntil(v -> v != null).handle(seq::exit);
- }).finish());
- assertEquals(0, status);
- }
- }
-
- @Test
- public void testLaunchKill() throws Throwable {
- try (SctlStub stub = runSctl()) {
- AsynchronousSocketChannel socket = AsynchronousSocketChannel.open();
- SctlClient client = new SctlClient("Test", socket);
- AtomicReference<TargetObject> root = new AtomicReference<>();
- waitOn(sequence(TypeSpec.VOID).then(seq -> {
- Msg.debug(this, "Connecting...");
- completable(TypeSpec.VOID, socket::connect, stub.addr).handle(seq::next);
- }).then(seq -> {
- Msg.debug(this, "Negotiating...");
- client.connect().handle(seq::next);
- }).then(seq -> {
- Msg.debug(this, "Getting model root");
- client.fetchModelRoot().handle(seq::next);
- }, root).then(seq -> {
- Msg.debug(this, "Initializing thread tracker");
- trackThreads(root.get()).init().handle(seq::next);
- }).then(seq -> {
- Msg.debug(this, "Launching...");
- TargetLauncher<?> launcher = root.get().as(TargetLauncher.tclass);
- launcher.launch(Map.of(TargetCmdLineLauncher.CMDLINE_ARGS_NAME,
- DummyProc.which("echo") + " test")).handle(seq::next);
- }).then(seq -> {
- Msg.debug(this, "Waiting for thread");
- ThreadTracker.strongRef.lastThreadRef.waitUntil(r -> r != null).handle(seq::next);
- }, TypeSpec.cls(TargetObjectRef.class)).then((threadRef, seq) -> {
- Msg.debug(this, "Got thread ref: " + threadRef);
- threadRef.fetch().handle(seq::next);
- }, TypeSpec.cls(TargetObject.class)).then((thread, seq) -> {
- Msg.debug(this, "Killing...");
- TargetKillable<?> killable = thread.as(TargetKillable.tclass);
- killable.kill().handle(seq::next);
- }).finish());
- }
- }
-
- @Test
- public void testAttachKill() throws Throwable {
- try (DummyProc dd = DummyProc.run("dd"); SctlStub stub = runSctl()) {
- AsynchronousSocketChannel socket = AsynchronousSocketChannel.open();
- SctlClient client = new SctlClient("Test", socket);
- AtomicReference<TargetObject> root = new AtomicReference<>();
- waitOn(sequence(TypeSpec.VOID).then(seq -> {
- Msg.debug(this, "Connecting...");
- completable(TypeSpec.VOID, socket::connect, stub.addr).handle(seq::next);
- }).then(seq -> {
- Msg.debug(this, "Negotiating...");
- client.connect().handle(seq::next);
- }).then(seq -> {
- Msg.debug(this, "Getting model root");
- client.fetchModelRoot().handle(seq::next);
- }, root).then(seq -> {
- Msg.debug(this, "Initializing thread tracker");
- trackThreads(root.get()).init().handle(seq::next);
- }).then(seq -> {
- Msg.debug(this, "Attaching...");
- TargetAttacher<?> attacher = root.get().as(TargetAttacher.tclass);
- attacher.attach(refPid(client, (int) dd.pid)).handle(seq::next);
- }).then(seq -> {
- Msg.debug(this, "Waiting for thread");
- ThreadTracker.strongRef.lastThreadRef.waitUntil(r -> r != null).handle(seq::next);
- }, TypeSpec.cls(TargetObjectRef.class)).then((threadRef, seq) -> {
- Msg.debug(this, "Got thread ref: " + threadRef);
- threadRef.fetch().handle(seq::next);
- }, TypeSpec.cls(TargetObject.class)).then((thread, seq) -> {
- Msg.debug(this, "Killing...");
- TargetKillable<?> killable = thread.as(TargetKillable.tclass);
- killable.kill().handle(seq::next);
- }).finish());
- }
- }
-
- @Test
- public void testLaunchSetClearBreakpoint() throws Throwable {
- try (SctlStub stub = runSctl()) {
- AsynchronousSocketChannel socket = AsynchronousSocketChannel.open();
- SctlClient client = new SctlClient("Test", socket);
- AtomicReference<TargetObject> root = new AtomicReference<>();
- AtomicReference<TargetRegisterBank<?>> regs = new AtomicReference<>();
- AtomicReference<TargetBreakpointContainer<?>> traps = new AtomicReference<>();
- waitOn(sequence(TypeSpec.VOID).then(seq -> {
- Msg.debug(this, "Connecting...");
- completable(TypeSpec.VOID, socket::connect, stub.addr).handle(seq::next);
- }).then(seq -> {
- Msg.debug(this, "Negotiating...");
- client.connect().handle(seq::next);
- }).then(seq -> {
- Msg.debug(this, "Getting model root");
- client.fetchModelRoot().handle(seq::next);
- }, root).then(seq -> {
- Msg.debug(this, "Initializing thread tracker");
- trackThreads(root.get()).init().handle(seq::next);
- }).then(seq -> {
- Msg.debug(this, "Launching...");
- TargetLauncher<?> launcher = root.get().as(TargetLauncher.tclass);
- launcher.launch(Map.of(TargetCmdLineLauncher.CMDLINE_ARGS_NAME,
- DummyProc.which("echo") + " test")).handle(seq::next);
- }).then(seq -> {
- Msg.debug(this, "Waiting for thread");
- ThreadTracker.strongRef.lastThreadRef.waitUntil(r -> r != null).handle(seq::next);
- }, TypeSpec.cls(TargetObjectRef.class)).then((threadRef, seq) -> {
- Msg.debug(this, "Got thread ref: " + threadRef);
- AsyncFence fence = new AsyncFence();
- fence.include(threadRef.fetchSuccessor("Registers").thenAccept(obj -> {
- regs.set(obj.as(TargetRegisterBank.tclass));
- }));
- fence.include(threadRef.fetchSuccessor("Breakpoints").thenAccept(obj -> {
- traps.set(obj.as(TargetBreakpointContainer.tclass));
- }));
- fence.ready().handle(seq::next);
- }).then(seq -> {
- Msg.debug(this, "Reading RIP...");
- regs.get().readRegister("rip").handle(seq::next);
- }, TypeSpec.BYTE_ARRAY).then((ripBytes, seq) -> {
- long ripVal = ByteBuffer.wrap(ripBytes).order(ByteOrder.BIG_ENDIAN).getLong(0);
- Address rip = client.getAddress("ram", ripVal);
- Msg.debug(this, "Got RIP=" + rip);
- traps.get()
- .placeBreakpoint(rip, Set.of(TargetBreakpointKind.SOFTWARE))
- .handle(seq::next);
- }).then(seq -> {
- Msg.debug(this, "Breakpoints: ");
- for (TargetObjectRef bref : traps.get().getCachedElements().values()) {
- Msg.debug(this, " " + bref);
- }
- traps.get()
- .getCachedElements()
- .values()
- .iterator()
- .next()
- .fetch()
- .handle(seq::next);
- }, TypeSpec.cls(TargetObject.class)).then((obj, seq) -> {
- TargetDeletable<?> spec = obj.as(TargetDeletable.tclass);
- spec.delete().handle(seq::next);
- }).then(seq -> {
- Msg.debug(this, "Deleted breakpoint");
- seq.exit();
- }).finish());
- }
- }
-
- @Test(expected = SctlError.class)
- public void testErr() throws Throwable {
- // TODO: Translate the exception to the appropriate model exception
- try (SctlStub stub = runSctl()) {
- AsynchronousSocketChannel socket = AsynchronousSocketChannel.open();
- SctlClient client = new SctlClient("Test", socket);
- AtomicReference<TargetObject> root = new AtomicReference<>();
- waitOn(sequence(TypeSpec.VOID).then(seq -> {
- Msg.debug(this, "Connecting...");
- completable(TypeSpec.VOID, socket::connect, stub.addr).handle(seq::next);
- }).then(seq -> {
- Msg.debug(this, "Negotiating...");
- client.connect().handle(seq::next);
- }).then(seq -> {
- Msg.debug(this, "Getting model root");
- client.fetchModelRoot().handle(seq::next);
- }, root).then(seq -> {
- Msg.debug(this, "Attaching to bogus PID...");
- TargetAttacher<?> attacher = root.get().as(TargetAttacher.tclass);
- attacher.attach(refPid(client, -1)).handle(seq::next);
- }).then(seq -> {
- fail("Got a thread");
- seq.exit();
- }).finish());
- }
- }
-
- /*
- * TODO:
- *
- * 1(DONE). See what happens when we fork the process (esp., wrt. threads). According to UNIX
- * docs, should cause a single ForkEvent, yielding a new process with one thread.
- *
- * 2(DONE). See what happens when we clone the process (esp., wrt. threads). Just another
- * thread.
- *
- * 3(DONE). See what happens on pthread_create. Causes CloneEvent.
- *
- * 4(DONE). See what happens when a thread exits. Do we get the status code? If not, then I need
- * to remove the threadExited callback from the listener. It probably belongs in process
- * listener anyway. Then again, even if the reference does not give it, shouldn't I model it
- * here for extensibility? It seems only threads that were alive at the time the process exited
- * are given the status code. All of them are given the same code. Threads that exit before the
- * process are reported with a status of 0, no matter what they return.
- *
- * 5(DONE). When I set a breakpoint on one CTLID of a process, will that cause the other threads
- * to break there, too? No, it does not.
- *
- * 6(DONE). Does killing one thread kill the whole process? Yes and no. When I kill the primary
- * thread, nothing seems to be affected. When I kill the secondary thread, sctl and the target
- * process die altogether.
- *
- * 7(DONE). Does detaching one thread detach the whole process? (try main thread and spawned
- * thread). No, detaching from either leaves the other thread attached. However, sctl appears
- * confused beyond that point. Continuing one thread actually continues both, or the attached
- * thread may continue immediately after the other is detached. In general, detach should be
- * avoided until we're ready to detach the whole process. Whatever the case, it appears SCTL is
- * meant to be able to detach a single thread, so we should assume thread granularity.
- *
- * 8(DONE). What if I start a process outside of sctl, it clones, and then I attach? It seems I
- * can only ever attach to the main thread.
- */
-
- @Test
- public void testExpFork() throws Throwable {
- try (SctlStub stub = runSctl()) {
- AsynchronousSocketChannel socket = AsynchronousSocketChannel.open();
- SctlClient client = new SctlClient("Test", socket);
- AtomicReference<TargetObject> root = new AtomicReference<>();
- waitOn(sequence(TypeSpec.VOID).then(seq -> {
- Msg.debug(this, "Connecting...");
- completable(TypeSpec.VOID, socket::connect, stub.addr).handle(seq::next);
- }).then(seq -> {
- Msg.debug(this, "Negotiating...");
- client.connect().handle(seq::next);
- }).then(seq -> {
- Msg.debug(this, "Getting model root");
- client.fetchModelRoot().handle(seq::next);
- }, root).then(seq -> {
- Msg.debug(this, "Initializing thread tracker");
- trackThreads(root.get()).init().handle(seq::next);
- }).then(seq -> {
- Msg.debug(this, "Launching...");
- TargetLauncher<?> launcher = root.get().as(TargetLauncher.tclass);
- launcher.launch(
- Map.of(TargetCmdLineLauncher.CMDLINE_ARGS_NAME, DummyProc.which("expFork")))
- .handle(seq::next);
- }).then(seq -> {
- Msg.debug(this, "Waiting for thread");
- ThreadTracker.strongRef.lastThreadRef.waitUntil(r -> r != null).handle(seq::next);
- }, TypeSpec.cls(TargetObjectRef.class)).then((threadRef, seq) -> {
- ThreadTracker.strongRef.lastThreadRef.set(null, null);
- Msg.debug(this, "Got thread ref: " + threadRef);
- threadRef.fetch().handle(seq::next);
- }, TypeSpec.cls(TargetObject.class)).then((thread, seq) -> {
- Msg.debug(this, "Resuming first (parent) indefinitely");
- resumeWhile(thread, t -> true).handle(seq::next);
- }).then(seq -> {
- Msg.debug(this, "Waiting for parent to exit");
- ThreadTracker.strongRef.lastExitCode.waitUntil(v -> v != null).handle(seq::next);
- }, TypeSpec.cls(Long.class)).then((exit, seq) -> {
- Msg.debug(this, "Parent exited with " + exit);
- ThreadTracker.strongRef.lastExitCode.set(null, null);
- // TODO: I'm not sure why this is off by a factor of 256. A byte offset somewhere?
- assertEquals(256, exit.longValue());
- Msg.debug(this, "Waiting for second (child) thread (and process)");
- ThreadTracker.strongRef.lastThreadRef.waitUntil(r -> r != null).handle(seq::next);
- }, TypeSpec.cls(TargetObjectRef.class)).then((threadRef, seq) -> {
- Msg.debug(this, "Got child thread ref: " + threadRef);
- threadRef.fetch().handle(seq::next);
- }, TypeSpec.cls(TargetObject.class)).then((thread, seq) -> {
- Msg.debug(this, "Resuming child indefinitely");
- resumeWhile(thread, t -> true).handle(seq::next);
- }).then(seq -> {
- Msg.debug(this, "Waiting for child to exit");
- ThreadTracker.strongRef.lastExitCode.waitUntil(v -> v != null).handle(seq::next);
- }, TypeSpec.cls(Long.class)).then((exit, seq) -> {
- Msg.debug(this, "Child exited with " + exit);
- assertEquals(0, exit.longValue());
- seq.exit();
- }).finish());
- }
- }
-
- /**
- * This experiment confirms that sctl has a separate list of breakpoints per thread
- *
- * @throws Throwable
- */
- @Test
- public void testExpCloneBreak() throws Throwable {
- String expCloneExit = DummyProc.which("expCloneExit");
- try (SctlStub stub = runSctl()) {
- AsynchronousSocketChannel socket = AsynchronousSocketChannel.open();
- SctlClient client = new SctlClient("Test", socket);
- AtomicReference<TargetObject> root = new AtomicReference<>();
- AtomicReference<TargetObject> launchedThread = new AtomicReference<>();
- AtomicReference<TargetObject> clonedThread = new AtomicReference<>();
- AtomicReference<TargetSymbol<?>> work = new AtomicReference<>();
- waitOn(sequence(TypeSpec.VOID).then(seq -> {
- Msg.debug(this, "Connecting...");
- completable(TypeSpec.VOID, socket::connect, stub.addr).handle(seq::next);
- }).then(seq -> {
- Msg.debug(this, "Negotiating...");
- client.connect().handle(seq::next);
- }).then(seq -> {
- Msg.debug(this, "Getting model root");
- client.fetchModelRoot().handle(seq::next);
- }, root).then(seq -> {
- Msg.debug(this, "Initializing thread tracker");
- trackThreads(root.get()).init().handle(seq::next);
- }).then(seq -> {
- Msg.debug(this, "Launching...");
- TargetLauncher<?> launcher = root.get().as(TargetLauncher.tclass);
- launcher.launch(Map.of(TargetCmdLineLauncher.CMDLINE_ARGS_NAME, expCloneExit))
- .handle(seq::next);
- }).then(seq -> {
- Msg.debug(this, "Waiting for launched thread ref");
- ThreadTracker.strongRef.lastThreadRef.waitUntil(r -> r != null).handle(seq::next);
- }, TypeSpec.cls(TargetObjectRef.class)).then((threadRef, seq) -> {
- ThreadTracker.strongRef.lastThreadRef.set(null, null);
- Msg.debug(this, "Got thread ref: " + threadRef);
- threadRef.fetch().handle(seq::next);
- }, launchedThread).then(seq -> {
- Msg.debug(this, "Resuming until another thread appears: " + launchedThread.get());
- resumeWhile(launchedThread.get(), t -> {
- TargetObjectRef ref = ThreadTracker.strongRef.lastThreadRef.get();
- Msg.debug(this, "lastThreadRef = " + ref);
- return ref == null;
- }).handle(seq::next);
- }).then(seq -> {
- Msg.debug(this, "Waiting for cloned thread");
- ThreadTracker.strongRef.lastThreadRef.waitUntil(r -> r != null).handle(seq::next);
- }, TypeSpec.cls(TargetObjectRef.class)).then((threadRef, seq) -> {
- Msg.debug(this, "Got thread ref: " + threadRef);
- threadRef.fetch().handle(seq::next);
- }, clonedThread).then(seq -> {
- // Verify nothing has exited, yet
- assertNull(ThreadTracker.strongRef.lastExitCode.get());
- Msg.debug(this, "Placing breakpoint at 'work'");
- ThreadTracker.strongRef.lastProcRef.get()
- .fetchSuccessor(
- PathUtils.parse("Modules[" + expCloneExit + "].Symbols[work]"))
- .handle(seq::next);
- }, TypeSpec.cls(TargetObject.class)).then((obj, seq) -> {
- work.set(obj.as(TargetSymbol.tclass));
- Msg.debug(this, "Resolved 'work' to " + work.get().getValue());
- launchedThread.get().fetchSuccessor("Breakpoints").handle(seq::next);
- }, TypeSpec.cls(TargetObject.class)).then((obj, seq) -> {
- TargetBreakpointContainer<?> traps = obj.as(TargetBreakpointContainer.tclass);
- traps.placeBreakpoint(work.get().getValue(), Set.of(TargetBreakpointKind.SOFTWARE))
- .handle(seq::next);
- }).then(seq -> {
- Msg.debug(this, "Continuing secondary thread indefinitely");
- resumeWhile(clonedThread.get(), t -> true).handle(seq::next);
- }).then(seq -> {
- Msg.debug(this, "Waiting for secondary thread to exit");
- ThreadTracker.strongRef.lastExitCode.waitUntil(v -> v != null).handle(seq::next);
- }, TypeSpec.cls(Long.class)).then((exit, seq) -> {
- ThreadTracker.strongRef.lastExitCode.set(null, null);
- Msg.debug(this, "Exited with " + exit);
- assertNull(ThreadTracker.strongRef.lastBreakHit.get());
- Msg.debug(this, "Continuing primary thread indefinitely");
- resumeWhile(launchedThread.get(), t -> true).handle(seq::next);
- }).then(seq -> {
- Msg.debug(this, "Waiting for primary thread to exit");
- ThreadTracker.strongRef.lastExitCode.waitUntil(v -> v != null).handle(seq::next);
- }, TypeSpec.cls(Long.class)).then((exit, seq) -> {
- ThreadTracker.strongRef.lastExitCode.set(null, null);
- Msg.debug(this, "Exited with " + exit);
- assertNotNull(ThreadTracker.strongRef.lastBreakHit.get());
- seq.exit();
- }).finish());
- }
- }
-
- /**
- * This experiment determined that a thread exiting unrelated to process termination is assigned
- * an exit status of 0. If any thread calls exit(), then all threads are terminated with a
- * status given by that call.
- *
- * @throws Throwable
- */
- @Test
- public void testExpCloneExit() throws Throwable {
- String expCloneExit = DummyProc.which("expCloneExit");
- try (SctlStub stub = runSctl()) {
- AsynchronousSocketChannel socket = AsynchronousSocketChannel.open();
- SctlClient client = new SctlClient("Test", socket);
- AtomicReference<TargetObject> root = new AtomicReference<>();
- AtomicReference<TargetObject> launchedThread = new AtomicReference<>();
- waitOn(sequence(TypeSpec.VOID).then(seq -> {
- Msg.debug(this, "Connecting...");
- completable(TypeSpec.VOID, socket::connect, stub.addr).handle(seq::next);
- }).then(seq -> {
- Msg.debug(this, "Negotiating...");
- client.connect().handle(seq::next);
- }).then(seq -> {
- Msg.debug(this, "Getting model root");
- client.fetchModelRoot().handle(seq::next);
- }, root).then(seq -> {
- Msg.debug(this, "Initializing thread tracker");
- trackThreads(root.get()).init().handle(seq::next);
- }).then(seq -> {
- Msg.debug(this, "Launching...");
- TargetLauncher<?> launcher = root.get().as(TargetLauncher.tclass);
- launcher.launch(Map.of(TargetCmdLineLauncher.CMDLINE_ARGS_NAME, expCloneExit))
- .handle(seq::next);
- }).then(seq -> {
- Msg.debug(this, "Waiting for launched thread ref");
- ThreadTracker.strongRef.lastThreadRef.waitUntil(r -> r != null).handle(seq::next);
- }, TypeSpec.cls(TargetObjectRef.class)).then((threadRef, seq) -> {
- ThreadTracker.strongRef.lastThreadRef.set(null, null);
- Msg.debug(this, "Got thread ref: " + threadRef);
- threadRef.fetch().handle(seq::next);
- }, launchedThread).then(seq -> {
- Msg.debug(this, "Resuming launched thread indefinitely");
- resumeWhile(launchedThread.get(), t -> true).handle(seq::next);
- // Note that the cloned thread will be terminated despite not returning
- }).then(seq -> {
- Msg.debug(this, "Waiting for 2 exits");
- ThreadTracker.strongRef.exitCount.waitValue(2).handle(seq::next);
- }).finish());
- }
- }
-
- /**
- * Check the behavior of sctl when a process clones and you detach the secondary thread
- *
- * This test reveals what appears to be a bug. If I remove the call to continue, then neither
- * prints until sctl is forcibly terminated.
- */
- @Test
- public void testExpCloneDetachSecondary() throws Throwable {
- String expCloneExit = DummyProc.which("expCloneExit");
- try (SctlStub stub = runSctl()) {
- AsynchronousSocketChannel socket = AsynchronousSocketChannel.open();
- SctlClient client = new SctlClient("Test", socket);
- AtomicReference<TargetObject> root = new AtomicReference<>();
- AtomicReference<TargetObject> launchedThread = new AtomicReference<>();
- AtomicReference<TargetObject> clonedThread = new AtomicReference<>();
- waitOn(sequence(TypeSpec.VOID).then(seq -> {
- Msg.debug(this, "Connecting...");
- completable(TypeSpec.VOID, socket::connect, stub.addr).handle(seq::next);
- }).then(seq -> {
- Msg.debug(this, "Negotiating...");
- client.connect().handle(seq::next);
- }).then(seq -> {
- Msg.debug(this, "Getting model root");
- client.fetchModelRoot().handle(seq::next);
- }, root).then(seq -> {
- Msg.debug(this, "Initializing thread tracker");
- trackThreads(root.get()).init().handle(seq::next);
- }).then(seq -> {
- Msg.debug(this, "Launching...");
- TargetLauncher<?> launcher = root.get().as(TargetLauncher.tclass);
- launcher.launch(Map.of(TargetCmdLineLauncher.CMDLINE_ARGS_NAME, expCloneExit))
- .handle(seq::next);
- }).then(seq -> {
- Msg.debug(this, "Waiting for launched thread ref");
- ThreadTracker.strongRef.lastThreadRef.waitUntil(r -> r != null).handle(seq::next);
- }, TypeSpec.cls(TargetObjectRef.class)).then((threadRef, seq) -> {
- ThreadTracker.strongRef.lastThreadRef.set(null, null);
- Msg.debug(this, "Got thread ref: " + threadRef);
- threadRef.fetch().handle(seq::next);
- }, launchedThread).then(seq -> {
- Msg.debug(this, "Resuming until another thread appears: " + launchedThread.get());
- resumeWhile(launchedThread.get(), t -> {
- TargetObjectRef ref = ThreadTracker.strongRef.lastThreadRef.get();
- Msg.debug(this, "lastThreadRef = " + ref);
- return ref == null;
- }).handle(seq::next);
- }).then(seq -> {
- Msg.debug(this, "Waiting for cloned thread");
- ThreadTracker.strongRef.lastThreadRef.waitUntil(r -> r != null).handle(seq::next);
- }, TypeSpec.cls(TargetObjectRef.class)).then((threadRef, seq) -> {
- Msg.debug(this, "Got thread ref: " + threadRef);
- threadRef.fetch().handle(seq::next);
- }, clonedThread).then(seq -> {
- // Verify nothing has exited, yet
- assertNull(ThreadTracker.strongRef.lastExitCode.get());
- Msg.debug(this, "Detaching from cloned thread");
- TargetDetachable<?> detachable = clonedThread.get().as(TargetDetachable.tclass);
- detachable.detach().handle(seq::next);
- }).then(seq -> {
- Msg.debug(this, "Continuing the primary thread indefinitely");
- resumeWhile(launchedThread.get(), t -> true).handle(seq::next);
- }).then(seq -> {
- Msg.debug(this, "Waiting on primary thread to exit");
- ThreadTracker.strongRef.exitCount.waitValue(1).handle(seq::next);
- }).finish());
- }
- }
-
- /**
- * Check the behavior of sctl when a process clones and you detach the primary thread
- *
- * This test reveals a minor annoyance. The primary thread resumes execution upon detaching, and
- * so it exits, terminating the secondary thread (to which I'm still attached) immediately with
- * the exit code of the whole process.
- */
- @Test
- public void testExpCloneDetachPrimary() throws Throwable {
- String expCloneExit = DummyProc.which("expCloneExit");
- try (SctlStub stub = runSctl()) {
- AsynchronousSocketChannel socket = AsynchronousSocketChannel.open();
- SctlClient client = new SctlClient("Test", socket);
- AtomicReference<TargetObject> root = new AtomicReference<>();
- AtomicReference<TargetObject> launchedThread = new AtomicReference<>();
- AtomicReference<TargetObject> clonedThread = new AtomicReference<>();
- waitOn(sequence(TypeSpec.VOID).then(seq -> {
- Msg.debug(this, "Connecting...");
- completable(TypeSpec.VOID, socket::connect, stub.addr).handle(seq::next);
- }).then(seq -> {
- Msg.debug(this, "Negotiating...");
- client.connect().handle(seq::next);
- }).then(seq -> {
- Msg.debug(this, "Getting model root");
- client.fetchModelRoot().handle(seq::next);
- }, root).then(seq -> {
- Msg.debug(this, "Initializing thread tracker");
- trackThreads(root.get()).init().handle(seq::next);
- }).then(seq -> {
- Msg.debug(this, "Launching...");
- TargetLauncher<?> launcher = root.get().as(TargetLauncher.tclass);
- launcher.launch(Map.of(TargetCmdLineLauncher.CMDLINE_ARGS_NAME, expCloneExit))
- .handle(seq::next);
- }).then(seq -> {
- Msg.debug(this, "Waiting for launched thread ref");
- ThreadTracker.strongRef.lastThreadRef.waitUntil(r -> r != null).handle(seq::next);
- }, TypeSpec.cls(TargetObjectRef.class)).then((threadRef, seq) -> {
- ThreadTracker.strongRef.lastThreadRef.set(null, null);
- Msg.debug(this, "Got thread ref: " + threadRef);
- threadRef.fetch().handle(seq::next);
- }, launchedThread).then(seq -> {
- Msg.debug(this, "Resuming until another thread appears: " + launchedThread.get());
- resumeWhile(launchedThread.get(), t -> {
- TargetObjectRef ref = ThreadTracker.strongRef.lastThreadRef.get();
- Msg.debug(this, "lastThreadRef = " + ref);
- return ref == null;
- }).handle(seq::next);
- }).then(seq -> {
- Msg.debug(this, "Waiting for cloned thread");
- ThreadTracker.strongRef.lastThreadRef.waitUntil(r -> r != null).handle(seq::next);
- }, TypeSpec.cls(TargetObjectRef.class)).then((threadRef, seq) -> {
- Msg.debug(this, "Got thread ref: " + threadRef);
- threadRef.fetch().handle(seq::next);
- }, clonedThread).then(seq -> {
- // Verify nothing has exited, yet
- assertNull(ThreadTracker.strongRef.lastExitCode.get());
- Msg.debug(this, "Detaching from primary thread");
- TargetDetachable<?> detachable = launchedThread.get().as(TargetDetachable.tclass);
- detachable.detach().handle(seq::next);
- }).then(seq -> {
- // NOTE: I don't have to continue to observe the exit event
- Msg.debug(this, "Waiting on cloned thread to exit");
- ThreadTracker.strongRef.exitCount.waitValue(1).handle(seq::next);
- }).finish());
- }
- }
-
- /**
- * Killing the secondary thread causes the primary thread to terminate with status 9 (not
- * shifted by 8).
- */
- @Test
- public void testExpCloneKillSecondary() throws Throwable {
- String expCloneExit = DummyProc.which("expCloneExit");
- try (SctlStub stub = runSctl()) {
- AsynchronousSocketChannel socket = AsynchronousSocketChannel.open();
- SctlClient client = new SctlClient("Test", socket);
- AtomicReference<TargetObject> root = new AtomicReference<>();
- AtomicReference<TargetObject> launchedThread = new AtomicReference<>();
- AtomicReference<TargetObject> clonedThread = new AtomicReference<>();
- waitOn(sequence(TypeSpec.VOID).then(seq -> {
- Msg.debug(this, "Connecting...");
- completable(TypeSpec.VOID, socket::connect, stub.addr).handle(seq::next);
- }).then(seq -> {
- Msg.debug(this, "Negotiating...");
- client.connect().handle(seq::next);
- }).then(seq -> {
- Msg.debug(this, "Getting model root");
- client.fetchModelRoot().handle(seq::next);
- }, root).then(seq -> {
- Msg.debug(this, "Initializing thread tracker");
- trackThreads(root.get()).init().handle(seq::next);
- }).then(seq -> {
- Msg.debug(this, "Launching...");
- TargetLauncher<?> launcher = root.get().as(TargetLauncher.tclass);
- launcher.launch(Map.of(TargetCmdLineLauncher.CMDLINE_ARGS_NAME, expCloneExit))
- .handle(seq::next);
- }).then(seq -> {
- Msg.debug(this, "Waiting for launched thread ref");
- ThreadTracker.strongRef.lastThreadRef.waitUntil(r -> r != null).handle(seq::next);
- }, TypeSpec.cls(TargetObjectRef.class)).then((threadRef, seq) -> {
- ThreadTracker.strongRef.lastThreadRef.set(null, null);
- Msg.debug(this, "Got thread ref: " + threadRef);
- threadRef.fetch().handle(seq::next);
- }, launchedThread).then(seq -> {
- Msg.debug(this, "Resuming until another thread appears: " + launchedThread.get());
- resumeWhile(launchedThread.get(), t -> {
- TargetObjectRef ref = ThreadTracker.strongRef.lastThreadRef.get();
- Msg.debug(this, "lastThreadRef = " + ref);
- return ref == null;
- }).handle(seq::next);
- }).then(seq -> {
- Msg.debug(this, "Waiting for cloned thread");
- ThreadTracker.strongRef.lastThreadRef.waitUntil(r -> r != null).handle(seq::next);
- }, TypeSpec.cls(TargetObjectRef.class)).then((threadRef, seq) -> {
- Msg.debug(this, "Got thread ref: " + threadRef);
- threadRef.fetch().handle(seq::next);
- }, clonedThread).then(seq -> {
- // Verify nothing has exited, yet
- assertNull(ThreadTracker.strongRef.lastExitCode.get());
- Msg.debug(this, "Killing cloned thread");
- TargetKillable<?> killable = clonedThread.get().as(TargetKillable.tclass);
- killable.kill().handle(seq::next);
- }).then(seq -> {
- Msg.debug(this, "Waiting for exit");
- ThreadTracker.strongRef.lastExitCode.waitUntil(v -> v != null).handle(seq::next);
- }, TypeSpec.cls(Long.class)).then((exit, seq) -> {
- assertEquals(9, exit.longValue());
- seq.exit();
- }).finish());
- }
- }
-
- /**
- * There seems to be a bug: The primary thread is not killed, but rather seems to resume, as it
- * prints. It then exits (with code 1, or status 256) causing the secondary thread to be
- * terminated.
- */
- @Test
- public void testExpCloneKillPrimary() throws Throwable {
- String expCloneExit = DummyProc.which("expCloneExit");
- try (SctlStub stub = runSctl()) {
- AsynchronousSocketChannel socket = AsynchronousSocketChannel.open();
- SctlClient client = new SctlClient("Test", socket);
- AtomicReference<TargetObject> root = new AtomicReference<>();
- AtomicReference<TargetObject> launchedThread = new AtomicReference<>();
- AtomicReference<TargetObject> clonedThread = new AtomicReference<>();
- waitOn(sequence(TypeSpec.VOID).then(seq -> {
- Msg.debug(this, "Connecting...");
- completable(TypeSpec.VOID, socket::connect, stub.addr).handle(seq::next);
- }).then(seq -> {
- Msg.debug(this, "Negotiating...");
- client.connect().handle(seq::next);
- }).then(seq -> {
- Msg.debug(this, "Getting model root");
- client.fetchModelRoot().handle(seq::next);
- }, root).then(seq -> {
- Msg.debug(this, "Initializing thread tracker");
- trackThreads(root.get()).init().handle(seq::next);
- }).then(seq -> {
- Msg.debug(this, "Launching...");
- TargetLauncher<?> launcher = root.get().as(TargetLauncher.tclass);
- launcher.launch(Map.of(TargetCmdLineLauncher.CMDLINE_ARGS_NAME, expCloneExit))
- .handle(seq::next);
- }).then(seq -> {
- Msg.debug(this, "Waiting for launched thread ref");
- ThreadTracker.strongRef.lastThreadRef.waitUntil(r -> r != null).handle(seq::next);
- }, TypeSpec.cls(TargetObjectRef.class)).then((threadRef, seq) -> {
- ThreadTracker.strongRef.lastThreadRef.set(null, null);
- Msg.debug(this, "Got thread ref: " + threadRef);
- threadRef.fetch().handle(seq::next);
- }, launchedThread).then(seq -> {
- Msg.debug(this, "Resuming until another thread appears: " + launchedThread.get());
- resumeWhile(launchedThread.get(), t -> {
- TargetObjectRef ref = ThreadTracker.strongRef.lastThreadRef.get();
- Msg.debug(this, "lastThreadRef = " + ref);
- return ref == null;
- }).handle(seq::next);
- }).then(seq -> {
- Msg.debug(this, "Waiting for cloned thread");
- ThreadTracker.strongRef.lastThreadRef.waitUntil(r -> r != null).handle(seq::next);
- }, TypeSpec.cls(TargetObjectRef.class)).then((threadRef, seq) -> {
- Msg.debug(this, "Got thread ref: " + threadRef);
- threadRef.fetch().handle(seq::next);
- }, clonedThread).then(seq -> {
- // Verify nothing has exited, yet
- assertNull(ThreadTracker.strongRef.lastExitCode.get());
- Msg.debug(this, "Killing launched thread");
- TargetKillable<?> killable = launchedThread.get().as(TargetKillable.tclass);
- killable.kill().handle(seq::next);
- }).then(seq -> {
- Msg.debug(this, "Waiting for exit");
- ThreadTracker.strongRef.lastExitCode.waitUntil(v -> v != null).handle(seq::next);
- }, TypeSpec.cls(Long.class)).then((exit, seq) -> {
- assertEquals(256, exit.longValue());
- seq.exit();
- }).finish());
- }
- }
-
- @Test
- public void testExpCloneThenAttachKill() throws Throwable {
- try (DummyProc expCloneSpin = DummyProc.run("expCloneSpin"); SctlStub stub = runSctl()) {
- AsynchronousSocketChannel socket = AsynchronousSocketChannel.open();
- SctlClient client = new SctlClient("Test", socket);
- AtomicReference<TargetObject> root = new AtomicReference<>();
- AtomicReference<TargetObject> attachedThread = new AtomicReference<>();
- waitOn(sequence(TypeSpec.VOID).then(seq -> {
- Msg.debug(this, "Connecting...");
- completable(TypeSpec.VOID, socket::connect, stub.addr).handle(seq::next);
- }).then(seq -> {
- Msg.debug(this, "Negotiating...");
- client.connect().handle(seq::next);
- }).then(seq -> {
- Msg.debug(this, "Getting model root");
- client.fetchModelRoot().handle(seq::next);
- }, root).then(seq -> {
- Msg.debug(this, "Initializing thread tracker");
- trackThreads(root.get()).init().handle(seq::next);
- }).then(seq -> {
- Msg.debug(this, "Attaching...");
- TargetAttacher<?> attacher = root.get().as(TargetAttacher.tclass);
- attacher.attach(refPid(client, (int) expCloneSpin.pid)).handle(seq::next);
- }).then(seq -> {
- Msg.debug(this, "Waiting for thread");
- ThreadTracker.strongRef.lastThreadRef.waitUntil(r -> r != null).handle(seq::next);
- }, TypeSpec.cls(TargetObjectRef.class)).then((threadRef, seq) -> {
- Msg.debug(this, "Got thread ref: " + threadRef);
- threadRef.fetch().handle(seq::next);
- }, attachedThread).then(seq -> {
- Msg.debug(this, "Killing...");
- TargetKillable<?> killable = attachedThread.get().as(TargetKillable.tclass);
- killable.kill().handle(seq::next);
- }).finish());
- }
- }
-
- @Test
- public void testExpReadRIP() throws Throwable {
- String expCloneExit = DummyProc.which("expCloneExit");
- try (SctlStub stub = runSctl()) {
- AsynchronousSocketChannel socket = AsynchronousSocketChannel.open();
- SctlClient client = new SctlClient("Test", socket);
- AtomicReference<TargetObject> root = new AtomicReference<>();
- AtomicReference<TargetRegisterBank<?>> regs = new AtomicReference<>();
- AtomicReference<TargetMemory<?>> memory = new AtomicReference<>();
- AtomicReference<Address> rip = new AtomicReference<>();
- waitOn(sequence(TypeSpec.VOID).then(seq -> {
- Msg.debug(this, "Connecting...");
- completable(TypeSpec.VOID, socket::connect, stub.addr).handle(seq::next);
- }).then(seq -> {
- Msg.debug(this, "Negotiating...");
- client.connect().handle(seq::next);
- }).then(seq -> {
- Msg.debug(this, "Getting model root");
- client.fetchModelRoot().handle(seq::next);
- }, root).then(seq -> {
- Msg.debug(this, "Initializing thread tracker");
- trackThreads(root.get()).init().handle(seq::next);
- }).then(seq -> {
- Msg.debug(this, "Launching...");
- TargetLauncher<?> launcher = root.get().as(TargetLauncher.tclass);
- launcher.launch(Map.of(TargetCmdLineLauncher.CMDLINE_ARGS_NAME, expCloneExit))
- .handle(seq::next);
- }).then(seq -> {
- Msg.debug(this, "Waiting for thread");
- ThreadTracker.strongRef.lastThreadRef.waitUntil(r -> r != null).handle(seq::next);
- }, TypeSpec.cls(TargetObjectRef.class)).then((threadRef, seq) -> {
- Msg.debug(this, "Got thread ref: " + threadRef);
- threadRef.fetchSuccessor("Registers").thenAccept(obj -> {
- regs.set(obj.as(TargetRegisterBank.tclass));
- }).handle(seq::next);
- }).then(seq -> {
- Msg.debug(this, "Reading rip");
- regs.get().readRegister("rip").handle(seq::next);
- }, TypeSpec.BYTE_ARRAY).then((data, seq) -> {
- long ripVal = ByteBuffer.wrap(data).order(ByteOrder.BIG_ENDIAN).getLong(0);
- rip.set(client.getAddress("ram", ripVal));
- Msg.debug(this, "RIP = " + Long.toHexString(ripVal));
- ThreadTracker.strongRef.lastProcRef.get()
- .fetchSuccessor("Memory")
- .thenAccept(obj -> {
- memory.set(obj.as(TargetMemory.tclass));
- })
- .handle(seq::next);
- }).then(seq -> {
- Msg.debug(this, "Reading memory[rip:8]");
- memory.get().readMemory(rip.get(), 8).handle(seq::next);
- // TODO: Can I assert what actual reads went over the network?
- // Expect: [rip:8], [rip+8:1], (none)
- }, TypeSpec.BYTE_ARRAY).then((data, seq) -> {
- Msg.debug(this,
- "Read memory[rip:8]: " + NumericUtilities.convertBytesToString(data, ":"));
- memory.get().readMemory(rip.get().add(1), 8).handle(seq::next);
- }, TypeSpec.BYTE_ARRAY).then((data, seq) -> {
- Msg.debug(this,
- "Read memory[rip+1:8]: " + NumericUtilities.convertBytesToString(data, ":"));
- memory.get().readMemory(rip.get().add(2), 5).handle(seq::next);
- }, TypeSpec.BYTE_ARRAY).then((data, seq) -> {
- Msg.debug(this,
- "Read memory[rip+2:5]: " + NumericUtilities.convertBytesToString(data, ":"));
- seq.exit();
- }).finish());
- }
- }
-
- @Test
- public void testExpWrite() throws Throwable {
- String expPrint = DummyProc.which("expPrint");
- final String toWrite = "Speak";
- final String expected = "Speak, World!";
- try (SctlStub stub = runSctl()) {
- AsynchronousSocketChannel socket = AsynchronousSocketChannel.open();
- SctlClient client = new SctlClient("Test", socket);
- AtomicReference<TargetObject> root = new AtomicReference<>();
- AtomicReference<TargetObject> thread = new AtomicReference<>();
- AtomicReference<TargetSymbol<?>> overwrite = new AtomicReference<>();
- AtomicReference<TargetMemory<?>> memory = new AtomicReference<>();
- waitOn(sequence(TypeSpec.VOID).then(seq -> {
- Msg.debug(this, "Connecting...");
- completable(TypeSpec.VOID, socket::connect, stub.addr).handle(seq::next);
- }).then(seq -> {
- Msg.debug(this, "Negotiating...");
- client.connect().handle(seq::next);
- }).then(seq -> {
- Msg.debug(this, "Getting model root");
- client.fetchModelRoot().handle(seq::next);
- }, root).then(seq -> {
- Msg.debug(this, "Initializing thread tracker");
- trackThreads(root.get()).init().handle(seq::next);
- }).then(seq -> {
- Msg.debug(this, "Launching...");
- TargetLauncher<?> launcher = root.get().as(TargetLauncher.tclass);
- launcher.launch(Map.of(TargetCmdLineLauncher.CMDLINE_ARGS_NAME, expPrint))
- .handle(seq::next);
- }).then(seq -> {
- Msg.debug(this, "Waiting for thread");
- ThreadTracker.strongRef.lastThreadRef.waitUntil(r -> r != null).handle(seq::next);
- }, TypeSpec.cls(TargetObjectRef.class)).then((threadRef, seq) -> {
- Msg.debug(this, "Got thread ref: " + threadRef);
- threadRef.fetch().handle(seq::next);
- }, thread).then(seq -> {
- ThreadTracker.strongRef.lastProcRef.get()
- .fetchSuccessor(
- PathUtils.parse("Modules[" + expPrint + "].Symbols[overwrite]"))
- .handle(seq::next);
- }, TypeSpec.cls(TargetObject.class)).then((obj, seq) -> {
- overwrite.set(obj.as(TargetSymbol.tclass));
- Msg.debug(this, "overwrite is at addr: " + overwrite.get().getValue());
- ThreadTracker.strongRef.lastProcRef.get()
- .fetchSuccessor("Memory")
- .handle(seq::next);
- }, TypeSpec.cls(TargetObject.class)).then((obj, seq) -> {
- memory.set(obj.as(TargetMemory.tclass));
- Msg.debug(this, "Writing memory");
- memory.get()
- .writeMemory(overwrite.get().getValue(), toWrite.getBytes())
- .handle(seq::next);
- }).then(seq -> {
- Msg.debug(this, "Reading memory");
- memory.get()
- .readMemory(overwrite.get().getValue(), expected.getBytes().length)
- .handle(seq::next);
- }, TypeSpec.BYTE_ARRAY).then((data, seq) -> {
- Msg.debug(this, "Read: " + new String(data));
- assertEquals(expected, new String(data));
- resumeWhile(thread.get(), t -> true).handle(seq::next);
- }).then(seq -> {
- Msg.debug(this, "Waiting for exit");
- ThreadTracker.strongRef.lastExitCode.waitUntil(v -> v != null).handle(seq::next);
- }, TypeSpec.cls(Long.class)).then((exit, seq) -> {
- assertEquals(toWrite.getBytes()[0], exit / 256);
- seq.exit();
- }).finish());
- }
- }
-
- @Test
- public void testExpTypes() throws Throwable {
- String expTypes = DummyProc.which("expTypes");
- DataTypeManager dtm = new StandAloneDataTypeManager("Test") {
- {
- dataOrganization =
- DataOrganizationImpl.getDefaultOrganization(getSLEIGH_X86_64_LANGUAGE());
- }
- };
-
- try (SctlStub stub = runSctl()) {
- AsynchronousSocketChannel socket = AsynchronousSocketChannel.open();
- SctlClient client = new SctlClient("Test", socket);
- AtomicReference<TargetObject> root = new AtomicReference<>();
- waitOn(sequence(TypeSpec.VOID).then(seq -> {
- Msg.debug(this, "Connecting...");
- completable(TypeSpec.VOID, socket::connect, stub.addr).handle(seq::next);
- }).then(seq -> {
- Msg.debug(this, "Negotiating...");
- client.connect().handle(seq::next);
- }).then(seq -> {
- Msg.debug(this, "Getting model root");
- client.fetchModelRoot().handle(seq::next);
- }, root).then(seq -> {
- Msg.debug(this, "Initializing thread tracker");
- trackThreads(root.get()).init().handle(seq::next);
- }).then(seq -> {
- Msg.debug(this, "Launching...");
- TargetLauncher<?> launcher = root.get().as(TargetLauncher.tclass);
- launcher.launch(Map.of(TargetCmdLineLauncher.CMDLINE_ARGS_NAME, expTypes))
- .handle(seq::next);
- }).then(seq -> {
- Msg.debug(this, "Waiting for process");
- ThreadTracker.strongRef.lastProcRef.waitUntil(r -> r != null).handle(seq::next);
- }, TypeSpec.cls(TargetObjectRef.class)).then((procRef, seq) -> {
- Msg.debug(this, "Got process ref: " + procRef);
- procRef.fetchSubElements(PathUtils.parse("Modules[" + expTypes + "].Types"))
- .thenCompose(DebugModelConventions::fetchAll)
- .handle(seq::next);
- }, DebuggerObjectModel.ELEMENT_MAP_TYPE).then((types, seq) -> {
- Msg.debug(this, "Converting data types");
- TargetDataTypeConverter conv = new TargetDataTypeConverter(dtm);
- AsyncFence fence = new AsyncFence();
- for (TargetObject obj : types.values()) {
- TargetDataType tdt = obj.as(TargetNamedDataType.tclass);
- fence.include(conv.convertTargetDataType(tdt).thenAccept(t -> {
- synchronized (dtm) {
- try (UndoableTransaction tid =
- UndoableTransaction.start(dtm, "Add type", true)) {
- dtm.addDataType(t, DataTypeConflictHandler.DEFAULT_HANDLER);
- }
- }
- }));
- }
- fence.ready().handle(seq::next);
- }).then(seq -> {
- // TODO: Figure out why offsets are lining up
- // I figure it's either alignment, or incorrect int size
- Msg.debug(this, "Printing data types:");
- try (PrintWriter writer = new PrintWriter(System.out)) {
- DataTypeWriter dtw = new DataTypeWriter(dtm, writer);
- List<DataType> all = new ArrayList<>();
- dtm.getAllDataTypes(all);
- dtw.write(all, TaskMonitor.DUMMY);
- }
- catch (Throwable e) {
- throw new AssertionError(e);
- }
- seq.exit();
- }).finish());
- }
- }
-
- @Test
- public void testExpSymbols() throws Throwable {
- String expTypes = DummyProc.which("expTypes");
- try (SctlStub stub = runSctl()) {
- AsynchronousSocketChannel socket = AsynchronousSocketChannel.open();
- SctlClient client = new SctlClient("Test", socket);
- AtomicReference<TargetObject> root = new AtomicReference<>();
- waitOn(sequence(TypeSpec.VOID).then(seq -> {
- Msg.debug(this, "Connecting...");
- completable(TypeSpec.VOID, socket::connect, stub.addr).handle(seq::next);
- }).then(seq -> {
- Msg.debug(this, "Negotiating...");
- client.connect().handle(seq::next);
- }).then(seq -> {
- Msg.debug(this, "Getting model root");
- client.fetchModelRoot().handle(seq::next);
- }, root).then(seq -> {
- Msg.debug(this, "Initializing thread tracker");
- trackThreads(root.get()).init().handle(seq::next);
- }).then(seq -> {
- Msg.debug(this, "Launching...");
- TargetLauncher<?> launcher = root.get().as(TargetLauncher.tclass);
- launcher.launch(Map.of(TargetCmdLineLauncher.CMDLINE_ARGS_NAME, expTypes))
- .handle(seq::next);
- }).then(seq -> {
- Msg.debug(this, "Waiting for process");
- ThreadTracker.strongRef.lastProcRef.waitUntil(r -> r != null).handle(seq::next);
- }, TypeSpec.cls(TargetObjectRef.class)).then((procRef, seq) -> {
- Msg.debug(this, "Got process ref: " + procRef);
- procRef.fetchSubElements(PathUtils.parse("Modules[" + expTypes + "].Symbols"))
- .thenCompose(DebugModelConventions::fetchAll)
- .handle(seq::next);
- }, DebuggerObjectModel.ELEMENT_MAP_TYPE).then((symbols, seq) -> {
- Msg.debug(this, "Printing symbols:");
- for (TargetObject sym : symbols.values()) {
- Msg.debug(this, " " + sym);
- }
- Msg.debug(this, "Done");
- seq.exit();
- }).finish());
- }
- }
-
- /**
- * Experiment to see what notifications SCTL sends when we clone then exec
- *
- * In particular what does it say about the threads that are destroyed by the call to exec?
- */
- @Test
- @Ignore("Eexec is unreliable in the reference stub")
- public void testCloneExec() throws Throwable {
- String expCloneExec = DummyProc.which("expCloneExec");
- try (SctlStub stub = runSctl()) {
- AsynchronousSocketChannel socket = AsynchronousSocketChannel.open();
- SctlClient client = new SctlClient("Test", socket);
- AtomicReference<TargetObject> root = new AtomicReference<>();
- AtomicReference<TargetObject> launchedThread = new AtomicReference<>();
- waitOn(sequence(TypeSpec.VOID).then(seq -> {
- Msg.debug(this, "Connecting...");
- completable(TypeSpec.VOID, socket::connect, stub.addr).handle(seq::next);
- }).then(seq -> {
- Msg.debug(this, "Negotiating...");
- client.connect().handle(seq::next);
- }).then(seq -> {
- Msg.debug(this, "Getting model root");
- client.fetchModelRoot().handle(seq::next);
- }, root).then(seq -> {
- Msg.debug(this, "Initializing thread tracker");
- trackThreads(root.get()).init().handle(seq::next);
- }).then(seq -> {
- Msg.debug(this, "Launching...");
- TargetLauncher<?> launcher = root.get().as(TargetLauncher.tclass);
- launcher.launch(Map.of(TargetCmdLineLauncher.CMDLINE_ARGS_NAME, expCloneExec))
- .handle(seq::next);
- }).then(seq -> {
- Msg.debug(this, "Waiting for launched thread ref");
- ThreadTracker.strongRef.lastThreadRef.waitUntil(r -> r != null).handle(seq::next);
- }, TypeSpec.cls(TargetObjectRef.class)).then((threadRef, seq) -> {
- ThreadTracker.strongRef.lastThreadRef.set(null, null);
- Msg.debug(this, "Got thread ref: " + threadRef);
- threadRef.fetch().handle(seq::next);
- }, launchedThread).then(seq -> {
- Msg.debug(this, "Resuming until another thread appears: " + launchedThread.get());
- resumeWhile(launchedThread.get(), t -> {
- TargetObjectRef ref = ThreadTracker.strongRef.lastThreadRef.get();
- Msg.debug(this, "lastThreadRef = " + ref);
- return ref == null;
- }).handle(seq::next);
- }).then(seq -> {
- Msg.debug(this, "Resuming until a thread disappears: " + launchedThread.get());
- ThreadTracker.strongRef.lastThreadRemoved.set(null, null);
- resumeWhile(launchedThread.get(), t -> {
- TargetObjectRef ref = ThreadTracker.strongRef.lastThreadRemoved.get();
- Msg.debug(this, "lastThreadRemoved = " + ref);
- return ref == null;
- }).handle(seq::next);
- }).then(seq -> {
- Msg.debug(this, "Checking number of threads");
- ThreadTracker.strongRef.lastProcRef.get()
- .fetchSubElements("Threads")
- .thenCompose(DebugModelConventions::fetchAll)
- .handle(seq::next);
- }, DebuggerObjectModel.ELEMENT_MAP_TYPE).then((threads, seq) -> {
- Msg.debug(this, "Got threads: " + threads);
- assertEquals(1, threads.size());
- seq.exit();
- }).finish());
- }
- }
-}
diff --git a/Ghidra/Debug/Debugger-sctl/src/test/java/ghidra/dbg/sctl/client/SctlPacketsTest.java b/Ghidra/Debug/Debugger-sctl/src/test/java/ghidra/dbg/sctl/client/SctlPacketsTest.java
deleted file mode 100644
index 13d9eba986..0000000000
--- a/Ghidra/Debug/Debugger-sctl/src/test/java/ghidra/dbg/sctl/client/SctlPacketsTest.java
+++ /dev/null
@@ -1,88 +0,0 @@
-/* ###
- * 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 ghidra.dbg.sctl.client;
-
-import static org.junit.Assert.assertEquals;
-
-import java.nio.ByteBuffer;
-import java.nio.ByteOrder;
-import java.util.Arrays;
-
-import org.junit.Test;
-
-import ghidra.comm.packet.PacketCodec;
-import ghidra.comm.packet.PacketFactory;
-import ghidra.comm.packet.binary.ByteBufferPacketCodec;
-import ghidra.comm.packet.err.PacketDecodeException;
-import ghidra.comm.packet.err.PacketEncodeException;
-import ghidra.dbg.sctl.protocol.AbstractSelSctlPacket;
-import ghidra.dbg.sctl.protocol.common.notify.AbstractSctlListsLibrariesEventNotification.PathBase;
-import ghidra.dbg.sctl.protocol.common.notify.SctlEventNotify;
-import ghidra.dbg.sctl.protocol.common.notify.SctlLoadNotification;
-import ghidra.dbg.sctl.protocol.v2012base.x86.SctlX86Context;
-import ghidra.dbg.sctl.protocol.v2012ext.SelSctl2012ExtPacket;
-import ghidra.dbg.sctl.protocol.v2012ext.x86.linux.Sctl2012ExtLinuxX86Dialect;
-import ghidra.util.NumericUtilities;
-
-public class SctlPacketsTest {
- /*
- * This one was giving me trouble. Decoding by hand seems to work.
- */
- @Test
- public void testDecode2012BusLoadNotification()
- throws PacketDecodeException, PacketEncodeException {
- String hexStr = "" + //
- "10010000000000000300000000ffffff" + // ................
- "ffffffffff0004000000000000010000" + // ................
- "00000000000b000000000000002f7573" + // ............./us
- "722f62696e2f6464ffffffffffffffff" + // r/bin/dd........
- "00000000000000000000000000000000" + // ................
- "00000000000000000000000000000000" + // ................
- "00000000000000000000000000000000" + // ................
- "00000000000000000000000000000000" + // ................
- "00000000000000000000000000000000" + // ................
- "00000000000000000000000000000000" + // ................
- "00000000000000000000000000000000" + // ................
- "00000000000000000000000000000000" + // ................
- "00000000000000000000000000000000" + // ................
- "00000000000000000000000000000000" + // ................
- "00000000000000000000000000000000" + // ................
- "00000000000000000000000000000000" + // ................
- "00000000000000000000000000000000" + // ................
- "0000000000000000"; // ........
- ByteBuffer inbuf = ByteBuffer.wrap(NumericUtilities.convertStringToBytes(hexStr));
- inbuf.order(ByteOrder.LITTLE_ENDIAN);
- int len = (int) inbuf.getLong();
- assertEquals(272, inbuf.remaining());
- assertEquals(272, len);
-
- final PacketCodec<ByteBuffer> codec = ByteBufferPacketCodec.getInstance();
- PacketFactory factory = Sctl2012ExtLinuxX86Dialect.INSTANCE.getPacketFactory();
- factory.registerTypes(codec);
-
- AbstractSelSctlPacket rcvd =
- codec.decodePacket(AbstractSelSctlPacket.class, inbuf, factory);
-
- SelSctl2012ExtPacket exp = new SelSctl2012ExtPacket(0,
- new SctlEventNotify(-1,
- new SctlLoadNotification(
- Arrays.asList(new PathBase[] { new PathBase("/usr/bin/dd", -1) }),
- new SctlX86Context())));
- codec.encodePacket(exp); // Fill the auto fields
-
- assertEquals(exp, rcvd);
- }
-}
diff --git a/Ghidra/Debug/Framework-AsyncComm/src/main/java/ghidra/comm/packet/AbstractPacketCodec.java b/Ghidra/Debug/Framework-AsyncComm/src/main/java/ghidra/comm/packet/AbstractPacketCodec.java
deleted file mode 100644
index 7ab636bfe6..0000000000
--- a/Ghidra/Debug/Framework-AsyncComm/src/main/java/ghidra/comm/packet/AbstractPacketCodec.java
+++ /dev/null
@@ -1,596 +0,0 @@
-/* ###
- * 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 ghidra.comm.packet;
-
-import java.io.EOFException;
-import java.io.IOException;
-import java.lang.annotation.Annotation;
-import java.lang.reflect.*;
-import java.util.*;
-import java.util.concurrent.locks.*;
-
-import ghidra.comm.packet.annot.CountedByField;
-import ghidra.comm.packet.annot.RepeatedField;
-import ghidra.comm.packet.annot.impl.*;
-import ghidra.comm.packet.binary.ByteBufferPacketCodec;
-import ghidra.comm.packet.codecs.*;
-import ghidra.comm.packet.err.*;
-import ghidra.comm.packet.fields.*;
-import ghidra.util.Msg;
-
-/**
- * A partial implementation of {@link PacketCodec} that ought to be used as the base for all
- * implementations.
- *
- * The general pattern for encoding packets is to construct a temporary encode buffer, encode the
- * fields of a given packet into that buffer, and then construct the final encoding from that
- * buffer. Conversely, the general pattern for decoding is to load the encoded data into a decode
- * buffer and then decode each field of the given packet from that buffer. In some cases, e.g.,
- * {@link ByteBufferPacketCodec}, all three forms may be fulfilled by the same class.
- *
- * Fields may be annotated to change its behavior and/or encoding. Some behaviors are implemented by
- * the annotation, others are implemented by the codec. During packet registration, a chain of
- * {@link FieldCodec}s is constructed for each {@link PacketField}-annotated field. It is best to
- * picture these chains from top to bottom, where the top {@link FieldCodec} is provided by the
- * packet codec -- via its {@link FieldCodecFactory} interface. The next codec is provided by the
- * first annotation -- other than {@link PacketField} -- applied to the field. The top codec is
- * closest to the encoded data. The bottom codec in the chain is provided by the last annotation
- * applied to the field. This codec is closest to the decoded data. To decode, data moves from top
- * to bottom. To encode, data moves from bottom to top.
- *
- * To construct the chain, the {@link WrapperFactory} is obtained for each annotation applied to the
- * field via {@link #getFactoryForAnnotation(Class, Field, Annotation)}. This permits different
- * codecs to implement annotations differently. Some annotations are universally applicable, and
- * they provide their own implementations. Thus, the packet codec ought to check for such an
- * implementation. Implementations using {@link AbstractPacketCodec} need only delegate to the super
- * method. To facilitate interaction among fields, a factory in one chain may also inject another
- * factory into the bottom of a preceding field's chain. The factories then begin building the
- * {@link FieldCodec}s from bottom to top.
- *
- * First, the type of the field is determined by reflection. Then the chain is asked for a
- * {@link FieldCodec} for that type, via
- * {@link FieldCodecFactory#buildChainForType(Class, Field, Class, PacketCodec, Deque)}. This method
- * is given the list of remaining wrapper factories. If it is empty, it obtains the field codec for
- * the type directly from the {@link FieldCodecFactory}, i.e., this {@link PacketCodec}. Otherwise,
- * it obtains a field codec from the next wrapper factory. That factory will in turn request the
- * field codec(s) for any type(s) it requires following the same method recursively. If at any
- * point, a factory cannot produce a codec for the type required by a lower codec, the packet
- * definition fails validation for this codec.
- *
- * Take the following example:
- *
- * <pre>
- * public class ListOfInt extends Packet {
- * &#64;PacketField
- * public int count;
- *
- * &#64;PacketField
- * &#64;RepeatedField
- * &#64;CountedByField("count")
- * public List<Integer> list;
- * }
- * </pre>
- *
- * First, the chains are built by processing the annotations. In this case, both annotations provide
- * their own implementations: {@link RepeatedField} is implemented by
- * {@link RepeatedFieldWrapperFactory}, and {@link CountedByField} is implemented by
- * {@link CountedByFieldWrapperFactory}. Thus, the chains initially look like this:
- *
- * <ul>
- * <li>{@code count}: []</li>
- * <li>{@code list}: [{@link CountedByFieldWrapperFactory},
- * {@link RepeatedFieldWrapperFactory}]</li>
- * </ul>
- *
- * Chain construction starts with the last field, and each chain is constructed by applying the
- * annotations from the bottom up. Thus, to start {@link FieldCodec} construction,
- * {@link CountedByFieldWrapperFactory} is asked for a field codec for
- * {@link List}{@code <}{@link Integer}{@code >}. It can provide one, because it knows how to count
- * elements of a list. It does not need to transform the list itself, so it will request the same
- * type from {@link RepeatedFieldWrapperFactory}. However, it needs to be able to modify the field
- * {@code count}, so it injects {@link CountedByFieldInjectionFactory} into {@code count}'s chain,
- * which will affect its field codecs. In the meantime, {@link RepeatedFieldWrapper} can provide a
- * field codec for {@link List}{@code <}{@link Integer}{@code >}, because it expects a collection or
- * an array. However, to encode each element, it needs a field codec for {@link Integer}. Because
- * there are no more wrapper factories in the chain, it asks the {@link FieldCodecFactory} for a
- * primitive {@link Integer} field codec, which it ought to provide.
- *
- * Then, we construct the chain for the {@code count} field, which now consists of
- * [{@link CountedByFieldInjectionFactory}]. Thus, it is asked for an {@link Integer} field codec.
- * Because the injection expects a numeric field, it provides one. This codec does not change the
- * type, but will modify the value, thus it asks the {@link FieldCodecFactory} for a primitive
- * {@link Integer} field codec, and the packet registration is complete.
- *
- * When encoding a {@code ListOfInt}, e.g., having entries [10, 9, 8], the codec starts with an
- * empty encode buffer at the {@code count} field. The data can be pictured moving through the
- * annotations from bottom to top, starting with the field value and remembering that injection
- * occurs at the bottom. Thus, we start with the current value of {@code count}, which might as well
- * be 0. The codec injected by {@link CountedByFieldInjectionFactory} is asked to encode that 0. It
- * then counts the number of elements in {@code list} and overwrites the value of {@code count} with
- * 3. It then asks the primitive {@link Integer} codec to encode that 3, so 3 is encoded and
- * appended to the buffer.
- *
- * It then proceeds to the {@code list} field, whose value is [10, 9, 8]. The field codec given by
- * {@link CountedByFieldWrapperFactory} does not modify this value. It asks the next codec up to
- * encode it. The field codec given by {@link RepeatedFieldWrapperFactory} iterates over each
- * element in the list, asking the next codec up to encode it. The next codec up is the primitive
- * {@link Integer} field codec. Thus, 10, 9, and 8 are encoded into the buffer in order. The buffer
- * is then converted to the final output type and returned to the caller of
- * {@link #encodePacket(Packet)}. If primitives are encoded, e.g., as big-endian binary bytes, the
- * result would be {@code 00000003 0000000a 00000009 00000008}.
- *
- * When decoding a {@code ListOfInt}, the codec starts by placing the data into a decode buffer and
- * begins decoding {@code count}. The data can be pictured moving through the annotations from top
- * to bottom, though the request to decode moves from bottom to top. The injected field codec on
- * {@code count} given by {@link CountedByFieldInjectionFactory} does not modify the request or the
- * data. Thus, a 3 is decoded and stored into {@code count}. Decoding then proceeds to {@code list}.
- * The field codec given by {@link CountedByFieldWrapperFactory} modifies the request, indicating
- * that 3 elements are expected. The field codec given by {@link RepeatedFieldWrapperFactory} then
- * forwards 3 requests, one at a time, to the next codec up. That codec, being a primitive
- * {@link Integer} field codec, then decodes and returns each value 10, 9, and 8 back down the
- * chain. The {@link RepeatedField} codec then packs those into a {@link List}, returning it to the
- * next field codec down. The {@link CountedByField} codec simply returns the result without
- * modification, which is then stored into {@code list}, completing the decode.
- *
- * @param <T> the type of encoded packets
- * @param <ENCBUF> the type of temporary buffer used to encode
- * @param <DECBUF> the type of temporary buffer used to decode
- */
-public abstract class AbstractPacketCodec<T, ENCBUF, DECBUF> extends
- AbstractFieldCodecFactory<ENCBUF, DECBUF> implements PacketCodecInternal<T, ENCBUF, DECBUF>,
- PrimitiveFactory<ENCBUF, DECBUF>, PrimitiveCodec<ENCBUF, DECBUF> {
-
- private final Map<Field, Deque<FieldCodecFactory<ENCBUF, DECBUF>>> fieldChains =
- new LinkedHashMap<>();
- private final Map<Field, FieldCodec<ENCBUF, DECBUF, ?>> fieldCodecs = new HashMap<>();
- private final Set<Class<? extends Packet>> registry = new HashSet<>();
-
- private final ReadWriteLock lock = new ReentrantReadWriteLock();
- private final Lock readLock = lock.readLock();
- private final Lock writeLock = lock.writeLock();
-
- /**
- * Finalize the encoding by converting an encode buffer into encoded data
- *
- * For some codecs, this is a NOP.
- *
- * @param buf the encode buffer to finalize
- * @return the finalized data
- */
- protected abstract T finishEncode(ENCBUF buf);
-
- /**
- * Register a single field of a packet type
- *
- * This constructs field codec by linking the applicable wrappers in a chain. For most fields,
- * the chain is one element derived from its declared type. Annotated fields (other than
- * {@link PacketField}) and those referred to by annotated fields may have more complex chains.
- *
- * @see #getFactoryForAnnotation(Class, Field, Annotation)
- *
- * @param pkt the packet type declaring the field
- * @param field the field to register
- * @param allFields a list of all other fields, in order, contained in the packet type
- */
- protected <A extends Annotation> void registerField(Class<? extends Packet> pkt, Field field,
- List<Field> allFields) {
- LinkedList<FieldCodecFactory<ENCBUF, DECBUF>> codecChain = new LinkedList<>();
- codecChain.push(this);
- for (Annotation annot : field.getAnnotations()) {
- if (annot.annotationType() == PacketField.class) {
- continue;
- }
- FieldCodecFactory<ENCBUF, DECBUF> factory = getFactoryForAnnotation(pkt, field, annot);
- if (factory == null) {
- continue;
- }
- codecChain.push(factory);
- }
- fieldChains.put(field, codecChain);
- }
-
- /**
- * Decodes a field and store or compare its value in the corresponding packet field
- *
- * If the field is non-final, its value is set to the decoded field value. If the field is
- * final, then its value is checked for equality with the final value. If the final value has
- * countable elements, then it is measured and the count passed to the field decoder.
- *
- * @see #decodeField(Packet, Field, Object, Integer, PacketFactory)
- *
- * @param pkt the packet whose field to decode
- * @param field the field to decode
- * @param buf the buffer positioned at the encoded field
- * @param factory a packet factory controlling version and dialect
- * @throws IOException if there is an issue accessing a device or buffer
- * @throws PacketDecodeException if the packet is not well formed
- */
- protected <U> void decodeAndStoreField(Packet pkt, Field field, DECBUF buf,
- PacketFactory factory) throws IOException, PacketDecodeException {
- try {
- int mod = field.getModifiers();
- Object reqObj = null;
- Integer count = null;
- if (Modifier.isFinal(mod)) {
- reqObj = field.get(pkt);
- if (!field.getType().isPrimitive() && !field.getType().isEnum()) {
- count = measureCount(reqObj);
- }
- }
- U decObj = decodeField(pkt, field, buf, count, factory);
- if (Modifier.isFinal(mod)) {
- if (!reqObj.equals(decObj)) {
- throw new PacketFieldValueMismatchException(field, reqObj.toString(),
- decObj.toString());
- }
- }
- else {
- field.set(pkt, decObj);
- }
- }
- catch (IllegalAccessException e) {
- throw new RuntimeException(e);
- }
- }
-
- @Override
- public <P extends Packet> P decodePacket(Packet parent, Field field, DECBUF buf,
- Class<P> pktType, PacketFactory factory) throws IOException, PacketDecodeException {
- readLock.lock();
- try {
- //Msg.debug(this, "PACKET: Descending into: " + pktType);
- P val = factory.newPacket(pktType);
- if (!registry.contains(val.getClass())) {
- throw new IllegalArgumentException("decoding " + field + ": constructed type " +
- val.getClass() + " is not registered with this codec.");
- }
- Collection<Field> fields = Packet.getFields(val.getClass());
- val.setParent(parent);
- for (Field f : fields) {
- decodeAndStoreField(val, f, buf, factory);
- }
- //Msg.debug(this, "PACKET: Ascending from " + pktType);
- return val;
- }
- catch (InstantiationException | IllegalAccessException | IllegalArgumentException
- | InvocationTargetException | NoSuchMethodException | SecurityException e) {
- throw new RuntimeException("Failed to instantiate " + pktType, e);
- }
- finally {
- readLock.unlock();
- }
- }
-
- @Override
- public void encodePacket(ENCBUF buf, Field field, Packet val)
- throws IOException, PacketEncodeException {
- readLock.lock();
- try {
- if (val == null) {
- throw new NullPointerException("field " + field + " cannot be encoded with null");
- }
- Class<? extends Packet> pktType = val.getClass();
- if (!registry.contains(pktType)) {
- if (field == null) {
- throw new IllegalArgumentException(
- "packet type " + val.getClass() + " is not registered with this codec.");
- }
- throw new IllegalArgumentException(
- "field " + field + " has value of an unregistered type: " + val);
- }
- Collection<Field> fields = Packet.getFields(pktType);
- for (Field f : fields) {
- encodeField(buf, val, f, f.get(val));
- }
- }
- catch (IllegalAccessException e) {
- throw new RuntimeException(e);
- }
- finally {
- readLock.unlock();
- }
- }
-
- @Override
- public void registerPacketType(Class<? extends Packet> pkt) {
- writeLock.lock();
- try {
- if (registry.contains(pkt)) {
- return; // Avoid infinite recursion
- }
-
- int mod = pkt.getModifiers();
- if (pkt.getDeclaringClass() != null && !Modifier.isStatic(mod)) {
- throw new IllegalArgumentException(
- "Cannot register non-static inner class " + pkt + " as packet");
- }
- if (Modifier.isAbstract(mod)) {
- // Packet factories permit fields to have abstract types
- // The user will need to register the concrete types, though
- registry.add(pkt);
- return;
- }
- // Failure will cause NoSuchMethodException or SecurityException
- @SuppressWarnings("unused")
- Constructor<?> cons = pkt.getConstructor();
-
- registry.add(pkt);
- List<Field> fields = Packet.getFields(pkt);
- Deque<Field> revFields = new LinkedList<>();
- for (Field f : fields) {
- registerField(pkt, f, fields);
- revFields.push(f);
- }
- for (Field f : revFields) {
- Deque<FieldCodecFactory<ENCBUF, DECBUF>> codecChain = fieldChains.get(f);
- FieldCodec<ENCBUF, DECBUF, ?> fieldCodec =
- FieldCodecFactory.buildChainForType(pkt, f, f.getType(), this, codecChain);
- fieldCodecs.put(f, fieldCodec);
- }
- }
- catch (NoSuchMethodException | SecurityException e) {
- throw new PacketDeclarationException(pkt,
- "Packet must have accessible default constructor", e);
- }
- finally {
- writeLock.unlock();
- }
- }
-
- @Override
- public <U> U decodeField(Packet pkt, Field field, DECBUF buf, Integer count,
- PacketFactory factory) throws IOException, PacketDecodeException {
- //Msg.debug(this, "PACKET: Decoding " + pkt.getClass().getSimpleName() + "." + field.getName());
- @SuppressWarnings("unchecked")
- FieldCodec<ENCBUF, DECBUF, U> fieldCodec =
- (FieldCodec<ENCBUF, DECBUF, U>) fieldCodecs.get(field);
- U u = fieldCodec.decodeField(pkt, buf, count, factory);
- //Msg.debug(this, "PACKET: " + field.getName() + " = " + u);
- return u;
- }
-
- @Override
- public <P extends Packet> P decodePacket(Class<P> pktType, T data, PacketFactory factory)
- throws PacketDecodeException {
- readLock.lock();
- try {
- if (!registry.contains(pktType)) {
- throw new IllegalArgumentException(
- "Cannot decode unregistered packet type: " + pktType);
- }
- DECBUF buf = newDecodeBuffer(data);
- P result = decodePacket(null, null, buf, pktType, factory);
- if (measureDecodeRemaining(buf) != 0) {
- throw new InvalidPacketException("Packet did not consume given buffer: " + buf);
- }
- return result;
- }
- catch (RuntimeException e) {
- throw e;
- }
- catch (EOFException e) {
- throw new InvalidPacketException("Reached end of buffer before decoding finished", e);
- }
- catch (PacketDecodeException e) {
- throw e;
- }
- catch (Exception e) {
- throw new AssertionError("Internal error", e);
- }
- finally {
- readLock.unlock();
- }
- }
-
- protected String toTruncatedString(Object obj, int maxLen) {
- if (maxLen < 3) {
- throw new IllegalArgumentException("Too short, no?");
- }
- String str = obj.toString();
- if (str.length() > maxLen) {
- return str.substring(0, maxLen - 3) + "...";
- }
- return str;
- }
-
- @Override
- public <U> void encodeField(ENCBUF buf, Packet pkt, Field field, U val)
- throws IOException, PacketEncodeException {
- @SuppressWarnings("unchecked")
- FieldCodec<ENCBUF, DECBUF, U> fieldCodec =
- (FieldCodec<ENCBUF, DECBUF, U>) fieldCodecs.get(field);
- try {
- fieldCodec.encodeField(buf, pkt, val);
- }
- catch (Throwable t) {
- Msg.error(this, t + "; while encoding field " + field + " of packet " + pkt.getClass() +
- " of value " + toTruncatedString(val, 30));
- throw t;
- }
- }
-
- @Override
- public void encodePacketInto(ENCBUF buf, Packet pkt) throws PacketEncodeException {
- try {
- encodePacket(buf, null, pkt);
- }
- catch (IOException e) {
- throw new AssertionError("Internal error", e);
- }
- }
-
- @Override
- public T encodePacket(Packet pkt) throws PacketEncodeException {
- try {
- ENCBUF buf = newEncodeBuffer();
- encodePacketInto(buf, pkt);
- return finishEncode(buf);
- }
- catch (RuntimeException e) {
- throw e;
- }
- catch (PacketEncodeException e) {
- throw e;
- }
- catch (Exception e) {
- throw new AssertionError("Internal error", e);
- }
- }
-
- @Override
- public WrapperFactory<ENCBUF, DECBUF> getFactoryForAnnotation(Class<? extends Packet> pkt,
- Field field, Annotation annot) {
- ImplementedBy wrapAnnot = annot.annotationType().getAnnotation(ImplementedBy.class);
- if (wrapAnnot == null) {
- // Some annotations have no meaning unless used with certain codecs.
- // Silently ignore this
- Msg.debug(this, "Ignoring " + annot + " on " + field + " with " + this);
- return null;
- }
-
- @SuppressWarnings("unchecked")
- Class<? extends WrapperFactory<?, ?>> factoryType =
- (Class<? extends WrapperFactory<?, ?>>) wrapAnnot.value();
- WrapperFactory<?, ?> factory;
- try {
- factory = factoryType.getConstructor().newInstance();
- }
- catch (InstantiationException | IllegalAccessException | IllegalArgumentException
- | InvocationTargetException | NoSuchMethodException | SecurityException e) {
- throw new PacketAnnotationException(pkt, field, annot, "Could not build wrapper", e);
- }
- // The following two situations are probably mistakes, in either the annotation or codec
- // implementations, or possibly the packet specification.
- if (!factory.getEncodingBufferClass().isAssignableFrom(this.getEncodingBufferClass())) {
- throw new PacketAnnotationException(pkt, field, annot,
- "Encoder offered by annotation is not compatible with this codec");
- }
- if (!factory.getDecodingBufferClass().isAssignableFrom(this.getDecodingBufferClass())) {
- throw new PacketAnnotationException(pkt, field, annot,
- "Decoder offered by annotation is not compatible with this codec");
- }
-
- @SuppressWarnings("unchecked")
- WrapperFactory<ENCBUF, DECBUF> result = (WrapperFactory<ENCBUF, DECBUF>) factory;
- return result;
- }
-
- @Override
- public <U> FieldCodec<ENCBUF, DECBUF, U> getFieldCodecForType(Class<? extends Packet> pktType,
- Field field, Class<? extends U> fldType) {
- if (Packet.class.isAssignableFrom(fldType)) {
- @SuppressWarnings("unchecked")
- Class<? extends Packet> subPktType = (Class<? extends Packet>) fldType;
-
- registerPacketType(subPktType);
-
- @SuppressWarnings("unchecked")
- FieldCodec<ENCBUF, DECBUF, U> result =
- (FieldCodec<ENCBUF, DECBUF, U>) new PacketFieldCodec<>(this, pktType, field,
- subPktType);
- return result;
- }
- else if (fldType == boolean.class || Boolean.class.isAssignableFrom(fldType)) {
- @SuppressWarnings("unchecked")
- FieldCodec<ENCBUF, DECBUF, U> result =
- (FieldCodec<ENCBUF, DECBUF, U>) new BooleanFieldCodec<>(this, pktType, field);
- return result;
- }
- else if (fldType == byte.class || Byte.class.isAssignableFrom(fldType)) {
- @SuppressWarnings("unchecked")
- FieldCodec<ENCBUF, DECBUF, U> result =
- (FieldCodec<ENCBUF, DECBUF, U>) new ByteFieldCodec<>(this, pktType, field);
- return result;
- }
- else if (fldType == char.class || Character.class.isAssignableFrom(fldType)) {
- @SuppressWarnings("unchecked")
- FieldCodec<ENCBUF, DECBUF, U> result =
- (FieldCodec<ENCBUF, DECBUF, U>) new CharacterFieldCodec<>(this, pktType, field);
- return result;
- }
- else if (fldType == short.class || Short.class.isAssignableFrom(fldType)) {
- @SuppressWarnings("unchecked")
- FieldCodec<ENCBUF, DECBUF, U> result =
- (FieldCodec<ENCBUF, DECBUF, U>) new ShortFieldCodec<>(this, pktType, field);
- return result;
- }
- else if (fldType == int.class || Integer.class.isAssignableFrom(fldType)) {
- @SuppressWarnings("unchecked")
- FieldCodec<ENCBUF, DECBUF, U> result =
- (FieldCodec<ENCBUF, DECBUF, U>) new IntegerFieldCodec<>(this, pktType, field);
- return result;
- }
- else if (fldType == long.class || Long.class.isAssignableFrom(fldType)) {
- @SuppressWarnings("unchecked")
- FieldCodec<ENCBUF, DECBUF, U> result =
- (FieldCodec<ENCBUF, DECBUF, U>) new LongFieldCodec<>(this, pktType, field);
- return result;
- }
- else if (fldType == float.class || Float.class.isAssignableFrom(fldType)) {
- @SuppressWarnings("unchecked")
- FieldCodec<ENCBUF, DECBUF, U> result =
- (FieldCodec<ENCBUF, DECBUF, U>) new FloatFieldCodec<>(this, pktType, field);
- return result;
- }
- else if (fldType == double.class || Double.class.isAssignableFrom(fldType)) {
- @SuppressWarnings("unchecked")
- FieldCodec<ENCBUF, DECBUF, U> result =
- (FieldCodec<ENCBUF, DECBUF, U>) new DoubleFieldCodec<>(this, pktType, field);
- return result;
- }
- else if (CharSequence.class.isAssignableFrom(fldType)) {
- @SuppressWarnings("unchecked")
- FieldCodec<ENCBUF, DECBUF, U> result =
- (FieldCodec<ENCBUF, DECBUF, U>) new CharSequenceFieldCodec<>(this, pktType, field);
- return result;
- }
- return null;
- }
-
- @Override
- public void injectChain(Class<? extends Packet> pkt, Field targetField,
- InjectionFactory<ENCBUF, DECBUF> factory, Field annotatedField, Annotation annot) {
- Deque<FieldCodecFactory<ENCBUF, DECBUF>> chain = fieldChains.get(targetField);
- if (chain == null) {
- throw new InvalidFieldNameException(pkt, targetField, annot,
- "Modified field must be a @" + PacketField.class.getSimpleName());
- }
- List<Field> all = Packet.getFields(pkt);
- int targetIdx = all.indexOf(targetField);
- assert targetIdx >= 0;
- int annotatedIdx = all.indexOf(annotatedField);
- assert annotatedIdx >= 0;
- if (annotatedIdx <= targetIdx) {
- throw new AnnotatedFieldOrderingException(pkt, annotatedField, annot,
- "Referenced field must precede the annotated field");
- }
- chain.push(factory);
- }
-
- @Override
- public int measureCount(Object obj) {
- if (obj instanceof String) {
- return ((String) obj).length();
- }
- else if (obj instanceof Collection) {
- return ((Collection<?>) obj).size();
- }
- else if (obj.getClass().isArray()) {
- return Array.getLength(obj);
- }
- throw new IllegalArgumentException("Do not know how to measure length of " + obj);
- }
-}
diff --git a/Ghidra/Debug/Framework-AsyncComm/src/main/java/ghidra/comm/packet/AbstractPacketFactory.java b/Ghidra/Debug/Framework-AsyncComm/src/main/java/ghidra/comm/packet/AbstractPacketFactory.java
deleted file mode 100644
index 2a9a7ba96e..0000000000
--- a/Ghidra/Debug/Framework-AsyncComm/src/main/java/ghidra/comm/packet/AbstractPacketFactory.java
+++ /dev/null
@@ -1,112 +0,0 @@
-/* ###
- * 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 ghidra.comm.packet;
-
-import java.lang.reflect.*;
-import java.util.*;
-
-/**
- * A partial implementation of {@link PacketFactory}
- *
- * This implementation provides reasonable defaults for arrays, lists, and sets. It also provides an
- * easy mechanism {@link #useFor(Class, Class)} to substitute a given class or interface for one of
- * its concrete subclasses or implementations.
- */
-public abstract class AbstractPacketFactory implements PacketFactory {
- private Map<Class<?>, Class<?>> substs = new HashMap<>();
-
- /**
- * Construct a new packet factory
- *
- * This applies the default substitutions: {@link ArrayList} for {@link List}, and
- * {@link LinkedHashSet} for {@link Set}.
- */
- public AbstractPacketFactory() {
- useFor(List.class, ArrayList.class);
- useFor(Set.class, LinkedHashSet.class);
- }
-
- /**
- * Specify an additional substitution for collections and packets
- *
- * When requested to construct a new collection or packet, the factory will check its map of
- * substitutions. If one is present, the substituted class is constructed instead. If one is not
- * present, then the factory attempts to construct the requested class, which may result in an
- * {@link InstantiationException}.
- *
- * @param abs the class, usually abstract, or interface to substitute out
- * @param impl the concrete implementation to substitute in
- */
- protected <T> void useFor(Class<T> abs, Class<? extends T> impl) {
- if (Modifier.isAbstract(impl.getModifiers())) {
- throw new IllegalArgumentException("Implementation class must not be abstract");
- }
- substs.put(abs, impl);
- }
-
- /**
- * Check if a given class has been substituted
- *
- * @param abs the class to check for substitutions
- * @return the concrete substitution, if specified, or null
- */
- @SuppressWarnings("unchecked")
- protected <T> Class<? extends T> getFor(Class<T> abs) {
- return (Class<? extends T>) substs.get(abs);
- }
-
- @Override
- public Object newArray(Class<?> componentType, int length) {
- return Array.newInstance(componentType, length);
- }
-
- @Override
- public <E, C extends Collection<E>> C newCollection(Class<C> colType, Class<E> elemType)
- throws InstantiationException, IllegalAccessException, IllegalArgumentException,
- InvocationTargetException, NoSuchMethodException, SecurityException {
- Class<? extends C> use = getFor(colType);
- if (use != null) {
- return use.getConstructor().newInstance();
- }
- return colType.getConstructor().newInstance();
- }
-
- @Override
- public <P extends Packet> P newPacket(Class<P> pktType)
- throws InstantiationException, IllegalAccessException, IllegalArgumentException,
- InvocationTargetException, NoSuchMethodException, SecurityException {
- Class<? extends P> use = getFor(pktType);
- if (use != null) {
- return use.getConstructor().newInstance();
- }
- return pktType.getConstructor().newInstance();
- }
-
- @SuppressWarnings("unchecked")
- @Override
- public void registerTypes(PacketCodec<?> codec) {
- for (Map.Entry<Class<?>, Class<?>> ent : substs.entrySet()) {
- Class<?> abs = ent.getKey();
- if (Packet.class.isAssignableFrom(abs)) {
- codec.registerPacketType((Class<? extends Packet>) abs);
- }
- Class<?> impl = ent.getValue();
- if (Packet.class.isAssignableFrom(impl)) {
- codec.registerPacketType((Class<? extends Packet>) impl);
- }
- }
- }
-}
diff --git a/Ghidra/Debug/Framework-AsyncComm/src/main/java/ghidra/comm/packet/AbstractPacketMarshaller.java b/Ghidra/Debug/Framework-AsyncComm/src/main/java/ghidra/comm/packet/AbstractPacketMarshaller.java
deleted file mode 100644
index f2fb73cb1e..0000000000
--- a/Ghidra/Debug/Framework-AsyncComm/src/main/java/ghidra/comm/packet/AbstractPacketMarshaller.java
+++ /dev/null
@@ -1,86 +0,0 @@
-/* ###
- * 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 ghidra.comm.packet;
-
-import static ghidra.comm.packet.codecs.PacketCodecInternal.getTypeParameterRaw;
-
-/**
- * A partial implementation of {@link PacketMarshaller} that handles the codec and type registration
- *
- * It also includes a facility for switching from one packet factory to another and registering its
- * packet types.
- *
- * @param <W> the type of packets to write, possibly abstract
- * @param <R> the type of packets to read, possiblt abstract
- * @param <E> the type of the buffer for framing and encoded packets, usually {@link ByteBuffer}
- */
-public abstract class AbstractPacketMarshaller<W extends Packet, R extends Packet, E>
- implements PacketMarshaller<W, R, E> {
- /** The underlying codec */
- protected final PacketCodec<E> codec;
- /** The type to use for reading packets when not overridden */
- protected final Class<? extends R> defaultType;
- /** The current packet factory, initialized to the default packet factory */
- protected PacketFactory factory = DefaultPacketFactory.getInstance();
-
- /**
- * Construct a new marshaller
- *
- * @param codec the underlying codec
- * @param defaultType the type to read when a more-specific type is not given
- */
- @SuppressWarnings("unchecked")
- public AbstractPacketMarshaller(PacketCodec<E> codec, Class<? extends R> defaultType) {
- this.codec = codec;
- this.defaultType = defaultType;
-
- Class<?> cls;
- cls = getTypeParameterRaw(this.getClass(), AbstractPacketMarshaller.class, "S");
- if (cls != null) {
- codec.registerPacketType((Class<? extends Packet>) cls);
- }
- cls = getTypeParameterRaw(this.getClass(), AbstractPacketMarshaller.class, "R");
- if (cls != null) {
- codec.registerPacketType((Class<? extends Packet>) cls);
- }
- }
-
- /**
- * Register a packet type with the underlying codec
- *
- * @param pktType the packet type to register
- */
- public void registerPacketType(Class<? extends Packet> pktType) {
- codec.registerPacketType(pktType);
- }
-
- /**
- * Set the packet factory to use for decoding packets
- *
- * This will automatically register the factory's types with the underlying codec.
- *
- * @param factory the factory
- */
- public void setPacketFactory(PacketFactory factory) {
- this.factory = factory;
- this.factory.registerTypes(codec);
- }
-
- @Override
- public Class<? extends R> getDefaultType() {
- return defaultType;
- }
-}
diff --git a/Ghidra/Debug/Framework-AsyncComm/src/main/java/ghidra/comm/packet/AsynchronousPacketChannel.java b/Ghidra/Debug/Framework-AsyncComm/src/main/java/ghidra/comm/packet/AsynchronousPacketChannel.java
deleted file mode 100644
index 3d7e15211e..0000000000
--- a/Ghidra/Debug/Framework-AsyncComm/src/main/java/ghidra/comm/packet/AsynchronousPacketChannel.java
+++ /dev/null
@@ -1,161 +0,0 @@
-/* ###
- * 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 ghidra.comm.packet;
-
-import static ghidra.async.AsyncUtils.completable;
-import static ghidra.async.AsyncUtils.loop;
-
-import java.io.EOFException;
-import java.nio.*;
-import java.nio.channels.AsynchronousByteChannel;
-import java.util.concurrent.CompletableFuture;
-import java.util.concurrent.atomic.AtomicInteger;
-
-import ghidra.async.AsyncLock;
-import ghidra.async.TypeSpec;
-import ghidra.comm.util.ByteBufferUtils;
-
-/**
- * An asynchronous channel for exchanging packets, usually over a network
- *
- * The underlying implementation uses {@link ByteBuffer}s, and the only provided codec that encodes
- * and decodes to a {@link ByteBuffer} is {@link ByteBufferCodec}. This does not preclude other
- * codecs. A {@link AbstractPacketMarshaller} must be provided during construction. The marshaller
- * provides the glue between the underlying channel, which is invariably {@link ByteBuffer} based,
- * and the decoded packet type. The marshaller chooses the codec.
- *
- * @param <S> the type of packet sent, possibly an abstract type
- * @param <R> the type of packet received, possibly an abstract type
- */
-public class AsynchronousPacketChannel<S extends Packet, R extends Packet> {
- /** The byte channel for sending and receiving encoded data */
- protected final AsynchronousByteChannel channel;
- /** The marshaller for encoding and decoding packet data */
- protected final AbstractPacketMarshaller<S, R, ByteBuffer> marshaller;
-
- /** A lock for sharing the underlying channel's read operation */
- protected final AsyncLock rLock = new AsyncLock();
- /** A lock for sharing the underlying channel's write operation */
- protected final AsyncLock wLock = new AsyncLock();
- /** A buffer of received data */
- protected ByteBuffer rBuf;
- /** A buffer of data to send */
- protected ByteBuffer wBuf;
-
- /**
- * Construct a new packet channel
- *
- * @param channel the underlying byte channel for communication
- * @param marshaller the marshaller for encoding and decoding packets
- * @param initbuflen the initial size for the send and receive buffers. They will each grow as
- * needed.
- */
- protected AsynchronousPacketChannel(AsynchronousByteChannel channel,
- AbstractPacketMarshaller<S, R, ByteBuffer> marshaller, int initbuflen) {
- this.channel = channel;
- this.marshaller = marshaller;
- this.rBuf = ByteBuffer.allocate(initbuflen);
- this.wBuf = ByteBuffer.allocate(initbuflen);
- }
-
- /**
- * Construct a new packet channel
- *
- * @param channel the underlying byte channel for communication
- * @param marshaller the marshaller for encoding and decoding packets
- */
- public AsynchronousPacketChannel(AsynchronousByteChannel channel,
- AbstractPacketMarshaller<S, R, ByteBuffer> marshaller) {
- this(channel, marshaller, 1024);
- }
-
- /**
- * Read and decode a packet from the channel
- *
- * @param pktType the type of packet expected
- * @return the read packet as a future
- */
- public <R2 extends R> CompletableFuture<R2> read(Class<R2> pktType) {
- return rLock.with(TypeSpec.cls(pktType), null).then((own, seq) -> {
- loop(TypeSpec.cls(pktType), (loop) -> {
- try {
- rBuf.flip();
- R2 res = marshaller.unmarshall(pktType, rBuf);
- rBuf.compact();
- loop.exit(res);
- }
- catch (BufferUnderflowException e) {
- rBuf.compact();
- completable(TypeSpec.INT, channel::read, rBuf).handle(loop::consume);
- }
- catch (Exception e) {
- rBuf.compact();
- loop.exit(e);
- }
- }, TypeSpec.INT, (lenread, loop) -> {
- if (lenread == -1) {
- loop.exit(new EOFException("Remote closed connection"));
- return;
- }
- else if (lenread == 0) {
- rBuf = ByteBufferUtils.upsize(rBuf);
- }
- loop.repeat();
- }).handle(seq::exit);
- }).finish();
- }
-
- /**
- * Encode and write a packet to the channel
- *
- * @param pkt the packet to write
- * @return the length of the written encoded packet as a future
- */
- public CompletableFuture<Integer> write(S pkt) {
- AtomicInteger len = new AtomicInteger();
- return wLock.with(TypeSpec.INT, null).then((own, seq) -> {
- while (true) {
- try {
- marshaller.marshall(wBuf, pkt);
- break;
- }
- catch (BufferOverflowException e) {
- wBuf.clear();
- wBuf = ByteBufferUtils.upsize(wBuf);
- }
- catch (Exception e) {
- seq.exit(e);
- return;
- }
- }
- wBuf.flip();
- len.set(wBuf.remaining());
- loop(TypeSpec.VOID, (loop) -> {
- completable(TypeSpec.INT, channel::write, wBuf).handle(loop::consume);
- }, TypeSpec.INT, (l, loop) -> {
- if (wBuf.hasRemaining()) {
- loop.repeat();
- }
- else {
- loop.exit();
- }
- }).handle(seq::next);
- }).then((seq) -> {
- wBuf.clear();
- seq.exit(len.get());
- }).finish();
- }
-}
diff --git a/Ghidra/Debug/Framework-AsyncComm/src/main/java/ghidra/comm/packet/AsynchronousPacketDebugChannel.java b/Ghidra/Debug/Framework-AsyncComm/src/main/java/ghidra/comm/packet/AsynchronousPacketDebugChannel.java
deleted file mode 100644
index 0131fb72cf..0000000000
--- a/Ghidra/Debug/Framework-AsyncComm/src/main/java/ghidra/comm/packet/AsynchronousPacketDebugChannel.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/* ###
- * 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 ghidra.comm.packet;
-
-import java.nio.ByteBuffer;
-import java.nio.channels.AsynchronousByteChannel;
-import java.util.concurrent.CompletableFuture;
-
-import ghidra.util.Msg;
-
-/**
- * An extension to {@link AsynchronousPacketChannel} that prints packets to the debug log
- *
- * @param <S> the type of packet sent, possibly an abstract type
- * @param <R> the type of packet received, possibly an abstract type
- */
-public class AsynchronousPacketDebugChannel<S extends Packet, R extends Packet>
- extends AsynchronousPacketChannel<S, R> {
-
- public AsynchronousPacketDebugChannel(AsynchronousByteChannel channel,
- AbstractPacketMarshaller<S, R, ByteBuffer> marshaller) {
- super(channel, marshaller);
- }
-
- @Override
- public <R2 extends R> CompletableFuture<R2> read(Class<R2> pktType) {
- return super.read(pktType).thenApply((pkt) -> {
- Msg.debug(this, "PACKET Read: " + pkt);
- return pkt;
- });
- }
-
- @Override
- public CompletableFuture<Integer> write(S pkt) {
- Msg.debug(this, "PACKET Write: " + pkt);
- return super.write(pkt).thenApply((len) -> {
- return len;
- });
- }
-}
diff --git a/Ghidra/Debug/Framework-AsyncComm/src/main/java/ghidra/comm/packet/DefaultPacketFactory.java b/Ghidra/Debug/Framework-AsyncComm/src/main/java/ghidra/comm/packet/DefaultPacketFactory.java
deleted file mode 100644
index 87d76b332d..0000000000
--- a/Ghidra/Debug/Framework-AsyncComm/src/main/java/ghidra/comm/packet/DefaultPacketFactory.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/* ###
- * 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 ghidra.comm.packet;
-
-/**
- * The default {@link PacketFactory}
- *
- * This factory is used for unversioned protocols, or for versioned protocols before the version has
- * been negotiated. It is up to the developer to negotiate the version, since each protocol
- * accomplishes this differently. The packets exchanged before and during negotiation ought not to
- * depend on any particular {@link PacketFactory}. If so, the protocol itself suffers from a serious
- * flaw.
- *
- * {@link PacketCodec#decodePacket(Class, Object)} uses this factory. It is a singleton instance.
- *
- * This factory does not register any additional, nor does it perform any substitutions aside from
- * those applied by {@link AbstractPacketFactory}.
- */
-public final class DefaultPacketFactory extends AbstractPacketFactory {
- public static final DefaultPacketFactory INSTANCE = new DefaultPacketFactory();
-
- private DefaultPacketFactory() {
- }
-
- public static DefaultPacketFactory getInstance() {
- return INSTANCE;
- }
-}
diff --git a/Ghidra/Debug/Framework-AsyncComm/src/main/java/ghidra/comm/packet/Packet.java b/Ghidra/Debug/Framework-AsyncComm/src/main/java/ghidra/comm/packet/Packet.java
deleted file mode 100644
index 530d763ad4..0000000000
--- a/Ghidra/Debug/Framework-AsyncComm/src/main/java/ghidra/comm/packet/Packet.java
+++ /dev/null
@@ -1,1123 +0,0 @@
-/* ###
- * 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 ghidra.comm.packet;
-
-import java.lang.reflect.*;
-import java.nio.ByteBuffer;
-import java.util.*;
-
-import org.apache.commons.lang3.StringUtils;
-
-import com.google.common.collect.ImmutableMap;
-
-import ghidra.comm.packet.annot.*;
-import ghidra.comm.packet.binary.*;
-import ghidra.comm.packet.err.*;
-import ghidra.comm.packet.fields.PacketField;
-import ghidra.comm.packet.string.*;
-import ghidra.graph.*;
-import ghidra.graph.algo.SorterException;
-import ghidra.graph.algo.TopologicalSorter;
-
-/**
- * A class with customizable serialization via {@link PacketField} annotations
- *
- * The goal of the packet library is to ease serialization and de-serialization of network packets.
- * Instead of providing methods to serialize and de-serialize primitives, and requiring a developer
- * to apply these conversely, it instead provides annotations which are applied to the fields to
- * serialize and de-serialize. The developer can then provide pluggable methods for serializing and
- * de-serializing various types. Of course, the library provides default implementations which
- * suffice for most uses. Consider an example:
- *
- * <pre>
- * public class Person extends Packet {
- * &#64;PacketField
- * &#64;NullTerminated
- * public String name;
- *
- * &#64;PacketField
- * public byte age;
- * }
- * </pre>
- *
- * Note that all fields to be encoded must be public, and there must be a default constructor. The
- * {@link PacketField} annotation indicates which fields are encoded. They are encoded in order of
- * declaration unless another annotation prescribes otherwise. Other annotations modify the encoding
- * and decoding methods applied. For example, the {@link NullTerminated} annotation modifies
- * encoding so that a null terminator is inserted after the encoded field. Conversely, it modifies
- * the decoding so that decoding the field consumes exactly the data preceding the next null
- * terminator, and then the annotation consumes the null terminator. Were this annotation not
- * applied, the {@code name} field would not be decoded correctly, as it would consume the data
- * encoded for {@code age} as well.
- *
- * The packet then must be registered with a codec. The codec provides the methods for encoding and
- * decoding primitive types, arrays, lists, etc. A single packet type may be registered with
- * multiple codecs. To encode the packet as binary data in a {@link ByteBuffer}, use the provided
- * {@link ByteBufferPacketCodec}.
- *
- * <pre>
- * ByteBufferPacketCodec codec = ByteBufferPacketCodec.getInstance();
- * codec.registerPacketType(Person.class);
- * </pre>
- *
- * Now, the packet is easily encoded and decoded:
- *
- * <pre>
- * Person alice = new Person();
- * alice.name = "Alice";
- * alice.age = 25;
- *
- * // Encode
- * ByteBuffer buf = ByteBuffer.allocate(1024);
- * codec.encodePacket(buf, alice);
- *
- * // Decode
- * buf.flip();
- * Person person = codec.decodePacket(buf);
- *
- * System.out.println(person);
- * </pre>
- *
- * Voila! There is also a {@link StringPacketCodec} that encodes and decodes packets as
- * {@link String}s. It follows the same scheme. Register the packet, then encode and decode. The
- * only notable difference is that its encode method has a different signature:
- *
- * <pre>
- * String encoded = codec.encodepacket(alice);
- * </pre>
- *
- * Technically, both codecs have both variants, but depending on the encoded type, one variant may
- * be more appropriate than another. Since {@link ByteBuffer}s are mutable by design, it's more
- * suitable to encode packets into an existing {@link ByteBuffer} than it is to ask the library to
- * instantiate a new one.
- *
- * Packets can also be nested. The packet codec already provides the methods needed to encode and
- * decode any packet. Thus, fields that are packets are simply encoded and decoded in place:
- *
- * <pre>
- * public class Person extends Packet {
- * &#64;PacketField
- * &#64;NullTerminated
- * public String name;
- *
- * &#64;PacketField
- * public byte age;
- *
- * &#64;PacketField
- * public Address homeAddress;
- * }
- *
- * public class Address extends Packet {
- * &#64;PacketField
- * &#64;NullTerminated
- * public String houseNumber;
- *
- * &#64;PacketField
- * &#64;NullTerminated
- * public String street;
- *
- * &#64;PacketField
- * public int zipCode;
- * }
- * </pre>
- *
- * Packet fields may also be declared {@code final}, which is useful for validation or packet type
- * selection. Final fields are encoded exactly the same was an non-final fields. When decoded, the
- * field value is checked against the final value. If they match, decoding continues. If not, a
- * {@link PacketFieldValueMismatchException} is thrown. If the final field is variable in size, that
- * size is used as a clue during decode. Thus, for example, the {@link NullTerminated} annotation
- * would not be required, since it would try to decode a {@link String} of the same size as the
- * final value. It would not need a null terminator to determine the size, though it may still be
- * applied if desired.
- *
- * The more interesting cases are handled by the various annotations. Many are included, and a
- * developer may provide additional ones. Generally, it is better to provide new annotations than it
- * is to extend a codec, unless the encoding and decoding of primitives needs to be modified
- * globally.
- *
- * Annotations for delimiting fields:
- * <ul>
- * <li>{@link CountedByField}</li>
- * <li>{@link SizedByField}</li>
- * <li>{@link SizedByMethods}</li>
- * <li>{@link NullTerminated}</li>
- * <li>{@link RegexTerminated}</li>
- * <li>{@link SequenceTerminated}</li>
- * </ul>
- *
- * Annotations for collections and arrays:
- * <ul>
- * <li>{@link RepeatedField}</li>
- * <li>{@link CountedByField}</li>
- * <li>{@link RegexSeparated}</li>
- * </ul>
- *
- * Annotations for conditionals and type selection:
- * <ul>
- * <li>{@link OptionalField}</li>
- * <li>{@link TypedByField}</li>
- * <li>{@link TypedByLookahead}</li>
- * </ul>
- *
- * Annotations for modifying primitive encoding:
- * <ul>
- * <li>{@link EncodeChars}</li>
- * <li>{@link ReverseByteOrder}</li>
- * <li>{@link SizeRestricted}</li>
- * <li>{@link WithRadix}</li>
- * <li>{@link WithSign}</li>
- * </ul>
- *
- * These annotations generally provide sufficient control for dealing with most common binary and
- * ASCII encoding schemes used in networking. For complex text processing, however, please consider
- * a formal parser, e.g., ANTLR.
- */
-public abstract class Packet implements Comparable<Packet> {
- private static final Map<Class<? extends Packet>, List<Field>> fieldsByType = new HashMap<>();
-
- private Packet parent;
-
- void setParent(Packet parent) {
- this.parent = parent;
- }
-
- /**
- * If this packet appeared as a packet field, obtain the packet containing it
- *
- * @return the containing packet
- */
- public Packet getParent() {
- return parent;
- }
-
- /**
- * Begin specifying a map of keys to field types in a single line
- *
- * @param key the type of keys -- generally values found in a keying field
- * @param val the type of value -- generally a packet type selected by the keying field
- * @return a builder for populating and obtaining the map
- */
- public static <K, V> ImmutableMap.Builder<K, Class<? extends V>> typeMap(Class<K> key,
- Class<V> val) {
- return new ImmutableMap.Builder<>();
- }
-
- /*
- * An edge in the graph used to order the packet fields
- */
- static class Precedes implements GEdge<Field> {
- public final Field first;
- public final Field second;
-
- public Precedes(Field first, Field second) {
- this.first = first;
- this.second = second;
- }
-
- @Override
- public int hashCode() {
- return first.hashCode() * 31 + second.hashCode();
- }
-
- @Override
- public boolean equals(Object obj) {
- if (!(obj instanceof Precedes)) {
- return false;
- }
- Precedes that = (Precedes) obj;
- return this.first.equals(that.first) && this.second.equals(that.second);
- }
-
- @Override
- public Field getStart() {
- return first;
- }
-
- @Override
- public Field getEnd() {
- return second;
- }
- }
-
- /**
- * Obtain a packet field by type and name, verifying that it is annotated
- *
- * @param cls the packet type
- * @param name the name of the field
- * @return the located field
- * @throws NoSuchFieldException if the field does not exist at all
- * @throws SecurityException if the field cannot be accessed
- * @throws PacketFieldDeclarationException if the field is not annotated with
- * {@link PacketField}
- */
- public static Field getPacketField(Class<? extends Packet> cls, String name)
- throws NoSuchFieldException, SecurityException {
- Field f = cls.getField(name);
- PacketField annot = f.getAnnotation(PacketField.class);
- if (annot == null) {
- throw new PacketFieldDeclarationException(cls, f,
- "Field is not a @" + PacketField.class.getSimpleName());
- }
- return f;
- }
-
- private static void checkPacketFieldModifiers(Class<? extends Packet> cls) {
- for (Field f : cls.getDeclaredFields()) {
- // This is just to check for correct access
- // Let the cls.getFields() method get all the interesting fields
- PacketField annot = f.getAnnotation(PacketField.class);
- if (annot == null) {
- continue;
- }
- int mod = f.getModifiers();
- if (!Modifier.isPublic(mod)) {
- throw new InvalidFieldModifiersException(cls, f, annot, "Field must be public");
- }
- if (Modifier.isStatic(mod) && !Modifier.isFinal(mod)) {
- throw new InvalidFieldModifiersException(cls, f, annot,
- "Static field must also be final");
- }
- }
- }
-
- /**
- * Obtain an ordered list of packet fields for the given packet type
- *
- * The ordering is accomplished via a topological sort of the fields after their relationships
- * are extracted. By default, a field declared after another is implied to be encoded after it.
- * Fields of a sub type have not implied ordering with respect to fields of its super type(s).
- * Thus, some {@link PacketField#before()} and/or {@link PacketField#after()} attributes must be
- * given, usually by the sub type. If the topological sort cannot be resolved uniquely --
- * meaning exactly one ordering is possible given all the before/after constraints -- a
- * {@link FieldOrderingException} is thrown.
- *
- * @param cls the packet type
- * @return the list of fields
- * @throws FieldOrderingException if the fields cannot be ordered uniquely
- */
- public static List<Field> getFields(Class<? extends Packet> cls) throws FieldOrderingException {
- List<Field> fields = fieldsByType.get(cls);
- if (fields != null) {
- return fields;
- }
-
- checkPacketFieldModifiers(cls);
-
- // Derive the field ordering relationships and add them to a graph
- GDirectedGraph<Field, Precedes> precedes = GraphFactory.createDirectedGraph();
- Map<String, Field> byName = new HashMap<>();
- Field lastF = null;
- String[] lastBefore = new String[0];
- for (Field f : cls.getFields()) {
- // TODO: I'm making assumptions about the order of fields returned.
- // According to the docs, I shouldn't....
- if (lastF != null && lastF.getDeclaringClass() != f.getDeclaringClass()) {
- lastF = null;
- lastBefore = new String[0];
- }
- PacketField annot = f.getAnnotation(PacketField.class);
- if (annot == null) {
- continue;
- }
- Field exists = byName.put(f.getName(), f);
- if (exists != null) {
- throw new PacketAnnotationException(cls, f, annot,
- "Duplicate field name: " + exists);
- }
-
- precedes.addVertex(f);
-
- String[] before = annot.before();
- String[] after = annot.after();
- try {
- if (before.length == 0) {
- before = lastBefore;
- }
- for (String b : before) {
- Field bf = getPacketField(cls, b);
- precedes.addEdge(new Precedes(f, bf));
- }
-
- if (after.length == 0 && lastF != null) {
- after = new String[] { lastF.getName() };
- }
- for (String a : after) {
- Field af = getPacketField(cls, a);
- precedes.addEdge(new Precedes(af, f));
- }
- }
- catch (NoSuchFieldException | SecurityException e) {
- throw new InvalidFieldNameException(cls, f, annot, e.getMessage(), e);
- }
-
- lastF = f;
- lastBefore = before;
- }
- // Attempt to uniquely sort the graph to obtain the field order
- try {
- fields = new TopologicalSorter<>(precedes, true).sort();
- }
- catch (SorterException e) {
- throw new FieldOrderingException(cls, "Could not order fields", e);
- }
- fieldsByType.put(cls, fields);
- return fields;
- }
-
- @Override
- public int hashCode() {
- int result = 0;
- try {
- for (Field f : Packet.getFields(this.getClass())) {
- result *= 31;
- Class<?> type = f.getType();
- if (type.isPrimitive()) {
- if (type == boolean.class) {
- result += Boolean.hashCode(f.getBoolean(this));
- }
- else if (type == byte.class) {
- result += Byte.hashCode(f.getByte(this));
- }
- else if (type == char.class) {
- result += Character.hashCode(f.getChar(this));
- }
- else if (type == short.class) {
- result += Short.hashCode(f.getShort(this));
- }
- else if (type == int.class) {
- result += Integer.hashCode(f.getInt(this));
- }
- else if (type == long.class) {
- result += Long.hashCode(f.getLong(this));
- }
- else if (type == float.class) {
- result += Float.hashCode(f.getFloat(this));
- }
- else if (type == double.class) {
- result += Double.hashCode(f.getDouble(this));
- }
- else {
- throw new AssertionError("INTERNAL: Forgot a primitive");
- }
- }
- else if (type.isArray()) {
- if (type == boolean[].class) {
- result += Arrays.hashCode((boolean[]) f.get(this));
- }
- else if (type == byte[].class) {
- result += Arrays.hashCode((byte[]) f.get(this));
- }
- else if (type == char[].class) {
- result += Arrays.hashCode((char[]) f.get(this));
- }
- else if (type == short[].class) {
- result += Arrays.hashCode((short[]) f.get(this));
- }
- else if (type == int[].class) {
- result += Arrays.hashCode((int[]) f.get(this));
- }
- else if (type == long[].class) {
- result += Arrays.hashCode((long[]) f.get(this));
- }
- else if (type == float[].class) {
- result += Arrays.hashCode((float[]) f.get(this));
- }
- else if (type == double[].class) {
- result += Arrays.hashCode((double[]) f.get(this));
- }
- else {
- result += Arrays.hashCode((Object[]) f.get(this));
- }
- }
- else {
- Object o = f.get(this);
- if (o == null) {
- continue;
- }
- result += o.hashCode();
- }
- }
- }
- catch (IllegalArgumentException | IllegalAccessException e) {
- throw new RuntimeException(e);
- }
- return result;
- }
-
- @Override
- public boolean equals(Object that) {
- Class<? extends Packet> pktType = this.getClass();
- if (pktType != that.getClass()) {
- return false;
- }
- try {
- for (Field f : Packet.getFields(pktType)) {
- Class<?> type = f.getType();
- if (type.isPrimitive()) {
- if (type == boolean.class) {
- if (f.getBoolean(this) != f.getBoolean(that)) {
- return false;
- }
- }
- else if (type == byte.class) {
- if (f.getByte(this) != f.getByte(that)) {
- return false;
- }
- }
- else if (type == char.class) {
- if (f.getChar(this) != f.getChar(that)) {
- return false;
- }
- }
- else if (type == short.class) {
- if (f.getShort(this) != f.getShort(that)) {
- return false;
- }
- }
- else if (type == int.class) {
- if (f.getInt(this) != f.getInt(that)) {
- return false;
- }
- }
- else if (type == long.class) {
- if (f.getLong(this) != f.getLong(that)) {
- return false;
- }
- }
- else if (type == float.class) {
- if (f.getFloat(this) != f.getFloat(that)) {
- return false;
- }
- }
- else if (type == double.class) {
- if (f.getDouble(this) != f.getDouble(that)) {
- return false;
- }
- }
- else {
- throw new AssertionError("INTERNAL: Forgot a primitive");
- }
- }
- else if (type.isArray()) {
- if (type == boolean[].class) {
- if (!Arrays.equals((boolean[]) f.get(this), (boolean[]) f.get(that))) {
- return false;
- }
- }
- else if (type == byte[].class) {
- if (!Arrays.equals((byte[]) f.get(this), (byte[]) f.get(that))) {
- return false;
- }
- }
- else if (type == char[].class) {
- if (!Arrays.equals((char[]) f.get(this), (char[]) f.get(that))) {
- return false;
- }
- }
- else if (type == short[].class) {
- if (!Arrays.equals((short[]) f.get(this), (short[]) f.get(that))) {
- return false;
- }
- }
- else if (type == int[].class) {
- if (!Arrays.equals((int[]) f.get(this), (int[]) f.get(that))) {
- return false;
- }
- }
- else if (type == long[].class) {
- if (!Arrays.equals((long[]) f.get(this), (long[]) f.get(that))) {
- return false;
- }
- }
- else if (type == float[].class) {
- if (!Arrays.equals((float[]) f.get(this), (float[]) f.get(that))) {
- return false;
- }
- }
- else if (type == double[].class) {
- if (!Arrays.equals((double[]) f.get(this), (double[]) f.get(that))) {
- return false;
- }
- }
- else {
- if (!Arrays.equals((Object[]) f.get(this), (Object[]) f.get(that))) {
- return false;
- }
- }
- }
- else {
- Object thisVal = f.get(this);
- Object thatVal = f.get(that);
- if (thisVal == null && thatVal == null) {
- continue;
- }
- else if (thisVal == null || thatVal == null) {
- return false;
- }
- else if (!f.get(this).equals(f.get(that))) {
- return false;
- }
- }
- }
- }
- catch (IllegalArgumentException | IllegalAccessException e) {
- throw new RuntimeException(e);
- }
- return true;
- }
-
- @Override
- public int compareTo(Packet that) {
- Class<? extends Packet> pktType = this.getClass();
- int c;
- c = pktType.getCanonicalName().compareTo(that.getClass().getCanonicalName());
- if (c != 0) {
- return c;
- }
- try {
- for (Field f : Packet.getFields(pktType)) {
- Class<?> type = f.getType();
- if (type.isPrimitive()) {
- if (type == boolean.class) {
- c = Boolean.compare(f.getBoolean(this), f.getBoolean(that));
- }
- else if (type == byte.class) {
- c = Byte.compare(f.getByte(this), f.getByte(that));
- }
- else if (type == char.class) {
- c = Character.compare(f.getChar(this), f.getChar(that));
- }
- else if (type == short.class) {
- c = Short.compare(f.getShort(this), f.getShort(that));
- }
- else if (type == int.class) {
- c = Integer.compare(f.getInt(this), f.getInt(that));
- }
- else if (type == long.class) {
- c = Long.compare(f.getLong(this), f.getLong(that));
- }
- else if (type == float.class) {
- c = Float.compare(f.getFloat(this), f.getFloat(that));
- }
- else if (type == double.class) {
- c = Double.compare(f.getDouble(this), f.getDouble(that));
- }
- else {
- throw new AssertionError("INTERNAL: Forgot a primitive");
- }
- }
- else {
- c = compareObjects(f.get(this), f.get(that));
- }
- if (c != 0) {
- return c;
- }
- }
- }
- catch (IllegalArgumentException | IllegalAccessException e) {
- throw new RuntimeException(e);
- }
- return 0;
- }
-
- @Override
- public String toString() {
- Class<? extends Packet> pktType = this.getClass();
- StringBuilder sb = new StringBuilder();
- sb.append(pktType.getSimpleName());
- sb.append('{');
- try {
- boolean first = true;
- for (Field f : Packet.getFields(pktType)) {
- if (Modifier.isFinal(f.getModifiers())) {
- continue;
- }
- if (first) {
- first = false;
- }
- else {
- sb.append(',');
- }
- sb.append(f.getName());
- sb.append('=');
- Object o = f.get(this);
- if (o == null) {
- continue;
- }
- Class<?> type = o.getClass();
- if (type.isArray()) {
- sb.append('[');
- if (type == boolean[].class) {
- sb.append(StringUtils.join((boolean[]) o, ','));
- }
- else if (type == byte[].class) {
- sb.append(StringUtils.join((byte[]) o, ','));
- }
- else if (type == char[].class) {
- sb.append(StringUtils.join((char[]) o, ','));
- }
- else if (type == short[].class) {
- sb.append(StringUtils.join((short[]) o, ','));
- }
- else if (type == int[].class) {
- sb.append(StringUtils.join((int[]) o, ','));
- }
- else if (type == long[].class) {
- sb.append(StringUtils.join((long[]) o, ','));
- }
- else if (type == float[].class) {
- sb.append(StringUtils.join((float[]) o, ','));
- }
- else if (type == double[].class) {
- sb.append(StringUtils.join((double[]) o, ','));
- }
- else {
- sb.append(StringUtils.join((Object[]) o, ','));
- }
- sb.append(']');
- }
- else {
- sb.append(f.get(this));
- }
- }
- }
- catch (IllegalArgumentException | IllegalAccessException e) {
- throw new RuntimeException(e);
- }
- sb.append('}');
- return sb.toString();
- }
-
- /**
- * Produce a deep copy of the given object, unless that object need not be copied
- *
- * @param obj the object to copy
- * @return the copied objects
- * @throws InstantiationException if a collection type could not be instantiated
- * @throws IllegalAccessException if a collection type could not be instantiated
- * @throws SecurityException
- * @throws NoSuchMethodException
- * @throws InvocationTargetException
- * @throws IllegalArgumentException
- */
- protected static <E> Object copyOrRefObject(Object obj)
- throws InstantiationException, IllegalAccessException, IllegalArgumentException,
- InvocationTargetException, NoSuchMethodException, SecurityException {
- if (obj == null) {
- return null;
- }
- Class<?> type = obj.getClass();
- if (type.isArray()) {
- if (type == boolean[].class) {
- boolean[] mine = (boolean[]) obj;
- return Arrays.copyOf(mine, mine.length);
- }
- else if (type == byte[].class) {
- byte[] mine = (byte[]) obj;
- return Arrays.copyOf(mine, mine.length);
- }
- else if (type == char[].class) {
- char[] mine = (char[]) obj;
- return Arrays.copyOf(mine, mine.length);
- }
- else if (type == short[].class) {
- short[] mine = (short[]) obj;
- return Arrays.copyOf(mine, mine.length);
- }
- else if (type == int[].class) {
- int[] mine = (int[]) obj;
- return Arrays.copyOf(mine, mine.length);
- }
- else if (type == long[].class) {
- long[] mine = (long[]) obj;
- return Arrays.copyOf(mine, mine.length);
- }
- else if (type == float[].class) {
- float[] mine = (float[]) obj;
- return Arrays.copyOf(mine, mine.length);
- }
- else if (type == double[].class) {
- double[] mine = (double[]) obj;
- return Arrays.copyOf(mine, mine.length);
- }
- else { // Object array
- Object[] mine = (Object[]) obj;
- Object result = Array.newInstance(type.getComponentType(), mine.length);
- for (int i = 0; i < mine.length; i++) {
- Array.set(result, i, copyOrRefObject(mine[i]));
- }
- return result;
- }
- }
- else if (Collection.class.isAssignableFrom(type)) {
- @SuppressWarnings("unchecked")
- Collection<E> dst = (Collection<E>) type.getConstructor().newInstance();
- @SuppressWarnings("unchecked")
- Collection<E> src = (Collection<E>) obj;
- for (Object s : src) {
- @SuppressWarnings("unchecked")
- E d = (E) copyOrRefObject(s);
- dst.add(d);
- }
- return dst;
- }
- else if (Packet.class.isAssignableFrom(type)) {
- Packet mySubPacket = (Packet) obj;
- return mySubPacket.copy();
- }
- else { // Just give the reference
- return obj;
- }
- }
-
- /**
- * Obtain a deep copy of this packet
- *
- * @return the copy
- */
- public <P extends Packet> P copy() {
- try {
- @SuppressWarnings("unchecked")
- Class<P> pktType = (Class<P>) this.getClass();
- P that = pktType.getConstructor().newInstance();
- for (Field f : Packet.getFields(pktType)) {
- Class<?> type = f.getType();
- if (type.isPrimitive()) {
- if (type == boolean.class) {
- f.setBoolean(that, f.getBoolean(this));
- }
- else if (type == byte.class) {
- f.setByte(that, f.getByte(this));
- }
- else if (type == char.class) {
- f.setChar(that, f.getChar(this));
- }
- else if (type == short.class) {
- f.setShort(that, f.getShort(this));
- }
- else if (type == int.class) {
- f.setInt(that, f.getInt(this));
- }
- else if (type == long.class) {
- f.setLong(that, f.getLong(this));
- }
- else if (type == float.class) {
- f.setFloat(that, f.getFloat(this));
- }
- else if (type == double.class) {
- f.setDouble(that, f.getDouble(this));
- }
- else {
- throw new AssertionError("INTERNAL: Forgot a primitive");
- }
- }
- else {
- f.set(that, copyOrRefObject(f.get(this)));
- }
- }
- return that;
- }
- catch (InstantiationException | IllegalAccessException | IllegalArgumentException
- | InvocationTargetException | NoSuchMethodException | SecurityException e) {
- throw new RuntimeException(e);
- }
- }
-
- protected static int compareArrays(boolean[] a, boolean[] b) {
- if (a == null && b == null) {
- return 0;
- }
- else if (a == null) {
- return -1;
- }
- else if (b == null) {
- return 1;
- }
- int c = a.length - b.length;
- if (c != 0) {
- return c;
- }
- for (int i = 0; i < a.length; i++) {
- c = Boolean.compare(a[i], b[i]);
- if (c != 0) {
- return c;
- }
- }
- return 0;
- }
-
- protected static int compareArrays(byte[] a, byte[] b) {
- if (a == null && b == null) {
- return 0;
- }
- else if (a == null) {
- return -1;
- }
- else if (b == null) {
- return 1;
- }
- int c = a.length - b.length;
- if (c != 0) {
- return c;
- }
- for (int i = 0; i < a.length; i++) {
- c = Byte.compare(a[i], b[i]);
- if (c != 0) {
- return c;
- }
- }
- return 0;
- }
-
- protected static int compareArrays(char[] a, char[] b) {
- if (a == null && b == null) {
- return 0;
- }
- else if (a == null) {
- return -1;
- }
- else if (b == null) {
- return 1;
- }
- int c = a.length - b.length;
- if (c != 0) {
- return c;
- }
- for (int i = 0; i < a.length; i++) {
- c = Character.compare(a[i], b[i]);
- if (c != 0) {
- return c;
- }
- }
- return 0;
- }
-
- protected static int compareArrays(short[] a, short[] b) {
- if (a == null && b == null) {
- return 0;
- }
- else if (a == null) {
- return -1;
- }
- else if (b == null) {
- return 1;
- }
- int c = a.length - b.length;
- if (c != 0) {
- return c;
- }
- for (int i = 0; i < a.length; i++) {
- c = Short.compare(a[i], b[i]);
- if (c != 0) {
- return c;
- }
- }
- return 0;
- }
-
- protected static int compareArrays(int[] a, int[] b) {
- if (a == null && b == null) {
- return 0;
- }
- else if (a == null) {
- return -1;
- }
- else if (b == null) {
- return 1;
- }
- int c = a.length - b.length;
- if (c != 0) {
- return c;
- }
- for (int i = 0; i < a.length; i++) {
- c = Integer.compare(a[i], b[i]);
- if (c != 0) {
- return c;
- }
- }
- return 0;
- }
-
- protected static int compareArrays(long[] a, long[] b) {
- if (a == null && b == null) {
- return 0;
- }
- else if (a == null) {
- return -1;
- }
- else if (b == null) {
- return 1;
- }
- int c = a.length - b.length;
- if (c != 0) {
- return c;
- }
- for (int i = 0; i < a.length; i++) {
- c = Long.compare(a[i], b[i]);
- if (c != 0) {
- return c;
- }
- }
- return 0;
- }
-
- protected static int compareArrays(float[] a, float[] b) {
- if (a == null && b == null) {
- return 0;
- }
- else if (a == null) {
- return -1;
- }
- else if (b == null) {
- return 1;
- }
- int c = a.length - b.length;
- if (c != 0) {
- return c;
- }
- for (int i = 0; i < a.length; i++) {
- c = Float.compare(a[i], b[i]);
- if (c != 0) {
- return c;
- }
- }
- return 0;
- }
-
- protected static int compareArrays(double[] a, double[] b) {
- if (a == null && b == null) {
- return 0;
- }
- else if (a == null) {
- return -1;
- }
- else if (b == null) {
- return 1;
- }
- int c = a.length - b.length;
- if (c != 0) {
- return c;
- }
- for (int i = 0; i < a.length; i++) {
- c = Double.compare(a[i], b[i]);
- if (c != 0) {
- return c;
- }
- }
- return 0;
- }
-
- protected static int compareArrays(Object[] a, Object[] b) {
- if (a == null && b == null) {
- return 0;
- }
- else if (a == null) {
- return -1;
- }
- else if (b == null) {
- return 1;
- }
- int c = a.length - b.length;
- if (c != 0) {
- return c;
- }
- for (int i = 0; i < a.length; i++) {
- c = compareObjects(a[i], b[i]);
- if (c != 0) {
- return c;
- }
- }
- return 0;
- }
-
- protected static int compareCollections(Collection<?> a, Collection<?> b) {
- if (a == null && b == null) {
- return 0;
- }
- else if (a == null) {
- return -1;
- }
- else if (b == null) {
- return 1;
- }
- int c = a.size() - b.size();
- if (c != 0) {
- return c;
- }
- Iterator<?> ai = a.iterator();
- Iterator<?> bi = b.iterator();
- while (ai.hasNext()) {
- c = compareObjects(ai.next(), bi.next());
- if (c != 0) {
- return c;
- }
- }
- return 0;
- }
-
- @SuppressWarnings({ "rawtypes", "unchecked" })
- protected static int compareObjects(Object a, Object b) {
- if (a == null && b == null) {
- return 0;
- }
- else if (a == null) {
- return -1;
- }
- else if (b == null) {
- return 1;
- }
- int c = a.getClass().getCanonicalName().compareTo(b.getClass().getCanonicalName());
- if (c != 0) {
- return c;
- }
- Class<?> type = a.getClass();
- if (type.isArray()) {
- if (type == boolean[].class) {
- return compareArrays((boolean[]) a, (boolean[]) b);
- }
- else if (type == byte[].class) {
- return compareArrays((byte[]) a, (byte[]) b);
- }
- else if (type == char[].class) {
- return compareArrays((char[]) a, (char[]) b);
- }
- else if (type == short[].class) {
- return compareArrays((short[]) a, (short[]) b);
- }
- else if (type == int[].class) {
- return compareArrays((int[]) a, (int[]) b);
- }
- else if (type == long[].class) {
- return compareArrays((long[]) a, (long[]) b);
- }
- else if (type == float[].class) {
- return compareArrays((float[]) a, (float[]) b);
- }
- else if (type == double[].class) {
- return compareArrays((double[]) a, (double[]) b);
- }
- else {
- return compareArrays((Object[]) a, (Object[]) b);
- }
- }
- else if (Collection.class.isAssignableFrom(type)) {
- return compareCollections((Collection) a, (Collection) b);
- }
- Comparable ac = (Comparable<?>) a;
- Comparable bc = (Comparable<?>) b;
- return ac.compareTo(bc);
- }
-}
diff --git a/Ghidra/Debug/Framework-AsyncComm/src/main/java/ghidra/comm/packet/PacketCodec.java b/Ghidra/Debug/Framework-AsyncComm/src/main/java/ghidra/comm/packet/PacketCodec.java
deleted file mode 100644
index 3eaf0b1aa1..0000000000
--- a/Ghidra/Debug/Framework-AsyncComm/src/main/java/ghidra/comm/packet/PacketCodec.java
+++ /dev/null
@@ -1,99 +0,0 @@
-/* ###
- * 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 ghidra.comm.packet;
-
-import ghidra.comm.packet.err.PacketDecodeException;
-import ghidra.comm.packet.err.PacketEncodeException;
-
-/**
- * A means of encoding and decoding packets
- *
- * @param <T> the type of encoded packets
- */
-public interface PacketCodec<T> {
- /**
- * Register a packet type with this codec
- *
- * This performs some validation of the packet definition and prepares encoders and decoders for
- * the individual fields -- called field codecs -- for the packet. A packet must be registered
- * before and can be encoded or decoded. Note that registering a packet type implicitly
- * registers the packet types of any of its fields, recursively. Thus, if the protocol is
- * defined by a single root packet type, it is only necessary to register it. If a packet
- * factory will be used, its particular implementations must be registered explicitly, often via
- * {@link PacketFactory#registerTypes(PacketCodec)}.
- *
- * @param pkt the packet type to register
- */
- public void registerPacketType(Class<? extends Packet> pkt);
-
- /**
- * Decode a packet of the given type from encoded data
- *
- * @param pktType the type of packet expected
- * @param data the encoded packet data
- * @return the decoded packet
- * @throws PacketDecodeException if the packet is not well formed
- */
- public default <P extends Packet> P decodePacket(Class<P> pktType, T data)
- throws PacketDecodeException {
- return decodePacket(pktType, data, DefaultPacketFactory.getInstance());
- }
-
- /**
- * Decode a packet of the given type from encoded data using a packet factory
- *
- * Packet factories provide a means of dynamically modifying the expected format of a packet, or
- * for providing pluggable field formats. This is most commonly used for implementing multiple
- * versions or dialects of a protocol. Pluggable points are indicated by fields having abstract
- * types, usually extending {@link Packet}. A {@link PacketFactory} can then provide an
- * implementation of that type particular to a version of the protocol. A different factory can
- * be given for each decode, if desired, allowing for versions to be negotiated dynamically.
- *
- * @param pktType the type of packet expected
- * @param data the encoded packet data
- * @param factory a packet factory, usually implementing a particular version of the protocol
- * @return the decoded packet
- * @throws PacketDecodeException if the packet is not well formed
- */
- public <P extends Packet> P decodePacket(Class<P> pktType, T data, PacketFactory factory)
- throws PacketDecodeException;
-
- /**
- * Encode a packet into a buffer (optional operation)
- *
- * If this codec encodes to and from a mutable buffer with a cursor, then it is possible to
- * re-use a buffer or append an encoded packet to an exiting buffer.
- *
- * @see #encodePacket(Packet)
- *
- * @param buf the buffer into which to append the encoded data
- * @param pkt the packet to encode
- * @throws PacketEncodeException if the packet is not well formed
- */
- public void encodePacket(T buf, Packet pkt) throws PacketEncodeException;
-
- /**
- * Encode a packet
- *
- * During encoding, some field values may be modified, e.g., a field that measures the size of
- * another field will be set to the appropriate value.
- *
- * @param p the packet to encode
- * @return the encoded data
- * @throws PacketEncodeException if the packet is not well formed
- */
- public T encodePacket(Packet p) throws PacketEncodeException;
-}
diff --git a/Ghidra/Debug/Framework-AsyncComm/src/main/java/ghidra/comm/packet/PacketFactory.java b/Ghidra/Debug/Framework-AsyncComm/src/main/java/ghidra/comm/packet/PacketFactory.java
deleted file mode 100644
index d1ff085373..0000000000
--- a/Ghidra/Debug/Framework-AsyncComm/src/main/java/ghidra/comm/packet/PacketFactory.java
+++ /dev/null
@@ -1,176 +0,0 @@
-/* ###
- * 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 ghidra.comm.packet;
-
-import java.lang.reflect.Array;
-import java.lang.reflect.InvocationTargetException;
-import java.util.*;
-
-/**
- * A factory for instantiating abstract types found in packet fields
- *
- * This permits a pluggable means of implementing multiple protocol versions and/or dialects while
- * locating most of the version-specific logic in one object. Generally each packet factory
- * implements the details of one version.
- *
- * Whenever an abstract packet type, array, or collection is encountered during decode, the packet
- * factory is used to create an empty instance ready to be populated with the decoded data. Thus, if
- * a portion of a packet is known to vary from version to version, the main protocol need only
- * specify an abstract type. One factory then instantiates the format for one version, while another
- * factory can do the same for another version. The codec will take care of the specifics for
- * decoding each format, e.g:
- *
- * Most implementations should extend {@link AbstractPacketFactory}, which provides reasonable
- * defaults for all but {@link #newPacket(Class)}.
- *
- * <pre>
- * public class Person {
- * &#64;PacketField
- * &#64;NullTerminated
- * public String name;
- *
- * &#64;PacketField
- * public AbstractAgeSpec ageSpec;
- * }
- *
- * public abstract class AbstractAgeSpec {
- * }
- *
- * public abstract class Age extends AbstractAgeSpec {
- * &#64;PacketField
- * public byte age; // in years
- * }
- *
- * public abstract class Birthday extends AbstractAgeSpec {
- * &#64;PacketField
- * public short birthYear;
- *
- * &#64;PacketField
- * public byte birthMonth;
- *
- * &#64;PacketField
- * public byte birthDay;
- * }
- *
- * public class Version1Factory extends AbstractPacketFactory {
- * &#64;Override
- * public <P extends Packet> P newPacket(Class<P> pktType) {
- * if (AbstractAgeSpec.class.equals(pktType)) {
- * return new Age();
- * }
- * }
- *
- * public void registerTypes(PacketCodec<?, ?, ?> codec) {
- * codec.registerPacketType(Age.class);
- * }
- * }
- *
- * public class Version2Factory extends AbstractPacketFactory {
- * &#64;Override
- * public <P extends Packet> P newPacket(Class<P> pktType) {
- * if (AbstractAgeSpec.class.equals(pktType)) {
- * return new Birthday();
- * }
- * }
- *
- * public void registerTypes(PacketCodec<?, ?, ?> codec) {
- * codec.registerPacketType(Birthday.class);
- * }
- * }
- * </pre>
- *
- * Now, the version can be selected statically or dynamically:
- *
- * <pre>
- * PacketFactory version = negotiateVersion();
- * version.registerTypes(codec);
- * Person p = codec.decodePacket(Person.class, buf, version);
- * </pre>
- *
- * Granted, there may still be specific logic to processing a birthday vs. an age, but a developer
- * can factor this into objects that already exist. It is possible, for example, to define abstract
- * methods in {@code AbstractAgeSpec} to obtain the person's age and/or birthday given the current
- * date. Or, it is possible to define a new abstract class extending {@code PacketFactory} and
- * define each version's implemented to extend it. The abstract class can then define methods that
- * each version must implement for the protocol to work in general.
- */
-public interface PacketFactory {
-
- /**
- * Instantiate an array
- *
- * Implementors need rarely if ever override this method. The default simply calls
- * {@link Array#newInstance(Class, int)}.
- *
- * @param componentType the type of element in the array
- * @param length the number of elements in the array
- * @return the new array
- */
- public Object newArray(Class<?> componentType, int length);
-
- /**
- * Construct a new collection of a given type
- *
- * This is mostly so that packets do not need to specify the exact type of collection. It is
- * sufficient to declare, e.g., {@code @PacketField public List<Integer> intList} instead of
- * {@code ArrayList<Integer>}.
- *
- * The default uses {@link ArrayList} for {@link List} and {@link LinkedHashSet} for
- * {@link Set}. Any other class is instantiated as requested, possibly throwing an
- * {@link InstantiationException}.
- *
- * @param colType the type of collection to instantiate
- * @param elemType the type of element stored in the collection
- * @return the new collection
- * @throws InstantiationException if the requested type cannot be instantiated
- * @throws IllegalAccessException if the requested type is not accessible
- * @throws SecurityException
- * @throws NoSuchMethodException
- * @throws InvocationTargetException
- * @throws IllegalArgumentException
- */
- public <E, C extends Collection<E>> C newCollection(Class<C> colType, Class<E> elemType)
- throws InstantiationException, IllegalAccessException, IllegalArgumentException,
- InvocationTargetException, NoSuchMethodException, SecurityException;
-
- /**
- * Construct a new blank packet of a given type
- *
- * @param pktType the type of packet, usually abstract, to instantiate
- * @return the new packet
- * @throws InstantiationException if the requested type cannot be instantiated
- * @throws IllegalAccessException if the requested type is not accessible
- * @throws SecurityException
- * @throws NoSuchMethodException
- * @throws InvocationTargetException
- * @throws IllegalArgumentException
- */
- public <P extends Packet> P newPacket(Class<P> pktType)
- throws InstantiationException, IllegalAccessException, IllegalArgumentException,
- InvocationTargetException, NoSuchMethodException, SecurityException;
-
- /**
- * Register the types used by this factory with the given codec
- *
- * The developer must call this method before passing this factory to any decode method.
- * Otherwise, the codec may attempt to decode a packet type that has not been registered. Using
- * a {@link AbstractPacketMarshaller} may ease this burden. It has some conveniences for
- * handling packet factories.
- *
- * @param codec the codec with which to register the version-specific packet types
- */
- public void registerTypes(PacketCodec<?> codec);
-}
diff --git a/Ghidra/Debug/Framework-AsyncComm/src/main/java/ghidra/comm/packet/PacketMarshaller.java b/Ghidra/Debug/Framework-AsyncComm/src/main/java/ghidra/comm/packet/PacketMarshaller.java
deleted file mode 100644
index 9531f9c02b..0000000000
--- a/Ghidra/Debug/Framework-AsyncComm/src/main/java/ghidra/comm/packet/PacketMarshaller.java
+++ /dev/null
@@ -1,80 +0,0 @@
-/* ###
- * 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 ghidra.comm.packet;
-
-import java.nio.ByteBuffer;
-
-import ghidra.comm.packet.err.PacketDecodeException;
-import ghidra.comm.packet.err.PacketEncodeException;
-
-/**
- * A marshaller for encoding, decoding, and framing packets on a channel
- *
- * It is certainly possible to implement a marshaller by simply invoking the codec; however, the
- * marshaller may be responsible for some portion of packet encoding not implemented in the packet
- * itself, i.e., "framing." For instance, a protocol may include a frame which gives the length of
- * the packet to follow. It is usually easier to implement this in the marshaller than in a
- * {@link Packet}.
- *
- * @param <W> the type of packets to write, possibly abstract
- * @param <R> the type of packets to read, possibly abstract
- * @param <E> the type of buffer for framing and encoding packets, usually {@link ByteBuffer}
- */
-public interface PacketMarshaller<W, R, E> {
- /**
- * Marshall a packet into the given buffer
- *
- * @param outbuf the output buffer
- * @param pkt the packet to encode and marshall
- * @throws PacketEncodeException if there's a problem encoding the packet
- */
- public abstract void marshall(E outbuf, W pkt) throws PacketEncodeException;
-
- /**
- * Unmarshall a packet from the given buffer using a given packet sub-type
- *
- * @param expected the sub-type expected
- * @param inbuf the input buffer
- * @return the unmarshalled and decoded packet
- * @throws PacketDecodeException if there's a problem decoding the packet
- *
- * @NOTE If an error occurs preventing the successful unmarshalling of a complete packet, then
- * this method must restore the buffer's state so that no data is consumed.
- */
- public abstract <R2 extends R> R2 unmarshall(Class<R2> expected, E inbuf)
- throws PacketDecodeException;
-
- /**
- * Unmarshall a packet from the given buffer using the default packet type
- *
- * @param inbuf the input buffer
- * @return the unmarshalled and decoded packet
- * @throws PacketDecodeException if there's a problem decoding the packet
- *
- * @NOTE If an error occurs preventing the successful unmarshalling of a complete packet, then
- * this method must restore the buffer's state so that no data is consumed.
- */
- public default R unmarshall(E inbuf) throws PacketDecodeException {
- return unmarshall(getDefaultType(), inbuf);
- }
-
- /**
- * Get the default packet type for reading
- *
- * @return the default packet type
- */
- public Class<? extends R> getDefaultType();
-}
diff --git a/Ghidra/Debug/Framework-AsyncComm/src/main/java/ghidra/comm/packet/annot/BitmaskEncoded.java b/Ghidra/Debug/Framework-AsyncComm/src/main/java/ghidra/comm/packet/annot/BitmaskEncoded.java
deleted file mode 100644
index efff542464..0000000000
--- a/Ghidra/Debug/Framework-AsyncComm/src/main/java/ghidra/comm/packet/annot/BitmaskEncoded.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/* ###
- * 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 ghidra.comm.packet.annot;
-
-import java.lang.annotation.*;
-
-import ghidra.comm.packet.annot.impl.BitmaskEncodedFieldCodecWrapperFactory;
-import ghidra.comm.packet.fields.ImplementedBy;
-
-@Retention(RetentionPolicy.RUNTIME)
-@Target(ElementType.FIELD)
-@ImplementedBy(BitmaskEncodedFieldCodecWrapperFactory.class)
-public @interface BitmaskEncoded {
- Class<? extends Number> type() default Long.class;
-
- @SuppressWarnings("rawtypes")
- Class<? extends Enum> universe() default DefaultUniverse.class;
-
- public enum DefaultUniverse {
- // A sentinel
- }
-}
diff --git a/Ghidra/Debug/Framework-AsyncComm/src/main/java/ghidra/comm/packet/annot/CountedByField.java b/Ghidra/Debug/Framework-AsyncComm/src/main/java/ghidra/comm/packet/annot/CountedByField.java
deleted file mode 100644
index 7e8bd41931..0000000000
--- a/Ghidra/Debug/Framework-AsyncComm/src/main/java/ghidra/comm/packet/annot/CountedByField.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/* ###
- * 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 ghidra.comm.packet.annot;
-
-import java.lang.annotation.*;
-
-import ghidra.comm.packet.annot.impl.CountedByFieldWrapperFactory;
-import ghidra.comm.packet.fields.ImplementedBy;
-
-/**
- * An annotation that indicates the number of elements in this field is given by the value of
- * another
- *
- * The annotated field is called the "counted field," and the field to which this annotation refers
- * is called the "counting field." Both of these fields must be declared in the same {@link Packet}.
- * Furthermore, the counting field must precede the counted field.
- *
- * This annotation must be preceded by {@link RepeatedField}.
- *
- * Example:
- *
- * <pre>
- * &#64;PacketField
- * public int count;
- *
- * &#64;PacketField
- * &#64;RepeatedField
- * &#64;CountedByField("count")
- * public List<Integer> list;
- * </pre>
- */
-@Retention(RetentionPolicy.RUNTIME)
-@Target(ElementType.FIELD)
-@ImplementedBy(CountedByFieldWrapperFactory.class)
-public @interface CountedByField {
- /**
- * The name of the field that gives the count
- *
- * @return the name of the counting field
- */
- String value();
-}
diff --git a/Ghidra/Debug/Framework-AsyncComm/src/main/java/ghidra/comm/packet/annot/EncodeChars.java b/Ghidra/Debug/Framework-AsyncComm/src/main/java/ghidra/comm/packet/annot/EncodeChars.java
deleted file mode 100644
index b98642cfa3..0000000000
--- a/Ghidra/Debug/Framework-AsyncComm/src/main/java/ghidra/comm/packet/annot/EncodeChars.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/* ###
- * 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 ghidra.comm.packet.annot;
-
-import java.lang.annotation.*;
-import java.nio.charset.Charset;
-
-import ghidra.comm.packet.PacketCodec;
-import ghidra.comm.packet.annot.impl.EncodeCharsWrapperFactory;
-import ghidra.comm.packet.fields.ImplementedBy;
-
-/**
- * An annotation to modify the encoding of strings
- *
- * This annotation transforms a {@link CharSequence} into a byte array. This may have unintended
- * consequences if the {@link PacketCodec} encodes {@link String}s. Most binary codecs will apply a
- * UTF-8 encoding by default, so this annotation provides a way to override that default.
- */
-@Retention(RetentionPolicy.RUNTIME)
-@Target(ElementType.FIELD)
-@ImplementedBy(EncodeCharsWrapperFactory.class)
-public @interface EncodeChars {
- /**
- * The name of the character set encoding to apply
- *
- * @see Charset#forName(String)
- * @return the name of the character set
- */
- String value();
-}
diff --git a/Ghidra/Debug/Framework-AsyncComm/src/main/java/ghidra/comm/packet/annot/OptionalField.java b/Ghidra/Debug/Framework-AsyncComm/src/main/java/ghidra/comm/packet/annot/OptionalField.java
deleted file mode 100644
index ee2a92fd0d..0000000000
--- a/Ghidra/Debug/Framework-AsyncComm/src/main/java/ghidra/comm/packet/annot/OptionalField.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/* ###
- * 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 ghidra.comm.packet.annot;
-
-import java.lang.annotation.*;
-
-import ghidra.comm.packet.annot.impl.OptionalFieldWrapperFactory;
-import ghidra.comm.packet.err.PacketDecodeException;
-import ghidra.comm.packet.fields.ImplementedBy;
-
-/**
- * An annotation that indicates a given field is optional
- *
- * This annotation is only useful for non-primitive types, because the field must be able to take a
- * {@code null} value. It can use boxed primitives, e.g., {@link Integer}. Ordinarily, attempting to
- * encode any {@code null} value will result in a {@link NullPointerException}. This annotation will
- * cause the encoder to skip the field if its value is {@code null}. During decode, an optional
- * field is given a value of {@code null} if the decode buffer is at its limit. If there is data
- * remaining in the buffer, but it is not enough data to decode the optional field, it will still
- * cause a {@link PacketDecodeException}.
- *
- * Take care to design the protocol carefully when using optional fields. They are generally only
- * useful at the end of a packet or sub-packet.
- */
-@Retention(RetentionPolicy.RUNTIME)
-@Target(ElementType.FIELD)
-@ImplementedBy(OptionalFieldWrapperFactory.class)
-public @interface OptionalField {
- // No attributes
-}
diff --git a/Ghidra/Debug/Framework-AsyncComm/src/main/java/ghidra/comm/packet/annot/RepeatedField.java b/Ghidra/Debug/Framework-AsyncComm/src/main/java/ghidra/comm/packet/annot/RepeatedField.java
deleted file mode 100644
index 51e2dda119..0000000000
--- a/Ghidra/Debug/Framework-AsyncComm/src/main/java/ghidra/comm/packet/annot/RepeatedField.java
+++ /dev/null
@@ -1,72 +0,0 @@
-/* ###
- * 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 ghidra.comm.packet.annot;
-
-import java.lang.annotation.*;
-import java.util.Collection;
-
-import ghidra.comm.packet.PacketFactory;
-import ghidra.comm.packet.annot.impl.RepeatedFieldWrapperFactory;
-import ghidra.comm.packet.fields.ImplementedBy;
-
-/**
- * An annotation applied to collections and arrays
- *
- * This annotation is required for collections and arrays, and it also provides some information
- * about types for the decoder to use. Each element is encoded in order defined by the collection's
- * iterator.
- *
- * A packet may declare abstract collection types, but something must determine what concrete type
- * to use. The same is true of its elements. If unspecified, the decoder will use implementations
- * provided by the {@link PacketFactory}. If, for some reason, those are insufficient, the packet
- * can either declare the field as the concrete type -- usually not the desired solution -- or set
- * an attribute on this annotation.
- */
-@Retention(RetentionPolicy.RUNTIME)
-@Target(ElementType.FIELD)
-@ImplementedBy(RepeatedFieldWrapperFactory.class)
-public @interface RepeatedField {
- /**
- * The concrete type to use for the collection
- *
- * @return the class for the collection
- */
- @SuppressWarnings("rawtypes")
- Class<? extends Collection> container() default DefaultContainer.class;
-
- /**
- * The concrete type to use for the elements of the collection or array
- *
- * @return the class for the elements
- */
- Class<?> elements() default DefaultElements.class;
-
- /**
- * A sentinel to represent the default, would-be-null, value for
- * {@link RepeatedField#container()}
- */
- interface DefaultContainer extends Collection<Object> {
- // A sentinel
- }
-
- /**
- * A sentinel to represent the default, would-be-null, value for
- * {@link RepeatedField#elements()}
- */
- interface DefaultElements {
- // A sentinel
- }
-}
diff --git a/Ghidra/Debug/Framework-AsyncComm/src/main/java/ghidra/comm/packet/annot/SizedByField.java b/Ghidra/Debug/Framework-AsyncComm/src/main/java/ghidra/comm/packet/annot/SizedByField.java
deleted file mode 100644
index c8736c4043..0000000000
--- a/Ghidra/Debug/Framework-AsyncComm/src/main/java/ghidra/comm/packet/annot/SizedByField.java
+++ /dev/null
@@ -1,59 +0,0 @@
-/* ###
- * 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 ghidra.comm.packet.annot;
-
-import java.lang.annotation.*;
-
-import ghidra.comm.packet.annot.impl.SizedByFieldWrapperFactory;
-import ghidra.comm.packet.fields.ImplementedBy;
-
-/**
- * An annotation that indicate the encoded length of this field is given by the value of another
- *
- * The annotated field is called the "sized field," and the field to which this annotation refers is
- * called the "sizing field." Both of these fields must be declared in the same {@link Packet}.
- * Furthermore, the sizing field must precede the sized field.
- *
- * Example:
- *
- * <pre>
- * &#64;PacketField
- * public int length;
- *
- * &#64;PacketField
- * &#64;SizedByField("length");
- * public String name;
- * </pre>
- */
-@Retention(RetentionPolicy.RUNTIME)
-@Target(ElementType.FIELD)
-@ImplementedBy(SizedByFieldWrapperFactory.class)
-public @interface SizedByField {
- /**
- * The amount of extra length to give when decoding the annotated field
- *
- * For example, if {@code name} in the example above were encoded to 6 bytes, and {@code adjust}
- * were set to 2, then {@code length} would be set to 4.
- */
- int adjust() default 0;
-
- /**
- * The name of the field that gives the length
- *
- * @return the name of the sizing field
- */
- String value();
-}
diff --git a/Ghidra/Debug/Framework-AsyncComm/src/main/java/ghidra/comm/packet/annot/SizedByMethods.java b/Ghidra/Debug/Framework-AsyncComm/src/main/java/ghidra/comm/packet/annot/SizedByMethods.java
deleted file mode 100644
index 825a057156..0000000000
--- a/Ghidra/Debug/Framework-AsyncComm/src/main/java/ghidra/comm/packet/annot/SizedByMethods.java
+++ /dev/null
@@ -1,69 +0,0 @@
-/* ###
- * 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 ghidra.comm.packet.annot;
-
-import java.lang.annotation.*;
-
-import ghidra.comm.packet.annot.impl.SizedByMethodsWrapperFactory;
-import ghidra.comm.packet.fields.ImplementedBy;
-
-/**
- * An annotation that indicates the encoded length of this field is given by methods associated with
- * another field
- *
- * The annotated field is called the "sized field," and the field associated with the methods is
- * called the "sizing field(s)." Bot of these fields must be declared in the same {@link Packet}.
- * Furthermore, the sizing field must precede the sized field.
- *
- * Because the sizing field is accessed via methods, the annotation cannot validate the field
- * ordering, unless the correct field name is given to {@link #modifies()}. If the sizing field does
- * not precede the sized field, then the decoder will not be able to determine the correct size of
- * the sized field, because it will not have yet decoded the sizing field. It's possible more than
- * one field is used by the methods. In that case, {@link #modifies()} can be set to either, but all
- * sizing field(s) must precede the sized field or there will be problems.
- */
-@Retention(RetentionPolicy.RUNTIME)
-@Target(ElementType.FIELD)
-@ImplementedBy(SizedByMethodsWrapperFactory.class)
-public @interface SizedByMethods {
- /**
- * The name of the method that gives the length
- *
- * It must be a getter, i.e., take no arguments and return a numeric type.
- *
- * @return the name of the getter method
- */
- String getter();
-
- /**
- * The name of the field related to the length
- *
- * Liars beware, problems may arise that are difficult to diagnose.
- *
- * @return the name of the sizing field
- */
- String modifies();
-
- /**
- * The name of the method used to set the length
- *
- * It must be a setter, i.e, it must take one argument of the same type returned by the
- * {@link #getter()}, and return {@code void}.
- *
- * @return the name of the setter method
- */
- String setter();
-}
diff --git a/Ghidra/Debug/Framework-AsyncComm/src/main/java/ghidra/comm/packet/annot/TypedByField.java b/Ghidra/Debug/Framework-AsyncComm/src/main/java/ghidra/comm/packet/annot/TypedByField.java
deleted file mode 100644
index 4399e247ff..0000000000
--- a/Ghidra/Debug/Framework-AsyncComm/src/main/java/ghidra/comm/packet/annot/TypedByField.java
+++ /dev/null
@@ -1,109 +0,0 @@
-/* ###
- * 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 ghidra.comm.packet.annot;
-
-import java.lang.annotation.*;
-import java.util.Map;
-
-import ghidra.comm.packet.annot.impl.TypedByFieldWrapperFactory;
-import ghidra.comm.packet.fields.ImplementedBy;
-
-/**
- * An annotation that indicates the type of this field is selected by the value of another
- *
- * The annotated field is called the "typed field," and the field to which this annotation referes
- * is called the "typing field." Both of these fields must be declared in the same {@link Packet}.
- * Furthermore, the typing field must precede the typed field.
- *
- * Example:
- *
- * <pre>
- * public class Command extends Packet {
- * &#64;PacketField
- * public int code;
- *
- * &#64;PacketField
- * &#64;TypedByField(by = "op", types = { &#64;TypeSelect(key = 1, type = Put.class),
- * &#64;TypeSelect(key = 2, type = Get.class) })
- * public Op op;
- * }
- *
- * public abstract class Op extends Packet {
- * // Type placeholder
- * }
- *
- * public class Put extends Op {
- * // Fields for "PUT" operation
- * }
- *
- * public class Get extends Op {
- * // Fields for "GET" operation
- * }
- * </pre>
- *
- * Technically, the {@code Op} placeholder class in the example is not required, but it is a useful
- * convention to avoid mistakes later. The map of typing field value to typed field type must be
- * invertible, i.e., one-to-one, since the encoding process will set the typing field value
- * according to the type present in the typed field.
- */
-@Retention(RetentionPolicy.RUNTIME)
-@Target(ElementType.FIELD)
-@ImplementedBy(TypedByFieldWrapperFactory.class)
-public @interface TypedByField {
- /**
- * Used in the {@link TypedByField#types()} attribute to associate keys with types
- */
- public static @interface TypeSelect {
- /**
- * The value of the typing field that selects this type
- *
- * @return the key
- */
- long key();
-
- /**
- * The type, a subclass of the typed field's declared type, to select for the given key
- *
- * @return the subclass
- */
- Class<?> type();
- }
-
- /**
- * The name of the field that selects the type
- *
- * @return the name of the typing field
- */
- String by();
-
- /**
- * The name of a {@code static final} {@link Map} to use as a map
- *
- * This attribute may be used instead of or in combination with {@link #types()}. Technically,
- * the map does not have to be {@code static} or {@code final}, but the map is consumed as-is at
- * the time of packet registration.
- *
- * @return
- */
- String map() default "";
-
- /**
- * An array of key-type pairs mapping typing field values to typed field types
- *
- * @return the array of pairs
- */
- TypeSelect[] types() default {};
-}
diff --git a/Ghidra/Debug/Framework-AsyncComm/src/main/java/ghidra/comm/packet/annot/TypedByLookahead.java b/Ghidra/Debug/Framework-AsyncComm/src/main/java/ghidra/comm/packet/annot/TypedByLookahead.java
deleted file mode 100644
index ea2138ace5..0000000000
--- a/Ghidra/Debug/Framework-AsyncComm/src/main/java/ghidra/comm/packet/annot/TypedByLookahead.java
+++ /dev/null
@@ -1,81 +0,0 @@
-/* ###
- * 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 ghidra.comm.packet.annot;
-
-import java.lang.annotation.*;
-
-import ghidra.comm.packet.Packet;
-import ghidra.comm.packet.annot.impl.TypedByLookaheadWrapperFactory;
-import ghidra.comm.packet.err.PacketDecodeException;
-import ghidra.comm.packet.err.PacketFieldValueMismatchException;
-import ghidra.comm.packet.fields.ImplementedBy;
-import ghidra.comm.packet.fields.PacketField;
-
-/**
- * An annotation that indicates the type of this field is selected by looking ahead
- *
- * That is, the decoder will attempt to decode from a list of types in order. The first one to
- * succeed without producing a {@link PacketFieldValueMismatchException} is taken as the type. Thus,
- * this annotation is most useful when the listed packet types have a {@code final}
- * {@link PacketField}, preferably as the first field. If a type is attempted and it produces any
- * exception other than {@link PacketFieldValueMismatchException}, the entire decode will fail.
- * Protocols should be designed to avoid looking ahead too far.
- *
- * Example:
- *
- * <pre>
- * public class Command extends Packet {
- * &#64;PacketField
- * &#64;TypedByLookahead({ Put.class, Get.class })
- * public Op op;
- * }
- *
- * public abstract class Op extends Packet {
- * // Type placeholder
- * }
- *
- * public class Put extends Op {
- * &#64;PacketField
- * public final String method = "PUT";
- *
- * // Additional fields for "PUT" operation
- * }
- *
- * public class Get extends Op {
- * &#64;PacketField
- * public final String method = "GET";
- *
- * // Additional fields for "GET" operation
- * }
- * </pre>
- *
- * Technically, the {@code Op} placeholder class in the example is not required, but it is a useful
- * convention to avoid mistakes later. For the pattern demonstrated, take care to list
- * {@link Packet}s with longer {@code final} {@link String}s first. If there were another command
- * {@code "PU"} listed before {@code "PUT"}, then {@code "PU"} could be selected by mistake for a
- * {@code "PUT"}, possibly resulting in a {@link PacketDecodeException}.
- */
-@Retention(RetentionPolicy.RUNTIME)
-@Target(ElementType.FIELD)
-@ImplementedBy(TypedByLookaheadWrapperFactory.class)
-public @interface TypedByLookahead {
- /**
- * An array of subclasses of the declared field type to try decoding, in order of preference
- *
- * @return the array of subclasses
- */
- Class<? extends Packet>[] value();
-}
diff --git a/Ghidra/Debug/Framework-AsyncComm/src/main/java/ghidra/comm/packet/annot/WithFlag.java b/Ghidra/Debug/Framework-AsyncComm/src/main/java/ghidra/comm/packet/annot/WithFlag.java
deleted file mode 100644
index c77e01b400..0000000000
--- a/Ghidra/Debug/Framework-AsyncComm/src/main/java/ghidra/comm/packet/annot/WithFlag.java
+++ /dev/null
@@ -1,111 +0,0 @@
-/* ###
- * 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 ghidra.comm.packet.annot;
-
-import java.lang.annotation.*;
-
-import ghidra.comm.packet.annot.impl.WithFlagWrapperFactory;
-import ghidra.comm.packet.fields.ImplementedBy;
-import ghidra.comm.util.BitmaskSet;
-
-/**
- * An annotation that indicates a field is only present if a flag is (or is not) present in another
- * field
- *
- * The annotated field is called the "controlled field," and the field to which this annotation
- * refers is called the "flags field." Both of these fields must be declared in the same
- * {@link Packet}. Furthermore, the flag field must precede the controlled field, and the flag field
- * must have type {@link BitmaskSet}.
- *
- * The annotated field must not be a primitive type, since its flag's absence (or presence, if
- * {@link #mode} is {@link Mode#ABSENT}) will cause it to decode to {@code null}.
- *
- * Example:
- *
- * <pre>
- * public enum ExampleUniverse implements BitmaskUniverse {
- * FIRST(1 << 0), SECOND(1 << 1), THIRD(1 << 2);
- *
- * private final long mask;
- *
- * ExampleUniverse(long mask) {
- * this.mask = mask;
- * }
- * }
- *
- * public class ExamplePacket extends Packet {
- * &#64;PacketField
- * &#64;BitmaskEncoded(universe = ExampleUniverse.class)
- * public BitmaskSet<ExampleUniverse> flags;
- *
- * &#64;PacketField
- * &#64;WithFlag(by = "flags", flag = "FIRST")
- * public FirstPart first;
- *
- * &#64;PacketField
- * &#64;WithFlag(by = "flags", flag = "SECOND")
- * public SecondPart second;
- *
- * &#64;PacketField
- * &#64;WithFlag(by = "flags", flag = "THIRD")
- * public ThirdPart third;
- * }
- * </pre>
- *
- * Please see {@link BitmaskSet} regarding the population count of flag constants. All flags named
- * in a {@link WithFlag} annotation referring to the same flags field must not share any bits. If
- * they do, the behavior is undefined.
- */
-@Retention(RetentionPolicy.RUNTIME)
-@Target(ElementType.FIELD)
-@ImplementedBy(WithFlagWrapperFactory.class)
-public @interface WithFlag {
- /**
- * A mode specifying the annotated field should be decoded if the flag is present or absent
- */
- enum Mode {
- /**
- * Decode only if the flag is present (default)
- */
- PRESENT,
- /**
- * Decode only if the flag is absent
- */
- ABSENT;
- }
-
- /**
- * The name of the field containing the flags
- *
- * @return the name of the flags field
- */
- String by();
-
- /**
- * The name of the enumeration constant representing the flag
- *
- * @return the name of the flag
- */
- String flag();
-
- /**
- * Specifies when to decode the controlled field
- *
- * @return {@link Mode#PRESENT} to decode when set, or {@link Mode#ABSENT} to decode when
- * cleared
- */
- Mode mode() default Mode.PRESENT;
-}
diff --git a/Ghidra/Debug/Framework-AsyncComm/src/main/java/ghidra/comm/packet/annot/impl/BitmaskEncodedFieldCodec.java b/Ghidra/Debug/Framework-AsyncComm/src/main/java/ghidra/comm/packet/annot/impl/BitmaskEncodedFieldCodec.java
deleted file mode 100644
index a248ae0d6b..0000000000
--- a/Ghidra/Debug/Framework-AsyncComm/src/main/java/ghidra/comm/packet/annot/impl/BitmaskEncodedFieldCodec.java
+++ /dev/null
@@ -1,69 +0,0 @@
-/* ###
- * 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 ghidra.comm.packet.annot.impl;
-
-import java.io.IOException;
-import java.lang.reflect.Field;
-import java.util.Set;
-
-import ghidra.comm.packet.Packet;
-import ghidra.comm.packet.PacketFactory;
-import ghidra.comm.packet.binary.AbstractByteBufferPacketCodec;
-import ghidra.comm.packet.err.PacketDecodeException;
-import ghidra.comm.packet.err.PacketEncodeException;
-import ghidra.comm.packet.fields.AbstractFieldCodec;
-import ghidra.comm.packet.fields.FieldCodec;
-import ghidra.comm.util.BitmaskSet;
-
-/**
- * The {@link FieldCodec} for encoding {@link BitmaskSet} values for
- * {@link AbstractByteBufferPacketCodec}
- *
- * This simply encodes the set using the bitmask encoding provided by the set. To use this codec,
- * the field should be declared as {@link BitmaskSet}, not just {@link Set}.
- */
-public class BitmaskEncodedFieldCodec<ENCBUF, DECBUF>
- extends AbstractFieldCodec<ENCBUF, DECBUF, BitmaskSet<?>> {
-
- private final Class<?> universe;
- private final Class<? extends Number> encType;
- private final FieldCodec<ENCBUF, DECBUF, Number> chainNext;
-
- public BitmaskEncodedFieldCodec(Class<? extends Packet> pktType, Field field, Class<?> universe,
- Class<? extends Number> encType, FieldCodec<ENCBUF, DECBUF, Number> chainNext) {
- super(pktType, field);
- this.universe = universe;
- this.encType = encType;
- this.chainNext = chainNext;
- }
-
- @Override
- public BitmaskSet<?> decodeField(Packet pkt, DECBUF buf, Integer count, PacketFactory factory)
- throws IOException, PacketDecodeException {
- Number bits = chainNext.decodeField(pkt, buf, null, factory);
- @SuppressWarnings({ "unchecked", "rawtypes" })
- BitmaskSet val = new BitmaskSet(universe, bits.longValue());
- return val;
- }
-
- @Override
- public void encodeField(ENCBUF buf, Packet pkt, BitmaskSet<?> val)
- throws IOException, PacketEncodeException {
- long bits = val.getBitmask();
- Number enc = getIntegralOfType(encType, bits);
- chainNext.encodeField(buf, pkt, enc);
- }
-}
diff --git a/Ghidra/Debug/Framework-AsyncComm/src/main/java/ghidra/comm/packet/annot/impl/BitmaskEncodedFieldCodecWrapperFactory.java b/Ghidra/Debug/Framework-AsyncComm/src/main/java/ghidra/comm/packet/annot/impl/BitmaskEncodedFieldCodecWrapperFactory.java
deleted file mode 100644
index d75f057a80..0000000000
--- a/Ghidra/Debug/Framework-AsyncComm/src/main/java/ghidra/comm/packet/annot/impl/BitmaskEncodedFieldCodecWrapperFactory.java
+++ /dev/null
@@ -1,97 +0,0 @@
-/* ###
- * 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 ghidra.comm.packet.annot.impl;
-
-import static ghidra.comm.packet.codecs.PacketCodecInternal.getTypeParameterValue;
-
-import java.lang.reflect.Field;
-import java.lang.reflect.Type;
-import java.util.Deque;
-
-import org.apache.commons.lang3.reflect.TypeUtils;
-
-import ghidra.comm.packet.Packet;
-import ghidra.comm.packet.annot.BitmaskEncoded;
-import ghidra.comm.packet.codecs.PacketCodecInternal;
-import ghidra.comm.packet.err.PacketAnnotationException;
-import ghidra.comm.packet.fields.*;
-import ghidra.comm.util.BitmaskSet;
-import ghidra.comm.util.BitmaskUniverse;
-
-/**
- * The factory implementing {@link BitmaskEncoded}
- *
- * @param <ENCBUF> the type of temporary buffer used to encode
- * @param <DECBUF> the type of temporary buffer used to decode
- */
-public class BitmaskEncodedFieldCodecWrapperFactory<ENCBUF, DECBUF>
- extends AbstractWrapperFactory<ENCBUF, DECBUF> {
-
- @SuppressWarnings("unchecked")
- public static <E extends Enum<E> & BitmaskUniverse> Class<E> getUniverse(
- Class<? extends Packet> pktType, Field field) {
- BitmaskEncoded annot = field.getAnnotation(BitmaskEncoded.class);
- final Type universeType;
- if (annot.universe() == BitmaskEncoded.DefaultUniverse.class) {
- universeType = getTypeParameterValue(field.getGenericType(), BitmaskSet.class, "E");
- }
- else {
- universeType = annot.universe();
- }
- if (universeType == null) {
- throw new PacketAnnotationException(pktType, field, annot,
- "Could not determine the universe");
- }
- return (Class<E>) TypeUtils.getRawType(universeType, Object.class);
- }
-
- @SuppressWarnings("unchecked")
- @Override
- public <T> FieldCodec<ENCBUF, DECBUF, T> getWrappedFieldCodecForType(
- Class<? extends Packet> pktType, Field field, Class<? extends T> fldType,
- PacketCodecInternal<?, ENCBUF, DECBUF> codec,
- Deque<FieldCodecFactory<ENCBUF, DECBUF>> chain) {
- BitmaskEncoded annot = field.getAnnotation(BitmaskEncoded.class);
- if (!BitmaskSet.class.isAssignableFrom(fldType)) {
- throw new PacketAnnotationException(pktType, field, annot,
- "Annotated field must be a BitmaskSet. Got " + fldType + " in the chain.");
- }
-
- Class<?> universe = getUniverse(pktType, field);
-
- Class<? extends Number> encType = annot.type();
- if (encType == Byte.class) {
- // Good
- }
- else if (encType == Short.class) {
- // Good
- }
- else if (encType == Integer.class) {
- // Good
- }
- else if (encType == Long.class) {
- // Good
- }
- else {
- throw new PacketAnnotationException(pktType, field, annot,
- "encoding type must be one of Byte, Short, Integer, or Long");
- }
- FieldCodec<ENCBUF, DECBUF, Number> chainNext =
- FieldCodecFactory.buildChainForType(pktType, field, encType, codec, chain);
- return (FieldCodec<ENCBUF, DECBUF, T>) new BitmaskEncodedFieldCodec<>(pktType, field,
- universe, encType, chainNext);
- }
-}
diff --git a/Ghidra/Debug/Framework-AsyncComm/src/main/java/ghidra/comm/packet/annot/impl/CountedByFieldFieldCodec.java b/Ghidra/Debug/Framework-AsyncComm/src/main/java/ghidra/comm/packet/annot/impl/CountedByFieldFieldCodec.java
deleted file mode 100644
index d9f50c6708..0000000000
--- a/Ghidra/Debug/Framework-AsyncComm/src/main/java/ghidra/comm/packet/annot/impl/CountedByFieldFieldCodec.java
+++ /dev/null
@@ -1,66 +0,0 @@
-/* ###
- * 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 ghidra.comm.packet.annot.impl;
-
-import java.io.IOException;
-import java.lang.reflect.Field;
-
-import ghidra.comm.packet.Packet;
-import ghidra.comm.packet.PacketFactory;
-import ghidra.comm.packet.annot.CountedByField;
-import ghidra.comm.packet.err.PacketDecodeException;
-import ghidra.comm.packet.err.PacketEncodeException;
-import ghidra.comm.packet.fields.AbstractFieldCodec;
-import ghidra.comm.packet.fields.FieldCodec;
-
-/**
- * The {@link FieldCodec} for fields annotated by {@link CountedByField}
- *
- * @see CountedByFieldWrapperFactory
- *
- * @param <ENCBUF> the type of temporary buffer used to encode
- * @param <DECBUF> the type of temporary buffer used to decode
- * @param <T> the type of the field as passed through the chain
- */
-class CountedByFieldFieldCodec<ENCBUF, DECBUF, T> extends AbstractFieldCodec<ENCBUF, DECBUF, T> {
- private final FieldCodec<ENCBUF, DECBUF, T> chainNext;
- private final Field countingField;
-
- CountedByFieldFieldCodec(Class<? extends Packet> pktType, Field countedField,
- Field countingField, FieldCodec<ENCBUF, DECBUF, T> chainNext) {
- super(pktType, countedField);
- this.countingField = countingField;
- this.chainNext = chainNext;
- }
-
- @Override
- public T decodeField(Packet pkt, DECBUF buf, Integer count, PacketFactory factory)
- throws IOException, PacketDecodeException {
- try {
- count = (int) getIntegralValue(countingField.get(pkt));
- return chainNext.decodeField(pkt, buf, count, factory);
- }
- catch (IllegalAccessException e) {
- throw new RuntimeException(e);
- }
- }
-
- @Override
- public void encodeField(ENCBUF buf, Packet pkt, T val)
- throws IOException, PacketEncodeException {
- chainNext.encodeField(buf, pkt, val); // TODO: Try to use a cache
- }
-}
diff --git a/Ghidra/Debug/Framework-AsyncComm/src/main/java/ghidra/comm/packet/annot/impl/CountedByFieldInjectedFieldCodec.java b/Ghidra/Debug/Framework-AsyncComm/src/main/java/ghidra/comm/packet/annot/impl/CountedByFieldInjectedFieldCodec.java
deleted file mode 100644
index 8c39a968c4..0000000000
--- a/Ghidra/Debug/Framework-AsyncComm/src/main/java/ghidra/comm/packet/annot/impl/CountedByFieldInjectedFieldCodec.java
+++ /dev/null
@@ -1,76 +0,0 @@
-/* ###
- * 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 ghidra.comm.packet.annot.impl;
-
-import java.io.IOException;
-import java.lang.reflect.Field;
-
-import ghidra.comm.packet.Packet;
-import ghidra.comm.packet.PacketFactory;
-import ghidra.comm.packet.annot.CountedByField;
-import ghidra.comm.packet.codecs.PacketCodecInternal;
-import ghidra.comm.packet.err.PacketDecodeException;
-import ghidra.comm.packet.err.PacketEncodeException;
-import ghidra.comm.packet.fields.AbstractFieldCodec;
-import ghidra.comm.packet.fields.FieldCodec;
-
-/**
- * The {@link FieldCodec} for fields referred to by {@link CountedByField}
- *
- * @see CountedByFieldWrapperFactory
- * @see CountedByFieldInjectionFactory
- *
- * @param <ENCBUF> the type of temporary buffer used to encode
- * @param <DECBUF> the type of temporary buffer used to decode
- * @param <T> the type of the field as passed through the chain
- */
-class CountedByFieldInjectedFieldCodec<ENCBUF, DECBUF, T>
- extends AbstractFieldCodec<ENCBUF, DECBUF, T> {
- private final FieldCodec<ENCBUF, DECBUF, T> chainNext;
- private final Class<? extends T> fldType;
- private final Field countedField;
- private final PacketCodecInternal<?, ENCBUF, DECBUF> codec;
-
- CountedByFieldInjectedFieldCodec(Class<? extends Packet> pktType, Field countingField,
- Class<? extends T> fldType, Field countedField,
- PacketCodecInternal<?, ENCBUF, DECBUF> codec, FieldCodec<ENCBUF, DECBUF, T> chainNext) {
- super(pktType, countingField);
- this.fldType = fldType;
- this.countedField = countedField;
- this.codec = codec;
- this.chainNext = chainNext;
- }
-
- @Override
- public T decodeField(Packet pkt, DECBUF buf, Integer count, PacketFactory factory)
- throws IOException, PacketDecodeException {
- return chainNext.decodeField(pkt, buf, count, factory);
- }
-
- @Override
- public void encodeField(ENCBUF buf, Packet pkt, T val)
- throws IOException, PacketEncodeException {
- try {
- Object countedVal = countedField.get(pkt);
- T count = getIntegralOfType(fldType, codec.measureCount(countedVal));
- field.set(pkt, count);
- chainNext.encodeField(buf, pkt, count);
- }
- catch (IllegalAccessException e) {
- throw new RuntimeException(e);
- }
- }
-}
diff --git a/Ghidra/Debug/Framework-AsyncComm/src/main/java/ghidra/comm/packet/annot/impl/CountedByFieldInjectionFactory.java b/Ghidra/Debug/Framework-AsyncComm/src/main/java/ghidra/comm/packet/annot/impl/CountedByFieldInjectionFactory.java
deleted file mode 100644
index 8a8ddf695e..0000000000
--- a/Ghidra/Debug/Framework-AsyncComm/src/main/java/ghidra/comm/packet/annot/impl/CountedByFieldInjectionFactory.java
+++ /dev/null
@@ -1,51 +0,0 @@
-/* ###
- * 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 ghidra.comm.packet.annot.impl;
-
-import java.lang.reflect.Field;
-import java.util.Deque;
-
-import ghidra.comm.packet.Packet;
-import ghidra.comm.packet.annot.CountedByField;
-import ghidra.comm.packet.codecs.PacketCodecInternal;
-import ghidra.comm.packet.fields.*;
-
-/**
- * The factory injecting {@link CountedByFieldInjectedFieldCodec} on behalf of
- * {@link CountedByField}
- *
- * @param <ENCBUF> the type of temporary buffer used to encode
- * @param <DECBUF> the type of temporary buffer used to decode
- */
-public class CountedByFieldInjectionFactory<ENCBUF, DECBUF>
- extends AbstractWrapperFactory<ENCBUF, DECBUF> implements InjectionFactory<ENCBUF, DECBUF> {
- private final Field countedField;
-
- public CountedByFieldInjectionFactory(Field countedField) {
- this.countedField = countedField;
- }
-
- @Override
- public <T> FieldCodec<ENCBUF, DECBUF, T> getWrappedFieldCodecForType(
- Class<? extends Packet> pktType, Field field, Class<? extends T> fldType,
- PacketCodecInternal<?, ENCBUF, DECBUF> codec,
- Deque<FieldCodecFactory<ENCBUF, DECBUF>> chain) {
- FieldCodec<ENCBUF, DECBUF, T> chainNext =
- FieldCodecFactory.buildChainForType(pktType, field, fldType, codec, chain);
- return new CountedByFieldInjectedFieldCodec<>(pktType, field, fldType, countedField, codec,
- chainNext);
- }
-}
diff --git a/Ghidra/Debug/Framework-AsyncComm/src/main/java/ghidra/comm/packet/annot/impl/CountedByFieldWrapperFactory.java b/Ghidra/Debug/Framework-AsyncComm/src/main/java/ghidra/comm/packet/annot/impl/CountedByFieldWrapperFactory.java
deleted file mode 100644
index d029f8eed3..0000000000
--- a/Ghidra/Debug/Framework-AsyncComm/src/main/java/ghidra/comm/packet/annot/impl/CountedByFieldWrapperFactory.java
+++ /dev/null
@@ -1,69 +0,0 @@
-/* ###
- * 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 ghidra.comm.packet.annot.impl;
-
-import static ghidra.comm.packet.fields.AbstractFieldCodec.isIntegralType;
-
-import java.lang.reflect.Field;
-import java.util.Deque;
-
-import ghidra.comm.packet.Packet;
-import ghidra.comm.packet.annot.CountedByField;
-import ghidra.comm.packet.codecs.PacketCodecInternal;
-import ghidra.comm.packet.err.InvalidFieldNameException;
-import ghidra.comm.packet.err.PacketAnnotationException;
-import ghidra.comm.packet.fields.*;
-
-/**
- * The factory implementing {@link CountedByField}
- *
- * @param <ENCBUF> the type of temporary buffer used to encode
- * @param <DECBUF> the type of temporary buffer used to decode
- */
-public class CountedByFieldWrapperFactory<ENCBUF, DECBUF>
- extends AbstractWrapperFactory<ENCBUF, DECBUF> {
- @Override
- public <T> FieldCodec<ENCBUF, DECBUF, T> getWrappedFieldCodecForType(
- Class<? extends Packet> pktType, Field field, Class<? extends T> fldType,
- PacketCodecInternal<?, ENCBUF, DECBUF> codec,
- Deque<FieldCodecFactory<ENCBUF, DECBUF>> chain) {
- CountedByField annot = field.getAnnotation(CountedByField.class);
- if (fldType.isPrimitive()) {
- throw new PacketAnnotationException(pktType, field, annot,
- "Annotated field cannot be primitive (type is " + fldType + " in the chain)");
- }
-
- final Field countingField;
- try {
- countingField = pktType.getField(annot.value());
- }
- catch (NoSuchFieldException | SecurityException e) {
- throw new InvalidFieldNameException(pktType, field, annot, e.getMessage(), e);
- }
- if (!isIntegralType(countingField.getType())) {
- throw new InvalidFieldNameException(pktType, field, annot,
- "Field is not an integral type");
- }
-
- CountedByFieldInjectionFactory<ENCBUF, DECBUF> injected =
- new CountedByFieldInjectionFactory<>(field);
- codec.injectChain(pktType, countingField, injected, field, annot);
-
- FieldCodec<ENCBUF, DECBUF, T> chainNext =
- FieldCodecFactory.buildChainForType(pktType, field, fldType, codec, chain);
- return new CountedByFieldFieldCodec<>(pktType, field, countingField, chainNext);
- }
-}
diff --git a/Ghidra/Debug/Framework-AsyncComm/src/main/java/ghidra/comm/packet/annot/impl/EncodeCharsFieldCodec.java b/Ghidra/Debug/Framework-AsyncComm/src/main/java/ghidra/comm/packet/annot/impl/EncodeCharsFieldCodec.java
deleted file mode 100644
index ee16bdf855..0000000000
--- a/Ghidra/Debug/Framework-AsyncComm/src/main/java/ghidra/comm/packet/annot/impl/EncodeCharsFieldCodec.java
+++ /dev/null
@@ -1,80 +0,0 @@
-/* ###
- * 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 ghidra.comm.packet.annot.impl;
-
-import java.io.IOException;
-import java.lang.reflect.Field;
-import java.nio.ByteBuffer;
-import java.nio.CharBuffer;
-import java.nio.charset.Charset;
-import java.nio.charset.CharsetEncoder;
-
-import ghidra.comm.packet.Packet;
-import ghidra.comm.packet.PacketFactory;
-import ghidra.comm.packet.annot.EncodeChars;
-import ghidra.comm.packet.binary.ByteBufferPacketCodec;
-import ghidra.comm.packet.codecs.PacketCodecInternal;
-import ghidra.comm.packet.err.PacketDecodeException;
-import ghidra.comm.packet.err.PacketEncodeException;
-import ghidra.comm.packet.fields.AbstractFieldCodec;
-import ghidra.comm.packet.fields.FieldCodec;
-
-/**
- * The {@link FieldCodec} for fields annoted by {@link EncodeChars}
- *
- * @see EncodeCharsWrapperFactory
- *
- * @param <ENCBUF> the type of temporary buffer used to encode
- * @param <DECBUF> the type of temporary buffer used to decode
- */
-class EncodeCharsFieldCodec<ENCBUF, DECBUF>
- extends AbstractFieldCodec<ENCBUF, DECBUF, CharSequence> {
- private final PacketCodecInternal<?, ENCBUF, DECBUF> codec;
- private final FieldCodec<ENCBUF, DECBUF, byte[]> chainNext;
- private final Charset charset;
-
- EncodeCharsFieldCodec(Class<? extends Packet> pktType, Field field, Charset charset,
- PacketCodecInternal<?, ENCBUF, DECBUF> codec,
- FieldCodec<ENCBUF, DECBUF, byte[]> chainNext) {
- super(pktType, field);
- this.charset = charset;
- this.codec = codec;
- this.chainNext = chainNext;
- }
-
- @Override
- public CharSequence decodeField(Packet pkt, DECBUF buf, Integer count, PacketFactory factory)
- throws IOException, PacketDecodeException {
- int pos = codec.getDecodePosition(buf);
- byte[] all = chainNext.decodeField(pkt, buf, null, factory);
- ByteBuffer temp = ByteBuffer.wrap(all);
- CharSequence result =
- ByteBufferPacketCodec.getInstance().decodeCharSequence(field, temp, count, charset);
- // Rewind, and consume just enough for the result
- codec.setDecodePosition(buf, pos);
- chainNext.decodeField(pkt, buf, temp.position(), factory);
- return result;
- }
-
- @Override
- public void encodeField(ENCBUF buf, Packet pkt, CharSequence val)
- throws IOException, PacketEncodeException {
- CharsetEncoder ce = charset.newEncoder();
- ByteBuffer temp = ce.encode(CharBuffer.wrap(val));
- temp.flip();
- chainNext.encodeField(buf, pkt, temp.array());
- }
-}
diff --git a/Ghidra/Debug/Framework-AsyncComm/src/main/java/ghidra/comm/packet/annot/impl/EncodeCharsWrapperFactory.java b/Ghidra/Debug/Framework-AsyncComm/src/main/java/ghidra/comm/packet/annot/impl/EncodeCharsWrapperFactory.java
deleted file mode 100644
index 653765a9a9..0000000000
--- a/Ghidra/Debug/Framework-AsyncComm/src/main/java/ghidra/comm/packet/annot/impl/EncodeCharsWrapperFactory.java
+++ /dev/null
@@ -1,61 +0,0 @@
-/* ###
- * 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 ghidra.comm.packet.annot.impl;
-
-import java.lang.reflect.Field;
-import java.nio.charset.*;
-import java.util.Deque;
-
-import ghidra.comm.packet.Packet;
-import ghidra.comm.packet.annot.EncodeChars;
-import ghidra.comm.packet.codecs.PacketCodecInternal;
-import ghidra.comm.packet.err.PacketAnnotationException;
-import ghidra.comm.packet.fields.*;
-
-/**
- * The factory implementing {@link EncodeChars}
- *
- * @param <ENCBUF> the type of temporary buffer used to encode
- * @param <DECBUF> the type of temporary buffer used to decode
- */
-public class EncodeCharsWrapperFactory<ENCBUF, DECBUF>
- extends AbstractWrapperFactory<ENCBUF, DECBUF> {
- @SuppressWarnings("unchecked")
- @Override
- public <T> FieldCodec<ENCBUF, DECBUF, T> getWrappedFieldCodecForType(
- Class<? extends Packet> pktType, Field field, Class<? extends T> fldType,
- PacketCodecInternal<?, ENCBUF, DECBUF> codec,
- Deque<FieldCodecFactory<ENCBUF, DECBUF>> chain) {
- EncodeChars annot = field.getAnnotation(EncodeChars.class);
-
- final Charset charset;
- try {
- charset = Charset.forName(annot.value());
- }
- catch (IllegalCharsetNameException | UnsupportedCharsetException e) {
- throw new PacketAnnotationException(pktType, field, annot,
- "Cannot find charset " + annot.value(), e);
- }
-
- if (CharSequence.class.isAssignableFrom(fldType)) {
- FieldCodec<ENCBUF, DECBUF, byte[]> chainNext =
- FieldCodecFactory.buildChainForType(pktType, field, byte[].class, codec, chain);
- return (FieldCodec<ENCBUF, DECBUF, T>) new EncodeCharsFieldCodec<>(pktType, field,
- charset, codec, chainNext);
- }
- return null;
- }
-}
diff --git a/Ghidra/Debug/Framework-AsyncComm/src/main/java/ghidra/comm/packet/annot/impl/OptionalFieldFieldCodec.java b/Ghidra/Debug/Framework-AsyncComm/src/main/java/ghidra/comm/packet/annot/impl/OptionalFieldFieldCodec.java
deleted file mode 100644
index 8d22c978a8..0000000000
--- a/Ghidra/Debug/Framework-AsyncComm/src/main/java/ghidra/comm/packet/annot/impl/OptionalFieldFieldCodec.java
+++ /dev/null
@@ -1,67 +0,0 @@
-/* ###
- * 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 ghidra.comm.packet.annot.impl;
-
-import java.io.IOException;
-import java.lang.reflect.Field;
-
-import ghidra.comm.packet.Packet;
-import ghidra.comm.packet.PacketFactory;
-import ghidra.comm.packet.annot.OptionalField;
-import ghidra.comm.packet.codecs.PacketCodecInternal;
-import ghidra.comm.packet.err.PacketDecodeException;
-import ghidra.comm.packet.err.PacketEncodeException;
-import ghidra.comm.packet.fields.AbstractFieldCodec;
-import ghidra.comm.packet.fields.FieldCodec;
-
-/**
- * The {@link FieldCodec} for fields annotated by {@link OptionalField}
- *
- * @see OptionalFieldWrapperFactory
- *
- * @param <ENCBUF> the type of temporary buffer used to encode
- * @param <DECBUF> the type of temporary buffer used to decode
- * @param <T> the type of the field as passed through the chain
- */
-class OptionalFieldFieldCodec<ENCBUF, DECBUF, T> extends AbstractFieldCodec<ENCBUF, DECBUF, T> {
- private final PacketCodecInternal<?, ENCBUF, DECBUF> codec;
- private final FieldCodec<ENCBUF, DECBUF, T> chainNext;
-
- OptionalFieldFieldCodec(Class<? extends Packet> pktType, Field field,
- PacketCodecInternal<?, ENCBUF, DECBUF> codec, FieldCodec<ENCBUF, DECBUF, T> chainNext) {
- super(pktType, field);
- this.codec = codec;
- this.chainNext = chainNext;
- }
-
- @Override
- public T decodeField(Packet pkt, DECBUF buf, Integer count, PacketFactory factory)
- throws IOException, PacketDecodeException {
- if (codec.measureDecodeRemaining(buf) == 0) {
- return null;
- }
- return chainNext.decodeField(pkt, buf, count, factory);
- }
-
- @Override
- public void encodeField(ENCBUF buf, Packet pkt, T val)
- throws IOException, PacketEncodeException {
- if (val == null) {
- return;
- }
- chainNext.encodeField(buf, pkt, val);
- }
-}
diff --git a/Ghidra/Debug/Framework-AsyncComm/src/main/java/ghidra/comm/packet/annot/impl/OptionalFieldWrapperFactory.java b/Ghidra/Debug/Framework-AsyncComm/src/main/java/ghidra/comm/packet/annot/impl/OptionalFieldWrapperFactory.java
deleted file mode 100644
index c0ce4baffc..0000000000
--- a/Ghidra/Debug/Framework-AsyncComm/src/main/java/ghidra/comm/packet/annot/impl/OptionalFieldWrapperFactory.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/* ###
- * 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 ghidra.comm.packet.annot.impl;
-
-import java.lang.reflect.Field;
-import java.util.Deque;
-
-import ghidra.comm.packet.Packet;
-import ghidra.comm.packet.annot.OptionalField;
-import ghidra.comm.packet.codecs.PacketCodecInternal;
-import ghidra.comm.packet.err.PacketAnnotationException;
-import ghidra.comm.packet.fields.*;
-
-/**
- * The factory implementing {@link OptionalField}
- *
- * @param <ENCBUF> the type of temporary buffer used to encode
- * @param <DECBUF> the type of temporary buffer used to decode
- */
-public class OptionalFieldWrapperFactory<ENCBUF, DECBUF>
- extends AbstractWrapperFactory<ENCBUF, DECBUF> {
- @Override
- public <T> FieldCodec<ENCBUF, DECBUF, T> getWrappedFieldCodecForType(
- Class<? extends Packet> pktType, Field field, Class<? extends T> fldType,
- PacketCodecInternal<?, ENCBUF, DECBUF> codec,
- Deque<FieldCodecFactory<ENCBUF, DECBUF>> chain) {
- OptionalField annot = field.getAnnotation(OptionalField.class);
- if (fldType.isPrimitive()) {
- throw new PacketAnnotationException(pktType, field, annot,
- "Field cannot be primitive (must accept null)");
- }
-
- FieldCodec<ENCBUF, DECBUF, T> chainNext =
- FieldCodecFactory.buildChainForType(pktType, field, fldType, codec, chain);
- return new OptionalFieldFieldCodec<>(pktType, field, codec, chainNext);
- }
-}
diff --git a/Ghidra/Debug/Framework-AsyncComm/src/main/java/ghidra/comm/packet/annot/impl/RepeatedFieldWrapperFactory.java b/Ghidra/Debug/Framework-AsyncComm/src/main/java/ghidra/comm/packet/annot/impl/RepeatedFieldWrapperFactory.java
deleted file mode 100644
index 3b5f91e3f0..0000000000
--- a/Ghidra/Debug/Framework-AsyncComm/src/main/java/ghidra/comm/packet/annot/impl/RepeatedFieldWrapperFactory.java
+++ /dev/null
@@ -1,114 +0,0 @@
-/* ###
- * 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 ghidra.comm.packet.annot.impl;
-
-import static ghidra.comm.packet.codecs.PacketCodecInternal.getTypeParameterValue;
-
-import java.io.IOException;
-import java.lang.reflect.Field;
-import java.lang.reflect.Type;
-import java.util.Collection;
-import java.util.Deque;
-
-import org.apache.commons.lang3.reflect.TypeUtils;
-
-import ghidra.comm.packet.Packet;
-import ghidra.comm.packet.PacketFactory;
-import ghidra.comm.packet.annot.RepeatedField;
-import ghidra.comm.packet.codecs.*;
-import ghidra.comm.packet.err.*;
-import ghidra.comm.packet.fields.*;
-
-/**
- * The factory implementing {@link RepeatedField}
- *
- * @see ArrayFieldCodec
- * @see CollectionFieldCodec
- *
- * @param <ENCBUF> the type of temporary buffer used to encode
- * @param <DECBUF> the type of temporary buffer used to decode
- * @param <E> the type of element encoded, as passed through the chain
- */
-public class RepeatedFieldWrapperFactory<ENCBUF, DECBUF, E>
- extends AbstractWrapperFactory<ENCBUF, DECBUF> implements ElementCodec<ENCBUF, DECBUF, E> {
- @SuppressWarnings("unchecked")
- @Override
- public <T> FieldCodec<ENCBUF, DECBUF, T> getWrappedFieldCodecForType(
- Class<? extends Packet> pktType, Field field, Class<? extends T> fldType,
- PacketCodecInternal<?, ENCBUF, DECBUF> codec,
- Deque<FieldCodecFactory<ENCBUF, DECBUF>> chain) {
- RepeatedField annot = field.getAnnotation(RepeatedField.class);
- if (Collection.class.isAssignableFrom(fldType)) {
- final Class<? extends Collection<E>> colType;
- if (annot.container() == RepeatedField.DefaultContainer.class) {
- colType = (Class<? extends Collection<E>>) fldType;
- }
- else if (!fldType.isAssignableFrom(annot.container())) {
- throw new PacketAnnotationException(pktType, field, annot, "Container type " +
- annot.container() + " must be assignable to the annotated field");
- }
- else {
- colType = (Class<? extends Collection<E>>) annot.container();
- }
- final Type elemType;
- if (annot.elements() == RepeatedField.DefaultElements.class) {
- elemType = getTypeParameterValue(field.getGenericType(), Collection.class, "E");
- }
- else {
- elemType = annot.elements();
- }
- if (elemType == null) {
- throw new PacketAnnotationException(pktType, field, annot,
- "Could not determine type of elements");
- }
- Class<E> elemRaw = (Class<E>) TypeUtils.getRawType(elemType, Object.class);
- FieldCodec<ENCBUF, DECBUF, E> chainNext =
- FieldCodecFactory.buildChainForType(pktType, field, elemRaw, codec, chain);
- return (FieldCodec<ENCBUF, DECBUF, T>) new CollectionFieldCodec<>(this, pktType, field,
- colType, elemRaw, codec, chainNext);
- }
- else if (fldType.isArray()) {
- Class<E> elemType = (Class<E>) fldType.getComponentType();
- if (annot.container() != RepeatedField.DefaultContainer.class) {
- throw new PacketAnnotationException(pktType, field, annot,
- "Cannot specify container type on array");
- }
- if (annot.elements() != RepeatedField.DefaultElements.class) {
- throw new PacketAnnotationException(pktType, field, annot,
- "Cannot specify element type on array");
- }
-
- FieldCodec<ENCBUF, DECBUF, E> chainNext =
- FieldCodecFactory.buildChainForType(pktType, field, elemType, codec, chain);
- return (FieldCodec<ENCBUF, DECBUF, T>) new ArrayFieldCodec<>(this, pktType, field,
- elemType, codec, chainNext);
- }
- return null;
- }
-
- @Override
- public E decodeElement(Packet pkt, Field field, DECBUF buf, Class<E> elemType, boolean last,
- FieldCodec<ENCBUF, DECBUF, E> chainNext, PacketFactory factory)
- throws IOException, PacketDecodeException {
- return chainNext.decodeField(pkt, buf, null, factory);
- }
-
- @Override
- public void encodeElement(ENCBUF buf, Packet pkt, Field field, E elem, boolean last,
- FieldCodec<ENCBUF, DECBUF, E> chainNext) throws IOException, PacketEncodeException {
- chainNext.encodeField(buf, pkt, elem);
- }
-}
diff --git a/Ghidra/Debug/Framework-AsyncComm/src/main/java/ghidra/comm/packet/annot/impl/SizedByFieldFieldCodec.java b/Ghidra/Debug/Framework-AsyncComm/src/main/java/ghidra/comm/packet/annot/impl/SizedByFieldFieldCodec.java
deleted file mode 100644
index e253fbbcc6..0000000000
--- a/Ghidra/Debug/Framework-AsyncComm/src/main/java/ghidra/comm/packet/annot/impl/SizedByFieldFieldCodec.java
+++ /dev/null
@@ -1,80 +0,0 @@
-/* ###
- * 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 ghidra.comm.packet.annot.impl;
-
-import java.io.IOException;
-import java.lang.reflect.Field;
-
-import ghidra.comm.packet.Packet;
-import ghidra.comm.packet.PacketFactory;
-import ghidra.comm.packet.annot.SizedByField;
-import ghidra.comm.packet.codecs.PacketCodecInternal;
-import ghidra.comm.packet.err.PacketDecodeException;
-import ghidra.comm.packet.err.PacketEncodeException;
-import ghidra.comm.packet.fields.AbstractFieldCodec;
-import ghidra.comm.packet.fields.FieldCodec;
-
-/**
- * The {@link FieldCodec} for fields annotated by {@link SizedByField}
- *
- * @see SizedByFieldWrapperFactory
- *
- * @param <ENCBUF> the type of temporary buffer used to encode
- * @param <DECBUF> the type of temporary buffer used to decode
- * @param <T> the type of the field as passed through the chain
- */
-class SizedByFieldFieldCodec<ENCBUF, DECBUF, T> extends AbstractFieldCodec<ENCBUF, DECBUF, T> {
- private final Field sizingField;
- private final SizedByField annot;
- private final FieldCodec<ENCBUF, DECBUF, T> chainNext;
- private final PacketCodecInternal<?, ENCBUF, DECBUF> codec;
-
- SizedByFieldFieldCodec(Class<? extends Packet> pktType, Field sizedField, Field sizingField,
- SizedByField annot, PacketCodecInternal<?, ENCBUF, DECBUF> codec,
- FieldCodec<ENCBUF, DECBUF, T> chainNext) {
- super(pktType, sizedField);
- this.sizingField = sizingField;
- this.annot = annot;
- this.codec = codec;
- this.chainNext = chainNext;
- }
-
- @Override
- public T decodeField(Packet pkt, DECBUF buf, Integer count, PacketFactory factory)
- throws IOException, PacketDecodeException {
- try {
- int len = (int) getIntegralValue(sizingField.get(pkt)) + annot.adjust();
- int pos = codec.getDecodePosition(buf);
- int orig = codec.limitDecodeBuffer(buf, pos + len);
- T result = chainNext.decodeField(pkt, buf, count, factory);
- if (codec.measureDecodeRemaining(buf) != 0) {
- throw new PacketDecodeException("Gratuitous data in sized field");
- // TODO: Consider padding
- }
- codec.limitDecodeBuffer(buf, orig);
- return result;
- }
- catch (IllegalAccessException e) {
- throw new RuntimeException(e);
- }
- }
-
- @Override
- public void encodeField(ENCBUF buf, Packet pkt, T val)
- throws IOException, PacketEncodeException {
- chainNext.encodeField(buf, pkt, val); // TODO: Try to use a cache
- }
-}
diff --git a/Ghidra/Debug/Framework-AsyncComm/src/main/java/ghidra/comm/packet/annot/impl/SizedByFieldInjectedFieldCodec.java b/Ghidra/Debug/Framework-AsyncComm/src/main/java/ghidra/comm/packet/annot/impl/SizedByFieldInjectedFieldCodec.java
deleted file mode 100644
index 4539a2cb8d..0000000000
--- a/Ghidra/Debug/Framework-AsyncComm/src/main/java/ghidra/comm/packet/annot/impl/SizedByFieldInjectedFieldCodec.java
+++ /dev/null
@@ -1,82 +0,0 @@
-/* ###
- * 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 ghidra.comm.packet.annot.impl;
-
-import java.io.IOException;
-import java.lang.reflect.Field;
-
-import ghidra.comm.packet.Packet;
-import ghidra.comm.packet.PacketFactory;
-import ghidra.comm.packet.annot.SizedByField;
-import ghidra.comm.packet.codecs.PacketCodecInternal;
-import ghidra.comm.packet.err.PacketDecodeException;
-import ghidra.comm.packet.err.PacketEncodeException;
-import ghidra.comm.packet.fields.AbstractFieldCodec;
-import ghidra.comm.packet.fields.FieldCodec;
-
-/**
- * The {@link FieldCodec} for fields referred to by {@link SizedByField}
- *
- * @see SizedByFieldWrapperFactory
- * @see SizedByFieldInjectionFactory
- *
- * @param <ENCBUF> the type of temporary buffer used to encode
- * @param <DECBUF> the type of temporary buffer used to decode
- * @param <T> the type of the field as passed through the chain
- */
-class SizedByFieldInjectedFieldCodec<ENCBUF, DECBUF, T>
- extends AbstractFieldCodec<ENCBUF, DECBUF, T> {
- private final Class<? extends T> fldType;
- private final Field sizedField;
- private final int adjust;
- private final PacketCodecInternal<?, ENCBUF, DECBUF> codec;
- private final FieldCodec<ENCBUF, DECBUF, T> chainNext;
-
- SizedByFieldInjectedFieldCodec(Class<? extends Packet> pktType, Field sizingField,
- Class<? extends T> fldType, Field sizedField, int adjust,
- PacketCodecInternal<?, ENCBUF, DECBUF> codec, FieldCodec<ENCBUF, DECBUF, T> chainNext) {
- super(pktType, sizingField);
- this.fldType = fldType;
- this.sizedField = sizedField;
- this.adjust = adjust;
- this.codec = codec;
- this.chainNext = chainNext;
- }
-
- @Override
- public T decodeField(Packet pkt, DECBUF buf, Integer count, PacketFactory factory)
- throws IOException, PacketDecodeException {
- return chainNext.decodeField(pkt, buf, count, factory);
- }
-
- @Override
- public void encodeField(ENCBUF buf, Packet pkt, T val)
- throws IOException, PacketEncodeException {
- try {
- int pos = codec.measureEncodeSize(buf);
- codec.encodeField(buf, pkt, sizedField, sizedField.get(pkt)); // TODO: Cache this
- int tot = codec.measureEncodeSize(buf);
- int size = tot - pos;
- codec.setEncodePosition(buf, pos);
- T len = getIntegralOfType(fldType, size - adjust);
- field.set(pkt, len);
- chainNext.encodeField(buf, pkt, len);
- }
- catch (IllegalAccessException e) {
- throw new RuntimeException(e);
- }
- }
-}
diff --git a/Ghidra/Debug/Framework-AsyncComm/src/main/java/ghidra/comm/packet/annot/impl/SizedByFieldInjectionFactory.java b/Ghidra/Debug/Framework-AsyncComm/src/main/java/ghidra/comm/packet/annot/impl/SizedByFieldInjectionFactory.java
deleted file mode 100644
index f0bb2f07dc..0000000000
--- a/Ghidra/Debug/Framework-AsyncComm/src/main/java/ghidra/comm/packet/annot/impl/SizedByFieldInjectionFactory.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/* ###
- * 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 ghidra.comm.packet.annot.impl;
-
-import java.lang.reflect.Field;
-import java.util.Deque;
-
-import ghidra.comm.packet.Packet;
-import ghidra.comm.packet.annot.SizedByField;
-import ghidra.comm.packet.codecs.PacketCodecInternal;
-import ghidra.comm.packet.fields.*;
-
-/**
- * The factory injecting {@link SizedByFieldInjectedFieldCodec} on behalf of {@link SizedByField}
- *
- * @param <ENCBUF> the type of temporary buffer used to encode
- * @param <DECBUF> the type of temporary buffer used to decode
- */
-public class SizedByFieldInjectionFactory<ENCBUF, DECBUF>
- extends AbstractWrapperFactory<ENCBUF, DECBUF> implements InjectionFactory<ENCBUF, DECBUF> {
- private final Field sizedField;
- private final int adjust;
-
- public SizedByFieldInjectionFactory(Field sizedField, int adjust) {
- this.sizedField = sizedField;
- this.adjust = adjust;
- }
-
- @Override
- public <T> FieldCodec<ENCBUF, DECBUF, T> getWrappedFieldCodecForType(
- Class<? extends Packet> pktType, Field field, Class<? extends T> fldType,
- PacketCodecInternal<?, ENCBUF, DECBUF> codec,
- Deque<FieldCodecFactory<ENCBUF, DECBUF>> chain) {
- FieldCodec<ENCBUF, DECBUF, T> chainNext =
- FieldCodecFactory.buildChainForType(pktType, field, fldType, codec, chain);
- return new SizedByFieldInjectedFieldCodec<>(pktType, field, fldType, sizedField, adjust,
- codec, chainNext);
- }
-}
diff --git a/Ghidra/Debug/Framework-AsyncComm/src/main/java/ghidra/comm/packet/annot/impl/SizedByFieldWrapperFactory.java b/Ghidra/Debug/Framework-AsyncComm/src/main/java/ghidra/comm/packet/annot/impl/SizedByFieldWrapperFactory.java
deleted file mode 100644
index 0f3f1ad4a4..0000000000
--- a/Ghidra/Debug/Framework-AsyncComm/src/main/java/ghidra/comm/packet/annot/impl/SizedByFieldWrapperFactory.java
+++ /dev/null
@@ -1,69 +0,0 @@
-/* ###
- * 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 ghidra.comm.packet.annot.impl;
-
-import static ghidra.comm.packet.fields.AbstractFieldCodec.isIntegralType;
-
-import java.lang.reflect.Field;
-import java.util.Deque;
-
-import ghidra.comm.packet.Packet;
-import ghidra.comm.packet.annot.SizedByField;
-import ghidra.comm.packet.codecs.PacketCodecInternal;
-import ghidra.comm.packet.err.InvalidFieldNameException;
-import ghidra.comm.packet.fields.*;
-
-/**
- * The factory implementing {@link SizedByField}
- *
- * @param <ENCBUF> the type of temporary buffer used to encode
- * @param <DECBUF> the type of temporary buffer used to decode
- */
-public class SizedByFieldWrapperFactory<ENCBUF, DECBUF>
- extends AbstractWrapperFactory<ENCBUF, DECBUF> {
- @Override
- public <T> FieldCodec<ENCBUF, DECBUF, T> getWrappedFieldCodecForType(
- Class<? extends Packet> pktType, Field field, Class<? extends T> fldType,
- PacketCodecInternal<?, ENCBUF, DECBUF> codec,
- Deque<FieldCodecFactory<ENCBUF, DECBUF>> chain) {
- SizedByField annot = field.getAnnotation(SizedByField.class);
- /*
- * if (chain.peek() instanceof WrapperFactory) { throw new
- * PacketAnnotationException(pktType, field, annot,
- * "must be applied directly above the field"); }
- */
-
- final Field sizingField;
- try {
- sizingField = pktType.getField(annot.value());
- }
- catch (NoSuchFieldException | SecurityException e) {
- throw new InvalidFieldNameException(pktType, field, annot, e.getMessage(), e);
- }
- if (!isIntegralType(sizingField.getType())) {
- throw new InvalidFieldNameException(pktType, sizingField, annot,
- "Field is not an integral type");
- }
-
- SizedByFieldInjectionFactory<ENCBUF, DECBUF> injected =
- new SizedByFieldInjectionFactory<>(field, annot.adjust());
- codec.injectChain(pktType, sizingField, injected, field, annot);
-
- FieldCodec<ENCBUF, DECBUF, T> chainNext =
- FieldCodecFactory.buildChainForType(pktType, field, fldType, codec, chain);
- return new SizedByFieldFieldCodec<>(pktType, field, sizingField, annot, codec, chainNext);
- }
-}
diff --git a/Ghidra/Debug/Framework-AsyncComm/src/main/java/ghidra/comm/packet/annot/impl/SizedByMethodsFieldCodec.java b/Ghidra/Debug/Framework-AsyncComm/src/main/java/ghidra/comm/packet/annot/impl/SizedByMethodsFieldCodec.java
deleted file mode 100644
index cbdbe75de4..0000000000
--- a/Ghidra/Debug/Framework-AsyncComm/src/main/java/ghidra/comm/packet/annot/impl/SizedByMethodsFieldCodec.java
+++ /dev/null
@@ -1,77 +0,0 @@
-/* ###
- * 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 ghidra.comm.packet.annot.impl;
-
-import java.io.IOException;
-import java.lang.reflect.*;
-
-import ghidra.comm.packet.Packet;
-import ghidra.comm.packet.PacketFactory;
-import ghidra.comm.packet.annot.SizedByMethods;
-import ghidra.comm.packet.codecs.PacketCodecInternal;
-import ghidra.comm.packet.err.PacketDecodeException;
-import ghidra.comm.packet.err.PacketEncodeException;
-import ghidra.comm.packet.fields.AbstractFieldCodec;
-import ghidra.comm.packet.fields.FieldCodec;
-
-/**
- * The {@link FieldCodec} for fields annotated by {@link SizedByMethods}
- *
- * @see SizedByMethodsWrapperFactory
- *
- * @param <ENCBUF> the type of temporary buffer used to encode
- * @param <DECBUF> the type of temporary buffer used to decode
- * @param <T> the type of the field as passed through the chain
- */
-class SizedByMethodsFieldCodec<ENCBUF, DECBUF, T> extends AbstractFieldCodec<ENCBUF, DECBUF, T> {
- private final PacketCodecInternal<?, ENCBUF, DECBUF> codec;
- private final FieldCodec<ENCBUF, DECBUF, T> chainNext;
- private final Method getter;
-
- SizedByMethodsFieldCodec(Class<? extends Packet> pktType, Field field, Method getter,
- PacketCodecInternal<?, ENCBUF, DECBUF> codec, FieldCodec<ENCBUF, DECBUF, T> chainNext) {
- super(pktType, field);
- this.getter = getter;
- this.codec = codec;
- this.chainNext = chainNext;
- }
-
- @Override
- public T decodeField(Packet pkt, DECBUF buf, Integer count, PacketFactory factory)
- throws IOException, PacketDecodeException {
- try {
- int len = (int) getIntegralValue(getter.invoke(pkt));
- int pos = codec.getDecodePosition(buf);
- int orig = codec.limitDecodeBuffer(buf, pos + len);
- T result = chainNext.decodeField(pkt, buf, count, factory);
- if (codec.measureDecodeRemaining(buf) != 0) {
- throw new PacketDecodeException("Gratuitous data in sized field");
- // TODO: Consider padding
- }
- codec.limitDecodeBuffer(buf, orig);
- return result;
- }
- catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) {
- throw new RuntimeException(e);
- }
- }
-
- @Override
- public void encodeField(ENCBUF buf, Packet pkt, T val)
- throws IOException, PacketEncodeException {
- chainNext.encodeField(buf, pkt, val); // TODO: Try to use a cache
- }
-}
diff --git a/Ghidra/Debug/Framework-AsyncComm/src/main/java/ghidra/comm/packet/annot/impl/SizedByMethodsInjectedFieldCodec.java b/Ghidra/Debug/Framework-AsyncComm/src/main/java/ghidra/comm/packet/annot/impl/SizedByMethodsInjectedFieldCodec.java
deleted file mode 100644
index c8bc4da4db..0000000000
--- a/Ghidra/Debug/Framework-AsyncComm/src/main/java/ghidra/comm/packet/annot/impl/SizedByMethodsInjectedFieldCodec.java
+++ /dev/null
@@ -1,83 +0,0 @@
-/* ###
- * 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 ghidra.comm.packet.annot.impl;
-
-import java.io.IOException;
-import java.lang.reflect.*;
-
-import ghidra.comm.packet.Packet;
-import ghidra.comm.packet.PacketFactory;
-import ghidra.comm.packet.annot.SizedByMethods;
-import ghidra.comm.packet.codecs.PacketCodecInternal;
-import ghidra.comm.packet.err.PacketDecodeException;
-import ghidra.comm.packet.err.PacketEncodeException;
-import ghidra.comm.packet.fields.AbstractFieldCodec;
-import ghidra.comm.packet.fields.FieldCodec;
-
-/**
- * The {@link FieldCodec} for fields referred to by {@link SizedByMethods}
- *
- * @see SizedByMethodsWrapperFactory
- * @see SizedByMethodsInjectionFactory
- *
- * @param <ENCBUF> the type of temporary buffer used to encode
- * @param <DECBUF> the type of temporary buffer used to decode
- * @param <T> the type of the field as passed through the chain
- */
-class SizedByMethodsInjectedFieldCodec<ENCBUF, DECBUF, T>
- extends AbstractFieldCodec<ENCBUF, DECBUF, T> {
- private final Field sizedField;
- private final Method getter;
- private final Method setter;
- private final PacketCodecInternal<?, ENCBUF, DECBUF> codec;
- private final FieldCodec<ENCBUF, DECBUF, T> chainNext;
-
- SizedByMethodsInjectedFieldCodec(Class<? extends Packet> pktType, Field sizingField,
- Field sizedField, Method getter, Method setter,
- PacketCodecInternal<?, ENCBUF, DECBUF> codec, FieldCodec<ENCBUF, DECBUF, T> chainNext) {
- super(pktType, sizingField);
- this.sizedField = sizedField;
- this.getter = getter;
- this.setter = setter;
- this.codec = codec;
- this.chainNext = chainNext;
- }
-
- @Override
- public T decodeField(Packet pkt, DECBUF buf, Integer count, PacketFactory factory)
- throws IOException, PacketDecodeException {
- return chainNext.decodeField(pkt, buf, count, factory);
- }
-
- @SuppressWarnings("unchecked")
- @Override
- public void encodeField(ENCBUF buf, Packet pkt, T val)
- throws IOException, PacketEncodeException {
- try {
- int pos = codec.measureEncodeSize(buf);
- codec.encodeField(buf, pkt, sizedField, sizedField.get(pkt)); // TODO: Cache this
- int tot = codec.measureEncodeSize(buf);
- int size = tot - pos;
- codec.setEncodePosition(buf, pos);
- Object len = getIntegralOfType(getter.getReturnType(), size);
- setter.invoke(pkt, len);
- chainNext.encodeField(buf, pkt, (T) field.get(pkt)); // Retrieve the field
- }
- catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) {
- throw new RuntimeException(e);
- }
- }
-}
diff --git a/Ghidra/Debug/Framework-AsyncComm/src/main/java/ghidra/comm/packet/annot/impl/SizedByMethodsInjectionFactory.java b/Ghidra/Debug/Framework-AsyncComm/src/main/java/ghidra/comm/packet/annot/impl/SizedByMethodsInjectionFactory.java
deleted file mode 100644
index eb053c74b0..0000000000
--- a/Ghidra/Debug/Framework-AsyncComm/src/main/java/ghidra/comm/packet/annot/impl/SizedByMethodsInjectionFactory.java
+++ /dev/null
@@ -1,56 +0,0 @@
-/* ###
- * 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 ghidra.comm.packet.annot.impl;
-
-import java.lang.reflect.Field;
-import java.lang.reflect.Method;
-import java.util.Deque;
-
-import ghidra.comm.packet.Packet;
-import ghidra.comm.packet.annot.SizedByMethods;
-import ghidra.comm.packet.codecs.PacketCodecInternal;
-import ghidra.comm.packet.fields.*;
-
-/**
- * The factory injecting {@link SizedByMethodsInjectedFieldCodec} on behalf of
- * {@link SizedByMethods}
- *
- * @param <ENCBUF> the type of temporary buffer used to encode
- * @param <DECBUF> the type of temporary buffer used to decode
- */
-public class SizedByMethodsInjectionFactory<ENCBUF, DECBUF>
- extends AbstractWrapperFactory<ENCBUF, DECBUF> implements InjectionFactory<ENCBUF, DECBUF> {
- private final Method getter;
- private final Method setter;
- private final Field sizedField;
-
- public SizedByMethodsInjectionFactory(Field sizedField, Method getter, Method setter) {
- this.sizedField = sizedField;
- this.getter = getter;
- this.setter = setter;
- }
-
- @Override
- public <T> FieldCodec<ENCBUF, DECBUF, T> getWrappedFieldCodecForType(
- Class<? extends Packet> pktType, Field field, Class<? extends T> fldType,
- PacketCodecInternal<?, ENCBUF, DECBUF> codec,
- Deque<FieldCodecFactory<ENCBUF, DECBUF>> chain) {
- FieldCodec<ENCBUF, DECBUF, T> chainNext =
- FieldCodecFactory.buildChainForType(pktType, field, fldType, codec, chain);
- return new SizedByMethodsInjectedFieldCodec<>(pktType, field, sizedField, getter, setter,
- codec, chainNext);
- }
-}
diff --git a/Ghidra/Debug/Framework-AsyncComm/src/main/java/ghidra/comm/packet/annot/impl/SizedByMethodsWrapperFactory.java b/Ghidra/Debug/Framework-AsyncComm/src/main/java/ghidra/comm/packet/annot/impl/SizedByMethodsWrapperFactory.java
deleted file mode 100644
index cbdb868067..0000000000
--- a/Ghidra/Debug/Framework-AsyncComm/src/main/java/ghidra/comm/packet/annot/impl/SizedByMethodsWrapperFactory.java
+++ /dev/null
@@ -1,80 +0,0 @@
-/* ###
- * 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 ghidra.comm.packet.annot.impl;
-
-import static ghidra.comm.packet.fields.AbstractFieldCodec.isIntegralType;
-
-import java.lang.reflect.Field;
-import java.lang.reflect.Method;
-import java.util.Deque;
-
-import ghidra.comm.packet.Packet;
-import ghidra.comm.packet.annot.SizedByMethods;
-import ghidra.comm.packet.codecs.PacketCodecInternal;
-import ghidra.comm.packet.err.*;
-import ghidra.comm.packet.fields.*;
-
-/**
- * The factory implementing {@link SizedByMethods}
- *
- * @param <ENCBUF> the type of temporary buffer used to encode
- * @param <DECBUF> the type of temporary buffer used to decode
- */
-public class SizedByMethodsWrapperFactory<ENCBUF, DECBUF>
- extends AbstractWrapperFactory<ENCBUF, DECBUF> {
- @Override
- public <T> FieldCodec<ENCBUF, DECBUF, T> getWrappedFieldCodecForType(
- Class<? extends Packet> pktType, Field field, Class<? extends T> fldType,
- PacketCodecInternal<?, ENCBUF, DECBUF> codec,
- Deque<FieldCodecFactory<ENCBUF, DECBUF>> chain) {
- SizedByMethods annot = field.getAnnotation(SizedByMethods.class);
- /*
- * if (chain.peek() instanceof WrapperFactory) { throw new
- * PacketAnnotationException(pktType, field, annot,
- * "must be applied directly above the field"); }
- */
-
- final Method getter;
- Method setter = null;
- final Field modified;
- try {
- getter = pktType.getMethod(annot.getter());
- if (!isIntegralType(getter.getReturnType())) {
- throw new InvalidMethodNameException(pktType, field, annot,
- "getter for must return an integral type");
- }
- setter = pktType.getMethod(annot.setter(), getter.getReturnType());
- modified = pktType.getField(annot.modifies());
- }
- catch (NoSuchMethodException e) {
- throw new InvalidMethodNameException(pktType, field, annot, e.getMessage(), e);
- }
- catch (NoSuchFieldException e) {
- throw new InvalidFieldNameException(pktType, field, annot, e.getMessage(), e);
- }
- catch (SecurityException e) {
- throw new PacketAnnotationException(pktType, field, annot, e.getMessage(), e);
- }
-
- SizedByMethodsInjectionFactory<ENCBUF, DECBUF> injected =
- new SizedByMethodsInjectionFactory<>(field, getter, setter);
- codec.injectChain(pktType, modified, injected, field, annot);
-
- FieldCodec<ENCBUF, DECBUF, T> chainNext =
- FieldCodecFactory.buildChainForType(pktType, field, fldType, codec, chain);
- return new SizedByMethodsFieldCodec<>(pktType, field, getter, codec, chainNext);
- }
-}
diff --git a/Ghidra/Debug/Framework-AsyncComm/src/main/java/ghidra/comm/packet/annot/impl/TypedByFieldFieldCodec.java b/Ghidra/Debug/Framework-AsyncComm/src/main/java/ghidra/comm/packet/annot/impl/TypedByFieldFieldCodec.java
deleted file mode 100644
index b01849255a..0000000000
--- a/Ghidra/Debug/Framework-AsyncComm/src/main/java/ghidra/comm/packet/annot/impl/TypedByFieldFieldCodec.java
+++ /dev/null
@@ -1,97 +0,0 @@
-/* ###
- * 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 ghidra.comm.packet.annot.impl;
-
-import java.io.IOException;
-import java.lang.reflect.Field;
-import java.util.Map;
-
-import org.apache.commons.collections4.BidiMap;
-
-import ghidra.comm.packet.Packet;
-import ghidra.comm.packet.PacketFactory;
-import ghidra.comm.packet.annot.TypedByField;
-import ghidra.comm.packet.err.*;
-import ghidra.comm.packet.fields.AbstractFieldCodec;
-import ghidra.comm.packet.fields.FieldCodec;
-
-/**
- * The {@link FieldCodec} for fields annotated by {@link TypedByField}
- *
- * @see TypedByFieldWrapperFactory
- *
- * @param <ENCBUF> the type of temporary buffer used to encode
- * @param <DECBUF> the type of temporary buffer used to decode
- * @param <T> the type of the field as passed through the chain
- */
-class TypedByFieldFieldCodec<ENCBUF, DECBUF, T> extends AbstractFieldCodec<ENCBUF, DECBUF, T> {
- private final Field typingField;
- private final TypedByField annot;
- private final BidiMap<Object, Class<? extends T>> typeMap;
- private final Map<Class<? extends T>, FieldCodec<ENCBUF, DECBUF, ? extends T>> chainMap;
-
- TypedByFieldFieldCodec(Class<? extends Packet> pktType, Field field, Field typingField,
- TypedByField annot, BidiMap<Object, Class<? extends T>> typeMap,
- Map<Class<? extends T>, FieldCodec<ENCBUF, DECBUF, ? extends T>> chainMap) {
- super(pktType, field);
- this.typingField = typingField;
- this.annot = annot;
- this.typeMap = typeMap;
- this.chainMap = chainMap;
- }
-
- @Override
- public T decodeField(Packet pkt, DECBUF buf, Integer count, PacketFactory factory)
- throws IOException, PacketDecodeException {
- try {
- Object key = typingField.get(pkt);
- if (annot.types().length > 0) {
- key = getIntegralValue(key);
- }
- Class<? extends T> type = typeMap.get(key);
- if (type == null) {
- throw new InvalidPacketException("In " + pkt.getClass() + ": Do not know type of " +
- field.getName() + " for key:" + typingField + "=" + key);
- }
- @SuppressWarnings("unchecked")
- FieldCodec<ENCBUF, DECBUF, T> fieldCodec =
- (FieldCodec<ENCBUF, DECBUF, T>) chainMap.get(type);
- return fieldCodec.decodeField(pkt, buf, count, factory);
- }
- catch (IllegalAccessException e) {
- throw new RuntimeException(e);
- }
- }
-
- @SuppressWarnings("unchecked")
- @Override
- public void encodeField(ENCBUF buf, Packet pkt, T val)
- throws IOException, PacketEncodeException {
- FieldCodec<ENCBUF, DECBUF, T> fieldCodec;
- Class<?> cls = val.getClass();
- for (;;) {
- fieldCodec = (FieldCodec<ENCBUF, DECBUF, T>) chainMap.get(cls);
- if (fieldCodec != null) {
- break;
- }
- cls = cls.getSuperclass();
- if (cls == null) {
- throw new AssertionError();
- }
- }
- fieldCodec.encodeField(buf, pkt, val);
- }
-}
diff --git a/Ghidra/Debug/Framework-AsyncComm/src/main/java/ghidra/comm/packet/annot/impl/TypedByFieldInjectedFieldCodec.java b/Ghidra/Debug/Framework-AsyncComm/src/main/java/ghidra/comm/packet/annot/impl/TypedByFieldInjectedFieldCodec.java
deleted file mode 100644
index e2c9cdfa97..0000000000
--- a/Ghidra/Debug/Framework-AsyncComm/src/main/java/ghidra/comm/packet/annot/impl/TypedByFieldInjectedFieldCodec.java
+++ /dev/null
@@ -1,98 +0,0 @@
-/* ###
- * 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 ghidra.comm.packet.annot.impl;
-
-import java.io.IOException;
-import java.lang.reflect.Field;
-
-import org.apache.commons.collections4.BidiMap;
-
-import ghidra.comm.packet.Packet;
-import ghidra.comm.packet.PacketFactory;
-import ghidra.comm.packet.annot.TypedByField;
-import ghidra.comm.packet.err.PacketDecodeException;
-import ghidra.comm.packet.err.PacketEncodeException;
-import ghidra.comm.packet.fields.AbstractFieldCodec;
-import ghidra.comm.packet.fields.FieldCodec;
-
-/**
- * The {@link FieldCodec} for fields referred to by {@link TypedByField}
- *
- * @see TypedByFieldWrapperFactory
- * @see TypedByFieldInjectionFactory
- *
- * @param <ENCBUF> the type of temporary buffer used to encode
- * @param <DECBUF> the type of temporary buffer used to decode
- * @param <T> the type of the field as passed through the chain
- * @param <U> the type of the annotated field as passed through the chain
- */
-class TypedByFieldInjectedFieldCodec<ENCBUF, DECBUF, T, U>
- extends AbstractFieldCodec<ENCBUF, DECBUF, T> {
- private final Class<? extends T> fldType;
- private final Field typedField;
- private final BidiMap<Object, Class<? extends U>> typeMap;
- private final FieldCodec<ENCBUF, DECBUF, T> chainNext;
-
- TypedByFieldInjectedFieldCodec(Class<? extends Packet> pktType, Field typingField,
- Class<? extends T> fldType, Field typedField,
- BidiMap<Object, Class<? extends U>> typeMap, FieldCodec<ENCBUF, DECBUF, T> chainNext) {
- super(pktType, typingField);
- this.fldType = fldType;
- this.typedField = typedField;
- this.typeMap = typeMap;
- this.chainNext = chainNext;
- }
-
- @Override
- public T decodeField(Packet pkt, DECBUF buf, Integer count, PacketFactory factory)
- throws IOException, PacketDecodeException {
- return chainNext.decodeField(pkt, buf, count, factory);
- }
-
- @SuppressWarnings("unchecked")
- @Override
- public void encodeField(ENCBUF buf, Packet pkt, T val)
- throws IOException, PacketEncodeException {
- try {
- Object typedVal = typedField.get(pkt);
- Object key;
- Class<?> cls = typedVal.getClass();
- for (;;) {
- key = typeMap.getKey(cls);
- if (key != null) {
- break;
- }
- // TODO: Cache superclass searches?
- cls = cls.getSuperclass();
- if (cls == null) {
- throw new PacketEncodeException(val + " is not a selectable type for " + field);
- }
- }
- T typeIdx;
- if (key instanceof Long) {
- typeIdx = getIntegralOfType(fldType, (Long) key);
- }
- else {
- typeIdx = (T) key;
- }
- field.set(pkt, typeIdx);
- chainNext.encodeField(buf, pkt, typeIdx);
- }
- catch (IllegalAccessException e) {
- throw new RuntimeException(e);
- }
- }
-}
diff --git a/Ghidra/Debug/Framework-AsyncComm/src/main/java/ghidra/comm/packet/annot/impl/TypedByFieldInjectionFactory.java b/Ghidra/Debug/Framework-AsyncComm/src/main/java/ghidra/comm/packet/annot/impl/TypedByFieldInjectionFactory.java
deleted file mode 100644
index 90a3f99770..0000000000
--- a/Ghidra/Debug/Framework-AsyncComm/src/main/java/ghidra/comm/packet/annot/impl/TypedByFieldInjectionFactory.java
+++ /dev/null
@@ -1,56 +0,0 @@
-/* ###
- * 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 ghidra.comm.packet.annot.impl;
-
-import java.lang.reflect.Field;
-import java.util.Deque;
-
-import org.apache.commons.collections4.BidiMap;
-
-import ghidra.comm.packet.Packet;
-import ghidra.comm.packet.annot.TypedByField;
-import ghidra.comm.packet.codecs.PacketCodecInternal;
-import ghidra.comm.packet.fields.*;
-
-/**
- * The factory injecting {@link TypedByFieldInjectedFieldCodec} on behalf of {@link TypedByField}
- *
- * @param <ENCBUF> the type of temporary buffer used to encode
- * @param <DECBUF> the type of temporary buffer used to decode
- * @param <U> the type of the annotated field as passed through the chain
- */
-public class TypedByFieldInjectionFactory<ENCBUF, DECBUF, U>
- extends AbstractWrapperFactory<ENCBUF, DECBUF> implements InjectionFactory<ENCBUF, DECBUF> {
- private final Field typedField;
- private final BidiMap<Object, Class<? extends U>> typeMap;
-
- public TypedByFieldInjectionFactory(Field typedField,
- BidiMap<Object, Class<? extends U>> typeMap) {
- this.typedField = typedField;
- this.typeMap = typeMap;
- }
-
- @Override
- public <T> FieldCodec<ENCBUF, DECBUF, T> getWrappedFieldCodecForType(
- Class<? extends Packet> pktType, Field field, Class<? extends T> fldType,
- PacketCodecInternal<?, ENCBUF, DECBUF> codec,
- Deque<FieldCodecFactory<ENCBUF, DECBUF>> chain) {
- FieldCodec<ENCBUF, DECBUF, T> chainNext =
- FieldCodecFactory.buildChainForType(pktType, field, fldType, codec, chain);
- return new TypedByFieldInjectedFieldCodec<>(pktType, field, fldType, typedField, typeMap,
- chainNext);
- }
-}
diff --git a/Ghidra/Debug/Framework-AsyncComm/src/main/java/ghidra/comm/packet/annot/impl/TypedByFieldWrapperFactory.java b/Ghidra/Debug/Framework-AsyncComm/src/main/java/ghidra/comm/packet/annot/impl/TypedByFieldWrapperFactory.java
deleted file mode 100644
index 636c38d405..0000000000
--- a/Ghidra/Debug/Framework-AsyncComm/src/main/java/ghidra/comm/packet/annot/impl/TypedByFieldWrapperFactory.java
+++ /dev/null
@@ -1,104 +0,0 @@
-/* ###
- * 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 ghidra.comm.packet.annot.impl;
-
-import static ghidra.comm.packet.fields.AbstractFieldCodec.isIntegralType;
-
-import java.lang.reflect.Field;
-import java.util.*;
-import java.util.Map.Entry;
-
-import org.apache.commons.collections4.BidiMap;
-import org.apache.commons.collections4.bidimap.DualLinkedHashBidiMap;
-
-import ghidra.comm.packet.Packet;
-import ghidra.comm.packet.annot.TypedByField;
-import ghidra.comm.packet.annot.TypedByField.TypeSelect;
-import ghidra.comm.packet.codecs.PacketCodecInternal;
-import ghidra.comm.packet.err.InvalidFieldNameException;
-import ghidra.comm.packet.err.PacketAnnotationException;
-import ghidra.comm.packet.fields.*;
-
-/**
- * The factory implementing {@link TypedByField}
- *
- * @param <ENCBUF> the type of temporary buffer used to encode
- * @param <DECBUF> the type of temporary buffer used to decode
- */
-public class TypedByFieldWrapperFactory<ENCBUF, DECBUF>
- extends AbstractWrapperFactory<ENCBUF, DECBUF> {
- @SuppressWarnings("unchecked")
- @Override
- public <T> FieldCodec<ENCBUF, DECBUF, T> getWrappedFieldCodecForType(
- Class<? extends Packet> pktType, Field field, Class<? extends T> fldType,
- PacketCodecInternal<?, ENCBUF, DECBUF> codec,
- Deque<FieldCodecFactory<ENCBUF, DECBUF>> chain) {
- TypedByField annot = field.getAnnotation(TypedByField.class);
- final Field typingField;
- try {
- typingField = pktType.getField(annot.by());
- }
- catch (NoSuchFieldException | SecurityException e) {
- throw new InvalidFieldNameException(pktType, field, annot, e.getMessage(), e);
- }
- if (annot.types().length > 0 && !isIntegralType(typingField.getType())) {
- throw new InvalidFieldNameException(pktType, typingField, annot,
- "Using types attribute requires field to be an integral type");
- }
-
- BidiMap<Object, Class<? extends T>> typeMap = new DualLinkedHashBidiMap<>();
- if (!"".equals(annot.map())) {
- if (annot.types().length > 0) {
- throw new PacketAnnotationException(pktType, field, annot,
- "Cannot use both types and map attributes");
- }
- try {
- Field mapField = pktType.getField(annot.map());
- Map<?, Class<? extends T>> map = (Map<?, Class<? extends T>>) mapField.get(pktType);
- for (Entry<?, Class<? extends T>> ent : map.entrySet()) {
- typeMap.put(ent.getKey(), ent.getValue());
- }
- }
- catch (NoSuchFieldException | SecurityException | IllegalAccessException
- | ClassCastException e) {
- throw new InvalidFieldNameException(pktType, field, annot, e.getMessage(), e);
- }
- }
- for (TypeSelect select : annot.types()) {
- Class<?> selType = select.type();
- if (!fldType.isAssignableFrom(selType)) {
- throw new PacketAnnotationException(pktType, field, annot,
- "Selectable types must be assignable to the annotated field");
- }
- typeMap.put(select.key(), (Class<? extends T>) selType);
- }
- if (typeMap.size() == 0) {
- throw new PacketAnnotationException(pktType, field, annot,
- "There must be at least one selectable type");
- }
-
- TypedByFieldInjectionFactory<ENCBUF, DECBUF, ? extends T> injected =
- new TypedByFieldInjectionFactory<>(field, typeMap);
- codec.injectChain(pktType, typingField, injected, field, annot);
-
- Map<Class<? extends T>, FieldCodec<ENCBUF, DECBUF, ? extends T>> chainMap = new HashMap<>();
- for (Class<? extends T> selType : typeMap.values()) {
- chainMap.put(selType, FieldCodecFactory.buildChainForType(pktType, field, selType,
- codec, new LinkedList<>(chain)));
- }
- return new TypedByFieldFieldCodec<>(pktType, field, typingField, annot, typeMap, chainMap);
- }
-}
diff --git a/Ghidra/Debug/Framework-AsyncComm/src/main/java/ghidra/comm/packet/annot/impl/TypedByLookaheadFieldCodec.java b/Ghidra/Debug/Framework-AsyncComm/src/main/java/ghidra/comm/packet/annot/impl/TypedByLookaheadFieldCodec.java
deleted file mode 100644
index d3112390a0..0000000000
--- a/Ghidra/Debug/Framework-AsyncComm/src/main/java/ghidra/comm/packet/annot/impl/TypedByLookaheadFieldCodec.java
+++ /dev/null
@@ -1,89 +0,0 @@
-/* ###
- * 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 ghidra.comm.packet.annot.impl;
-
-import java.io.IOException;
-import java.lang.reflect.Field;
-import java.util.List;
-import java.util.Map;
-
-import ghidra.comm.packet.Packet;
-import ghidra.comm.packet.PacketFactory;
-import ghidra.comm.packet.annot.TypedByLookahead;
-import ghidra.comm.packet.codecs.PacketCodecInternal;
-import ghidra.comm.packet.err.*;
-import ghidra.comm.packet.fields.AbstractFieldCodec;
-import ghidra.comm.packet.fields.FieldCodec;
-
-/**
- * The {@link FieldCodec} for fields annotated by {@link TypedByLookahead}
- *
- * @see TypedByLookaheadWrapperFactory
- *
- * @param <ENCBUF> the type of temporary buffer used to encode
- * @param <DECBUF> the type of temporary buffer used to decode
- * @param <T> the type of the field as passed through the chain
- */
-class TypedByLookaheadFieldCodec<ENCBUF, DECBUF, T> extends AbstractFieldCodec<ENCBUF, DECBUF, T> {
- private final PacketCodecInternal<?, ENCBUF, DECBUF> codec;
- private final Map<Class<? extends T>, FieldCodec<ENCBUF, DECBUF, ? extends T>> chainMap;
- private final List<Class<? extends T>> types;
-
- TypedByLookaheadFieldCodec(Class<? extends Packet> pktType, Field field,
- List<Class<? extends T>> types, PacketCodecInternal<?, ENCBUF, DECBUF> codec,
- Map<Class<? extends T>, FieldCodec<ENCBUF, DECBUF, ? extends T>> chainMap) {
- super(pktType, field);
- this.types = types;
- this.codec = codec;
- this.chainMap = chainMap;
- }
-
- @Override
- public T decodeField(Packet pkt, DECBUF buf, Integer count, PacketFactory factory)
- throws IOException, PacketDecodeException {
- int mark = codec.getDecodePosition(buf);
- for (Map.Entry<Class<? extends T>, FieldCodec<ENCBUF, DECBUF, ? extends T>> ent : chainMap
- .entrySet()) {
- try {
- @SuppressWarnings("unchecked")
- FieldCodec<ENCBUF, DECBUF, T> fieldCodec =
- (FieldCodec<ENCBUF, DECBUF, T>) ent.getValue();
- return fieldCodec.decodeField(pkt, buf, count, factory);
- }
- catch (PacketFieldValueMismatchException | InvalidPacketException e) {
- /*
- * Msg.debug(this, "Lookahead for " + ent.getKey() + " backtracked: " +
- * e.getMessage(), e);
- */
- codec.setDecodePosition(buf, mark);
- // Try the next
- }
- }
- throw new InvalidPacketException("No selectable lookahead type succeeded for " + field);
- }
-
- @Override
- public void encodeField(ENCBUF buf, Packet pkt, T val)
- throws IOException, PacketEncodeException {
- if (!types.contains(val.getClass())) {
- throw new PacketEncodeException(val + " is not a selectable type for " + field);
- }
- @SuppressWarnings("unchecked")
- FieldCodec<ENCBUF, DECBUF, T> fieldCodec =
- (FieldCodec<ENCBUF, DECBUF, T>) chainMap.get(val.getClass());
- fieldCodec.encodeField(buf, pkt, val);
- }
-}
diff --git a/Ghidra/Debug/Framework-AsyncComm/src/main/java/ghidra/comm/packet/annot/impl/TypedByLookaheadWrapperFactory.java b/Ghidra/Debug/Framework-AsyncComm/src/main/java/ghidra/comm/packet/annot/impl/TypedByLookaheadWrapperFactory.java
deleted file mode 100644
index 440b7865f0..0000000000
--- a/Ghidra/Debug/Framework-AsyncComm/src/main/java/ghidra/comm/packet/annot/impl/TypedByLookaheadWrapperFactory.java
+++ /dev/null
@@ -1,79 +0,0 @@
-/* ###
- * 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 ghidra.comm.packet.annot.impl;
-
-import java.lang.reflect.Field;
-import java.util.*;
-
-import ghidra.comm.packet.Packet;
-import ghidra.comm.packet.annot.TypedByLookahead;
-import ghidra.comm.packet.codecs.PacketCodecInternal;
-import ghidra.comm.packet.err.PacketAnnotationException;
-import ghidra.comm.packet.fields.*;
-
-/**
- * The factory implementing {@link TypedByLookahead}
- *
- * @param <ENCBUF> the type of temporary buffer used to encode
- * @param <DECBUF> the type of temporary buffer used to decode
- */
-public class TypedByLookaheadWrapperFactory<ENCBUF, DECBUF>
- extends AbstractWrapperFactory<ENCBUF, DECBUF> {
- @SuppressWarnings("unchecked")
- @Override
- public <T> FieldCodec<ENCBUF, DECBUF, T> getWrappedFieldCodecForType(
- Class<? extends Packet> pktType, Field field, Class<? extends T> fldType,
- PacketCodecInternal<?, ENCBUF, DECBUF> codec,
- Deque<FieldCodecFactory<ENCBUF, DECBUF>> chain) {
- TypedByLookahead annot = field.getAnnotation(TypedByLookahead.class);
- if (annot.value().length == 0) {
- throw new PacketAnnotationException(pktType, field, annot,
- "Selectable type map cannot be empty");
- }
- List<Class<? extends T>> types = new ArrayList<>();
- for (Class<?> selType : annot.value()) {
- if (!fldType.isAssignableFrom(selType)) {
- throw new PacketAnnotationException(pktType, field, annot, "Selectable type " +
- selType + " must be assignable to the annotated field type " + fldType);
- }
- types.add((Class<? extends T>) selType);
- }
- final Map<Class<? extends T>, FieldCodec<ENCBUF, DECBUF, ? extends T>> chainMap =
- new LinkedHashMap<>();
- for (Class<? extends T> selType : types) {
- chainMap.put(selType, FieldCodecFactory.buildChainForType(pktType, field, selType,
- codec, new LinkedList<>(chain)));
- }
- return new TypedByLookaheadFieldCodec<>(pktType, field, types, codec, chainMap);
- }
-
- @SuppressWarnings("unchecked")
- public static <P extends Packet> List<Class<? extends P>> getSelectableOfType(Field field,
- Class<P> type) {
- List<Class<? extends P>> result = new ArrayList<>();
- TypedByLookahead annot = field.getAnnotation(TypedByLookahead.class);
- if (annot == null) {
- throw new IllegalArgumentException(
- field + " is not annotated by @" + TypedByLookahead.class.getSimpleName());
- }
- for (Class<? extends Packet> sel : annot.value()) {
- if (type.isAssignableFrom(sel)) {
- result.add((Class<? extends P>) sel);
- }
- }
- return Collections.unmodifiableList(result);
- }
-}
diff --git a/Ghidra/Debug/Framework-AsyncComm/src/main/java/ghidra/comm/packet/annot/impl/WithFlagFieldCodec.java b/Ghidra/Debug/Framework-AsyncComm/src/main/java/ghidra/comm/packet/annot/impl/WithFlagFieldCodec.java
deleted file mode 100644
index 1153553401..0000000000
--- a/Ghidra/Debug/Framework-AsyncComm/src/main/java/ghidra/comm/packet/annot/impl/WithFlagFieldCodec.java
+++ /dev/null
@@ -1,81 +0,0 @@
-/* ###
- * 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 ghidra.comm.packet.annot.impl;
-
-import java.io.IOException;
-import java.lang.reflect.Field;
-
-import ghidra.comm.packet.Packet;
-import ghidra.comm.packet.PacketFactory;
-import ghidra.comm.packet.annot.WithFlag;
-import ghidra.comm.packet.annot.WithFlag.Mode;
-import ghidra.comm.packet.err.PacketDecodeException;
-import ghidra.comm.packet.err.PacketEncodeException;
-import ghidra.comm.packet.fields.AbstractFieldCodec;
-import ghidra.comm.packet.fields.FieldCodec;
-import ghidra.comm.util.BitmaskSet;
-
-/**
- * The {@link FieldCodec} for fields annotated by {@link WithFlag}
- *
- * @see WithFlagWrapperFactory
- *
- * @param <ENCBUF> the type of temporary buffer used to encode
- * @param <DECBUF> the type of temporary buffer used to decode
- * @param <T> the type of the field as passed through the chain
- */
-public class WithFlagFieldCodec<ENCBUF, DECBUF, T> extends AbstractFieldCodec<ENCBUF, DECBUF, T> {
-
- private final Field flagField;
- @SuppressWarnings("rawtypes")
- private final Enum flag;
- private final Mode mode;
- private final FieldCodec<ENCBUF, DECBUF, T> chainNext;
-
- public WithFlagFieldCodec(Class<? extends Packet> pktType, Field field, Field flagField,
- @SuppressWarnings("rawtypes") Enum flag, WithFlag.Mode mode,
- FieldCodec<ENCBUF, DECBUF, T> chainNext) {
- super(pktType, field);
- this.flagField = flagField;
- this.flag = flag;
- this.mode = mode;
- this.chainNext = chainNext;
- }
-
- @Override
- public T decodeField(Packet pkt, DECBUF buf, Integer count, PacketFactory factory)
- throws IOException, PacketDecodeException {
- try {
- @SuppressWarnings("rawtypes")
- BitmaskSet bm = (BitmaskSet) flagField.get(pkt);
- if (bm.contains(flag) ^ mode != WithFlag.Mode.PRESENT) {
- return chainNext.decodeField(pkt, buf, count, factory);
- }
- return null;
- }
- catch (IllegalArgumentException | IllegalAccessException e) {
- throw new AssertionError("INTERNAL:", e);
- }
- }
-
- @Override
- public void encodeField(ENCBUF buf, Packet pkt, T val)
- throws IOException, PacketEncodeException {
- if (val != null) {
- chainNext.encodeField(buf, pkt, val);
- }
- }
-}
diff --git a/Ghidra/Debug/Framework-AsyncComm/src/main/java/ghidra/comm/packet/annot/impl/WithFlagInjectedFieldCodec.java b/Ghidra/Debug/Framework-AsyncComm/src/main/java/ghidra/comm/packet/annot/impl/WithFlagInjectedFieldCodec.java
deleted file mode 100644
index 401180cee1..0000000000
--- a/Ghidra/Debug/Framework-AsyncComm/src/main/java/ghidra/comm/packet/annot/impl/WithFlagInjectedFieldCodec.java
+++ /dev/null
@@ -1,89 +0,0 @@
-/* ###
- * 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 ghidra.comm.packet.annot.impl;
-
-import java.io.IOException;
-import java.lang.reflect.Field;
-
-import ghidra.comm.packet.Packet;
-import ghidra.comm.packet.PacketFactory;
-import ghidra.comm.packet.annot.SizedByField;
-import ghidra.comm.packet.annot.WithFlag;
-import ghidra.comm.packet.err.PacketDecodeException;
-import ghidra.comm.packet.err.PacketEncodeException;
-import ghidra.comm.packet.fields.AbstractFieldCodec;
-import ghidra.comm.packet.fields.FieldCodec;
-import ghidra.comm.util.BitmaskSet;
-
-/**
- * The {@link FieldCodec} for fields referred to by {@link SizedByField}
- *
- * @see WithFlagWrapperFactory
- * @see WithFlagInjectionFactory
- *
- * @param <ENCBUF> the type of temporary buffer used to encode
- * @param <DECBUF> the type of temporary buffer used to decode
- * @param <T> the type of the field as passed through the chain. Must be a {@link BitmaskSet}
- */
-public class WithFlagInjectedFieldCodec<ENCBUF, DECBUF, T>
- extends AbstractFieldCodec<ENCBUF, DECBUF, T> {
-
- private final Field controlledField;
- @SuppressWarnings("rawtypes")
- private final Enum flag;
- private final FieldCodec<ENCBUF, DECBUF, T> chainNext;
- private WithFlag.Mode mode;
-
- public WithFlagInjectedFieldCodec(Class<? extends Packet> pktType, Field field,
- Field controlledField, @SuppressWarnings("rawtypes") Enum flag, WithFlag.Mode mode,
- FieldCodec<ENCBUF, DECBUF, T> chainNext) {
- super(pktType, field);
- this.controlledField = controlledField;
- this.flag = flag;
- this.mode = mode;
- this.chainNext = chainNext;
- }
-
- @Override
- public T decodeField(Packet pkt, DECBUF buf, Integer count, PacketFactory factory)
- throws IOException, PacketDecodeException {
- return chainNext.decodeField(pkt, buf, count, factory);
- }
-
- @SuppressWarnings({ "rawtypes", "unchecked" })
- @Override
- public void encodeField(ENCBUF buf, Packet pkt, T val)
- throws IOException, PacketEncodeException {
- try {
- Object controlledValue = controlledField.get(pkt);
- BitmaskSet bs = (BitmaskSet) field.get(pkt); // val will not be updated if null
- if (bs == null) {
- bs = new BitmaskSet(flag.getClass());
- field.set(pkt, bs);
- }
- if ((controlledValue != null) ^ (mode != WithFlag.Mode.PRESENT)) {
- bs.add(flag);
- }
- else {
- bs.remove(flag);
- }
- chainNext.encodeField(buf, pkt, (T) bs);
- }
- catch (IllegalArgumentException | IllegalAccessException e) {
- throw new AssertionError("INTERNAL:", e);
- }
- }
-}
diff --git a/Ghidra/Debug/Framework-AsyncComm/src/main/java/ghidra/comm/packet/annot/impl/WithFlagInjectionFactory.java b/Ghidra/Debug/Framework-AsyncComm/src/main/java/ghidra/comm/packet/annot/impl/WithFlagInjectionFactory.java
deleted file mode 100644
index bdac99533d..0000000000
--- a/Ghidra/Debug/Framework-AsyncComm/src/main/java/ghidra/comm/packet/annot/impl/WithFlagInjectionFactory.java
+++ /dev/null
@@ -1,57 +0,0 @@
-/* ###
- * 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 ghidra.comm.packet.annot.impl;
-
-import java.lang.reflect.Field;
-import java.util.Deque;
-
-import ghidra.comm.packet.Packet;
-import ghidra.comm.packet.annot.WithFlag;
-import ghidra.comm.packet.codecs.PacketCodecInternal;
-import ghidra.comm.packet.fields.*;
-
-/**
- * The factory injecting {@link WithFlagInjectedFieldCodec} on behalf of {@link WithFlag}
- *
- * @param <ENCBUF> the type of temporary buffer used to encode
- * @param <DECBUF> the type of temporary buffer used to decode
- */
-public class WithFlagInjectionFactory<ENCBUF, DECBUF> extends AbstractWrapperFactory<ENCBUF, DECBUF>
- implements InjectionFactory<ENCBUF, DECBUF> {
-
- private final Field controlledField;
- @SuppressWarnings("rawtypes")
- private final Enum flag;
- private final WithFlag.Mode mode;
-
- public WithFlagInjectionFactory(Field controlledField, @SuppressWarnings("rawtypes") Enum flag,
- WithFlag.Mode mode) {
- this.controlledField = controlledField;
- this.flag = flag;
- this.mode = mode;
- }
-
- @Override
- public <T> FieldCodec<ENCBUF, DECBUF, T> getWrappedFieldCodecForType(
- Class<? extends Packet> pktType, Field field, Class<? extends T> fldType,
- PacketCodecInternal<?, ENCBUF, DECBUF> codec,
- Deque<FieldCodecFactory<ENCBUF, DECBUF>> chain) {
- FieldCodec<ENCBUF, DECBUF, T> chainNext =
- FieldCodecFactory.buildChainForType(pktType, field, fldType, codec, chain);
- return new WithFlagInjectedFieldCodec<>(pktType, field, controlledField, flag, mode,
- chainNext);
- }
-}
diff --git a/Ghidra/Debug/Framework-AsyncComm/src/main/java/ghidra/comm/packet/annot/impl/WithFlagWrapperFactory.java b/Ghidra/Debug/Framework-AsyncComm/src/main/java/ghidra/comm/packet/annot/impl/WithFlagWrapperFactory.java
deleted file mode 100644
index ebd044a1ea..0000000000
--- a/Ghidra/Debug/Framework-AsyncComm/src/main/java/ghidra/comm/packet/annot/impl/WithFlagWrapperFactory.java
+++ /dev/null
@@ -1,79 +0,0 @@
-/* ###
- * 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 ghidra.comm.packet.annot.impl;
-
-import java.lang.reflect.Field;
-import java.util.Deque;
-
-import ghidra.comm.packet.Packet;
-import ghidra.comm.packet.annot.WithFlag;
-import ghidra.comm.packet.codecs.PacketCodecInternal;
-import ghidra.comm.packet.err.InvalidFieldNameException;
-import ghidra.comm.packet.err.PacketAnnotationException;
-import ghidra.comm.packet.fields.*;
-import ghidra.comm.util.BitmaskSet;
-
-/**
- * The factory implementing {@link WithFlag}
- *
- * @param <ENCBUF> the type of temporary buffer used to encode
- * @param <DECBUF> the type of temporary buffer used to decode
- */
-public class WithFlagWrapperFactory<ENCBUF, DECBUF> extends AbstractWrapperFactory<ENCBUF, DECBUF> {
-
- @Override
- public <T> FieldCodec<ENCBUF, DECBUF, T> getWrappedFieldCodecForType(
- Class<? extends Packet> pktType, Field field, Class<? extends T> fldType,
- PacketCodecInternal<?, ENCBUF, DECBUF> codec,
- Deque<FieldCodecFactory<ENCBUF, DECBUF>> chain) {
- WithFlag annot = field.getAnnotation(WithFlag.class);
-
- final Field flagField;
- try {
- flagField = pktType.getField(annot.by());
- }
- catch (NoSuchFieldException | SecurityException e) {
- throw new InvalidFieldNameException(pktType, field, annot, e.getMessage(), e);
- }
- if (!BitmaskSet.class.isAssignableFrom(flagField.getType())) {
- throw new InvalidFieldNameException(pktType, flagField, annot,
- "Field is not a " + BitmaskSet.class.getSimpleName());
- }
-
- @SuppressWarnings({ "unchecked", "rawtypes" })
- Class<? extends Enum> universe =
- BitmaskEncodedFieldCodecWrapperFactory.getUniverse(pktType, flagField);
- @SuppressWarnings("rawtypes")
- Enum flag = null;
- for (@SuppressWarnings("rawtypes")
- Enum e : universe.getEnumConstants()) {
- if (annot.flag().equals(e.name())) {
- flag = e;
- }
- }
- if (flag == null) {
- throw new PacketAnnotationException(pktType, field, annot,
- "Could not find constant " + annot.flag() + " in " + universe);
- }
- WithFlagInjectionFactory<ENCBUF, DECBUF> injected =
- new WithFlagInjectionFactory<>(field, flag, annot.mode());
- codec.injectChain(pktType, flagField, injected, field, annot);
-
- FieldCodec<ENCBUF, DECBUF, T> chainNext =
- FieldCodecFactory.buildChainForType(pktType, field, fldType, codec, chain);
- return new WithFlagFieldCodec<>(pktType, field, flagField, flag, annot.mode(), chainNext);
- }
-}
diff --git a/Ghidra/Debug/Framework-AsyncComm/src/main/java/ghidra/comm/packet/binary/AbstractBinaryPacketCodec.java b/Ghidra/Debug/Framework-AsyncComm/src/main/java/ghidra/comm/packet/binary/AbstractBinaryPacketCodec.java
deleted file mode 100644
index 6101d36ae5..0000000000
--- a/Ghidra/Debug/Framework-AsyncComm/src/main/java/ghidra/comm/packet/binary/AbstractBinaryPacketCodec.java
+++ /dev/null
@@ -1,91 +0,0 @@
-/* ###
- * 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 ghidra.comm.packet.binary;
-
-import java.io.IOException;
-import java.nio.*;
-import java.util.Arrays;
-
-import ghidra.comm.packet.Packet;
-import ghidra.comm.packet.err.PacketEncodeException;
-import ghidra.comm.util.ByteBufferUtils;
-
-/**
- * A codec for encoding packets as binary data into byte arrays
- */
-public abstract class AbstractBinaryPacketCodec extends AbstractByteBufferPacketCodec<byte[]> {
- protected AbstractBinaryPacketCodec() {
- }
-
- /**
- * The default byte order
- *
- * @return the byte order
- */
- protected abstract ByteOrder getDefaultByteOrder();
-
- @Override
- public void encodePacket(byte[] buf, Packet pkt) throws PacketEncodeException {
- encodePacketInto(ByteBuffer.wrap(buf), pkt);
- }
-
- @Override
- public ByteBuffer newDecodeBuffer(byte[] data) throws IOException {
- return ByteBuffer.wrap(data);
- }
-
- @Override
- public ByteBuffer newEncodeBuffer() throws IOException {
- ByteBuffer buf = ByteBuffer.allocate(1024);
- buf.order(getDefaultByteOrder());
- return buf;
- }
-
- @Override
- protected byte[] finishEncode(ByteBuffer buf) {
- return Arrays.copyOf(buf.array(), buf.position());
- }
-
- @Override
- public byte[] encodePacket(Packet pkt) throws PacketEncodeException {
- ByteBuffer buf;
- try {
- buf = newEncodeBuffer();
- }
- catch (IOException e) {
- throw new AssertionError("Internal error", e);
- }
- while (true) {
- try {
- encodePacketInto(buf, pkt);
- return finishEncode(buf);
- }
- catch (PacketEncodeException e) {
- throw e;
- }
- catch (BufferOverflowException e) {
- buf.clear();
- buf = ByteBufferUtils.upsize(buf);
- }
- catch (RuntimeException e) {
- throw e;
- }
- catch (Exception e) {
- throw new AssertionError("Internal error", e);
- }
- }
- }
-}
diff --git a/Ghidra/Debug/Framework-AsyncComm/src/main/java/ghidra/comm/packet/binary/AbstractByteBufferPacketCodec.java b/Ghidra/Debug/Framework-AsyncComm/src/main/java/ghidra/comm/packet/binary/AbstractByteBufferPacketCodec.java
deleted file mode 100644
index 5cb6b6682d..0000000000
--- a/Ghidra/Debug/Framework-AsyncComm/src/main/java/ghidra/comm/packet/binary/AbstractByteBufferPacketCodec.java
+++ /dev/null
@@ -1,317 +0,0 @@
-/* ###
- * 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 ghidra.comm.packet.binary;
-
-import java.io.IOException;
-import java.lang.annotation.Annotation;
-import java.lang.reflect.Field;
-import java.nio.*;
-import java.nio.charset.*;
-
-import ghidra.comm.packet.AbstractPacketCodec;
-import ghidra.comm.packet.Packet;
-import ghidra.comm.packet.err.*;
-import ghidra.comm.packet.fields.FieldCodec;
-import ghidra.comm.packet.fields.WrapperFactory;
-
-/**
- * A codec for encoding packets as binary
- *
- * These codecs encode integers in two's complement, floating-point numbers in IEEE 754, characters
- * in UTF-16, strings in UTF-8, enums as ordinals, and byte buffers as is. They employ
- * {@link ByteBuffer} for encoding and decoding.
- *
- * @param <T> the type of encoded packets
- */
-public abstract class AbstractByteBufferPacketCodec<T>
- extends AbstractPacketCodec<T, ByteBuffer, ByteBuffer> {
-
- /**
- * Decode a byte array
- *
- * @param field the field for which the value is decoded
- * @param buf the buffer from which the value is decoded
- * @param count the number of byte to decode, or null for unlimited
- * @return the decoded value
- */
- protected byte[] decodeByteArray(Field field, ByteBuffer buf, Integer count) {
- byte[] result = new byte[count == null ? buf.remaining() : count];
- buf.get(result);
- return result;
- }
-
- /**
- * Encode a byte array
- *
- * @param buf the buffer into which to append the encoded data
- * @param field the field for which the value is encoded
- * @param val the value to encode
- */
- protected void encodeByteArray(ByteBuffer buf, Field field, byte[] val) {
- buf.put(val);
- }
-
- /**
- * Decode a character sequence using the given character set
- *
- * @param field the field for which the value is decoded
- * @param buf the buffer from which the value is decoded
- * @param count the number of characters to decode, or null for unlimited
- * @param charset the character set to use to decode bytes to characters
- * @return the decoded value
- * @throws IOException if there is an issue accessing a device or buffer
- */
- public CharSequence decodeCharSequence(Field field, ByteBuffer buf, Integer count,
- Charset charset) throws IOException {
- CharsetDecoder cd = charset.newDecoder();
- if (count == null) {
- return cd.decode(buf).toString();
- }
- CharBuffer out = CharBuffer.allocate(count.intValue());
- cd.decode(buf, out, true);
- out.flip();
- return out.toString();
- }
-
- /**
- * Encode a character sequence using the given character set
- *
- * @param buf the buffer into which to append the encoded data
- * @param field the field for which the value is encoded
- * @param val the value to encode
- * @param charset the character set to use to encode characters to bytes
- */
- public void encodeCharSequence(ByteBuffer buf, Field field, CharSequence val, Charset charset) {
- CharsetEncoder ce = charset.newEncoder();
- if (ce.encode(CharBuffer.wrap(val), buf, true) == CoderResult.OVERFLOW) {
- throw new BufferOverflowException();
- }
- }
-
- @Override
- public void appendEncoded(ByteBuffer into, ByteBuffer from) throws IOException {
- into.put(from);
- }
-
- @Override
- public boolean decodeBoolean(Field field, ByteBuffer buf)
- throws IOException, PacketDecodeException {
- return buf.get() != 0;
- }
-
- @Override
- public byte decodeByte(Field field, ByteBuffer buf) throws IOException, PacketDecodeException {
- return buf.get();
- }
-
- @Override
- public char decodeChar(Field field, ByteBuffer buf) throws IOException, PacketDecodeException {
- return buf.getChar();
- }
-
- @Override
- public short decodeShort(Field field, ByteBuffer buf)
- throws IOException, PacketDecodeException {
- return buf.getShort();
- }
-
- @Override
- public int decodeInt(Field field, ByteBuffer buf) throws IOException, PacketDecodeException {
- return buf.getInt();
- }
-
- @Override
- public long decodeLong(Field field, ByteBuffer buf) throws IOException, PacketDecodeException {
- return buf.getLong();
- }
-
- @Override
- public float decodeFloat(Field field, ByteBuffer buf)
- throws IOException, PacketDecodeException {
- return buf.getFloat();
- }
-
- @Override
- public double decodeDouble(Field field, ByteBuffer buf)
- throws IOException, PacketDecodeException {
- return buf.getDouble();
- }
-
- @Override
- public CharSequence decodeCharSequence(Field field, ByteBuffer buf, Integer count)
- throws IOException, PacketDecodeException {
- return decodeCharSequence(field, buf, count, Charset.defaultCharset());
- }
-
- @Override
- public <E extends Enum<E>> E decodeEnumConstant(Field field, ByteBuffer buf, Class<E> type)
- throws IOException, PacketDecodeException {
- E[] consts = type.getEnumConstants();
- int idx;
- if (consts.length <= 0x100) {
- idx = decodeByte(field, buf);
- if (idx < 0) {
- idx += 0x100;
- }
- }
- else if (consts.length <= 0x10000) {
- idx = decodeShort(field, buf);
- idx = decodeByte(field, buf);
- if (idx < 0) {
- idx += 0x10000;
- }
- }
- else {
- idx = decodeInt(field, buf);
- }
- if (idx >= 0 && idx < consts.length) {
- return consts[idx];
- }
- throw new PacketFieldValueMismatchException(field, "0 <= n < " + consts.length, idx);
- }
-
- @Override
- public void encodeBoolean(ByteBuffer buf, Field field, boolean val) {
- buf.put(val ? (byte) 1 : 0);
- }
-
- @Override
- public void encodeByte(ByteBuffer buf, Field field, byte val)
- throws IOException, PacketEncodeException {
- buf.put(val);
- }
-
- @Override
- public void encodeChar(ByteBuffer buf, Field field, char val)
- throws IOException, PacketEncodeException {
- buf.putChar(val);
- }
-
- @Override
- public void encodeShort(ByteBuffer buf, Field field, short val)
- throws IOException, PacketEncodeException {
- buf.putShort(val);
- }
-
- @Override
- public void encodeInt(ByteBuffer buf, Field field, int val)
- throws IOException, PacketEncodeException {
- buf.putInt(val);
- }
-
- @Override
- public void encodeLong(ByteBuffer buf, Field field, long val)
- throws IOException, PacketEncodeException {
- buf.putLong(val);
- }
-
- @Override
- public void encodeFloat(ByteBuffer buf, Field field, float val)
- throws IOException, PacketEncodeException {
- buf.putFloat(val);
- }
-
- @Override
- public void encodeDouble(ByteBuffer buf, Field field, double val)
- throws IOException, PacketEncodeException {
- buf.putDouble(val);
- }
-
- @Override
- public void encodeCharSequence(ByteBuffer buf, Field field, CharSequence val)
- throws IOException, PacketEncodeException {
- encodeCharSequence(buf, field, val, Charset.defaultCharset());
- }
-
- @Override
- public void encodeEnumConstant(ByteBuffer buf, Field field, Enum<?> val)
- throws IOException, PacketEncodeException {
- int max = val.getClass().getEnumConstants().length;
- if (max <= 0x100) {
- encodeByte(buf, field, (byte) val.ordinal());
- }
- else if (max <= 0x100000) {
- encodeShort(buf, field, (short) val.ordinal());
- }
- else {
- encodeInt(buf, field, val.ordinal());
- }
- }
-
- @Override
- public WrapperFactory<ByteBuffer, ByteBuffer> getFactoryForAnnotation(
- Class<? extends Packet> pkt, Field field, Annotation annot) {
- if (annot.annotationType() == SequenceTerminated.class) {
- return new SequenceTerminatedWrapperFactory();
- }
- else if (annot.annotationType() == NullTerminated.class) {
- return new NullTerminatedWrapperFactory();
- }
- else if (annot.annotationType() == ReverseByteOrder.class) {
- return new ReverseByteOrderWrapperFactory();
- }
- return super.getFactoryForAnnotation(pkt, field, annot);
- }
-
- @SuppressWarnings({ "unchecked", "rawtypes" })
- @Override
- public <U> FieldCodec<ByteBuffer, ByteBuffer, U> getFieldCodecForType(
- Class<? extends Packet> pktType, Field field, Class<? extends U> fldType) {
- if (fldType == byte[].class) {
- return (FieldCodec<ByteBuffer, ByteBuffer, U>) new ByteArrayFieldCodec(this, pktType,
- field);
- }
- else if (fldType.isEnum()) {
- return new ByteBufferEnumFieldCodec(pktType, field, fldType, this);
- }
- return super.getFieldCodecForType(pktType, field, fldType);
- }
-
- @Override
- public int getDecodePosition(ByteBuffer buf) {
- return buf.position();
- }
-
- @Override
- public int limitDecodeBuffer(ByteBuffer buf, int len) {
- if (len > buf.capacity()) {
- throw new BufferUnderflowException();
- }
- int cur = buf.limit();
- buf.limit(len);
- return cur;
- }
-
- @Override
- public int measureDecodeRemaining(ByteBuffer buf) {
- return buf.remaining();
- }
-
- @Override
- public int measureEncodeSize(ByteBuffer buf) {
- return buf.position();
- }
-
- @Override
- public void setDecodePosition(ByteBuffer buf, int position) {
- buf.position(position);
- }
-
- @Override
- public void setEncodePosition(ByteBuffer buf, int pos) {
- buf.position(pos);
- }
-}
diff --git a/Ghidra/Debug/Framework-AsyncComm/src/main/java/ghidra/comm/packet/binary/BinaryLEPacketCodec.java b/Ghidra/Debug/Framework-AsyncComm/src/main/java/ghidra/comm/packet/binary/BinaryLEPacketCodec.java
deleted file mode 100644
index 0dee473d57..0000000000
--- a/Ghidra/Debug/Framework-AsyncComm/src/main/java/ghidra/comm/packet/binary/BinaryLEPacketCodec.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/* ###
- * 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 ghidra.comm.packet.binary;
-
-import java.nio.ByteOrder;
-
-/**
- * A codec for encoding packets as binary data into byte arrays in little-endian order
- */
-public class BinaryLEPacketCodec extends AbstractBinaryPacketCodec {
-
- public static final BinaryLEPacketCodec INSTANCE = new BinaryLEPacketCodec();
-
- /**
- * Get the singleton instance of this codec
- *
- * @return the instance
- */
- public static BinaryLEPacketCodec getInstance() {
- return INSTANCE;
- }
-
- protected BinaryLEPacketCodec() {
- }
-
- @Override
- protected ByteOrder getDefaultByteOrder() {
- return ByteOrder.LITTLE_ENDIAN;
- }
-}
diff --git a/Ghidra/Debug/Framework-AsyncComm/src/main/java/ghidra/comm/packet/binary/BinaryPacketCodec.java b/Ghidra/Debug/Framework-AsyncComm/src/main/java/ghidra/comm/packet/binary/BinaryPacketCodec.java
deleted file mode 100644
index cda420228f..0000000000
--- a/Ghidra/Debug/Framework-AsyncComm/src/main/java/ghidra/comm/packet/binary/BinaryPacketCodec.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/* ###
- * 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 ghidra.comm.packet.binary;
-
-import java.nio.ByteOrder;
-
-/**
- * A codec for encoding packets as binary data into byte arrays in big-endian order
- */
-public class BinaryPacketCodec extends AbstractBinaryPacketCodec {
-
- public static final BinaryPacketCodec INSTANCE = new BinaryPacketCodec();
-
- /**
- * Get the singleton instance of this codec
- *
- * @return the instance
- */
- public static BinaryPacketCodec getInstance() {
- return INSTANCE;
- }
-
- protected BinaryPacketCodec() {
- }
-
- @Override
- protected ByteOrder getDefaultByteOrder() {
- return ByteOrder.BIG_ENDIAN;
- }
-}
diff --git a/Ghidra/Debug/Framework-AsyncComm/src/main/java/ghidra/comm/packet/binary/ByteArrayFieldCodec.java b/Ghidra/Debug/Framework-AsyncComm/src/main/java/ghidra/comm/packet/binary/ByteArrayFieldCodec.java
deleted file mode 100644
index 182db0626a..0000000000
--- a/Ghidra/Debug/Framework-AsyncComm/src/main/java/ghidra/comm/packet/binary/ByteArrayFieldCodec.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/* ###
- * 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 ghidra.comm.packet.binary;
-
-import java.io.IOException;
-import java.lang.reflect.Field;
-import java.nio.ByteBuffer;
-
-import ghidra.comm.packet.Packet;
-import ghidra.comm.packet.PacketFactory;
-import ghidra.comm.packet.err.PacketDecodeException;
-import ghidra.comm.packet.err.PacketEncodeException;
-import ghidra.comm.packet.fields.AbstractFieldCodec;
-import ghidra.comm.packet.fields.FieldCodec;
-
-/**
- * The {@link FieldCodec} for encoding byte arrays for {@link AbstractByteBufferPacketCodec}
- *
- * This simply appends the array contents to the buffer for encoding, or consumes the remaining
- * contents of the buffer for decoding.
- */
-class ByteArrayFieldCodec extends AbstractFieldCodec<ByteBuffer, ByteBuffer, byte[]> {
- private final AbstractByteBufferPacketCodec<?> codec;
-
- ByteArrayFieldCodec(AbstractByteBufferPacketCodec<?> codec, Class<? extends Packet> pktType,
- Field field) {
- super(pktType, field);
- this.codec = codec;
- }
-
- @Override
- public byte[] decodeField(Packet pkt, ByteBuffer buf, Integer count, PacketFactory factory)
- throws IOException, PacketDecodeException {
- return codec.decodeByteArray(field, buf, count);
- }
-
- @Override
- public void encodeField(ByteBuffer buf, Packet pkt, byte[] val)
- throws IOException, PacketEncodeException {
- codec.encodeByteArray(buf, field, val);
- }
-}
diff --git a/Ghidra/Debug/Framework-AsyncComm/src/main/java/ghidra/comm/packet/binary/ByteBufferEnumFieldCodec.java b/Ghidra/Debug/Framework-AsyncComm/src/main/java/ghidra/comm/packet/binary/ByteBufferEnumFieldCodec.java
deleted file mode 100644
index 6cf6486696..0000000000
--- a/Ghidra/Debug/Framework-AsyncComm/src/main/java/ghidra/comm/packet/binary/ByteBufferEnumFieldCodec.java
+++ /dev/null
@@ -1,61 +0,0 @@
-/* ###
- * 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 ghidra.comm.packet.binary;
-
-import java.io.IOException;
-import java.lang.reflect.Field;
-import java.nio.ByteBuffer;
-
-import ghidra.comm.packet.Packet;
-import ghidra.comm.packet.PacketFactory;
-import ghidra.comm.packet.codecs.PrimitiveCodec;
-import ghidra.comm.packet.err.PacketDecodeException;
-import ghidra.comm.packet.err.PacketEncodeException;
-import ghidra.comm.packet.fields.AbstractFieldCodec;
-import ghidra.comm.packet.fields.FieldCodec;
-
-/**
- * The {@link FieldCodec} for encoding enumeration values for {@link AbstractByteBufferPacketCodec}
- *
- * This simply encodes the value's ordinal in the smallest primitive type possible. For example, if
- * the {@code enum} has 256 or fewer constants, the ordinal is encoding using a single byte.
- *
- * @param <U> the type of the {@code enum}
- */
-public class ByteBufferEnumFieldCodec<U extends Enum<U>>
- extends AbstractFieldCodec<ByteBuffer, ByteBuffer, U> {
- private final Class<U> type;
- private final PrimitiveCodec<ByteBuffer, ByteBuffer> codec;
-
- public ByteBufferEnumFieldCodec(Class<? extends Packet> pktType, Field field, Class<U> type,
- PrimitiveCodec<ByteBuffer, ByteBuffer> codec) {
- super(pktType, field);
- this.type = type;
- this.codec = codec;
- }
-
- @Override
- public U decodeField(Packet pkt, ByteBuffer buf, Integer count, PacketFactory factory)
- throws IOException, PacketDecodeException {
- return codec.decodeEnumConstant(field, buf, type);
- }
-
- @Override
- public void encodeField(ByteBuffer buf, Packet pkt, U val)
- throws IOException, PacketEncodeException {
- codec.encodeEnumConstant(buf, field, val);
- }
-}
diff --git a/Ghidra/Debug/Framework-AsyncComm/src/main/java/ghidra/comm/packet/binary/ByteBufferPacketCodec.java b/Ghidra/Debug/Framework-AsyncComm/src/main/java/ghidra/comm/packet/binary/ByteBufferPacketCodec.java
deleted file mode 100644
index 5d060e9319..0000000000
--- a/Ghidra/Debug/Framework-AsyncComm/src/main/java/ghidra/comm/packet/binary/ByteBufferPacketCodec.java
+++ /dev/null
@@ -1,85 +0,0 @@
-/* ###
- * 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 ghidra.comm.packet.binary;
-
-import java.io.IOException;
-import java.nio.BufferOverflowException;
-import java.nio.ByteBuffer;
-
-import ghidra.comm.packet.Packet;
-import ghidra.comm.packet.err.PacketEncodeException;
-import ghidra.comm.util.ByteBufferUtils;
-
-/**
- * A codec for encoding packets as binary data directly into or from a {@link ByteBuffer}
- *
- * Unlike {@link BinaryPacketCodec} and {@link BinaryLEPacketCodec}, this codec expects the caller
- * to provide the encode or decode buffer. The caller is responsible for managing the buffer. For
- * example, the caller must configure the buffer's byte order. Additionally, if the buffer is too
- * small, the codec will allow the {@link BufferOverflowException} to propagate. The caller should
- * re-allocate the buffer and try again.
- */
-public class ByteBufferPacketCodec extends AbstractByteBufferPacketCodec<ByteBuffer> {
-
- public static final ByteBufferPacketCodec INSTANCE = new ByteBufferPacketCodec();
-
- /**
- * Get the singleton instance of this codec
- *
- * @return the instance
- */
- public static ByteBufferPacketCodec getInstance() {
- return INSTANCE;
- }
-
- protected ByteBufferPacketCodec() {
- }
-
- @Override
- public ByteBuffer encodePacket(Packet pkt) throws PacketEncodeException {
- ByteBuffer buf = ByteBuffer.allocate(1024);
- while (true) {
- try {
- encodePacketInto(buf, pkt);
- buf.flip();
- return buf;
- }
- catch (BufferOverflowException e) {
- buf = ByteBufferUtils.upsize(buf);
- }
- }
- }
-
- @Override
- protected ByteBuffer finishEncode(ByteBuffer buf) {
- return buf;
- }
-
- @Override
- public ByteBuffer newDecodeBuffer(ByteBuffer data) throws IOException {
- return data; // No conversion necessary
- }
-
- @Override
- public ByteBuffer newEncodeBuffer() throws IOException {
- throw new UnsupportedOperationException("Caller should provide its own encode buffer");
- }
-
- @Override
- public void encodePacket(ByteBuffer buf, Packet pkt) throws PacketEncodeException {
- encodePacketInto(buf, pkt);
- }
-}
diff --git a/Ghidra/Debug/Framework-AsyncComm/src/main/java/ghidra/comm/packet/binary/NullTerminated.java b/Ghidra/Debug/Framework-AsyncComm/src/main/java/ghidra/comm/packet/binary/NullTerminated.java
deleted file mode 100644
index 9cd76f761d..0000000000
--- a/Ghidra/Debug/Framework-AsyncComm/src/main/java/ghidra/comm/packet/binary/NullTerminated.java
+++ /dev/null
@@ -1,56 +0,0 @@
-/* ###
- * 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 ghidra.comm.packet.binary;
-
-import java.lang.annotation.*;
-
-import ghidra.comm.packet.err.PacketDecodeException;
-
-/**
- * An annotation that indicates a field is null terminated
- *
- * This annotation is only meaningful to byte-based packet codecs. When encoded, the annotated field
- * will be conditionally followed by some number of null bytes. When decoded, the field codec will
- * read ahead to the null terminator and limit the chained codec to the preceding data. Once
- * decoded, it will resume immediately following the null terminator.
- *
- * @see SequenceTerminated
- */
-@Retention(RetentionPolicy.RUNTIME)
-@Target(ElementType.FIELD)
-public @interface NullTerminated {
- /**
- * The number of null bytes in the terminator
- *
- * @return the number of bytes
- */
- int value() default 1;
-
- /**
- * The name of the field, preceding this one, upon which the terminator is conditioned
- *
- * If a name is provided, and the named field has a value of {@code null} during encoding, then
- * the terminator is not appended. Otherwise, the terminator is always applied. If a name is
- * provided, and the decoder hits the buffer limit while reading ahead to the terminator, the
- * chained field is permitted to consume up to the same limit. Otherwise, a missing terminator
- * causes a {@link PacketDecodeException}.
- *
- * The named field must be in the same {@link Packet}.
- *
- * @return the name of the field
- */
- String cond() default "";
-}
diff --git a/Ghidra/Debug/Framework-AsyncComm/src/main/java/ghidra/comm/packet/binary/NullTerminatedWrapperFactory.java b/Ghidra/Debug/Framework-AsyncComm/src/main/java/ghidra/comm/packet/binary/NullTerminatedWrapperFactory.java
deleted file mode 100644
index 986a4150b2..0000000000
--- a/Ghidra/Debug/Framework-AsyncComm/src/main/java/ghidra/comm/packet/binary/NullTerminatedWrapperFactory.java
+++ /dev/null
@@ -1,59 +0,0 @@
-/* ###
- * 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 ghidra.comm.packet.binary;
-
-import java.lang.reflect.Field;
-import java.nio.ByteBuffer;
-import java.util.Deque;
-
-import ghidra.comm.packet.Packet;
-import ghidra.comm.packet.codecs.PacketCodecInternal;
-import ghidra.comm.packet.err.PacketAnnotationException;
-import ghidra.comm.packet.fields.*;
-
-/**
- * The factory implementing {@link NullTerminated} for {@link ByteBufferPacketCodec}
- */
-public class NullTerminatedWrapperFactory extends AbstractWrapperFactory<ByteBuffer, ByteBuffer> {
- @Override
- public <T> FieldCodec<ByteBuffer, ByteBuffer, T> getWrappedFieldCodecForType(
- Class<? extends Packet> pktType, Field field, Class<? extends T> fldType,
- PacketCodecInternal<?, ByteBuffer, ByteBuffer> codec,
- Deque<FieldCodecFactory<ByteBuffer, ByteBuffer>> chain) {
- NullTerminated annot = field.getAnnotation(NullTerminated.class);
- if (annot.value() < 1) {
- throw new PacketAnnotationException(pktType, field, annot, "Cannot have count < 1");
- }
-
- Field condField;
- if ("".equals(annot.cond())) {
- condField = null;
- }
- else {
- try {
- condField = Packet.getPacketField(pktType, annot.cond());
- }
- catch (NoSuchFieldException | SecurityException e) {
- throw new PacketAnnotationException(pktType, field, annot, e.getMessage(), e);
- }
- }
-
- FieldCodec<ByteBuffer, ByteBuffer, T> next =
- FieldCodecFactory.buildChainForType(pktType, field, fldType, codec, chain);
- byte[] tok = new byte[annot.value()];
- return new SequenceTerminatedFieldCodec<>(pktType, field, tok, condField, next);
- }
-}
diff --git a/Ghidra/Debug/Framework-AsyncComm/src/main/java/ghidra/comm/packet/binary/ReverseByteOrder.java b/Ghidra/Debug/Framework-AsyncComm/src/main/java/ghidra/comm/packet/binary/ReverseByteOrder.java
deleted file mode 100644
index fc064c0eb7..0000000000
--- a/Ghidra/Debug/Framework-AsyncComm/src/main/java/ghidra/comm/packet/binary/ReverseByteOrder.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/* ###
- * 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 ghidra.comm.packet.binary;
-
-import java.lang.annotation.*;
-
-/**
- * An annotation indicating that values should be encoded with the opposite endianness
- *
- * This changes the byte order relative to the surrounding fields. Thus, a user must take note of
- * the default byte order of the codec, or the current byte order in context of the protocol.
- *
- * Note that this cannot be used to reverse the bytes of anything, or of an entire encoded buffer.
- * It only affects the byte ordering of individually-encoded integers, float-point values, and
- * characters.
- */
-@Retention(RetentionPolicy.RUNTIME)
-@Target(ElementType.FIELD)
-public @interface ReverseByteOrder {
- // No attributes
-}
diff --git a/Ghidra/Debug/Framework-AsyncComm/src/main/java/ghidra/comm/packet/binary/ReverseByteOrderWrapperFactory.java b/Ghidra/Debug/Framework-AsyncComm/src/main/java/ghidra/comm/packet/binary/ReverseByteOrderWrapperFactory.java
deleted file mode 100644
index 46c2d137a7..0000000000
--- a/Ghidra/Debug/Framework-AsyncComm/src/main/java/ghidra/comm/packet/binary/ReverseByteOrderWrapperFactory.java
+++ /dev/null
@@ -1,66 +0,0 @@
-/* ###
- * 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 ghidra.comm.packet.binary;
-
-import java.io.IOException;
-import java.lang.reflect.Field;
-import java.nio.ByteBuffer;
-import java.nio.ByteOrder;
-import java.util.Deque;
-
-import ghidra.comm.packet.Packet;
-import ghidra.comm.packet.PacketFactory;
-import ghidra.comm.packet.codecs.PacketCodecInternal;
-import ghidra.comm.packet.err.PacketDecodeException;
-import ghidra.comm.packet.err.PacketEncodeException;
-import ghidra.comm.packet.fields.*;
-
-/**
- * The factory implementing {@link ReverseByteOrder} for {@link ByteBufferPacketCodec}
- */
-public class ReverseByteOrderWrapperFactory extends AbstractWrapperFactory<ByteBuffer, ByteBuffer> {
- @Override
- public <T> FieldCodec<ByteBuffer, ByteBuffer, T> getWrappedFieldCodecForType(
- Class<? extends Packet> pktType, Field field, Class<? extends T> fldType,
- PacketCodecInternal<?, ByteBuffer, ByteBuffer> codec,
- Deque<FieldCodecFactory<ByteBuffer, ByteBuffer>> chain) {
-
- FieldCodec<ByteBuffer, ByteBuffer, T> chainNext =
- FieldCodecFactory.buildChainForType(pktType, field, fldType, codec, chain);
- return new AbstractFieldCodec<ByteBuffer, ByteBuffer, T>(pktType, field) {
- @Override
- public T decodeField(Packet pkt, ByteBuffer buf, Integer count, PacketFactory factory)
- throws IOException, PacketDecodeException {
- ByteOrder orig = buf.order();
- buf.order(
- orig == ByteOrder.BIG_ENDIAN ? ByteOrder.LITTLE_ENDIAN : ByteOrder.BIG_ENDIAN);
- T result = chainNext.decodeField(pkt, buf, count, factory);
- buf.order(orig);
- return result;
- }
-
- @Override
- public void encodeField(ByteBuffer buf, Packet pkt, T val)
- throws IOException, PacketEncodeException {
- ByteOrder orig = buf.order();
- buf.order(
- orig == ByteOrder.BIG_ENDIAN ? ByteOrder.LITTLE_ENDIAN : ByteOrder.BIG_ENDIAN);
- chainNext.encodeField(buf, pkt, val);
- buf.order(orig);
- }
- };
- }
-}
diff --git a/Ghidra/Debug/Framework-AsyncComm/src/main/java/ghidra/comm/packet/binary/SequenceTerminated.java b/Ghidra/Debug/Framework-AsyncComm/src/main/java/ghidra/comm/packet/binary/SequenceTerminated.java
deleted file mode 100644
index ae5e4e6549..0000000000
--- a/Ghidra/Debug/Framework-AsyncComm/src/main/java/ghidra/comm/packet/binary/SequenceTerminated.java
+++ /dev/null
@@ -1,56 +0,0 @@
-/* ###
- * 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 ghidra.comm.packet.binary;
-
-import java.lang.annotation.*;
-
-import ghidra.comm.packet.err.PacketDecodeException;
-
-/**
- * An annotation that indicates a field is terminated by a sequence of bytes
- *
- * This annotation is only meaningful to byte-based packet codecs. When encoded, the annotated field
- * will be conditionally followed by the byte sequence. When decoded, the field codec will read
- * ahead to the terminator and limit the chained codec to the preceding data. Once decoded, it will
- * resume immediately following the terminator.
- *
- * @see NullTerminated
- */
-@Retention(RetentionPolicy.RUNTIME)
-@Target(ElementType.FIELD)
-public @interface SequenceTerminated {
- /**
- * The terminating byte sequence
- *
- * @return the byte sequence
- */
- byte[] value();
-
- /**
- * The name of the field, preceding this one, upon which the terminator is conditioned
- *
- * If a name is provided, and the named field has a value of {@code null} during encoding, then
- * the terminator is not appended. Otherwise, the terminator is always applied. If a name is
- * provided, and the decoder hits the buffer limit while reading ahead to the terminator, the
- * chained field is permitted to consume up to the same limit. Otherwise, a missing terminator
- * causes a {@link PacketDecodeException}.
- *
- * The named field must be in the same {@link Packet}.
- *
- * @return the name of the field
- */
- String cond() default "";
-}
diff --git a/Ghidra/Debug/Framework-AsyncComm/src/main/java/ghidra/comm/packet/binary/SequenceTerminatedFieldCodec.java b/Ghidra/Debug/Framework-AsyncComm/src/main/java/ghidra/comm/packet/binary/SequenceTerminatedFieldCodec.java
deleted file mode 100644
index 011bb44a1b..0000000000
--- a/Ghidra/Debug/Framework-AsyncComm/src/main/java/ghidra/comm/packet/binary/SequenceTerminatedFieldCodec.java
+++ /dev/null
@@ -1,107 +0,0 @@
-/* ###
- * 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 ghidra.comm.packet.binary;
-
-import java.io.EOFException;
-import java.io.IOException;
-import java.lang.reflect.Field;
-import java.nio.ByteBuffer;
-
-import ghidra.comm.packet.Packet;
-import ghidra.comm.packet.PacketFactory;
-import ghidra.comm.packet.err.*;
-import ghidra.comm.packet.fields.AbstractFieldCodec;
-import ghidra.comm.packet.fields.FieldCodec;
-import ghidra.util.NumericUtilities;
-
-/**
- * The {@link FieldCodec} for fields annotated by {@link SequenceTerminated} or
- * {@link NullTerminated} for {@link ByteBufferPacketCodec}
- *
- * @see SequenceTerminatedWrapperFactory
- * @see NullTerminatedWrapperFactory
- *
- * @param <T> the type of the field as passed through the chain
- */
-public final class SequenceTerminatedFieldCodec<T>
- extends AbstractFieldCodec<ByteBuffer, ByteBuffer, T> {
- private final Field condField;
- private final FieldCodec<ByteBuffer, ByteBuffer, T> chainNext;
- private byte[] tok;
-
- public SequenceTerminatedFieldCodec(Class<? extends Packet> pktType, Field field, byte[] tok,
- Field optField, FieldCodec<ByteBuffer, ByteBuffer, T> chainNext) {
- super(pktType, field);
- this.tok = tok;
- this.condField = optField;
- this.chainNext = chainNext;
- }
-
- @Override
- public T decodeField(Packet pkt, ByteBuffer buf, Integer count, PacketFactory factory)
- throws IOException, PacketDecodeException {
- // Look ahead to find the token, then chop the buffer removing the token
- // NOTE: This probably shouldn't decode through the chain.
- // Part of the idea of the annotation is that certain codecs may ignore them.
- // I see no reason for, e.g., the string codec to insert 00 to "null terminate"
-
- int matchedLen = 0;
- int i;
- for (i = buf.position(); i < buf.limit() && matchedLen < tok.length; i++) {
- if (buf.get(i) == tok[matchedLen]) {
- matchedLen++;
- }
- else {
- matchedLen = 0;
- }
- }
- if (matchedLen != tok.length) {
- if (condField != null) {
- return chainNext.decodeField(pkt, buf, count, factory);
- }
- else if (!buf.hasRemaining()) {
- throw new EOFException("Buffer is empty");
- }
- else {
- throw new InvalidPacketException("Missing terminator sequence [" +
- NumericUtilities.convertBytesToString(tok, ":"));
- }
- }
- int orig = buf.limit();
- buf.limit(i - matchedLen);
- T result = chainNext.decodeField(pkt, buf, count, factory);
- if (buf.hasRemaining()) {
- throw new InvalidPacketException(field + " did not consume buffer " + buf);
- }
- buf.limit(orig);
- buf.position(buf.position() + tok.length);
- return result;
- }
-
- @Override
- public void encodeField(ByteBuffer buf, Packet pkt, T val)
- throws IOException, PacketEncodeException {
- chainNext.encodeField(buf, pkt, val);
- try {
- if (condField == null || condField.get(pkt) != null) {
- buf.put(tok);
- }
- }
- catch (IllegalAccessException e) {
- throw new RuntimeException(e);
- }
- }
-}
diff --git a/Ghidra/Debug/Framework-AsyncComm/src/main/java/ghidra/comm/packet/binary/SequenceTerminatedWrapperFactory.java b/Ghidra/Debug/Framework-AsyncComm/src/main/java/ghidra/comm/packet/binary/SequenceTerminatedWrapperFactory.java
deleted file mode 100644
index 53aa2ab407..0000000000
--- a/Ghidra/Debug/Framework-AsyncComm/src/main/java/ghidra/comm/packet/binary/SequenceTerminatedWrapperFactory.java
+++ /dev/null
@@ -1,61 +0,0 @@
-/* ###
- * 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 ghidra.comm.packet.binary;
-
-import java.lang.reflect.Field;
-import java.nio.ByteBuffer;
-import java.util.Deque;
-
-import ghidra.comm.packet.Packet;
-import ghidra.comm.packet.codecs.PacketCodecInternal;
-import ghidra.comm.packet.err.PacketAnnotationException;
-import ghidra.comm.packet.fields.*;
-
-/**
- * The factory implementing {@link SequenceTerminated} for {@link ByteBufferPacketCodec}
- */
-public class SequenceTerminatedWrapperFactory
- extends AbstractWrapperFactory<ByteBuffer, ByteBuffer> {
- @Override
- public <T> FieldCodec<ByteBuffer, ByteBuffer, T> getWrappedFieldCodecForType(
- Class<? extends Packet> pktType, Field field, Class<? extends T> fldType,
- PacketCodecInternal<?, ByteBuffer, ByteBuffer> codec,
- Deque<FieldCodecFactory<ByteBuffer, ByteBuffer>> chain) {
- SequenceTerminated annot = field.getAnnotation(SequenceTerminated.class);
- if (annot.value().length < 1) {
- throw new PacketAnnotationException(pktType, field, annot,
- "Cannot have sequence length < 1");
- }
-
- Field condField;
- if ("".equals(annot.cond())) {
- condField = null;
- }
- else {
- try {
- condField = Packet.getPacketField(pktType, annot.cond());
- }
- catch (NoSuchFieldException | SecurityException e) {
- throw new PacketAnnotationException(pktType, field, annot, e.getMessage(), e);
- }
- }
-
- FieldCodec<ByteBuffer, ByteBuffer, T> chainNext =
- FieldCodecFactory.buildChainForType(pktType, field, fldType, codec, chain);
- return new SequenceTerminatedFieldCodec<>(pktType, field, annot.value(), condField,
- chainNext);
- }
-}
diff --git a/Ghidra/Debug/Framework-AsyncComm/src/main/java/ghidra/comm/packet/codecs/ArrayFieldCodec.java b/Ghidra/Debug/Framework-AsyncComm/src/main/java/ghidra/comm/packet/codecs/ArrayFieldCodec.java
deleted file mode 100644
index c0ce3e6646..0000000000
--- a/Ghidra/Debug/Framework-AsyncComm/src/main/java/ghidra/comm/packet/codecs/ArrayFieldCodec.java
+++ /dev/null
@@ -1,95 +0,0 @@
-/* ###
- * 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 ghidra.comm.packet.codecs;
-
-import java.io.EOFException;
-import java.io.IOException;
-import java.lang.reflect.Array;
-import java.lang.reflect.Field;
-import java.util.ArrayList;
-
-import ghidra.comm.packet.Packet;
-import ghidra.comm.packet.PacketFactory;
-import ghidra.comm.packet.annot.RepeatedField;
-import ghidra.comm.packet.err.PacketDecodeException;
-import ghidra.comm.packet.err.PacketEncodeException;
-import ghidra.comm.packet.fields.AbstractFieldCodec;
-import ghidra.comm.packet.fields.FieldCodec;
-
-/**
- * The {@link FieldCodec} for encoding arrays
- *
- * @see {@link RepeatedField}
- *
- * @param <ENCBUF> the type of temporary buffer used to encode
- * @param <DECBUF> the type of temporary buffer used to decode
- * @param <E> the type of element encoded, as passed through the chain
- */
-public class ArrayFieldCodec<ENCBUF, DECBUF, E> extends AbstractFieldCodec<ENCBUF, DECBUF, Object> {
- private final ElementCodec<ENCBUF, DECBUF, E> elemCodec;
- private final Class<E> elemType;
- private final FieldCodec<ENCBUF, DECBUF, E> chainNext;
- private final PacketCodecInternal<?, ENCBUF, DECBUF> codec;
-
- public ArrayFieldCodec(ElementCodec<ENCBUF, DECBUF, E> elemCodec,
- Class<? extends Packet> pktType, Field field, Class<E> elemType,
- PacketCodecInternal<?, ENCBUF, DECBUF> codec, FieldCodec<ENCBUF, DECBUF, E> chainNext) {
- super(pktType, field);
- this.elemCodec = elemCodec;
- this.elemType = elemType;
- this.codec = codec;
- this.chainNext = chainNext;
- }
-
- @Override
- public void encodeField(ENCBUF buf, Packet pkt, Object arr)
- throws IOException, PacketEncodeException {
- int len = Array.getLength(arr);
- for (int i = 0; i < len; i++) {
- @SuppressWarnings("unchecked")
- E elem = (E) Array.get(arr, i);
- elemCodec.encodeElement(buf, pkt, field, elem, i == len - 1, chainNext);
- }
- }
-
- @Override
- public Object decodeField(Packet pkt, DECBUF buf, Integer count, PacketFactory factory)
- throws IOException, PacketDecodeException {
- if (count != null) {
- Object arr = factory.newArray(elemType, count.intValue());
- for (int i = 0; i < count; i++) {
- Array.set(arr, i, elemCodec.decodeElement(pkt, field, buf, elemType, i == count - 1,
- chainNext, factory));
- }
- return arr;
- }
- ArrayList<E> result = new ArrayList<>();
- try {
- while (codec.measureDecodeRemaining(buf) > 0) {
- result.add(
- elemCodec.decodeElement(pkt, field, buf, elemType, false, chainNext, factory));
- }
- }
- catch (EOFException e) {
- // finished
- }
- Object arr = factory.newArray(elemType, result.size());
- for (int i = 0; i < result.size(); i++) {
- Array.set(arr, i, result.get(i));
- }
- return arr;
- }
-}
diff --git a/Ghidra/Debug/Framework-AsyncComm/src/main/java/ghidra/comm/packet/codecs/BooleanFieldCodec.java b/Ghidra/Debug/Framework-AsyncComm/src/main/java/ghidra/comm/packet/codecs/BooleanFieldCodec.java
deleted file mode 100644
index 2134bf59c6..0000000000
--- a/Ghidra/Debug/Framework-AsyncComm/src/main/java/ghidra/comm/packet/codecs/BooleanFieldCodec.java
+++ /dev/null
@@ -1,56 +0,0 @@
-/* ###
- * 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 ghidra.comm.packet.codecs;
-
-import java.io.IOException;
-import java.lang.reflect.Field;
-
-import ghidra.comm.packet.Packet;
-import ghidra.comm.packet.PacketFactory;
-import ghidra.comm.packet.err.PacketDecodeException;
-import ghidra.comm.packet.err.PacketEncodeException;
-import ghidra.comm.packet.fields.AbstractFieldCodec;
-import ghidra.comm.packet.fields.FieldCodec;
-
-/**
- * The {@link FieldCodec} for encoding boolean values
- *
- * This delegates to the given {@link PrimitiveCodec}
- *
- * @param <ENCBUF> the type of temporary buffer used to encode
- * @param <DECBUF> the type of temporary buffer used to decode
- */
-public class BooleanFieldCodec<ENCBUF, DECBUF> extends AbstractFieldCodec<ENCBUF, DECBUF, Boolean> {
- private final PrimitiveCodec<ENCBUF, DECBUF> codec;
-
- public BooleanFieldCodec(PrimitiveCodec<ENCBUF, DECBUF> codec, Class<? extends Packet> pktType,
- Field field) {
- super(pktType, field);
- this.codec = codec;
- }
-
- @Override
- public Boolean decodeField(Packet pkt, DECBUF buf, Integer count, PacketFactory factory)
- throws IOException, PacketDecodeException {
- return codec.decodeBoolean(field, buf);
- }
-
- @Override
- public void encodeField(ENCBUF buf, Packet pkt, Boolean val)
- throws IOException, PacketEncodeException {
- codec.encodeBoolean(buf, field, val);
- }
-}
diff --git a/Ghidra/Debug/Framework-AsyncComm/src/main/java/ghidra/comm/packet/codecs/ByteFieldCodec.java b/Ghidra/Debug/Framework-AsyncComm/src/main/java/ghidra/comm/packet/codecs/ByteFieldCodec.java
deleted file mode 100644
index ff0724bf68..0000000000
--- a/Ghidra/Debug/Framework-AsyncComm/src/main/java/ghidra/comm/packet/codecs/ByteFieldCodec.java
+++ /dev/null
@@ -1,56 +0,0 @@
-/* ###
- * 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 ghidra.comm.packet.codecs;
-
-import java.io.IOException;
-import java.lang.reflect.Field;
-
-import ghidra.comm.packet.Packet;
-import ghidra.comm.packet.PacketFactory;
-import ghidra.comm.packet.err.PacketDecodeException;
-import ghidra.comm.packet.err.PacketEncodeException;
-import ghidra.comm.packet.fields.AbstractFieldCodec;
-import ghidra.comm.packet.fields.FieldCodec;
-
-/**
- * The {@link FieldCodec} for encoding byte values
- *
- * This delegates to the given {@link PrimitiveCodec}
- *
- * @param <ENCBUF> the type of temporary buffer used to encode
- * @param <DECBUF> the type of temporary buffer used to decode
- */
-public class ByteFieldCodec<ENCBUF, DECBUF> extends AbstractFieldCodec<ENCBUF, DECBUF, Byte> {
- private final PrimitiveCodec<ENCBUF, DECBUF> codec;
-
- public ByteFieldCodec(PrimitiveCodec<ENCBUF, DECBUF> codec, Class<? extends Packet> pktType,
- Field field) {
- super(pktType, field);
- this.codec = codec;
- }
-
- @Override
- public Byte decodeField(Packet pkt, DECBUF buf, Integer count, PacketFactory factory)
- throws IOException, PacketDecodeException {
- return codec.decodeByte(field, buf);
- }
-
- @Override
- public void encodeField(ENCBUF buf, Packet pkt, Byte val)
- throws IOException, PacketEncodeException {
- codec.encodeByte(buf, field, val);
- }
-}
diff --git a/Ghidra/Debug/Framework-AsyncComm/src/main/java/ghidra/comm/packet/codecs/CharSequenceFieldCodec.java b/Ghidra/Debug/Framework-AsyncComm/src/main/java/ghidra/comm/packet/codecs/CharSequenceFieldCodec.java
deleted file mode 100644
index 66060b1d54..0000000000
--- a/Ghidra/Debug/Framework-AsyncComm/src/main/java/ghidra/comm/packet/codecs/CharSequenceFieldCodec.java
+++ /dev/null
@@ -1,57 +0,0 @@
-/* ###
- * 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 ghidra.comm.packet.codecs;
-
-import java.io.IOException;
-import java.lang.reflect.Field;
-
-import ghidra.comm.packet.Packet;
-import ghidra.comm.packet.PacketFactory;
-import ghidra.comm.packet.err.PacketDecodeException;
-import ghidra.comm.packet.err.PacketEncodeException;
-import ghidra.comm.packet.fields.AbstractFieldCodec;
-import ghidra.comm.packet.fields.FieldCodec;
-
-/**
- * The {@link FieldCodec} for encoding character sequences
- *
- * This delegates to the given {@link PrimitiveCodec}
- *
- * @param <ENCBUF> the type of temporary buffer used to encode
- * @param <DECBUF> the type of temporary buffer used to decode
- */
-public class CharSequenceFieldCodec<ENCBUF, DECBUF>
- extends AbstractFieldCodec<ENCBUF, DECBUF, CharSequence> {
- private final PrimitiveCodec<ENCBUF, DECBUF> codec;
-
- public CharSequenceFieldCodec(PrimitiveCodec<ENCBUF, DECBUF> codec,
- Class<? extends Packet> pktType, Field field) {
- super(pktType, field);
- this.codec = codec;
- }
-
- @Override
- public CharSequence decodeField(Packet pkt, DECBUF buf, Integer count, PacketFactory factory)
- throws IOException, PacketDecodeException {
- return codec.decodeCharSequence(field, buf, count);
- }
-
- @Override
- public void encodeField(ENCBUF buf, Packet pkt, CharSequence val)
- throws IOException, PacketEncodeException {
- codec.encodeCharSequence(buf, field, val);
- }
-}
diff --git a/Ghidra/Debug/Framework-AsyncComm/src/main/java/ghidra/comm/packet/codecs/CharacterFieldCodec.java b/Ghidra/Debug/Framework-AsyncComm/src/main/java/ghidra/comm/packet/codecs/CharacterFieldCodec.java
deleted file mode 100644
index 72ed70a733..0000000000
--- a/Ghidra/Debug/Framework-AsyncComm/src/main/java/ghidra/comm/packet/codecs/CharacterFieldCodec.java
+++ /dev/null
@@ -1,57 +0,0 @@
-/* ###
- * 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 ghidra.comm.packet.codecs;
-
-import java.io.IOException;
-import java.lang.reflect.Field;
-
-import ghidra.comm.packet.Packet;
-import ghidra.comm.packet.PacketFactory;
-import ghidra.comm.packet.err.PacketDecodeException;
-import ghidra.comm.packet.err.PacketEncodeException;
-import ghidra.comm.packet.fields.AbstractFieldCodec;
-import ghidra.comm.packet.fields.FieldCodec;
-
-/**
- * The {@link FieldCodec} for encoding character values
- *
- * This delegates to the given {@link PrimitiveCodec}
- *
- * @param <ENCBUF> the type of temporary buffer used to encode
- * @param <DECBUF> the type of temporary buffer used to decode
- */
-public class CharacterFieldCodec<ENCBUF, DECBUF>
- extends AbstractFieldCodec<ENCBUF, DECBUF, Character> {
- private final PrimitiveCodec<ENCBUF, DECBUF> codec;
-
- public CharacterFieldCodec(PrimitiveCodec<ENCBUF, DECBUF> codec,
- Class<? extends Packet> pktType, Field field) {
- super(pktType, field);
- this.codec = codec;
- }
-
- @Override
- public Character decodeField(Packet pkt, DECBUF buf, Integer count, PacketFactory factory)
- throws IOException, PacketDecodeException {
- return codec.decodeChar(field, buf);
- }
-
- @Override
- public void encodeField(ENCBUF buf, Packet pkt, Character val)
- throws IOException, PacketEncodeException {
- codec.encodeChar(buf, field, val);
- }
-}
diff --git a/Ghidra/Debug/Framework-AsyncComm/src/main/java/ghidra/comm/packet/codecs/CollectionFieldCodec.java b/Ghidra/Debug/Framework-AsyncComm/src/main/java/ghidra/comm/packet/codecs/CollectionFieldCodec.java
deleted file mode 100644
index f162dd4db1..0000000000
--- a/Ghidra/Debug/Framework-AsyncComm/src/main/java/ghidra/comm/packet/codecs/CollectionFieldCodec.java
+++ /dev/null
@@ -1,110 +0,0 @@
-/* ###
- * 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 ghidra.comm.packet.codecs;
-
-import java.io.EOFException;
-import java.io.IOException;
-import java.lang.reflect.Field;
-import java.lang.reflect.InvocationTargetException;
-import java.util.Collection;
-import java.util.Iterator;
-
-import ghidra.comm.packet.Packet;
-import ghidra.comm.packet.PacketFactory;
-import ghidra.comm.packet.annot.RepeatedField;
-import ghidra.comm.packet.err.PacketDecodeException;
-import ghidra.comm.packet.err.PacketEncodeException;
-import ghidra.comm.packet.fields.AbstractFieldCodec;
-import ghidra.comm.packet.fields.FieldCodec;
-
-/**
- * The {@link FieldCodec} for encoding collections
- *
- * @see {@link RepeatedField}
- *
- * @param <ENCBUF> the type of temporary buffer used to encode
- * @param <DECBUF> the type of temporary buffer used to decode
- * @param <E> the type of element encoded, as passed through the chain
- */
-public class CollectionFieldCodec<ENCBUF, DECBUF, E>
- extends AbstractFieldCodec<ENCBUF, DECBUF, Collection<E>> {
- private final ElementCodec<ENCBUF, DECBUF, E> elemCodec;
- private final Class<? extends Collection<E>> colType;
- private final Class<E> elemType;
- private final FieldCodec<ENCBUF, DECBUF, E> chainNext;
- private final PacketCodecInternal<?, ENCBUF, DECBUF> codec;
-
- public CollectionFieldCodec(ElementCodec<ENCBUF, DECBUF, E> elemCodec,
- Class<? extends Packet> pktType, Field field, Class<? extends Collection<E>> colType,
- Class<E> elemType, PacketCodecInternal<?, ENCBUF, DECBUF> codec,
- FieldCodec<ENCBUF, DECBUF, E> chainNext) {
- super(pktType, field);
- this.elemCodec = elemCodec;
- this.colType = colType;
- this.elemType = elemType;
- this.codec = codec;
- this.chainNext = chainNext;
- }
-
- @Override
- public void encodeField(ENCBUF buf, Packet pkt, Collection<E> val)
- throws IOException, PacketEncodeException {
- Iterator<E> it = val.iterator();
- while (it.hasNext()) {
- elemCodec.encodeElement(buf, pkt, field, it.next(), !it.hasNext(), chainNext);
- }
- }
-
- @SuppressWarnings("unchecked")
- @Override
- public Collection<E> decodeField(Packet pkt, DECBUF buf, Integer count, PacketFactory factory)
- throws IOException, PacketDecodeException {
- Collection<E> result;
- try {
- // Try to use a pre-constructed collection, if present.
- result = (Collection<E>) field.get(pkt);
- if (result == null) {
- result = factory.newCollection(colType, elemType);
- }
- }
- catch (InstantiationException | IllegalAccessException | IllegalArgumentException
- | InvocationTargetException | NoSuchMethodException | SecurityException e) {
- throw new RuntimeException(e);
- }
- try {
- int i;
- for (i = 0; (count == null || i < count) &&
- codec.measureDecodeRemaining(buf) > 0; i++) {
- E elem = elemCodec.decodeElement(pkt, field, buf, elemType,
- (count != null && i == count - 1), chainNext, factory);
- if (elem == null) {
- return result;
- }
- result.add(elem);
- }
- if (count != null && i < count) {
- throw new EOFException(
- "Reached end of buffer before decoding " + count + " elements");
- }
- }
- catch (EOFException e) {
- if (count != null) {
- throw e;
- }
- }
- return result;
- }
-}
diff --git a/Ghidra/Debug/Framework-AsyncComm/src/main/java/ghidra/comm/packet/codecs/DoubleFieldCodec.java b/Ghidra/Debug/Framework-AsyncComm/src/main/java/ghidra/comm/packet/codecs/DoubleFieldCodec.java
deleted file mode 100644
index 7dd4e250b1..0000000000
--- a/Ghidra/Debug/Framework-AsyncComm/src/main/java/ghidra/comm/packet/codecs/DoubleFieldCodec.java
+++ /dev/null
@@ -1,56 +0,0 @@
-/* ###
- * 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 ghidra.comm.packet.codecs;
-
-import java.io.IOException;
-import java.lang.reflect.Field;
-
-import ghidra.comm.packet.Packet;
-import ghidra.comm.packet.PacketFactory;
-import ghidra.comm.packet.err.PacketDecodeException;
-import ghidra.comm.packet.err.PacketEncodeException;
-import ghidra.comm.packet.fields.AbstractFieldCodec;
-import ghidra.comm.packet.fields.FieldCodec;
-
-/**
- * The {@link FieldCodec} for encoding double-precision float values
- *
- * This delegates to the given {@link PrimitiveCodec}
- *
- * @param <ENCBUF> the type of temporary buffer used to encode
- * @param <DECBUF> the type of temporary buffer used to decode
- */
-public class DoubleFieldCodec<ENCBUF, DECBUF> extends AbstractFieldCodec<ENCBUF, DECBUF, Double> {
- private final PrimitiveCodec<ENCBUF, DECBUF> codec;
-
- public DoubleFieldCodec(PrimitiveCodec<ENCBUF, DECBUF> codec, Class<? extends Packet> pktType,
- Field field) {
- super(pktType, field);
- this.codec = codec;
- }
-
- @Override
- public Double decodeField(Packet pkt, DECBUF buf, Integer count, PacketFactory factory)
- throws IOException, PacketDecodeException {
- return codec.decodeDouble(field, buf);
- }
-
- @Override
- public void encodeField(ENCBUF buf, Packet pkt, Double val)
- throws IOException, PacketEncodeException {
- codec.encodeDouble(buf, field, val);
- }
-}
diff --git a/Ghidra/Debug/Framework-AsyncComm/src/main/java/ghidra/comm/packet/codecs/ElementCodec.java b/Ghidra/Debug/Framework-AsyncComm/src/main/java/ghidra/comm/packet/codecs/ElementCodec.java
deleted file mode 100644
index 1f3577a721..0000000000
--- a/Ghidra/Debug/Framework-AsyncComm/src/main/java/ghidra/comm/packet/codecs/ElementCodec.java
+++ /dev/null
@@ -1,80 +0,0 @@
-/* ###
- * 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 ghidra.comm.packet.codecs;
-
-import java.io.IOException;
-import java.lang.reflect.Field;
-
-import ghidra.comm.packet.Packet;
-import ghidra.comm.packet.PacketFactory;
-import ghidra.comm.packet.annot.RepeatedField;
-import ghidra.comm.packet.err.PacketDecodeException;
-import ghidra.comm.packet.err.PacketEncodeException;
-import ghidra.comm.packet.fields.FieldCodec;
-import ghidra.comm.packet.string.RegexSeparated;
-
-/**
- * A codec for encoding elements of an array or collection
- *
- * @see RepeatedField
- * @see RegexSeparated
- * @see ArrayFieldCodec
- * @see CollectionFieldCodec
- *
- * @param <ENCBUF> the type of temporary buffer used to encode
- * @param <DECBUF> the type of temporary buffer used to decode
- * @param <E> the type of element encoded, as passed through the chain
- */
-public interface ElementCodec<ENCBUF, DECBUF, E> {
- /**
- * Decode an element
- *
- * The simplest implementation delegates directly to {@code chainNext}. Other implementations
- * typically parse information to delineate each element.
- *
- * @param pkt the packet currently being decoded
- * @param field the field currently being decoded
- * @param buf the buffer from which the element is decoded
- * @param elemType the type expected for each element
- * @param last true if this is known to be the last element of the array or collection
- * @param chainNext the next field codec in the chain
- * @param factory a packet factory, usually implementing a particular version of the protocol
- * @return the decoded element
- * @throws IOException if there is an issue accessing a device or buffer
- * @throws PacketDecodeException if the packet is not well formed
- */
- E decodeElement(Packet pkt, Field field, DECBUF buf, Class<E> elemType, boolean last,
- FieldCodec<ENCBUF, DECBUF, E> chainNext, PacketFactory factory)
- throws IOException, PacketDecodeException;
-
- /**
- * Encode an element
- *
- * The simplest implementation delegate directly to {@code chainNext}. Other implementations
- * typically insert information to delineate each element.
- *
- * @param buf the buffer into which to append the encoded data
- * @param pkt the packet currently being encoded
- * @param field the field currently being encoded
- * @param elem the element to encode
- * @param last true if this is the last element of the array or collection
- * @param chainNext the next field codec in the chain
- * @throws IOException if there is an issue accessing a device or buffer
- * @throws PacketDecodeException if the packet is not well formed
- */
- void encodeElement(ENCBUF buf, Packet pkt, Field field, E elem, boolean last,
- FieldCodec<ENCBUF, DECBUF, E> chainNext) throws IOException, PacketEncodeException;
-}
diff --git a/Ghidra/Debug/Framework-AsyncComm/src/main/java/ghidra/comm/packet/codecs/FloatFieldCodec.java b/Ghidra/Debug/Framework-AsyncComm/src/main/java/ghidra/comm/packet/codecs/FloatFieldCodec.java
deleted file mode 100644
index 358b7e8fb4..0000000000
--- a/Ghidra/Debug/Framework-AsyncComm/src/main/java/ghidra/comm/packet/codecs/FloatFieldCodec.java
+++ /dev/null
@@ -1,56 +0,0 @@
-/* ###
- * 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 ghidra.comm.packet.codecs;
-
-import java.io.IOException;
-import java.lang.reflect.Field;
-
-import ghidra.comm.packet.Packet;
-import ghidra.comm.packet.PacketFactory;
-import ghidra.comm.packet.err.PacketDecodeException;
-import ghidra.comm.packet.err.PacketEncodeException;
-import ghidra.comm.packet.fields.AbstractFieldCodec;
-import ghidra.comm.packet.fields.FieldCodec;
-
-/**
- * The {@link FieldCodec} for encoding single-precision float values
- *
- * This delegates to the given {@link PrimitiveCodec}
- *
- * @param <ENCBUF> the type of temporary buffer used to encode
- * @param <DECBUF> the type of temporary buffer used to decode
- */
-public class FloatFieldCodec<ENCBUF, DECBUF> extends AbstractFieldCodec<ENCBUF, DECBUF, Float> {
- private final PrimitiveCodec<ENCBUF, DECBUF> codec;
-
- public FloatFieldCodec(PrimitiveCodec<ENCBUF, DECBUF> codec, Class<? extends Packet> pktType,
- Field field) {
- super(pktType, field);
- this.codec = codec;
- }
-
- @Override
- public Float decodeField(Packet pkt, DECBUF buf, Integer count, PacketFactory factory)
- throws IOException, PacketDecodeException {
- return codec.decodeFloat(field, buf);
- }
-
- @Override
- public void encodeField(ENCBUF buf, Packet pkt, Float val)
- throws IOException, PacketEncodeException {
- codec.encodeFloat(buf, field, val);
- }
-}
diff --git a/Ghidra/Debug/Framework-AsyncComm/src/main/java/ghidra/comm/packet/codecs/IntegerFieldCodec.java b/Ghidra/Debug/Framework-AsyncComm/src/main/java/ghidra/comm/packet/codecs/IntegerFieldCodec.java
deleted file mode 100644
index a61e4fb374..0000000000
--- a/Ghidra/Debug/Framework-AsyncComm/src/main/java/ghidra/comm/packet/codecs/IntegerFieldCodec.java
+++ /dev/null
@@ -1,56 +0,0 @@
-/* ###
- * 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 ghidra.comm.packet.codecs;
-
-import java.io.IOException;
-import java.lang.reflect.Field;
-
-import ghidra.comm.packet.Packet;
-import ghidra.comm.packet.PacketFactory;
-import ghidra.comm.packet.err.PacketDecodeException;
-import ghidra.comm.packet.err.PacketEncodeException;
-import ghidra.comm.packet.fields.AbstractFieldCodec;
-import ghidra.comm.packet.fields.FieldCodec;
-
-/**
- * The {@link FieldCodec} for encoding integer values
- *
- * This delegates to the given {@link PrimitiveCodec}
- *
- * @param <ENCBUF> the type of temporary buffer used to encode
- * @param <DECBUF> the type of temporary buffer used to decode
- */
-public class IntegerFieldCodec<ENCBUF, DECBUF> extends AbstractFieldCodec<ENCBUF, DECBUF, Integer> {
- private final PrimitiveCodec<ENCBUF, DECBUF> codec;
-
- public IntegerFieldCodec(PrimitiveCodec<ENCBUF, DECBUF> codec, Class<? extends Packet> pktType,
- Field field) {
- super(pktType, field);
- this.codec = codec;
- }
-
- @Override
- public Integer decodeField(Packet pkt, DECBUF buf, Integer count, PacketFactory factory)
- throws IOException, PacketDecodeException {
- return codec.decodeInt(field, buf);
- }
-
- @Override
- public void encodeField(ENCBUF buf, Packet pkt, Integer val)
- throws IOException, PacketEncodeException {
- codec.encodeInt(buf, field, val);
- }
-}
diff --git a/Ghidra/Debug/Framework-AsyncComm/src/main/java/ghidra/comm/packet/codecs/LongFieldCodec.java b/Ghidra/Debug/Framework-AsyncComm/src/main/java/ghidra/comm/packet/codecs/LongFieldCodec.java
deleted file mode 100644
index 6481cf0628..0000000000
--- a/Ghidra/Debug/Framework-AsyncComm/src/main/java/ghidra/comm/packet/codecs/LongFieldCodec.java
+++ /dev/null
@@ -1,56 +0,0 @@
-/* ###
- * 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 ghidra.comm.packet.codecs;
-
-import java.io.IOException;
-import java.lang.reflect.Field;
-
-import ghidra.comm.packet.Packet;
-import ghidra.comm.packet.PacketFactory;
-import ghidra.comm.packet.err.PacketDecodeException;
-import ghidra.comm.packet.err.PacketEncodeException;
-import ghidra.comm.packet.fields.AbstractFieldCodec;
-import ghidra.comm.packet.fields.FieldCodec;
-
-/**
- * The {@link FieldCodec} for encoding long values
- *
- * This delegates to the given {@link PrimitiveCodec}
- *
- * @param <ENCBUF> the type of temporary buffer used to encode
- * @param <DECBUF> the type of temporary buffer used to decode
- */
-public class LongFieldCodec<ENCBUF, DECBUF> extends AbstractFieldCodec<ENCBUF, DECBUF, Long> {
- private final PrimitiveCodec<ENCBUF, DECBUF> codec;
-
- public LongFieldCodec(PrimitiveCodec<ENCBUF, DECBUF> codec, Class<? extends Packet> pktType,
- Field field) {
- super(pktType, field);
- this.codec = codec;
- }
-
- @Override
- public Long decodeField(Packet pkt, DECBUF buf, Integer count, PacketFactory factory)
- throws IOException, PacketDecodeException {
- return codec.decodeLong(field, buf);
- }
-
- @Override
- public void encodeField(ENCBUF buf, Packet pkt, Long val)
- throws IOException, PacketEncodeException {
- codec.encodeLong(buf, field, val);
- }
-}
diff --git a/Ghidra/Debug/Framework-AsyncComm/src/main/java/ghidra/comm/packet/codecs/PacketCodecInternal.java b/Ghidra/Debug/Framework-AsyncComm/src/main/java/ghidra/comm/packet/codecs/PacketCodecInternal.java
deleted file mode 100644
index 48da62b517..0000000000
--- a/Ghidra/Debug/Framework-AsyncComm/src/main/java/ghidra/comm/packet/codecs/PacketCodecInternal.java
+++ /dev/null
@@ -1,268 +0,0 @@
-/* ###
- * 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 ghidra.comm.packet.codecs;
-
-import java.io.IOException;
-import java.lang.annotation.Annotation;
-import java.lang.reflect.*;
-import java.util.Map.Entry;
-
-import org.apache.commons.lang3.reflect.TypeUtils;
-
-import ghidra.comm.packet.*;
-import ghidra.comm.packet.annot.SizedByField;
-import ghidra.comm.packet.err.PacketDecodeException;
-import ghidra.comm.packet.err.PacketEncodeException;
-import ghidra.comm.packet.fields.*;
-
-/**
- * The internal interface for {@link PacketCodec}
- *
- * This interface should only be used by codec and annotation implementations. Implementors ought to
- * extend {@link AbstractPacketCodec}.
- *
- * A codec must internally provide factories for encoding and decoding all of the types it natively
- * supports. Every codec ought to support Java's primitives, {@link String}s, and nested
- * {@link Packet}s.
- *
- * It must also provide general mechanisms for interacting with its temporary encode and decode
- * buffers. These permit measured packet fields, e.g., those annotated with {@link SizedByField}, to
- * operate correctly.
- *
- * @param <T> the type of encoded packets
- * @param <ENCBUF> the type of temporary buffer used to encode
- * @param <DECBUF> the type of temporary buffer used to decode
- */
-public interface PacketCodecInternal<T, ENCBUF, DECBUF>
- extends PacketCodec<T>, FieldCodecFactory<ENCBUF, DECBUF> {
- /**
- * A utility for obtaining the class given for a type parameter by a subclass
- *
- * @param type the subclass type
- * @param sup the superclass type having the type parameter of interest
- * @param name the name of the type parameter of interest
- * @return the class given for the parameter, or null if it another variable or the name is not
- * found
- */
- public static Class<?> getTypeParameterRaw(Type type, Class<?> sup, String name) {
- Type generic = getTypeParameterValue(type, sup, name);
- if (generic == null) {
- return null;
- }
- return TypeUtils.getRawType(generic, type);
- }
-
- /**
- * A utility for obtaining the type given for a type parameter by a subclass
- *
- * @param type the subclass type
- * @param sup the superclass type having the type parameter of interest
- * @param name the name of the type parameter of interest
- * @return the type given for the parameter, or null if the name is not found
- */
- public static Type getTypeParameterValue(Type type, Class<?> sup, String name) {
- for (Entry<TypeVariable<?>, Type> ent : TypeUtils.getTypeArguments(type, sup).entrySet()) {
- if (ent.getKey().getName().equals(name)) {
- return ent.getValue();
- }
- }
- return null;
- }
-
- /**
- * Decode a packet field from a given buffer
- *
- * This method <em>need not</em> actually set the field value. Just return it, and the caller
- * will handle setting the field or comparing it to a final field value.
- *
- * @param pkt the packet whose field to decode
- * @param field the field to decode
- * @param buf the buffer positioned at the encoded field
- * @param count for repeated fields, the number of repetitions expected
- * @param factory a factory for instantiating abstract types
- * @return the field value
- * @throws IOException if there is an issue accessing a device or buffer
- * @throws PacketDecodeException if the packet is not well formed
- */
- public <U> U decodeField(Packet pkt, Field field, DECBUF buf, Integer count,
- PacketFactory factory) throws IOException, PacketDecodeException;
-
- /**
- * Encode a packet field into a buffer
- *
- * @param buf the destination buffer to append encoded data
- * @param pkt the packet whose field to encode
- * @param field the field to encode
- * @param val the value of the field to encode
- * @throws IOException if there is an issue accessing a device or buffer
- * @throws PacketEncodeException if the packet is not well formed
- */
- public <U> void encodeField(ENCBUF buf, Packet pkt, Field field, U val)
- throws IOException, PacketEncodeException;
-
- /**
- * Encode a packet into a buffer
- *
- * During encoding, some field values may be modified, e.g., a field that measures the size of
- * another field will be set to the appropriate value.
- *
- * @param buf the destination buffer to append encoded data
- * @param pkt the packet to encode
- * @throws PacketEncodeException if the packet is not well formed
- */
- public void encodePacketInto(ENCBUF buf, Packet pkt) throws PacketEncodeException;
-
- /**
- * Obtain the field codec wrapper factory for a given field and annotation
- *
- * @param pkt the packet type being registered
- * @param field the packet field being registered
- * @param annot the annotation currently being processed
- * @return a factory to construct a link in the field codec chain
- */
- public WrapperFactory<ENCBUF, DECBUF> getFactoryForAnnotation(Class<? extends Packet> pkt,
- Field field, Annotation annot);
-
- /**
- * Inject a wrapper into a field's codec chain
- *
- * This action essentially associates two fields. It is most often used when the value of one
- * field controls the decoding, usually by determining the size, count, or type, of another
- * field. In general, the annotation associating two fields is applied to the controlled field.
- * Some attribute of that annotation identifies the controlling field, into which a wrapper must
- * be injected.
- *
- * @param pkt the packet type being registered
- * @param controllingField the field into whose chain to inject the wrapper
- * @param injected the factory providing the wrapper to inject
- * @param controlledField the field whose annotation is injecting the wrapper
- * @param annot the annotation injecting the wrapper
- */
- void injectChain(Class<? extends Packet> pkt, Field controllingField,
- InjectionFactory<ENCBUF, DECBUF> injected, Field controlledField, Annotation annot);
-
- /**
- * Construct a new decode buffer for the given encoded data
- *
- * @param data the encoded data
- * @return the buffer ready to decode the data
- * @throws IOException if there is an issue accessing a device or buffer
- */
- public DECBUF newDecodeBuffer(T data) throws IOException;
-
- /**
- * Construct a new blank encode buffer
- *
- * @return the buffer ready to encode data
- * @throws IOException if there is an issue accessing a device or buffer
- */
- public ENCBUF newEncodeBuffer() throws IOException;
-
- /**
- * Apply a mark to the decode buffer which prevents consumption of data beyond it
- *
- * This is essentially the converse of {@link #measureEncodeSize(Object)}. Both are used in
- * circumstances where one field measures the encoded length of another. This one is used during
- * decode to limit the given field to the measured amount of data.
- *
- * @see #getDecodePosition(Object) regarding "position"
- *
- * @param buf the buffer whose consumption to restrict
- * @param pos the position beyond which data cannot be consumed
- * @return the previous mark
- */
- public int limitDecodeBuffer(DECBUF buf, int pos);
-
- /**
- * Measure the count of elements in an object
- *
- * Counts of collections, arrays, and strings are well understood to mean the size or length.
- * The provided codecs implement this count. If a codec wishes to encode and decode other kinds
- * of "countable" objects, it should override this method.
- *
- * @param obj the object being measured
- * @return the count of elements in the object
- */
- public int measureCount(Object obj);
-
- /**
- * Measure the length of an encoded buffer
- *
- * This is essentially the converse of {@link #limitDecodeBuffer(Object, int)}. Both are used in
- * circumstances where one field measures the encoded length of another. This one is used during
- * encoding to set the value of the controlling field.
- *
- * @see #setEncodePosition(Object, int)} regarding "position"
- *
- * @param buf the buffer containing the encoded data
- * @return the size or length of the data
- */
- public int measureEncodeSize(ENCBUF buf);
-
- /**
- * Measure the length of data remaining in a decode buffer
- *
- * @param buf the buffer containing data to decode
- * @return the size or length of the data remaining
- */
- public int measureDecodeRemaining(DECBUF buf);
-
- /**
- * Copy the contents of one buffer into another immediately following its current contents
- *
- * @param into the destination buffer
- * @param from the source buffer
- * @throws IOException if there is an issue accessing a device or buffer
- */
- public void appendEncoded(ENCBUF into, ENCBUF from) throws IOException;
-
- /**
- * Obtain the position in a decode buffer
- *
- * @param buf the buffer whose position is to be obtained
- * @return the position
- */
- public int getDecodePosition(DECBUF buf);
-
- /**
- * (Re)set the position in a decode buffer
- *
- * "Position" is not strictly defined, though it is usually the position of, e.g., the cursor,
- * as an offset from the start of the buffer. The codec can use whatever definition is most
- * suitable for the decode buffer, so long as that position can be represented by an integer.
- * The same definition must be used by {@link #getDecodePosition(Object)} and
- * {@link #limitDecodeBuffer(Object, int)}. Furthermore, {@link #measureDecodeRemaining(Object)}
- * should return a delta position.
- *
- * @param buf the buffer whose position to set
- * @param pos the position
- */
- public void setDecodePosition(DECBUF buf, int pos);
-
- /**
- * (Re)set the position in an encode buffer
- *
- * "Position" is not strictly defined, though it is usually the position of, e.g., the cursor,
- * as an offset from the start of the buffer. The codec can use whatever definition is most
- * suitable for the encode buffer, so long as that position can be represented by an integer.
- * The same definition must be used by {@link #measureEncodeSize(Object)}, though it should
- * return a delta position.
- *
- * @param buf the buffer whose position to set
- * @param pos the position
- */
- public void setEncodePosition(ENCBUF buf, int pos);
-}
diff --git a/Ghidra/Debug/Framework-AsyncComm/src/main/java/ghidra/comm/packet/codecs/PacketFieldCodec.java b/Ghidra/Debug/Framework-AsyncComm/src/main/java/ghidra/comm/packet/codecs/PacketFieldCodec.java
deleted file mode 100644
index e883979399..0000000000
--- a/Ghidra/Debug/Framework-AsyncComm/src/main/java/ghidra/comm/packet/codecs/PacketFieldCodec.java
+++ /dev/null
@@ -1,58 +0,0 @@
-/* ###
- * 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 ghidra.comm.packet.codecs;
-
-import java.io.IOException;
-import java.lang.reflect.Field;
-
-import ghidra.comm.packet.Packet;
-import ghidra.comm.packet.PacketFactory;
-import ghidra.comm.packet.err.PacketDecodeException;
-import ghidra.comm.packet.err.PacketEncodeException;
-import ghidra.comm.packet.fields.AbstractFieldCodec;
-import ghidra.comm.packet.fields.FieldCodec;
-
-/**
- * The {@link FieldCodec} for encoding sub-packet values
- *
- * This delegates to the given {@link PrimitiveCodec}
- *
- * @param <ENCBUF> the type of temporary buffer used to encode
- * @param <DECBUF> the type of temporary buffer used to decode
- */
-public class PacketFieldCodec<ENCBUF, DECBUF> extends AbstractFieldCodec<ENCBUF, DECBUF, Packet> {
- private final PrimitiveCodec<ENCBUF, DECBUF> codec;
- private final Class<? extends Packet> type;
-
- public PacketFieldCodec(PrimitiveCodec<ENCBUF, DECBUF> codec, Class<? extends Packet> pktType,
- Field field, Class<? extends Packet> type) {
- super(pktType, field);
- this.codec = codec;
- this.type = type;
- }
-
- @Override
- public Packet decodeField(Packet pkt, DECBUF buf, Integer count, PacketFactory factory)
- throws IOException, PacketDecodeException {
- return codec.decodePacket(pkt, field, buf, type, factory);
- }
-
- @Override
- public void encodeField(ENCBUF buf, Packet pkt, Packet val)
- throws IOException, PacketEncodeException {
- codec.encodePacket(buf, field, val);
- }
-}
diff --git a/Ghidra/Debug/Framework-AsyncComm/src/main/java/ghidra/comm/packet/codecs/PrimitiveCodec.java b/Ghidra/Debug/Framework-AsyncComm/src/main/java/ghidra/comm/packet/codecs/PrimitiveCodec.java
deleted file mode 100644
index 3253758815..0000000000
--- a/Ghidra/Debug/Framework-AsyncComm/src/main/java/ghidra/comm/packet/codecs/PrimitiveCodec.java
+++ /dev/null
@@ -1,297 +0,0 @@
-/* ###
- * 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 ghidra.comm.packet.codecs;
-
-import java.io.IOException;
-import java.lang.reflect.Field;
-
-import ghidra.comm.packet.*;
-import ghidra.comm.packet.err.PacketDecodeException;
-import ghidra.comm.packet.err.PacketEncodeException;
-import ghidra.comm.packet.fields.FieldCodec;
-
-/**
- * A codec for all the basic types including primitives, strings, enumerations, and sub-packets
- *
- * This interface is used primarily by {@link AbstractPacketCodec} as a convenience for providing an
- * implementation of {@link FieldCodec} for each of the basic types. It is easier to implement these
- * methods than it is to implement an individual class for each primitive.
- *
- * @param <ENCBUF> the type of the temporary encode buffer
- * @param <DECBUF> the type of the temporary decode buffer
- */
-public interface PrimitiveCodec<ENCBUF, DECBUF> {
- /**
- * Decode a boolean value
- *
- * @param field the field for which the value is decoded
- * @param buf the buffer from which the value is decoded
- * @return the decoded value
- * @throws IOException if there is an issue accessing a device or buffer
- * @throws PacketDecodeException if the packet is not well formed
- */
- boolean decodeBoolean(Field field, DECBUF buf) throws IOException, PacketDecodeException;
-
- /**
- * Decode a byte value
- *
- * @param field the field for which the value is decoded
- * @param buf the buffer from which the value is decoded
- * @return the decoded value
- * @throws IOException if there is an issue accessing a device or buffer
- * @throws PacketDecodeException if the packet is not well formed
- */
- byte decodeByte(Field field, DECBUF buf) throws IOException, PacketDecodeException;
-
- /**
- * Decode a character value
- *
- * @param field the field for which the value is decoded
- * @param buf the buffer from which the value is decoded
- * @return the decoded value
- * @throws IOException if there is an issue accessing a device or buffer
- * @throws PacketDecodeException if the packet is not well formed
- */
- char decodeChar(Field field, DECBUF buf) throws IOException, PacketDecodeException;
-
- /**
- * Decode a short integer value
- *
- * @param field the field for which the value is decoded
- * @param buf the buffer from which the value is decoded
- * @return the decoded value
- * @throws IOException if there is an issue accessing a device or buffer
- * @throws PacketDecodeException if the packet is not well formed
- */
- short decodeShort(Field field, DECBUF buf) throws IOException, PacketDecodeException;
-
- /**
- * Decode an integer value
- *
- * @param field the field for which the value is decoded
- * @param buf the buffer from which the value is decoded
- * @return the decoded value
- * @throws IOException if there is an issue accessing a device or buffer
- * @throws PacketDecodeException if the packet is not well formed
- */
- int decodeInt(Field field, DECBUF buf) throws IOException, PacketDecodeException;
-
- /**
- * Decode a long integer value
- *
- * @param field the field for which the value is decoded
- * @param buf the buffer from which the value is decoded
- * @return the decoded value
- * @throws IOException if there is an issue accessing a device or buffer
- * @throws PacketDecodeException if the packet is not well formed
- */
- long decodeLong(Field field, DECBUF buf) throws IOException, PacketDecodeException;
-
- /**
- * Decode a single-precision float value
- *
- * @param field the field for which the value is decoded
- * @param buf the buffer from which the value is decoded
- * @return the decoded value
- * @throws IOException if there is an issue accessing a device or buffer
- * @throws PacketDecodeException if the packet is not well formed
- */
- float decodeFloat(Field field, DECBUF buf) throws IOException, PacketDecodeException;
-
- /**
- * Decode a double-precision float value
- *
- * @param field the field for which the value is decoded
- * @param buf the buffer from which the value is decoded
- * @return the decoded value
- * @throws IOException if there is an issue accessing a device or buffer
- * @throws PacketDecodeException if the packet is not well formed
- */
- double decodeDouble(Field field, DECBUF buf) throws IOException, PacketDecodeException;
-
- /**
- * Decode an enumeration constant
- *
- * @param field the field for which the value is decoded
- * @param buf the buffer from which the value is decoded
- * @param type the enumeration of values expected
- * @return the decoded value
- * @throws IOException if there is an issue accessing a device or buffer
- * @throws PacketDecodeException if the packet is not well formed
- */
- <E extends Enum<E>> E decodeEnumConstant(Field field, DECBUF buf, Class<E> type)
- throws IOException, PacketDecodeException;
-
- /**
- * Decode a character sequence, e.g., {@link String}
- *
- * @param field the field for which the value is decoded
- * @param buf the buffer from which the value is decoded
- * @param count the number of characters to decode, or null for unlimited
- * @return the decoded value
- * @throws IOException if there is an issue accessing a device or buffer
- * @throws PacketDecodeException if the packet is not well formed
- */
- CharSequence decodeCharSequence(Field field, DECBUF buf, Integer count)
- throws IOException, PacketDecodeException;
-
- /**
- * Decode a packet
- *
- * This is used internally both to decode root packets, as well as to decode packets used as
- * fields in parent packets.
- *
- * @param parent if applicable, the packet containing this packet as a field
- * @param field if applicable, the field of the parent packet
- * @param buf the decode buffer positioned at the packet data
- * @param pktType the type of packet to decode
- * @param factory a factory for instantiating abstract types
- * @return the decoded packet
- * @throws IOException if there is an issue accessing a device or buffer
- * @throws PacketDecodeException if the packet is not well formed
- */
- <P extends Packet> P decodePacket(Packet parent, Field field, DECBUF buf, Class<P> pktType,
- PacketFactory factory) throws IOException, PacketDecodeException;
-
- /**
- * Encode a boolean value
- *
- * @param buf the buffer into which to append the encoded data
- * @param field the field for which the value is encoded
- * @param val the value to encode
- * @throws IOException if there is an issue accessing a device or buffer
- * @throws PacketEncodeException if the packet is not well formed
- */
- void encodeBoolean(ENCBUF buf, Field field, boolean val)
- throws IOException, PacketEncodeException;
-
- /**
- * Encode a byte value
- *
- * @param buf the buffer into which to append the encoded data
- * @param field the field for which the value is encoded
- * @param val the value to encode
- * @throws IOException if there is an issue accessing a device or buffer
- * @throws PacketEncodeException if the packet is not well formed
- */
- void encodeByte(ENCBUF buf, Field field, byte val) throws IOException, PacketEncodeException;
-
- /**
- * Encode a character value
- *
- * @param buf the buffer into which to append the encoded data
- * @param field the field for which the value is encoded
- * @param val the value to encode
- * @throws IOException if there is an issue accessing a device or buffer
- * @throws PacketEncodeException if the packet is not well formed
- */
- void encodeChar(ENCBUF buf, Field field, char val) throws IOException, PacketEncodeException;
-
- /**
- * Encode a short integer value
- *
- * @param buf the buffer into which to append the encoded data
- * @param field the field for which the value is encoded
- * @param val the value to encode
- * @throws IOException if there is an issue accessing a device or buffer
- * @throws PacketEncodeException if the packet is not well formed
- */
- void encodeShort(ENCBUF buf, Field field, short val) throws IOException, PacketEncodeException;
-
- /**
- * Encode an integer value
- *
- * @param buf the buffer into which to append the encoded data
- * @param field the field for which the value is encoded
- * @param val the value to encode
- * @throws IOException if there is an issue accessing a device or buffer
- * @throws PacketEncodeException if the packet is not well formed
- */
- void encodeInt(ENCBUF buf, Field field, int val) throws IOException, PacketEncodeException;
-
- /**
- * Encode a long integer value
- *
- * @param buf the buffer into which to append the encoded data
- * @param field the field for which the value is encoded
- * @param val the value to encode
- * @throws IOException if there is an issue accessing a device or buffer
- * @throws PacketEncodeException if the packet is not well formed
- */
- void encodeLong(ENCBUF buf, Field field, long val) throws IOException, PacketEncodeException;
-
- /**
- * Encode a single-precision float value
- *
- * @param buf the buffer into which to append the encoded data
- * @param field the field for which the value is encoded
- * @param val the value to encode
- * @throws IOException if there is an issue accessing a device or buffer
- * @throws PacketEncodeException if the packet is not well formed
- */
- void encodeFloat(ENCBUF buf, Field field, float val) throws IOException, PacketEncodeException;
-
- /**
- * Encode a double-precision float value
- *
- * @param buf the buffer into which to append the encoded data
- * @param field the field for which the value is encoded
- * @param val the value to encode
- * @throws IOException if there is an issue accessing a device or buffer
- * @throws PacketEncodeException if the packet is not well formed
- */
- void encodeDouble(ENCBUF buf, Field field, double val)
- throws IOException, PacketEncodeException;
-
- /**
- * Encode an enumeration constant
- *
- * @param buf the buffer into which to append the encoded data
- * @param field the field for which the value is encoded
- * @param val the value to encode
- * @throws IOException if there is an issue accessing a device or buffer
- * @throws PacketEncodeException if the packet is not well formed
- */
- public void encodeEnumConstant(ENCBUF buf, Field field, Enum<?> val)
- throws IOException, PacketEncodeException;
-
- /**
- * Encode a character sequence, e.g., {@link String}
- *
- * @param buf the buffer into which to append the encoded data
- * @param field the field for which the value is encoded
- * @param val the value to encode
- * @throws IOException if there is an issue accessing a device or buffer
- * @throws PacketEncodeException if the packet is not well formed
- */
- void encodeCharSequence(ENCBUF buf, Field field, CharSequence val)
- throws IOException, PacketEncodeException;
-
- /**
- * Encode a packet
- *
- * This is used internally both to encode root packets, as well as to encode packets used as
- * fields in parent packets.
- *
- * @param buf the buffer into which to append the encoded data
- * @param field if applicable, the field of the parent packet
- * @param val the packet to encode
- * @throws IOException if there is an issue accessing a device or buffer
- * @throws PacketEncodeException if the packet is not well formed
- */
- void encodePacket(ENCBUF buf, Field field, Packet val)
- throws IOException, PacketEncodeException;
-}
diff --git a/Ghidra/Debug/Framework-AsyncComm/src/main/java/ghidra/comm/packet/codecs/ShortFieldCodec.java b/Ghidra/Debug/Framework-AsyncComm/src/main/java/ghidra/comm/packet/codecs/ShortFieldCodec.java
deleted file mode 100644
index b0ba33448d..0000000000
--- a/Ghidra/Debug/Framework-AsyncComm/src/main/java/ghidra/comm/packet/codecs/ShortFieldCodec.java
+++ /dev/null
@@ -1,56 +0,0 @@
-/* ###
- * 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 ghidra.comm.packet.codecs;
-
-import java.io.IOException;
-import java.lang.reflect.Field;
-
-import ghidra.comm.packet.Packet;
-import ghidra.comm.packet.PacketFactory;
-import ghidra.comm.packet.err.PacketDecodeException;
-import ghidra.comm.packet.err.PacketEncodeException;
-import ghidra.comm.packet.fields.AbstractFieldCodec;
-import ghidra.comm.packet.fields.FieldCodec;
-
-/**
- * The {@link FieldCodec} for encoding short values
- *
- * This delegates to the given {@link PrimitiveCodec}
- *
- * @param <ENCBUF> the type of temporary buffer used to encode
- * @param <DECBUF> the type of temporary buffer used to decode
- */
-public class ShortFieldCodec<ENCBUF, DECBUF> extends AbstractFieldCodec<ENCBUF, DECBUF, Short> {
- private final PrimitiveCodec<ENCBUF, DECBUF> codec;
-
- public ShortFieldCodec(PrimitiveCodec<ENCBUF, DECBUF> codec, Class<? extends Packet> pktType,
- Field field) {
- super(pktType, field);
- this.codec = codec;
- }
-
- @Override
- public Short decodeField(Packet pkt, DECBUF buf, Integer count, PacketFactory factory)
- throws IOException, PacketDecodeException {
- return codec.decodeShort(field, buf);
- }
-
- @Override
- public void encodeField(ENCBUF buf, Packet pkt, Short val)
- throws IOException, PacketEncodeException {
- codec.encodeShort(buf, field, val);
- }
-}
diff --git a/Ghidra/Debug/Framework-AsyncComm/src/main/java/ghidra/comm/packet/err/AnnotatedFieldOrderingException.java b/Ghidra/Debug/Framework-AsyncComm/src/main/java/ghidra/comm/packet/err/AnnotatedFieldOrderingException.java
deleted file mode 100644
index 06b2d12dc0..0000000000
--- a/Ghidra/Debug/Framework-AsyncComm/src/main/java/ghidra/comm/packet/err/AnnotatedFieldOrderingException.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/* ###
- * 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 ghidra.comm.packet.err;
-
-import java.lang.annotation.Annotation;
-import java.lang.reflect.Field;
-
-import ghidra.comm.packet.Packet;
-
-/**
- * Occurs when a referenced field follows the referring field
- *
- * For example, when a length field comes after the field whose length it gives, this exception will
- * be thrown upon packet registration. Consider the packet design:
- *
- * <pre>
- * +-------//---------+--------------+
- * | data (len bytes) | len (1 byte) |
- * +------------------+--------------+
- * </pre>
- *
- * This cannot happen, because during decoding, the length must be decoded before decoding the field
- * whose length it gives.
- */
-public class AnnotatedFieldOrderingException extends PacketAnnotationException {
- public AnnotatedFieldOrderingException(Class<? extends Packet> packet, Field field,
- Annotation annotation, String msg) {
- super(packet, field, annotation, msg);
- }
-}
diff --git a/Ghidra/Debug/Framework-AsyncComm/src/main/java/ghidra/comm/packet/err/FieldOrderingException.java b/Ghidra/Debug/Framework-AsyncComm/src/main/java/ghidra/comm/packet/err/FieldOrderingException.java
deleted file mode 100644
index 6e8137395a..0000000000
--- a/Ghidra/Debug/Framework-AsyncComm/src/main/java/ghidra/comm/packet/err/FieldOrderingException.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/* ###
- * 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 ghidra.comm.packet.err;
-
-import ghidra.comm.packet.Packet;
-import ghidra.comm.packet.fields.PacketField;
-import ghidra.graph.algo.SorterException;
-
-/**
- * Occurs when the field order is not fully specified or circular
- *
- * When extending another packet type, added fields must be ordered explicitly with respect to the
- * fields of the super type(s). This is accomplished using the {@link PacketField#before()} and
- * {@link PacketField#after()} attributes. Fields declared within the same class are assumed to be
- * in declaration order. Once applied, these rules form a graph and a topological sort is attempted.
- * The sort could fail if the rules form a cycle, or if multiple orders are possible without
- * breaking one or more rules. If the sort fails, this exception is thrown upon packet registration.
- */
-public class FieldOrderingException extends PacketDeclarationException {
- public FieldOrderingException(Class<? extends Packet> packet, String msg,
- SorterException cause) {
- super(packet, msg, cause);
- }
-}
diff --git a/Ghidra/Debug/Framework-AsyncComm/src/main/java/ghidra/comm/packet/err/InvalidFieldModifiersException.java b/Ghidra/Debug/Framework-AsyncComm/src/main/java/ghidra/comm/packet/err/InvalidFieldModifiersException.java
deleted file mode 100644
index 3335559212..0000000000
--- a/Ghidra/Debug/Framework-AsyncComm/src/main/java/ghidra/comm/packet/err/InvalidFieldModifiersException.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/* ###
- * 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 ghidra.comm.packet.err;
-
-import java.lang.annotation.Annotation;
-import java.lang.reflect.Field;
-
-import ghidra.comm.packet.Packet;
-import ghidra.comm.packet.fields.PacketField;
-
-/**
- * Occurs if a field annotated with {@link PacketField} has incompatible modifiers
- *
- * Packet fields must be public so that the codec can access them. A static field must also be a
- * final field. There are few occasions for a packet type to contain static data, and a codec should
- * never interact with such data directly. If incompatible modifiers are found, this exception is
- * thrown upon packet registration.
- */
-public class InvalidFieldModifiersException extends PacketAnnotationException {
- public InvalidFieldModifiersException(Class<? extends Packet> packet, Field field,
- Annotation annotation, String msg) {
- super(packet, field, annotation, msg);
- }
-}
diff --git a/Ghidra/Debug/Framework-AsyncComm/src/main/java/ghidra/comm/packet/err/InvalidFieldNameException.java b/Ghidra/Debug/Framework-AsyncComm/src/main/java/ghidra/comm/packet/err/InvalidFieldNameException.java
deleted file mode 100644
index 30ff3591da..0000000000
--- a/Ghidra/Debug/Framework-AsyncComm/src/main/java/ghidra/comm/packet/err/InvalidFieldNameException.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/* ###
- * 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 ghidra.comm.packet.err;
-
-import java.lang.annotation.Annotation;
-import java.lang.reflect.Field;
-
-import ghidra.comm.packet.Packet;
-import ghidra.comm.packet.fields.PacketField;
-
-/**
- * Occurs when a packet annotation refers to a non-existent packet field
- *
- * Some annotations refer to other fields by name. The name is verified during packet registration.
- * If the field does not exist, or the field is not annotated by {@link PacketField}, then the name
- * is invalid and this exception is thrown.
- */
-public class InvalidFieldNameException extends PacketAnnotationException {
- public InvalidFieldNameException(Class<? extends Packet> pktType, Field field,
- Annotation annotation, String msg, Throwable cause) {
- super(pktType, field, annotation, msg, cause);
- }
-
- public InvalidFieldNameException(Class<? extends Packet> pktType, Field field,
- Annotation annotation, String msg) {
- super(pktType, field, annotation, msg);
- }
-}
diff --git a/Ghidra/Debug/Framework-AsyncComm/src/main/java/ghidra/comm/packet/err/InvalidMethodNameException.java b/Ghidra/Debug/Framework-AsyncComm/src/main/java/ghidra/comm/packet/err/InvalidMethodNameException.java
deleted file mode 100644
index ecc7da3b89..0000000000
--- a/Ghidra/Debug/Framework-AsyncComm/src/main/java/ghidra/comm/packet/err/InvalidMethodNameException.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/* ###
- * 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 ghidra.comm.packet.err;
-
-import java.lang.annotation.Annotation;
-import java.lang.reflect.Field;
-
-import ghidra.comm.packet.Packet;
-
-/**
- * Occurs when a packet annotation refers to a non-existent method
- *
- * An annotation may refer to a method by name. The name is verified during packet registration. If
- * the method does not exist, then the name is invalid and this exception is thrown.
- */
-public class InvalidMethodNameException extends PacketAnnotationException {
- public InvalidMethodNameException(Class<? extends Packet> packet, Field field,
- Annotation annotation, String msg) {
- super(packet, field, annotation, msg);
- }
-
- public InvalidMethodNameException(Class<? extends Packet> packet, Field field,
- Annotation annotation, String msg, Throwable cause) {
- super(packet, field, annotation, msg, cause);
- }
-}
diff --git a/Ghidra/Debug/Framework-AsyncComm/src/main/java/ghidra/comm/packet/err/InvalidPacketException.java b/Ghidra/Debug/Framework-AsyncComm/src/main/java/ghidra/comm/packet/err/InvalidPacketException.java
deleted file mode 100644
index 320142155a..0000000000
--- a/Ghidra/Debug/Framework-AsyncComm/src/main/java/ghidra/comm/packet/err/InvalidPacketException.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/* ###
- * 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 ghidra.comm.packet.err;
-
-import ghidra.comm.packet.binary.NullTerminated;
-
-/**
- * Occurs during decode when a packet field does not conform to the expected format
- *
- * For example, when using a text codec and decoding a byte, only digits are valid, and they must
- * specify a number from 0 to 255. Or, when using a binary codec, a field annotated with
- * {@link NullTerminated} requires a null terminator.
- */
-public class InvalidPacketException extends PacketDecodeException {
- public InvalidPacketException(String msg, Throwable cause) {
- super(msg, cause);
- }
-
- public InvalidPacketException(String msg) {
- super(msg);
- }
-}
diff --git a/Ghidra/Debug/Framework-AsyncComm/src/main/java/ghidra/comm/packet/err/PacketAnnotationException.java b/Ghidra/Debug/Framework-AsyncComm/src/main/java/ghidra/comm/packet/err/PacketAnnotationException.java
deleted file mode 100644
index ee00329425..0000000000
--- a/Ghidra/Debug/Framework-AsyncComm/src/main/java/ghidra/comm/packet/err/PacketAnnotationException.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/* ###
- * 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 ghidra.comm.packet.err;
-
-import java.lang.annotation.Annotation;
-import java.lang.reflect.Field;
-
-import ghidra.comm.packet.Packet;
-
-/**
- * Occurs when a packet is declared with invalid or erroneous annotations
- */
-public class PacketAnnotationException extends PacketFieldDeclarationException {
- private final Annotation annotation;
-
- public PacketAnnotationException(Class<? extends Packet> packet, Field field,
- Annotation annotation, String msg, Throwable cause) {
- super(packet, field, "Cannot apply " + annotation + ": " + msg, cause);
- this.annotation = annotation;
- }
-
- public PacketAnnotationException(Class<? extends Packet> packet, Field field,
- Annotation annotation, String msg) {
- this(packet, field, annotation, msg, null);
- }
-
- public Annotation getAnnotation() {
- return annotation;
- }
-}
diff --git a/Ghidra/Debug/Framework-AsyncComm/src/main/java/ghidra/comm/packet/err/PacketDeclarationException.java b/Ghidra/Debug/Framework-AsyncComm/src/main/java/ghidra/comm/packet/err/PacketDeclarationException.java
deleted file mode 100644
index 27a4a6a75d..0000000000
--- a/Ghidra/Debug/Framework-AsyncComm/src/main/java/ghidra/comm/packet/err/PacketDeclarationException.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/* ###
- * 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 ghidra.comm.packet.err;
-
-import ghidra.comm.packet.Packet;
-
-/**
- * Occurs when a packet class is declared incorrectly, i.e., missing a public default constructor
- */
-public class PacketDeclarationException extends RuntimeException {
- private Class<? extends Packet> packet;
-
- public PacketDeclarationException(Class<? extends Packet> packet, String msg, Throwable cause) {
- super("Problem in " + packet + ": " + msg, cause);
- this.packet = packet;
- }
-
- public PacketDeclarationException(Class<? extends Packet> packet, String msg) {
- this(packet, msg, null);
- }
-
- public Class<? extends Packet> getPacket() {
- return packet;
- }
-}
diff --git a/Ghidra/Debug/Framework-AsyncComm/src/main/java/ghidra/comm/packet/err/PacketDecodeException.java b/Ghidra/Debug/Framework-AsyncComm/src/main/java/ghidra/comm/packet/err/PacketDecodeException.java
deleted file mode 100644
index 6882bf7e17..0000000000
--- a/Ghidra/Debug/Framework-AsyncComm/src/main/java/ghidra/comm/packet/err/PacketDecodeException.java
+++ /dev/null
@@ -1,29 +0,0 @@
-/* ###
- * 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 ghidra.comm.packet.err;
-
-/**
- * Occurs during decoding when packet data does not conform to the expected type
- */
-public class PacketDecodeException extends Exception {
- public PacketDecodeException(String msg, Throwable cause) {
- super(msg, cause);
- }
-
- public PacketDecodeException(String msg) {
- super(msg);
- }
-}
diff --git a/Ghidra/Debug/Framework-AsyncComm/src/main/java/ghidra/comm/packet/err/PacketEncodeException.java b/Ghidra/Debug/Framework-AsyncComm/src/main/java/ghidra/comm/packet/err/PacketEncodeException.java
deleted file mode 100644
index 90d83c1933..0000000000
--- a/Ghidra/Debug/Framework-AsyncComm/src/main/java/ghidra/comm/packet/err/PacketEncodeException.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/* ###
- * 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 ghidra.comm.packet.err;
-
-/**
- * Occurs during encode when the given packet cannot be encoded according to the type's definition
- *
- * For example, a string field may be limited to a certain length. Or, for dynamically-typed fields,
- * the given value must be of a supported type.
- */
-public class PacketEncodeException extends Exception {
- public PacketEncodeException(String msg, Throwable cause) {
- super(msg, cause);
- }
-
- public PacketEncodeException(String msg) {
- super(msg);
- }
-}
diff --git a/Ghidra/Debug/Framework-AsyncComm/src/main/java/ghidra/comm/packet/err/PacketFieldDeclarationException.java b/Ghidra/Debug/Framework-AsyncComm/src/main/java/ghidra/comm/packet/err/PacketFieldDeclarationException.java
deleted file mode 100644
index ec69d621dc..0000000000
--- a/Ghidra/Debug/Framework-AsyncComm/src/main/java/ghidra/comm/packet/err/PacketFieldDeclarationException.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/* ###
- * 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 ghidra.comm.packet.err;
-
-import java.lang.reflect.Field;
-
-import ghidra.comm.packet.Packet;
-
-/**
- * Occurs when the specified annotations are not compatible with the codec
- *
- * Each annotation usually corresponds to a transformation, which may modify the type of the field
- * during the encode or decode process. Each pair of neighboring transformations must negotiate that
- * type, and the final transformation must negotiate that type with the codec. If this process
- * fails, this exception is thrown upon packet registration.
- */
-public class PacketFieldDeclarationException extends PacketDeclarationException {
- private final Field field;
-
- public PacketFieldDeclarationException(Class<? extends Packet> packet, Field field, String msg,
- Throwable cause) {
- super(packet, "With field " + field.getName() + ": " + msg, cause);
- this.field = field;
- }
-
- public PacketFieldDeclarationException(Class<? extends Packet> packet, Field field,
- String msg) {
- this(packet, field, msg, null);
- }
-
- /**
- * Get the field whose transformation types could not be negotiated
- *
- * @return the field
- */
- public Field getField() {
- return field;
- }
-}
diff --git a/Ghidra/Debug/Framework-AsyncComm/src/main/java/ghidra/comm/packet/err/PacketFieldValueMismatchException.java b/Ghidra/Debug/Framework-AsyncComm/src/main/java/ghidra/comm/packet/err/PacketFieldValueMismatchException.java
deleted file mode 100644
index 6c70aa7421..0000000000
--- a/Ghidra/Debug/Framework-AsyncComm/src/main/java/ghidra/comm/packet/err/PacketFieldValueMismatchException.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/* ###
- * 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 ghidra.comm.packet.err;
-
-import java.lang.reflect.Field;
-import java.util.List;
-
-import ghidra.comm.packet.annot.TypedByLookahead;
-import ghidra.comm.packet.fields.PacketField;
-
-/**
- * Occurs during decode when a constant field does not match the decoded value
- *
- * Static final fields may be annotated with {@link PacketField}, causing them to be encoded and
- * decoded the same as any other field, with two exceptions. When decoding final fields with
- * countable elements, the codec expects to decode the same number of elements. If the decoded value
- * does not match the constant value, the packet is considered malformed and this exception is
- * thrown.
- *
- * This exception differs from {@link InvalidPacketException} in that it deals in field values, not
- * in encoding formats. It is also used by {@link TypedByLookahead} to distinguish sub-packet types.
- */
-public class PacketFieldValueMismatchException extends PacketDecodeException {
- public PacketFieldValueMismatchException(Field field, Object req, Object dec) {
- super(field + " must decode with value " + req + ". Got " + dec);
- }
-
- public PacketFieldValueMismatchException(Field field, List<?> req, Object dec) {
- super(field + " must decode with a value from " + req + ". Got " + dec);
- }
-}
diff --git a/Ghidra/Debug/Framework-AsyncComm/src/main/java/ghidra/comm/packet/fields/AbstractFieldCodec.java b/Ghidra/Debug/Framework-AsyncComm/src/main/java/ghidra/comm/packet/fields/AbstractFieldCodec.java
deleted file mode 100644
index c3c3d03a04..0000000000
--- a/Ghidra/Debug/Framework-AsyncComm/src/main/java/ghidra/comm/packet/fields/AbstractFieldCodec.java
+++ /dev/null
@@ -1,115 +0,0 @@
-/* ###
- * 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 ghidra.comm.packet.fields;
-
-import java.lang.reflect.Field;
-
-import ghidra.comm.packet.Packet;
-
-/**
- * An abstract implementation of {@link FieldCodec} associated with a registered packet type and
- * field
- *
- * @param <ENCBUF> the type of temporary buffer used to encode
- * @param <DECBUF> the type of temporary buffer used to decode
- * @param <T> the type linking this codec to the next codec down the chain, or to the annotated
- * field
- */
-public abstract class AbstractFieldCodec<ENCBUF, DECBUF, T>
- implements FieldCodec<ENCBUF, DECBUF, T> {
-
- /**
- * Assuming val has an integral value, get it
- *
- * @param val an object of type {@link Byte}, {@link Short}, {@link Integer}, or {@link Long}
- * @return the value as a {@code long}
- */
- public static long getIntegralValue(Object val) {
- if (val instanceof Byte) {
- return (Byte) val;
- }
- else if (val instanceof Short) {
- return (Short) val;
- }
- else if (val instanceof Integer) {
- return (Integer) val;
- }
- else if (val instanceof Long) {
- return (Long) val;
- }
- throw new IllegalArgumentException(val + " is not an integral type");
- }
-
- /**
- * Convert a long to {@link Byte}, {@link Short}, {@link Integer}, or {@link Long}
- *
- * @param type the desired type
- * @param val the value
- * @return the value as the desired type, if possible
- */
- @SuppressWarnings("unchecked")
- public static <T> T getIntegralOfType(Class<T> type, long val) {
- if (type == byte.class || Byte.class.isAssignableFrom(type)) {
- return (T) Byte.valueOf((byte) val);
- }
- else if (type == short.class || Short.class.isAssignableFrom(type)) {
- return (T) Short.valueOf((short) val);
- }
- else if (type == int.class || Integer.class.isAssignableFrom(type)) {
- return (T) Integer.valueOf((int) val);
- }
- else if (type == long.class || Long.class.isAssignableFrom(type)) {
- return (T) Long.valueOf(val);
- }
- throw new IllegalArgumentException(type + " is not an integral type");
- }
-
- /**
- * Check if a type is {@link Byte}, {@link Short}, {@link Integer}, or {@link Long}
- *
- * @param type the type
- * @return true, if the type represents an integral value
- */
- public static boolean isIntegralType(Class<?> type) {
- if (type == byte.class || Byte.class.isAssignableFrom(type)) {
- return true;
- }
- else if (type == short.class || Short.class.isAssignableFrom(type)) {
- return true;
- }
- else if (type == int.class || Integer.class.isAssignableFrom(type)) {
- return true;
- }
- else if (type == long.class || Long.class.isAssignableFrom(type)) {
- return true;
- }
- return false;
- }
-
- protected final Class<? extends Packet> pktType;
- protected final Field field;
-
- /**
- * Construct a new {@code AbstractFieldCodec}
- *
- * @param pktType the packet type with which this field codec is registered
- * @param field the field in whose chain this field codec resides
- */
- public AbstractFieldCodec(Class<? extends Packet> pktType, Field field) {
- this.pktType = pktType;
- this.field = field;
- }
-}
diff --git a/Ghidra/Debug/Framework-AsyncComm/src/main/java/ghidra/comm/packet/fields/AbstractFieldCodecFactory.java b/Ghidra/Debug/Framework-AsyncComm/src/main/java/ghidra/comm/packet/fields/AbstractFieldCodecFactory.java
deleted file mode 100644
index 4acc8104c8..0000000000
--- a/Ghidra/Debug/Framework-AsyncComm/src/main/java/ghidra/comm/packet/fields/AbstractFieldCodecFactory.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/* ###
- * 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 ghidra.comm.packet.fields;
-
-import static ghidra.comm.packet.codecs.PacketCodecInternal.getTypeParameterRaw;
-
-/**
- * A partial implementation of {@link FieldCodecFactory}.
- *
- * This provides default implementations for {@link #getEncodingBufferClass()} and
- * {@link #getDecodingBufferClass()} using reflection of the type parameters.
- *
- * @param <ENCBUF> the type of temporary buffer used to encode
- * @param <DECBUF> the type of temporary buffer used to decode
- */
-public abstract class AbstractFieldCodecFactory<ENCBUF, DECBUF>
- implements FieldCodecFactory<ENCBUF, DECBUF> {
- @SuppressWarnings("unchecked")
- @Override
- public Class<? extends ENCBUF> getEncodingBufferClass() {
- Class<? extends ENCBUF> type =
- (Class<? extends ENCBUF>) getTypeParameterRaw(this.getClass(),
- AbstractFieldCodecFactory.class, "ENCBUF");
- if (type == null) {
- return (Class<? extends ENCBUF>) Object.class;
- }
- return type;
- }
-
- @SuppressWarnings("unchecked")
- @Override
- public Class<? extends DECBUF> getDecodingBufferClass() {
- Class<? extends DECBUF> type =
- (Class<? extends DECBUF>) getTypeParameterRaw(this.getClass(),
- AbstractFieldCodecFactory.class, "DECBUF");
- if (type == null) {
- return (Class<? extends DECBUF>) Object.class;
- }
- return type;
- }
-}
diff --git a/Ghidra/Debug/Framework-AsyncComm/src/main/java/ghidra/comm/packet/fields/AbstractWrapperFactory.java b/Ghidra/Debug/Framework-AsyncComm/src/main/java/ghidra/comm/packet/fields/AbstractWrapperFactory.java
deleted file mode 100644
index 40beeeb90e..0000000000
--- a/Ghidra/Debug/Framework-AsyncComm/src/main/java/ghidra/comm/packet/fields/AbstractWrapperFactory.java
+++ /dev/null
@@ -1,27 +0,0 @@
-/* ###
- * 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 ghidra.comm.packet.fields;
-
-/**
- * A partial implementation of {@link WrapperFactory}
- *
- * @param <ENCBUF> the type of temporary buffer used to encode
- * @param <DECBUF> the type of temporary buffer used to decode
- */
-public abstract class AbstractWrapperFactory<ENCBUF, DECBUF> extends
- AbstractFieldCodecFactory<ENCBUF, DECBUF> implements WrapperFactory<ENCBUF, DECBUF> {
- // Nothing here. This just combines AbstractFieldCodecFactory with WrapperFactory
-}
diff --git a/Ghidra/Debug/Framework-AsyncComm/src/main/java/ghidra/comm/packet/fields/FieldCodec.java b/Ghidra/Debug/Framework-AsyncComm/src/main/java/ghidra/comm/packet/fields/FieldCodec.java
deleted file mode 100644
index 833bd63cdd..0000000000
--- a/Ghidra/Debug/Framework-AsyncComm/src/main/java/ghidra/comm/packet/fields/FieldCodec.java
+++ /dev/null
@@ -1,67 +0,0 @@
-/* ###
- * 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 ghidra.comm.packet.fields;
-
-import java.io.IOException;
-
-import ghidra.comm.packet.*;
-import ghidra.comm.packet.err.PacketDecodeException;
-import ghidra.comm.packet.err.PacketEncodeException;
-
-/**
- * A codec to encode fields of a particular type
- *
- * This may be provided by the packet codec, in which case it's most likely a primitive field codec,
- * i.e., at the top of the chain. Primitive field codecs actually encode the given data into the
- * final output buffer, or decode data from the input buffer. Non-primitive field codecs -- those
- * found further down the chain -- transform or process the data as it passes on to the next field
- * codec.
- *
- * @see AbstractPacketCodec
- *
- * @param <ENCBUF> the type of temporary buffer used to encode
- * @param <DECBUF> the type of temporary buffer used to decode
- * @param <T> the type linking this codec to the next codec down the chain, or to the annotated
- * field
- */
-public interface FieldCodec<ENCBUF, DECBUF, T> {
- /**
- * Decode a value from a buffer
- *
- * @param pkt the packet currently being decoded
- * @param buf the buffer from which the value is decoded
- * @param count for arrays and collections, the number of elements to decode, or {@code null}
- * for unlimited
- * @param factory a packet factory, usually implementing a particular version of the protocol
- * @return the decoded value
- * @throws IOException if there is an issue accessing a device or buffer
- * @throws PacketDecodeException if the packet is not well formed
- */
- public T decodeField(Packet pkt, DECBUF buf, Integer count, PacketFactory factory)
- throws IOException, PacketDecodeException;
-
- /**
- * Encode a value into a buffer
- *
- * @param buf the buffer into which to append the encoded data
- * @param pkt the packet currently being encoded
- * @param val the value to encode
- * @throws IOException if there is an issue accessing a device or buffer
- * @throws PacketEncodeException if the packet is not well formed
- */
- public void encodeField(ENCBUF buf, Packet pkt, T val)
- throws IOException, PacketEncodeException;
-}
diff --git a/Ghidra/Debug/Framework-AsyncComm/src/main/java/ghidra/comm/packet/fields/FieldCodecFactory.java b/Ghidra/Debug/Framework-AsyncComm/src/main/java/ghidra/comm/packet/fields/FieldCodecFactory.java
deleted file mode 100644
index 5fa946fa1f..0000000000
--- a/Ghidra/Debug/Framework-AsyncComm/src/main/java/ghidra/comm/packet/fields/FieldCodecFactory.java
+++ /dev/null
@@ -1,106 +0,0 @@
-/* ###
- * 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 ghidra.comm.packet.fields;
-
-import java.lang.reflect.Field;
-import java.util.Deque;
-
-import ghidra.comm.packet.AbstractPacketCodec;
-import ghidra.comm.packet.Packet;
-import ghidra.comm.packet.codecs.PacketCodecInternal;
-import ghidra.comm.packet.err.PacketFieldDeclarationException;
-
-/**
- * A factory of {@link FieldCodec}s
- *
- * More than likely, this interface is implemented by extending {@link AbstractPacketCodec} or
- * {@link AbstractWrapperFactory}. During packet registration, these are stored in lists called
- * "chains." Each factory may request a {@link FieldCodec} for a particular type from the next
- * factory up the chain. If each factory can provide one, then the type of the field is successfully
- * linked to the primitive field codec, which encodes or decodes the value in the buffer.
- *
- * @see AbstractPacketCodec
- *
- * @param <ENCBUF> the type of temporary buffer used to encode
- * @param <DECBUF> the type of temporary buffer used to decode
- */
-public interface FieldCodecFactory<ENCBUF, DECBUF> {
-
- /**
- * The method used by packet codecs and wrapper factories to obtain a field codec
- *
- * For packet codecs, this obtains the field codec at the bottom of the chain, which may be the
- * only link in the chain. For wrapper factories, this obtains the field codec from the next
- * factory up the chain. The last (top-most) field codec will be the primitive one. In summary,
- * this takes a chain of field codec factories, given as a {@link Deque}, and recursively
- * constructs a chain of field codecs. The returned {@link FieldCodec} keeps a reference to the
- * next field codec up the resolved chain, if applicable.
- *
- * @see #getFieldCodecForType(Class, Field, Class)
- * @see WrapperFactory#getWrappedFieldCodecForType(Class, Field, Class, PacketCodecInternal,
- * Deque)
- *
- * @param pktType the packet type being registered
- * @param field the field being registered
- * @param fldType the type requested from the next factory down the chain
- * @param codec the packet codec requesting the field codec
- * @param chain the factories remaining in the chain, the next one up being at index 0
- * @return the constructed field codec chain
- */
- public static <ENCBUF, DECBUF, T> FieldCodec<ENCBUF, DECBUF, T> buildChainForType(
- Class<? extends Packet> pktType, Field field, Class<? extends T> fldType,
- PacketCodecInternal<?, ENCBUF, DECBUF> codec,
- Deque<FieldCodecFactory<ENCBUF, DECBUF>> chain) {
- FieldCodecFactory<ENCBUF, DECBUF> next = chain.pop();
- FieldCodec<ENCBUF, DECBUF, T> result = null;
- if (next instanceof WrapperFactory) {
- WrapperFactory<ENCBUF, DECBUF> wrap = (WrapperFactory<ENCBUF, DECBUF>) next;
- result = wrap.getWrappedFieldCodecForType(pktType, field, fldType, codec, chain);
- }
- else if (!chain.isEmpty()) {
- throw new AssertionError("INTERNAL: Chain is not empty, yet");
- }
- else if (next instanceof PrimitiveFactory) {
- PrimitiveFactory<ENCBUF, DECBUF> primitive = (PrimitiveFactory<ENCBUF, DECBUF>) next;
- result = primitive.getFieldCodecForType(pktType, field, fldType);
- }
- if (result == null) {
- throw new PacketFieldDeclarationException(pktType, field,
- next + " cannot provide encoder for " + fldType);
- }
- return result;
- }
-
- /**
- * If this factory only supports a certain decode buffer class, return it
- *
- * The default implementation provided by {@link AbstractFieldCodecFactory} examines the type
- * variables and returns the appropriate value automatically.
- *
- * @return the supported decode buffer class, or {@code null} if universal
- */
- public Class<? extends DECBUF> getDecodingBufferClass();
-
- /**
- * If this factory only supports a certain encode buffer class, return it
- *
- * The default implementation provided by {@link AbstractFieldCodecFactory} examines the type
- * variables and returns the appropriate value automatically.
- *
- * @return the supported encode buffer class, or {@code null} if universal
- */
- public Class<? extends ENCBUF> getEncodingBufferClass();
-}
diff --git a/Ghidra/Debug/Framework-AsyncComm/src/main/java/ghidra/comm/packet/fields/ImplementedBy.java b/Ghidra/Debug/Framework-AsyncComm/src/main/java/ghidra/comm/packet/fields/ImplementedBy.java
deleted file mode 100644
index a3d7b793db..0000000000
--- a/Ghidra/Debug/Framework-AsyncComm/src/main/java/ghidra/comm/packet/fields/ImplementedBy.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/* ###
- * 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 ghidra.comm.packet.fields;
-
-import java.lang.annotation.*;
-
-/**
- * An annotation specifying a universal implementation of a packet annotation
- *
- * Some packet annotations can be applied regardless of the codec. Others are only applicable to
- * certain codecs. The codec may override any universal implementation.
- */
-@Retention(RetentionPolicy.RUNTIME)
-@Target(ElementType.ANNOTATION_TYPE)
-public @interface ImplementedBy {
- @SuppressWarnings("rawtypes")
- Class<? extends WrapperFactory> value();
-}
diff --git a/Ghidra/Debug/Framework-AsyncComm/src/main/java/ghidra/comm/packet/fields/InjectionFactory.java b/Ghidra/Debug/Framework-AsyncComm/src/main/java/ghidra/comm/packet/fields/InjectionFactory.java
deleted file mode 100644
index 94ef552b34..0000000000
--- a/Ghidra/Debug/Framework-AsyncComm/src/main/java/ghidra/comm/packet/fields/InjectionFactory.java
+++ /dev/null
@@ -1,29 +0,0 @@
-/* ###
- * 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 ghidra.comm.packet.fields;
-
-/**
- * A special factory used to inject a {@link FieldCodec} into another chain
- *
- * This interface does not introduce any methods, but it ensures that only factories meant for
- * injection are in fact used for injection.
- *
- * @param <ENCBUF> the type of temporary buffer used to encode
- * @param <DECBUF> the type of temporary buffer used to decode
- */
-public interface InjectionFactory<ENCBUF, DECBUF> extends WrapperFactory<ENCBUF, DECBUF> {
- // A type placeholder
-}
diff --git a/Ghidra/Debug/Framework-AsyncComm/src/main/java/ghidra/comm/packet/fields/PacketField.java b/Ghidra/Debug/Framework-AsyncComm/src/main/java/ghidra/comm/packet/fields/PacketField.java
deleted file mode 100644
index e0a657bc50..0000000000
--- a/Ghidra/Debug/Framework-AsyncComm/src/main/java/ghidra/comm/packet/fields/PacketField.java
+++ /dev/null
@@ -1,75 +0,0 @@
-/* ###
- * 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 ghidra.comm.packet.fields;
-
-import java.lang.annotation.*;
-
-/**
- * An annotation applied to all fields that will be serialized into a {@link Packet}
- *
- * This annotation is only meaningful when applied to classes extending {@link Packet}. By
- * convention, it is the first packet-related annotation applied to the field. In this way, the
- * {@link PacketField} annotation stands for the encoded field, while the field declaration stands
- * for the decoded field. The annotations between represent any applicable transformations applied
- * to encode or decode the field.
- *
- * If required, the attributes of this annotation can re-order the encoding of the fields.
- * Otherwise, the fields are encoded in declaration order. Note, that since JDK6, the method
- * {@link Class#getDeclaredFields()} has returned the fields in declaration order, despite the
- * documentation saying otherwise. This may not be the case for other Java implementations, e.g.,
- * Dalvik. To be certain about field order, specify it explicitly.
- *
- * For a {@link Packet} that extends another {@link Packet}, the two sets of declared fields must
- * have an explicit order. It is usually sufficient to declare the first field in the extended
- * packet as coming {@link #after()} the last of the base packet.
- *
- * Example:
- *
- * <pre>
- * public class Person extends Packet {
- * &#64;PacketField
- * &#64;NullTerminated
- * public String name;
- *
- * &#64;PacketField
- * &#64;NullTerminated
- * public String address;
- * }
- *
- * public class Employee extends Person {
- * &#64;PacketField(after = "address")
- * public int dateOfHire;
- * }
- * </pre>
- */
-
-@Retention(RetentionPolicy.RUNTIME)
-@Target(ElementType.FIELD)
-public @interface PacketField {
- /**
- * The names of fields, all of which this field must precede
- *
- * @return the array of names
- */
- String[] before() default {};
-
- /**
- * The names of fields, all of which the field must follow
- *
- * @return the array of names
- */
- String[] after() default {};
-}
diff --git a/Ghidra/Debug/Framework-AsyncComm/src/main/java/ghidra/comm/packet/fields/PrimitiveFactory.java b/Ghidra/Debug/Framework-AsyncComm/src/main/java/ghidra/comm/packet/fields/PrimitiveFactory.java
deleted file mode 100644
index fc019b7a9e..0000000000
--- a/Ghidra/Debug/Framework-AsyncComm/src/main/java/ghidra/comm/packet/fields/PrimitiveFactory.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/* ###
- * 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 ghidra.comm.packet.fields;
-
-import java.lang.reflect.Field;
-
-import ghidra.comm.packet.AbstractPacketCodec;
-import ghidra.comm.packet.Packet;
-
-/**
- * A factory of {@link FieldCodec}s that encode and decode actual packet data, i.e., the top-most
- * link in a chain
- *
- * This interface is most likely implemented by extending {@link AbstractPacketCodec}
- *
- * @param <ENCBUF> the type of temporary buffer used to encode
- * @param <DECBUF> the type of temporary buffer used to decode
- */
-public interface PrimitiveFactory<ENCBUF, DECBUF> extends FieldCodecFactory<ENCBUF, DECBUF> {
-
- /**
- * Request a {@link FieldCodec} for a particular type
- *
- * @param pktType the packet type being registered
- * @param field the field being registered
- * @param fldType the type of field codec requested from this factory
- * @return the constructed field codec
- */
- public <T> FieldCodec<ENCBUF, DECBUF, T> getFieldCodecForType(Class<? extends Packet> pktType,
- Field field, Class<? extends T> fldType);
-}
diff --git a/Ghidra/Debug/Framework-AsyncComm/src/main/java/ghidra/comm/packet/fields/WrapperFactory.java b/Ghidra/Debug/Framework-AsyncComm/src/main/java/ghidra/comm/packet/fields/WrapperFactory.java
deleted file mode 100644
index f019e2f16f..0000000000
--- a/Ghidra/Debug/Framework-AsyncComm/src/main/java/ghidra/comm/packet/fields/WrapperFactory.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/* ###
- * 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 ghidra.comm.packet.fields;
-
-import java.lang.reflect.Field;
-import java.util.Deque;
-
-import ghidra.comm.packet.AbstractPacketCodec;
-import ghidra.comm.packet.Packet;
-import ghidra.comm.packet.codecs.PacketCodecInternal;
-
-/**
- * A factory of {@link FieldCodec}s that wrap another, i.e., a link in a chain
- *
- * For convenience, this interface is most likely implemented by extending
- * {@link AbstractWrapperFactory}.
- *
- * @see AbstractPacketCodec
- *
- * @param <ENCBUF> the type of temporary buffer used to encode
- * @param <DECBUF> the type of temporary buffer used to decode
- */
-public interface WrapperFactory<ENCBUF, DECBUF> extends FieldCodecFactory<ENCBUF, DECBUF> {
-
- /**
- * Request a {@link FieldCodec} for a particular type
- *
- * The returned field codec transforms the data and delegates further encoding or decoding to
- * field codecs constructed from factories later in the chain.
- *
- * @param pktType the packet type being registered
- * @param field the field being registered
- * @param fldType the type of field codec requested from this factory
- * @param codec the packet codec with which the packet is being registered
- * @param chain the factories remaining in the chain
- * @return the constructed field codec
- */
- public <T> FieldCodec<ENCBUF, DECBUF, T> getWrappedFieldCodecForType(
- Class<? extends Packet> pktType, Field field, Class<? extends T> fldType,
- PacketCodecInternal<?, ENCBUF, DECBUF> codec,
- Deque<FieldCodecFactory<ENCBUF, DECBUF>> chain);
-}
diff --git a/Ghidra/Debug/Framework-AsyncComm/src/main/java/ghidra/comm/packet/string/CharArrayFieldCodec.java b/Ghidra/Debug/Framework-AsyncComm/src/main/java/ghidra/comm/packet/string/CharArrayFieldCodec.java
deleted file mode 100644
index 178776a759..0000000000
--- a/Ghidra/Debug/Framework-AsyncComm/src/main/java/ghidra/comm/packet/string/CharArrayFieldCodec.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/* ###
- * 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 ghidra.comm.packet.string;
-
-import java.io.IOException;
-import java.lang.reflect.Field;
-import java.nio.CharBuffer;
-
-import ghidra.comm.packet.Packet;
-import ghidra.comm.packet.PacketFactory;
-import ghidra.comm.packet.err.PacketDecodeException;
-import ghidra.comm.packet.err.PacketEncodeException;
-import ghidra.comm.packet.fields.AbstractFieldCodec;
-import ghidra.comm.packet.fields.FieldCodec;
-
-/**
- * The {@link FieldCodec} for encoding character arrays for {@link StringPacketCodec}
- *
- * This simply appends the array contents to the buffer for encoding, or consumes the remaining
- * contents of the buffer for decoding.
- */
-class CharArrayFieldCodec extends AbstractFieldCodec<StringBuilder, CharBuffer, char[]> {
- private final StringPacketCodec codec;
-
- CharArrayFieldCodec(StringPacketCodec codec, Class<? extends Packet> pktType, Field field) {
- super(pktType, field);
- this.codec = codec;
- }
-
- @Override
- public char[] decodeField(Packet pkt, CharBuffer buf, Integer count, PacketFactory factory)
- throws IOException, PacketDecodeException {
- return codec.decodeCharArray(field, buf, count.intValue());
- }
-
- @Override
- public void encodeField(StringBuilder buf, Packet pkt, char[] val)
- throws IOException, PacketEncodeException {
- codec.encodeCharArray(buf, field, val);
- }
-}
diff --git a/Ghidra/Debug/Framework-AsyncComm/src/main/java/ghidra/comm/packet/string/RegexSeparated.java b/Ghidra/Debug/Framework-AsyncComm/src/main/java/ghidra/comm/packet/string/RegexSeparated.java
deleted file mode 100644
index a05d0ddfae..0000000000
--- a/Ghidra/Debug/Framework-AsyncComm/src/main/java/ghidra/comm/packet/string/RegexSeparated.java
+++ /dev/null
@@ -1,78 +0,0 @@
-/* ###
- * 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 ghidra.comm.packet.string;
-
-import java.lang.annotation.*;
-import java.util.regex.Pattern;
-
-import ghidra.comm.packet.annot.CountedByField;
-import ghidra.comm.packet.annot.RepeatedField;
-
-/**
- * An annotation that indicates the elements of a field are separated by a regular expression
- *
- * This annotation is only meaningful to string-based packet codecs. It must be preceded by
- * {@link RepeatedField}.
- *
- * Example:
- *
- * <pre>
- * &#64;PacketField
- * &#64;RepeatedField
- * &#64;RegexSeparated(exp=",", tok=",")
- * public List<Integer> list
- * </pre>
- *
- * This would encode a list as, e.g., {@code "1,2,3"}. Note that {@code RegexSeparated} is subtly
- * different than {@link RegexTerminated} when applied with {@link RepeatedField}. The former
- * requires a terminator between pairs of consecutive elements, whereas the latter requires a
- * terminator after every element. The difference is in the final element. When encoding of the
- * form, e.g., {@code "a;b;c;"} is required, please refrain from using {@code RegexSeparated}.
- */
-@Retention(RetentionPolicy.RUNTIME)
-@Target(ElementType.FIELD)
-public @interface RegexSeparated {
- /**
- * The regular expression to match the tokens separating each encoded element
- *
- * This expression is applied during decoding to determine where each element ends.
- *
- * @see Pattern#compile(String)
- * @return the separator regular expression
- */
- String exp();
-
- /**
- * True if the separator can be omitted from the final element of an indefinitely-sized list
- *
- * This applies when the {@link CountedByField} annotation is not also present, because the
- * decoder will not know ahead of time whether or not the current element is the last element.
- * There is rarely a reason to set this to {@code false}.
- *
- * @return {@code true} to allow omission, {@code false} to forbid omission
- */
- boolean optional() default true;
-
- /**
- * The token to insert between each encoded element
- *
- * This token is inserted during encoding to separate each element. It is validated against
- * {@link #exp()} to ensure it will match during decode.
- *
- * @return the separator token
- */
- String tok();
-}
diff --git a/Ghidra/Debug/Framework-AsyncComm/src/main/java/ghidra/comm/packet/string/RegexSeparatedWrapperFactory.java b/Ghidra/Debug/Framework-AsyncComm/src/main/java/ghidra/comm/packet/string/RegexSeparatedWrapperFactory.java
deleted file mode 100644
index 03681731e1..0000000000
--- a/Ghidra/Debug/Framework-AsyncComm/src/main/java/ghidra/comm/packet/string/RegexSeparatedWrapperFactory.java
+++ /dev/null
@@ -1,102 +0,0 @@
-/* ###
- * 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 ghidra.comm.packet.string;
-
-import java.io.IOException;
-import java.lang.reflect.Field;
-import java.nio.CharBuffer;
-import java.util.Deque;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
-import ghidra.comm.packet.Packet;
-import ghidra.comm.packet.PacketFactory;
-import ghidra.comm.packet.annot.RepeatedField;
-import ghidra.comm.packet.annot.impl.RepeatedFieldWrapperFactory;
-import ghidra.comm.packet.codecs.PacketCodecInternal;
-import ghidra.comm.packet.err.*;
-import ghidra.comm.packet.fields.FieldCodec;
-import ghidra.comm.packet.fields.FieldCodecFactory;
-
-/**
- * The factory implementing {@link RegexSeparated}
- *
- * @see RepeatedField
- *
- * @param <E> the type of element encoded
- */
-class RegexSeparatedWrapperFactory<E>
- extends RepeatedFieldWrapperFactory<StringBuilder, CharBuffer, E> {
- private RegexSeparated annot;
-
- @Override
- public E decodeElement(Packet pkt, Field field, CharBuffer buf, Class<E> elemType, boolean last,
- FieldCodec<StringBuilder, CharBuffer, E> chain, PacketFactory factory)
- throws IOException, PacketDecodeException {
- if (!last) {
- /* This will be a lot like {@link String#split(String, int)} */
- Pattern pat = Pattern.compile(annot.exp());
- Matcher mat = pat.matcher(buf);
- if (!mat.find()) {
- if (!annot.optional()) {
- throw new InvalidPacketException(
- "Missing terminator token [" + annot.exp() + "]");
- }
- return super.decodeElement(pkt, field, buf, elemType, last, chain, factory);
- }
- CharBuffer part = buf.subSequence(0, mat.start());
- buf.position(buf.position() + mat.end());
- E result = super.decodeElement(pkt, field, part, elemType, last, chain, factory);
- if (part.hasRemaining()) {
- throw new InvalidPacketException(field + " did not consume buffer " + part);
- }
- return result;
- }
- return super.decodeElement(pkt, field, buf, elemType, last, chain, factory);
- }
-
- @Override
- public void encodeElement(StringBuilder buf, Packet pkt, Field field, E elem, boolean last,
- FieldCodec<StringBuilder, CharBuffer, E> chain)
- throws IOException, PacketEncodeException {
- super.encodeElement(buf, pkt, field, elem, last, chain);
- if (!last) {
- buf.append(annot.tok());
- }
- }
-
- @Override
- public <T> FieldCodec<StringBuilder, CharBuffer, T> getWrappedFieldCodecForType(
- Class<? extends Packet> pktType, Field field, Class<? extends T> fldType,
- PacketCodecInternal<?, StringBuilder, CharBuffer> codec,
- Deque<FieldCodecFactory<StringBuilder, CharBuffer>> chain) {
- annot = field.getAnnotation(RegexSeparated.class);
- if ("".equals(annot.tok())) {
- // Do nothing
- }
- else if (!Pattern.matches(annot.exp(), annot.tok())) {
- throw new PacketAnnotationException(pktType, field, annot,
- "Token does not match token expression");
- }
- if (chain.pop().getClass() != RepeatedFieldWrapperFactory.class) {
- throw new PacketAnnotationException(pktType, field, annot,
- "Must be applied directly below @" + RepeatedField.class.getSimpleName());
- }
- // No need for a whole new field codec
- // The behavior is changed by overriding decodeElement and encodeElement
- return super.getWrappedFieldCodecForType(pktType, field, fldType, codec, chain);
- }
-}
diff --git a/Ghidra/Debug/Framework-AsyncComm/src/main/java/ghidra/comm/packet/string/RegexTerminated.java b/Ghidra/Debug/Framework-AsyncComm/src/main/java/ghidra/comm/packet/string/RegexTerminated.java
deleted file mode 100644
index e86d358cb2..0000000000
--- a/Ghidra/Debug/Framework-AsyncComm/src/main/java/ghidra/comm/packet/string/RegexTerminated.java
+++ /dev/null
@@ -1,73 +0,0 @@
-/* ###
- * 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 ghidra.comm.packet.string;
-
-import java.lang.annotation.*;
-import java.util.regex.Pattern;
-
-import ghidra.comm.packet.annot.RepeatedField;
-import ghidra.comm.packet.err.PacketDecodeException;
-
-/**
- * An annotation that indicates a field is terminated by a token matching a regular expression
- *
- * This annotation is only meaningful to string-based packet codecs. When encoded, the annotated
- * field will be conditionally followed by a terminator token. When decoded, the field codec will
- * read ahead, using a regular expression to locate the terminator and limit the chained codec to
- * the preceding data. Once decoded, it will resume immediately following the matched terminator.
- *
- * Note that when used with {@link RepeatedField}, this annotation requires every element, including
- * the last, to be terminated. To allow the final terminator to be omitted, consider using
- * {@link RegexSeparated}.
- */
-@Retention(RetentionPolicy.RUNTIME)
-@Target(ElementType.FIELD)
-public @interface RegexTerminated {
- /**
- * The regular expression to match the terminating token
- *
- * This expression is applied during decode to scan ahead to the terminator.
- *
- * @see Pattern#compile(String)
- * @return the terminator regular expression
- */
- String exp();
-
- /**
- * The name of the field, preceding this one, upon which the terminator is conditioned
- *
- * If a name is provided, and the named field has a value of {@code null} during encoding, then
- * the terminator is not appended. Otherwise, the terminator is always applied. If a name is
- * provided, and the decoder hits the buffer limit while reading ahead to the terminator, the
- * chained field is permitted to consume up to the same limit. Otherwise, a missing terminator
- * causes a {@link PacketDecodeException}.
- *
- * The named field must be in the same {@link Packet}.
- *
- * @return the name of the field
- */
- String cond() default "";
-
- /**
- * The token to insert after the field
- *
- * This token is inserted during encoding to terminate the field. It is validated against
- * {@link #exp()} to ensure it will match during decode.
- *
- * @return the terminator token
- */
- String tok();
-}
diff --git a/Ghidra/Debug/Framework-AsyncComm/src/main/java/ghidra/comm/packet/string/RegexTerminatedFieldCodec.java b/Ghidra/Debug/Framework-AsyncComm/src/main/java/ghidra/comm/packet/string/RegexTerminatedFieldCodec.java
deleted file mode 100644
index d9b2f070ee..0000000000
--- a/Ghidra/Debug/Framework-AsyncComm/src/main/java/ghidra/comm/packet/string/RegexTerminatedFieldCodec.java
+++ /dev/null
@@ -1,102 +0,0 @@
-/* ###
- * 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 ghidra.comm.packet.string;
-
-import java.io.EOFException;
-import java.io.IOException;
-import java.lang.reflect.Field;
-import java.nio.CharBuffer;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
-import ghidra.comm.packet.Packet;
-import ghidra.comm.packet.PacketFactory;
-import ghidra.comm.packet.codecs.PacketCodecInternal;
-import ghidra.comm.packet.err.*;
-import ghidra.comm.packet.fields.AbstractFieldCodec;
-import ghidra.comm.packet.fields.FieldCodec;
-
-/**
- * The {@link FieldCodec} for fields annotated by {@link RegexTerminated}
- *
- * @see RegexTerminatedWrapperFactory
- *
- * @param <T> the type of field encoded
- */
-public class RegexTerminatedFieldCodec<T> extends AbstractFieldCodec<StringBuilder, CharBuffer, T> {
- private final Field condField;
- private final RegexTerminated annot;
- private final PacketCodecInternal<?, StringBuilder, CharBuffer> codec;
- private final FieldCodec<StringBuilder, CharBuffer, T> chainNext;
-
- public RegexTerminatedFieldCodec(Class<? extends Packet> pktType, Field field, Field condField,
- RegexTerminated annot, PacketCodecInternal<?, StringBuilder, CharBuffer> codec,
- FieldCodec<StringBuilder, CharBuffer, T> chainNext) {
- super(pktType, field);
- this.condField = condField;
- this.chainNext = chainNext;
- this.codec = codec;
- this.annot = annot;
- }
-
- @Override
- public T decodeField(Packet pkt, CharBuffer buf, Integer count, PacketFactory factory)
- throws IOException, PacketDecodeException {
- // TODO: This ought to decode the token through the chain....
- /** This will be a lot like {@link String#split(String, int)} */
- Pattern pat = Pattern.compile(annot.exp());
- Matcher mat = pat.matcher(buf);
- if (!mat.find()) {
- if (condField != null) {
- return chainNext.decodeField(pkt, buf, count, factory);
- }
- else if (codec.measureDecodeRemaining(buf) == 0) {
- throw new EOFException("Buffer is empty");
- }
- else {
- throw new InvalidPacketException("Missing terminator token [" + annot.exp() + "]");
- }
- }
- CharBuffer part = buf.subSequence(0, mat.start());
- if ("".equals(annot.tok())) {
- // Token is empty, so something else is expected to consume it
- buf.position(buf.position() + mat.start());
- }
- else {
- // Token is given, so consume whatever the expression matched
- buf.position(buf.position() + mat.end());
- }
- T result = chainNext.decodeField(pkt, part, count, factory);
- if (codec.measureDecodeRemaining(part) != 0) {
- throw new InvalidPacketException(field + " did not consume buffer " + part);
- }
- return result;
- }
-
- @Override
- public void encodeField(StringBuilder buf, Packet pkt, T val)
- throws IOException, PacketEncodeException {
- try {
- chainNext.encodeField(buf, pkt, val);
- if (condField == null || condField.get(pkt) != null) {
- buf.append(annot.tok());
- }
- }
- catch (IllegalAccessException e) {
- throw new RuntimeException(e);
- }
- }
-}
diff --git a/Ghidra/Debug/Framework-AsyncComm/src/main/java/ghidra/comm/packet/string/RegexTerminatedWrapperFactory.java b/Ghidra/Debug/Framework-AsyncComm/src/main/java/ghidra/comm/packet/string/RegexTerminatedWrapperFactory.java
deleted file mode 100644
index 6feb518d8b..0000000000
--- a/Ghidra/Debug/Framework-AsyncComm/src/main/java/ghidra/comm/packet/string/RegexTerminatedWrapperFactory.java
+++ /dev/null
@@ -1,61 +0,0 @@
-/* ###
- * 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 ghidra.comm.packet.string;
-
-import java.lang.reflect.Field;
-import java.nio.CharBuffer;
-import java.util.Deque;
-import java.util.regex.Pattern;
-
-import ghidra.comm.packet.Packet;
-import ghidra.comm.packet.codecs.PacketCodecInternal;
-import ghidra.comm.packet.err.PacketAnnotationException;
-import ghidra.comm.packet.fields.*;
-
-/**
- * The factory implementing {@link RegexTerminated}
- */
-public class RegexTerminatedWrapperFactory
- extends AbstractWrapperFactory<StringBuilder, CharBuffer> {
- @Override
- public <T> FieldCodec<StringBuilder, CharBuffer, T> getWrappedFieldCodecForType(
- Class<? extends Packet> pktType, Field field, Class<? extends T> fldType,
- PacketCodecInternal<?, StringBuilder, CharBuffer> codec,
- Deque<FieldCodecFactory<StringBuilder, CharBuffer>> chain) {
- RegexTerminated annot = field.getAnnotation(RegexTerminated.class);
- if (!"".equals(annot.tok()) && !Pattern.matches(annot.exp(), annot.tok())) {
- throw new PacketAnnotationException(pktType, field, annot,
- "Token does not match token expression");
- }
-
- Field condField;
- if ("".equals(annot.cond())) {
- condField = null;
- }
- else {
- try {
- condField = Packet.getPacketField(pktType, annot.cond());
- }
- catch (NoSuchFieldException | SecurityException e) {
- throw new PacketAnnotationException(pktType, field, annot, e.getMessage(), e);
- }
- }
-
- FieldCodec<StringBuilder, CharBuffer, T> chainNext =
- FieldCodecFactory.buildChainForType(pktType, field, fldType, codec, chain);
- return new RegexTerminatedFieldCodec<>(pktType, field, condField, annot, codec, chainNext);
- }
-}
diff --git a/Ghidra/Debug/Framework-AsyncComm/src/main/java/ghidra/comm/packet/string/SizeRestricted.java b/Ghidra/Debug/Framework-AsyncComm/src/main/java/ghidra/comm/packet/string/SizeRestricted.java
deleted file mode 100644
index d1ca8a7e40..0000000000
--- a/Ghidra/Debug/Framework-AsyncComm/src/main/java/ghidra/comm/packet/string/SizeRestricted.java
+++ /dev/null
@@ -1,91 +0,0 @@
-/* ###
- * 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 ghidra.comm.packet.string;
-
-import static java.lang.annotation.ElementType.FIELD;
-import static java.lang.annotation.RetentionPolicy.RUNTIME;
-
-import java.lang.annotation.Retention;
-import java.lang.annotation.Target;
-
-import ghidra.comm.packet.err.PacketEncodeException;
-
-/**
- * An annotation that indicates a field should be encoded to a restricted, even constant, length
- *
- * This annotation is only meaningful to string-based packet codecs. Note that this affects only the
- * encoding, so user beware lest decoding is affected by the pad. For example, padding to the left
- * with 0 is acceptable for most positive numeric encodings.
- */
-@Retention(RUNTIME)
-@Target(FIELD)
-public @interface SizeRestricted {
- /**
- * The side to which padding may be applied
- */
- public enum PadDirection {
- /**
- * Pad to the left of (before) the encoded value
- */
- LEFT,
- /**
- * Do not permit padding; throw a {@link PacketEncodeException} if below the minimum length
- */
- NONE,
- /**
- * Pad to the right of (after) the encoded value
- */
- RIGHT;
- }
-
- /**
- * The direction in which padding may be applied, if at all
- *
- * @return the pad direction
- */
- PadDirection direction() default PadDirection.NONE;
-
- /**
- * The character used for padding
- *
- * @return the pad character
- */
- char pad() default ' ';
-
- /**
- * The fixed length of the encoding
- *
- * Sets the minimum and maximum to the same value. If given, then neither {@link #min()} nor
- * {@link #max()} can also be given.
- *
- * @return the fixed length
- */
- int value() default Integer.MIN_VALUE;
-
- /**
- * The minimum length of the encoding
- *
- * @return the minimum length
- */
- int min() default 0;
-
- /**
- * The maximum length of the encoding
- *
- * @return the maximum length
- */
- int max() default Integer.MAX_VALUE;
-}
diff --git a/Ghidra/Debug/Framework-AsyncComm/src/main/java/ghidra/comm/packet/string/SizeRestrictedFieldCodec.java b/Ghidra/Debug/Framework-AsyncComm/src/main/java/ghidra/comm/packet/string/SizeRestrictedFieldCodec.java
deleted file mode 100644
index 511823127c..0000000000
--- a/Ghidra/Debug/Framework-AsyncComm/src/main/java/ghidra/comm/packet/string/SizeRestrictedFieldCodec.java
+++ /dev/null
@@ -1,104 +0,0 @@
-/* ###
- * 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 ghidra.comm.packet.string;
-
-import java.io.IOException;
-import java.lang.reflect.Field;
-
-import ghidra.comm.packet.Packet;
-import ghidra.comm.packet.PacketFactory;
-import ghidra.comm.packet.codecs.PacketCodecInternal;
-import ghidra.comm.packet.err.PacketDecodeException;
-import ghidra.comm.packet.err.PacketEncodeException;
-import ghidra.comm.packet.fields.AbstractFieldCodec;
-import ghidra.comm.packet.fields.FieldCodec;
-import ghidra.comm.packet.string.SizeRestricted.PadDirection;
-
-/**
- * The {@link FieldCodec} for fields annotated by {@link SizeRestricted}
- *
- * @see SizeRestrictedWrapperFactory
- *
- * @param <ENCBUF> the type of temporary buffer used to encode
- * @param <DECBUF> the type of temporary buffer used to decode
- * @param <T> the type of the field as passed through the chain
- */
-public class SizeRestrictedFieldCodec<ENCBUF, DECBUF, T>
- extends AbstractFieldCodec<ENCBUF, DECBUF, T> {
- private final int min;
- private final int max;
- private final SizeRestricted annot;
- private final PacketCodecInternal<?, ENCBUF, DECBUF> codec;
- private final FieldCodec<ENCBUF, DECBUF, T> chainNext;
- private final FieldCodec<ENCBUF, DECBUF, Character> chainChar;
-
- public SizeRestrictedFieldCodec(Class<? extends Packet> pktType, Field field, int min, int max,
- SizeRestricted annot, PacketCodecInternal<?, ENCBUF, DECBUF> codec,
- FieldCodec<ENCBUF, DECBUF, T> chainNext,
- FieldCodec<ENCBUF, DECBUF, Character> chainChar) {
- super(pktType, field);
- this.max = max;
- this.min = min;
- this.annot = annot;
- this.codec = codec;
- this.chainNext = chainNext;
- this.chainChar = chainChar;
- }
-
- @Override
- public T decodeField(Packet pkt, DECBUF buf, Integer count, PacketFactory factory)
- throws IOException, PacketDecodeException {
- int pos = codec.getDecodePosition(buf);
- int orig = codec.limitDecodeBuffer(buf, pos + max);
- T result = chainNext.decodeField(pkt, buf, count, factory);
- if (codec.measureDecodeRemaining(buf) != 0) {
- throw new PacketDecodeException("Gratuitous data in size-restricted field: " + buf);
- // TODO: Consider: it might be padding...
- }
- codec.limitDecodeBuffer(buf, orig);
- return result;
- }
-
- @Override
- public void encodeField(ENCBUF buf, Packet pkt, T val)
- throws IOException, PacketEncodeException {
- ENCBUF part = codec.newEncodeBuffer();
- chainNext.encodeField(part, pkt, val);
- long len = codec.measureEncodeSize(part);
- if (len > max) {
- throw new PacketEncodeException("Encoding " + field + " exceeds its maximum size");
- }
- else if (len >= min) {
- codec.appendEncoded(buf, part);
- }
- else if (annot.direction() == PadDirection.LEFT) {
- for (int i = 0; i < min - len; i++) {
- chainChar.encodeField(buf, pkt, annot.pad());
- }
- codec.appendEncoded(buf, part);
- }
- else if (annot.direction() == PadDirection.RIGHT) {
- codec.appendEncoded(buf, part);
- for (int i = 0; i < min - len; i++) {
- chainChar.encodeField(buf, pkt, annot.pad());
- }
- }
- else {
- throw new PacketEncodeException(
- "Encoding " + field + " fails to meet its minimum size");
- }
- }
-}
diff --git a/Ghidra/Debug/Framework-AsyncComm/src/main/java/ghidra/comm/packet/string/SizeRestrictedWrapperFactory.java b/Ghidra/Debug/Framework-AsyncComm/src/main/java/ghidra/comm/packet/string/SizeRestrictedWrapperFactory.java
deleted file mode 100644
index 1f2fccd361..0000000000
--- a/Ghidra/Debug/Framework-AsyncComm/src/main/java/ghidra/comm/packet/string/SizeRestrictedWrapperFactory.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/* ###
- * 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 ghidra.comm.packet.string;
-
-import java.lang.reflect.Field;
-import java.util.Deque;
-import java.util.LinkedList;
-
-import ghidra.comm.packet.Packet;
-import ghidra.comm.packet.codecs.PacketCodecInternal;
-import ghidra.comm.packet.err.PacketAnnotationException;
-import ghidra.comm.packet.fields.*;
-
-/**
- * The factory implementing {@link SizeRestricted}
- *
- * @param <ENCBUF> the type of temporary buffer used to encode
- * @param <DECBUF> the type of temporary buffer used to decode
- */
-public class SizeRestrictedWrapperFactory<ENCBUF, DECBUF>
- extends AbstractWrapperFactory<ENCBUF, DECBUF> {
- @Override
- public <T> FieldCodec<ENCBUF, DECBUF, T> getWrappedFieldCodecForType(
- Class<? extends Packet> pktType, Field field, Class<? extends T> fldType,
- PacketCodecInternal<?, ENCBUF, DECBUF> codec,
- Deque<FieldCodecFactory<ENCBUF, DECBUF>> chain) {
- SizeRestricted annot = field.getAnnotation(SizeRestricted.class);
- int fixed = annot.value();
- final int min = fixed == Integer.MIN_VALUE ? annot.min() : fixed;
- final int max = fixed == Integer.MIN_VALUE ? annot.max() : fixed;
- if (min == max && min < 1) {
- throw new PacketAnnotationException(pktType, field, annot, "Cannot have fixed len < 1");
- }
-
- FieldCodec<ENCBUF, DECBUF, T> chainNext = FieldCodecFactory.buildChainForType(pktType,
- field, fldType, codec, new LinkedList<>(chain));
- FieldCodec<ENCBUF, DECBUF, Character> chainChar =
- FieldCodecFactory.buildChainForType(pktType, field, Character.class, codec, chain);
- return new SizeRestrictedFieldCodec<>(pktType, field, min, max, annot, codec, chainNext,
- chainChar);
- }
-}
diff --git a/Ghidra/Debug/Framework-AsyncComm/src/main/java/ghidra/comm/packet/string/StringEnumFieldCodec.java b/Ghidra/Debug/Framework-AsyncComm/src/main/java/ghidra/comm/packet/string/StringEnumFieldCodec.java
deleted file mode 100644
index 5ef71dc02e..0000000000
--- a/Ghidra/Debug/Framework-AsyncComm/src/main/java/ghidra/comm/packet/string/StringEnumFieldCodec.java
+++ /dev/null
@@ -1,60 +0,0 @@
-/* ###
- * 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 ghidra.comm.packet.string;
-
-import java.io.IOException;
-import java.lang.reflect.Field;
-import java.nio.CharBuffer;
-
-import ghidra.comm.packet.Packet;
-import ghidra.comm.packet.PacketFactory;
-import ghidra.comm.packet.codecs.PrimitiveCodec;
-import ghidra.comm.packet.err.PacketDecodeException;
-import ghidra.comm.packet.err.PacketEncodeException;
-import ghidra.comm.packet.fields.AbstractFieldCodec;
-import ghidra.comm.packet.fields.FieldCodec;
-
-/**
- * The {@link FieldCodec} for encoding enumeration values for {@link StringPacketCodec}
- *
- * This simply encodes the value's name as a string.
- *
- * @param <U> the type of the {@code enum}
- */
-public class StringEnumFieldCodec<U extends Enum<U>>
- extends AbstractFieldCodec<StringBuilder, CharBuffer, U> {
- private final PrimitiveCodec<StringBuilder, CharBuffer> codec;
- private final Class<U> type;
-
- public StringEnumFieldCodec(PrimitiveCodec<StringBuilder, CharBuffer> codec,
- Class<? extends Packet> pktType, Field field, Class<U> type) {
- super(pktType, field);
- this.codec = codec;
- this.type = type;
- }
-
- @Override
- public U decodeField(Packet pkt, CharBuffer buf, Integer count, PacketFactory factory)
- throws IOException, PacketDecodeException {
- return codec.decodeEnumConstant(field, buf, type);
- }
-
- @Override
- public void encodeField(StringBuilder buf, Packet pkt, U val)
- throws IOException, PacketEncodeException {
- codec.encodeEnumConstant(buf, field, val);
- }
-}
diff --git a/Ghidra/Debug/Framework-AsyncComm/src/main/java/ghidra/comm/packet/string/StringPacketCodec.java b/Ghidra/Debug/Framework-AsyncComm/src/main/java/ghidra/comm/packet/string/StringPacketCodec.java
deleted file mode 100644
index 52b750c1b5..0000000000
--- a/Ghidra/Debug/Framework-AsyncComm/src/main/java/ghidra/comm/packet/string/StringPacketCodec.java
+++ /dev/null
@@ -1,723 +0,0 @@
-/* ###
- * 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 ghidra.comm.packet.string;
-
-import java.io.EOFException;
-import java.io.IOException;
-import java.lang.annotation.Annotation;
-import java.lang.reflect.Field;
-import java.math.BigInteger;
-import java.nio.BufferUnderflowException;
-import java.nio.CharBuffer;
-import java.util.*;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
-import org.apache.commons.collections4.map.LazyMap;
-import org.apache.commons.lang3.tuple.ImmutablePair;
-import org.apache.commons.lang3.tuple.Pair;
-
-import com.google.common.primitives.UnsignedInteger;
-import com.google.common.primitives.UnsignedLong;
-
-import ghidra.comm.packet.AbstractPacketCodec;
-import ghidra.comm.packet.Packet;
-import ghidra.comm.packet.err.*;
-import ghidra.comm.packet.fields.FieldCodec;
-import ghidra.comm.packet.fields.WrapperFactory;
-
-/**
- * A codec for encoding packets as text
- */
-public class StringPacketCodec extends AbstractPacketCodec<String, StringBuilder, CharBuffer> {
- public static final StringPacketCodec INSTANCE = new StringPacketCodec();
- public static final int DEFAULT_RADIX = 16;
-
- protected final static String RADIX_DIGS = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
-
- protected static final BigInteger LONG_MODULUS =
- new BigInteger(1, new byte[] { 1, 0, 0, 0, 0, 0, 0, 0, 0 });
-
- protected static final String _RE_DIGITS = "(\\p{Digit}+)";
- protected static final String _RE_HEX_DIGITS = "(\\p{XDigit}+)";
- // an exponent is 'e' or 'E' followed by a signed decimal integer.
- protected static final String _RE_EXPONENT = "[eE][+-]?" + _RE_DIGITS;
- /** This was taken from the documentation in {@link Double#valueOf(String)} */
- protected static final Pattern RE_FLOATING_POINT = Pattern.compile( //
- "[+-]?(" + // Optional sign character
- "NaN|" + // "NaN" string
- "Infinity|" + // "Infinity" string
-
- // A decimal floating-point string representing a finite positive
- // number without a leading sign has at most five basic pieces:
- // Digits . Digits ExponentPart FloatTypeSuffix
- //
- // Since this method allows integer-only strings as input
- // in addition to strings of floating-point literals, the
- // two sub-patterns below are simplifications of the grammar
- // productions from section 3.10.2 of
- // The Java Language Specification.
-
- // Digits ._opt Digits_opt ExponentPart_opt FloatTypeSuffix_opt
- "(((" + _RE_DIGITS + "(\\.)?(" + _RE_DIGITS + "?)(" + _RE_EXPONENT + ")?)|" +
-
- // . Digits ExponentPart_opt FloatTypeSuffix_opt
- "(\\.(" + _RE_DIGITS + ")(" + _RE_EXPONENT + ")?)|" +
-
- // Hexadecimal strings
- "((" +
- // 0[xX] HexDigits ._opt BinaryExponent FloatTypeSuffix_opt
- "(0[xX]" + _RE_HEX_DIGITS + "(\\.)?)|" +
-
- // 0[xX] HexDigits_opt . HexDigits BinaryExponent FloatTypeSuffix_opt
- "(0[xX]" + _RE_HEX_DIGITS + "?(\\.)" + _RE_HEX_DIGITS + ")" +
-
- ")[pP][+-]?" + _RE_DIGITS + "))" + "[fFdD]?))" //
- );
-
- /**
- * Get the singleton instance of this codec
- *
- * @return the instance
- */
- public static StringPacketCodec getInstance() {
- return INSTANCE;
- }
-
- /**
- * Compute the maximum number of characters needed to represent a numeric type
- *
- * Computes the number of characters needed to encode the maximum value of a numeric type stored
- * in the given number of bytes. The number is encoded by converting the value to a string using
- * the given radix. For example, the maximum number of characters needed to store a two-byte
- * integer in base 10 is 5, based on the maximum encoded value: {@code "65535"}.
- *
- * @param radix the radix for text encoding
- * @param byteCount the number of bytes in the primitive type
- * @return the maximum number of characters need to encode the type
- */
- protected static int computeMaxChars(int radix, int byteCount) {
- if (radix == 16) {
- return byteCount * 2;
- }
- double charsPerByte = 8 / (Math.log(radix / Math.log(2)));
- double chars = byteCount * charsPerByte;
- return (int) Math.ceil(chars);
- }
-
- /**
- * Construct a regular expression to recognize textual numbers of a given radix
- *
- * @see Long#parseLong(String, int)
- *
- * @param radix the radix
- * @return the regular expression
- */
- protected static Pattern makeNumericPattern(int radix) {
- if (radix < 2 || radix > 36) {
- throw new IllegalArgumentException("Radix must be between 2 and 36");
- }
- String digs = RADIX_DIGS.substring(0, radix);
- if (radix > 10) {
- digs += RADIX_DIGS.substring(10, radix).toLowerCase();
- }
- return Pattern.compile("[+-]?[" + digs + "]+");
- }
-
- /**
- * Read as many characters from the buffer that match the format of a floating-point value
- *
- * @param buf the buffer
- * @return the prefix matching the format
- * @throws InvalidPacketException if no prefix matches the format
- * @throws IOException if there is an issue accessing a device or buffer
- */
- protected static String readFloatingPoint(CharBuffer buf) throws InvalidPacketException {
- return readString(buf, null, RE_FLOATING_POINT);
- }
-
- /**
- * Read as many characters from the buffer that match the format of an integer
- *
- * @param buf the buffer
- * @param radix the radix of the expected value
- * @param bytes the number of bytes in the primitive integer type
- * @return the prefix matching the format
- * @throws InvalidPacketException if no prefix matches the format
- * @throws IOException if there is an issue accessing a device or buffer
- */
- protected static String readNumericString(CharBuffer buf, int radix, int bytes)
- throws InvalidPacketException {
- return readString(buf, computeMaxChars(radix, bytes), makeNumericPattern(radix));
- }
-
- /**
- * Read a given number of characters from the buffer
- *
- * @param buf the buffer
- * @param count the number of characters, or null for all remaining characters
- * @return the prefix
- * @throws IOException if there is an issue accessing a device or buffer
- */
- protected static String readString(CharBuffer buf, Integer count) {
- try {
- return readString(buf, count, null);
- }
- catch (InvalidPacketException e) {
- throw new AssertionError("INTERNAL");
- }
- }
-
- /**
- * Read as many characters from the buffer that match a given pattern
- *
- * @param buf the buffer
- * @param count the maximum number of characters, or null for unlimited
- * @param pat the pattern to match
- * @return the prefix matching the pattern
- * @throws InvalidPacketException if no prefix matches the pattern
- * @throws EOFException
- */
- protected static String readString(CharBuffer buf, Integer count, Pattern pat)
- throws InvalidPacketException {
- CharBuffer sub = buf;
- if (count != null) {
- count = Math.min(count, buf.remaining());
- sub = buf.subSequence(0, count.intValue());
- }
- if (pat != null) {
- Matcher mat = pat.matcher(sub);
- if (mat.matches()) {
- count = buf.remaining();
- }
- else if (mat.lookingAt()) {
- count = mat.end();
- }
- else if (!buf.hasRemaining()) {
- throw new BufferUnderflowException();
- }
- else {
- throw new InvalidPacketException(
- "Field '" + buf + "' does not follow expected pattern: " + pat);
- }
- }
- if (count != null) {
- sub = buf.subSequence(0, count);
- buf.position(buf.position() + count);
- return sub.toString();
- }
- String ret = buf.toString();
- buf.position(buf.limit());
- return ret;
- }
-
- /**
- * A map of enum names to enum values, listing the longest names first
- *
- * This is a map of maps. The first tier maps enum types. The second tier maps the constant
- * names from each enum type to the actual constant value. The longest name is listed first so
- * that if one name is a prefix of another in the same {@code enum}, the longest match is taken.
- */
- protected Map<Class<Enum<?>>, LinkedHashMap<String, Enum<?>>> longestNamesByEnumClass =
- LazyMap.lazyMap(new HashMap<>(), (Class<Enum<?>> enumType) -> {
- List<Pair<String, Enum<?>>> longestFirst = new ArrayList<>();
- if (CustomNamedEnum.class.isAssignableFrom(enumType)) {
- for (Enum<?> e : enumType.getEnumConstants()) {
- CustomNamedEnum c = (CustomNamedEnum) e;
- longestFirst.add(new ImmutablePair<>(c.getCustomName(), e));
- }
- }
- else {
- for (Enum<?> e : enumType.getEnumConstants()) {
- longestFirst.add(new ImmutablePair<>(e.name(), e));
- }
- }
- longestFirst.sort((Pair<String, Enum<?>> p1,
- Pair<String, Enum<?>> p2) -> p2.getKey().length() - p1.getKey().length());
- LinkedHashMap<String, Enum<?>> result = new LinkedHashMap<>();
- for (Pair<String, Enum<?>> p : longestFirst) {
- result.put(p.getKey(), p.getValue());
- }
- return result;
- });
-
- protected StringPacketCodec() {
- }
-
- /**
- * Decode a byte value in the given radix
- *
- * @param field the field for which the value is decoded
- * @param buf the buffer from which the value is decoded
- * @param radix the radix
- * @return the decoded value
- * @throws PacketDecodeException if the packet is not well formed
- */
- public byte decodeByte(Field field, CharBuffer buf, int radix) throws PacketDecodeException {
- String part = readNumericString(buf, radix, 1);
- try {
- return (byte) Short.parseShort(part, radix);
- }
- catch (NumberFormatException e) {
- throw new InvalidPacketException("Malformed byte", e);
- }
- }
-
- /**
- * Decode a short integer value in the given radix
- *
- * @param field the field for which the value is decoded
- * @param buf the buffer from which the value is decoded
- * @param radix the radix
- * @return the decoded value
- * @throws PacketDecodeException if the packet is not well formed
- */
- public short decodeShort(Field field, CharBuffer buf, int radix) throws PacketDecodeException {
- String part = readNumericString(buf, radix, 2);
- try {
- return (short) Integer.parseInt(part, radix);
- }
- catch (NumberFormatException e) {
- throw new InvalidPacketException("Malformed long", e);
- }
- }
-
- /**
- * Decode an integer value in the given radix
- *
- * @param field the field for which the value is decoded
- * @param buf the buffer from which the value is decoded
- * @param radix the radix
- * @return the decoded value
- * @throws PacketDecodeException if the packet is not well formed
- */
- public int decodeInt(Field field, CharBuffer buf, int radix) throws PacketDecodeException {
- String part = readNumericString(buf, radix, 4);
- try {
- return UnsignedInteger.valueOf(part, radix).intValue();
- }
- catch (NumberFormatException e) {
- throw new InvalidPacketException("Malformed int", e);
- }
- }
-
- /**
- * Decode a long integer value in the given radix
- *
- * @param field the field for which the value is decoded
- * @param buf the buffer from which the value is decoded
- * @param radix the radix
- * @return the decoded value
- * @throws PacketDecodeException if the packet is not well formed
- */
- public long decodeLong(Field field, CharBuffer buf, int radix) throws PacketDecodeException {
- String part = readNumericString(buf, radix, 8);
- try {
- return UnsignedLong.valueOf(part, radix).longValue();
- }
- catch (NumberFormatException e) {
- throw new InvalidPacketException("Malformed long", e);
- }
- }
-
- /**
- * Decode a character array
- *
- * @param field the field for which the value is decoded
- * @param buf the buffer from which the value is decoded
- * @param count the number of characters to decode; -1 for all remaining
- * @return the decoded array
- */
- public char[] decodeCharArray(Field field, CharBuffer buf, int count) {
- char[] ret;
- if (count == -1) {
- ret = new char[buf.remaining()];
- }
- else {
- ret = new char[count];
- }
- buf.get(ret);
- return ret;
- }
-
- /**
- * Encode a byte value in the given radix
- *
- * @param buf the buffer into which to append the encoded data
- * @param field the field for which the value is encoded
- * @param val the value to encode
- * @param radix the radix
- */
- public void encodeByte(StringBuilder buf, Field field, byte val, int radix) {
- buf.append(Integer.toString(val & 0x0ff, radix));
- }
-
- /**
- * Encode a short integer value in the given radix
- *
- * @param buf the buffer into which to append the encoded data
- * @param field the field for which the value is encoded
- * @param val the value to encode
- * @param radix the radix
- */
- public void encodeShort(StringBuilder buf, Field field, short val, int radix) {
- buf.append(Integer.toString(val & 0x0ffff, radix));
- }
-
- /**
- * Encode an integer value in the given radix
- *
- * @param buf the buffer into which to append the encoded data
- * @param field the field for which the value is encoded
- * @param val the value to encode
- * @param radix the radix
- */
- public void encodeInt(StringBuilder buf, Field field, int val, int radix) {
- buf.append(Long.toString(val & 0x0ffffffffL, radix));
- }
-
- /**
- * Encode a long integer value in the given radix
- *
- * @param buf the buffer into which to append the encoded data
- * @param field the field for which the value is encoded
- * @param val the value to encode
- * @param radix the radix
- */
- public void encodeLong(StringBuilder buf, Field field, long val, int radix) {
- if (val >= 0) {
- buf.append(Long.toString(val, radix));
- }
- else {
- BigInteger v = BigInteger.valueOf(val);
- v = v.add(LONG_MODULUS);
- buf.append(v.toString(radix));
- }
- }
-
- /**
- * Encode a single-precision float value in decimal or hexadecimal
- *
- * @param buf the buffer into which to append the encoded data
- * @param field the field for which the value is encoded
- * @param val the value to encode
- * @param hex true to use hexadecimal, false to use decimal
- */
- public void encodeFloat(StringBuilder buf, Field field, float val, boolean hex) {
- if (hex) {
- buf.append(Float.toHexString(val));
- }
- else {
- buf.append(val);
- }
- }
-
- /**
- * Encode a double-precision float value in decimal or hexadecimal
- *
- * @param buf the buffer into which to append the encoded data
- * @param field the field for which the value is encoded
- * @param val the value to encode
- * @param hex true to use hexadecimal, false to use decimal
- */
- public void encodeDouble(StringBuilder buf, Field field, double val, boolean hex) {
- if (hex) {
- buf.append(Double.toHexString(val));
- }
- else {
- buf.append(val);
- }
- }
-
- /**
- * Encode a character array
- *
- * @param buf the buffer into which to append the encoded data
- * @param field the field for which the value is encoded
- * @param val the value to encode
- */
- public void encodeCharArray(StringBuilder buf, Field field, char[] val) {
- buf.append(val);
- }
-
- @Override
- public boolean decodeBoolean(Field field, CharBuffer buf)
- throws IOException, PacketDecodeException {
- char zeroOne = buf.get();
- if (zeroOne == '0') {
- return false;
- }
- else if (zeroOne == '1') {
- return true;
- }
- else {
- throw new InvalidPacketException(
- "Expected boolean (1/0) for " + field + ". Got " + zeroOne);
- }
- }
-
- @Override
- public byte decodeByte(Field field, CharBuffer buf) throws IOException, PacketDecodeException {
- return decodeByte(field, buf, DEFAULT_RADIX);
- }
-
- @Override
- public char decodeChar(Field field, CharBuffer buf) throws IOException, PacketDecodeException {
- return buf.get();
- }
-
- @Override
- public short decodeShort(Field field, CharBuffer buf)
- throws IOException, PacketDecodeException {
- return decodeShort(field, buf, DEFAULT_RADIX);
- }
-
- @Override
- public int decodeInt(Field field, CharBuffer buf) throws IOException, PacketDecodeException {
- return decodeInt(field, buf, DEFAULT_RADIX);
- }
-
- @Override
- public long decodeLong(Field field, CharBuffer buf) throws IOException, PacketDecodeException {
- return decodeLong(field, buf, DEFAULT_RADIX);
- }
-
- @Override
- public float decodeFloat(Field field, CharBuffer buf)
- throws IOException, PacketDecodeException {
- String part = readFloatingPoint(buf);
- try {
- return Float.parseFloat(part);
- }
- catch (NumberFormatException e) {
- throw new InvalidPacketException("Malformed float", e);
- }
- }
-
- @Override
- public double decodeDouble(Field field, CharBuffer buf)
- throws IOException, PacketDecodeException {
- String part = readFloatingPoint(buf);
- try {
- return Double.parseDouble(part);
- }
- catch (NumberFormatException e) {
- throw new InvalidPacketException("Malformed double", e);
- }
- }
-
- @Override
- @SuppressWarnings("unchecked")
- public <E extends Enum<E>> E decodeEnumConstant(Field field, CharBuffer buf, Class<E> type)
- throws IOException, PacketDecodeException {
- Map<String, Enum<?>> longestFirst = longestNamesByEnumClass.get(type);
- int pos = getDecodePosition(buf);
- String dec = "";
- for (Map.Entry<String, Enum<?>> ent : longestFirst.entrySet()) {
- setDecodePosition(buf, pos);
- String name = ent.getKey();
- int len = name.length();
- if (measureDecodeRemaining(buf) >= len) {
- dec = decodeCharSequence(field, buf, len);
- if (name.equals(dec)) {
- return (E) ent.getValue();
- }
- }
- }
-
- setDecodePosition(buf, pos);
- throw new PacketFieldValueMismatchException(field, longestFirst.keySet(), dec);
- }
-
- @Override
- public String decodeCharSequence(Field field, CharBuffer buf, Integer count)
- throws IOException, PacketDecodeException {
- return readString(buf, count == null ? null : count.intValue());
- }
-
- @Override
- public void encodeBoolean(StringBuilder buf, Field field, boolean val)
- throws IOException, PacketEncodeException {
- if (val) {
- buf.append('1');
- }
- else {
- buf.append('0');
- }
- }
-
- @Override
- public void encodeByte(StringBuilder buf, Field field, byte val)
- throws IOException, PacketEncodeException {
- encodeByte(buf, field, val, DEFAULT_RADIX);
- }
-
- @Override
- public void encodeChar(StringBuilder buf, Field field, char val) {
- buf.append(val);
- }
-
- @Override
- public void encodeShort(StringBuilder buf, Field field, short val) {
- encodeShort(buf, field, val, DEFAULT_RADIX);
- }
-
- @Override
- public void encodeInt(StringBuilder buf, Field field, int val) {
- encodeInt(buf, field, val, DEFAULT_RADIX);
- }
-
- @Override
- public void encodeLong(StringBuilder buf, Field field, long val) {
- encodeLong(buf, field, val, DEFAULT_RADIX);
- }
-
- @Override
- public void encodeFloat(StringBuilder buf, Field field, float val) {
- encodeFloat(buf, field, val, false);
- }
-
- @Override
- public void encodeDouble(StringBuilder buf, Field field, double val) {
- encodeDouble(buf, field, val, false);
- }
-
- @Override
- public void encodeEnumConstant(StringBuilder buf, Field field, Enum<?> val) {
- if (val instanceof CustomNamedEnum) {
- encodeCharSequence(buf, field, ((CustomNamedEnum) val).getCustomName());
- }
- else {
- encodeCharSequence(buf, field, val.name());
- }
- }
-
- @Override
- public void encodeCharSequence(StringBuilder buf, Field field, CharSequence val) {
- buf.append(val);
- }
-
- @Override
- public void encodePacket(String buf, Packet pkt) throws PacketEncodeException {
- throw new UnsupportedOperationException("Strings are immutable");
- }
-
- @Override
- public WrapperFactory<StringBuilder, CharBuffer> getFactoryForAnnotation(
- Class<? extends Packet> pkt, Field field, Annotation annot) {
- if (annot.annotationType() == RegexSeparated.class) {
- return new RegexSeparatedWrapperFactory<>();
- }
- else if (annot.annotationType() == RegexTerminated.class) {
- return new RegexTerminatedWrapperFactory();
- }
- else if (annot.annotationType() == SizeRestricted.class) {
- return new SizeRestrictedWrapperFactory<>();
- }
- else if (annot.annotationType() == WithRadix.class) {
- return new WithRadixWrapperFactory();
- }
- else if (annot.annotationType() == WithSign.class) {
- return new WithSignWrapperFactory();
- }
- return super.getFactoryForAnnotation(pkt, field, annot);
- }
-
- @SuppressWarnings({ "unchecked", "rawtypes" })
- @Override
- public <U> FieldCodec<StringBuilder, CharBuffer, U> getFieldCodecForType(
- Class<? extends Packet> pktType, Field field, Class<? extends U> fldType) {
- if (fldType == char[].class) {
- return (FieldCodec<StringBuilder, CharBuffer, U>) new CharArrayFieldCodec(this, pktType,
- field);
- }
- else if (fldType.isEnum()) {
- return new StringEnumFieldCodec(this, pktType, field, fldType);
- }
- return super.getFieldCodecForType(pktType, field, fldType);
- }
-
- @Override
- protected String finishEncode(StringBuilder buf) {
- return buf.toString();
- }
-
- @Override
- public void appendEncoded(StringBuilder into, StringBuilder from) throws IOException {
- into.append(from);
- }
-
- @Override
- public int getDecodePosition(CharBuffer buf) {
- return buf.position();
- }
-
- @Override
- public int limitDecodeBuffer(CharBuffer buf, int len) {
- int cur = buf.limit();
- buf.limit(len);
- return cur;
- }
-
- @Override
- public int measureDecodeRemaining(CharBuffer buf) {
- return buf.remaining();
- }
-
- @Override
- public int measureEncodeSize(StringBuilder buf) {
- return buf.length();
- }
-
- @Override
- public CharBuffer newDecodeBuffer(String data) {
- return CharBuffer.wrap(data);
- }
-
- @Override
- public StringBuilder newEncodeBuffer() {
- return new StringBuilder();
- }
-
- @Override
- public void setDecodePosition(CharBuffer buf, int pos) {
- buf.position(pos);
- }
-
- @Override
- public void setEncodePosition(StringBuilder buf, int pos) {
- buf.setLength(pos);
- }
-
- /**
- * An interface for {@code enum}s to control their encoding
- *
- * It's possible a protocol specifies some list of commands well suited for enumeration.
- * However, the text of the commands may not be suitable as names in a Java {@code enum}. Some
- * characters may not be legal in Java identifiers. Furthermore, coding standards usually
- * require names in {@code UPPER_CASE_WITH_UNDERSCORES}. If an {@code enum} implements this
- * interface, it can encode its values to something other than their names so long as each
- * custom name is still unique within the enumeration.
- */
- public static interface CustomNamedEnum {
- /**
- * Get the custom name for encoding this enumeration constant
- *
- * @return the custom name
- */
- public String getCustomName();
- }
-}
diff --git a/Ghidra/Debug/Framework-AsyncComm/src/main/java/ghidra/comm/packet/string/WithRadix.java b/Ghidra/Debug/Framework-AsyncComm/src/main/java/ghidra/comm/packet/string/WithRadix.java
deleted file mode 100644
index e2a37c1cf7..0000000000
--- a/Ghidra/Debug/Framework-AsyncComm/src/main/java/ghidra/comm/packet/string/WithRadix.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/* ###
- * 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 ghidra.comm.packet.string;
-
-import java.lang.annotation.*;
-
-import ghidra.comm.packet.PacketCodec;
-
-/**
- * An annotation to modify the radix of an encoded numeric value
- *
- * This annotation transforms a numeric type into a {@link String}. This may have unintended
- * consequences if the {@link PacketCodec} encodes to bytes. Most string codecs will apply a radix
- * of 16 by default, so this annotation provides a way to override that default. For floating-point
- * types, the radix must be 10 or 16. All others may use a radix from 2 to 36, inclusive.
- *
- * @see Long#toString(int, int)
- * @see Float#toString(float)
- * @see Float#toHexString(float)
- * @see Double#toString(double)
- * @see Double#toHexString(double)
- */
-@Retention(RetentionPolicy.RUNTIME)
-@Target(ElementType.FIELD)
-public @interface WithRadix {
- /**
- * The radix to use for string encoding
- *
- * @return the radix
- */
- int value();
-}
diff --git a/Ghidra/Debug/Framework-AsyncComm/src/main/java/ghidra/comm/packet/string/WithRadixByteFieldCodec.java b/Ghidra/Debug/Framework-AsyncComm/src/main/java/ghidra/comm/packet/string/WithRadixByteFieldCodec.java
deleted file mode 100644
index 031efe964d..0000000000
--- a/Ghidra/Debug/Framework-AsyncComm/src/main/java/ghidra/comm/packet/string/WithRadixByteFieldCodec.java
+++ /dev/null
@@ -1,64 +0,0 @@
-/* ###
- * 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 ghidra.comm.packet.string;
-
-import java.io.IOException;
-import java.lang.reflect.Field;
-import java.nio.CharBuffer;
-
-import ghidra.comm.packet.Packet;
-import ghidra.comm.packet.PacketFactory;
-import ghidra.comm.packet.err.PacketDecodeException;
-import ghidra.comm.packet.err.PacketEncodeException;
-import ghidra.comm.packet.fields.AbstractFieldCodec;
-import ghidra.comm.packet.fields.FieldCodec;
-
-/**
- * The {@link FieldCodec} for {@code byte} fields annotated by {@link WithRadix}
- *
- * @see WithRadixWrapperFactory
- */
-public class WithRadixByteFieldCodec extends AbstractFieldCodec<StringBuilder, CharBuffer, Byte> {
- private final int radix;
- private final StringPacketCodec strCodec;
- private final FieldCodec<StringBuilder, CharBuffer, String> chainNext;
-
- public WithRadixByteFieldCodec(Class<? extends Packet> pktType, Field field, int radix,
- StringPacketCodec strCodec, FieldCodec<StringBuilder, CharBuffer, String> chainNext) {
- super(pktType, field);
- this.radix = radix;
- this.strCodec = strCodec;
- this.chainNext = chainNext;
- }
-
- @Override
- public Byte decodeField(Packet pkt, CharBuffer buf, Integer count, PacketFactory factory)
- throws IOException, PacketDecodeException {
- int len = StringPacketCodec.computeMaxChars(radix, 1);
- CharBuffer part = CharBuffer.wrap(chainNext.decodeField(pkt, buf, len, factory));
- Byte result = strCodec.decodeByte(field, part, radix);
- buf.position(buf.position() - part.remaining());
- return result;
- }
-
- @Override
- public void encodeField(StringBuilder buf, Packet pkt, Byte val)
- throws IOException, PacketEncodeException {
- StringBuilder part = strCodec.newEncodeBuffer();
- strCodec.encodeByte(part, field, val, radix);
- chainNext.encodeField(buf, pkt, part.toString());
- }
-}
diff --git a/Ghidra/Debug/Framework-AsyncComm/src/main/java/ghidra/comm/packet/string/WithRadixDoubleFieldCodec.java b/Ghidra/Debug/Framework-AsyncComm/src/main/java/ghidra/comm/packet/string/WithRadixDoubleFieldCodec.java
deleted file mode 100644
index 2fb01b899f..0000000000
--- a/Ghidra/Debug/Framework-AsyncComm/src/main/java/ghidra/comm/packet/string/WithRadixDoubleFieldCodec.java
+++ /dev/null
@@ -1,64 +0,0 @@
-/* ###
- * 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 ghidra.comm.packet.string;
-
-import java.io.IOException;
-import java.lang.reflect.Field;
-import java.nio.CharBuffer;
-
-import ghidra.comm.packet.Packet;
-import ghidra.comm.packet.PacketFactory;
-import ghidra.comm.packet.err.PacketDecodeException;
-import ghidra.comm.packet.err.PacketEncodeException;
-import ghidra.comm.packet.fields.AbstractFieldCodec;
-import ghidra.comm.packet.fields.FieldCodec;
-
-/**
- * The {@link FieldCodec} for {@code double} fields annotated by {@link WithRadix}
- *
- * @see WithRadixWrapperFactory
- */
-public class WithRadixDoubleFieldCodec
- extends AbstractFieldCodec<StringBuilder, CharBuffer, Double> {
- private final int radix;
- private final StringPacketCodec strCodec;
- private final FieldCodec<StringBuilder, CharBuffer, String> chainNext;
-
- public WithRadixDoubleFieldCodec(Class<? extends Packet> pktType, Field field, int radix,
- StringPacketCodec strCodec, FieldCodec<StringBuilder, CharBuffer, String> chainNext) {
- super(pktType, field);
- this.radix = radix;
- this.strCodec = strCodec;
- this.chainNext = chainNext;
- }
-
- @Override
- public Double decodeField(Packet pkt, CharBuffer buf, Integer count, PacketFactory factory)
- throws IOException, PacketDecodeException {
- CharBuffer part = CharBuffer.wrap(chainNext.decodeField(pkt, buf, null, factory));
- Double result = strCodec.decodeDouble(field, part);
- buf.position(buf.position() - part.remaining());
- return result;
- }
-
- @Override
- public void encodeField(StringBuilder buf, Packet pkt, Double val)
- throws IOException, PacketEncodeException {
- StringBuilder part = strCodec.newEncodeBuffer();
- strCodec.encodeDouble(part, field, val, radix == 16);
- chainNext.encodeField(buf, pkt, part.toString());
- }
-}
diff --git a/Ghidra/Debug/Framework-AsyncComm/src/main/java/ghidra/comm/packet/string/WithRadixFloatFieldCodec.java b/Ghidra/Debug/Framework-AsyncComm/src/main/java/ghidra/comm/packet/string/WithRadixFloatFieldCodec.java
deleted file mode 100644
index b4ad728551..0000000000
--- a/Ghidra/Debug/Framework-AsyncComm/src/main/java/ghidra/comm/packet/string/WithRadixFloatFieldCodec.java
+++ /dev/null
@@ -1,63 +0,0 @@
-/* ###
- * 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 ghidra.comm.packet.string;
-
-import java.io.IOException;
-import java.lang.reflect.Field;
-import java.nio.CharBuffer;
-
-import ghidra.comm.packet.Packet;
-import ghidra.comm.packet.PacketFactory;
-import ghidra.comm.packet.err.PacketDecodeException;
-import ghidra.comm.packet.err.PacketEncodeException;
-import ghidra.comm.packet.fields.AbstractFieldCodec;
-import ghidra.comm.packet.fields.FieldCodec;
-
-/**
- * The {@link FieldCodec} for {@code float} fields annotated by {@link WithRadix}
- *
- * @see WithRadixWrapperFactory
- */
-public class WithRadixFloatFieldCodec extends AbstractFieldCodec<StringBuilder, CharBuffer, Float> {
- private final int radix;
- private final StringPacketCodec strCodec;
- private final FieldCodec<StringBuilder, CharBuffer, String> chainNext;
-
- public WithRadixFloatFieldCodec(Class<? extends Packet> pktType, Field field, int radix,
- StringPacketCodec strCodec, FieldCodec<StringBuilder, CharBuffer, String> chainNext) {
- super(pktType, field);
- this.radix = radix;
- this.strCodec = strCodec;
- this.chainNext = chainNext;
- }
-
- @Override
- public Float decodeField(Packet pkt, CharBuffer buf, Integer count, PacketFactory factory)
- throws IOException, PacketDecodeException {
- CharBuffer part = CharBuffer.wrap(chainNext.decodeField(pkt, buf, null, factory));
- Float result = strCodec.decodeFloat(field, part);
- buf.position(buf.position() - part.remaining());
- return result;
- }
-
- @Override
- public void encodeField(StringBuilder buf, Packet pkt, Float val)
- throws IOException, PacketEncodeException {
- StringBuilder part = strCodec.newEncodeBuffer();
- strCodec.encodeFloat(part, field, val, radix == 16);
- chainNext.encodeField(buf, pkt, part.toString());
- }
-}
diff --git a/Ghidra/Debug/Framework-AsyncComm/src/main/java/ghidra/comm/packet/string/WithRadixIntegerFieldCodec.java b/Ghidra/Debug/Framework-AsyncComm/src/main/java/ghidra/comm/packet/string/WithRadixIntegerFieldCodec.java
deleted file mode 100644
index 5805888f6d..0000000000
--- a/Ghidra/Debug/Framework-AsyncComm/src/main/java/ghidra/comm/packet/string/WithRadixIntegerFieldCodec.java
+++ /dev/null
@@ -1,65 +0,0 @@
-/* ###
- * 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 ghidra.comm.packet.string;
-
-import java.io.IOException;
-import java.lang.reflect.Field;
-import java.nio.CharBuffer;
-
-import ghidra.comm.packet.Packet;
-import ghidra.comm.packet.PacketFactory;
-import ghidra.comm.packet.err.PacketDecodeException;
-import ghidra.comm.packet.err.PacketEncodeException;
-import ghidra.comm.packet.fields.AbstractFieldCodec;
-import ghidra.comm.packet.fields.FieldCodec;
-
-/**
- * The {@link FieldCodec} for {@code int} fields annotated by {@link WithRadix}
- *
- * @see WithRadixWrapperFactory
- */
-public class WithRadixIntegerFieldCodec
- extends AbstractFieldCodec<StringBuilder, CharBuffer, Integer> {
- private final int radix;
- private final StringPacketCodec strCodec;
- private final FieldCodec<StringBuilder, CharBuffer, String> chainNext;
-
- public WithRadixIntegerFieldCodec(Class<? extends Packet> pktType, Field field, int radix,
- StringPacketCodec strCodec, FieldCodec<StringBuilder, CharBuffer, String> chainNext) {
- super(pktType, field);
- this.radix = radix;
- this.strCodec = strCodec;
- this.chainNext = chainNext;
- }
-
- @Override
- public Integer decodeField(Packet pkt, CharBuffer buf, Integer count, PacketFactory factory)
- throws IOException, PacketDecodeException {
- int len = StringPacketCodec.computeMaxChars(radix, 4);
- CharBuffer part = CharBuffer.wrap(chainNext.decodeField(pkt, buf, len, factory));
- Integer result = strCodec.decodeInt(field, part, radix);
- buf.position(buf.position() - part.remaining());
- return result;
- }
-
- @Override
- public void encodeField(StringBuilder buf, Packet pkt, Integer val)
- throws IOException, PacketEncodeException {
- StringBuilder part = strCodec.newEncodeBuffer();
- strCodec.encodeInt(part, field, val, radix);
- chainNext.encodeField(buf, pkt, part.toString());
- }
-}
diff --git a/Ghidra/Debug/Framework-AsyncComm/src/main/java/ghidra/comm/packet/string/WithRadixLongFieldCodec.java b/Ghidra/Debug/Framework-AsyncComm/src/main/java/ghidra/comm/packet/string/WithRadixLongFieldCodec.java
deleted file mode 100644
index db0a969ce0..0000000000
--- a/Ghidra/Debug/Framework-AsyncComm/src/main/java/ghidra/comm/packet/string/WithRadixLongFieldCodec.java
+++ /dev/null
@@ -1,64 +0,0 @@
-/* ###
- * 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 ghidra.comm.packet.string;
-
-import java.io.IOException;
-import java.lang.reflect.Field;
-import java.nio.CharBuffer;
-
-import ghidra.comm.packet.Packet;
-import ghidra.comm.packet.PacketFactory;
-import ghidra.comm.packet.err.PacketDecodeException;
-import ghidra.comm.packet.err.PacketEncodeException;
-import ghidra.comm.packet.fields.AbstractFieldCodec;
-import ghidra.comm.packet.fields.FieldCodec;
-
-/**
- * The {@link FieldCodec} for {@code long} fields annotated by {@link WithRadix}
- *
- * @see WithRadixWrapperFactory
- */
-public class WithRadixLongFieldCodec extends AbstractFieldCodec<StringBuilder, CharBuffer, Long> {
- private final int radix;
- private final StringPacketCodec strCodec;
- private final FieldCodec<StringBuilder, CharBuffer, String> chainNext;
-
- public WithRadixLongFieldCodec(Class<? extends Packet> pktType, Field field, int radix,
- StringPacketCodec strCodec, FieldCodec<StringBuilder, CharBuffer, String> chainNext) {
- super(pktType, field);
- this.radix = radix;
- this.strCodec = strCodec;
- this.chainNext = chainNext;
- }
-
- @Override
- public Long decodeField(Packet pkt, CharBuffer buf, Integer count, PacketFactory factory)
- throws IOException, PacketDecodeException {
- int len = StringPacketCodec.computeMaxChars(radix, 8);
- CharBuffer part = CharBuffer.wrap(chainNext.decodeField(pkt, buf, len, factory));
- Long result = strCodec.decodeLong(field, part, radix);
- buf.position(buf.position() - part.remaining());
- return result;
- }
-
- @Override
- public void encodeField(StringBuilder buf, Packet pkt, Long val)
- throws IOException, PacketEncodeException {
- StringBuilder part = strCodec.newEncodeBuffer();
- strCodec.encodeLong(part, field, val, radix);
- chainNext.encodeField(buf, pkt, part.toString());
- }
-}
diff --git a/Ghidra/Debug/Framework-AsyncComm/src/main/java/ghidra/comm/packet/string/WithRadixShortFieldCodec.java b/Ghidra/Debug/Framework-AsyncComm/src/main/java/ghidra/comm/packet/string/WithRadixShortFieldCodec.java
deleted file mode 100644
index 9cb0b5028b..0000000000
--- a/Ghidra/Debug/Framework-AsyncComm/src/main/java/ghidra/comm/packet/string/WithRadixShortFieldCodec.java
+++ /dev/null
@@ -1,64 +0,0 @@
-/* ###
- * 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 ghidra.comm.packet.string;
-
-import java.io.IOException;
-import java.lang.reflect.Field;
-import java.nio.CharBuffer;
-
-import ghidra.comm.packet.Packet;
-import ghidra.comm.packet.PacketFactory;
-import ghidra.comm.packet.err.PacketDecodeException;
-import ghidra.comm.packet.err.PacketEncodeException;
-import ghidra.comm.packet.fields.AbstractFieldCodec;
-import ghidra.comm.packet.fields.FieldCodec;
-
-/**
- * The {@link FieldCodec} for {@code short} fields annotated by {@link WithRadix}
- *
- * @see WithRadixWrapperFactory
- */
-public class WithRadixShortFieldCodec extends AbstractFieldCodec<StringBuilder, CharBuffer, Short> {
- private final int radix;
- private final StringPacketCodec strCodec;
- private final FieldCodec<StringBuilder, CharBuffer, String> chainNext;
-
- public WithRadixShortFieldCodec(Class<? extends Packet> pktType, Field field, int radix,
- StringPacketCodec strCodec, FieldCodec<StringBuilder, CharBuffer, String> chainNext) {
- super(pktType, field);
- this.radix = radix;
- this.strCodec = strCodec;
- this.chainNext = chainNext;
- }
-
- @Override
- public Short decodeField(Packet pkt, CharBuffer buf, Integer count, PacketFactory factory)
- throws IOException, PacketDecodeException {
- int len = StringPacketCodec.computeMaxChars(radix, 2);
- CharBuffer part = CharBuffer.wrap(chainNext.decodeField(pkt, buf, len, factory));
- Short result = strCodec.decodeShort(field, part, radix);
- buf.position(buf.position() - part.remaining());
- return result;
- }
-
- @Override
- public void encodeField(StringBuilder buf, Packet pkt, Short val)
- throws IOException, PacketEncodeException {
- StringBuilder part = strCodec.newEncodeBuffer();
- strCodec.encodeShort(part, field, val, radix);
- chainNext.encodeField(buf, pkt, part.toString());
- }
-}
diff --git a/Ghidra/Debug/Framework-AsyncComm/src/main/java/ghidra/comm/packet/string/WithRadixWrapperFactory.java b/Ghidra/Debug/Framework-AsyncComm/src/main/java/ghidra/comm/packet/string/WithRadixWrapperFactory.java
deleted file mode 100644
index 94e25b8abb..0000000000
--- a/Ghidra/Debug/Framework-AsyncComm/src/main/java/ghidra/comm/packet/string/WithRadixWrapperFactory.java
+++ /dev/null
@@ -1,87 +0,0 @@
-/* ###
- * 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 ghidra.comm.packet.string;
-
-import java.lang.reflect.Field;
-import java.nio.CharBuffer;
-import java.util.Deque;
-
-import ghidra.comm.packet.Packet;
-import ghidra.comm.packet.codecs.PacketCodecInternal;
-import ghidra.comm.packet.err.PacketAnnotationException;
-import ghidra.comm.packet.fields.*;
-
-/**
- * The factory implementing {@link WithRadix}
- */
-public class WithRadixWrapperFactory extends AbstractWrapperFactory<StringBuilder, CharBuffer> {
- @SuppressWarnings("unchecked")
- @Override
- public <T> FieldCodec<StringBuilder, CharBuffer, T> getWrappedFieldCodecForType(
- Class<? extends Packet> pktType, Field field, Class<? extends T> fldType,
- PacketCodecInternal<?, StringBuilder, CharBuffer> codec,
- Deque<FieldCodecFactory<StringBuilder, CharBuffer>> chain) {
- if (!(codec instanceof StringPacketCodec)) {
- return FieldCodecFactory.buildChainForType(pktType, field, fldType, codec, chain);
- }
- StringPacketCodec strCodec = (StringPacketCodec) codec;
- WithRadix annot = field.getAnnotation(WithRadix.class);
- int radix = annot.value();
- if (radix == 10) {
- // Do nothing, floats with radix 10 are allowed
- }
- else if (radix == 16) {
- // Do nothing, floats with radix 16 are allowed
- }
- else if (fldType == float.class || fldType == float[].class || fldType == double.class ||
- fldType == double[].class) {
- throw new PacketAnnotationException(pktType, field, annot,
- "Floating-point field must have radix 10 or 16");
- }
- else if (Float.class.isAssignableFrom(fldType) || Double.class.isAssignableFrom(fldType)) {
- throw new PacketAnnotationException(pktType, field, annot,
- "Floating-point field must have radix 10 or 16");
- }
-
- FieldCodec<StringBuilder, CharBuffer, String> chainNext =
- FieldCodecFactory.buildChainForType(pktType, field, String.class, codec, chain);
- if (fldType == byte.class || Byte.class.isAssignableFrom(fldType)) {
- return (FieldCodec<StringBuilder, CharBuffer, T>) new WithRadixByteFieldCodec(pktType,
- field, radix, strCodec, chainNext);
- }
- else if (fldType == short.class || Short.class.isAssignableFrom(fldType)) {
- return (FieldCodec<StringBuilder, CharBuffer, T>) new WithRadixShortFieldCodec(pktType,
- field, radix, strCodec, chainNext);
- }
- else if (fldType == int.class || Integer.class.isAssignableFrom(fldType)) {
- return (FieldCodec<StringBuilder, CharBuffer, T>) new WithRadixIntegerFieldCodec(
- pktType, field, radix, strCodec, chainNext);
- }
- else if (fldType == long.class || Long.class.isAssignableFrom(fldType)) {
- return (FieldCodec<StringBuilder, CharBuffer, T>) new WithRadixLongFieldCodec(pktType,
- field, radix, strCodec, chainNext);
- }
- else if (fldType == float.class || Float.class.isAssignableFrom(fldType)) {
- return (FieldCodec<StringBuilder, CharBuffer, T>) new WithRadixFloatFieldCodec(pktType,
- field, radix, strCodec, chainNext);
- }
- else if (fldType == double.class || Double.class.isAssignableFrom(fldType)) {
- return (FieldCodec<StringBuilder, CharBuffer, T>) new WithRadixDoubleFieldCodec(pktType,
- field, radix, strCodec, chainNext);
- }
- return null;
- }
-}
diff --git a/Ghidra/Debug/Framework-AsyncComm/src/main/java/ghidra/comm/packet/string/WithSign.java b/Ghidra/Debug/Framework-AsyncComm/src/main/java/ghidra/comm/packet/string/WithSign.java
deleted file mode 100644
index b64a9475f1..0000000000
--- a/Ghidra/Debug/Framework-AsyncComm/src/main/java/ghidra/comm/packet/string/WithSign.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/* ###
- * 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 ghidra.comm.packet.string;
-
-import static java.lang.annotation.ElementType.FIELD;
-import static java.lang.annotation.RetentionPolicy.RUNTIME;
-
-import java.lang.annotation.Retention;
-import java.lang.annotation.Target;
-
-/**
- * An annotation to encode a signed integral type
- *
- * As a design decision, the {@link StringPacketCodec} encodes its integral types as if unsigned,
- * despite Java's insistence on signed types. Applying this annotation overrides this behavior. This
- * is only meaningful when encoding an integer as a {@link String}, i.e., using a string-based codec
- * or {@link WithRadix}.
- */
-@Retention(RUNTIME)
-@Target(FIELD)
-public @interface WithSign {
- // No attributes
-}
diff --git a/Ghidra/Debug/Framework-AsyncComm/src/main/java/ghidra/comm/packet/string/WithSignFieldCodec.java b/Ghidra/Debug/Framework-AsyncComm/src/main/java/ghidra/comm/packet/string/WithSignFieldCodec.java
deleted file mode 100644
index 8531669dda..0000000000
--- a/Ghidra/Debug/Framework-AsyncComm/src/main/java/ghidra/comm/packet/string/WithSignFieldCodec.java
+++ /dev/null
@@ -1,70 +0,0 @@
-/* ###
- * 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 ghidra.comm.packet.string;
-
-import java.io.IOException;
-import java.lang.reflect.Field;
-import java.nio.CharBuffer;
-
-import ghidra.comm.packet.Packet;
-import ghidra.comm.packet.PacketFactory;
-import ghidra.comm.packet.err.PacketDecodeException;
-import ghidra.comm.packet.err.PacketEncodeException;
-import ghidra.comm.packet.fields.AbstractFieldCodec;
-import ghidra.comm.packet.fields.FieldCodec;
-
-/**
- * The {@link FieldCodec} for fields annotated by {@link WithSign}
- *
- * @see WithSignWrapperFactory
- *
- * @param <T> the type of the field as passed through the chain
- */
-public class WithSignFieldCodec<T> extends AbstractFieldCodec<StringBuilder, CharBuffer, T> {
- private final Class<? extends T> fldType;
- private final FieldCodec<StringBuilder, CharBuffer, T> chainNext;
-
- public WithSignFieldCodec(Class<? extends Packet> pktType, Field field,
- Class<? extends T> fldType, FieldCodec<StringBuilder, CharBuffer, T> chainNext) {
- super(pktType, field);
- this.fldType = fldType;
- this.chainNext = chainNext;
- }
-
- @Override
- public T decodeField(Packet pkt, CharBuffer buf, Integer count, PacketFactory factory)
- throws IOException, PacketDecodeException {
- if (buf.charAt(0) == '-') {
- buf.get();
- long n = getIntegralValue(chainNext.decodeField(pkt, buf, count, factory));
- return getIntegralOfType(fldType, -n);
- }
- return chainNext.decodeField(pkt, buf, count, factory);
- }
-
- @Override
- public void encodeField(StringBuilder buf, Packet pkt, T val)
- throws IOException, PacketEncodeException {
- long n = getIntegralValue(val);
- if (n < 0) {
- buf.append('-');
- chainNext.encodeField(buf, pkt, getIntegralOfType(fldType, -n));
- }
- else {
- chainNext.encodeField(buf, pkt, val);
- }
- }
-}
diff --git a/Ghidra/Debug/Framework-AsyncComm/src/main/java/ghidra/comm/packet/string/WithSignWrapperFactory.java b/Ghidra/Debug/Framework-AsyncComm/src/main/java/ghidra/comm/packet/string/WithSignWrapperFactory.java
deleted file mode 100644
index 7e51928fc7..0000000000
--- a/Ghidra/Debug/Framework-AsyncComm/src/main/java/ghidra/comm/packet/string/WithSignWrapperFactory.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/* ###
- * 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 ghidra.comm.packet.string;
-
-import static ghidra.comm.packet.fields.AbstractFieldCodec.isIntegralType;
-
-import java.lang.reflect.Field;
-import java.nio.CharBuffer;
-import java.util.Deque;
-
-import ghidra.comm.packet.Packet;
-import ghidra.comm.packet.codecs.PacketCodecInternal;
-import ghidra.comm.packet.fields.*;
-
-/**
- * The factory implementing {@link WithSign}
- */
-public class WithSignWrapperFactory extends AbstractWrapperFactory<StringBuilder, CharBuffer> {
- @Override
- public <T> FieldCodec<StringBuilder, CharBuffer, T> getWrappedFieldCodecForType(
- Class<? extends Packet> pktType, Field field, Class<? extends T> fldType,
- PacketCodecInternal<?, StringBuilder, CharBuffer> codec,
- Deque<FieldCodecFactory<StringBuilder, CharBuffer>> chain) {
- @SuppressWarnings("unused")
- WithSign annot = field.getAnnotation(WithSign.class);
-
- FieldCodec<StringBuilder, CharBuffer, T> chainNext =
- FieldCodecFactory.buildChainForType(pktType, field, fldType, codec, chain);
- if (isIntegralType(fldType)) {
- return new WithSignFieldCodec<>(pktType, field, fldType, chainNext);
- }
- return null;
- }
-}
diff --git a/Ghidra/Debug/Framework-AsyncComm/src/main/java/ghidra/comm/util/pyexport/GeneratePython.java b/Ghidra/Debug/Framework-AsyncComm/src/main/java/ghidra/comm/util/pyexport/GeneratePython.java
deleted file mode 100644
index 7f4c72d1db..0000000000
--- a/Ghidra/Debug/Framework-AsyncComm/src/main/java/ghidra/comm/util/pyexport/GeneratePython.java
+++ /dev/null
@@ -1,367 +0,0 @@
-/* ###
- * 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 ghidra.comm.util.pyexport;
-
-import java.io.File;
-import java.io.IOException;
-import java.lang.annotation.Annotation;
-import java.lang.reflect.*;
-import java.util.*;
-import java.util.Map.Entry;
-
-import org.apache.commons.lang3.ClassUtils;
-import org.apache.commons.lang3.StringUtils;
-import org.apache.commons.lang3.reflect.TypeUtils;
-
-import com.google.common.primitives.Primitives;
-import com.google.common.reflect.ClassPath;
-import com.google.common.reflect.ClassPath.ClassInfo;
-
-import ghidra.comm.packet.Packet;
-import ghidra.comm.packet.annot.TypedByField;
-import ghidra.comm.packet.binary.BinaryPacketCodec;
-import ghidra.comm.packet.fields.PacketField;
-import ghidra.graph.algo.SorterException;
-import ghidra.util.Msg;
-
-/**
- * A command-line utility to export a set of packet specification to Python
- *
- * The exported classes are generally usable out-of-the-box, but there are some caveats:
- *
- * <ol>
- * <li>The names of nested classes are slightly mangled, since nested classes in Python have a
- * subtly different meaning than those in Java. The packet class my.pkg.A.B in java will be exported
- * as my.pkg.A_B in Python.</li>
- * <li>The exported classes must be used with the provided {@code ghidra.comm.packet} and
- * {@code java} Python packages.</li>
- * <li>Any custom annotations must be ported manually to Python.</li>
- * <li>Any custom field types must be ported manually to Python.</li>
- * <li>Currently, only {@link BinaryPacketCodec} is ported to Python.</li>
- * <li>Some common Java types may not have placeholders implemented. If more are needed, it may be
- * necessary to submit a feature request or monkey patch them in.</li>
- * </ol>
- */
-public class GeneratePython {
- /**
- * Execute the utility:
- *
- * <pre>
- * java -cp ... GeneratePython [PACKAGE] [OUTPUT_DIR]
- * </pre>
- *
- * This exports all packets found in the package {@code [PACKAGE]} and all of its subpackages
- * into a Python package at {@code [OUTPUT_DIR]}.
- *
- * @param args
- */
- public static void main(String[] args) {
- System.exit(new GeneratePython().run(args));
- }
-
- private PythonPackage rootPkg = new PythonPackage(this, "", null);
-
- private void exportClass(Class<?> cls)
- throws IllegalAccessException, IllegalArgumentException, InvocationTargetException,
- NoSuchFieldException, SecurityException, NoSuchMethodException {
- exportClass(cls, new HashSet<>());
- }
-
- @SuppressWarnings("unchecked")
- private void exportClass(Class<?> cls, Set<Class<?>> visited)
- throws IllegalAccessException, IllegalArgumentException, InvocationTargetException,
- NoSuchFieldException, SecurityException, NoSuchMethodException {
- if (!visited.add(cls)) {
- return;
- }
- if (Packet.class.isAssignableFrom(cls)) {
- exportPacketClass((Class<? extends Packet>) cls);
- }
- else if (cls.isEnum()) {
- exportEnumClass((Class<? extends Enum<?>>) cls);
- }
- for (Class<?> scls : cls.getClasses()) {
- exportClass(scls, visited);
- }
- }
-
- private void exportEnumClass(Class<? extends Enum<?>> javaEnum)
- throws NoSuchFieldException, SecurityException, IllegalAccessException,
- IllegalArgumentException, InvocationTargetException, NoSuchMethodException {
- PythonClass pyCls = javaToPyClass(javaEnum);
- pyCls.addBase(javaToPyClass(Enum.class));
- if (!pyCls.isExported) {
- pyCls.isExported = true;
- Map<String, Method> attrs = new LinkedHashMap<>();
- attrs.put("ordinal", javaEnum.getMethod("ordinal"));
- attrs.put("name", javaEnum.getMethod("name"));
- for (Method m : javaEnum.getDeclaredMethods()) {
- if (m.getName().startsWith("get")) {
- if (m.getParameterCount() == 0) {
- attrs.put(StringUtils.uncapitalize(m.getName().substring(3)), m);
- }
- }
- }
- pyCls.addLine(
- String.format("def __init__(self, %s):", StringUtils.join(attrs.keySet(), ", ")));
- for (String a : attrs.keySet()) {
- pyCls.addLine(String.format(" self.%s = %s", a, a));
- }
-
- Set<String> values = new LinkedHashSet<>();
- for (Enum<?> eConst : javaEnum.getEnumConstants()) {
- values.add(String.format("%s.%s", pyCls.getPythonShortName(), eConst.name()));
- Set<String> attrAssigns = new LinkedHashSet<>();
- for (Entry<String, Method> a : attrs.entrySet()) {
- attrAssigns.add(String.format("%s=%s", a.getKey(),
- regenerateValue(pyCls, javaEnum, a.getValue().invoke(eConst))));
- }
- pyCls.addPostAssign(eConst.name(), String.format("%s(%s)",
- pyCls.getPythonShortName(), StringUtils.join(attrAssigns, ", ")));
- }
- pyCls.addPostAssign("values", regenerateValue(pyCls, javaEnum, values));
- }
- }
-
- private void exportPackage(String pkgName) throws IOException, IllegalAccessException,
- IllegalArgumentException, InvocationTargetException, NoSuchFieldException,
- SecurityException, NoSuchMethodException {
- rootPkg.getSubPackage(pkgName).isExported = true;
- ClassPath cp = ClassPath.from(this.getClass().getClassLoader());
- for (ClassInfo ci : cp.getTopLevelClassesRecursive(pkgName)) {
- exportClass(ci.load());
- }
- }
-
- private void exportPacketClass(Class<? extends Packet> pktType)
- throws IllegalAccessException, IllegalArgumentException, InvocationTargetException,
- NoSuchFieldException, SecurityException {
- final List<Field> fields;
- try {
- if (Modifier.isAbstract(pktType.getModifiers())) {
- fields = Collections.emptyList();
- }
- else {
- fields = Packet.getFields(pktType);
- }
- }
- catch (Exception e) {
- Msg.error(this, "Could not export " + pktType, e);
- return;
- }
-
- PythonClass pyCls = packetToPyClass(pktType);
- if (!pyCls.isExported) {
- pyCls.isExported = true;
- PythonClass pySup = javaToPyClass(pktType.getSuperclass());
- pyCls.addBase(pySup);
- for (Field f : fields) {
- pyCls.addLine();
- for (Annotation annot : f.getAnnotations()) {
- Class<? extends Annotation> atype = annot.annotationType();
- if (atype == PacketField.class) {
- continue;
- }
- pyCls.addImport(javaToPyClass(atype));
- pyCls.addLine("@" + regenerateAnnotation(pyCls, pktType, annot));
- }
- Type type = f.getGenericType();
- String pytype = regenerateType(pyCls, pktType, type);
- StringBuilder decl = new StringBuilder();
- decl.append(String.format("@field(%s", pytype));
- if (Modifier.isFinal(f.getModifiers())) {
- decl.append(
- String.format(", fixed=%s", regenerateValue(pyCls, pktType, f.get(null))));
- }
- decl.append(")");
- pyCls.addLine(decl.toString());
- pyCls.addLine(String.format("def %s(self):", avoidReserved(f.getName())));
- pyCls.addLine(" pass");
- }
- }
- }
-
- private String avoidReserved(String id) {
- if ("exec".equals(id)) {
- return "_exec";
- }
- return id;
- }
-
- private PythonClass javaToPyClass(Class<?> cls) {
- PythonPackage pkg = rootPkg.getSubPackage(ClassUtils.getPackageName(cls));
- return pkg.getClass(ClassUtils.getShortClassName(cls).replace('.', '_'));
- }
-
- private String regenerateAnnotation(PythonClass pyCls, Class<?> javaCls, Annotation annot)
- throws IllegalAccessException, IllegalArgumentException, InvocationTargetException,
- NoSuchFieldException, SecurityException {
- StringBuilder sb = new StringBuilder();
- Class<?> type = annot.annotationType();
- PythonClass pyType = javaToPyClass(type);
- sb.append(pyType.getFullName(false));
- sb.append("(");
- boolean first = true;
- for (Method m : type.getDeclaredMethods()) {
- Object val = m.invoke(annot);
- if (m.getDefaultValue() == null || !m.getDefaultValue().equals(val)) {
- if (!first) {
- sb.append(", ");
- }
- first = false;
- sb.append(m.getName());
- sb.append("=");
- sb.append(regenerateValue(pyCls, javaCls, val));
- }
- }
- sb.append(")");
-
- // TODO: I don't care much for specific cases here, but aw well
- if (type == TypedByField.class) {
- TypedByField tbf = (TypedByField) annot;
- String mapName = tbf.map();
- if (!"".equals(mapName)) {
- Map<?, ?> map = (Map<?, ?>) javaCls.getField(mapName).get(null);
- pyCls.preLine(
- String.format("%s = %s", mapName, regenerateValue(pyCls, javaCls, map)));
- pyCls.preLine();
- }
- }
-
- return sb.toString();
- }
-
- private String regenerateArray(PythonClass pyCls, Class<?> javaCls, Object arr)
- throws ArrayIndexOutOfBoundsException, IllegalAccessException, IllegalArgumentException,
- InvocationTargetException, NoSuchFieldException, SecurityException {
- StringBuilder sb = new StringBuilder();
- sb.append('[');
- for (int i = 0; i < Array.getLength(arr); i++) {
- sb.append(regenerateValue(pyCls, javaCls, Array.get(arr, i)));
- sb.append(", ");
- }
- sb.append(']');
- return sb.toString();
- }
-
- private String regenerateEnum(PythonClass pyCls, Enum<?> enumval) {
- PythonClass pyEnum = javaToPyClass(enumval.getClass());
- return pyEnum.getFullName(true) + "." + enumval.name();
- }
-
- private String regenerateMap(PythonClass pyCls, Class<?> javaCls, Map<?, ?> map)
- throws IllegalAccessException, IllegalArgumentException, InvocationTargetException,
- NoSuchFieldException, SecurityException {
- pyCls.addImport("collections", "OrderedDict");
- StringBuilder sb = new StringBuilder();
- sb.append("OrderedDict([");
- for (Entry<?, ?> ent : map.entrySet()) {
- sb.append(String.format("(%s, %s), ", regenerateValue(pyCls, javaCls, ent.getKey()),
- regenerateValue(pyCls, javaCls, ent.getValue())));
- }
- sb.append("])");
- return sb.toString();
- }
-
- private String regenerateString(String str) {
- return "'" + str + "'";
- }
-
- private String regenerateType(PythonClass pyCls, Class<?> javaCls, Type type) {
- Class<?> asCls = TypeUtils.getRawType(type, javaCls);
- if (asCls.isArray()) {
- PythonClass pyType = javaToPyClass(List.class);
- pyCls.addImport(pyType);
- return String.format("typedesc(lambda:%s, E=%s)", pyType.getFullName(true),
- regenerateType(pyCls, javaCls, asCls.getComponentType()));
- }
- else if (asCls.isPrimitive()) {
- return regenerateType(pyCls, javaCls, Primitives.wrap(asCls));
- }
- else {
- StringBuilder sb = new StringBuilder();
- // TODO: This lambda thing is a bit dirty of a hack
- sb.append("typedesc(lambda:");
- PythonClass pyType = javaToPyClass(asCls);
- pyCls.addImport(pyType);
- sb.append(pyType.getFullName(true));
- for (Entry<TypeVariable<?>, Type> arg : TypeUtils.getTypeArguments(type, asCls)
- .entrySet()) {
- sb.append(String.format(", %s=%s", arg.getKey().getName(),
- regenerateType(pyCls, javaCls, arg.getValue())));
- }
- sb.append(")");
- return sb.toString();
- }
- }
-
- private String regenerateValue(PythonClass pyCls, Class<?> javaCls, Object val)
- throws IllegalAccessException, IllegalArgumentException, InvocationTargetException,
- NoSuchFieldException, SecurityException {
- if (val instanceof Annotation) {
- return regenerateAnnotation(pyCls, javaCls, (Annotation) val);
- }
- else if (val.getClass().isArray()) {
- return regenerateArray(pyCls, javaCls, val);
- }
- else if (val instanceof Class) {
- return regenerateType(pyCls, javaCls, (Class<?>) val);
- }
- else if (val instanceof Map) {
- return regenerateMap(pyCls, javaCls, (Map<?, ?>) val);
- }
- else if (val instanceof String) {
- return regenerateString((String) val);
- }
- else if (val instanceof Enum) {
- return regenerateEnum(pyCls, (Enum<?>) val);
- }
- else {
- return val.toString();
- }
- }
-
- private int run(String pkgName, File outputDir) throws IllegalAccessException,
- IllegalArgumentException, InvocationTargetException, IOException, NoSuchFieldException,
- SecurityException, SorterException, NoSuchMethodException {
- exportPackage(pkgName);
- rootPkg.generate(outputDir.getCanonicalFile().toPath());
- return 0;
- }
-
- private int run(String[] args) {
- if (args.length != 2) {
- System.err.println(
- "Usage: " + this.getClass().getCanonicalName() + " [PACKAGE] [OUTPUT_DIR]");
- return -1;
- }
- File outputDir = new File(args[1]);
-
- try {
- run(args[0], outputDir);
- }
- catch (Exception e) {
- e.printStackTrace();
- return -2;
- }
-
- return 0;
- }
-
- PythonClass packetToPyClass(Class<? extends Packet> pkt) {
- return javaToPyClass(pkt);
- }
-}
diff --git a/Ghidra/Debug/Framework-AsyncComm/src/main/java/ghidra/comm/util/pyexport/PythonClass.java b/Ghidra/Debug/Framework-AsyncComm/src/main/java/ghidra/comm/util/pyexport/PythonClass.java
deleted file mode 100644
index 2186884e06..0000000000
--- a/Ghidra/Debug/Framework-AsyncComm/src/main/java/ghidra/comm/util/pyexport/PythonClass.java
+++ /dev/null
@@ -1,191 +0,0 @@
-/* ###
- * 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 ghidra.comm.util.pyexport;
-
-import java.io.IOException;
-import java.io.PrintWriter;
-import java.nio.file.Files;
-import java.nio.file.Path;
-import java.util.*;
-import java.util.Map.Entry;
-
-import org.apache.commons.collections4.MultiValuedMap;
-import org.apache.commons.lang3.StringUtils;
-
-import ghidra.comm.packet.Packet;
-import ghidra.generic.util.datastruct.TreeSetValuedTreeMap;
-
-/**
- * A model of a Python class
- *
- * It contains a list of imports, class-level assignments, base classes, and other lines of code
- *
- * This model neglects modules, because it is meant for automatic porting of Java classes to Python.
- * Like Java, each Python class is exported to its own file.
- */
-class PythonClass implements Comparable<PythonClass> {
- private final GeneratePython generator;
-
- private final PythonPackage pkg;
- private final MultiValuedMap<String, String> libImports = new TreeSetValuedTreeMap<>();
- private final String clsName;
- private final Map<String, String> assigns = new LinkedHashMap<>();
- private final Map<String, String> postAssigns = new LinkedHashMap<>();
- private final Set<PythonClass> bases = new LinkedHashSet<>();
- private final Set<PythonClass> imports = new TreeSet<>();
- private final List<String> lines = new ArrayList<>();
-
- boolean isExported = false;
-
- PythonClass(GeneratePython generator, String clsName, PythonPackage pkg) {
- this.generator = generator;
- this.clsName = clsName;
- this.pkg = pkg;
- }
-
- void addImport(String module, String... names) {
- for (String name : names) {
- libImports.put(module, name);
- }
- }
-
- void addAssign(String var, String val) {
- assigns.put(var, val);
- }
-
- void addPostAssign(String var, String val) {
- postAssigns.put(var, val);
- }
-
- void addBase(PythonClass cls) {
- addImport(cls);
- bases.add(cls);
- }
-
- void addImport(PythonClass cls) {
- imports.add(cls);
- }
-
- void preLine() {
- preLine(null);
- }
-
- void preLine(String line) {
- lines.add(0, line);
- }
-
- void addLine() {
- lines.add(null);
- }
-
- void addLine(String line) {
- lines.add(line);
- }
-
- void generate(Path outputRoot) throws IOException {
- String pyClsName = getPythonShortName();
- final Path out = outputRoot.resolve("classes").resolve(pkg.getPath())
- .resolve("_class_" + pyClsName + ".py");
- Files.createDirectories(out.getParent());
- try (PrintWriter wr = new PrintWriter(Files.newBufferedWriter(out))) {
- wr.println("# DO NOT MODIFY: This file was automatically generated");
- wr.println();
- for (Entry<String, Collection<String>> ent : libImports.asMap().entrySet()) {
- wr.println(
- "from " + ent.getKey() + " import " + StringUtils.join(ent.getValue(), ", "));
- }
- if (!libImports.isEmpty()) {
- wr.println();
- }
- Set<String> importPkgs = new TreeSet<>();
- for (PythonClass imp : imports) {
- importPkgs.add(imp.getImportPkg(true));
- }
- for (String imp : importPkgs) {
- wr.println("import " + imp);
- }
- if (importPkgs.size() > 0) {
- wr.println();
- }
- PythonClass pyPkt = generator.packetToPyClass(Packet.class);
- wr.println("from " + pyPkt.pkg.getFullName() + " import field, typedesc");
- wr.println();
- wr.println();
- wr.print("class " + pyClsName);
- if (bases.size() > 0) {
- wr.print("(");
- boolean first = true;
- for (PythonClass base : bases) {
- if (!first) {
- wr.print(", ");
- }
- first = false;
- wr.print(base.getFullName(true));
- }
- wr.print(")");
- }
- wr.println(":");
- if (assigns.size() == 0 && lines.size() == 0) {
- wr.println(" pass");
- return;
- }
- // TODO: Export doc?
- for (Entry<String, String> assign : assigns.entrySet()) {
- wr.println(String.format(" %s = %s", assign.getKey(), assign.getValue()));
- }
- for (String line : lines) {
- if (line == null) {
- wr.println();
- }
- else {
- wr.println(" " + line);
- }
- }
- for (Entry<String, String> post : postAssigns.entrySet()) {
- wr.println(String.format("%s.%s = %s", pyClsName, post.getKey(), post.getValue()));
- }
- }
- }
-
- public String getFullName(boolean internal) {
- return getImportPkg(internal) + "." + getPythonShortName();
- }
-
- public String getImportPkg(boolean internal) {
- String pkgName = pkg.getFullName();
- if (internal && pkg.isExported()) {
- if ("".equals(pkgName)) {
- return "classes._class_" + getPythonShortName();
- }
- return "classes." + pkgName + "._class_" + getPythonShortName();
- }
- return pkgName;
- }
-
- public String getPythonShortName() {
- return clsName.replace('$', '_');
- }
-
- @Override
- public int compareTo(PythonClass that) {
- return this.getFullName(false).compareTo(that.getFullName(false));
- }
-
- @Override
- public String toString() {
- return getFullName(false);
- }
-}
diff --git a/Ghidra/Debug/Framework-AsyncComm/src/main/java/ghidra/comm/util/pyexport/PythonPackage.java b/Ghidra/Debug/Framework-AsyncComm/src/main/java/ghidra/comm/util/pyexport/PythonPackage.java
deleted file mode 100644
index cebefa92af..0000000000
--- a/Ghidra/Debug/Framework-AsyncComm/src/main/java/ghidra/comm/util/pyexport/PythonPackage.java
+++ /dev/null
@@ -1,140 +0,0 @@
-/* ###
- * 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 ghidra.comm.util.pyexport;
-
-import java.io.*;
-import java.nio.file.*;
-import java.util.*;
-
-import org.apache.commons.collections4.map.LazyMap;
-import org.apache.commons.lang3.StringUtils;
-import org.apache.commons.lang3.text.StrSubstitutor;
-
-import ghidra.graph.algo.SorterException;
-
-/**
- * A model of a Python package
- *
- * It contains classes and subpackages.
- *
- * This model neglects modules, because it is meant for automatic porting of Java classes to Python.
- * Like Java, each Python class is exported to its own file.
- */
-@SuppressWarnings("deprecation") // FIXME: Remove pyexport package
-class PythonPackage implements Comparable<PythonPackage> {
- private final PythonPackage parent;
- private final String pkgName;
-
- private Map<String, PythonPackage> subPackages;
- private final Map<String, PythonClass> classes;
-
- boolean isExported;
-
- PythonPackage(GeneratePython generator, String pkgName, PythonPackage parent) {
- this.pkgName = pkgName;
- this.parent = parent;
-
- subPackages =
- LazyMap.lazyMap(new HashMap<>(), (name) -> new PythonPackage(generator, name, this));
- classes =
- LazyMap.lazyMap(new TreeMap<>(), (name) -> new PythonClass(generator, name, this));
- }
-
- boolean generate(Path outputRoot) throws IOException, SorterException {
- boolean doCreate = false;
- for (PythonPackage sub : subPackages.values()) {
- doCreate |= sub.generate(outputRoot);
- }
- for (PythonClass cls : classes.values()) {
- if (cls.isExported) {
- doCreate = true;
- }
- }
- if (!doCreate) {
- return false;
- }
-
- for (PythonClass cls : classes.values()) {
- if (cls.isExported) {
- cls.generate(outputRoot);
- }
- }
-
- final Path out = outputRoot.resolve(getPath()).resolve("__init__.py");
- Files.createDirectories(out.getParent());
- Map<String, String> varMap = new HashMap<>();
- varMap.put("relpath", getPath().toString());
- StrSubstitutor subst = new StrSubstitutor(varMap);
- try (PrintWriter wr = new PrintWriter(Files.newBufferedWriter(out))) {
- try (BufferedReader rd = new BufferedReader(new InputStreamReader(
- GeneratePython.class.getResourceAsStream("__init__.py.template")))) {
- String line;
- while (null != (line = rd.readLine())) {
- wr.println(subst.replace(line));
- }
- }
- }
- final Path init = outputRoot.resolve("classes").resolve(getPath()).resolve("__init__.py");
- Files.createDirectories(init.getParent());
- if (Files.notExists(init)) {
- Files.createFile(init);
- }
- return true;
- }
-
- public PythonClass getClass(String name) {
- String[] parts = name.split("\\.", 2);
- if (parts.length == 1) {
- return classes.get(parts[0]);
- }
- return subPackages.get(parts[0]).getClass(parts[1]);
- }
-
- public String getFullName() {
- return StringUtils.join(getPath(), ".");
- }
-
- public Path getPath() {
- if (parent == null) {
- return Paths.get(pkgName);
- }
- return parent.getPath().resolve(pkgName);
- }
-
- public PythonPackage getSubPackage(String subPkgName) {
- String[] parts = subPkgName.split("\\.", 2);
- PythonPackage next = subPackages.get(parts[0]);
- if (parts.length == 1) {
- return next;
- }
- return next.getSubPackage(parts[1]);
- }
-
- public boolean isExported() {
- if (isExported) {
- return true;
- }
- if (parent == null) {
- return false;
- }
- return parent.isExported();
- }
-
- @Override
- public int compareTo(PythonPackage that) {
- return this.getFullName().compareTo(that.getFullName());
- }
-}
diff --git a/Ghidra/Debug/Framework-AsyncComm/src/main/resources/ghidra/comm/util/pyexport/__init__.py.template b/Ghidra/Debug/Framework-AsyncComm/src/main/resources/ghidra/comm/util/pyexport/__init__.py.template
deleted file mode 100644
index e078372257..0000000000
--- a/Ghidra/Debug/Framework-AsyncComm/src/main/resources/ghidra/comm/util/pyexport/__init__.py.template
+++ /dev/null
@@ -1,19 +0,0 @@
-import pkgutil
-
-
-relpath = __package__.replace('.', '/')
-
-paths = []
-for p in __path__:
- if p.endswith(relpath):
- prefix = p[:-len(relpath)]
- paths.append(prefix + 'classes/' + relpath)
-
-for importer, modname, ispkg in pkgutil.iter_modules(paths):
- if modname.startswith('_class_'):
- name = "%s.%s" % (__package__, modname)
- mod = __import__("classes." + name)
- for i in name.split('.'):
- mod = getattr(mod, i)
- clsname = modname[7:]
- globals()[clsname] = getattr(mod, clsname)
diff --git a/Ghidra/Debug/Framework-AsyncComm/src/main/resources/ghidra/comm/util/pyexport/setup.py.template b/Ghidra/Debug/Framework-AsyncComm/src/main/resources/ghidra/comm/util/pyexport/setup.py.template
deleted file mode 100644
index 9b647f6c33..0000000000
--- a/Ghidra/Debug/Framework-AsyncComm/src/main/resources/ghidra/comm/util/pyexport/setup.py.template
+++ /dev/null
@@ -1,16 +0,0 @@
-from setuptools import setup, find_packages
-
-setup(
- name = "${name}",
- version = "${version}",
- packages = find_packages(),
- zip_safe = True,
-)
-
-'''
-entry_points = {
- 'setuptools.installation': [
- 'eggsecutable = plugin:main',
- ],
-},
-'''
\ No newline at end of file
diff --git a/Ghidra/Debug/Framework-AsyncComm/src/test/java/ghidra/async/AsyncPacketChannelTest.java b/Ghidra/Debug/Framework-AsyncComm/src/test/java/ghidra/async/AsyncPacketChannelTest.java
deleted file mode 100644
index d760299551..0000000000
--- a/Ghidra/Debug/Framework-AsyncComm/src/test/java/ghidra/async/AsyncPacketChannelTest.java
+++ /dev/null
@@ -1,291 +0,0 @@
-/* ###
- * 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 ghidra.async;
-
-import static ghidra.async.AsyncUtils.*;
-import static ghidra.comm.tests.packet.BinaryPacketDecodingTest.consPacket;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.fail;
-
-import java.io.EOFException;
-import java.io.IOException;
-import java.net.*;
-import java.nio.*;
-import java.nio.channels.*;
-import java.util.Random;
-import java.util.concurrent.*;
-
-import org.junit.*;
-
-import ghidra.comm.packet.*;
-import ghidra.comm.packet.binary.ByteBufferPacketCodec;
-import ghidra.comm.packet.err.PacketDecodeException;
-import ghidra.comm.packet.err.PacketEncodeException;
-import ghidra.comm.tests.packet.PacketTestClasses.TestMessageEnum;
-import ghidra.comm.tests.packet.PacketTestClasses.TestMessageTypedByMap;
-import ghidra.comm.tests.packet.PacketTestClasses.TestMessageTypedByMap.TestASubByMap;
-import ghidra.util.NumericUtilities;
-
-// Also checks that the resulting syntax/patterns are agreeable
-public class AsyncPacketChannelTest {
- final static PacketCodec<ByteBuffer> BB_CODEC = ByteBufferPacketCodec.getInstance();
-
- protected int testPort;
-
- private static class FragmentControlledAsyncByteChannel implements AsynchronousByteChannel {
- final byte[][] fragments;
- int fragno = 0;
-
- public FragmentControlledAsyncByteChannel(byte[]... fragments) {
- this.fragments = fragments;
- }
-
- @Override
- public boolean isOpen() {
- return true;
- }
-
- @Override
- public void close() throws IOException {
- // Nothing
- }
-
- @Override
- public <A> void write(ByteBuffer src, A attachment,
- CompletionHandler<Integer, ? super A> handler) {
- // Nothing, doesn't need testing here
- }
-
- @Override
- public Future<Integer> write(ByteBuffer src) {
- // Nothing
- return null;
- }
-
- @Override
- public <A> void read(ByteBuffer dst, A attachment,
- CompletionHandler<Integer, ? super A> handler) {
- int pos = dst.position();
- try {
- dst.put(fragments[fragno]);
- int len = fragments[fragno].length;
- fragno++;
- ForkJoinPool.commonPool().submit(() -> {
- handler.completed(len, attachment);
- });
- }
- catch (BufferOverflowException e) {
- dst.position(pos);
- ForkJoinPool.commonPool().submit(() -> {
- handler.completed(0, attachment);
- });
- }
- }
-
- @Override
- public Future<Integer> read(ByteBuffer dst) {
- // Nothing. Implementing strictly via completion handler
- return null;
- }
- }
-
- static class MyMarshaller
- extends AbstractPacketMarshaller<TestMessageTypedByMap, TestMessageEnum, ByteBuffer> {
- public MyMarshaller() {
- super(BB_CODEC, TestMessageEnum.class);
- }
-
- @Override
- public void marshall(ByteBuffer outbuf, TestMessageTypedByMap pkt)
- throws PacketEncodeException {
- int pos = outbuf.position();
- try {
- outbuf.putLong(0); // Placeholder
- BB_CODEC.encodePacket(outbuf, pkt);
-
- // Backfill the length
- int end = outbuf.position();
- int len = end - pos - Long.BYTES;
- ByteOrder orig = outbuf.order();
- outbuf.order(ByteOrder.LITTLE_ENDIAN);
- outbuf.putLong(pos, len);
- outbuf.order(orig);
- }
- catch (Exception e) {
- outbuf.position(pos);
- throw e;
- }
- }
-
- @Override
- public <R extends TestMessageEnum> R unmarshall(Class<R> pktType, ByteBuffer inbuf)
- throws PacketDecodeException {
- int origPos = inbuf.position();
- int origLimit = inbuf.limit();
- ByteOrder origOrder = inbuf.order();
- try {
- inbuf.order(ByteOrder.LITTLE_ENDIAN);
- int len = (int) inbuf.getLong() + Long.BYTES;
- inbuf.order(origOrder);
- if (inbuf.limit() < len) {
- throw new BufferUnderflowException();
- }
- inbuf.limit(len);
- R rcvd = BB_CODEC.decodePacket(pktType, inbuf, factory);
- return rcvd;
- }
- catch (Exception e) {
- inbuf.position(origPos);
- throw e;
- }
- finally {
- inbuf.limit(origLimit);
- inbuf.order(origOrder);
- }
- }
- }
-
- static class SocketClient
- extends AsynchronousPacketChannel<TestMessageTypedByMap, TestMessageEnum> {
- SocketClient(AsynchronousByteChannel channel) {
- //super(channel, new MyMarshaller(), 8);
- super(new DebugByteChannel(channel), new MyMarshaller(), 8);
- }
- }
-
- void runServer() {
- try (ServerSocket srv = new ServerSocket(testPort)) {
- try (Socket cli = srv.accept()) {
- byte[] buf = new byte[13];
- int len = cli.getInputStream().read(buf);
- System.out.println("Server got " + len + " bytes: " +
- NumericUtilities.convertBytesToString(buf, 0, len, ":"));
- cli.getOutputStream()
- .write(consPacket( //
- "05:00:00:00:00:00:00:00", "02", "00:00:00:33", //
- "05:00:00:00:00:00:00:00", "03", "00:00:00:10"));
- }
- }
- catch (Exception e) {
- e.printStackTrace();
- fail();
- }
- }
-
- @Before
- public void setUp() {
- testPort = 12345 + new Random().nextInt(1024);
- new Thread(this::runServer).start();
- }
-
- @Test
- public void testUnmarshallIncomplete() throws Throwable {
- BB_CODEC.registerPacketType(TestMessageEnum.class);
-
- TestMessageEnum exp1 = new TestMessageEnum(TestMessageEnum.TestEnum.ONE, 51);
- TestMessageEnum exp2 = new TestMessageEnum(TestMessageEnum.TestEnum.TWO, 16);
- // Initialize any meta fields
- BB_CODEC.encodePacket(exp1);
- BB_CODEC.encodePacket(exp2);
-
- // Structure fragments to ensure incomplete packets reset the buffer state
- // Also, a complete packet should advance, not restore, the buffer state
- AsynchronousByteChannel channel = new FragmentControlledAsyncByteChannel( //
- consPacket("05:00"), //
- consPacket("00:00:00:00:00"), //
- consPacket("00", "02", "00"), //
- consPacket("00:00:33"), //
- //
- consPacket("05:00"), //
- consPacket("00:00:00:00:00"), //
- consPacket("00", "03", "00"), //
- consPacket("00:00:10") //
- );
- AsynchronousPacketChannel<TestMessageTypedByMap, TestMessageEnum> client =
- new SocketClient(channel);
- sequence(TypeSpec.VOID).then((seq) -> {
- client.read(TestMessageEnum.class).handle(seq::next);
- }, TypeSpec.cls(TestMessageEnum.class)).then((pkt, seq) -> {
- System.out.println("Read: " + pkt);
- assertEquals(exp1, pkt);
-
- client.read(TestMessageEnum.class).handle(seq::next);
- }, TypeSpec.cls(TestMessageEnum.class)).then((pkt, seq) -> {
- System.out.println("Read: " + pkt);
- assertEquals(exp2, pkt);
-
- seq.exit(null, null);
- }).finish().get(1000, TimeUnit.MILLISECONDS);
- }
-
- @Test
- @Ignore("TODO") // Not sure why this fails under Gradle but not my IDE
- public void testClient() throws Throwable {
- BB_CODEC.registerPacketType(TestMessageTypedByMap.class);
- BB_CODEC.registerPacketType(TestMessageEnum.class);
-
- AsynchronousSocketChannel channel = AsynchronousSocketChannel.open();
- AsynchronousPacketChannel<TestMessageTypedByMap, TestMessageEnum> client =
- new SocketClient(channel);
- sequence(TypeSpec.VOID).then((seq) -> {
- completable(TypeSpec.VOID, channel::connect,
- new InetSocketAddress("localhost", testPort)).handle(seq::next);
- }).then((seq) -> {
- System.out.println("Connected");
- client.write(new TestMessageTypedByMap(new TestASubByMap(5))).handle(seq::next);
- }, TypeSpec.cls(Integer.class)).then((len, seq) -> {
- System.out.println("Sent " + len + " bytes");
- client.read(TestMessageEnum.class).handle(seq::next);
- }, TypeSpec.cls(TestMessageEnum.class)).then((pkt, seq) -> {
- System.out.println("Received: " + pkt);
- client.read(TestMessageEnum.class).handle(seq::next);
- }, TypeSpec.cls(TestMessageEnum.class)).then((pkt, seq) -> {
- System.out.println("Received: " + pkt);
- seq.exit(null, null);
- }).finish().get(1000, TimeUnit.MILLISECONDS);
- }
-
- @Test(expected = EOFException.class)
- @Ignore("TODO") // Not sure why this fails under Gradle but not my IDE
- public void testClientDisconnect() throws Throwable {
- BB_CODEC.registerPacketType(TestMessageTypedByMap.class);
- BB_CODEC.registerPacketType(TestMessageEnum.class);
-
- AsynchronousSocketChannel channel = AsynchronousSocketChannel.open();
- AsynchronousPacketChannel<TestMessageTypedByMap, TestMessageEnum> client =
- new SocketClient(channel);
- try {
- sequence(TypeSpec.VOID).then((seq) -> {
- completable(TypeSpec.VOID, channel::connect,
- new InetSocketAddress("localhost", testPort)).handle(seq::next);
- }).then((seq) -> {
- System.out.println("Connected");
- client.write(new TestMessageTypedByMap(new TestASubByMap(5))).handle(seq::next);
- }, TypeSpec.INT).then((len, seq) -> {
- System.out.println("Sent " + len + " bytes");
- loop(TypeSpec.VOID, (loop) -> {
- client.read(TestMessageEnum.class).handle(loop::consume);
- }, TypeSpec.cls(TestMessageEnum.class), (pkt, loop) -> {
- System.out.println("Received: " + pkt);
- loop.repeat();
- }).handle(seq::exit);
- }).finish().get(1000, TimeUnit.MILLISECONDS);
- }
- catch (ExecutionException e) {
- throw e.getCause();
- }
- }
-}
diff --git a/Ghidra/Debug/Framework-AsyncComm/src/test/java/ghidra/comm/tests/packet/BinaryPacketDecodingTest.java b/Ghidra/Debug/Framework-AsyncComm/src/test/java/ghidra/comm/tests/packet/BinaryPacketDecodingTest.java
deleted file mode 100644
index 6e1bba4ddf..0000000000
--- a/Ghidra/Debug/Framework-AsyncComm/src/test/java/ghidra/comm/tests/packet/BinaryPacketDecodingTest.java
+++ /dev/null
@@ -1,311 +0,0 @@
-/* ###
- * 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 ghidra.comm.tests.packet;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.fail;
-
-import org.apache.commons.lang3.StringUtils;
-import org.junit.Before;
-import org.junit.Test;
-
-import ghidra.comm.packet.PacketCodec;
-import ghidra.comm.packet.binary.BinaryPacketCodec;
-import ghidra.comm.packet.err.*;
-import ghidra.comm.tests.packet.PacketTestClasses.TestMessageEnum.TestEnum;
-import ghidra.comm.tests.packet.PacketTestClasses.TestMessageFlags.TestFlags;
-import ghidra.comm.tests.packet.PacketTestClasses.TestMessageTypedByMap.TestASubByMap;
-import ghidra.comm.tests.packet.PacketTestClasses.TestMessageTypedByMap.TestBSubByMap;
-import ghidra.comm.util.BitmaskSet;
-import ghidra.util.NumericUtilities;
-
-public class BinaryPacketDecodingTest implements PacketTestClasses {
- protected PacketCodec<byte[]> codec; // Use the interface to ensure methods are defined there
-
- @Before
- public void setUp() {
- codec = BinaryPacketCodec.getInstance();
- }
-
- public static byte[] consPacket(String... parts) {
- String full = StringUtils.join(parts).replace(":", "");
- return NumericUtilities.convertStringToBytes(full);
- }
-
- @Test
- public void testFlat() throws PacketDecodeException, FieldOrderingException {
- codec.registerPacketType(TestMessageFlatTypes.class);
- codec.registerPacketType(TestMessageFlatMixedEndian.class);
- byte[] enc;
-
- enc = consPacket("01", "02", "00:33", "00:04", "00:00:00:05", "00:00:00:00:00:00:00:06",
- "73:65:76:65:6e:00", "41:00:00:00", "40:22:00:00:00:00:00:00");
- TestMessageFlatTypes p1 = codec.decodePacket(TestMessageFlatTypes.class, enc);
- assertEquals(new TestMessageFlatTypes(true, (byte) 2, '3', (short) 4, 5, 6, "seven", 8, 9),
- p1);
-
- enc = consPacket("00:31", "32:00", "00:00:00:03", "04:00:00:00", "66:69:76:65:00",
- "73:69:78:00:00", "00:00:00:00:00:00:00:07", "08:00:00:00:00:00:00:00", "41:10:00:00",
- "00:00:20:41", "40:26:00:00:00:00:00:00", "00:00:00:00:00:00:28:40");
- TestMessageFlatMixedEndian p2 = codec.decodePacket(TestMessageFlatMixedEndian.class, enc);
- assertEquals(
- new TestMessageFlatMixedEndian('1', '2', 3, 4, "five", "six", 7, 8, 9, 10, 11, 12), p2);
- }
-
- @Test
- public void testSizedAnnot() throws PacketDecodeException, FieldOrderingException {
- codec.registerPacketType(TestMessageSizedString.class);
- codec.registerPacketType(TestMessageMethodSizedString.class);
- byte[] enc;
-
- enc = consPacket("00:00:00:07", "54:65:73:74:69:6e:67", "00:00:00:04");
- TestMessageSizedString p1 = codec.decodePacket(TestMessageSizedString.class, enc);
- TestMessageSizedString e1 = new TestMessageSizedString("Testing", 4);
- e1.len = 7; // Have to set this manually for testing, since it's never encoded
- assertEquals(e1, p1);
-
- enc = consPacket("00:00:00:0c", "54:65:73:74:69:6e:67:32");
- TestMessageMethodSizedString p2 =
- codec.decodePacket(TestMessageMethodSizedString.class, enc);
- TestMessageMethodSizedString e2 = new TestMessageMethodSizedString("Testing2");
- e2.len = 12;
- assertEquals(e2, p2);
- }
-
- @Test
- public void testCountedAnnot() throws PacketDecodeException, FieldOrderingException {
- codec.registerPacketType(TestMessageCountedShortArray.class);
- byte[] enc;
-
- enc = consPacket("00:00:00:04", "00:00", "01:00", "02:00", "03:00", "00:00:be:ef");
- TestMessageCountedShortArray p1 =
- codec.decodePacket(TestMessageCountedShortArray.class, enc);
- TestMessageCountedShortArray e1 =
- new TestMessageCountedShortArray(0xbeef, (short) 0, (short) 1, (short) 2, (short) 3);
- e1.count = 4;
- assertEquals(e1, p1);
- }
-
- @Test
- public void testTypedAnnot() throws PacketDecodeException, FieldOrderingException {
- codec.registerPacketType(TestMessageDynamicTyped.class);
- codec.registerPacketType(TestMessageDynamicTypedSubs.class);
- byte[] enc;
-
- enc = consPacket("00:00:00:01", "00:00:00:03");
- TestMessageDynamicTyped p1 = codec.decodePacket(TestMessageDynamicTyped.class, enc);
- TestMessageDynamicTyped e1 = new TestMessageDynamicTyped(3);
- e1.type = 1;
- assertEquals(e1, p1);
-
- TestMessageDynamicTypedSubs p2 = codec.decodePacket(TestMessageDynamicTypedSubs.class, enc);
- TestMessageDynamicTypedSubs e2 =
- new TestMessageDynamicTypedSubs(new TestMessageDynamicTypedSubs.IntTestMessage(3));
- e2.type = 1;
- assertEquals(e2, p2);
-
- enc = consPacket("00:00:00:02", "00:00:00:00:00:00:00:04");
- p1 = codec.decodePacket(TestMessageDynamicTyped.class, enc);
- e1 = new TestMessageDynamicTyped(4L);
- e1.type = 2;
- assertEquals(e1, p1);
-
- p2 = codec.decodePacket(TestMessageDynamicTypedSubs.class, enc);
- e2 = new TestMessageDynamicTypedSubs(new TestMessageDynamicTypedSubs.LongTestMessage(4));
- e2.type = 2;
- assertEquals(e2, p2);
- }
-
- @Test
- public void testCollection()
- throws PacketDecodeException, PacketEncodeException, FieldOrderingException {
- codec.registerPacketType(TestMessageUnmeasuredCollection.class);
- codec.registerPacketType(TestMessageFullSpecColField.class);
- byte[] enc;
-
- enc = consPacket(//
- "02", "00:07", "54:65:73:74:69:6e:67", //
- "01", "00:04", "00:00:00:01", //
- "01", "00:04", "00:00:00:02");
- TestMessageUnmeasuredCollection p1 =
- codec.decodePacket(TestMessageUnmeasuredCollection.class, enc);
- TestMessageUnmeasuredCollection e1 = new TestMessageUnmeasuredCollection("Testing", 1, 2);
- codec.encodePacket(e1); // codec will initialize referenced fields (type, len)
- assertEquals(e1, p1);
-
- enc = consPacket("00:00:00:00", "00:00:00:01", "00:00:00:02", "00:00:00:03");
- TestMessageFullSpecColField p2 = codec.decodePacket(TestMessageFullSpecColField.class, enc);
- TestMessageFullSpecColField e2 = new TestMessageFullSpecColField(0, 1, 2, 3);
- assertEquals(e2, p2);
- }
-
- @Test
- public void testLookahead() throws PacketDecodeException, FieldOrderingException {
- codec.registerPacketType(TestMessageLookahead.class);
- byte[] enc;
-
- enc = consPacket("49:6e:74", "00:00:00:03");
- TestMessageLookahead p1 = codec.decodePacket(TestMessageLookahead.class, enc);
- TestMessageLookahead e1 = new TestMessageLookahead(3);
- assertEquals(e1, p1);
-
- enc = consPacket("4c:6f:6e:67", "00:00:00:00:00:00:00:04");
- p1 = codec.decodePacket(TestMessageLookahead.class, enc);
- e1 = new TestMessageLookahead(4L);
- assertEquals(e1, p1);
- }
-
- @Test
- public void testDoubleTermed() throws PacketDecodeException, FieldOrderingException {
- codec.registerPacketType(TestMessageDoubleTermed.class);
- byte[] enc;
-
- enc = consPacket("00:00:00:07", "54:65:73:74:69:6e:67", "00");
- TestMessageDoubleTermed p1 = codec.decodePacket(TestMessageDoubleTermed.class, enc);
- TestMessageDoubleTermed e1 = new TestMessageDoubleTermed("Testing");
- e1.len = 7;
- assertEquals(e1, p1);
- }
-
- @Test
- public void testOptional() throws PacketDecodeException {
- codec.registerPacketType(TestMessageOptional.class);
- byte[] enc;
-
- enc = consPacket("53:6f:6d:65:53:74:72:69:6e:67");
- TestMessageOptional p1 = codec.decodePacket(TestMessageOptional.class, enc);
- TestMessageOptional e1 = new TestMessageOptional("SomeString");
- assertEquals(e1, p1);
-
- enc = consPacket("53:6f:6d:65:53:74:72:69:6e:67", "00", "00:00:00:33");
- p1 = codec.decodePacket(TestMessageOptional.class, enc);
- e1 = new TestMessageOptional("SomeString", 51);
- assertEquals(e1, p1);
- }
-
- @Test
- public void testEnum() throws PacketDecodeException {
- codec.registerPacketType(TestMessageEnum.class);
- byte[] enc;
-
- enc = consPacket("01", "00:00:00:33");
- TestMessageEnum p1 = codec.decodePacket(TestMessageEnum.class, enc);
- TestMessageEnum e1 = new TestMessageEnum(TestEnum.ON, 51);
- assertEquals(e1, p1);
-
- enc = consPacket("02", "00:00:00:33");
- p1 = codec.decodePacket(TestMessageEnum.class, enc);
- e1 = new TestMessageEnum(TestEnum.ONE, 51);
- assertEquals(e1, p1);
-
- enc = consPacket("05", "00:00:00:33");
- try {
- p1 = codec.decodePacket(TestMessageEnum.class, enc);
- fail();
- }
- catch (PacketFieldValueMismatchException e) {
- // pass
- }
- }
-
- @Test
- public void testNoEmpty() {
- codec.registerPacketType(TestMessageEmpty.class);
- byte[] enc;
-
- enc = consPacket("00");
- try {
- @SuppressWarnings("unused")
- TestMessageEmpty p1 = codec.decodePacket(TestMessageEmpty.class, enc);
- fail();
- }
- catch (PacketDecodeException e) {
- // pass
- }
- }
-
- @Test
- public void testAbstract() throws PacketDecodeException {
- codec.registerPacketType(TestMessageAbstractTestNumber.class);
- PacketTestClasses.LONG_TEST_NUMBER_FACTORY.registerTypes(codec);
- PacketTestClasses.INT_TEST_NUMBER_FACTORY.registerTypes(codec);
- byte[] enc;
-
- enc = consPacket("00:00:00:02", "00:00:00:00:00:00:00:05", "00:00:00:00:00:00:00:06",
- "00:00:30:39");
- TestMessageAbstractTestNumber p1 = codec.decodePacket(TestMessageAbstractTestNumber.class,
- enc, PacketTestClasses.LONG_TEST_NUMBER_FACTORY);
- TestMessageAbstractTestNumber e1 =
- new TestMessageAbstractTestNumber(12345, new LongTestNumber(5), new LongTestNumber(6));
- e1.count = 2;
- assertEquals(e1, p1);
-
- enc = consPacket("00:00:00:02", "00:00:00:05", "00:00:00:06", "00:00:30:39");
- p1 = codec.decodePacket(TestMessageAbstractTestNumber.class, enc,
- PacketTestClasses.INT_TEST_NUMBER_FACTORY);
- e1 = new TestMessageAbstractTestNumber(12345, new IntTestNumber(5), new IntTestNumber(6));
- e1.count = 2;
- assertEquals(e1, p1);
- }
-
- @Test
- public void testTypedByMap() throws PacketDecodeException {
- codec.registerPacketType(TestMessageTypedByMap.class);
- byte[] enc;
-
- enc = consPacket("00", "00:00:00:05");
- TestMessageTypedByMap p1 = codec.decodePacket(TestMessageTypedByMap.class, enc);
- TestMessageTypedByMap e1 = new TestMessageTypedByMap(new TestASubByMap(5));
- e1.type = TestMessageTypedByMap.TestEnum.A;
- assertEquals(e1, p1);
-
- enc = consPacket("01", "00:00:00:00:00:00:00:06");
- p1 = codec.decodePacket(TestMessageTypedByMap.class, enc);
- e1 = new TestMessageTypedByMap(new TestBSubByMap(6));
- e1.type = TestMessageTypedByMap.TestEnum.B;
- assertEquals(e1, p1);
- }
-
- @Test
- public void testFlags() throws PacketDecodeException {
- codec.registerPacketType(TestMessageFlags.class);
- byte[] enc;
-
- enc = consPacket("02");
- TestMessageFlags p1 = codec.decodePacket(TestMessageFlags.class, enc);
- TestMessageFlags e1 = new TestMessageFlags();
- e1.flags = BitmaskSet.of(TestFlags.SECOND);
- assertEquals(e1, p1);
-
- enc = consPacket("03", "11:22:33:44:55:66:77:88");
- p1 = codec.decodePacket(TestMessageFlags.class, enc);
- e1 = new TestMessageFlags(0x1122334455667788L);
- e1.flags = BitmaskSet.of(TestFlags.FIRST, TestFlags.SECOND);
- assertEquals(e1, p1);
-
- enc = consPacket("00", "12:34:56:78");
- p1 = codec.decodePacket(TestMessageFlags.class, enc);
- e1 = new TestMessageFlags(0x12345678);
- e1.flags = BitmaskSet.of();
- assertEquals(e1, p1);
-
- enc = consPacket("01", "11:22:33:44:55:66:77:88", "12:34:56:78");
- p1 = codec.decodePacket(TestMessageFlags.class, enc);
- e1 = new TestMessageFlags(0x1122334455667788L, 0x12345678);
- e1.flags = BitmaskSet.of(TestFlags.FIRST);
- assertEquals(e1, p1);
- }
-}
diff --git a/Ghidra/Debug/Framework-AsyncComm/src/test/java/ghidra/comm/tests/packet/BinaryPacketEncodingTest.java b/Ghidra/Debug/Framework-AsyncComm/src/test/java/ghidra/comm/tests/packet/BinaryPacketEncodingTest.java
deleted file mode 100644
index 146b538410..0000000000
--- a/Ghidra/Debug/Framework-AsyncComm/src/test/java/ghidra/comm/tests/packet/BinaryPacketEncodingTest.java
+++ /dev/null
@@ -1,229 +0,0 @@
-/* ###
- * 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 ghidra.comm.tests.packet;
-
-import static org.junit.Assert.assertEquals;
-
-import org.junit.Before;
-import org.junit.Test;
-
-import ghidra.comm.packet.PacketCodec;
-import ghidra.comm.packet.binary.BinaryPacketCodec;
-import ghidra.comm.packet.err.FieldOrderingException;
-import ghidra.comm.packet.err.PacketEncodeException;
-import ghidra.comm.tests.packet.PacketTestClasses.TestMessageEnum.TestEnum;
-import ghidra.comm.tests.packet.PacketTestClasses.TestMessageTypedByMap.TestASubByMap;
-import ghidra.comm.tests.packet.PacketTestClasses.TestMessageTypedByMap.TestBSubByMap;
-import ghidra.util.NumericUtilities;
-
-public class BinaryPacketEncodingTest implements PacketTestClasses {
- protected PacketCodec<byte[]> codec;
-
- @Before
- public void setUp() {
- codec = BinaryPacketCodec.getInstance();
- }
-
- @Test
- public void testFlat() throws PacketEncodeException, FieldOrderingException {
- codec.registerPacketType(TestMessageFlatTypes.class);
- codec.registerPacketType(TestMessageFlatMixedEndian.class);
- byte[] enc;
-
- enc = codec.encodePacket(
- new TestMessageFlatTypes(true, (byte) 2, '3', (short) 4, 5, 6, "seven", 8, 9));
- assertEquals(
- "01:" + "02:" + "00:33:" + "00:04:" + "00:00:00:05:" + "00:00:00:00:00:00:00:06:" +
- "73:65:76:65:6e:00:" + "41:00:00:00:" + "40:22:00:00:00:00:00:00",
- NumericUtilities.convertBytesToString(enc, ":"));
-
- enc = codec.encodePacket(
- new TestMessageFlatMixedEndian('1', '2', 3, 4, "five", "six", 7, 8, 9, 10, 11, 12));
- assertEquals("00:31:" + "32:00:" + "00:00:00:03:" + "04:00:00:00:" + "66:69:76:65:00:" +
- "73:69:78:00:00:" + "00:00:00:00:00:00:00:07:" + "08:00:00:00:00:00:00:00:" +
- "41:10:00:00:" + "00:00:20:41:" + "40:26:00:00:00:00:00:00:" +
- "00:00:00:00:00:00:28:40", NumericUtilities.convertBytesToString(enc, ":"));
- }
-
- @Test
- public void testSizedAnnot() throws PacketEncodeException, FieldOrderingException {
- codec.registerPacketType(TestMessageSizedString.class);
- codec.registerPacketType(TestMessageMethodSizedString.class);
- byte[] enc;
-
- enc = codec.encodePacket(new TestMessageSizedString("Testing", 4));
- assertEquals("00:00:00:07:" + "54:65:73:74:69:6e:67:" + "00:00:00:04",
- NumericUtilities.convertBytesToString(enc, ":"));
-
- enc = codec.encodePacket(new TestMessageMethodSizedString("Testing2"));
- assertEquals("00:00:00:0c:" + "54:65:73:74:69:6e:67:32",
- NumericUtilities.convertBytesToString(enc, ":"));
- }
-
- @Test
- public void testCountedAnnot() throws PacketEncodeException, FieldOrderingException {
- codec.registerPacketType(TestMessageCountedShortArray.class);
- byte[] enc;
-
- enc = codec.encodePacket(
- new TestMessageCountedShortArray(0xbeef, (short) 0, (short) 1, (short) 2, (short) 3));
- assertEquals("00:00:00:04:" + "00:00:" + "01:00:" + "02:00:" + "03:00:" + "00:00:be:ef",
- NumericUtilities.convertBytesToString(enc, ":"));
- }
-
- @Test
- public void testTypedAnnot() throws PacketEncodeException, FieldOrderingException {
- codec.registerPacketType(TestMessageDynamicTyped.class);
- codec.registerPacketType(TestMessageDynamicTypedSubs.class);
- byte[] enc;
-
- enc = codec.encodePacket(new TestMessageDynamicTyped(3));
- assertEquals("00:00:00:01:" + "00:00:00:03",
- NumericUtilities.convertBytesToString(enc, ":"));
-
- enc = codec.encodePacket(new TestMessageDynamicTyped(4L));
- assertEquals("00:00:00:02:" + "00:00:00:00:00:00:00:04",
- NumericUtilities.convertBytesToString(enc, ":"));
-
- enc = codec.encodePacket(
- new TestMessageDynamicTypedSubs(new TestMessageDynamicTypedSubs.IntTestMessage(3)));
- assertEquals("00:00:00:01:" + "00:00:00:03",
- NumericUtilities.convertBytesToString(enc, ":"));
-
- enc = codec.encodePacket(
- new TestMessageDynamicTypedSubs(new TestMessageDynamicTypedSubs.LongTestMessage(4)));
- assertEquals("00:00:00:02:" + "00:00:00:00:00:00:00:04",
- NumericUtilities.convertBytesToString(enc, ":"));
- }
-
- @Test
- public void testCollection() throws PacketEncodeException, FieldOrderingException {
- codec.registerPacketType(TestMessageUnmeasuredCollection.class);
- codec.registerPacketType(TestMessageFullSpecColField.class);
- byte[] enc;
-
- enc = codec.encodePacket(new TestMessageUnmeasuredCollection("Testing", 1, 2));
- assertEquals("" +//
- "02:" + "00:07:" + "54:65:73:74:69:6e:67:" + //
- "01:" + "00:04:" + "00:00:00:01:" + //
- "01:" + "00:04:" + "00:00:00:02", //
- NumericUtilities.convertBytesToString(enc, ":"));
-
- enc = codec.encodePacket(new TestMessageFullSpecColField(0, 1, 2, 3));
- assertEquals("00:00:00:00:" + "00:00:00:01:" + "00:00:00:02:" + "00:00:00:03",
- NumericUtilities.convertBytesToString(enc, ":"));
- }
-
- @Test
- public void testLookahead() throws PacketEncodeException, FieldOrderingException {
- codec.registerPacketType(TestMessageLookahead.class);
- byte[] enc;
-
- enc = codec.encodePacket(new TestMessageLookahead(3));
- assertEquals("49:6e:74:" + "00:00:00:03", NumericUtilities.convertBytesToString(enc, ":"));
-
- enc = codec.encodePacket(new TestMessageLookahead(4L));
- assertEquals("4c:6f:6e:67:" + "00:00:00:00:00:00:00:04",
- NumericUtilities.convertBytesToString(enc, ":"));
- }
-
- @Test
- public void testDoubleTermed() throws PacketEncodeException, FieldOrderingException {
- codec.registerPacketType(TestMessageDoubleTermed.class);
- byte[] enc;
-
- enc = codec.encodePacket(new TestMessageDoubleTermed("Testing"));
- assertEquals("00:00:00:07:" + "54:65:73:74:69:6e:67:" + "00",
- NumericUtilities.convertBytesToString(enc, ":"));
- }
-
- @Test
- public void testOptional() throws PacketEncodeException {
- codec.registerPacketType(TestMessageOptional.class);
- byte[] enc;
-
- enc = codec.encodePacket(new TestMessageOptional("SomeString"));
- assertEquals("53:6f:6d:65:53:74:72:69:6e:67",
- NumericUtilities.convertBytesToString(enc, ":"));
-
- enc = codec.encodePacket(new TestMessageOptional("SomeString", 51));
- assertEquals("53:6f:6d:65:53:74:72:69:6e:67:" + "00:" + "00:00:00:33",
- NumericUtilities.convertBytesToString(enc, ":"));
- }
-
- @Test
- public void testEnum() throws PacketEncodeException {
- codec.registerPacketType(TestMessageEnum.class);
- byte[] enc;
-
- enc = codec.encodePacket(new TestMessageEnum(TestEnum.ON, 51));
- assertEquals("01:" + "00:00:00:33", NumericUtilities.convertBytesToString(enc, ":"));
-
- enc = codec.encodePacket(new TestMessageEnum(TestEnum.ONE, 51));
- assertEquals("02:" + "00:00:00:33", NumericUtilities.convertBytesToString(enc, ":"));
- }
-
- @Test
- public void testAbstract() throws PacketEncodeException {
- codec.registerPacketType(TestMessageAbstractTestNumber.class);
- PacketTestClasses.LONG_TEST_NUMBER_FACTORY.registerTypes(codec);
- PacketTestClasses.INT_TEST_NUMBER_FACTORY.registerTypes(codec);
- byte[] enc;
-
- enc = codec.encodePacket(
- new TestMessageAbstractTestNumber(12345, new LongTestNumber(5), new LongTestNumber(6)));
- assertEquals("00:00:00:02:" + "00:00:00:00:00:00:00:05:" + "00:00:00:00:00:00:00:06:" +
- "00:00:30:39", NumericUtilities.convertBytesToString(enc, ":"));
-
- enc = codec.encodePacket(
- new TestMessageAbstractTestNumber(12345, new IntTestNumber(5), new IntTestNumber(6)));
- assertEquals("00:00:00:02:" + "00:00:00:05:" + "00:00:00:06:" + "00:00:30:39",
- NumericUtilities.convertBytesToString(enc, ":"));
- }
-
- @Test
- public void testTypedByMap() throws PacketEncodeException {
- codec.registerPacketType(TestMessageTypedByMap.class);
- byte[] enc;
-
- enc = codec.encodePacket(new TestMessageTypedByMap(new TestASubByMap(5)));
- assertEquals("00:" + "00:00:00:05", NumericUtilities.convertBytesToString(enc, ":"));
-
- enc = codec.encodePacket(new TestMessageTypedByMap(new TestBSubByMap(6)));
- assertEquals("01:" + "00:00:00:00:00:00:00:06",
- NumericUtilities.convertBytesToString(enc, ":"));
- }
-
- @Test
- public void testFlags() throws PacketEncodeException {
- codec.registerPacketType(TestMessageFlags.class);
- byte[] enc;
-
- enc = codec.encodePacket(new TestMessageFlags());
- assertEquals("02", NumericUtilities.convertBytesToString(enc, ":"));
-
- enc = codec.encodePacket(new TestMessageFlags(0x1122334455667788L));
- assertEquals("03:" + "11:22:33:44:55:66:77:88",
- NumericUtilities.convertBytesToString(enc, ":"));
-
- enc = codec.encodePacket(new TestMessageFlags(0x12345678));
- assertEquals("00:" + "12:34:56:78", NumericUtilities.convertBytesToString(enc, ":"));
-
- enc = codec.encodePacket(new TestMessageFlags(0x1122334455667788L, 0x12345678));
- assertEquals("01:" + "11:22:33:44:55:66:77:88:" + "12:34:56:78",
- NumericUtilities.convertBytesToString(enc, ":"));
- }
-}
diff --git a/Ghidra/Debug/Framework-AsyncComm/src/test/java/ghidra/comm/tests/packet/ByteBufferPacketDecodingTest.java b/Ghidra/Debug/Framework-AsyncComm/src/test/java/ghidra/comm/tests/packet/ByteBufferPacketDecodingTest.java
deleted file mode 100644
index 50dc885c9a..0000000000
--- a/Ghidra/Debug/Framework-AsyncComm/src/test/java/ghidra/comm/tests/packet/ByteBufferPacketDecodingTest.java
+++ /dev/null
@@ -1,305 +0,0 @@
-/* ###
- * 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 ghidra.comm.tests.packet;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.fail;
-
-import java.nio.ByteBuffer;
-
-import org.apache.commons.lang3.StringUtils;
-import org.junit.Before;
-import org.junit.Test;
-
-import ghidra.comm.packet.PacketCodec;
-import ghidra.comm.packet.binary.ByteBufferPacketCodec;
-import ghidra.comm.packet.err.*;
-import ghidra.comm.tests.packet.PacketTestClasses.TestMessageEnum.TestEnum;
-import ghidra.comm.tests.packet.PacketTestClasses.TestMessageTypedByMap.TestASubByMap;
-import ghidra.comm.tests.packet.PacketTestClasses.TestMessageTypedByMap.TestBSubByMap;
-import ghidra.util.NumericUtilities;
-
-public class ByteBufferPacketDecodingTest implements PacketTestClasses {
- protected PacketCodec<ByteBuffer> codec; // Use the interface to ensure methods are defined there
-
- @Before
- public void setUp() {
- codec = ByteBufferPacketCodec.getInstance();
- }
-
- public static ByteBuffer consPacket(String... parts) {
- String full = StringUtils.join(parts).replace(":", "");
- return ByteBuffer.wrap(NumericUtilities.convertStringToBytes(full));
- }
-
- @Test
- public void testFlat() throws PacketDecodeException, FieldOrderingException {
- codec.registerPacketType(TestMessageFlatTypes.class);
- codec.registerPacketType(TestMessageFlatMixedEndian.class);
- ByteBuffer enc;
-
- enc = consPacket("01", "02", "00:33", "00:04", "00:00:00:05", "00:00:00:00:00:00:00:06",
- "73:65:76:65:6e:00", "41:00:00:00", "40:22:00:00:00:00:00:00");
- TestMessageFlatTypes p1 = codec.decodePacket(TestMessageFlatTypes.class, enc);
- assertEquals(new TestMessageFlatTypes(true, (byte) 2, '3', (short) 4, 5, 6, "seven", 8, 9),
- p1);
-
- enc = consPacket("00:31", "32:00", "00:00:00:03", "04:00:00:00", "66:69:76:65:00",
- "73:69:78:00:00", "00:00:00:00:00:00:00:07", "08:00:00:00:00:00:00:00", "41:10:00:00",
- "00:00:20:41", "40:26:00:00:00:00:00:00", "00:00:00:00:00:00:28:40");
- TestMessageFlatMixedEndian p2 = codec.decodePacket(TestMessageFlatMixedEndian.class, enc);
- assertEquals(
- new TestMessageFlatMixedEndian('1', '2', 3, 4, "five", "six", 7, 8, 9, 10, 11, 12), p2);
- }
-
- @Test
- public void testSizedAnnot() throws PacketDecodeException, FieldOrderingException {
- codec.registerPacketType(TestMessageSizedString.class);
- codec.registerPacketType(TestMessageMethodSizedString.class);
- ByteBuffer enc;
-
- enc = consPacket("00:00:00:07", "54:65:73:74:69:6e:67", "00:00:00:04");
- TestMessageSizedString p1 = codec.decodePacket(TestMessageSizedString.class, enc);
- TestMessageSizedString e1 = new TestMessageSizedString("Testing", 4);
- e1.len = 7; // Have to set this manually for testing, since it's never encoded
- assertEquals(e1, p1);
-
- enc = consPacket("00:00:00:0c", "54:65:73:74:69:6e:67:32");
- TestMessageMethodSizedString p2 =
- codec.decodePacket(TestMessageMethodSizedString.class, enc);
- TestMessageMethodSizedString e2 = new TestMessageMethodSizedString("Testing2");
- e2.len = 12;
- assertEquals(e2, p2);
- }
-
- @Test
- public void testCountedAnnot() throws PacketDecodeException, FieldOrderingException {
- codec.registerPacketType(TestMessageCountedShortArray.class);
- ByteBuffer enc;
-
- enc = consPacket("00:00:00:04", "00:00", "01:00", "02:00", "03:00", "00:00:be:ef");
- TestMessageCountedShortArray p1 =
- codec.decodePacket(TestMessageCountedShortArray.class, enc);
- TestMessageCountedShortArray e1 =
- new TestMessageCountedShortArray(0xbeef, (short) 0, (short) 1, (short) 2, (short) 3);
- e1.count = 4;
- assertEquals(e1, p1);
- }
-
- // Often have to copy, since decode consumes the buffer in place
- public ByteBuffer copy(ByteBuffer src) {
- return ByteBuffer.wrap(src.array());
- }
-
- @Test
- public void testTypedAnnot() throws PacketDecodeException, FieldOrderingException {
- codec.registerPacketType(TestMessageDynamicTyped.class);
- codec.registerPacketType(TestMessageDynamicTypedSubs.class);
- ByteBuffer enc;
-
- enc = consPacket("00:00:00:01", "00:00:00:03");
- TestMessageDynamicTyped p1 = codec.decodePacket(TestMessageDynamicTyped.class, copy(enc));
- TestMessageDynamicTyped e1 = new TestMessageDynamicTyped(3);
- e1.type = 1;
- assertEquals(e1, p1);
-
- TestMessageDynamicTypedSubs p2 = codec.decodePacket(TestMessageDynamicTypedSubs.class, enc);
- TestMessageDynamicTypedSubs e2 =
- new TestMessageDynamicTypedSubs(new TestMessageDynamicTypedSubs.IntTestMessage(3));
- e2.type = 1;
- assertEquals(e2, p2);
-
- enc = consPacket("00:00:00:02", "00:00:00:00:00:00:00:04");
- p1 = codec.decodePacket(TestMessageDynamicTyped.class, copy(enc));
- e1 = new TestMessageDynamicTyped(4L);
- e1.type = 2;
- assertEquals(e1, p1);
-
- p2 = codec.decodePacket(TestMessageDynamicTypedSubs.class, enc);
- e2 = new TestMessageDynamicTypedSubs(new TestMessageDynamicTypedSubs.LongTestMessage(4));
- e2.type = 2;
- assertEquals(e2, p2);
- }
-
- @Test
- public void testCollection()
- throws PacketDecodeException, PacketEncodeException, FieldOrderingException {
- codec.registerPacketType(TestMessageUnmeasuredCollection.class);
- codec.registerPacketType(TestMessageFullSpecColField.class);
- ByteBuffer enc;
-
- enc = consPacket(//
- "02", "00:07", "54:65:73:74:69:6e:67", //
- "01", "00:04", "00:00:00:01", //
- "01", "00:04", "00:00:00:02");
- TestMessageUnmeasuredCollection p1 =
- codec.decodePacket(TestMessageUnmeasuredCollection.class, enc);
- TestMessageUnmeasuredCollection e1 = new TestMessageUnmeasuredCollection("Testing", 1, 2);
- codec.encodePacket(e1); // codec will initialize referenced fields (type, len)
- assertEquals(e1, p1);
-
- enc = consPacket("00:00:00:00", "00:00:00:01", "00:00:00:02", "00:00:00:03");
- TestMessageFullSpecColField p2 = codec.decodePacket(TestMessageFullSpecColField.class, enc);
- TestMessageFullSpecColField e2 = new TestMessageFullSpecColField(0, 1, 2, 3);
- assertEquals(e2, p2);
- }
-
- @Test
- public void testLookahead() throws PacketDecodeException, FieldOrderingException {
- codec.registerPacketType(TestMessageLookahead.class);
- ByteBuffer enc;
-
- enc = consPacket("49:6e:74", "00:00:00:03");
- TestMessageLookahead p1 = codec.decodePacket(TestMessageLookahead.class, enc);
- TestMessageLookahead e1 = new TestMessageLookahead(3);
- assertEquals(e1, p1);
-
- enc = consPacket("4c:6f:6e:67", "00:00:00:00:00:00:00:04");
- p1 = codec.decodePacket(TestMessageLookahead.class, enc);
- e1 = new TestMessageLookahead(4L);
- assertEquals(e1, p1);
- }
-
- @Test
- public void testDoubleTermed() throws PacketDecodeException, FieldOrderingException {
- codec.registerPacketType(TestMessageDoubleTermed.class);
- ByteBuffer enc;
-
- enc = consPacket("00:00:00:07", "54:65:73:74:69:6e:67", "00");
- TestMessageDoubleTermed p1 = codec.decodePacket(TestMessageDoubleTermed.class, enc);
- TestMessageDoubleTermed e1 = new TestMessageDoubleTermed("Testing");
- e1.len = 7;
- assertEquals(e1, p1);
- }
-
- @Test
- public void testOptional() throws PacketDecodeException {
- codec.registerPacketType(TestMessageOptional.class);
- ByteBuffer enc;
-
- enc = consPacket("53:6f:6d:65:53:74:72:69:6e:67");
- TestMessageOptional p1 = codec.decodePacket(TestMessageOptional.class, enc);
- TestMessageOptional e1 = new TestMessageOptional("SomeString");
- assertEquals(e1, p1);
-
- enc = consPacket("53:6f:6d:65:53:74:72:69:6e:67", "00", "00:00:00:33");
- p1 = codec.decodePacket(TestMessageOptional.class, enc);
- e1 = new TestMessageOptional("SomeString", 51);
- assertEquals(e1, p1);
- }
-
- @Test
- public void testEnum() throws PacketDecodeException {
- codec.registerPacketType(TestMessageEnum.class);
- ByteBuffer enc;
-
- enc = consPacket("01", "00:00:00:33");
- TestMessageEnum p1 = codec.decodePacket(TestMessageEnum.class, enc);
- TestMessageEnum e1 = new TestMessageEnum(TestEnum.ON, 51);
- assertEquals(e1, p1);
-
- enc = consPacket("02", "00:00:00:33");
- p1 = codec.decodePacket(TestMessageEnum.class, enc);
- e1 = new TestMessageEnum(TestEnum.ONE, 51);
- assertEquals(e1, p1);
-
- enc = consPacket("05", "00:00:00:33");
- try {
- p1 = codec.decodePacket(TestMessageEnum.class, enc);
- fail();
- }
- catch (PacketFieldValueMismatchException e) {
- // pass
- }
- }
-
- @Test
- public void testNoEmpty() {
- codec.registerPacketType(TestMessageEmpty.class);
- ByteBuffer enc;
-
- enc = consPacket("00");
- try {
- @SuppressWarnings("unused")
- TestMessageEmpty p1 = codec.decodePacket(TestMessageEmpty.class, enc);
- fail();
- }
- catch (PacketDecodeException e) {
- // pass
- }
- }
-
- @Test
- public void testAbstractElements() throws PacketDecodeException {
- codec.registerPacketType(TestMessageAbstractTestNumber.class);
- PacketTestClasses.LONG_TEST_NUMBER_FACTORY.registerTypes(codec);
- PacketTestClasses.INT_TEST_NUMBER_FACTORY.registerTypes(codec);
- ByteBuffer enc;
-
- enc = consPacket("00:00:00:02", "00:00:00:00:00:00:00:05", "00:00:00:00:00:00:00:06",
- "00:00:30:39");
- TestMessageAbstractTestNumber p1 = codec.decodePacket(TestMessageAbstractTestNumber.class,
- enc, PacketTestClasses.LONG_TEST_NUMBER_FACTORY);
- TestMessageAbstractTestNumber e1 =
- new TestMessageAbstractTestNumber(12345, new LongTestNumber(5), new LongTestNumber(6));
- e1.count = 2;
- assertEquals(e1, p1);
-
- enc = consPacket("00:00:00:02", "00:00:00:05", "00:00:00:06", "00:00:30:39");
- p1 = codec.decodePacket(TestMessageAbstractTestNumber.class, enc,
- PacketTestClasses.INT_TEST_NUMBER_FACTORY);
- e1 = new TestMessageAbstractTestNumber(12345, new IntTestNumber(5), new IntTestNumber(6));
- e1.count = 2;
- assertEquals(e1, p1);
- }
-
- @Test
- public void testAbstractPacket() throws PacketDecodeException {
- PacketTestClasses.LONG_TEST_NUMBER_FACTORY.registerTypes(codec);
- PacketTestClasses.INT_TEST_NUMBER_FACTORY.registerTypes(codec);
- ByteBuffer enc;
-
- enc = consPacket("00:00:00:00:00:00:00:02");
- AbstractTestNumber p1 = codec.decodePacket(AbstractTestNumber.class, enc,
- PacketTestClasses.LONG_TEST_NUMBER_FACTORY);
- AbstractTestNumber e1 = new LongTestNumber(2);
- assertEquals(e1, p1);
-
- enc = consPacket("00:00:00:02");
- AbstractTestNumber p2 = codec.decodePacket(AbstractTestNumber.class, enc,
- PacketTestClasses.INT_TEST_NUMBER_FACTORY);
- AbstractTestNumber e2 = new IntTestNumber(2);
- assertEquals(e2, p2);
- }
-
- @Test
- public void testTypedByMap() throws PacketDecodeException {
- codec.registerPacketType(TestMessageTypedByMap.class);
- ByteBuffer enc;
-
- enc = consPacket("00", "00:00:00:05");
- TestMessageTypedByMap p1 = codec.decodePacket(TestMessageTypedByMap.class, enc);
- TestMessageTypedByMap e1 = new TestMessageTypedByMap(new TestASubByMap(5));
- e1.type = TestMessageTypedByMap.TestEnum.A;
- assertEquals(e1, p1);
-
- enc = consPacket("01", "00:00:00:00:00:00:00:06");
- p1 = codec.decodePacket(TestMessageTypedByMap.class, enc);
- e1 = new TestMessageTypedByMap(new TestBSubByMap(6));
- e1.type = TestMessageTypedByMap.TestEnum.B;
- assertEquals(e1, p1);
- }
-}
diff --git a/Ghidra/Debug/Framework-AsyncComm/src/test/java/ghidra/comm/tests/packet/ByteBufferPacketEncodingTest.java b/Ghidra/Debug/Framework-AsyncComm/src/test/java/ghidra/comm/tests/packet/ByteBufferPacketEncodingTest.java
deleted file mode 100644
index 7d4bb6e9f9..0000000000
--- a/Ghidra/Debug/Framework-AsyncComm/src/test/java/ghidra/comm/tests/packet/ByteBufferPacketEncodingTest.java
+++ /dev/null
@@ -1,212 +0,0 @@
-/* ###
- * 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 ghidra.comm.tests.packet;
-
-import static ghidra.comm.tests.packet.ByteBufferPacketDecodingTest.consPacket;
-import static org.junit.Assert.assertEquals;
-
-import java.nio.ByteBuffer;
-
-import org.junit.Before;
-import org.junit.Test;
-
-import ghidra.comm.packet.PacketCodec;
-import ghidra.comm.packet.binary.ByteBufferPacketCodec;
-import ghidra.comm.packet.err.FieldOrderingException;
-import ghidra.comm.packet.err.PacketEncodeException;
-import ghidra.comm.tests.packet.PacketTestClasses.TestMessageEnum.TestEnum;
-import ghidra.comm.tests.packet.PacketTestClasses.TestMessageTypedByMap.TestASubByMap;
-import ghidra.comm.tests.packet.PacketTestClasses.TestMessageTypedByMap.TestBSubByMap;
-
-public class ByteBufferPacketEncodingTest implements PacketTestClasses {
- protected PacketCodec<ByteBuffer> codec;
-
- @Before
- public void setUp() {
- codec = ByteBufferPacketCodec.getInstance();
- }
-
- @Test
- public void testFlat() throws PacketEncodeException, FieldOrderingException {
- codec.registerPacketType(TestMessageFlatTypes.class);
- codec.registerPacketType(TestMessageFlatMixedEndian.class);
- ByteBuffer enc;
-
- enc = codec.encodePacket(
- new TestMessageFlatTypes(true, (byte) 2, '3', (short) 4, 5, 6, "seven", 8, 9));
- assertEquals(
- consPacket("01", "02" + "00:33", "00:04", "00:00:00:05", "00:00:00:00:00:00:00:06",
- "73:65:76:65:6e:00", "41:00:00:00", "40:22:00:00:00:00:00:00"),
- enc);
-
- enc = codec.encodePacket(
- new TestMessageFlatMixedEndian('1', '2', 3, 4, "five", "six", 7, 8, 9, 10, 11, 12));
- assertEquals(
- consPacket("00:31", "32:00", "00:00:00:03", "04:00:00:00", "66:69:76:65:00",
- "73:69:78:00:00", "00:00:00:00:00:00:00:07", "08:00:00:00:00:00:00:00",
- "41:10:00:00", "00:00:20:41", "40:26:00:00:00:00:00:00", "00:00:00:00:00:00:28:40"),
- enc);
- }
-
- @Test
- public void testSizedAnnot() throws PacketEncodeException, FieldOrderingException {
- codec.registerPacketType(TestMessageSizedString.class);
- codec.registerPacketType(TestMessageMethodSizedString.class);
- ByteBuffer enc;
-
- enc = codec.encodePacket(new TestMessageSizedString("Testing", 4));
- assertEquals(consPacket("00:00:00:07", "54:65:73:74:69:6e:67", "00:00:00:04"), enc);
-
- enc = codec.encodePacket(new TestMessageMethodSizedString("Testing2"));
- assertEquals(consPacket("00:00:00:0c", "54:65:73:74:69:6e:67:32"), enc);
- }
-
- @Test
- public void testCountedAnnot() throws PacketEncodeException, FieldOrderingException {
- codec.registerPacketType(TestMessageCountedShortArray.class);
- ByteBuffer enc;
-
- enc = codec.encodePacket(
- new TestMessageCountedShortArray(0xbeef, (short) 0, (short) 1, (short) 2, (short) 3));
- assertEquals(consPacket("00:00:00:04", "00:00", "01:00", "02:00", "03:00", "00:00:be:ef"),
- enc);
- }
-
- @Test
- public void testTypedAnnot() throws PacketEncodeException, FieldOrderingException {
- codec.registerPacketType(TestMessageDynamicTyped.class);
- codec.registerPacketType(TestMessageDynamicTypedSubs.class);
- ByteBuffer enc;
-
- enc = codec.encodePacket(new TestMessageDynamicTyped(3));
- assertEquals(consPacket("00:00:00:01", "00:00:00:03"), enc);
-
- enc = codec.encodePacket(new TestMessageDynamicTyped(4L));
- assertEquals(consPacket("00:00:00:02", "00:00:00:00:00:00:00:04"), enc);
-
- enc = codec.encodePacket(
- new TestMessageDynamicTypedSubs(new TestMessageDynamicTypedSubs.IntTestMessage(3)));
- assertEquals(consPacket("00:00:00:01", "00:00:00:03"), enc);
-
- enc = codec.encodePacket(
- new TestMessageDynamicTypedSubs(new TestMessageDynamicTypedSubs.LongTestMessage(4)));
- assertEquals(consPacket("00:00:00:02", "00:00:00:00:00:00:00:04"), enc);
- }
-
- @Test
- public void testCollection() throws PacketEncodeException, FieldOrderingException {
- codec.registerPacketType(TestMessageUnmeasuredCollection.class);
- codec.registerPacketType(TestMessageFullSpecColField.class);
- ByteBuffer enc;
-
- enc = codec.encodePacket(new TestMessageUnmeasuredCollection("Testing", 1, 2));
- assertEquals(consPacket( //
- "02", "00:07", "54:65:73:74:69:6e:67", //
- "01", "00:04", "00:00:00:01", //
- "01", "00:04", "00:00:00:02"), //
- enc);
-
- enc = codec.encodePacket(new TestMessageFullSpecColField(0, 1, 2, 3));
- assertEquals(consPacket("00:00:00:00", "00:00:00:01", "00:00:00:02", "00:00:00:03"), enc);
- }
-
- @Test
- public void testLookahead() throws PacketEncodeException, FieldOrderingException {
- codec.registerPacketType(TestMessageLookahead.class);
- ByteBuffer enc;
-
- enc = codec.encodePacket(new TestMessageLookahead(3));
- assertEquals(consPacket("49:6e:74", "00:00:00:03"), enc);
-
- enc = codec.encodePacket(new TestMessageLookahead(4L));
- assertEquals(consPacket("4c:6f:6e:67", "00:00:00:00:00:00:00:04"), enc);
- }
-
- @Test
- public void testDoubleTermed() throws PacketEncodeException, FieldOrderingException {
- codec.registerPacketType(TestMessageDoubleTermed.class);
- ByteBuffer enc;
-
- enc = codec.encodePacket(new TestMessageDoubleTermed("Testing"));
- assertEquals(consPacket("00:00:00:07", "54:65:73:74:69:6e:67", "00"), enc);
- }
-
- @Test
- public void testOptional() throws PacketEncodeException {
- codec.registerPacketType(TestMessageOptional.class);
- ByteBuffer enc;
-
- enc = codec.encodePacket(new TestMessageOptional("SomeString"));
- assertEquals(consPacket("53:6f:6d:65:53:74:72:69:6e:67"), enc);
-
- enc = codec.encodePacket(new TestMessageOptional("SomeString", 51));
- assertEquals(consPacket("53:6f:6d:65:53:74:72:69:6e:67", "00", "00:00:00:33"), enc);
- }
-
- @Test
- public void testEnum() throws PacketEncodeException {
- codec.registerPacketType(TestMessageEnum.class);
- ByteBuffer enc;
-
- enc = codec.encodePacket(new TestMessageEnum(TestEnum.ON, 51));
- assertEquals(consPacket("01", "00:00:00:33"), enc);
-
- enc = codec.encodePacket(new TestMessageEnum(TestEnum.ONE, 51));
- assertEquals(consPacket("02", "00:00:00:33"), enc);
- }
-
- @Test
- public void testAbstractElements() throws PacketEncodeException {
- codec.registerPacketType(TestMessageAbstractTestNumber.class);
- PacketTestClasses.LONG_TEST_NUMBER_FACTORY.registerTypes(codec);
- PacketTestClasses.INT_TEST_NUMBER_FACTORY.registerTypes(codec);
- ByteBuffer enc;
-
- enc = codec.encodePacket(
- new TestMessageAbstractTestNumber(12345, new LongTestNumber(5), new LongTestNumber(6)));
- assertEquals(consPacket("00:00:00:02", "00:00:00:00:00:00:00:05", "00:00:00:00:00:00:00:06",
- "00:00:30:39"), enc);
-
- enc = codec.encodePacket(
- new TestMessageAbstractTestNumber(12345, new IntTestNumber(5), new IntTestNumber(6)));
- assertEquals(consPacket("00:00:00:02", "00:00:00:05", "00:00:00:06", "00:00:30:39"), enc);
- }
-
- @Test
- public void testAbstractPacket() throws PacketEncodeException {
- PacketTestClasses.LONG_TEST_NUMBER_FACTORY.registerTypes(codec);
- PacketTestClasses.INT_TEST_NUMBER_FACTORY.registerTypes(codec);
- ByteBuffer enc;
-
- enc = codec.encodePacket(new LongTestNumber(2));
- assertEquals(consPacket("00:00:00:00:00:00:00:02"), enc);
-
- enc = codec.encodePacket(new IntTestNumber(2));
- assertEquals(consPacket("00:00:00:02"), enc);
- }
-
- @Test
- public void testTypedByMap() throws PacketEncodeException {
- codec.registerPacketType(TestMessageTypedByMap.class);
- ByteBuffer enc;
-
- enc = codec.encodePacket(new TestMessageTypedByMap(new TestASubByMap(5)));
- assertEquals(consPacket("00", "00:00:00:05"), enc);
-
- enc = codec.encodePacket(new TestMessageTypedByMap(new TestBSubByMap(6)));
- assertEquals(consPacket("01", "00:00:00:00:00:00:00:06"), enc);
- }
-}
diff --git a/Ghidra/Debug/Framework-AsyncComm/src/test/java/ghidra/comm/tests/packet/PacketCompTest.java b/Ghidra/Debug/Framework-AsyncComm/src/test/java/ghidra/comm/tests/packet/PacketCompTest.java
deleted file mode 100644
index f3a65c8da3..0000000000
--- a/Ghidra/Debug/Framework-AsyncComm/src/test/java/ghidra/comm/tests/packet/PacketCompTest.java
+++ /dev/null
@@ -1,159 +0,0 @@
-/* ###
- * 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 ghidra.comm.tests.packet;
-
-import static org.junit.Assert.*;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.junit.Test;
-
-import ghidra.comm.packet.Packet;
-import ghidra.comm.packet.fields.PacketField;
-
-public class PacketCompTest {
- public static class TestMessage extends Packet {
- @PacketField
- public int f1;
-
- @PacketField
- public TestSubMessage f2;
-
- @PacketField
- public TestSubMessage[] f3;
-
- @PacketField
- public short[] f4;
-
- @PacketField
- public List<TestSubMessage> f5;
-
- public int notafield;
- }
-
- public static class TestSubMessage extends Packet {
- @PacketField
- public float fA;
-
- @PacketField
- public String fB;
-
- @PacketField
- public String fC;
-
- public int alsonotfield;
- }
-
- protected TestMessage getExpPacket() {
- TestMessage msg = new TestMessage();
- msg.f1 = 5;
- msg.f2 = new TestSubMessage();
- msg.f2.fA = 7.0f;
- msg.f2.fB = "Copy";
- msg.f3 = new TestSubMessage[] { new TestSubMessage(), null };
- msg.f3[0].fB = "Elem0";
- msg.f4 = new short[] { (short) 3, (short) 4 };
- msg.f5 = new ArrayList<>();
- msg.f5.add(new TestSubMessage());
- msg.f5.add(null);
- msg.f5.get(0).fC = "ListElem0";
- msg.notafield = 1;
- msg.f2.alsonotfield = 2;
-
- return msg;
- }
-
- @Test
- public void testCopy() {
- TestMessage msg = getExpPacket();
- TestMessage cpy = msg.copy();
-
- assertEquals(5, cpy.f1);
- assertEquals(7.0f, cpy.f2.fA, 0.0);
- assertEquals("Copy", cpy.f2.fB);
- assertEquals(null, cpy.f2.fC);
- assertEquals("Elem0", cpy.f3[0].fB);
- assertEquals(null, cpy.f3[1]);
- assertEquals((short) 3, cpy.f4[0]);
- assertEquals((short) 4, cpy.f4[1]);
- assertEquals("ListElem0", cpy.f5.get(0).fC);
- assertEquals(null, cpy.f5.get(1));
- assertEquals(0, cpy.notafield);
- assertEquals(0, cpy.f2.alsonotfield);
-
- // Verify a deep copy
- cpy.f3[0].fB = "Clobber";
- assertEquals("Elem0", msg.f3[0].fB);
- cpy.f5.get(0).fC = "Clobber";
- assertEquals("ListElem0", msg.f5.get(0).fC);
- }
-
- @Test
- public void testToString() {
- TestMessage msg = getExpPacket();
- TestMessage cpy = getExpPacket();
-
- assertEquals(msg.toString(), cpy.toString());
-
- cpy.f3[0].fB = "Clobber";
- assertFalse(msg.toString().equals(cpy.toString()));
- }
-
- @Test
- public void testHashCode() {
- TestMessage msg = getExpPacket();
- TestMessage cpy = getExpPacket();
- int msgHash = msg.hashCode();
-
- assertEquals(msgHash, cpy.hashCode());
-
- cpy.f3[0].fB = "Clobber";
- assertFalse(msgHash == cpy.hashCode());
- }
-
- @Test
- public void testEquality() {
- TestMessage msg = getExpPacket();
- TestMessage cpy = getExpPacket();
-
- assertEquals(msg, cpy);
-
- cpy.f3[0].fB = "Clobber";
- assertFalse(msg.equals(cpy));
- }
-
- @Test
- public void testCompare() {
- TestMessage msg = getExpPacket();
- TestMessage cpy = getExpPacket();
-
- assertEquals(0, msg.compareTo(cpy));
-
- cpy.f2 = null;
- assertTrue(msg.compareTo(cpy) > 0);
- cpy = getExpPacket();
-
- cpy.f3[0].fB = "Clobber";
- assertTrue(msg.compareTo(cpy) > 0);
-
- cpy.f3[0].fB = "FollowsElem0";
- assertTrue(msg.compareTo(cpy) < 0);
-
- cpy.f3[0].fB = "Elem0";
- assertEquals(0, msg.compareTo(cpy));
- }
-}
diff --git a/Ghidra/Debug/Framework-AsyncComm/src/test/java/ghidra/comm/tests/packet/PacketFieldAnnotTest.java b/Ghidra/Debug/Framework-AsyncComm/src/test/java/ghidra/comm/tests/packet/PacketFieldAnnotTest.java
deleted file mode 100644
index 54b077a1af..0000000000
--- a/Ghidra/Debug/Framework-AsyncComm/src/test/java/ghidra/comm/tests/packet/PacketFieldAnnotTest.java
+++ /dev/null
@@ -1,343 +0,0 @@
-/* ###
- * 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 ghidra.comm.tests.packet;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.fail;
-
-import java.lang.reflect.Field;
-import java.util.*;
-
-import org.junit.Test;
-
-import ghidra.comm.packet.Packet;
-import ghidra.comm.packet.annot.*;
-import ghidra.comm.packet.annot.TypedByField.TypeSelect;
-import ghidra.comm.packet.binary.BinaryPacketCodec;
-import ghidra.comm.packet.err.*;
-import ghidra.comm.packet.fields.PacketField;
-
-public class PacketFieldAnnotTest {
- protected void expectOrder(Class<? extends Packet> cls, String... names)
- throws NoSuchFieldException, SecurityException, FieldOrderingException {
- List<Field> expected = new ArrayList<>();
-
- for (String name : names) {
- expected.add(cls.getField(name));
- }
- assertEquals(expected, Packet.getFields(cls));
- }
-
- public static class TestMessageBase extends Packet {
- @PacketField
- public int field1;
-
- @PacketField
- public int field2;
-
- public int notAField;
- }
-
- public static class TestMessageBase2 extends Packet {
- @PacketField
- public int field2;
-
- @PacketField
- public int field1;
- }
-
- public static class TestMessageExtM extends TestMessageBase {
- @PacketField(after = "field1", before = "field2")
- public String field1dot5;
- }
-
- @Test
- public void testGoodFieldOrders()
- throws NoSuchFieldException, SecurityException, FieldOrderingException {
- expectOrder(TestMessageBase.class, "field1", "field2");
- expectOrder(TestMessageBase2.class, "field2", "field1");
- expectOrder(TestMessageExtM.class, "field1", "field1dot5", "field2");
- }
-
- public static class TestMessageOrderCirc extends TestMessageBase {
- @PacketField(after = "field2", before = "field1")
- public String fieldCirc;
- }
-
- @Test
- public void testCircularOrder() throws NoSuchFieldException, SecurityException {
- try {
- expectOrder(TestMessageOrderCirc.class);
- fail();
- }
- catch (FieldOrderingException e) {
- if (!e.getCause().getMessage().contains("cyclic")) {
- fail(e.getMessage());
- }
- // pass
- }
- }
-
- public static class TestMessageExtU extends TestMessageBase {
- @PacketField
- public String fieldUnordered;
- }
-
- @Test
- public void testNotTotalOrder() throws NoSuchFieldException, SecurityException {
- try {
- expectOrder(TestMessageExtU.class);
- fail();
- }
- catch (FieldOrderingException e) {
- if (!e.getCause().getMessage().contains("total")) {
- fail(e.getMessage());
- }
- // pass
- }
- }
-
- public static class TestMessageExtAdvA extends TestMessageBase {
- @PacketField(after = "field2")
- public int field3;
-
- @PacketField
- public int field4;
- }
-
- public static class TestMessageExtAdvM extends TestMessageBase {
- @PacketField(after = "field1", before = "field2")
- public int field1dot3;
-
- @PacketField
- public int field1dot6;
- }
-
- @Test
- public void testAdvancedOrdering()
- throws NoSuchFieldException, SecurityException, FieldOrderingException {
- expectOrder(TestMessageExtAdvA.class, "field1", "field2", "field3", "field4");
- expectOrder(TestMessageExtAdvM.class, "field1", "field1dot3", "field1dot6", "field2");
- }
-
- public static class TestMessageAccessDefault extends Packet {
- @PacketField
- int forgotPublic;
- }
-
- public static class TestMessageStaticNotFinal extends Packet {
- @PacketField
- public static int forgotFinal;
- }
-
- @Test
- public void testForgotMods() throws FieldOrderingException {
- try {
- BinaryPacketCodec.getInstance().registerPacketType(TestMessageAccessDefault.class);
- fail();
- }
- catch (InvalidFieldModifiersException e) {
- // pass
- }
-
- try {
- BinaryPacketCodec.getInstance().registerPacketType(TestMessageStaticNotFinal.class);
- fail();
- }
- catch (InvalidFieldModifiersException e) {
- // pass
- }
- }
-
- public static class TestMessageNoSuchField extends Packet {
- @PacketField
- @SizedByField("nosuch")
- public byte[] data;
- }
-
- public static class TestMessageNotPacketField extends Packet {
- public int notfield;
-
- @PacketField
- @SizedByField("notfield")
- public byte[] data;
- }
-
- @Test
- public void testNoSuchField() throws FieldOrderingException {
- try {
- BinaryPacketCodec.getInstance().registerPacketType(TestMessageNoSuchField.class);
- fail();
- }
- catch (InvalidFieldNameException e) {
- // pass
- }
- }
-
- @Test
- public void testNotPacketField() throws FieldOrderingException {
- try {
- BinaryPacketCodec.getInstance().registerPacketType(TestMessageNotPacketField.class);
- fail();
- }
- catch (InvalidFieldNameException e) {
- // pass
- }
- }
-
- public static class TestMessageTypeNotExtension extends Packet {
- @PacketField
- public int type;
-
- @PacketField
- @TypedByField(by = "type", types = { //
- @TypeSelect(key = 1, type = String.class),//
- @TypeSelect(key = 2, type = Integer.class) })
- public Number num;
- }
-
- @Test
- public void testTypeNotExtension() throws FieldOrderingException {
- try {
- BinaryPacketCodec.getInstance().registerPacketType(TestMessageTypeNotExtension.class);
- fail();
- }
- catch (PacketAnnotationException e) {
- // pass
- }
- }
-
- public static class TestMessageCountProceedsField extends Packet {
- @PacketField
- @CountedByField("count")
- public byte[] data;
-
- @PacketField
- public int count;
- }
-
- @Test
- public void testCountProceedsField() {
- try {
- BinaryPacketCodec.getInstance().registerPacketType(TestMessageCountProceedsField.class);
- fail();
- }
- catch (AnnotatedFieldOrderingException e) {
- // pass
- }
- }
-
- public static class TestMessageSizeProceedsField extends Packet {
- @PacketField
- @SizedByField("size")
- public byte[] data;
-
- @PacketField
- public int size;
- }
-
- @Test
- public void testSizeProceedsField() {
- try {
- BinaryPacketCodec.getInstance().registerPacketType(TestMessageSizeProceedsField.class);
- fail();
- }
- catch (AnnotatedFieldOrderingException e) {
- // pass
- }
- }
-
- public static class TestMessageTypeProceedsField extends Packet {
- @PacketField
- @TypedByField(by = "type", types = { //
- @TypeSelect(key = 1, type = String.class) })
- public Object data;
-
- @PacketField
- public int type;
- }
-
- @Test
- public void testTypeProceedsField() {
- try {
- BinaryPacketCodec.getInstance().registerPacketType(TestMessageTypeProceedsField.class);
- fail();
- }
- catch (AnnotatedFieldOrderingException e) {
- // pass
- }
- }
-
- public static class TestMessageTypeNoMap extends Packet {
- @PacketField
- public int type;
-
- @PacketField
- @TypedByField(by = "type", types = {})
- public Object[] data;
- }
-
- @Test
- public void testTypeNoMap() throws FieldOrderingException {
- try {
- BinaryPacketCodec.getInstance().registerPacketType(TestMessageTypeNoMap.class);
- fail();
- }
- catch (PacketAnnotationException e) {
- if (!(e.getAnnotation().annotationType() == TypedByField.class)) {
- fail();
- }
- // pass
- }
- }
-
- public static class TestMessageColNoRepAnnot extends Packet {
- @PacketField
- public Collection<Object> col;
- }
-
- @Test
- public void testColNoRepAnnot() {
- try {
- BinaryPacketCodec.getInstance().registerPacketType(TestMessageColNoRepAnnot.class);
- fail();
- }
- catch (PacketDeclarationException e) {
- // pass
- }
- }
-
- public static class TestMessageStaticFinalInherit extends Packet {
- public TestMessageStaticFinalInherit() {
- }
-
- @PacketField
- public static final String A = "A";
- }
-
- public static class TestSubMessageStaticFinalInherit extends TestMessageStaticFinalInherit {
- @PacketField(after = "A")
- public String f2;
- }
-
- @Test
- public void testStaticFinalInherit() {
- List<Field> fields = Packet.getFields(TestSubMessageStaticFinalInherit.class);
- assertEquals(2, fields.size());
- assertEquals("A", fields.get(0).getName());
- assertEquals("f2", fields.get(1).getName());
- }
-}
diff --git a/Ghidra/Debug/Framework-AsyncComm/src/test/java/ghidra/comm/tests/packet/PacketTestClasses.java b/Ghidra/Debug/Framework-AsyncComm/src/test/java/ghidra/comm/tests/packet/PacketTestClasses.java
deleted file mode 100644
index ab8f246e3c..0000000000
--- a/Ghidra/Debug/Framework-AsyncComm/src/test/java/ghidra/comm/tests/packet/PacketTestClasses.java
+++ /dev/null
@@ -1,723 +0,0 @@
-/* ###
- * 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 ghidra.comm.tests.packet;
-
-import java.lang.reflect.InvocationTargetException;
-import java.util.*;
-
-import ghidra.comm.packet.*;
-import ghidra.comm.packet.annot.*;
-import ghidra.comm.packet.annot.TypedByField.TypeSelect;
-import ghidra.comm.packet.annot.WithFlag.Mode;
-import ghidra.comm.packet.binary.NullTerminated;
-import ghidra.comm.packet.binary.ReverseByteOrder;
-import ghidra.comm.packet.fields.PacketField;
-import ghidra.comm.packet.string.*;
-import ghidra.comm.packet.string.SizeRestricted.PadDirection;
-import ghidra.comm.util.BitmaskSet;
-import ghidra.comm.util.BitmaskUniverse;
-
-public interface PacketTestClasses {
- public static class TestMessageFlatTypes extends Packet {
- public TestMessageFlatTypes() {
- }
-
- public TestMessageFlatTypes(boolean f1, byte f2, char f3, short f4, int f5, long f6,
- String f7, float f8, double f9) {
- this.f1 = f1;
- this.f2 = f2;
- this.f3 = f3;
- this.f4 = f4;
- this.f5 = f5;
- this.f6 = f6;
- this.f7 = f7;
- this.f8 = f8;
- this.f9 = f9;
- }
-
- @PacketField
- @RegexTerminated(exp = ",", tok = ",")
- public boolean f1;
-
- @PacketField
- @RegexTerminated(exp = ",", tok = ",")
- public byte f2;
-
- @PacketField
- @RegexTerminated(exp = ",", tok = ",")
- public char f3;
-
- @PacketField
- @RegexTerminated(exp = ",", tok = ",")
- public short f4;
-
- @PacketField
- @RegexTerminated(exp = ",", tok = ",")
- @WithRadix(10)
- public int f5;
-
- @PacketField
- @RegexTerminated(exp = ",", tok = ",")
- public long f6;
-
- @PacketField
- @NullTerminated
- @RegexTerminated(exp = ",", tok = ",")
- public String f7;
-
- @PacketField
- @RegexTerminated(exp = ",", tok = ",")
- public float f8;
-
- @PacketField
- @WithRadix(16)
- public double f9;
- }
-
- public static class TestMessageFlatMixedEndian extends Packet {
- public TestMessageFlatMixedEndian() {
- }
-
- public TestMessageFlatMixedEndian(char f1, char f2, int f3, int f4, String f5, String f6,
- long f7, long f8, float f9, float f10, double f11, double f12) {
- this.f1 = f1;
- this.f2 = f2;
- this.f3 = f3;
- this.f4 = f4;
- this.f5 = f5;
- this.f6 = f6;
- this.f7 = f7;
- this.f8 = f8;
- this.f9 = f9;
- this.f10 = f10;
- this.f11 = f11;
- this.f12 = f12;
- }
-
- @PacketField
- @RegexTerminated(exp = ",", tok = ",")
- public char f1;
-
- @PacketField
- @ReverseByteOrder
- @RegexTerminated(exp = ",", tok = ",")
- public char f2;
-
- @PacketField
- @RegexTerminated(exp = ",", tok = ",")
- public int f3;
-
- @PacketField
- @ReverseByteOrder
- @RegexTerminated(exp = ",", tok = ",")
- public int f4;
-
- @PacketField
- @NullTerminated
- @RegexTerminated(exp = ",", tok = ",")
- public String f5;
-
- @PacketField
- @NullTerminated(2)
- @RegexTerminated(exp = "\\s+", tok = " ")
- public String f6;
-
- @PacketField
- @RegexTerminated(exp = ",", tok = ",")
- public long f7;
-
- @PacketField
- @ReverseByteOrder
- @RegexTerminated(exp = ",", tok = ",")
- public long f8;
-
- @PacketField
- @RegexTerminated(exp = ",", tok = ",")
- @WithRadix(10)
- public float f9;
-
- @PacketField
- @ReverseByteOrder
- @RegexTerminated(exp = ",", tok = ",")
- @WithRadix(10)
- public float f10;
-
- @PacketField
- @RegexTerminated(exp = ",", tok = ",")
- @WithRadix(10)
- public double f11;
-
- @PacketField
- @ReverseByteOrder
- @WithRadix(10)
- public double f12;
- }
-
- public static class TestMessageSizedString extends Packet {
- public TestMessageSizedString() {
- }
-
- public TestMessageSizedString(String str, int more) {
- this.str = str;
- this.more = more;
- }
-
- @PacketField
- @RegexTerminated(exp = ",", tok = ",")
- public int len;
-
- @PacketField
- @SizedByField("len")
- public String str;
-
- @PacketField
- public int more;
- }
-
- public static class TestMessageMethodSizedString extends Packet {
- public TestMessageMethodSizedString() {
- }
-
- public TestMessageMethodSizedString(String str) {
- this.str = str;
- }
-
- @PacketField
- @RegexTerminated(exp = ",", tok = ",")
- public int len;
-
- public int getLen() {
- return len - 4;
- }
-
- public void setLen(int len) {
- this.len = len + 4;
- }
-
- @PacketField
- @SizedByMethods(getter = "getLen", setter = "setLen", modifies = "len")
- public String str;
- }
-
- public static class TestMessageCountedShortArray extends Packet {
- public TestMessageCountedShortArray() {
- }
-
- public TestMessageCountedShortArray(int more, short... arr) {
- this.arr = arr;
- this.more = more;
- }
-
- @PacketField
- @RegexTerminated(exp = ",", tok = ",")
- public int count;
-
- @PacketField
- @ReverseByteOrder
- @RepeatedField
- @RegexSeparated(exp = ",", tok = ",")
- @CountedByField(value = "count")
- @RegexTerminated(exp = ";", tok = ";")
- public short[] arr;
-
- @PacketField
- @WithRadix(16)
- public int more;
- }
-
- public static class TestMessageDynamicTypedSubs extends Packet {
- public static abstract class SubTestMessageType extends Packet {
- // Placeholder
- }
-
- public TestMessageDynamicTypedSubs() {
- }
-
- public TestMessageDynamicTypedSubs(SubTestMessageType sub) {
- this.sub = sub;
- }
-
- public static class IntTestMessage extends SubTestMessageType {
- public IntTestMessage() {
- }
-
- public IntTestMessage(int val) {
- this.val = val;
- }
-
- @PacketField
- public int val;
- }
-
- public static class LongTestMessage extends SubTestMessageType {
- public LongTestMessage() {
- }
-
- public LongTestMessage(long val) {
- this.val = val;
- }
-
- @PacketField
- public long val;
- }
-
- @PacketField
- @RegexTerminated(exp = ",", tok = ",")
- public int type;
-
- @PacketField
- @TypedByField(by = "type", types = { //
- @TypeSelect(key = 1, type = IntTestMessage.class), //
- @TypeSelect(key = 2, type = LongTestMessage.class) })
- public SubTestMessageType sub;
- }
-
- public static class TestMessageDynamicTyped extends Packet {
- public TestMessageDynamicTyped() {
- }
-
- public TestMessageDynamicTyped(Number num) {
- this.num = num;
- }
-
- @PacketField
- @RegexTerminated(exp = ",", tok = ",")
- public int type;
-
- @PacketField
- @TypedByField(by = "type", types = { //
- @TypeSelect(key = 1, type = Integer.class), //
- @TypeSelect(key = 2, type = Long.class) })
- public Number num;
- }
-
- public static class TestMessageUnmeasuredCollection extends Packet {
- public static class TestElement extends Packet {
- public TestElement() {
- }
-
- public TestElement(Object val) {
- this.val = val;
- }
-
- @PacketField
- @RegexTerminated(exp = ",", tok = ",")
- public byte type;
-
- @PacketField
- @RegexTerminated(exp = ",", tok = ",")
- public short len;
-
- @PacketField
- @SizedByField("len")
- @TypedByField(by = "type", types = { //
- @TypeSelect(key = 1, type = Integer.class), //
- @TypeSelect(key = 2, type = String.class) })
- public Object val;
- }
-
- public TestMessageUnmeasuredCollection() {
- }
-
- public TestMessageUnmeasuredCollection(Object... items) {
- this.col = new ArrayList<>();
- for (Object o : items) {
- this.col.add(new TestElement(o));
- }
- }
-
- @PacketField
- @RepeatedField(container = ArrayList.class, elements = TestMessageUnmeasuredCollection.TestElement.class)
- public Collection<TestMessageUnmeasuredCollection.TestElement> col;
- }
-
- public static class TestMessageFullSpecColField extends Packet {
- public static class IntList extends ArrayList<Integer> {
- // Placeholder
- }
-
- public TestMessageFullSpecColField() {
- }
-
- public TestMessageFullSpecColField(int... nums) {
- col = new IntList();
- for (int n : nums) {
- col.add(n);
- }
- }
-
- @PacketField
- @RepeatedField
- @RegexSeparated(exp = ",", tok = ",")
- public IntList col;
- }
-
- public static class TestMessageLookahead extends Packet {
- public static abstract class SubTestMessageLookahead extends Packet {
- // Placeholder
- }
-
- public static class IntTestMessage extends SubTestMessageLookahead {
- public IntTestMessage() {
- }
-
- public IntTestMessage(int val) {
- this.val = val;
- }
-
- @PacketField
- public static final String INT = "Int";
-
- @PacketField
- public int val;
- }
-
- public static class LongTestMessage extends SubTestMessageLookahead {
- public LongTestMessage() {
- }
-
- public LongTestMessage(long val) {
- this.val = val;
- }
-
- @PacketField
- public static final String LONG = "Long";
-
- @PacketField
- public long val;
- }
-
- public TestMessageLookahead() {
- }
-
- public TestMessageLookahead(int val) {
- this.dyn = new IntTestMessage(val);
- }
-
- public TestMessageLookahead(long val) {
- this.dyn = new LongTestMessage(val);
- }
-
- @PacketField
- @TypedByLookahead({ IntTestMessage.class, LongTestMessage.class })
- public SubTestMessageLookahead dyn;
- }
-
- public static class TestMessageDoubleTermed extends Packet {
- public TestMessageDoubleTermed() {
- }
-
- public TestMessageDoubleTermed(String str) {
- this.str = str;
- }
-
- @PacketField
- @RegexTerminated(exp = ",", tok = ",")
- public int len;
-
- @PacketField
- @NullTerminated
- @RegexTerminated(exp = ",", tok = ",")
- @SizedByField(value = "len", adjust = 1)
- public String str;
- }
-
- public static class TestMessageFixedSize extends Packet {
- public TestMessageFixedSize() {
- }
-
- public TestMessageFixedSize(int... vals) {
- this.vals = vals;
- }
-
- @PacketField
- @SizeRestricted(direction = PadDirection.LEFT, pad = '0', value = 8)
- @WithRadix(16)
- @RepeatedField
- public int[] vals;
- }
-
- public static class TestMessageOptional extends Packet {
- public TestMessageOptional() {
- }
-
- public TestMessageOptional(String f1) {
- this.f1 = f1;
- }
-
- public TestMessageOptional(String f1, int opt) {
- this.f1 = f1;
- this.opt = opt;
- }
-
- @PacketField
- @RegexTerminated(exp = ";", tok = ";", cond = "opt")
- @NullTerminated(cond = "opt")
- public String f1;
-
- @PacketField
- @OptionalField
- public Integer opt;
- }
-
- public static class TestMessageEnum extends Packet {
- public static enum TestEnum {
- OFF, ON, ONE, TWO, THREE;
- }
-
- public TestMessageEnum() {
- }
-
- public TestMessageEnum(TestEnum mode, int val) {
- this.mode = mode;
- this.val = val;
- }
-
- @PacketField
- public TestEnum mode;
-
- @PacketField
- public int val;
- }
-
- public static class TestMessageHexString extends Packet {
- public TestMessageHexString() {
- }
-
- public TestMessageHexString(String encstr) {
- this.encstr = encstr;
- }
-
- @PacketField
- @SizeRestricted(direction = PadDirection.LEFT, pad = '0', value = 2)
- @WithRadix(16)
- @RepeatedField
- @EncodeChars("UTF-8")
- public String encstr;
- }
-
- public static class TestMessageEmpty extends Packet {
- // Intentionally empty
- }
-
- public static abstract class AbstractTestNumber extends Packet {
- public abstract long getLongValue();
-
- public abstract void setLongValue(long val);
- }
-
- public static class LongTestNumber extends AbstractTestNumber {
- @PacketField
- public long val;
-
- public LongTestNumber() {
- }
-
- public LongTestNumber(long val) {
- this.val = val;
- }
-
- @Override
- public long getLongValue() {
- return val;
- }
-
- @Override
- public void setLongValue(long val) {
- this.val = val;
- }
- }
-
- public static class IntTestNumber extends AbstractTestNumber {
- @PacketField
- public int val;
-
- public IntTestNumber() {
- }
-
- public IntTestNumber(int val) {
- this.val = val;
- }
-
- @Override
- public long getLongValue() {
- return val;
- }
-
- @Override
- public void setLongValue(long val) {
- this.val = (int) val;
- }
- }
-
- static final PacketFactory LONG_TEST_NUMBER_FACTORY = new AbstractPacketFactory() {
- @SuppressWarnings("unchecked")
- @Override
- public <P extends Packet> P newPacket(Class<P> pktType)
- throws InstantiationException, IllegalAccessException, IllegalArgumentException,
- InvocationTargetException, NoSuchMethodException, SecurityException {
- if (pktType == AbstractTestNumber.class) {
- return (P) new LongTestNumber();
- }
- return super.newPacket(pktType);
- }
-
- @Override
- public void registerTypes(PacketCodec<?> codec) {
- codec.registerPacketType(LongTestNumber.class);
- }
- };
-
- static final PacketFactory INT_TEST_NUMBER_FACTORY = new AbstractPacketFactory() {
- @SuppressWarnings("unchecked")
- @Override
- public <P extends Packet> P newPacket(Class<P> pktType)
- throws InstantiationException, IllegalAccessException, IllegalArgumentException,
- InvocationTargetException, NoSuchMethodException, SecurityException {
- if (pktType == AbstractTestNumber.class) {
- return (P) new IntTestNumber();
- }
- return super.newPacket(pktType);
- }
-
- @Override
- public void registerTypes(PacketCodec<?> codec) {
- codec.registerPacketType(IntTestNumber.class);
- }
- };
-
- public static class TestMessageAbstractTestNumber extends Packet {
- public TestMessageAbstractTestNumber() {
- }
-
- @SafeVarargs
- public TestMessageAbstractTestNumber(int follows, AbstractTestNumber... numbers) {
- this.numbers = Arrays.asList(numbers);
- this.follows = follows;
- }
-
- @PacketField
- public int count;
-
- @PacketField
- @RepeatedField
- @CountedByField("count")
- public List<AbstractTestNumber> numbers;
-
- @PacketField
- public int follows;
- }
-
- public static class TestMessageTypedByMap extends Packet {
- public enum TestEnum {
- A, B;
- }
-
- public static final Map<TestEnum, Class<? extends TestSubByMap>> ENUM_MAP =
- typeMap(TestEnum.class, TestSubByMap.class) //
- .put(TestEnum.A, TestASubByMap.class) //
- .put(TestEnum.B, TestBSubByMap.class) //
- .build();
-
- public abstract static class TestSubByMap extends Packet {
- // Placeholder
- }
-
- public static class TestASubByMap extends TestSubByMap {
- public TestASubByMap() {
- }
-
- public TestASubByMap(int val) {
- this.val = val;
- }
-
- @PacketField
- public int val;
- }
-
- public static class TestBSubByMap extends TestSubByMap {
- public TestBSubByMap() {
- }
-
- public TestBSubByMap(long val) {
- this.val = val;
- }
-
- @PacketField
- public long val;
- }
-
- public TestMessageTypedByMap() {
- }
-
- public TestMessageTypedByMap(TestSubByMap sub) {
- this.sub = sub;
- }
-
- @PacketField
- public TestEnum type;
-
- @PacketField
- @TypedByField(by = "type", map = "ENUM_MAP")
- public TestSubByMap sub;
- }
-
- public static class TestMessageFlags extends Packet {
- public enum TestFlags implements BitmaskUniverse {
- FIRST(1 << 0), SECOND(1 << 1);
-
- private final long mask;
-
- TestFlags(long mask) {
- this.mask = mask;
- }
-
- @Override
- public long getMask() {
- return mask;
- }
- }
-
- public TestMessageFlags() {
- this(null, null);
- }
-
- public TestMessageFlags(Long first) {
- this(first, null);
- }
-
- public TestMessageFlags(Integer second) {
- this(null, second);
- }
-
- public TestMessageFlags(Long first, Integer second) {
- this.first = first;
- this.second = second;
- }
-
- @PacketField
- @BitmaskEncoded(universe = TestFlags.class, type = Byte.class)
- public BitmaskSet<TestFlags> flags;
-
- @PacketField
- @WithFlag(by = "flags", flag = "FIRST")
- public Long first;
-
- @PacketField
- @WithFlag(by = "flags", flag = "SECOND", mode = Mode.ABSENT)
- public Integer second;
- }
-}
diff --git a/Ghidra/Debug/Framework-AsyncComm/src/test/java/ghidra/comm/tests/packet/PutzTest.java b/Ghidra/Debug/Framework-AsyncComm/src/test/java/ghidra/comm/tests/packet/PutzTest.java
deleted file mode 100644
index 02624cfbc8..0000000000
--- a/Ghidra/Debug/Framework-AsyncComm/src/test/java/ghidra/comm/tests/packet/PutzTest.java
+++ /dev/null
@@ -1,318 +0,0 @@
-/* ###
- * 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 ghidra.comm.tests.packet;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-
-import java.lang.reflect.*;
-import java.nio.charset.Charset;
-import java.util.*;
-import java.util.Map.Entry;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
-import org.apache.commons.lang3.StringUtils;
-import org.apache.commons.lang3.reflect.TypeUtils;
-import org.junit.Ignore;
-import org.junit.Test;
-
-public class PutzTest {
- public static class MyList extends ArrayList<Integer> {
- //
- }
-
- public static class MyList2 implements Collection<Integer> {
-
- @Override
- public int size() {
- // TODO Auto-generated method stub
- return 0;
- }
-
- @Override
- public boolean isEmpty() {
- // TODO Auto-generated method stub
- return false;
- }
-
- @Override
- public boolean contains(Object o) {
- // TODO Auto-generated method stub
- return false;
- }
-
- @Override
- public Iterator<Integer> iterator() {
- // TODO Auto-generated method stub
- return null;
- }
-
- @Override
- public Object[] toArray() {
- // TODO Auto-generated method stub
- return null;
- }
-
- @Override
- public <T> T[] toArray(T[] a) {
- // TODO Auto-generated method stub
- return null;
- }
-
- @Override
- public boolean add(Integer e) {
- // TODO Auto-generated method stub
- return false;
- }
-
- @Override
- public boolean remove(Object o) {
- // TODO Auto-generated method stub
- return false;
- }
-
- @Override
- public boolean containsAll(Collection<?> c) {
- // TODO Auto-generated method stub
- return false;
- }
-
- @Override
- public boolean addAll(Collection<? extends Integer> c) {
- // TODO Auto-generated method stub
- return false;
- }
-
- @Override
- public boolean removeAll(Collection<?> c) {
- // TODO Auto-generated method stub
- return false;
- }
-
- @Override
- public boolean retainAll(Collection<?> c) {
- // TODO Auto-generated method stub
- return false;
- }
-
- @Override
- public void clear() {
- // TODO Auto-generated method stub
-
- }
-
- }
-
- public List<Integer> f1;
- public MyList f2;
-
- @SuppressWarnings("unchecked")
- @Test
- public <E> void testColType() throws NoSuchFieldException, SecurityException {
- Field field;
- Class<? extends Collection<E>> colType;
-
- field = PutzTest.class.getField("f1");
- colType = (Class<? extends Collection<E>>) field.getType();
-
- System.out.println("a:" + colType);
- System.out.println("b:" + colType.getComponentType());
- System.out.println("c:" + colType.getTypeName());
- System.out.println("d:" + StringUtils.join(colType.getGenericInterfaces(), ","));
- System.out.println("e:" + StringUtils.join(colType.getTypeParameters(), ","));
- System.out.println("g:" + colType.getGenericSuperclass());
- System.out.println();
-
- field = PutzTest.class.getField("f2");
- colType = (Class<? extends Collection<E>>) field.getType();
-
- System.out.println("a:" + colType);
- System.out.println("b:" + colType.getComponentType());
- System.out.println("c:" + colType.getTypeName());
- System.out.println("d:" + StringUtils.join(colType.getGenericInterfaces(), ","));
- System.out.println("e:" + StringUtils.join(colType.getTypeParameters(), ","));
- Class<?> supType = colType.getSuperclass();
- System.out.println("f:" + supType);
- System.out.println("g:" + colType.getGenericSuperclass());
- System.out.println();
-
- System.out.println("h:" + StringUtils.join(MyList2.class.getGenericInterfaces(), ","));
- System.out.println("i:" + StringUtils.join(MyList.class.getGenericInterfaces(), ","));
- System.out.println();
-
- Map<TypeVariable<?>, Type> args =
- TypeUtils.getTypeArguments(MyList.class, Collection.class);
- System.out.println("a:" + args);
- System.out.println("b:" + TypeUtils.getTypeArguments(MyList2.class, Collection.class));
-
- for (Map.Entry<TypeVariable<?>, Type> ent : args.entrySet()) {
- System.out.println(ent.getKey().getGenericDeclaration());
- System.out.println(ent.getKey().getName());
- }
- }
-
- public static interface MyI1<T> {
- void someMethod(T t);
- }
-
- public static interface MyBound1 {
- //
- }
-
- public static interface MyArg1 extends MyBound1 {
- //
- }
-
- public static interface MyI2<T extends MyBound1> extends MyI1<T> {
- //
- }
-
- public static interface MyI3 extends MyI2<MyArg1> {
- //
- }
-
- public static class MyC1 implements MyI3 {
-
- @Override
- public void someMethod(MyArg1 t) {
- // TODO Auto-generated method stub
-
- }
-
- }
-
- protected void dumpTypeArguments(Class<?> cls, Map<TypeVariable<?>, Type> map) {
- for (Entry<TypeVariable<?>, Type> entry : map.entrySet()) {
- System.out.println(entry.getValue());
- System.out.println(" val:" + entry.getValue());
- System.out.println(" cls:" + entry.getValue().getClass());
- System.out.println(" raw:" + TypeUtils.getRawType(entry.getValue(), cls));
- System.out.println(" bnd:" + StringUtils.join(entry.getKey().getBounds(), ","));
- }
- }
-
- @Test
- public void testTypes() {
- dumpTypeArguments(MyI2.class, TypeUtils.getTypeArguments(MyI2.class, MyI1.class));
- //TypeUtils.typesSatisfyVariables(typeVarAssigns);
- for (Method m : MyI2.class.getMethods()) {
- System.out.println(m);
- }
- for (Method m : MyI3.class.getMethods()) {
- System.out.println(m);
- }
- for (Method m : MyC1.class.getMethods()) {
- System.out.println(m);
- }
- }
-
- @Test
- public void testNumber() {
- System.out.println(Number.class.isAssignableFrom(Integer.class));
- System.out.println(Number.class.isAssignableFrom(int.class));
- }
-
- public static enum EnumTest {
- ZERO, ONE, TWO, THREE;
- }
-
- @Test
- public void testEnum() {
- Object et = EnumTest.TWO;
-
- System.out.println(et.getClass().isEnum());
- Enum<?> e = (Enum<?>) et;
- System.out.println(e.name());
- System.out.println(e.ordinal());
-
- for (Enum<?> ec : e.getClass().getEnumConstants()) {
- System.out.println(ec);
- }
- }
-
- @Test
- public void testASCII() {
- Charset cs = Charset.forName("ASCII");
- System.out.println(cs);
- }
-
- @Ignore
- @Test
- public void testMatcherMutable() {
- Pattern pat = Pattern.compile("#");
- Matcher mat = pat.matcher("Test#aa");
- assertTrue(mat.find());
-
- StringBuilder buf = new StringBuilder();
- buf.append("Test#aa");
- System.out.println(buf);
- mat = pat.matcher(buf);
- assertTrue(mat.find());
- int i = mat.start();
- System.out.println(i);
- buf.append("More#bb");
- System.out.println(buf);
- assertTrue(mat.find());
- i = mat.start();
- System.out.println(i);
- }
-
- @Test
- public void testRegexSymbols() {
- Pattern pat = Pattern.compile("[=\\+\\-\\?]");
- Matcher mat = pat.matcher("some:string:more+");
- assertTrue(mat.find());
- assertEquals("+", mat.group());
- }
-
- @Test
- public void testSpeedFormat() {
- System.out.println(Integer.toHexString(23));
- long start = System.currentTimeMillis();
- for (int i = 0; i < 100000; i++) {
- @SuppressWarnings("unused")
- String ignore = StringUtils.leftPad(Integer.toHexString(i), 4, '0');
- }
- long mid = System.currentTimeMillis();
- for (int i = 0; i < 100000; i++) {
- @SuppressWarnings("unused")
- String ignore = String.format("%04x", i);
- }
- long end = System.currentTimeMillis();
-
- System.out.println("toHexString time: " + (mid - start));
- System.out.println("format time: " + (end - mid));
- }
-
- @Test
- public void testGenerics() throws SecurityException {
- Object o = new Object() {
- @SuppressWarnings("unused")
- public Integer fieldInteger;
- @SuppressWarnings("unused")
- public int fieldInt;
- @SuppressWarnings("unused")
- public List<Integer> fieldListInteger;
- };
-
- for (Field f : o.getClass().getFields()) {
- System.out.println(f.getName() + ":" + f.getGenericType());
- System.out.println(TypeUtils.getRawType(f.getGenericType(), Object.class));
- }
-
- }
-}
diff --git a/Ghidra/Debug/Framework-AsyncComm/src/test/java/ghidra/comm/tests/packet/StringPacketDecodingTest.java b/Ghidra/Debug/Framework-AsyncComm/src/test/java/ghidra/comm/tests/packet/StringPacketDecodingTest.java
deleted file mode 100644
index 57eb895b7e..0000000000
--- a/Ghidra/Debug/Framework-AsyncComm/src/test/java/ghidra/comm/tests/packet/StringPacketDecodingTest.java
+++ /dev/null
@@ -1,232 +0,0 @@
-/* ###
- * 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 ghidra.comm.tests.packet;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.fail;
-
-import org.junit.Before;
-import org.junit.Test;
-
-import ghidra.comm.packet.PacketCodec;
-import ghidra.comm.packet.err.*;
-import ghidra.comm.packet.string.StringPacketCodec;
-import ghidra.comm.tests.packet.PacketTestClasses.*;
-import ghidra.comm.tests.packet.PacketTestClasses.TestMessageEnum.TestEnum;
-
-public class StringPacketDecodingTest {
- protected PacketCodec<String> codec; // Use the interface to ensure methods are defined there
-
- @Before
- public void setUp() {
- codec = StringPacketCodec.getInstance();
- }
-
- @Test
- public void testFlat() throws PacketDecodeException {
- codec.registerPacketType(TestMessageFlatTypes.class);
- codec.registerPacketType(TestMessageFlatMixedEndian.class);
- String enc;
-
- enc = "1,2,3,4,50,3c,seven,8.0,0x1.2p3";
- TestMessageFlatTypes p1 = codec.decodePacket(TestMessageFlatTypes.class, enc);
- TestMessageFlatTypes e1 =
- new TestMessageFlatTypes(true, (byte) 2, '3', (short) 4, 50, 60, "seven", 8, 9);
- assertEquals(e1, p1);
-
- enc = "1,2,3,4,five,six 7,8,9.0,10.0,11.0,12.0";
- TestMessageFlatMixedEndian p2 = codec.decodePacket(TestMessageFlatMixedEndian.class, enc);
- TestMessageFlatMixedEndian e2 =
- new TestMessageFlatMixedEndian('1', '2', 3, 4, "five", "six", 7, 8, 9, 10, 11, 12);
- assertEquals(e2, p2);
- }
-
- @Test
- public void testSizedAnnot() throws PacketDecodeException {
- codec.registerPacketType(TestMessageSizedString.class);
- codec.registerPacketType(TestMessageMethodSizedString.class);
- String enc;
-
- enc = "7,Testing4";
- TestMessageSizedString p1 = codec.decodePacket(TestMessageSizedString.class, enc);
- TestMessageSizedString e1 = new TestMessageSizedString("Testing", 4);
- e1.len = 7; // Have to set this manually for testing, since it's never encoded
- assertEquals(e1, p1);
-
- enc = "c,Testing2";
- TestMessageMethodSizedString p2 =
- codec.decodePacket(TestMessageMethodSizedString.class, enc);
- TestMessageMethodSizedString e2 = new TestMessageMethodSizedString("Testing2");
- e2.len = 12;
- assertEquals(e2, p2);
- }
-
- @Test
- public void testCountedAnnot() throws PacketDecodeException {
- codec.registerPacketType(TestMessageCountedShortArray.class);
- String enc;
-
- enc = "4,0,1,2,3;beef";
- TestMessageCountedShortArray p1 =
- codec.decodePacket(TestMessageCountedShortArray.class, enc);
- TestMessageCountedShortArray e1 =
- new TestMessageCountedShortArray(0xbeef, (short) 0, (short) 1, (short) 2, (short) 3);
- e1.count = 4;
- assertEquals(e1, p1);
- }
-
- @Test
- public void testTypedAnnot() throws PacketDecodeException {
- codec.registerPacketType(TestMessageDynamicTyped.class);
- codec.registerPacketType(TestMessageDynamicTypedSubs.class);
- String enc;
-
- enc = "1,3";
- TestMessageDynamicTyped p1 = codec.decodePacket(TestMessageDynamicTyped.class, enc);
- TestMessageDynamicTyped e1 = new TestMessageDynamicTyped(3);
- e1.type = 1;
- assertEquals(e1, p1);
-
- TestMessageDynamicTypedSubs p2 = codec.decodePacket(TestMessageDynamicTypedSubs.class, enc);
- TestMessageDynamicTypedSubs e2 =
- new TestMessageDynamicTypedSubs(new TestMessageDynamicTypedSubs.IntTestMessage(3));
- e2.type = 1;
- assertEquals(e2, p2);
-
- enc = "2,4";
- p1 = codec.decodePacket(TestMessageDynamicTyped.class, enc);
- e1 = new TestMessageDynamicTyped(4L);
- e1.type = 2;
- assertEquals(e1, p1);
-
- p2 = codec.decodePacket(TestMessageDynamicTypedSubs.class, enc);
- e2 = new TestMessageDynamicTypedSubs(new TestMessageDynamicTypedSubs.LongTestMessage(4));
- e2.type = 2;
- assertEquals(e2, p2);
- }
-
- @Test
- public void testCollection() throws PacketDecodeException, PacketEncodeException {
- codec.registerPacketType(TestMessageUnmeasuredCollection.class);
- codec.registerPacketType(TestMessageFullSpecColField.class);
- String enc;
-
- enc = "2,7,Testing" + "1,1,1" + "1,1,2";
- TestMessageUnmeasuredCollection p1 =
- codec.decodePacket(TestMessageUnmeasuredCollection.class, enc);
- TestMessageUnmeasuredCollection e1 = new TestMessageUnmeasuredCollection("Testing", 1, 2);
- codec.encodePacket(e1); // codec will initialize referenced fields (type, len)
- assertEquals(e1, p1);
-
- enc = "0,1,2,3";
- TestMessageFullSpecColField p2 = codec.decodePacket(TestMessageFullSpecColField.class, enc);
- TestMessageFullSpecColField e2 = new TestMessageFullSpecColField(0, 1, 2, 3);
- assertEquals(e2, p2);
- }
-
- @Test
- public void testLookahead() throws PacketDecodeException {
- codec.registerPacketType(TestMessageLookahead.class);
- String enc;
-
- enc = "Int3";
- TestMessageLookahead p1 = codec.decodePacket(TestMessageLookahead.class, enc);
- TestMessageLookahead e1 = new TestMessageLookahead(3);
- assertEquals(e1, p1);
-
- enc = "Long4";
- p1 = codec.decodePacket(TestMessageLookahead.class, enc);
- e1 = new TestMessageLookahead(4L);
- assertEquals(e1, p1);
- }
-
- @Test
- public void testDoubleTermed() throws PacketDecodeException {
- codec.registerPacketType(TestMessageDoubleTermed.class);
- String enc;
-
- enc = "7,Testing,";
- TestMessageDoubleTermed p1 = codec.decodePacket(TestMessageDoubleTermed.class, enc);
- TestMessageDoubleTermed e1 = new TestMessageDoubleTermed("Testing");
- e1.len = 7;
- assertEquals(e1, p1);
- }
-
- @Test
- public void testFixedSize() throws PacketDecodeException {
- codec.registerPacketType(TestMessageFixedSize.class);
- String enc;
-
- enc = "00000000000000010000000200000003";
- TestMessageFixedSize p1 = codec.decodePacket(TestMessageFixedSize.class, enc);
- TestMessageFixedSize e1 = new TestMessageFixedSize(0, 1, 2, 3);
- assertEquals(e1, p1);
- }
-
- @Test
- public void testOptional() throws PacketDecodeException {
- codec.registerPacketType(TestMessageOptional.class);
- String enc;
-
- enc = "SomeString";
- TestMessageOptional p1 = codec.decodePacket(TestMessageOptional.class, enc);
- TestMessageOptional e1 = new TestMessageOptional("SomeString");
- assertEquals(e1, p1);
-
- enc = "SomeString;33";
- p1 = codec.decodePacket(TestMessageOptional.class, enc);
- e1 = new TestMessageOptional("SomeString", 51);
- assertEquals(e1, p1);
- }
-
- @Test
- public void testEnum() throws PacketDecodeException {
- codec.registerPacketType(TestMessageEnum.class);
- String enc;
-
- enc = "ON33";
- TestMessageEnum p1 = codec.decodePacket(TestMessageEnum.class, enc);
- TestMessageEnum e1 = new TestMessageEnum(TestEnum.ON, 51);
- assertEquals(e1, p1);
-
- enc = "ONE33";
- p1 = codec.decodePacket(TestMessageEnum.class, enc);
- e1 = new TestMessageEnum(TestEnum.ONE, 51);
- assertEquals(e1, p1);
-
- enc = "NONE33";
- try {
- p1 = codec.decodePacket(TestMessageEnum.class, enc);
- fail();
- }
- catch (PacketFieldValueMismatchException e) {
- // pass
- }
- }
-
- @Test
- public void testHexString() throws PacketDecodeException {
- codec.registerPacketType(TestMessageHexString.class);
- String enc;
-
- enc = "54657374696e67";
- TestMessageHexString p1 = codec.decodePacket(TestMessageHexString.class, enc);
- TestMessageHexString e1 = new TestMessageHexString("Testing");
- assertEquals(e1, p1);
- }
-
- // TODO: Test Optional/Repeated vs. Repeated/Optional
-}
diff --git a/Ghidra/Debug/Framework-AsyncComm/src/test/java/ghidra/comm/tests/packet/StringPacketEncodingTest.java b/Ghidra/Debug/Framework-AsyncComm/src/test/java/ghidra/comm/tests/packet/StringPacketEncodingTest.java
deleted file mode 100644
index bb6b701bea..0000000000
--- a/Ghidra/Debug/Framework-AsyncComm/src/test/java/ghidra/comm/tests/packet/StringPacketEncodingTest.java
+++ /dev/null
@@ -1,170 +0,0 @@
-/* ###
- * 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 ghidra.comm.tests.packet;
-
-import static org.junit.Assert.assertEquals;
-
-import org.junit.Before;
-import org.junit.Test;
-
-import ghidra.comm.packet.PacketCodec;
-import ghidra.comm.packet.err.PacketEncodeException;
-import ghidra.comm.packet.string.StringPacketCodec;
-import ghidra.comm.tests.packet.PacketTestClasses.TestMessageEnum.TestEnum;
-
-public class StringPacketEncodingTest implements PacketTestClasses {
- protected PacketCodec<String> codec;
-
- @Before
- public void setUp() {
- codec = StringPacketCodec.getInstance();
- }
-
- @Test
- public void testFlat() throws PacketEncodeException {
- codec.registerPacketType(TestMessageFlatTypes.class);
- codec.registerPacketType(TestMessageFlatMixedEndian.class);
- String enc;
-
- enc = codec.encodePacket(
- new TestMessageFlatTypes(true, (byte) 2, '3', (short) 4, 50, 60, "seven", 8, 9));
- assertEquals("1,2,3,4,50,3c,seven,8.0,0x1.2p3", enc);
-
- enc = codec.encodePacket(
- new TestMessageFlatMixedEndian('1', '2', 3, 4, "five", "six", 7, 8, 9, 10, 11, 12));
- assertEquals("1,2,3,4,five,six 7,8,9.0,10.0,11.0,12.0", enc);
- }
-
- @Test
- public void testSizedAnnot() throws PacketEncodeException {
- codec.registerPacketType(TestMessageSizedString.class);
- codec.registerPacketType(TestMessageMethodSizedString.class);
- String enc;
-
- enc = codec.encodePacket(new TestMessageSizedString("Testing", 4));
- assertEquals("7,Testing4", enc);
-
- enc = codec.encodePacket(new TestMessageMethodSizedString("Testing2"));
- assertEquals("c,Testing2", enc);
- }
-
- @Test
- public void testCountedAnnot() throws PacketEncodeException {
- codec.registerPacketType(TestMessageCountedShortArray.class);
- String enc;
-
- enc = codec.encodePacket(
- new TestMessageCountedShortArray(0xbeef, (short) 0, (short) 1, (short) 2, (short) 3));
- assertEquals("4,0,1,2,3;beef", enc);
- }
-
- @Test
- public void testTypedAnnot() throws PacketEncodeException {
- codec.registerPacketType(TestMessageDynamicTyped.class);
- codec.registerPacketType(TestMessageDynamicTypedSubs.class);
- String enc;
-
- enc = codec.encodePacket(new TestMessageDynamicTyped(3));
- assertEquals("1,3", enc);
-
- enc = codec.encodePacket(new TestMessageDynamicTyped(4L));
- assertEquals("2,4", enc);
-
- enc = codec.encodePacket(
- new TestMessageDynamicTypedSubs(new TestMessageDynamicTypedSubs.IntTestMessage(3)));
- assertEquals("1,3", enc);
-
- enc = codec.encodePacket(
- new TestMessageDynamicTypedSubs(new TestMessageDynamicTypedSubs.LongTestMessage(4)));
- assertEquals("2,4", enc);
- }
-
- @Test
- public void testCollection() throws PacketEncodeException {
- codec.registerPacketType(TestMessageUnmeasuredCollection.class);
- codec.registerPacketType(TestMessageFullSpecColField.class);
- String enc;
-
- enc = codec.encodePacket(new TestMessageUnmeasuredCollection("Testing", 1, 2));
- assertEquals("2,7,Testing" + "1,1,1" + "1,1,2", enc);
-
- enc = codec.encodePacket(new TestMessageFullSpecColField(0, 1, 2, 3));
- assertEquals("0,1,2,3", enc);
- }
-
- @Test
- public void testLookahead() throws PacketEncodeException {
- codec.registerPacketType(TestMessageLookahead.class);
- String enc;
-
- enc = codec.encodePacket(new TestMessageLookahead(3));
- assertEquals("Int3", enc);
-
- enc = codec.encodePacket(new TestMessageLookahead(4L));
- assertEquals("Long4", enc);
- }
-
- @Test
- public void testDoubleTermed() throws PacketEncodeException {
- codec.registerPacketType(TestMessageDoubleTermed.class);
- String enc;
-
- enc = codec.encodePacket(new TestMessageDoubleTermed("Testing"));
- assertEquals("7,Testing,", enc);
- }
-
- @Test
- public void testFixedSize() throws PacketEncodeException {
- codec.registerPacketType(TestMessageFixedSize.class);
- String enc;
-
- enc = codec.encodePacket(new TestMessageFixedSize(0, 1, 2, 3));
- assertEquals("00000000000000010000000200000003", enc);
- }
-
- @Test
- public void testOptional() throws PacketEncodeException {
- codec.registerPacketType(TestMessageOptional.class);
- String enc;
-
- enc = codec.encodePacket(new TestMessageOptional("SomeString"));
- assertEquals("SomeString", enc);
-
- enc = codec.encodePacket(new TestMessageOptional("SomeString", 51));
- assertEquals("SomeString;33", enc);
- }
-
- @Test
- public void testEnum() throws PacketEncodeException {
- codec.registerPacketType(TestMessageEnum.class);
- String enc;
-
- enc = codec.encodePacket(new TestMessageEnum(TestEnum.ON, 51));
- assertEquals("ON33", enc);
-
- enc = codec.encodePacket(new TestMessageEnum(TestEnum.ONE, 51));
- assertEquals("ONE33", enc);
- }
-
- @Test
- public void testHexString() throws PacketEncodeException {
- codec.registerPacketType(TestMessageHexString.class);
- String enc;
-
- enc = codec.encodePacket(new TestMessageHexString("Testing"));
- assertEquals("54657374696e67", enc);
- }
-}
diff --git a/Ghidra/Debug/Framework-AsyncComm/src/test/java/ghidra/comm/tests/packet/package-info.java b/Ghidra/Debug/Framework-AsyncComm/src/test/java/ghidra/comm/tests/packet/package-info.java
deleted file mode 100644
index 70e36e0513..0000000000
--- a/Ghidra/Debug/Framework-AsyncComm/src/test/java/ghidra/comm/tests/packet/package-info.java
+++ /dev/null
@@ -1,23 +0,0 @@
-/* ###
- * 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.
- */
-/**
- * This package cannot share the same name as the package in main, because that package contains all
- * the scaffolding. Otherwise, when it is exported by
- * {@link ghidra.comm.util.pyexport.GeneratePython}, it gets confused, since it tries to export that
- * scaffolding, and thinks classes referred to in it are getting exported. That should never be the
- * case. Each target language for export must provide its own scaffolding.
- */
-package ghidra.comm.tests.packet;
diff --git a/Ghidra/Debug/Framework-AsyncComm/src/test/java/ghidra/comm/tests/packet/subpkg/PacketInSubpackage.java b/Ghidra/Debug/Framework-AsyncComm/src/test/java/ghidra/comm/tests/packet/subpkg/PacketInSubpackage.java
deleted file mode 100644
index 6e26cc55fe..0000000000
--- a/Ghidra/Debug/Framework-AsyncComm/src/test/java/ghidra/comm/tests/packet/subpkg/PacketInSubpackage.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/* ###
- * 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 ghidra.comm.tests.packet.subpkg;
-
-import java.util.List;
-import java.util.Map;
-
-import ghidra.comm.packet.Packet;
-import ghidra.comm.packet.fields.PacketField;
-
-public class PacketInSubpackage extends Packet {
- @PacketField
- public int a;
-
- @PacketField
- public long b;
-
- @PacketField
- public List<String> strList;
-
- @PacketField
- public Map<String, List<String>> multiStrMap;
-}
diff --git a/Ghidra/Debug/Framework-AsyncComm/src/test/java/ghidra/comm/util/CheckPackets.java b/Ghidra/Debug/Framework-AsyncComm/src/test/java/ghidra/comm/util/CheckPackets.java
deleted file mode 100644
index 895f5e665e..0000000000
--- a/Ghidra/Debug/Framework-AsyncComm/src/test/java/ghidra/comm/util/CheckPackets.java
+++ /dev/null
@@ -1,74 +0,0 @@
-/* ###
- * 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 ghidra.comm.util;
-
-import java.io.IOException;
-import java.net.*;
-import java.nio.file.*;
-import java.nio.file.attribute.BasicFileAttributes;
-
-import org.junit.Ignore;
-import org.junit.Test;
-
-import ghidra.comm.packet.Packet;
-import ghidra.comm.packet.PacketCodec;
-import ghidra.comm.packet.string.StringPacketCodec;
-import ghidra.util.Msg;
-
-@Ignore("Not high priority")
-public class CheckPackets {
- @Test
- public void testRegisterAll() throws IOException, URISyntaxException {
- registerAll(StringPacketCodec.getInstance());
- }
-
- public static void registerAll(PacketCodec<?> codec) throws IOException, URISyntaxException {
- URLClassLoader loader = (URLClassLoader) CheckPackets.class.getClassLoader();
- for (URL url : loader.getURLs()) {
- Path root = Paths.get(url.toURI());
- Files.walkFileTree(root, new SimpleFileVisitor<Path>() {
- @SuppressWarnings("unchecked")
- @Override
- public FileVisitResult visitFile(Path file, BasicFileAttributes attrs)
- throws IOException {
- if (!file.endsWith(".class")) {
- return FileVisitResult.CONTINUE;
- }
- String relPath = root.relativize(file).toString();
- String clsName = relPath.substring(0, relPath.length() - ".class".length())
- .replace('/', '.');
- Class<?> cls;
- try {
- cls = loader.loadClass(clsName);
- }
- catch (ClassNotFoundException e) {
- throw new RuntimeException(e);
- }
- if (Packet.class.isAssignableFrom(cls)) {
- try {
- codec.registerPacketType((Class<? extends Packet>) cls);
- }
- catch (Exception e) {
- Msg.error(CheckPackets.class,
- "Problem registering packet: " + e.getMessage());
- }
- }
- return FileVisitResult.CONTINUE;
- }
- });
- }
- }
-}