mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2025-10-06 03:50:02 +02:00
GP-4636: Use Debug Console for initial mapping failure.
This commit is contained in:
parent
35434613b8
commit
1db04f8c71
8 changed files with 435 additions and 58 deletions
|
@ -0,0 +1,54 @@
|
|||
/* ###
|
||||
* IP: GHIDRA
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package ghidra.debug.api.modules;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
import docking.DefaultActionContext;
|
||||
import ghidra.trace.model.modules.TraceModule;
|
||||
|
||||
public class DebuggerMissingModuleActionContext extends DefaultActionContext {
|
||||
private final TraceModule module;
|
||||
private final int hashCode;
|
||||
|
||||
public DebuggerMissingModuleActionContext(TraceModule module) {
|
||||
this.module = Objects.requireNonNull(module);
|
||||
this.hashCode = Objects.hash(getClass(), module);
|
||||
}
|
||||
|
||||
public TraceModule getModule() {
|
||||
return module;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return hashCode;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj) {
|
||||
return true;
|
||||
}
|
||||
if (!(obj instanceof DebuggerMissingModuleActionContext that)) {
|
||||
return false;
|
||||
}
|
||||
if (!this.module.equals(that.module)) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,98 @@
|
|||
/* ###
|
||||
* IP: GHIDRA
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package ghidra.debug.api.modules;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
import docking.DefaultActionContext;
|
||||
import ghidra.program.model.address.*;
|
||||
import ghidra.program.model.listing.InstructionIterator;
|
||||
import ghidra.program.model.listing.Program;
|
||||
import ghidra.trace.model.Trace;
|
||||
|
||||
public class DebuggerMissingProgramActionContext extends DefaultActionContext {
|
||||
|
||||
public static Address getMappingProbeAddress(Program program) {
|
||||
if (program == null) {
|
||||
return null;
|
||||
}
|
||||
AddressIterator eepi = program.getSymbolTable().getExternalEntryPointIterator();
|
||||
if (eepi.hasNext()) {
|
||||
return eepi.next();
|
||||
}
|
||||
InstructionIterator ii = program.getListing().getInstructions(true);
|
||||
if (ii.hasNext()) {
|
||||
return ii.next().getAddress();
|
||||
}
|
||||
AddressSetView es = program.getMemory().getExecuteSet();
|
||||
if (!es.isEmpty()) {
|
||||
return es.getMinAddress();
|
||||
}
|
||||
if (!program.getMemory().isEmpty()) {
|
||||
return program.getMinAddress();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private final Trace trace;
|
||||
private final Program program;
|
||||
private final int hashCode;
|
||||
|
||||
private Address probe;
|
||||
|
||||
public DebuggerMissingProgramActionContext(Trace trace, Program program) {
|
||||
this.trace = Objects.requireNonNull(trace);
|
||||
this.program = Objects.requireNonNull(program);
|
||||
this.hashCode = Objects.hash(getClass(), trace, program);
|
||||
}
|
||||
|
||||
public Trace getTrace() {
|
||||
return trace;
|
||||
}
|
||||
|
||||
public Program getProgram() {
|
||||
return program;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return hashCode;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj) {
|
||||
return true;
|
||||
}
|
||||
if (!(obj instanceof DebuggerMissingProgramActionContext that)) {
|
||||
return false;
|
||||
}
|
||||
if (!this.trace.equals(that.trace)) {
|
||||
return false;
|
||||
}
|
||||
if (!this.program.equals(that.program)) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public Address getMappingProbeAddress() {
|
||||
if (probe == null) {
|
||||
probe = getMappingProbeAddress(program);
|
||||
}
|
||||
return probe;
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue