Example #1
0
void add_nodes(node_names_t& nodes, node_names_t& deps, const std::string field_name)
{
    dot.printf("/* Field: %s */\n", field_name.c_str());
    for(node_names_t::const_iterator it(nodes.begin()); it != nodes.end(); ++it) {
        if(manager.field_is_defined(it->f_filename, field_name)) {
            wpkg_dependencies::dependencies depends(manager.get_dependencies(it->f_filename, field_name));
            for(int i(0); i < depends.size(); ++i) {
                const wpkg_dependencies::dependencies::dependency_t& dep(depends.get_dependency(i));
                node_names_t packages(find_nodes(nodes, dep.f_name));
                if(packages.empty()) {
                    packages = find_nodes(deps, dep.f_name);
                    if(packages.empty()) {
                        // it's not defined yet, add it as a dependency
                        package_info_t info;
                        info.f_package = dep.f_name;
                        info.f_filename = dep.f_name;
                        info.f_nodecount = node_count;
                        deps.push_back(info);
                        dot.printf("n%d [label=\"%s\",shape=ellipse];\n", node_count, dep.f_name.c_str());
                        ++node_count;
                        packages = find_nodes(deps, dep.f_name);
                    }
                }
                if(dep.f_operator == wpkg_dependencies::dependencies::operator_any) {
                    // if any operator, then version doesn't apply,
                    // put an empty string instead
                    dot.printf("edge [headlabel=\"\"];\n");
                }
                else {
                    std::string op(dep.operator_to_string());
                    if(op.length() == 0) {
                        op = "=";
                    }
                    std::string version(op + " " + dep.f_version);
                    dot.printf("edge [headlabel=\"\\rversion %s\"];\n", version.c_str());
                }
                for(node_names_t::const_iterator pt(packages.begin()); pt != packages.end(); ++pt) {
                    dot.printf("n%d -> n%d;\n", it->f_nodecount, pt->f_nodecount);
                }
            }
        }
    }
}
Example #2
0
QVariant TestItem::data(int role) const
{
  switch(role) {
  case DurationRole:
      return duration();
  case ChecksumRole:
    return checksum();
  case DependsRole:
    return depends();
  case TestNameRole:
    return testname();
  case RequiresRole:
    return requires();
  case DescriptionRole:
      return description();

  case CommandRole:
      return command();
  case EnvironRole:
      return environ();
  case PluginRole:
      return plugin();
  case TypeRole:
      return type();
  case UserRole:
      return user();
  case ViaRole:
      return via();

  case GroupRole:
      return group();
  case CheckRole:
      return check();
  case ObjectPathRole:
      return objectpath();
  case RunstatusRole:
      return runstatus();
  case ElapsedtimeRole:
      return elapsedtime();
  case GroupstatusRole:
      return groupstatus();

  case ParentNameRole:
      break;

  case ParentIdRole:
    break;

  case DepthRole:
      return depth();

  case BranchRole:
      return branch();

  case RerunRole:
      return rerun();

  default:
    return QVariant();
  }

  // Prevents non-void return warning from the compiler
  return QVariant();
}
Example #3
0
bool Expr::depends(const Symbol& s) const
{
  std::set<Symbol> symbols;
  symbols.insert(s);
  return depends(symbols);
}
Example #4
0
		void depends(InputIterator begin, InputIterator end)
		{
			for (; begin != end; ++begin)
				depends(*begin);
		}
Example #5
0
 static bool depends(const exprt &expr, const string_sett &dependencies)
 {
     string_sett tmp;
     get_symbols(expr, tmp);
     return depends(tmp, dependencies);
 }
Example #6
0
void path_slicert::do_step(
    const abstract_functionst &abstract_functions,
    string_sett &dependencies,
    abstract_stept &step)
{
    if(!step.has_pc) return;

    // get abstract statement
    const abstract_programt::instructiont &a_instruction=
        *step.pc;

    // get concrete statement
    const goto_programt::instructiont &c_instruction=
        *a_instruction.code.concrete_pc;

    if(c_instruction.is_assign())
    {
        assert(c_instruction.code.operands().size()==2);

        const exprt &lhs=c_instruction.code.op0();
        const exprt &rhs=c_instruction.code.op1();

        if(depends_lhs(lhs, dependencies))
            add_dependencies(rhs, dependencies);
        else
            step.relevant=false;
    }
    else if(c_instruction.is_other())
    {
        const irep_idt &statement=
            c_instruction.code.get_statement();

        // check if it's an assignment
        if(statement=="init")
        {
            assert(c_instruction.code.operands().size()==2);

            const exprt &lhs=c_instruction.code.op0();
            const exprt &rhs=c_instruction.code.op1();

            if(depends_lhs(lhs, dependencies))
                add_dependencies(rhs, dependencies);
            else
                step.relevant=false;
        }
        else if(statement==ID_assign)
        {
            // shouldn't be here
            assert(false);
        }
        else if(statement==ID_expression)
        {
            // these don't do anything
            step.relevant=false;
        }
        else if(statement==ID_printf)
        {
            // doesn't do anything relevant
        }
        else
        {
            // arg!
            throw "path_slicert: unknown statement: `"+id2string(statement)+"'";
        }
    }
    else if(c_instruction.is_decl())
    {
        assert(c_instruction.code.operands().size()==1);

        if(!depends_lhs(c_instruction.code.op0(), dependencies))
            step.relevant=false;
    }
    else if(c_instruction.is_assume())
    {
        add_dependencies(c_instruction.guard, dependencies);
    }
    else if(c_instruction.is_goto())
    {
        if(c_instruction.guard.is_constant())
        {
            // ignore
        }
        else if(depends(c_instruction.guard, dependencies))
        {
            // it depends! add more dependencies
            add_dependencies(c_instruction.guard, dependencies);
        }
        else
        {
            // the abstract one must be the same goto
            assert(a_instruction.is_goto());

            // find out if we merge back to this on all paths
            assert(a_instruction.targets.size()==1);

            abstract_programt::const_targett dest;

            if(step.branch_taken)
                dest=a_instruction.targets.front();
            else
            {
                dest=step.pc;
                dest++;
            }

            if(all_merge_to(abstract_functions, dependencies, step.pc, dest))
            {
                step.relevant=false;
#ifdef DEBUG
                std::cout << "GOTO is not relevant\n";
#endif
            }
            else
            {
#ifdef DEBUG
                std::cout << "GOTO is relevant\n";
#endif
                add_dependencies(c_instruction.guard, dependencies);
            }
        }
    }
    else if(c_instruction.is_location() ||
            c_instruction.is_end_function())
        step.relevant=false;

#ifdef DEBUG
    if(step.relevant)
        std::cout << "RELEVANT\n";
    else
        std::cout << "NOT RELEVANT\n";

    std::cout << "*******\n";
    std::cout << dependencies;
    std::cout << "*******\n";
#endif
}
Example #7
0
bool path_slicert::depends_lhs_rec(
    const exprt &expr,
    const string_sett &suffixes_r,
    const string_sett &suffixes_w,
    string_sett &dependencies,
    string_sett &new_dependencies)
{
    if(expr.id()==ID_symbol)
    {
        string_sett tmp_r, tmp_w;

        const irep_idt &id=to_symbol_expr(expr).get_identifier();

        for(string_sett::const_iterator
                it=suffixes_w.begin();
                it!=suffixes_w.end();
                it++)
            tmp_w.insert(id2string(id)+id2string(*it));

        for(string_sett::const_iterator
                it=suffixes_r.begin();
                it!=suffixes_r.end();
                it++)
        {
            tmp_r.insert(id2string(id)+id2string(*it));
#ifdef DEBUG
            std::cout << "tmp_r: " << id2string(id)+id2string(*it) << std::endl;
#endif
        }

        // do we depend on it?
        if(!depends(tmp_r, dependencies))
        {
#ifdef DEBUG
            std::cout << "NO DEPN\n";
#endif
            return false; // no!
        }

#ifdef DEBUG
        std::cout << "DEP!\n";
#endif

        // yes! but we no longer do.
        for(string_sett::const_iterator it=tmp_w.begin();
                it!=tmp_w.end();
                it++)
            dependencies.erase(*it);
    }
    else if(expr.id()==ID_index)
    {
        assert(expr.operands().size()==2);
        get_symbols(expr.op0(), new_dependencies);
        get_symbols(expr.op1(), new_dependencies);

        string_sett tmp_r, tmp_w;

        for(string_sett::const_iterator it=suffixes_r.begin();
                it!=suffixes_r.end();
                it++)
        {
            tmp_r.insert(*it);
            tmp_r.insert("[]"+id2string(*it));
        }

        // can't get rid of array depenencies
        // thus, tmp_w stays empty

        return depends_lhs_rec(expr.op0(), tmp_r, tmp_w, dependencies, new_dependencies);
    }
    else if(expr.id()==ID_member)
    {
        assert(expr.operands().size()==1);

        string_sett tmp_r, tmp_w;

        for(string_sett::const_iterator it=suffixes_r.begin();
                it!=suffixes_r.end();
                it++)
        {
            tmp_r.insert(*it);
            tmp_r.insert("."+expr.get_string("component_name")+id2string(*it));
        }

        for(string_sett::const_iterator it=suffixes_w.begin();
                it!=suffixes_w.end();
                it++)
        {
            tmp_w.insert("."+expr.get_string("component_name")+id2string(*it));
        }

        return depends_lhs_rec(expr.op0(), tmp_r, tmp_w, dependencies, new_dependencies);
    }

    return true;
}