Hi Shuai,
BPatch_entry represents the entry of a function. You should use
BPatch_locBasicBlockEntry instead of BPatch_entry.
Or, you can try "BPatch_point* BPatch_basicBlock::findEntryPoint()".
Thanks
--Xiaozhu
On Sat, Aug 22, 2015 at 9:06 PM, Shuai Wang <wangshuai901@xxxxxxxxx> wrote:
> Dear list,
>
>
> I am a newbie to DynInst, and I am trying to instrument every basic blocks
> of a given elf binary. For example, to insert a basic block counter at the
> beginning of each basic block.
>
> I installed DynInst 8.2.1, and modified the example in DynInstAPI's appendix
> A, some code snippet like this:
>
>
> .....
>
> BPatch_point *entryPointBB(BPatch_basicBlock *bb) {
> BPatch_point *points;
> points = bb->findPoint(BPatch_entry);
>
> return points;
> }
>
> void binaryAnalysis(BPatch_addressSpace *app) {
> BPatch_image *appImage = app->getImage();
> int insns_access_memory = 0;
> std::vector<BPatch_function *> funcs;
> appImage->findFunction("main", funcs);
>
> BPatch_flowGraph *fg = funcs[0]->getCFG();
> std::set<BPatch_basicBlock *> blocks;
> fg->getAllBasicBlocks(blocks);
>
> std::set<BPatch_basicBlock *>::iterator block_iter;
> for (block_iter = blocks.begin(); block_iter != blocks.end();
> ++block_iter)
> {
> BPatch_basicBlock *block = *block_iter;
>
> BPatch_point * ps = entryPointBB(block);
>
> //patchBB(app, ps);
> printf("%p\n", ps); <------------------- (nil)
> }
> }
> ....
>
> However, after the compilation, when I tried to execute the code, I find
> that BPatch_point ps does not get any value. As a result, the last printf
> statement print out a nil for this empty pointer..
>
>
> Here is my question: Am I missed anything? What should I do if I want to
> instrument every basic block at its front?
>
> I really appreciate if anyone can give me some help. Thank you a lot!
>
> Sincerely,
> Shuai
>
>
>
>
> _______________________________________________
> Dyninst-api mailing list
> Dyninst-api@xxxxxxxxxxx
> https://lists.cs.wisc.edu/mailman/listinfo/dyninst-api
>
|