static void data_race(FILE **g,struct rbc_dynamic_input *dynamic_input,struct rbc_output **output){ char line[LINE_MAX]; char *f_name,*s_name,*l_number,*p; struct rbc_output node; char error_message[LINE_MAX]; int found_a_file = 0; node.err_msg = NULL; while (fgets(line, LINE_MAX, *g) != NULL && !is_break_line(line)){ if (strstr(line,"This conflicts with a previous")){ goto conflicts_with; } if (!is_detail_line(line)) return; if (!parse_line(line,&f_name,&s_name,&l_number)) return; if (!found_a_file && is_source(dynamic_input->sources, dynamic_input->source_count,s_name)){ found_a_file = 1; strcpy(error_message, "In function "); strcat(error_message, f_name); strcat(error_message, ", in file "); strcat(error_message, s_name); strcat(error_message, ", at line "); strcat(error_message, l_number); node.err_msg = strdup(error_message); node.err_type = ERR_DATA_RACE; } } conflicts_with: while (fgets(line, LINE_MAX, *g) != NULL && !is_break_line(line)){ if (!is_detail_line(line)) return; if (!parse_line(line,&f_name,&s_name,&l_number)) return; if (is_source(dynamic_input->sources, dynamic_input->source_count,s_name)){ strcat(error_message, "\nConflicts with data located in function "); strcpy(error_message,f_name); strcat(error_message,", in file "); strcat(error_message,s_name); strcat(error_message,", at line "); strcat(error_message,l_number); node.err_msg = strdup(error_message); add(output,node); return; } } }
/** * @brief Print the graph * * Print the graph. Useful for debugging. * * @warning The format in which this function prints a graph is not the same * as the DAG string format used by the XSocket API. To obtain a * string version of the DAG for use with the XSocket API, use * Graph::dag_string() instead. */ void Graph::print_graph() const { for (std::size_t i = 0; i < nodes_.size(); i++) { if (is_source(i)) printf("[SRC] "); else printf(" "); printf("Node %zu: [%s] ", i, nodes_[i].type_string().c_str()); //printf("%20s", nodes_[i].id()); for (std::size_t j = 0; j < Node::ID_LEN; j++) printf("%02x", nodes_[i].id()[j]); bool first = true; for (std::size_t j = 0; j < out_edges_[i].size(); j++) { if (first) { first = false; printf(" ->"); } printf(" Node %zu", out_edges_[i][j]); } if (is_sink(i)) printf(" [SNK]"); printf("\n"); } }
static void get_info(FILE **g,struct rbc_dynamic_input *dynamic_input,struct rbc_output **output,enum EN_err_type err_type){ char line[LINE_MAX]; char error_message[LINE_MAX]; char *f_name,*s_name,*l_number; struct rbc_output node; int found_a_file = 0; node.err_msg = NULL; while (fgets(line, LINE_MAX, *g) != NULL && !is_break_line(line)){ if (!is_detail_line(line)) return; if (!parse_line(line,&f_name,&s_name,&l_number)) return; if (!found_a_file && is_source(dynamic_input->sources, dynamic_input->source_count,s_name)){ found_a_file = 1; strcpy(error_message, "In function "); strcat(error_message, f_name); strcat(error_message, ", in file "); strcat(error_message, s_name); strcat(error_message, ", at line "); strcat(error_message, l_number); node.err_type = err_type; node.err_msg = strdup(error_message); add(output,node); return; } } }
/** * @brief Get the index of the souce node * * Get the index of the source node. This method returns the index of the first * source node it finds. * * @return The index of the DAG's source node */ std::size_t Graph::source_index() const { for (std::size_t i = 0; i < nodes_.size(); i++) { if (is_source(i)) return i; } printf("Warning: source_index: no source node found\n"); return -1; }
void Fcode_12_handler() { //diag_printf( "12" ); //last_addr = current_mf & address_filter; cyg_uint32 uart_checkbit; HAL_IO_UART_CHECKBIT(&uart_checkbit); if ( uart_checkbit == HAL_IO_ENUM_UART_NOT_EMPTY && is_source() ) { mvb_arm_send_message(); } }
/** * @brief Get a node from the DAG * * Get a Node from the graph at the specified index. The sink node will always * be returned last (that is, it has index num_nodes()-1). * * @note This function skips the starting node * * @param i The index of the node to return * * @return The node at index i */ Node Graph::get_node(int i) const { std::size_t src_index, sink_index; for (std::size_t j = 0; j < nodes_.size(); j++) { if (is_source(j)) src_index = j; if (is_sink(j)) sink_index = j; } return nodes_[index_from_dag_string_index(i, src_index, sink_index)]; }
/** * @brief Return the graph in string form * * Get the DAG string representation of the graph. This string is suitable for * use with the XSocket API. * * @return The graph in DAG string form. */ std::string Graph::dag_string() const { // TODO: check DAG first (one source, one sink, actually a DAG) std::string dag_string; int sink_index = -1, source_index = -1; // Find source and sink for (std::size_t i = 0; i < nodes_.size(); i++) { if (is_source(i)) source_index = i; if (is_sink(i)) sink_index = i; } if (sink_index >= 0 && source_index >= 0) { // Add source first dag_string += "DAG"; dag_string += out_edges_for_index(source_index, source_index, sink_index); dag_string += " - \n"; // Add intermediate nodes for (std::size_t i = 0; i < nodes_.size(); i++) { if (i == source_index || i == sink_index) continue; // add XID type dag_string += nodes_[i].type_string() + ":"; // add XID dag_string += nodes_[i].id_string(); // add out edges dag_string += out_edges_for_index(i, source_index, sink_index); dag_string += " - \n"; } // Add sink last dag_string += nodes_[sink_index].type_string() + ":"; dag_string += nodes_[sink_index].id_string(); } else { printf("WARNING: dag_string(): could not find source and/or sink. Returning empty string.\n"); } return dag_string; }
/** * @brief Get the out edges for a node * * Get the out edges for a node at index i * * @note This function skips the starting node. Use index -1 to get the * starting node's outgoing edges. * * @param i The index of the node * * @return The out edges of node i */ std::vector<std::size_t> Graph::get_out_edges(int i) const { std::size_t src_index, sink_index; for (std::size_t j = 0; j < nodes_.size(); j++) { if (is_source(j)) src_index = j; if (is_sink(j)) sink_index = j; } std::size_t real_index; if (i == -1) real_index = src_index; else real_index = index_from_dag_string_index(i, src_index, sink_index); std::vector<std::size_t> out_edges; for (std::size_t j = 0; j < out_edges_[real_index].size(); j++) { out_edges.push_back(index_in_dag_string(out_edges_[real_index][j], src_index, sink_index)); } return out_edges; }