예제 #1
0
파일: pdwinnt.C 프로젝트: hira-a/dyninst
char *cplus_demangle(char *c, int, bool includeTypes) { 
    char buf[1000];
    if (c[0]=='_') {
       // VC++ 5.0 seems to decorate C symbols differently to C++ symbols
       // and the UnDecorateSymbolName() function provided by imagehlp.lib
       // doesn't manage (or want) to undecorate them, so it has to be done
       // manually, removing a leading underscore from functions & variables
       // and the trailing "$stuff" from variables (actually "$Sstuff")
       unsigned i;
       for (i=1; i<sizeof(buf) && c[i]!='$' && c[i]!='\0'; i++)
           buf[i-1]=c[i];
       buf[i-1]='\0';
       stripAtSuffix(buf);
       if (buf[0] == '\0') return 0; // avoid null names which seem to annoy Paradyn
       return P_strdup(buf);
    } else {
       if (includeTypes) {
          if (UnDecorateSymbolName(c, buf, 1000, UNDNAME_COMPLETE| UNDNAME_NO_ACCESS_SPECIFIERS|UNDNAME_NO_MEMBER_TYPE|UNDNAME_NO_MS_KEYWORDS)) {
            //   printf("Undecorate with types: %s = %s\n", c, buf);
            stripAtSuffix(buf);
            return P_strdup(buf);
          }
       }  else if (UnDecorateSymbolName(c, buf, 1000, UNDNAME_NAME_ONLY)) {
         //     else if (UnDecorateSymbolName(c, buf, 1000, UNDNAME_COMPLETE|UNDNAME_32_BIT_DECODE)) {
         //	printf("Undecorate: %s = %s\n", c, buf);
         stripAtSuffix(buf);          
         return P_strdup(buf);
       }
    }
    return 0;
}
예제 #2
0
파일: pdwinnt.C 프로젝트: hira-a/dyninst
bool AddressSpace::getDyninstRTLibName() {
    // Set the name of the dyninst RT lib
    if (dyninstRT_name.length() == 0) {
        // Get env variable
        if (getenv("DYNINSTAPI_RT_LIB") != NULL) {
            dyninstRT_name = getenv("DYNINSTAPI_RT_LIB");
        }
        else {
            std::string msg = std::string("Environment variable ") +
               std::string("DYNINSTAPI_RT_LIB") +
               std::string(" has not been defined");
            showErrorCallback(101, msg);
            return false;
        }
    }
    //Canonicalize name
    char *sptr = P_strdup(dyninstRT_name.c_str());
    for (unsigned i=0; i<strlen(sptr); i++)
       if (sptr[i] == '/') sptr[i] = '\\';
    dyninstRT_name = sptr;
    free(sptr);
           
    if (_access(dyninstRT_name.c_str(), 04)) {
        std::string msg = std::string("Runtime library ") + dyninstRT_name +
                       std::string(" does not exist or cannot be accessed!");
        showErrorCallback(101, msg);
        return false;
    }

    return true;
}
예제 #3
0
BPatch_loopTreeNode::BPatch_loopTreeNode(BPatch_basicBlockLoop *l,
        const char *n)
{
    loop = l;
    hierarchicalName = NULL;
    if (n != NULL) {
        hierarchicalName = P_strdup(n);
    }
}
예제 #4
0
//
// This procedure is used when paradyn create a process after 
// reading a configuration file (using option -f).
//
void
ParadynTkGUI::ProcessCmd(pdstring *args)
{

  pdstring command;
  command = pdstring("paradyn process ") + (*args);

  if (Tcl_VarEval(interp,command.c_str(),0)==TCL_ERROR) {
    pdstring msg = pdstring("Tcl interpreter failed in routine ProcessCmd: ");
    msg += pdstring(Tcl_GetStringResult(interp));
    msg += pdstring("Was processing: ");
    msg += command;
    uiMgr->showError(83, P_strdup(msg.c_str()));
  }  
  delete args;
}
예제 #5
0
파일: DMmetric.C 프로젝트: dyninst/paradyn
pdvector<metricInstance*> *metricInstance::query(metric_focus_pair metfocus)
{
    resourceListHandle focus_handle=resourceList::getResourceList(metfocus.res);
    pdvector<metricInstance*> *result=new pdvector<metricInstance*>;

    dictionary_hash_iter<metricInstanceHandle,metricInstance *> 
			allMI(allMetricInstances);
    metricInstanceHandle handle;
    metricInstance *mi;
    while(allMI.next(handle,mi)){
    	if (metfocus.met != UNUSED_METRIC_HANDLE) {
   	    if((mi->getMetricHandle() == metfocus.met) && (mi->getFocusHandle() == focus_handle)){
	       *result += mi;
	       return result;
	    }
	}else {
	       pdvector<resourceHandle> *mi_focus=resourceList::getResourceHandles(mi->getFocusHandle());
	       assert(mi_focus != NULL);

	       pdstring mi_focus_name = resource::DMcreateRLname(*mi_focus);
	       delete mi_focus;
	       pdstring focus_name = resource::DMcreateRLname(metfocus.res);
	       char *focus_name_str = P_strdup(focus_name.c_str());

	       pdstring focus_code("/Code");
	       pdstring focus_machine("/Machine");
	       pdstring focus_sync("/SyncObject");
	       int  index=0;
	       char *pos = strtok(const_cast<char *>(focus_name_str),",");
	       for (; pos != NULL; pos=strtok(NULL,","))
	       {
	       	    index++;
		    if (index == 1)
		    	focus_code=pos;
		    else if (index == 2)
		    	focus_machine=pos;
		    else if (index == 3)
		    	focus_sync=pos;
	       }
	       delete focus_name_str;

	       char *mi_focus_str = P_strdup(mi_focus_name.c_str());
	       pdstring mi_code("/Code");
	       pdstring mi_machine("/Machine");
	       pdstring mi_sync("/SyncObject");
	       index=0;
	       pos = strtok(const_cast<char *>(mi_focus_str),",");
	       for (; pos; pos=strtok(NULL,","))
	       {
	       	    index++;
		    if (index == 1)
		    	mi_code=pos;
		    else if (index == 2)
		    	mi_machine=pos;
		    else if (index == 3)
		    	mi_sync=pos;
	       }
	       delete mi_focus_str;

	       if (focus_code == mi_code && focus_machine.prefix_of(mi_machine) && focus_sync.prefix_of(mi_sync))
	       		*result += mi;
	}
    }
    return result;

}