Files
tsuki 831d96e562 Initial public source release
Split reusable rendering and format support into vectorail-core and vectorail-gc.
2026-08-02 17:05:27 +02:00

39 lines
1.5 KiB
Java

// GhidraScript: print instructions around one or more addresses.
// Usage: DumpInstructions.java 0x001b184c 0x001b1870
import ghidra.app.script.GhidraScript;
import ghidra.program.model.listing.Function;
import ghidra.program.model.listing.Instruction;
public class DumpInstructions extends GhidraScript {
@Override
public void run() throws Exception {
String[] args = getScriptArgs();
if (args == null || args.length == 0) {
printerr("DumpInstructions: needs one or more addresses");
return;
}
for (String arg : args) {
Instruction center = getInstructionContaining(toAddr(Long.decode(arg)));
println("=== " + arg + " ===");
if (center == null) {
println("(no instruction)");
continue;
}
Instruction cursor = center;
for (int i = 0; i < 18; ++i) {
Instruction previous = cursor.getPrevious();
if (previous == null) break;
cursor = previous;
}
for (int i = 0; i < 40 && cursor != null; ++i) {
Function function = getFunctionContaining(cursor.getAddress());
String marker = cursor.getAddress().equals(center.getAddress()) ? "=>" : " ";
println(marker + " " + cursor.getAddress() + " " +
(function == null ? "" : function.getName() + " ") + cursor);
cursor = cursor.getNext();
}
}
}
}