Skip to content
This repository has been archived by the owner on Oct 1, 2023. It is now read-only.

Commit

Permalink
Fixed unstarted transaction error
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrew Strelsky committed Mar 12, 2022
1 parent 4463610 commit fa8a773
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@

import ghidra.app.cmd.data.TypeDescriptorModel;
import ghidra.app.cmd.data.rtti.*;
import ghidra.app.util.NamespaceUtils;

import cppclassanalyzer.data.manager.recordmanagers.ProgramRttiRecordManager;
import ghidra.program.model.address.Address;
import ghidra.program.model.data.InvalidDataTypeException;
Expand All @@ -16,6 +18,7 @@
import ghidra.util.datastruct.LongIntHashtable;
import ghidra.util.exception.AssertException;
import ghidra.util.exception.CancelledException;
import ghidra.util.exception.InvalidInputException;
import ghidra.util.task.TaskMonitor;

import cppclassanalyzer.database.record.ClassTypeInfoRecord;
Expand All @@ -31,7 +34,7 @@ public class VsClassTypeInfoDB extends AbstractClassTypeInfoDB implements VsClas

public VsClassTypeInfoDB(ProgramRttiRecordManager worker, ClassTypeInfoRecord record) {
super(worker, record);
this.gc = (GhidraClass) getTypeDescriptor().getDescriptorAsNamespace();
this.gc = doGetGhidraClass();
}

public VsClassTypeInfoDB(ProgramRttiRecordManager worker, VsClassTypeInfo type,
Expand All @@ -40,6 +43,23 @@ public VsClassTypeInfoDB(ProgramRttiRecordManager worker, VsClassTypeInfo type,
this.gc = type.getGhidraClass();
}

private GhidraClass doGetGhidraClass() {
int id = getProgram().startTransaction(getClass().getSimpleName()+": Getting GhidraClass");
boolean success = false;
try {
Namespace ns = getTypeDescriptor().getDescriptorAsNamespace();
if (!(ns instanceof GhidraClass)) {
ns = NamespaceUtils.convertNamespaceToClass(ns);
}
success = true;
return (GhidraClass) ns;
} catch (InvalidInputException e) {
throw new AssertException(e);
} finally {
getProgram().endTransaction(id, success);
}
}

private void fillRecord(ClassTypeInfoRecord record) {
ByteBuffer buf = ByteBuffer.allocate(getSize());
ClassTypeInfoRecord.setLongArray(buf, baseKeys);
Expand Down
1 change: 0 additions & 1 deletion src/main/java/cppclassanalyzer/scanner/RttiScanner.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
import ghidra.program.model.address.Address;
import ghidra.program.model.listing.Program;
import ghidra.util.classfinder.ClassSearcher;
import ghidra.util.exception.AssertException;
import ghidra.util.exception.CancelledException;
import ghidra.util.task.TaskMonitor;

Expand Down

0 comments on commit fa8a773

Please sign in to comment.