Re: [DynInst_API:] Type conflict building parseAPI example


Date: Tue, 5 Feb 2013 14:14:40 +0000
From: "E.Robbins" <er209@xxxxxxxxxx>
Subject: Re: [DynInst_API:] Type conflict building parseAPI example
Hi again,
I added a couple of lines to your example and now it groups nodes from the same function into clusters and labels function nodes with the name of the function... makes it a bit clearer what is going on. Give it a try! I've attached it.

BTW, I commented out the deletes at the end because one of them causes a crash, at least on my system.

Cheers,
Ed
________________________________________
From: Andrew Bernat [bernat@xxxxxxxxxxx]
Sent: 30 January 2013 17:49
To: E.Robbins
Cc: dyninst-api@xxxxxxxxxxx
Subject: Re: [DynInst_API:] Type conflict building parseAPI example

That mistake is on our end. Change it to a Function::blocklist::const_iterator (instead of Function::blocklist::iterator). Or, more easily, use auto. I'll get the documentation updated.

Drew

On Jan 30, 2013, at 10:20 AM, "E.Robbins" <er209@xxxxxxxxxx<mailto:er209@xxxxxxxxxx>> wrote:

Hi there,
I tried to build the simple example from page 3/4 of the parseAPI manual, but it fails with

error: conversion from ‘std::vector<Dyninst::ParseAPI::Edge*>::const_iterator {aka __gnu_cxx::__normal_iterator<Dyninst::ParseAPI::Edge* const*, std::vector<Dyninst::ParseAPI::Edge*> >}’ to non-scalar type ‘std::vector<Dyninst::ParseAPI::Edge*>::iterator {aka __gnu_cxx::__normal_iterator<Dyninst::ParseAPI::Edge**, std::vector<Dyninst::ParseAPI::Edge*> >}’ requested

referring to line 37 of the code listing.

I am building with gcc 4.7.2 on Ubuntu Linux amd64. To build I am using:

g++ -std=c++11 -I/usr/include/boost -g -o recoverCFG recoverCFG.cpp -lparseAPI -lsymtabAPI -linstructionAPI -lcommon -ldynDwarf -ldynElf -ldwarf -lelf -lsymLite

Though I also get the same results using -std=c++0x or when omitting the -std option altogether.

I tried using the pre-built binaries available on the website but then when that failed I checked out the git version, built and tested against that but with the same results.

Am I missing something simple? Can anyone help?

Thanks,
Ed
_______________________________________________
Dyninst-api mailing list
Dyninst-api@xxxxxxxxxxx<mailto:Dyninst-api@xxxxxxxxxxx>
https://lists.cs.wisc.edu/mailman/listinfo/dyninst-api

--
Andrew Bernat
Paradyn Project
bernat@xxxxxxxxxxx<mailto:bernat@xxxxxxxxxxx>
http://www.cs.wisc.edu/~bernat




#include <stdio.h>
#include <map>
#include "CodeObject.h"
#include "CFG.h"

using namespace std;
using namespace Dyninst;
using namespace ParseAPI;

int main(int argc, char * argv[])
{
	map<Address, bool> seen;
	vector<Function *> funcs;
	SymtabCodeSource *sts;
	CodeObject *co;

	// Create a new binary code object from the filename argument
	sts = new SymtabCodeSource( argv[1] );
	co = new CodeObject( sts );

	// Parse the binary
	co->parse();
	printf("digraph G {\n");

	// Print the control flow graph
	CodeObject::funclist all = co->funcs();
	CodeObject::funclist::iterator fit = all.begin();
	for( ; fit != all.end(); ++fit) {
		Function *f = *fit;

		printf("\t subgraph cluster_%s {label=\"%s\";\n\t\tcolour=blue;\n", f->name().c_str(), f->name().c_str());
		if(f->retstatus() == NORETURN)
			printf("\t\t\"%lx\" [shape=box,color=red]\n",f->addr());
		else
			printf("\t\t\"%lx\" [shape=box]\n",f->addr());
		printf("\t\t\"%lx\" [label=\"%s\"];\n", f->addr(), f->name().c_str());

		Function::blocklist::const_iterator bit = f->blocks().begin();
		for( ; bit != f->blocks().end(); ++bit) {
			Block *b = *bit;
			// Donâ??t revisit blocks in shared code
			if(seen.find(b->start()) != seen.end())
				continue;

			seen[b->start()] = true;

			Block::edgelist::const_iterator it = b->targets().begin();
			for( ; it != b->targets().end(); ++it) {
				char * s = "";
				if((*it)->type() == CALL)
					s = " [color=blue]";
				else if((*it)->type() == RET)
					s = " [color=green]";
				printf("\t\t\t\"%lx\" -> \"%lx\"%s\n", (*it)->src()->start(), (*it)->trg()->start(),s);
			}
		}
		printf("\t}");

	}

	printf("}\n");
	//delete co;
	//delete sts;
}
[← Prev in Thread] Current Thread [Next in Thread→]