Пример #1
0
/* Initialize local data */
static void
dump_init0(void)
{
  dump_filep = NULL;
  dump_open = dump_type;

  switch (dump_open) {
  case DT_NONE:
  case DT_CMN_ERR:
    break;
  case DT_STDERR:
    dump_filep = stderr;
    break;
  case DT_FILE:
    dump_filep = fopen(dump_filename, "a");
    if (dump_filep == NULL) {
      dump_open = DT_STDERR;
      dump_filep = stderr;
      dump_printf(EL_WARN, "Cannot open log file %s", dump_filename);
    }
    break;
  case DT_SYSLOG:
    openlog("lane", LOG_PID | LOG_CONS, LOG_DAEMON);
    break;
  case DT_CONSOLE:
    dump_filep = fopen(dump_console, "w");
    if (dump_filep == NULL) {
      dump_open = DT_STDERR;
      dump_filep = stderr;
      dump_printf(EL_WARN, "Cannot open console log");
    }
    break;
  }
  dump_printf(EL_DEBUG, "Log opened");
}
Пример #2
0
void trace_event(event_t *event)
{
	unsigned char *raw_event = (void *)event;
	const char *color = PERF_COLOR_BLUE;
	int i, j;

	if (!dump_trace)
		return;

	dump_printf(".");
	dump_printf_color("\n. ... raw event: size %d bytes\n", color,
			  event->header.size);

	for (i = 0; i < event->header.size; i++) {
		if ((i & 15) == 0) {
			dump_printf(".");
			dump_printf_color("  %04x: ", color, i);
		}

		dump_printf_color(" %02x", color, raw_event[i]);

		if (((i & 15) == 15) || i == event->header.size-1) {
			dump_printf_color("  ", color);
			for (j = 0; j < 15-(i & 15); j++)
				dump_printf_color("   ", color);
			for (j = i & ~15; j <= i; j++) {
				dump_printf_color("%c", color,
						isprint(raw_event[j]) ?
						raw_event[j] : '.');
			}
			dump_printf_color("\n", color);
		}
	}
	dump_printf(".\n");
}
void CommonTimeServer::PacketRTTLog::dumpLog(int fd, const CommonClock& cclk) {
    const size_t SIZE = 256;
    char buffer[SIZE];
    uint32_t avail = !logFull ? wrPtr : RTT_LOG_SIZE;

    if (!avail)
        return;

    dump_printf("\nPacket Log (%d entries)\n", avail);

    uint32_t ndx = 0;
    uint32_t i = logFull ? wrPtr : 0;
    do {
        if (rxTimes[i]) {
            int64_t delta = rxTimes[i] - txTimes[i];
            int64_t deltaUsec = cclk.localDurationToCommonDuration(delta);
            dump_printf("pkt[%2d] : localTX %12" PRId64 " localRX %12" PRId64 " "
                        "(%.3f msec RTT)\n",
                        ndx, txTimes[i], rxTimes[i],
                        static_cast<float>(deltaUsec) / 1000.0);
        } else {
            dump_printf("pkt[%2d] : localTX %12" PRId64 " localRX never\n",
                        ndx, txTimes[i]);
        }
        i = (i + 1) % RTT_LOG_SIZE;
        ndx++;
    } while (i != wrPtr);
}
Пример #4
0
static unsigned int
increase_alignment (void)
{
  struct varpool_node *vnode;

  /* Increase the alignment of all global arrays for vectorization.  */
  FOR_EACH_DEFINED_VARIABLE (vnode)
    {
      tree vectype, decl = vnode->symbol.decl;
      tree t;
      unsigned int alignment;

      t = TREE_TYPE(decl);
      if (TREE_CODE (t) != ARRAY_TYPE)
        continue;
      vectype = get_vectype_for_scalar_type (strip_array_types (t));
      if (!vectype)
        continue;
      alignment = TYPE_ALIGN (vectype);
      if (DECL_ALIGN (decl) >= alignment)
        continue;

      if (vect_can_force_dr_alignment_p (decl, alignment))
        {
          DECL_ALIGN (decl) = TYPE_ALIGN (vectype);
          DECL_USER_ALIGN (decl) = 1;
          dump_printf (MSG_NOTE, "Increasing alignment of decl: ");
          dump_generic_expr (MSG_NOTE, TDF_SLIM, decl);
          dump_printf (MSG_NOTE, "\n");
        }
    }
  return 0;
}
Пример #5
0
Файл: xml.c Проект: MigNov/CDVWS
void xml_dump(void) {
    int i;

    for (i = 0; i < xml_numAttr; i++) {
        dump_printf("Attribute #%d:\n", i + 1);
        dump_printf("\tFilename: %s\n", xattr[i].filename);
        dump_printf("\tNode: %s\n", xattr[i].node);
        dump_printf("\tName: %s\n", xattr[i].name);
        dump_printf("\tValue: %s\n", xattr[i].value);
    }
}
Пример #6
0
int event__process_comm(event_t *self)
{
	struct thread *thread = threads__findnew(self->comm.pid);

	dump_printf(": %s:%d\n", self->comm.comm, self->comm.pid);

	if (thread == NULL || thread__set_comm(thread, self->comm.comm)) {
		dump_printf("problem processing PERF_RECORD_COMM, skipping event.\n");
		return -1;
	}

	return 0;
}
Пример #7
0
int event__process_comm(event_t *self, struct perf_session *session)
{
	struct thread *thread = perf_session__findnew(session, self->comm.tid);

	dump_printf(": %s:%d\n", self->comm.comm, self->comm.tid);

	if (thread == NULL || thread__set_comm_adjust(thread, self->comm.comm)) {
		dump_printf("problem processing PERF_RECORD_COMM, skipping event.\n");
		return -1;
	}

	return 0;
}
Пример #8
0
void
dump_vars(const Unit_t *unit)
{
  const VarList_t *tmp;
  LaneDestList_t *ltmp;

  Debug_unit(&load_unit, "Dumping variables");
  for (tmp = varlist; tmp != NULL; tmp = tmp->next) {
    assert(tmp->var != NULL);
    assert(tmp->var->unit != NULL);
    assert(tmp->var->unit->name != NULL);
    assert(tmp->var->name != NULL);
    if (unit == NULL || strcmp(unit->name, tmp->var->unit->name) == 0) {
      switch (tmp->var->type) {
      case VT_INT:
	Debug_unit(&load_unit, "%s/%s = %d", tmp->var->unit->name, tmp->var->name, tmp->var->val_u.intval);
	break;
      case VT_STR:
	Debug_unit(&load_unit, "%s/%s = \"%s\"", tmp->var->unit->name, tmp->var->name, tmp->var->val_u.strval);
	break;
      case VT_BOOL:
	Debug_unit(&load_unit, "%s/%s = %s", tmp->var->unit->name, tmp->var->name, tmp->var->val_u.boolval == BL_TRUE? "True" : "False" );
	break;
      case VT_ADDR:
	Debug_unit(&load_unit, "%s/%s =", tmp->var->unit->name, tmp->var->name);
	dump_atmaddr(tmp->var->val_u.addrval);
	break;
      case VT_PVC:
	Debug_unit(&load_unit,"%s/%s = %d,%d,%d with lecid:%d ",
		   tmp->var->unit->name, 
		   tmp->var->name, 
		   tmp->var->val_u.init->pvc->port,
		   tmp->var->val_u.init->pvc->vpi,
		   tmp->var->val_u.init->pvc->vci,
		   tmp->var->val_u.init->lecid);
	dump_atmaddr(tmp->var->val_u.init->address);
	ltmp = tmp->var->val_u.init->destinations;
	while(ltmp) {
	  dump_printf(EL_CONT,"\t");
	  dump_addr(ltmp->addr);
	  dump_printf(EL_CONT,"\n");
	  ltmp = ltmp->next;
	}
	break;
      }
    }
  }
}
Пример #9
0
int main( int argc, char *argv)	{

	/*	SET LOG LEVEL
		[PROCESS NAME] [ARG]
		ARG - 0, LOG
		ARG - 1, LOG ERROR
		ARG - 2, LOG ERROR DEBUG

		DEFAULT - 2, LOG ERROR DEBUG
	*/
	if ( argc > 1) {
		gi_LogLevel = atoi(argv[1]);
	} else {
		gi_LogLevel = 2;
	}
	
	log_printf(LOG_ARG,">>>>>>>>>>>>>>>>>>>>>>>>>");
	log_printf(LOG_ARG,"TEST START!!");
	log_printf(LOG_ARG,">>>>>>>>>>>>>>>>>>>>>>>>>");

	db_Conn();
	
	char lc_temp[1100];
	memset(lc_temp,0x30,sizeof(lc_temp));
	
	dump_printf(lc_temp,sizeof(lc_temp));

	return 0;
	
}
Пример #10
0
int event__preprocess_sample(const event_t *self, struct perf_session *session,
                             struct addr_location *al, symbol_filter_t filter)
{
    u8 cpumode = self->header.misc & PERF_RECORD_MISC_CPUMODE_MASK;
    struct thread *thread = perf_session__findnew(session, self->ip.pid);

    if (thread == NULL)
        return -1;

    if (symbol_conf.comm_list &&
            !strlist__has_entry(symbol_conf.comm_list, thread->comm))
        goto out_filtered;

    dump_printf(" ... thread: %s:%d\n", thread->comm, thread->pid);

    thread__find_addr_location(thread, session, cpumode, MAP__FUNCTION,
                               self->ip.ip, al, filter);
    dump_printf(" ...... dso: %s\n",
                al->map ? al->map->dso->long_name :
                al->level == 'H' ? "[hypervisor]" : "<not found>");
    /*
     * We have to do this here as we may have a dso with no symbol hit that
     * has a name longer than the ones with symbols sampled.
     */
    if (al->map && !sort_dso.elide && !al->map->dso->slen_calculated)
        dso__calc_col_width(al->map->dso);

    if (symbol_conf.dso_list &&
            (!al->map || !al->map->dso ||
             !(strlist__has_entry(symbol_conf.dso_list, al->map->dso->short_name) ||
               (al->map->dso->short_name != al->map->dso->long_name &&
                strlist__has_entry(symbol_conf.dso_list, al->map->dso->long_name)))))
        goto out_filtered;

    if (symbol_conf.sym_list && al->sym &&
            !strlist__has_entry(symbol_conf.sym_list, al->sym->name))
        goto out_filtered;

    al->filtered = false;
    return 0;

out_filtered:
    al->filtered = true;
    return 0;
}
Пример #11
0
int event__preprocess_sample(const event_t *self, struct addr_location *al,
			     symbol_filter_t filter)
{
	u8 cpumode = self->header.misc & PERF_RECORD_MISC_CPUMODE_MASK;
	struct thread *thread = threads__findnew(self->ip.pid);

	if (thread == NULL)
		return -1;

	dump_printf(" ... thread: %s:%d\n", thread->comm, thread->pid);

	thread__find_addr_location(thread, cpumode, MAP__FUNCTION,
				   self->ip.ip, al, filter);
	dump_printf(" ...... dso: %s\n",
		    al->map ? al->map->dso->long_name :
			al->level == 'H' ? "[hypervisor]" : "<not found>");
	return 0;
}
Пример #12
0
static void
conn_main(void)
{
  const AtmAddr_t *addr;
  int main_conn;
  const char *str;
  int i;

  addr = get_var_addr(&conn_unit, "S1");
  if (addr == NULL) {
    dump_printf(EL_ERROR, "S1 (LES Address) must be specified");
    event_put(&conn_unit, CE_EXIT, NULL);
  }
  else {
    str = get_var_str(&conn_unit,"S2");
    if (str == NULL) {
      set_var_str(&conn_unit, "S2", S2_default);
    }
    i = get_var_int(&conn_unit,"S3");
    if (i == 0) {
      set_var_int(&conn_unit,"S3", S3_default);
    }
    i = get_var_int(&conn_unit,"S4");
    if (i == 0) {
      set_var_int(&conn_unit,"S4", S4_default);
    }
    i = get_var_int(&conn_unit,"S5");
    if (i == 0) {
      set_var_int(&conn_unit,"S5", S5_default);
    }
    addr = get_var_addr(&conn_unit, "S6");
    if (addr == NULL) {
      dump_printf(EL_ERROR, "S6 (BUS Address) must be specified");
      event_put(&conn_unit, CE_EXIT, NULL);
    } else {
      main_conn = atm_create_socket(CONTROL_DIRECT, 
				    get_var_addr(&conn_unit, "S1"));
      if (main_conn >= 0) {
	(void)conn_add(CT_MAIN, main_conn,0);
      }
    }
  }
}
Пример #13
0
static void
dump_atmtext(const AtmAddr_t addr)
{
  int i;
  char buffer[ATM_ADDR_LEN*3+2];

  for (i=0;i<ATM_ADDR_LEN;i++) {
    sprintf(&buffer[i*2], "%2.2x ", 0xff&(unsigned char)addr.addr[i]);
  }
  dump_printf(EL_CONT, "%s", buffer);
}
Пример #14
0
int event__process_mmap(event_t *self)
{
	struct thread *thread = threads__findnew(self->mmap.pid);
	struct map *map = map__new(&self->mmap, MAP__FUNCTION,
				   event__cwd, event__cwdlen);

	dump_printf(" %d/%d: [%p(%p) @ %p]: %s\n",
		    self->mmap.pid, self->mmap.tid,
		    (void *)(long)self->mmap.start,
		    (void *)(long)self->mmap.len,
		    (void *)(long)self->mmap.pgoff,
		    self->mmap.filename);

	if (thread == NULL || map == NULL)
		dump_printf("problem processing PERF_RECORD_MMAP, skipping event.\n");
	else
		thread__insert_map(thread, map);

	return 0;
}
Пример #15
0
static void
init(const ctr_list_t *ctrs, const dumper_config_t *_conf)
{
    attr = &ctrs->head->attr;
    const uint64_t sample_type = attr->sample_type;

    conf = *_conf;

    sample_no = 0;

    dump_printf("#");
    if (sample_type & PERF_SAMPLE_TIME)
        dump_printf("time");
    else
        dump_printf("number");

    no_counters = 0;
    for (ctr_t *ctr = ctrs->head; ctr; ctr = ctr->next) {
        no_counters++;
        switch (ctr->attr.type) {
        case PERF_TYPE_HARDWARE:
            dump_printf(",hw:%" PRIu64, (uint64_t)ctr->attr.config);
            break;
        case PERF_TYPE_SOFTWARE:
            dump_printf(",sw:%" PRIu64, (uint64_t)ctr->attr.config);
            break;
        case PERF_TYPE_HW_CACHE:
            dump_printf(",hwc:0x%" PRIx64, (uint64_t)ctr->attr.config);
            break;
        case PERF_TYPE_RAW:
            dump_printf(",0x%" PRIx64, (uint64_t)ctr->attr.config);
            break;
        default:
            dump_printf(",%" PRIu32 ":%" PRIu64,
                        (uint32_t)ctr->attr.type, (uint64_t)ctr->attr.config);
            break;
        }
    }

    if (conf.delta) {
        EXPECT(old_values = malloc(sizeof(*old_values) * no_counters));
        memset(old_values, 0, sizeof(*old_values) * no_counters);
    }

    dump_printf("\n");
}
Пример #16
0
int event__process_task(event_t *self, struct perf_session *session)
{
	struct thread *thread = perf_session__findnew(session, self->fork.tid);
	struct thread *parent = perf_session__findnew(session, self->fork.ptid);

	dump_printf("(%d:%d):(%d:%d)\n", self->fork.pid, self->fork.tid,
		    self->fork.ppid, self->fork.ptid);

	if (self->header.type == PERF_RECORD_EXIT) {
		perf_session__remove_thread(session, thread);
		return 0;
	}

	if (thread == NULL || parent == NULL ||
	    thread__fork(thread, parent) < 0) {
		dump_printf("problem processing PERF_RECORD_FORK, skipping event.\n");
		return -1;
	}

	return 0;
}
Пример #17
0
struct perf_session *perf_session__new(const char *filename, int mode,
				       bool force, bool repipe,
				       struct perf_tool *tool)
{
	struct perf_session *self;
	struct stat st;
	size_t len;

	if (!filename || !strlen(filename)) {
		if (!fstat(STDIN_FILENO, &st) && S_ISFIFO(st.st_mode))
			filename = "-";
		else
			filename = "perf.data";
	}

	len = strlen(filename);
	self = zalloc(sizeof(*self) + len);

	if (self == NULL)
		goto out;

	memcpy(self->filename, filename, len);
	self->repipe = repipe;
	INIT_LIST_HEAD(&self->ordered_samples.samples);
	INIT_LIST_HEAD(&self->ordered_samples.sample_cache);
	INIT_LIST_HEAD(&self->ordered_samples.to_free);
	machines__init(&self->machines);

	if (mode == O_RDONLY) {
		if (perf_session__open(self, force) < 0)
			goto out_delete;
		perf_session__set_id_hdr_size(self);
	} else if (mode == O_WRONLY) {
		/*
		 * In O_RDONLY mode this will be performed when reading the
		 * kernel MMAP event, in perf_event__process_mmap().
		 */
		if (perf_session__create_kernel_maps(self) < 0)
			goto out_delete;
	}

	if (tool && tool->ordering_requires_timestamps &&
	    tool->ordered_samples && !perf_evlist__sample_id_all(self->evlist)) {
		dump_printf("WARNING: No sample_id_all support, falling back to unordered processing\n");
		tool->ordered_samples = false;
	}

out:
	return self;
out_delete:
	perf_session__delete(self);
	return NULL;
}
Пример #18
0
static int
process_comm_event(event_t *event, unsigned long offset, unsigned long head)
{
	struct thread *thread;

	thread = threads__findnew(event->comm.pid, &threads, &last_match);

	dump_printf("%p [%p]: PERF_RECORD_COMM: %s:%d\n",
		(void *)(offset + head),
		(void *)(long)(event->header.size),
		event->comm.comm, event->comm.pid);

	if (thread == NULL ||
	    thread__set_comm(thread, event->comm.comm)) {
		dump_printf("problem processing PERF_RECORD_COMM, skipping event.\n");
		return -1;
	}
	total_comm++;

	return 0;
}
status_t CommonTimeServer::dumpConfigInterface(int fd,
                                               const Vector<String16>& /* args */) {
    AutoMutex _lock(&mLock);
    const size_t SIZE = 256;
    char buffer[SIZE];

    if (checkCallingPermission(String16("android.permission.DUMP")) == false) {
        snprintf(buffer, SIZE, "Permission Denial: "
                 "can't dump CommonTimeConfigService from pid=%d, uid=%d\n",
                 IPCThreadState::self()->getCallingPid(),
                 IPCThreadState::self()->getCallingUid());
        write(fd, buffer, strlen(buffer));
    } else {
        char meStr[64];

        sockaddrToString(mMasterElectionEP, true, meStr, sizeof(meStr));

        dump_printf("Common Time Config Service Status\n"
                    "Bound Interface           : %s\n",
                    mBindIfaceValid ? mBindIface.string() : "<unbound>");
        dump_printf("Master Election Endpoint  : %s\n", meStr);
        dump_printf("Master Election Group ID  : %016" PRIu64 "\n", mSyncGroupID);
        dump_printf("Master Announce Interval  : %d mSec\n",
                    mMasterAnnounceIntervalMs);
        dump_printf("Client Sync Interval      : %d mSec\n",
                    mSyncRequestIntervalMs);
        dump_printf("Panic Threshold           : %d uSec\n",
                    mPanicThresholdUsec);
        dump_printf("Base ME Prio              : 0x%02x\n",
                    static_cast<uint32_t>(mMasterPriority));
        dump_printf("Effective ME Prio         : 0x%02x\n",
                    static_cast<uint32_t>(effectivePriority()));
        dump_printf("Auto Disable Allowed      : %s\n",
                    mAutoDisable ? "yes" : "no");
        dump_printf("Auto Disable Engaged      : %s\n",
                    shouldAutoDisable() ? "yes" : "no");
    }

    return NO_ERROR;
}
Пример #20
0
void 
disp_sockaddr(struct sockaddr_atmsvc *addr, struct atm_blli *blli)
{
  int i;
  dump_printf(EL_DEBUG,"Socket_address");
  dump_printf(EL_CONT, "Sas_family:%d\n\tAddress:",addr->sas_family);
  for(i=0;i<20;i++) {
    dump_printf(EL_CONT,"%2.2x ",addr->sas_addr.prv[i]);
  }
  dump_printf(EL_CONT,"\nBlli:\n\t");
  dump_printf(EL_CONT,"l2_proto:%d\n\t",blli->l2_proto);
  dump_printf(EL_CONT,"l3_proto:%d\n\t\t",blli->l3_proto);
  dump_printf(EL_CONT,"ipi:%x\tsnap:",blli->l3.tr9577.ipi);
  for(i=0;i<5;i++) {
    dump_printf(EL_CONT,"%2.2x ",blli->l3.tr9577.snap[i]);
  }
  dump_printf(EL_CONT,"\n");
}
Пример #21
0
struct perf_session *perf_session__new(struct perf_data_file *file,
				       bool repipe, struct perf_tool *tool)
{
	struct perf_session *session = zalloc(sizeof(*session));

	if (!session)
		goto out;

	session->repipe = repipe;
	INIT_LIST_HEAD(&session->ordered_samples.samples);
	INIT_LIST_HEAD(&session->ordered_samples.sample_cache);
	INIT_LIST_HEAD(&session->ordered_samples.to_free);
	machines__init(&session->machines);

	if (file) {
		if (perf_data_file__open(file))
			goto out_delete;

		session->file = file;

		if (perf_data_file__is_read(file)) {
			if (perf_session__open(session) < 0)
				goto out_close;

			perf_session__set_id_hdr_size(session);
		}
	}

	if (!file || perf_data_file__is_write(file)) {
		/*
		 * In O_RDONLY mode this will be performed when reading the
		 * kernel MMAP event, in perf_event__process_mmap().
		 */
		if (perf_session__create_kernel_maps(session) < 0)
			goto out_delete;
	}

	if (tool && tool->ordering_requires_timestamps &&
	    tool->ordered_samples && !perf_evlist__sample_id_all(session->evlist)) {
		dump_printf("WARNING: No sample_id_all support, falling back to unordered processing\n");
		tool->ordered_samples = false;
	}

	return session;

 out_close:
	perf_data_file__close(file);
 out_delete:
	perf_session__delete(session);
 out:
	return NULL;
}
Пример #22
0
int event__process_mmap(event_t *self, struct perf_session *session)
{
	struct machine *machine;
	struct thread *thread;
	struct map *map;
	u8 cpumode = self->header.misc & PERF_RECORD_MISC_CPUMODE_MASK;
	int ret = 0;

	dump_printf(" %d/%d: [%#Lx(%#Lx) @ %#Lx]: %s\n",
			self->mmap.pid, self->mmap.tid, self->mmap.start,
			self->mmap.len, self->mmap.pgoff, self->mmap.filename);

	if (cpumode == PERF_RECORD_MISC_GUEST_KERNEL ||
	    cpumode == PERF_RECORD_MISC_KERNEL) {
		ret = event__process_kernel_mmap(self, session);
		if (ret < 0)
			goto out_problem;
		return 0;
	}

	machine = perf_session__find_host_machine(session);
	if (machine == NULL)
		goto out_problem;
	thread = perf_session__findnew(session, self->mmap.pid);
	map = map__new(&machine->user_dsos, self->mmap.start,
			self->mmap.len, self->mmap.pgoff,
			self->mmap.pid, self->mmap.filename,
			MAP__FUNCTION, session->cwd, session->cwdlen);

	if (thread == NULL || map == NULL)
		goto out_problem;

	thread__insert_map(thread, map);
	return 0;

out_problem:
	dump_printf("problem processing PERF_RECORD_MMAP, skipping event.\n");
	return 0;
}
Пример #23
0
/* Dumping functions, LANE address */
void
dump_addr(const LaneDestination_t *addr)
{
  assert(addr != NULL);
  switch (ntohs(addr->tag)) {
  case LANE_DEST_NP:
    dump_printf(EL_CONT, "Not present");
    break;
    
  case LANE_DEST_MAC:
    dump_printf(EL_CONT, "MAC addr %2.2x.%2.2x.%2.2x.%2.2x.%2.2x.%2.2x",
		addr->a_r.mac_address[0],addr->a_r.mac_address[1],
		addr->a_r.mac_address[2],addr->a_r.mac_address[3],
		addr->a_r.mac_address[4],addr->a_r.mac_address[5]
		);
    break;
    
  case LANE_DEST_RD:
    dump_printf(EL_CONT, "Route Designator %4.4x", addr->a_r.route.designator);
    break;
  }
}
Пример #24
0
/* Release allocated memory, close files etc. */
static void
dump_release(void)
{
  int flush_ret;

  Debug_unit(&dump_unit, "Releasing unit");

  dump_printf(EL_DEBUG, "Closing log file");

  switch (dump_open) {
  case DT_NONE:
  case DT_CMN_ERR:
    break;
  case DT_STDERR:
    flush_ret = fflush(stderr);
    assert(flush_ret == 0);
    break;
  case DT_FILE:
    if (fclose(dump_filep) != 0) {
      dump_open = DT_STDERR;
      dump_filep = stderr;
      dump_printf(EL_WARN, "Cannot close log file %s", dump_filename);
    }
    break;
  case DT_SYSLOG:
    closelog();
    break;
  case DT_CONSOLE:
      if (fclose(dump_filep) != 0) {
      dump_open = DT_STDERR;
      dump_filep = stderr;
      dump_printf(EL_WARN, "Cannot close console log");
    }
    break;
  }
  dump_filep = NULL;
  dump_open = DT_NONE;
}
Пример #25
0
/* Dumping functions, ATM address */
void
dump_atmaddr(const AtmAddr_t *addr)
{
  int i;
  char buffer[ATM_ADDR_LEN*3+2];

  assert(addr != 0);

  for (i = 0; i<ATM_ADDR_LEN; i++){
    sprintf(&buffer[i*2], "%2.2x ", 0xff&(unsigned char)addr->addr[i]);
  }

  dump_printf(EL_DEBUG, "%s", buffer);
}
Пример #26
0
int event__process_task(event_t *self)
{
	struct thread *thread = threads__findnew(self->fork.pid);
	struct thread *parent = threads__findnew(self->fork.ppid);

	dump_printf("(%d:%d):(%d:%d)\n", self->fork.pid, self->fork.tid,
		    self->fork.ppid, self->fork.ptid);
	/*
	 * A thread clone will have the same PID for both parent and child.
	 */
	if (thread == parent)
		return 0;

	if (self->header.type == PERF_RECORD_EXIT)
		return 0;

	if (thread == NULL || parent == NULL ||
	    thread__fork(thread, parent) < 0) {
		dump_printf("problem processing PERF_RECORD_FORK, skipping event.\n");
		return -1;
	}

	return 0;
}
Пример #27
0
static int
register_req(Conn_t *conn)
{
  Reg_t *tmp;
  Lecdb_t *ltmp;

  Debug_unit(&conn_unit, "Register_req called");
  dump_conn(conn);
  assert(control_packet != NULL);

  /* If trying to register a multicast or broadcast address, reject */
  if (is_multicast(&control_packet->source)) {
    send_register_response(conn->sfd, control_packet,
			   LE_STATUS_BAD_DEST, 1);
    return 1;
  }

  /* Check lecid */
  ltmp = leciddb_find(control_packet->lecid);
  if (!ltmp) {
    send_register_response(conn->sfd, control_packet,
			   LE_STATUS_BAD_LECID, 1);
    return 1;
  }
  tmp = regdb_find_mac(control_packet->source);
  if (tmp == NULL) {
    /* Unregistered MAC, registering... */
    dump_addr(&control_packet->source);
    dump_printf(EL_CONT,"\n");

    regdb_add(control_packet->source_addr, control_packet->source);
    send_register_response(conn->sfd, control_packet,
			   LE_STATUS_SUCCESS, 1);
  } else {
    if (memcmp(&tmp->atm_address,&control_packet->source_addr, 
	       sizeof(AtmAddr_t)) != 0) {
      Debug_unit(&conn_unit, "MAC Address is bound to another ATM address");
      send_register_response(conn->sfd, control_packet,
			     LE_STATUS_DUPLICATE_REG, 1);
    } else {
      Debug_unit(&conn_unit,"Duplicate registeration");
      send_register_response(conn->sfd, control_packet,
			     LE_STATUS_SUCCESS, 1);
    }
  }
  return 1;
}
Пример #28
0
void dump_expr_if(const expr *e, dump *ctx)
{
	dump_desc_expr(ctx, "conditional", e);

	dump_inc(ctx);

	dump_expr(e->expr, ctx);

	if(e->lhs)
		dump_expr(e->lhs, ctx);
	else
		dump_printf(ctx, "?: lhs\n");

	dump_expr(e->rhs, ctx);

	dump_dec(ctx);
}
Пример #29
0
static int
arp_find(Conn_t *conn)
{
  Reg_t *tmp;
  Lecdb_t *ltmp;
  
  Debug_unit(&conn_unit, "Arp_find called");
  dump_conn(conn);

  Debug_unit(&conn_unit,"Arping for:");
  dump_addr(&control_packet->target);
  dump_printf(EL_CONT,"\n");

  /* If requested multicast /broadcast address, respond with BUS address */
  if (is_multicast(&control_packet->target)) {
    tmp = mem_alloc(&conn_unit, sizeof(Reg_t));
    memcpy(&tmp->atm_address, get_var_addr(&conn_unit, "S6"), 
	   sizeof(AtmAddr_t));
    Debug_unit(&conn_unit,"Arp for multicast address");
    send_arp_response(conn->sfd, control_packet,
		      LE_STATUS_SUCCESS, tmp);
    return 1;
  }

  /* Check lecid */
  ltmp = leciddb_find(control_packet->lecid);
  if (!ltmp) {
    send_arp_response(conn->sfd, control_packet,
		      LE_STATUS_BAD_LECID, NULL);
    return 1;
  }
  tmp = regdb_find_mac(control_packet->target);
  if (tmp) {
    Debug_unit(&conn_unit,"Address in databases");
    /* Send response */
    send_arp_response(conn->sfd, control_packet,
		      LE_STATUS_SUCCESS,
		      tmp);
    return 1;
  }
  forward_arp_request(control_packet, proxylist);
  return 1;
}
static int process_sample_event(event_t *event, struct perf_session *session)
{
	struct addr_location al;

	dump_printf("(IP, %d): %d: %p\n", event->header.misc,
		    event->ip.pid, (void *)(long)event->ip.ip);

	if (event__preprocess_sample(event, session, &al, NULL) < 0) {
		fprintf(stderr, "problem processing %d event, skipping it.\n",
			event->header.type);
		return -1;
	}

	if (!al.filtered && perf_session__add_hist_entry(session, &al, 1)) {
		fprintf(stderr, "problem incrementing symbol count, "
				"skipping event\n");
		return -1;
	}

	return 0;
}