예제 #1
0
char* getDemangledName(bfd* abfd, const char* name)
{
    // strip ./$ prefix
    if (name[0] == '.' || name[0] == '$') name++;

    // strip various known symbol prefixes
    if (const char* strip = getStripPrefix(name))
    {
        name = stripPrefixWild(name, strip);
    }

    // strip /... prefix
    if (name[0] == '/')
    {
        const char* dot = strchr(name, '.');
        if (dot) name = dot + 1;
    }

    // strip $rodata suffix before demangling
    if (const char* rodata = findRodataSuffix(name))
    {
        std::string temp(name, rodata);

        char* rawname = getDemangledNameRaw(abfd, temp.c_str());
        char* result = rawname ? concatStrings(rawname, " rodata") : 0;

        free(rawname);

        return result;
    }
    else
        return getDemangledNameRaw(abfd, name);
}
//Broadcasts readings
void broadcastReadings(float* rawReadings, char** units)
{
  logMsg("Broadcasting readings. . .", "INFO");
  //Requires an array of readings and an array of units
  int readingsLength = sizeof(*rawReadings)/sizeof(rawReadings[0]);
  int unitsLength = sizeof(*units)/sizeof(units[0]);
  
  if(readingsLength == unitsLength){

    char** formattedReadings;
    for(int j = 0; j < readingsLength ; ++j){
      strcpy(formattedReadings[j], floatToString(rawReadings[j]));
    }
    char* messageToBroadcast;
    for(int i = 0; i < readingsLength && i < unitsLength; ++i){
      //Put reading/unit pairs into message
      char* toAdd[] = {formattedReadings[i], MESSAGE_DELIMITER, units[i], MESSAGE_DELIMITER};
      messageToBroadcast = concatStrings(toAdd);
    }

//    sendMessage(messageToBroadcast, READING_IDENTIFIER);
  }
  else{
    logMsg("Readings and units vectors different lengths; they need to be the same size.", "ERROR"); 
  }
}
예제 #3
0
//Broadcasts readings
void broadcastReadings(float* rawReadings, char** units)
{
  logMsg("Broadcasting readings. . .", "INFO");
  //Requires an array of readings and an array of units
  int readingsLength = sizeof(*rawReadings)/sizeof(rawReadings[0]);
  int unitsLength = sizeof(*units)/sizeof(units[0]);
  
  char* messageToBroadcast;
  if(readingsLength == unitsLength){
    for(int i = 0; i < readingsLength && i < unitsLength; ++i){
      //Put reading/unit pairs into message
      char* temp = floatToString(rawReadings[i]);
      char* toAdd[] = {floatToString(rawReadings[i]), MESSAGE_DELIMITER, units[i]};
      char* newMsg[] = {messageToBroadcast, concatStrings(toAdd, sizeof(toAdd)/sizeof(toAdd[0]))};
      messageToBroadcast = concatStrings(newMsg, sizeof(newMsg)/sizeof(newMsg[0]));
    }
 //   Serial.println(messageToBroadcast);
    sendMessage(messageToBroadcast, READING_IDENTIFIER);
  }
  else{
    logMsg("Readings and units vectors different lengths; they need to be the same size.", "ERROR"); 
  }
}
예제 #4
0
void adjustSearchPath( _TCHAR* vmLib ){
	_TCHAR ** paths;
	_TCHAR* cwd = NULL;
	_TCHAR * path = NULL, *newPath = NULL;
	_TCHAR * c;
	int i, length;
	int needAdjust = 0, freePath = 0;
	
	paths = getVMLibrarySearchPath(vmLib);
	
	/* bug 325902 - add current working dir to the end of the search path */
	length = GetCurrentDirectory(0, NULL);
	cwd = malloc((length + 1)* sizeof(_TCHAR));
	GetCurrentDirectory(length, cwd);
	cwd[length - 1] = pathSeparator;
	cwd[length] = 0;
	
	/* first call to GetEnvironmentVariable tells us how big to make the buffer */
	length = GetEnvironmentVariable(_T_ECLIPSE("PATH"), path, 0);
	if (length > 0) {
		_TCHAR* current [] = { cwd, NULL };
		path = malloc(length * sizeof(_TCHAR));
		GetEnvironmentVariable(_T_ECLIPSE("PATH"), path, length);
		needAdjust = !containsPaths(path, paths) || !containsPaths(path, current);
		freePath = 1;
	} else {
		path = _T_ECLIPSE("");
		freePath = 0;
		needAdjust = 1;
	}
	
	if (needAdjust) {
		c = concatStrings(paths);
		newPath = malloc((_tcslen(c) + length + 1 + _tcslen(cwd) + 1) * sizeof(_TCHAR));
		_stprintf(newPath, _T_ECLIPSE("%s%s%c%s"), c, path, pathSeparator, cwd);
		SetEnvironmentVariable( _T_ECLIPSE("PATH"), newPath);
		free(c);
		free(newPath);
	}
	
	for (i = 0; paths[i] != NULL; i++)
		free(paths[i]);
	free(paths);
	free(cwd);
	if (freePath)
		free(path);
}
예제 #5
0
파일: client.c 프로젝트: hpc/Spindle
char *client_library_load(const char *name)
{
   char *newname;
   int errcode;

   check_for_fork();
   if (!use_ldcs || ldcsid == -1) {
      return (char *) name;
   }
   if (!(opts & OPT_RELOCSO)) {
      return (char *) name;
   }
   
   /* Don't relocate a new copy of libc, it's always already loaded into the process. */
   find_libc_name();
   if (libc_name && strcmp(name, libc_name) == 0) {
      debug_printf("la_objsearch not redirecting libc %s\n", name);
      test_log(name);
      return (char *) name;
   }
   
   sync_cwd();

   get_relocated_file(ldcsid, name, &newname, &errcode);
 
   if(!newname) {
      newname = concatStrings(NOT_FOUND_PREFIX, name);
   }
   else {
      patch_on_load_success(newname, name);
   }

   debug_printf("la_objsearch redirecting %s to %s\n", name, newname);
   test_log(newname);
   return newname;
}