From 108ea044cc777cddbaa59cb57d66eb63f509706b Mon Sep 17 00:00:00 2001 From: Dan <46821332+nsadeveloper789@users.noreply.github.com> Date: Tue, 23 Nov 2021 10:50:16 -0500 Subject: [PATCH] GP-1231: Added 'Map by Regions' action to Debugger. --- .../impl/GdbModelTargetMemoryRegion.java | 4 +- Ghidra/Debug/Debugger/certification.manifest | 1 + .../Debugger/ghidra_scripts/AddMapping.java | 14 +- .../topics/DebuggerBots/DebuggerBots.html | 10 + .../DebuggerRegionsPlugin.html | 35 + .../DebuggerRegionMapProposalDialog.png | Bin 0 -> 22302 bytes .../images/DebuggerRegionsPlugin.png | Bin 19430 -> 20302 bytes .../AbstractDebuggerMapProposalDialog.java | 12 +- .../DebuggerBlockChooserDialog.java | 44 +- .../core/debug/gui/DebuggerResources.java | 54 +- .../DebuggerRegionMapProposalDialog.java | 164 +++++ .../gui/memory/DebuggerRegionsPlugin.java | 51 +- .../gui/memory/DebuggerRegionsProvider.java | 178 ++++- .../gui/modules/DebuggerAddMappingDialog.java | 5 +- .../DebuggerModuleMapProposalDialog.java | 9 +- .../gui/modules/DebuggerModulesPlugin.java | 35 +- .../gui/modules/DebuggerModulesProvider.java | 22 +- .../DebuggerSectionMapProposalDialog.java | 9 +- .../service/modules/AbstractMapEntry.java | 99 +++ .../service/modules/AbstractMapProposal.java | 145 ++++ .../DebuggerStaticMappingProposals.java | 287 ++++++++ .../DebuggerStaticMappingServicePlugin.java | 649 +++--------------- .../modules/DebuggerStaticMappingUtils.java | 285 ++++++-- .../modules/DefaultModuleMapProposal.java | 233 +++++++ .../modules/DefaultRegionMapProposal.java | 192 ++++++ .../modules/DefaultSectionMapProposal.java | 178 +++++ .../modules/MapModulesBackgroundCommand.java | 2 +- .../modules/MapRegionsBackgroundCommand.java | 48 ++ .../modules/MapSectionsBackgroundCommand.java | 2 +- .../service/modules/ModuleRegionMatcher.java | 38 + .../workflow/AbstractMapDebuggerBot.java | 180 +++++ .../debug/workflow/MapModulesDebuggerBot.java | 200 +----- .../debug/workflow/MapRegionsDebuggerBot.java | 57 ++ .../workflow/MapSectionsDebuggerBot.java | 176 +---- .../DebuggerStaticMappingService.java | 558 +++------------ .../java/ghidra/app/services/MapEntry.java | 46 ++ .../java/ghidra/app/services/MapProposal.java | 107 +++ .../app/services/ModuleMapProposal.java | 62 ++ .../app/services/RegionMapProposal.java | 52 ++ .../app/services/SectionMapProposal.java | 75 ++ .../DebuggerRegionsPluginScreenShots.java | 122 +++- .../DebuggerModulesPluginScreenShots.java | 24 +- ...ebuggerStaticMappingPluginScreenShots.java | 8 +- .../memory/DebuggerRegionsProviderTest.java | 127 +++- .../modules/DebuggerModulesProviderTest.java | 36 +- .../DebuggerStaticMappingServiceTest.java | 25 + 46 files changed, 3091 insertions(+), 1569 deletions(-) create mode 100644 Ghidra/Debug/Debugger/src/main/help/help/topics/DebuggerRegionsPlugin/images/DebuggerRegionMapProposalDialog.png rename Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/gui/{modules => }/AbstractDebuggerMapProposalDialog.java (92%) rename Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/gui/{modules => }/DebuggerBlockChooserDialog.java (82%) create mode 100644 Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/gui/memory/DebuggerRegionMapProposalDialog.java create mode 100644 Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/service/modules/AbstractMapEntry.java create mode 100644 Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/service/modules/AbstractMapProposal.java create mode 100644 Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/service/modules/DebuggerStaticMappingProposals.java create mode 100644 Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/service/modules/DefaultModuleMapProposal.java create mode 100644 Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/service/modules/DefaultRegionMapProposal.java create mode 100644 Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/service/modules/DefaultSectionMapProposal.java create mode 100644 Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/service/modules/MapRegionsBackgroundCommand.java create mode 100644 Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/service/modules/ModuleRegionMatcher.java create mode 100644 Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/workflow/AbstractMapDebuggerBot.java create mode 100644 Ghidra/Debug/Debugger/src/main/java/ghidra/app/plugin/core/debug/workflow/MapRegionsDebuggerBot.java create mode 100644 Ghidra/Debug/Debugger/src/main/java/ghidra/app/services/MapEntry.java create mode 100644 Ghidra/Debug/Debugger/src/main/java/ghidra/app/services/MapProposal.java create mode 100644 Ghidra/Debug/Debugger/src/main/java/ghidra/app/services/ModuleMapProposal.java create mode 100644 Ghidra/Debug/Debugger/src/main/java/ghidra/app/services/RegionMapProposal.java create mode 100644 Ghidra/Debug/Debugger/src/main/java/ghidra/app/services/SectionMapProposal.java diff --git a/Ghidra/Debug/Debugger-agent-gdb/src/main/java/agent/gdb/model/impl/GdbModelTargetMemoryRegion.java b/Ghidra/Debug/Debugger-agent-gdb/src/main/java/agent/gdb/model/impl/GdbModelTargetMemoryRegion.java index 843b0869e3..ae56376ed5 100644 --- a/Ghidra/Debug/Debugger-agent-gdb/src/main/java/agent/gdb/model/impl/GdbModelTargetMemoryRegion.java +++ b/Ghidra/Debug/Debugger-agent-gdb/src/main/java/agent/gdb/model/impl/GdbModelTargetMemoryRegion.java @@ -52,9 +52,9 @@ public class GdbModelTargetMemoryRegion protected static String computeDisplay(GdbMemoryMapping mapping) { // NOTE: This deviates from GDB's table display, as it'd be confusing in isolation if (mapping.getObjfile() == null || mapping.getObjfile().length() == 0) { - return String.format("?? [0x%x-0x%x]", mapping.getStart(), mapping.getEnd()); + return String.format("?? (0x%x-0x%x)", mapping.getStart(), mapping.getEnd()); } - return String.format("%s [0x%x-0x%x] (0x%x)", mapping.getObjfile(), mapping.getStart(), + return String.format("%s (0x%x-0x%x,0x%x)", mapping.getObjfile(), mapping.getStart(), mapping.getEnd(), mapping.getOffset()); } diff --git a/Ghidra/Debug/Debugger/certification.manifest b/Ghidra/Debug/Debugger/certification.manifest index 2b87be0f13..197b22ac1d 100644 --- a/Ghidra/Debug/Debugger/certification.manifest +++ b/Ghidra/Debug/Debugger/certification.manifest @@ -95,6 +95,7 @@ src/main/help/help/topics/DebuggerObjectsPlugin/images/stop.png||GHIDRA||||END| src/main/help/help/topics/DebuggerPcodeStepperPlugin/DebuggerPcodeStepperPlugin.html||GHIDRA||||END| src/main/help/help/topics/DebuggerPcodeStepperPlugin/images/DebuggerPcodeStepperPlugin.png||GHIDRA||||END| src/main/help/help/topics/DebuggerRegionsPlugin/DebuggerRegionsPlugin.html||GHIDRA||||END| +src/main/help/help/topics/DebuggerRegionsPlugin/images/DebuggerRegionMapProposalDialog.png||GHIDRA||||END| src/main/help/help/topics/DebuggerRegionsPlugin/images/DebuggerRegionsPlugin.png||GHIDRA||||END| src/main/help/help/topics/DebuggerRegistersPlugin/DebuggerRegistersPlugin.html||GHIDRA||||END| src/main/help/help/topics/DebuggerRegistersPlugin/images/DebuggerAvailableRegistersDialog.png||GHIDRA||||END| diff --git a/Ghidra/Debug/Debugger/ghidra_scripts/AddMapping.java b/Ghidra/Debug/Debugger/ghidra_scripts/AddMapping.java index ce98c0ee31..1831dcd77c 100644 --- a/Ghidra/Debug/Debugger/ghidra_scripts/AddMapping.java +++ b/Ghidra/Debug/Debugger/ghidra_scripts/AddMapping.java @@ -22,7 +22,6 @@ import ghidra.program.model.address.AddressSpace; import ghidra.program.util.ProgramLocation; import ghidra.trace.model.DefaultTraceLocation; import ghidra.trace.model.Trace; -import ghidra.util.database.UndoableTransaction; public class AddMapping extends GhidraScript { @Override @@ -35,13 +34,10 @@ public class AddMapping extends GhidraScript { AddressSpace dynRam = currentTrace.getBaseAddressFactory().getDefaultAddressSpace(); AddressSpace statRam = currentProgram.getAddressFactory().getDefaultAddressSpace(); - try (UndoableTransaction tid = - UndoableTransaction.start(currentTrace, "Add Mapping", true)) { - mappings.addMapping( - new DefaultTraceLocation(currentTrace, null, Range.atLeast(0L), - dynRam.getAddress(0x00400000)), - new ProgramLocation(currentProgram, statRam.getAddress(0x00400000)), - 0x10000, false); - } + mappings.addMapping( + new DefaultTraceLocation(currentTrace, null, Range.atLeast(0L), + dynRam.getAddress(0x00400000)), + new ProgramLocation(currentProgram, statRam.getAddress(0x00400000)), + 0x10000, false); } } diff --git a/Ghidra/Debug/Debugger/src/main/help/help/topics/DebuggerBots/DebuggerBots.html b/Ghidra/Debug/Debugger/src/main/help/help/topics/DebuggerBots/DebuggerBots.html index c7e4d3751b..c4ef1ef1be 100644 --- a/Ghidra/Debug/Debugger/src/main/help/help/topics/DebuggerBots/DebuggerBots.html +++ b/Ghidra/Debug/Debugger/src/main/help/help/topics/DebuggerBots/DebuggerBots.html @@ -59,5 +59,15 @@ performed manually using the Map Sections action in the Modules and Sections window.
+ +This bot automatically maps trace regions to memory blocks of programs opened in the same + tool. Its operation is analogous to that of the Map Modules Bot, except that it creates the + mapped ranges by region. It is not commonly used, as it's less efficient than the Map Modules + Bot, but it is required whenever a target fails to present modules. This action can be + performed manually using the Map Regions + action in the Regions window.