diff --git a/Ghidra/Debug/Debugger-isf/src/main/java/ghidra/dbg/isf/IsfServer.java b/Ghidra/Debug/Debugger-isf/src/main/java/ghidra/dbg/isf/IsfServer.java index 14d2d9067e..aeba8d0941 100644 --- a/Ghidra/Debug/Debugger-isf/src/main/java/ghidra/dbg/isf/IsfServer.java +++ b/Ghidra/Debug/Debugger-isf/src/main/java/ghidra/dbg/isf/IsfServer.java @@ -36,7 +36,6 @@ import ghidra.program.model.data.DataTypeManager; import ghidra.program.model.data.FileDataTypeManager; import ghidra.program.model.listing.Program; import ghidra.util.Msg; -import ghidra.util.exception.VersionException; import ghidra.util.task.TaskMonitor; public class IsfServer extends Thread { @@ -101,13 +100,13 @@ public class IsfServer extends Thread { try { DataTypeManager dtm; if (ns.endsWith(".gdt")) { - dtm = openAsArchive(ns); + dtm = openAsDataTypeArchive(ns); } else if (ns.endsWith(".gzf")) { - dtm = openAsDatabase(ns); + dtm = openAsProgramDatabase(ns); } else { - dtm = openAsDomainFile(ns); + dtm = openAsProgramFile(ns); } managers.put(ns, dtm); return dtm; @@ -119,43 +118,43 @@ public class IsfServer extends Thread { } } - private DataTypeManager openAsDomainFile(String ns) throws Exception { + private DataTypeManager openAsProgramFile(String ns) throws Exception { ProjectData projectData = project.getProjectData(); DomainFile df = projectData.getFile(ns); + if (!Program.class.isAssignableFrom(df.getDomainObjectClass())) { + throw new IOException("File does not correspond to Program content: " + ns); + } + + // FIXME: Need to track and release Program instance after DTM use is complete (GP-6895) Program program = (Program) df.getDomainObject(this, false, false, TaskMonitor.DUMMY); return program.getDataTypeManager(); } - private DataTypeManager openAsArchive(String ns) throws Exception { + private DataTypeManager openAsDataTypeArchive(String ns) throws Exception { File gdt = new File(ns); return FileDataTypeManager.openFileArchive(gdt, false); } - private DataTypeManager openAsDatabase(String ns) throws Exception { + private DataTypeManager openAsProgramDatabase(String ns) throws Exception { File gzf = new File(ns); TaskMonitor dummy = TaskMonitor.DUMMY; PackedDatabase db = PackedDatabase.getPackedDatabase(gzf, dummy); + DBHandle dbh = db.openForUpdate(dummy); - ProgramDB p = null; + + Program p; + boolean success = false; try { - p = new ProgramDB(dbh, OpenMode.UPDATE, dummy, this); - } - catch (VersionException e) { - if (!e.isUpgradable()) { - throw new RuntimeException(p + " uses an older version and is not upgradable."); - } + p = new ProgramDB(dbh, OpenMode.UPGRADE, dummy, this); + success = true; } finally { - dbh.close(); - } - - dbh = db.openForUpdate(dummy); - p = new ProgramDB(dbh, OpenMode.UPGRADE, dummy, this); - - if (!p.isChanged()) { - throw new RuntimeException(p + " uses an older version and was not upgraded."); + if (!success) { + dbh.close(); + } } + // FIXME: Need to track and release Program instance after DTM use is complete (GP-6895) return p.getListing().getDataTypeManager(); } diff --git a/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/export/TraceViewAsciiExporter.java b/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/export/TraceViewAsciiExporter.java deleted file mode 100644 index f31c1ffe8a..0000000000 --- a/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/export/TraceViewAsciiExporter.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.app.plugin.core.debug.export; - -import ghidra.app.util.exporter.AsciiExporter; -import ghidra.framework.model.DomainObject; -import ghidra.trace.model.Trace; - -public class TraceViewAsciiExporter extends AsciiExporter { - @Override - public boolean canExportDomainObject(Class domainObjectClass) { - return Trace.class.isAssignableFrom(domainObjectClass); - } -} diff --git a/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/export/TraceViewBinaryExporter.java b/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/export/TraceViewBinaryExporter.java deleted file mode 100644 index 2949322a91..0000000000 --- a/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/export/TraceViewBinaryExporter.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.app.plugin.core.debug.export; - -import ghidra.app.util.exporter.BinaryExporter; -import ghidra.framework.model.DomainObject; -import ghidra.trace.model.Trace; - -public class TraceViewBinaryExporter extends BinaryExporter { - @Override - public boolean canExportDomainObject(Class domainObjectClass) { - return Trace.class.isAssignableFrom(domainObjectClass); - } -} diff --git a/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/export/TraceViewHtmlExporter.java b/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/export/TraceViewHtmlExporter.java deleted file mode 100644 index b9c581e2c9..0000000000 --- a/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/export/TraceViewHtmlExporter.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.app.plugin.core.debug.export; - -import ghidra.app.util.exporter.HtmlExporter; -import ghidra.framework.model.DomainObject; -import ghidra.trace.model.Trace; - -public class TraceViewHtmlExporter extends HtmlExporter { - @Override - public boolean canExportDomainObject(Class domainObjectClass) { - return Trace.class.isAssignableFrom(domainObjectClass); - } -} diff --git a/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/export/TraceViewIntelHexExporter.java b/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/export/TraceViewIntelHexExporter.java deleted file mode 100644 index 96c85d60fd..0000000000 --- a/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/export/TraceViewIntelHexExporter.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.app.plugin.core.debug.export; - -import ghidra.app.util.exporter.IntelHexExporter; -import ghidra.framework.model.DomainObject; -import ghidra.trace.model.Trace; - -public class TraceViewIntelHexExporter extends IntelHexExporter { - @Override - public boolean canExportDomainObject(Class domainObjectClass) { - return Trace.class.isAssignableFrom(domainObjectClass); - } -} diff --git a/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/export/TraceViewXmlExporter.java b/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/export/TraceViewXmlExporter.java deleted file mode 100644 index 89778fc795..0000000000 --- a/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/export/TraceViewXmlExporter.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.app.plugin.core.debug.export; - -import java.util.*; -import java.util.stream.Collectors; - -import ghidra.app.util.*; -import ghidra.app.util.exporter.XmlExporter; -import ghidra.framework.model.DomainObject; -import ghidra.trace.model.Trace; - -// TODO: perhaps getApplicableExporters should use domainObject's class, not file's object class. -// TODO: Where un-supported, be less abrasive, e.g., present empty managers. -public class TraceViewXmlExporter extends XmlExporter { - private final Map hideOpts = Map.of( - "Properties", false, - "Relocation Table", false, - "External Libraries", false); - - @Override - public boolean canExportDomainObject(Class domainObjectClass) { - return Trace.class.isAssignableFrom(domainObjectClass); - } - - @Override - public List