Class GhidraDBTransaction
- java.lang.Object
-
- ghidra.app.plugin.assembler.sleigh.util.GhidraDBTransaction
-
- All Implemented Interfaces:
java.lang.AutoCloseable
public class GhidraDBTransaction extends java.lang.Object implements java.lang.AutoCloseableA convenience context for transaction IDs on a Ghidra program database This is meant to be used idiomatically, as in a try-with-resources block:
This idiom is very useful if there is complex logic in your transaction, it's very easy to forget to close the transaction, especially if an error occurs, leaving the database in an open transaction indefinitely. Try try-with-resources block will ensure that the transaction is closed in all circumstances. Note, however, that in order for the transaction to be committed, you must calltry (GhidraDBTransaction t = new GhidraDBTransaction(program, "Demo")) { program.getMemory()..... t.commit(); }commit(). Any exceptions within the block will causet.commit()to be skipped, thus aborting the transaction.
-
-
Constructor Summary
Constructors Constructor Description GhidraDBTransaction(Program program, java.lang.String description)Start a transaction on the given program with the given description
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()Finish the transaction If this is called beforecommit(), then the transaction is aborted.voidcommit()Finish the transaction, and commit This MUST be called in order to commit the transaction.
-
-
-
Field Detail
-
program
protected Program program
-
tid
protected int tid
-
open
protected boolean open
-
-
Constructor Detail
-
GhidraDBTransaction
public GhidraDBTransaction(Program program, java.lang.String description)
Start a transaction on the given program with the given description- Parameters:
program- the program to modifydescription- a description of the transaction
-
-
Method Detail
-
close
public void close()
Finish the transaction If this is called beforecommit(), then the transaction is aborted. This is called automatically at the close of a try-with-resources block.- Specified by:
closein interfacejava.lang.AutoCloseable
-
commit
public void commit()
Finish the transaction, and commit This MUST be called in order to commit the transaction. The transaction is immediately closed, and any further modifications to the database will likely result in an error.
-
-