{"record":{"id":"fb4dc8d986b0ec85","repo":"NationalSecurityAgency/ghidra","slug":"cannot-add-gzt-to-program","errorCode":null,"errorMessage":"Cannot add GZT to program","messagePattern":"Cannot add GZT to program","errorType":"exception","errorClass":"LoadException","httpStatus":null,"severity":"error","filePath":"Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/utils/GztLoader.java","lineNumber":132,"sourceCode":"\t\t\t\t\t}\n\t\t\t\t\telse {\n\t\t\t\t\t\tpackedDatabase.dispose();\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn trace;\n\t\t}\n\t\tfinally {\n\t\t\tif (tmpFile != null) {\n\t\t\t\ttmpFile.delete();\n\t\t\t}\n\t\t}\n\t}\n\n\t@Override\n\tpublic void loadInto(Program program, ImporterSettings settings)\n\t\t\tthrows IOException, LoadException, CancelledException {\n\t\tthrow new LoadException(\"Cannot add GZT to program\");\n\t}\n\n\t@Override\n\tpublic Collection<LoadSpec> findSupportedLoadSpecs(ByteProvider provider) throws IOException {\n\t\tList<LoadSpec> loadSpecs = new ArrayList<>();\n\t\tif (isGztFile(provider)) {\n\t\t\tloadSpecs.add(new LoadSpec(this, 0, false));\n\t\t}\n\t\treturn loadSpecs;\n\t}\n\n\t@Override\n\tpublic String getPreferredFileName(ByteProvider provider) {\n\t\treturn FilenameUtils.removeExtension(provider.getName());\n\t}\n\n\tprivate static File createTmpFile(ByteProvider provider, TaskMonitor monitor)\n\t\t\tthrows IOException {","sourceCodeStart":114,"sourceCodeEnd":150,"githubUrl":"https://github.com/NationalSecurityAgency/ghidra/blob/d5f144c24d6bc53c9cbf4448c6d11143e7696206/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/utils/GztLoader.java#L114-L150","documentation":"Thrown by GztLoader.loadInto() unconditionally — GZT traces cannot be appended or merged into an existing Program. The LoadException is always thrown because a GZT file represents a complete trace database, not an additive overlay. The loader only supports creating a new trace via load(), not loading into an existing program.","triggerScenarios":"Any call to GztLoader.loadInto(Program, ImporterSettings) throws immediately. This happens when the Ghidra import framework or a script attempts to use the GZT loader in 'add to program' mode — for example, importing additional files into an already-open program, or the import dialog offering 'Add to Program' for a GZT file.","commonSituations":"The user selects 'Add to Program' in the import dialog for a .gzt file. A script calls loader.loadInto() on a GztLoader instance. The import framework routes a multi-file import through loadInto instead of load.","solutions":["Use 'Import' (creating a new trace) instead of 'Add to Program' for GZT files.","If scripting, call GztLoader.load() to create a new trace rather than loadInto().","Disable or hide the 'Add to Program' option in the UI when the GZT loader is selected.","If merging trace data is needed, open the trace separately and use the Debugger's mapping features."],"exampleFix":"// Before:\n// loader.loadInto(program, settings); // always throws for GZT\n//\n// After:\n// // GZT can only create new traces:\n// DBTrace trace = (DBTrace) loader.load(loadSpecs, optionList, monitor, consumer);","handlingStrategy":"validation","validationCode":"// Before calling loadInto, check if the loader supports it:\n// GztLoader always throws from loadInto — never call it.\n// Use load() instead to create a new trace.","typeGuard":"// GztLoader does not support loadInto at all.\n// Always route GZT imports through load(), not loadInto().\nboolean supportsLoadInto(Loader loader) {\n    return !(loader instanceof GztLoader);\n}","tryCatchPattern":"try {\n    loader.loadInto(program, settings);\n} catch (LoadException e) {\n    if (e.getMessage().equals(\"Cannot add GZT to program\")) {\n        // use loader.load() to create a new trace instead\n    } else { throw e; }\n}","preventionTips":["Never call loadInto() on GztLoader — it is unconditionally unsupported.","In import workflows, use the 'New Project / Import' path for GZT files, not 'Add to Program'.","In scripts, branch on loader type before calling loadInto vs load."],"tags":["import","gzt","trace","load-exception","unsupported-operation"],"backgroundTag":null,"analyzedSha":"d5f144c24d6bc53c9cbf4448c6d11143e7696206","analyzedAt":"2026-08-14T01:00:57.564Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}