Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dyninst-10.0.0 boost::shared_ptr<Dyninst::InstructionAPI::Instruction> instead of Dyninst::InstructionAPI::Instruction #505

Closed
vysocky opened this issue Nov 28, 2018 · 2 comments

Comments

@vysocky
Copy link

vysocky commented Nov 28, 2018

Example from dyninstAPI.pdf page 5 shows how to count number of instructions per basic block:

size_t inst_cnt = 0;
for (auto block_iter = blocks.begin(); block_iter != blocks.end(); ++block_iter)
{
	BPatch_basicBlock* block = *block_iter;
	std::vector<Dyninst::InstructionAPI::Instruction::Ptr> insns;
	block->getInstructions(insns);
	inst_cnt += insns.size();
}

Under Dyninst-9.3.2 it works perfectly, however under Dyninst-10.0.0 declaration of std::vector<Dyninst::InstructionAPI::Instruction::Ptr> insns creates std::vector<boost::shared_ptr<Dyninst::InstructionAPI::Instruction>> which is not compatible with implementations of BPatch_basicBlock::getInstructions(...):

dinst_instrument.cpp:391:34: error: no matching function for call to ‘BPatch_basicBlock::getInstructions(std::vector<boost::shared_ptr<Dyninst::InstructionAPI::Instruction> >&)’
      block->getInstructions(insns);
                                  ^
dinst_instrument.cpp:391:34: note: candidates are:
In file included from /home/vys0053/Software/Dyninst-10.0.0/dyninstAPI/h/BPatch_flowGraph.h:40:0,
                 from dinst_instrument.cpp:17:
/home/vys0053/Software/Dyninst-10.0.0/dyninstAPI/h/BPatch_basicBlock.h:296:9: note: bool BPatch_basicBlock::getInstructions(std::vector<Dyninst::InstructionAPI::Instruction>&)
   bool  getInstructions(std::vector<Dyninst::InstructionAPI::Instruction>& insns);
         ^
/home/vys0053/Software/Dyninst-10.0.0/dyninstAPI/h/BPatch_basicBlock.h:296:9: note:   no known conversion for argument 1 from ‘std::vector<boost::shared_ptr<Dyninst::InstructionAPI::Instruction> >’ to ‘std::vector<Dyninst::InstructionAPI::Instruction>&’
/home/vys0053/Software/Dyninst-10.0.0/dyninstAPI/h/BPatch_basicBlock.h:297:9: note: bool BPatch_basicBlock::getInstructions(std::vector<std::pair<Dyninst::InstructionAPI::Instruction, long unsigned int> >&)
   bool  getInstructions(std::vector<std::pair<Dyninst::InstructionAPI::Instruction, Dyninst::Address> >& insnInstances);
         ^
/home/vys0053/Software/Dyninst-10.0.0/dyninstAPI/h/BPatch_basicBlock.h:297:9: note:   no known conversion for argument 1 from ‘std::vector<boost::shared_ptr<Dyninst::InstructionAPI::Instruction> >’ to ‘std::vector<std::pair<Dyninst::InstructionAPI::Instruction, long unsigned int> >&’

I am not very familiar with boost, so I don't know where the boost::shared_ptr comes from. Do you have an idea what is wrong?

@mxz297
Copy link
Member

mxz297 commented Nov 28, 2018

Basically, in Dyninst 10.0, Instruction::Ptr is replaced with Instruction. So, change the line:

std::vector<Dyninst::InstructionAPI::Instruction::Ptr> insns;

to

std::vector<Dyninst::InstructionAPI::Instruction> insns;

We will update the manual accordingly.

@vysocky
Copy link
Author

vysocky commented Nov 29, 2018

Thanks, it helps

@mxz297 mxz297 closed this as completed Feb 8, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants