mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2026-09-19 16:40:38 -09:00
GP-4093: Add "Module" column to "Stack" panel.
This commit is contained in:
@@ -40,17 +40,20 @@ public class ModuleRow {
|
||||
}
|
||||
}
|
||||
|
||||
public static String computeShortName(String path) {
|
||||
int sep = path.lastIndexOf('\\');
|
||||
if (sep > 0 && sep < path.length()) {
|
||||
path = path.substring(sep + 1);
|
||||
}
|
||||
sep = path.lastIndexOf('/');
|
||||
if (sep > 0 && sep < path.length()) {
|
||||
path = path.substring(sep + 1);
|
||||
}
|
||||
return path;
|
||||
}
|
||||
|
||||
public String getShortName() {
|
||||
String name = module.getName();
|
||||
int sep = name.lastIndexOf('\\');
|
||||
if (sep > 0 && sep < name.length()) {
|
||||
name = name.substring(sep + 1);
|
||||
}
|
||||
sep = name.lastIndexOf('/');
|
||||
if (sep > 0 && sep < name.length()) {
|
||||
name = name.substring(sep + 1);
|
||||
}
|
||||
return name;
|
||||
return computeShortName(module.getName());
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
|
||||
@@ -60,6 +60,7 @@ public class DebuggerLegacyStackPanel extends JPanel {
|
||||
LEVEL("Level", Integer.class, StackFrameRow::getFrameLevel),
|
||||
PC("PC", Address.class, StackFrameRow::getProgramCounter),
|
||||
FUNCTION("Function", ghidra.program.model.listing.Function.class, StackFrameRow::getFunction),
|
||||
MODULE("Module", String.class, StackFrameRow::getModule),
|
||||
COMMENT("Comment", String.class, StackFrameRow::getComment, StackFrameRow::setComment, StackFrameRow::isCommentable);
|
||||
|
||||
private final String header;
|
||||
@@ -292,6 +293,8 @@ public class DebuggerLegacyStackPanel extends JPanel {
|
||||
pcCol.setCellRenderer(boldCurrentRenderer);
|
||||
TableColumn funcCol = columnModel.getColumn(StackTableColumns.FUNCTION.ordinal());
|
||||
funcCol.setCellRenderer(boldCurrentRenderer);
|
||||
TableColumn modCol = columnModel.getColumn(StackTableColumns.MODULE.ordinal());
|
||||
modCol.setCellRenderer(boldCurrentRenderer);
|
||||
TableColumn commCol = columnModel.getColumn(StackTableColumns.COMMENT.ordinal());
|
||||
commCol.setCellRenderer(boldCurrentRenderer);
|
||||
}
|
||||
|
||||
@@ -40,6 +40,7 @@ import ghidra.framework.plugintool.annotation.AutoServiceConsumed;
|
||||
import ghidra.program.model.address.Address;
|
||||
import ghidra.program.model.listing.Function;
|
||||
import ghidra.trace.model.Trace;
|
||||
import ghidra.trace.model.modules.TraceModule;
|
||||
import ghidra.trace.model.stack.TraceObjectStackFrame;
|
||||
import ghidra.trace.model.target.TraceObject;
|
||||
import ghidra.trace.model.target.TraceObjectValue;
|
||||
@@ -83,7 +84,22 @@ public class DebuggerStackPanel extends AbstractObjectsTableBasedPanel<TraceObje
|
||||
ServiceProvider serviceProvider) throws IllegalArgumentException {
|
||||
TraceObjectValue value =
|
||||
rowObject.getAttributeEntry(TargetStackFrame.PC_ATTRIBUTE_NAME);
|
||||
return value == null ? null : provider.getFunction((Address) value.getValue());
|
||||
return value == null ? null : provider.getFunction(value.castValue());
|
||||
}
|
||||
}
|
||||
|
||||
private class FrameModuleColumn extends AbstractDynamicTableColumn<ValueRow, String, Trace> {
|
||||
@Override
|
||||
public String getColumnName() {
|
||||
return "Module";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getValue(ValueRow rowObject, Settings settings, Trace data,
|
||||
ServiceProvider serviceProvider) throws IllegalArgumentException {
|
||||
TraceObjectValue value =
|
||||
rowObject.getAttributeEntry(TargetStackFrame.PC_ATTRIBUTE_NAME);
|
||||
return value == null ? null : provider.getModule(value.castValue());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -98,6 +114,7 @@ public class DebuggerStackPanel extends AbstractObjectsTableBasedPanel<TraceObje
|
||||
descriptor.addVisibleColumn(new FrameLevelColumn(), 1, true);
|
||||
descriptor.addVisibleColumn(new FramePcColumn());
|
||||
descriptor.addVisibleColumn(new FrameFunctionColumn());
|
||||
descriptor.addVisibleColumn(new FrameModuleColumn());
|
||||
return descriptor;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,6 +30,7 @@ import docking.action.DockingAction;
|
||||
import docking.action.builder.ActionBuilder;
|
||||
import ghidra.app.plugin.core.debug.DebuggerPluginPackage;
|
||||
import ghidra.app.plugin.core.debug.gui.DebuggerResources;
|
||||
import ghidra.app.plugin.core.debug.gui.modules.ModuleRow;
|
||||
import ghidra.app.plugin.core.debug.stack.UnwindStackCommand;
|
||||
import ghidra.app.services.DebuggerStaticMappingService;
|
||||
import ghidra.debug.api.tracemgr.DebuggerCoordinates;
|
||||
@@ -39,6 +40,7 @@ import ghidra.program.model.address.Address;
|
||||
import ghidra.program.model.listing.Function;
|
||||
import ghidra.program.util.ProgramLocation;
|
||||
import ghidra.trace.model.*;
|
||||
import ghidra.trace.model.modules.TraceModule;
|
||||
import ghidra.trace.model.thread.TraceThread;
|
||||
import ghidra.util.HelpLocation;
|
||||
|
||||
@@ -210,4 +212,19 @@ public class DebuggerStackProvider extends ComponentProviderAdapter {
|
||||
}
|
||||
return sloc.getProgram().getFunctionManager().getFunctionContaining(sloc.getAddress());
|
||||
}
|
||||
|
||||
public String getModule(Address pc) {
|
||||
if (pc == null) {
|
||||
return null;
|
||||
}
|
||||
Trace trace = current.getTrace();
|
||||
if (trace == null) {
|
||||
return null;
|
||||
}
|
||||
for (TraceModule module : trace.getModuleManager().getModulesAt(current.getSnap(), pc)) {
|
||||
// Just take the first
|
||||
return ModuleRow.computeShortName(module.getName());
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -87,6 +87,10 @@ public class StackFrameRow {
|
||||
return panel.provider.getFunction(getProgramCounter());
|
||||
}
|
||||
|
||||
public String getModule() {
|
||||
return panel.provider.getModule(getProgramCounter());
|
||||
}
|
||||
|
||||
protected void update() {
|
||||
assert frame != null; // Should never update a synthetic stack
|
||||
level = frame.getLevel();
|
||||
|
||||
Reference in New Issue
Block a user