From 128f8bc3d3d447950d47492dd73acca40af7b667 Mon Sep 17 00:00:00 2001 From: d-millar <33498836+d-millar@users.noreply.github.com> Date: Sat, 24 Apr 2021 12:39:31 -0400 Subject: [PATCH] GP-889: opinion for 68k --- .../GdbM68kDebuggerMappingOpinion.java | 58 +++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/platform/GdbM68kDebuggerMappingOpinion.java diff --git a/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/platform/GdbM68kDebuggerMappingOpinion.java b/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/platform/GdbM68kDebuggerMappingOpinion.java new file mode 100644 index 0000000000..c6976a805c --- /dev/null +++ b/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/platform/GdbM68kDebuggerMappingOpinion.java @@ -0,0 +1,58 @@ +/* ### + * IP: GHIDRA + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package ghidra.app.plugin.core.debug.platform; + +import java.util.Set; + +import ghidra.app.plugin.core.debug.mapping.DebuggerMappingOffer; +import ghidra.app.plugin.core.debug.mapping.DebuggerMappingOpinion; +import ghidra.dbg.target.TargetEnvironment; +import ghidra.dbg.target.TargetProcess; +import ghidra.program.model.lang.CompilerSpecID; +import ghidra.program.model.lang.LanguageID; + +public class GdbM68kDebuggerMappingOpinion implements DebuggerMappingOpinion { + protected static final LanguageID LANG_ID_68K_BE = new LanguageID("68000:BE:32:default"); + protected static final CompilerSpecID COMP_ID_DEFAULT = new CompilerSpecID("default"); + + protected static class GdbM68kBELinux32DefOffer extends AbstractGdbDebuggerMappingOffer { + public GdbM68kBELinux32DefOffer(TargetProcess process) { + super(process, 100, "GDB on Linux m68k - 32-bit", LANG_ID_68K_BE, COMP_ID_DEFAULT, + Set.of()); + } + } + + @Override + public Set offersForEnv(TargetEnvironment env, TargetProcess process) { + if (!env.getDebugger().toLowerCase().contains("gdb")) { + return Set.of(); + } + String os = env.getOperatingSystem(); + if (!os.contains("Linux")) { + return Set.of(); + } + String endian = env.getEndian(); + if (!endian.contains("big")) { + return Set.of(); + } + String arch = env.getArchitecture(); + if (arch.startsWith("mips:32")) { + return Set.of(new GdbM68kBELinux32DefOffer(process)); + } + return Set.of(); + } + +}