I want to get the basic block in Function graph by containing address,and then get the start address and end address of it.How to get it?
See #92, #444, #613.
Thanks, @saruman9. Did you get what you needed from that @Kingkingyoung?
Thanks, @saruman9. Did you get what you needed from that @Kingkingyoung?
Not yet,Code Block or Code unit is not what I want.I want to get a vertex(in function graph view) start/end address by a containg address.I found getBasicBlocks() in ghidra.program.model.pcode.PcodeSyntaxTree and the class PcodeBlockBasic seems has start/end address.But I have not find how to get it properly.And I also found ghidra.app.plugin.core.functiongraph in source code,but I can't find it in doc. And I'm trying to figure it out.But I'm not sure it is the correct way.
e.g I want to get address 8e48 and 8e59 by any address in this block
from ghidra.program.model.block import BasicBlockModel
basicBlockModel = BasicBlockModel(currentProgram)
codeBlocks = basicBlockModel.getCodeBlocksContaining(currentAddress, monitor)
listing = currentProgram.getListing()
for codeBlock in codeBlocks:
print listing.getCodeUnitContaining(codeBlock.getMinAddress()).getAddress(), listing.getCodeUnitContaining(codeBlock.getMaxAddress()).getAddress()
from ghidra.program.model.block import BasicBlockModel basicBlockModel = BasicBlockModel(currentProgram) codeBlocks = basicBlockModel.getCodeBlocksContaining(currentAddress, monitor) listing = currentProgram.getListing() for codeBlock in codeBlocks: print listing.getCodeUnitContaining(codeBlock.getMinAddress()).getAddress(), listing.getCodeUnitContaining(codeBlock.getMaxAddress()).getAddress()
Thanks! This is exactly what I want.Thanks again!
from ghidra.program.model.block import BasicBlockModel basicBlockModel = BasicBlockModel(currentProgram) codeBlocks = basicBlockModel.getCodeBlocksContaining(currentAddress, monitor) listing = currentProgram.getListing() for codeBlock in codeBlocks: print listing.getCodeUnitContaining(codeBlock.getMinAddress()).getAddress(), listing.getCodeUnitContaining(codeBlock.getMaxAddress()).getAddress()
And I will close this issue.
Thanks @saruman9!
Most helpful comment