int tracing_loop(tracee_t* tracee, addr_t start) { int signal, ret, count = 0; addr_t addr; pverbose(1, "\nStarting tracing !\n\n"); if (!start) { if (proc_step(tracee->proc, 0) == -1) errexit("ftrace: proc_step, %s", ftrace_strerror(errno)); } tracee->status = STEP; while (1) { ret = proc_wait_debug_event(tracee->proc, &signal); if (ret == -1) errexit("ftrace: proc_wait_debug_event, %s", ftrace_strerror(errno)); switch (ret) { case DEBUG_EVENT: count++; if (tracer_quit) return (0); /* ** Treat event */ if (start) { addr = start; ret = proc_seek_calls(tracee->proc, &addr); if (ret == -1) errexit("ftrace: proc_seek_calls, %s", ftrace_strerror(errno)); print_call(tracee, ret, addr); start = 0; } addr = 0; ret = proc_seek_calls(tracee->proc, &addr); if (ret == -1) errexit("ftrace: proc_seek_calls, %s", ftrace_strerror(errno)); print_call(tracee, ret, addr); if (proc_step(tracee->proc, 0) == -1) errexit("ftrace: proc_step, %s", ftrace_strerror(errno)); break; case SIGNAL_EVENT: pverbose(1, "Program received signal %d, %s\n", signal, sys_siglist[signal]); proc_step(tracee->proc, signal); break; case EXIT_EVENT: pverbose(1, "\nProgram exited normally.\n"); return (0); case EXIT_SIGNALED_EVENT: pverbose(1, "\nProgram exited with signal %d, %s\n", signal, sys_siglist[signal]); return (0); default: errexit("ftrace: proc_wait_debug_event, Unknow Error !"); } } return (-1); }
static void print_call(rpc_call_t* call) { printf("\"type\":\"call\", \"seq\":%d, \"fun\":\"%s\", ", call->sequence, rpc_function_to_string(call->function)); if (0) { } else if (call->function == RPC_TELL) { printf("\"peer\":\""); uip_debug_ipaddr_print(&call->data.tell.peer); printf("\", \"call\":{"); print_call(call->data.tell.call); printf("}"); } else if (call->function == RPC_READ_SLOW_SENSOR) { printf("\"sensor\":%d", call->data.read_slow_sensor.sensor); } else if (call->function == RPC_READ_FAST_SENSOR) { printf("\"sensor\":%d", call->data.read_fast_sensor.sensor); } else { ASSERT(false); } }
std::ostream& node(const ast::abstract::Node& node) { switch(node) { case ast::ExternNode: print_extern(dynamic_cast<const ast::Extern&>(node)); break; case ast::FuncNode: print_func(dynamic_cast<const ast::Func&>(node)); break; case ast::VariableNode: print_variable(dynamic_cast<const ast::Variable&>(node)); break; case ast::ConstantNode: print_constant(dynamic_cast<const ast::Constant&>(node)); break; case ast::CastNode: print_cast(dynamic_cast<const ast::Cast&>(node)); break; case ast::UnOpNode: print_un_op(dynamic_cast<const ast::UnOp&>(node)); break; case ast::BinOpNode: print_bin_op(dynamic_cast<const ast::BinOp&>(node)); break; case ast::CallNode: print_call(dynamic_cast<const ast::Call&>(node)); break; case ast::ReturnNode: print_return(dynamic_cast<const ast::Return&>(node)); break; case ast::BranchNode: print_branch(dynamic_cast<const ast::Branch&>(node)); break; case ast::AssignmentNode: print_assignment(dynamic_cast<const ast::Assignment&>(node)); break; case ast::WhileNode: print_while(dynamic_cast<const ast::While&>(node)); break; case ast::VoidContextNode: print_void_context(dynamic_cast<const ast::VoidContext&>(node)); break; default: stream << "[Unknown Node] ??"; } return stream; }
/* Print a summary of the per call statistics. */ void print_call_stats() { int j=0; int top = 0; top = get_call_next_id(); if (top >= buf_size) { top = buf_size; printf("\nCall Statistics (buffer filled):\n\n"); } else { printf("\nCall Statistics:\n\n"); } /* print data */ for (j = 0; j < top; j++) { print_call(call_stats[j]); } }
void rpc_print_call(rpc_call_t* call) { printf("{"); print_call(call); printf("}\n"); }
/* This function is called when a connection times out. */ void process_call_timeout(Conn * c ) { assert (c != NULL); Call * cur_call; int index; int timeout_type = 1; int i = 0; /* process calls in the connection's send queue * The send queue holds all calls that are waiting * have their requests sent to the web server */ cur_call = c->sendq; while (cur_call != NULL) { /* print information on the fly */ if (param.call_stats == 0) { call_data cd; cd.c_call_id = cur_call->id; cd.c_conn_id = cur_call->conn->id; strncpy (cd.c_name, (char *) cur_call->req.iov[IE_URI].iov_base, URI_SIZE); if (param.num_sessions) { cd.c_size = cur_call->file_size; } else if (strncmp (param.uri, "/", 2) != 0) { cd.c_size = get_f_size(cd.c_name); } else { cd.c_size = -2; } #ifdef UW_DYNOUT if (cur_call->timelimit != 0) { cd.c_time_lim = cur_call->timelimit; } else { cd.c_time_lim = param.timeout; } #else cd.c_time_lim = param.timeout; #endif /* UW_DYNOUT */ cd.c_timeout = timeout_type; cd.c_conn_time = -1; cd.c_resp_time = -1; cd.c_total_time = -1; cd.c_byte_rate = -1; cd.c_perc_recvd = -1; cd.c_status = -1; cd.c_bytes_recvd = -1; print_call(cd); } else { index = get_index(cur_call); if (index != -1) { call_stats[index].c_timeout = timeout_type; call_stats[index].c_call_id = index; strncpy (call_stats[index].c_name, (char *) cur_call->req.iov[IE_URI].iov_base, URI_SIZE); if (param.num_sessions) { call_stats[index].c_size = cur_call->file_size; } else if (strncmp (param.uri, "/", 2) != 0) { call_stats[index].c_size = get_f_size(call_stats[index].c_name); } else { call_stats[index].c_size = -2; } call_stats[index].c_conn_id = c->id; #ifdef UW_DYNOUT if (cur_call->timelimit != 0) { call_stats[index].c_time_lim = cur_call->timelimit; } else { call_stats[index].c_time_lim = param.timeout; } #else call_stats[index].c_time_lim = param.timeout; #endif /* UW_DYNOUT */ } } cur_call = cur_call->sendq_next; } /* process calls in the connection's receive queue * The receive queue holds all call that are waiting * for a response from the web server */ cur_call = c->recvq; while (cur_call != NULL) { /* print information on the fly */ if (param.call_stats == 0) { call_data cd; cd.c_call_id = cur_call->id; cd.c_conn_id = cur_call->conn->id; strncpy (cd.c_name, (char *) cur_call->req.iov[IE_URI].iov_base, URI_SIZE); if (param.num_sessions) { cd.c_size = cur_call->file_size; } else if (strncmp (param.uri, "/", 2) != 0) { cd.c_size = get_f_size(cd.c_name); } else { cd.c_size = -2; } cd.c_bytes_recvd = (int) cur_call->reply.content_bytes; cd.c_status = cur_call->reply.status ; #ifdef UW_DYNOUT if (cur_call->timelimit != 0) { cd.c_time_lim = cur_call->timelimit; } else { cd.c_time_lim = param.timeout; } #else cd.c_time_lim = param.timeout; #endif /* UW_DYNOUT */ cd.c_timeout = timeout_type; cd.c_conn_time = cur_call->record_conn_time == 1 ? cur_call->conn->basic.time_to_connect : 0; cd.c_resp_time = c->basic.time_of_timeout - cur_call->basic.time_send_start; cd.c_total_time = cd.c_conn_time + cd.c_resp_time; cd.c_byte_rate = (double) ((double) cur_call->reply.content_bytes / (double) cd.c_resp_time) * 8.0 / 1000000.0; cd.c_perc_recvd = 100 * ((double) cur_call->reply.content_bytes / (double) cd.c_size); print_call(cd); } else { index = get_index(cur_call); if (index != -1) { call_stats[index].c_timeout = timeout_type; call_stats[index].c_status = cur_call->reply.status; call_stats[index].c_bytes_recvd = (int) cur_call->reply.content_bytes; call_stats[index].c_resp_time = c->basic.time_of_timeout - cur_call->basic.time_send_start; call_stats[index].c_total_time = call_stats[index].c_resp_time + call_stats[index].c_conn_time; call_stats[index].c_perc_recvd = 100 * (double) cur_call->reply.content_bytes / (double) call_stats[index].c_size; call_stats[index].c_byte_rate = (double) ((double) cur_call->reply.content_bytes / (double) call_stats[index].c_resp_time) * 8.0 / 1000000.0; } } cur_call = cur_call->recvq_next; } /* Simulate the calls that never happened by * not allowing the id that they should have used * to be used by another call */ int calls; /* this is used if a session log file generated the requests */ if (param.num_sessions) { calls = num_missed_calls(c); set_missed_calls(c); } else if (strncmp (param.uri, "/", 2) != 0) { /* this is used if a videosesslog file was not specified */ if (c->state < S_CONNECTED) { timeout_type = 2; calls = param.num_calls - c->basic.num_calls_completed; } else { /* Don't count the call that timed out, as it has already been * taken care of above */ calls = param.num_calls - c->basic.num_calls_completed - 1; } } else { /* No other load generating mechanism is currently supported */ calls = 0; } /* if this connection timed out before it was connected * then the first call was already created when using videosesslog*/ if (c->state < S_CONNECTED && param.num_sessions) { cur_call = session_get_last_call(c); timeout_type = 2; /* print information on the fly */ if (param.call_stats == 0) { call_data cd; cd.c_call_id = cur_call->id; cd.c_conn_id = c->id; strncpy (cd.c_name, (char *) cur_call->req.iov[IE_URI].iov_base, URI_SIZE); if (param.num_sessions) { cd.c_size = cur_call->file_size; } else if (strncmp (param.uri, "/", 2) != 0) { cd.c_size = get_f_size(cd.c_name); } else { cd.c_size = -2; } #ifdef UW_DYNOUT if (cur_call->timelimit != 0) { cd.c_time_lim = cur_call->timelimit; } else { cd.c_time_lim = param.timeout; } #else cd.c_time_lim = param.timeout; #endif /* UW_DYNOUT */ cd.c_timeout = timeout_type; cd.c_conn_time = c->basic.time_of_timeout - c->basic.time_connect_start; cd.c_resp_time = -1; cd.c_total_time = -1; cd.c_byte_rate = -1; cd.c_perc_recvd = -1; cd.c_status = -1; cd.c_bytes_recvd = -1; print_call(cd); } else { index = get_index(cur_call); if (index != -1) { call_stats[index].c_timeout = timeout_type; strncpy (call_stats[index].c_name, (char *) cur_call->req.iov[IE_URI].iov_base, URI_SIZE); if (param.num_sessions) { call_stats[index].c_size = cur_call->file_size; } else if (strncmp (param.uri, "/", 2) != 0) { call_stats[index].c_size = get_f_size(call_stats[index].c_name); } else { call_stats[index].c_size = -2; } call_stats[index].c_conn_id = c->id; call_stats[index].c_call_id = index; call_stats[index].c_conn_time = c->basic.time_of_timeout - c->basic.time_connect_start; #ifdef UW_DYNOUT if (cur_call->timelimit != 0) { call_stats[index].c_time_lim = cur_call->timelimit; } else { call_stats[index].c_time_lim = param.timeout; } #else call_stats[index].c_time_lim = param.timeout; #endif /* UW_DYNOUT */ } calls--; } } if (calls > 0) { inc_call_next_id(calls); int top = get_call_next_id (); i = top - calls; if (top > buf_size && param.call_stats != 0) { top = buf_size; } for (; i < top; i++) { /* print information on the fly */ if (param.call_stats == 0) { call_data cd; cd.c_call_id = i; cd.c_conn_id = c->id; if (param.num_sessions) { strncpy (cd.c_name, get_next_missed_uri(c), URI_SIZE); cd.c_size = get_next_missed_size(c); } else if (strncmp (param.uri, "/", 2) != 0) { strncpy (cd.c_name, param.uri, URI_SIZE); cd.c_size = get_f_size(cd.c_name); } else { strcpy(cd.c_name, "--"); cd.c_size = -2; } #ifdef UW_DYNOUT cd.c_time_lim = get_next_missed_timelimit(c); #else cd.c_time_lim = param.timeout; #endif /* UW_DYNOUT */ cd.c_timeout = timeout_type; cd.c_conn_time = -1; cd.c_resp_time = -1; cd.c_total_time = -1; cd.c_byte_rate = -1; cd.c_perc_recvd = -1; cd.c_status = -1; cd.c_bytes_recvd = -1; print_call(cd); } else { call_stats[i].c_call_id= i; call_stats[i].c_conn_id = c->id; call_stats[i].c_timeout = timeout_type; if (param.num_sessions) { //strncpy (call_stats[i].c_name, get_next_missed_uri(c), URI_SIZE); strncpy (call_stats[i].c_name, "BLA", 4); //call_stats[i].c_size = get_next_missed_size(c); call_stats[i].c_size = 0; } else if (strncmp (param.uri, "/", 2) != 0) { strncpy (call_stats[i].c_name, param.uri, URI_SIZE); call_stats[i].c_size = get_f_size(call_stats[i].c_name); } else { strcpy(call_stats[i].c_name, "--"); call_stats[i].c_size = -2; } #ifdef UW_DYNOUT //call_stats[i].c_time_lim = get_next_missed_timelimit(c); call_stats[i].c_time_lim = param.timeout; #else call_stats[i].c_time_lim = param.timeout; #endif /* UW_DYNOUT */ } } } }
/* This function is called when the last byte of a reply is received from the server */ void track_call_reply(Call * c, double transfer_time) { assert (c != NULL); /* print information on the fly */ if (param.call_stats == 0) { call_data cd; cd.c_call_id = c->id; cd.c_conn_id = c->conn->id; strncpy (cd.c_name, (char *) c->req.iov[IE_URI].iov_base, URI_SIZE); cd.c_size =c->file_size ; if (param.num_sessions) { cd.c_size = c->file_size; } else if (strncmp (param.uri, "/", 2) != 0) { cd.c_size = get_f_size(cd.c_name); } else { cd.c_size = -2; } cd.c_bytes_recvd = (int) c->reply.content_bytes; cd.c_status =c->reply.status ; #ifdef UW_DYNOUT if (c->timelimit != 0) { cd.c_time_lim = c->timelimit; } else { cd.c_time_lim = param.timeout; } #else cd.c_time_lim =param.timeout ; #endif /* UW_DYNOUT */ cd.c_timeout = 0; cd.c_conn_time = c->record_conn_time == 1 ? c->conn->basic.time_to_connect : 0; cd.c_resp_time = transfer_time + c->basic.time_recv_start - c->basic.time_send_start; cd.c_total_time = cd.c_conn_time + cd.c_resp_time; cd.c_byte_rate = (double) ((double) c->reply.content_bytes / (double) cd.c_resp_time) * 8.0 / 1000000.0; cd.c_perc_recvd = 100 * ((double) c->reply.content_bytes / (double) cd.c_size); print_call(cd); } else { int index = get_index(c); if (index != -1) { call_stats[index].c_timeout = 0; call_stats[index].c_resp_time = transfer_time + c->basic.time_recv_start - c->basic.time_send_start; call_stats[index].c_total_time = call_stats[index].c_resp_time + call_stats[index].c_conn_time; call_stats[index].c_status = c->reply.status; call_stats[index].c_bytes_recvd = (int) c->reply.content_bytes; call_stats[index].c_perc_recvd = 100 * ((double) call_stats[index].c_bytes_recvd / (double) call_stats[index].c_size); call_stats[index].c_byte_rate = (double) ((double) call_stats[index].c_bytes_recvd / (double) call_stats[index].c_resp_time) * 8.0 / 1000000.0; } } }