{"record":{"id":"9279cc4a5b3b2b84","repo":"NationalSecurityAgency/ghidra","slug":"trace-is-not-opened-in-this-tool","errorCode":null,"errorMessage":"Trace is not opened in this tool","messagePattern":"Trace is not opened in this tool","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/service/platform/DebuggerPlatformServicePlugin.java","lineNumber":97,"sourceCode":"\t\tsynchronized (mappersByTrace) {\n\t\t\tmapper = mappersByTrace.get(trace);\n\t\t\tif (mapper != null && mapper.canInterpret(object, snap)) {\n\t\t\t\treturn mapper;\n\t\t\t}\n\t\t\tmapper = getNewMapper(trace, object, snap);\n\t\t\tif (mapper == null) {\n\t\t\t\treturn null;\n\t\t\t}\n\t\t\tmappersByTrace.put(trace, mapper);\n\t\t}\n\t\tfirePluginEvent(new DebuggerPlatformPluginEvent(getName(), trace, mapper));\n\t\treturn mapper;\n\t}\n\n\t@Override\n\tpublic DebuggerPlatformMapper getNewMapper(Trace trace, TraceObject object, long snap) {\n\t\tif (!traceManager.getOpenTraces().contains(trace)) {\n\t\t\tthrow new IllegalArgumentException(\"Trace is not opened in this tool\");\n\t\t}\n\t\tfor (DebuggerPlatformOffer offer : DebuggerPlatformOpinion.queryOpinions(trace, object,\n\t\t\tsnap, false)) {\n\t\t\treturn offer.take(tool, trace);\n\t\t}\n\t\treturn null;\n\t}\n\n\t@Override\n\tpublic void setCurrentMapperFor(Trace trace, TraceObject focus, DebuggerPlatformMapper mapper, long snap) {\n\t\tObjects.requireNonNull(trace);\n\t\tObjects.requireNonNull(mapper);\n\t\tif (!traceManager.getOpenTraces().contains(trace)) {\n\t\t\tthrow new IllegalArgumentException(\"Trace is not opened in this tool\");\n\t\t}\n\t\tsynchronized (mappersByTrace) {\n\t\t\tmappersByTrace.put(trace, mapper);\n\t\t}","sourceCodeStart":79,"sourceCodeEnd":115,"githubUrl":"https://github.com/NationalSecurityAgency/ghidra/blob/d5f144c24d6bc53c9cbf4448c6d11143e7696206/Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/service/platform/DebuggerPlatformServicePlugin.java#L79-L115","documentation":"DebuggerPlatformServicePlugin.getNewMapper() requires the trace to be open in the current tool before it can query platform opinions and create a mapper. It checks traceManager.getOpenTraces().contains(trace) and throws IllegalArgumentException(\"Trace is not opened in this tool\") if not. A platform mapper needs the tool context (offers take(tool, trace)) to be constructed.","triggerScenarios":"Calling getNewMapper(trace, object, snap) on a trace that was never opened or was closed. Obtaining a Trace from a domain file and requesting a platform mapper without opening it in the trace manager.","commonSituations":"Scripts or headless code that hold a Trace reference but never opened it in the tool. Reusing a Trace after the user closed it. Cross-tool calls where the trace is open in a different tool.","solutions":["Open the trace in the trace manager (traceManager.openTrace(trace)) before calling getNewMapper.","Guard with traceManager.getOpenTraces().contains(trace) and open if missing.","Ensure you are operating within the same tool that owns the open trace."],"exampleFix":"// before\nDebuggerPlatformMapper mapper = platformService.getNewMapper(trace, obj, snap); // throws\n\n// after\nif (!traceManager.getOpenTraces().contains(trace)) {\n    traceManager.openTrace(trace);\n}\nDebuggerPlatformMapper mapper = platformService.getNewMapper(trace, obj, snap);","handlingStrategy":"validation","validationCode":"public static void ensureOpen(DebuggerTraceManagerService tm, Trace trace) {\n    if (!tm.getOpenTraces().contains(trace)) {\n        tm.openTrace(trace);\n    }\n}\n// before:\nensureOpen(traceManager, trace);\nplatformService.getNewMapper(trace, obj, snap);","typeGuard":"public static boolean isOpenInTool(DebuggerTraceManagerService tm, Trace trace) {\n    return trace != null && tm.getOpenTraces().contains(trace);\n}","tryCatchPattern":"try {\n    platformService.getNewMapper(trace, obj, snap);\n} catch (IllegalArgumentException e) {\n    if (e.getMessage().equals(\"Trace is not opened in this tool\")) {\n        traceManager.openTrace(trace);\n        platformService.getNewMapper(trace, obj, snap);\n    } else throw e;\n}","preventionTips":["Open the trace in the trace manager before any platform/mapping/emulation API.","Drop trace references after close; re-open before reuse.","Operate within the same tool that owns the open trace."],"tags":["platform","trace-manager","lifecycle","precondition"],"backgroundTag":null,"analyzedSha":"d5f144c24d6bc53c9cbf4448c6d11143e7696206","analyzedAt":"2026-08-14T01:00:57.564Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}