{"record":{"id":"b53bf6ecb7acb957","repo":"NationalSecurityAgency/ghidra","slug":"trace-already-started-b53bf6","errorCode":null,"errorMessage":"Trace already started","messagePattern":"Trace already started","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"Ghidra/Debug/Debugger-jpda/src/main/java/ghidra/dbg/jdi/rmi/jpda/JdiCommands.java","lineNumber":91,"sourceCode":"\t\t\tthrow new RuntimeException(\"Already connected\");\n\t\t}\n\t}\n\n\tpublic void resetClient() {\n\t\tclient = null;\n\t\tresetTrace();\n\t}\n\n\tpublic RmiTrace requireTrace() {\n\t\tif (trace == null) {\n\t\t\tthrow new RuntimeException(\"No trace started\");\n\t\t}\n\t\treturn trace;\n\t}\n\n\tpublic void requireNoTrace() {\n\t\tif (trace != null) {\n\t\t\tthrow new RuntimeException(\"Trace already started\");\n\t\t}\n\t}\n\n\tpublic void resetTrace() {\n\t\ttrace = null;\n\t\tresetTx();\n\t}\n\n\tpublic RmiTransaction requireTx() {\n\t\tif (tx == null) {\n\t\t\tthrow new RuntimeException(\"No transaction\");\n\t\t}\n\t\treturn tx;\n\t}\n\n\tpublic void requireNoTx() {\n\t\tif (tx != null) {\n\t\t\tthrow new RuntimeException(\"Transaction already started\");","sourceCodeStart":73,"sourceCodeEnd":109,"githubUrl":"https://github.com/NationalSecurityAgency/ghidra/blob/d5f144c24d6bc53c9cbf4448c6d11143e7696206/Ghidra/Debug/Debugger-jpda/src/main/java/ghidra/dbg/jdi/rmi/jpda/JdiCommands.java#L73-L109","documentation":"RuntimeException('Trace already started') thrown by State.requireNoTrace() when trace is already non-null. It guards start-trace commands that require no existing trace. Unlike requireNoClient, it does not clear the field before throwing.","triggerScenarios":"Calling the start-trace command (or any command routing through requireNoTrace()) while State.trace is already set from a previous start that was not reset.","commonSituations":"Running start-trace twice; reconnecting/restarting a session without first resetting the trace; a script that re-enters its setup block.","solutions":["Reset the existing trace (resetTrace or the end-trace command) before starting a new one.","Check state.trace == null before starting; if non-null, reuse the existing trace.","Structure command sequences so start-trace is issued exactly once per session."],"exampleFix":"// before\n// start-trace issued again -> 'Trace already started'\n\n// after\nif (state.trace != null) {\n    state.resetTrace();\n}\nstartTrace(...);","handlingStrategy":"validation","validationCode":"if (state.trace != null) {\n    state.resetTrace();\n}\nstartTrace(...);","typeGuard":null,"tryCatchPattern":"try {\n    state.requireNoTrace();\n} catch (RuntimeException e) {\n    if (\"Trace already started\".equals(e.getMessage())) {\n        // reset trace, then start a new one\n    }\n}","preventionTips":["Issue start-trace exactly once per session.","Reset the existing trace before starting a new one.","Check state.trace == null before starting."],"tags":["ghidra","jdi","jpda","trace","state-machine","validation"],"backgroundTag":null,"analyzedSha":"d5f144c24d6bc53c9cbf4448c6d11143e7696206","analyzedAt":"2026-08-14T01:00:57.564Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}