Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/GP-1797_ghidra1_EliminateDatatyp…
Browse files Browse the repository at this point in the history
…eConflictException'
  • Loading branch information
ghidra1 committed May 16, 2022
2 parents 7f2ae7a + 01067de commit 0f3d941
Show file tree
Hide file tree
Showing 56 changed files with 169 additions and 362 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,8 @@
import ghidra.framework.plugintool.ComponentProviderAdapter;
import ghidra.framework.plugintool.annotation.AutoServiceConsumed;
import ghidra.program.model.address.*;
import ghidra.program.model.data.*;
import ghidra.program.model.data.DataType;
import ghidra.program.model.data.DataTypeEncodeException;
import ghidra.program.model.lang.*;
import ghidra.program.model.util.CodeUnitInsertionException;
import ghidra.trace.model.*;
Expand Down Expand Up @@ -840,7 +841,7 @@ void writeRegisterDataType(Register register, DataType dataType) {
}
tid.commit();
}
catch (CodeUnitInsertionException | DataTypeConflictException | CancelledException e) {
catch (CodeUnitInsertionException | CancelledException e) {
throw new AssertionError(e);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@
import ghidra.pcode.exec.trace.TraceSleighUtils;
import ghidra.program.model.address.*;
import ghidra.program.model.data.DataType;
import ghidra.program.model.data.DataTypeConflictException;
import ghidra.program.model.lang.Register;
import ghidra.program.model.listing.*;
import ghidra.program.model.util.CodeUnitInsertionException;
Expand Down Expand Up @@ -528,7 +527,7 @@ private void activatedApplyDataType(DebuggerWatchActionContext context) {
listing.clearCodeUnits(row.getAddress(), row.getRange().getMaxAddress(), false);
listing.createData(address, dataType, size);
}
catch (CodeUnitInsertionException | DataTypeConflictException e) {
catch (CodeUnitInsertionException e) {
errs.add(address + " " + dataType + "(" + size + "): " + e.getMessage());
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@
import ghidra.app.plugin.debug.MemoryUsagePlugin;
import ghidra.framework.plugintool.util.PluginException;
import ghidra.program.model.address.AddressOverflowException;
import ghidra.program.model.data.DataTypeConflictException;
import ghidra.program.model.data.Undefined4DataType;
import ghidra.program.model.lang.Language;
import ghidra.program.model.util.CodeUnitInsertionException;
Expand Down Expand Up @@ -78,7 +77,7 @@ public void tearDownManualTest() {
@Test
@Ignore
public void testManual01() throws PluginException, CodeUnitInsertionException,
DataTypeConflictException, AddressOverflowException, DuplicateNameException,
AddressOverflowException, DuplicateNameException,
TraceOverlappedRegionException, InterruptedException {
addPlugin(tool, DebuggerBreakpointMarkerPlugin.class);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
import ghidra.framework.options.Options;
import ghidra.program.model.address.*;
import ghidra.program.model.data.AlignmentDataType;
import ghidra.program.model.data.DataTypeConflictException;
import ghidra.program.model.listing.*;
import ghidra.program.model.mem.Memory;
import ghidra.program.model.mem.MemoryAccessException;
Expand Down Expand Up @@ -213,12 +212,6 @@ private void replaceFillerBytes(Listing listing, Address fillerAddress, int fill
"Unable to condense filler bytes (bad filler value?) at " + fillerAddress, e);
return;
}
catch (DataTypeConflictException e) {
// shouldn't happen if we have true filler bytes
Msg.error(this,
"Unable to condense filler bytes (bad filler value?) at " + fillerAddress, e);
return;
}
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@
import ghidra.framework.cmd.BackgroundCommand;
import ghidra.framework.model.DomainObject;
import ghidra.program.model.address.*;
import ghidra.program.model.data.*;
import ghidra.program.model.data.DataType;
import ghidra.program.model.data.DataUtilities;
import ghidra.program.model.listing.*;
import ghidra.program.model.util.CodeUnitInsertionException;
import ghidra.util.Swing;
Expand Down Expand Up @@ -126,8 +127,7 @@ public boolean doApplyTo(DomainObject obj, TaskMonitor monitor) {
}

private void createData(Address start, Address end, DataType dataType, Program p,
TaskMonitor monitor)
throws AddressOverflowException, CodeUnitInsertionException, DataTypeConflictException {
TaskMonitor monitor) throws AddressOverflowException, CodeUnitInsertionException {

Listing listing = p.getListing();
listing.clearCodeUnits(start, end, false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -459,9 +459,6 @@ public final void createData(Program program, Address address, int size) {
catch (CodeUnitInsertionException e) {
// don't care; we tried
}
catch (DataTypeConflictException e) {
// don't care; we tried
}
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@
import ghidra.app.util.importer.MessageLog;
import ghidra.app.util.opinion.PefLoader;
import ghidra.program.model.address.*;
import ghidra.program.model.data.*;
import ghidra.program.model.data.DataType;
import ghidra.program.model.data.DataUtilities;
import ghidra.program.model.data.DataUtilities.ClearDataMode;
import ghidra.program.model.listing.*;
import ghidra.program.model.mem.Memory;
Expand Down Expand Up @@ -69,8 +70,8 @@ public boolean added(Program program, AddressSetView functionSet, TaskMonitor mo
}

private void applyStructure(Program program, Address address) throws MemoryAccessException,
AddressOutOfBoundsException, CodeUnitInsertionException, DataTypeConflictException,
DuplicateNameException, InvalidInputException, CircularDependencyException {
AddressOutOfBoundsException, CodeUnitInsertionException, DuplicateNameException,
InvalidInputException, CircularDependencyException {

Listing listing = program.getListing();
Memory memory = program.getMemory();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@
import ghidra.framework.plugintool.Plugin;
import ghidra.program.database.util.ProgramTransaction;
import ghidra.program.model.address.*;
import ghidra.program.model.data.*;
import ghidra.program.model.data.DataType;
import ghidra.program.model.data.DataTypeEncodeException;
import ghidra.program.model.listing.*;
import ghidra.program.model.mem.MemoryAccessException;
import ghidra.program.model.util.CodeUnitInsertionException;
Expand Down Expand Up @@ -146,7 +147,7 @@ public void accept() {
catch (MemoryAccessException e) {
Msg.showError(this, null, "Patch Failure", e.getMessage(), e);
}
catch (CodeUnitInsertionException | DataTypeConflictException e) {
catch (CodeUnitInsertionException e) {
throw new AssertionError(); // Should have been cleared first
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -527,12 +527,10 @@ public DataTypeComponent insert(int rowIndex, DataType dt) throws UsrException {
*
* @throws InvalidDataTypeException if the structure being edited is part
* of the data type being inserted or if inserting isn't allowed.
* @throws DataTypeConflictException if creating the data type or one of
* its sub-parts conflicted with an existing data type.
*/
@Override
public DataTypeComponent insert(int rowIndex, DataType datatype, int length)
throws UsrException {
throws InvalidDataTypeException, UsrException {

if (isEditingField()) {
endFieldEditing();
Expand Down Expand Up @@ -999,8 +997,7 @@ public void duplicateMultiple(int rowIndex, int multiple, TaskMonitor monitor)
public abstract void clearComponents(int[] rows) throws UsrException;

@Override
protected void createArray(int numElements)
throws InvalidDataTypeException, DataTypeConflictException, UsrException {
protected void createArray(int numElements) throws InvalidDataTypeException, UsrException {
if (selection.getNumRanges() != 1) {
throw new UsrException("Can only create arrays on a contiguous selection.");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -509,8 +509,7 @@ else if (isContiguousComponentSelection()) {
}
}

protected void createArray(int numElements)
throws InvalidDataTypeException, DataTypeConflictException, UsrException {
protected void createArray(int numElements) throws InvalidDataTypeException, UsrException {
if (selection.getNumRanges() != 1) {
throw new UsrException("Can only create arrays on a contiguous selection.");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1091,7 +1091,7 @@ public boolean isShowingUndefinedBytes() {
}

public void createInternalStructure(TaskMonitor monitor)
throws InvalidDataTypeException, DataTypeConflictException, UsrException {
throws InvalidDataTypeException, UsrException {

if (selection.getNumRanges() != 1) {
throw new UsrException("Can only create structure on a contiguous selection.");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -187,8 +187,7 @@ public void clearSelectedComponents() throws UsrException {
}

@Override
protected void createArray(int numElements)
throws InvalidDataTypeException, DataTypeConflictException, UsrException {
protected void createArray(int numElements) throws InvalidDataTypeException, UsrException {
if (getNumSelectedComponentRows() != 1) {
throw new UsrException("Select an individual component to create an array.");
}
Expand Down Expand Up @@ -362,11 +361,10 @@ protected int getNumBytesInRange(FieldRange range) {
*
* @throws InvalidDataTypeException if the union being edited is part
* of the data type being inserted or if inserting isn't allowed.
* @throws DataTypeConflictException if creating the data type or one of
* its sub-parts conflicted with an existing data type.
*/
@Override
public DataTypeComponent insert(int rowIndex, DataType dt, int dtLength) throws UsrException {
public DataTypeComponent insert(int rowIndex, DataType dt, int dtLength)
throws InvalidDataTypeException, UsrException {
if (dt.equals(DataType.DEFAULT)) {
throw new InvalidDataTypeException(
"Inserting undefined bytes is not allowed in a union.");
Expand Down
Loading

0 comments on commit 0f3d941

Please sign in to comment.