Exemplo n.º 1
0
/*********************************************************
  NAME         : DisplayGenericCore
  DESCRIPTION  : Prints out a description of a core
                   frame of applicable methods for
                   a particular call of a generic function
  INPUTS       : The generic function
  RETURNS      : Nothing useful
  SIDE EFFECTS : None
  NOTES        : None
 *********************************************************/
static void DisplayGenericCore(
  DEFGENERIC *gfunc)
  {
   register int i;
   char buf[256];
   int rtn = FALSE;

   for (i = 0 ; i < gfunc->mcnt ; i++)
     {
      gfunc->methods[i].busy++;
      if (IsMethodApplicable(&gfunc->methods[i]))
        {
         rtn = TRUE;
         PrintRouter(WDISPLAY,GetDefgenericName((void *) gfunc));
         PrintRouter(WDISPLAY," #");
         PrintMethod(buf,255,&gfunc->methods[i]);
         PrintRouter(WDISPLAY,buf);
         PrintRouter(WDISPLAY,"\n");
#if ! IMPERATIVE_METHODS
         break;
#endif
        }
      gfunc->methods[i].busy--;
     }
   if (rtn == FALSE)
     {
      PrintRouter(WDISPLAY,"No applicable methods for ");
      PrintRouter(WDISPLAY,GetDefgenericName((void *) gfunc));
      PrintRouter(WDISPLAY,".\n");
     }
  }
Exemplo n.º 2
0
/*********************************************************
  NAME         : DisplayGenericCore
  DESCRIPTION  : Prints out a description of a core
                   frame of applicable methods for
                   a particular call of a generic function
  INPUTS       : The generic function
  RETURNS      : Nothing useful
  SIDE EFFECTS : None
  NOTES        : None
 *********************************************************/
static void DisplayGenericCore(
  void *theEnv,
  DEFGENERIC *gfunc)
  {
   long i;
   char buf[256];
   int rtn = FALSE;

   for (i = 0 ; i < gfunc->mcnt ; i++)
     {
      gfunc->methods[i].busy++;
      if (IsMethodApplicable(theEnv,&gfunc->methods[i]))
        {
         rtn = TRUE;
         EnvPrintRouter(theEnv,WDISPLAY,EnvGetDefgenericName(theEnv,(void *) gfunc));
         EnvPrintRouter(theEnv,WDISPLAY,(char*)" #");
         PrintMethod(theEnv,buf,255,&gfunc->methods[i]);
         EnvPrintRouter(theEnv,WDISPLAY,buf);
         EnvPrintRouter(theEnv,WDISPLAY,(char*)"\n");
        }
      gfunc->methods[i].busy--;
     }
   if (rtn == FALSE)
     {
      EnvPrintRouter(theEnv,WDISPLAY,(char*)"No applicable methods for ");
      EnvPrintRouter(theEnv,WDISPLAY,EnvGetDefgenericName(theEnv,(void *) gfunc));
      EnvPrintRouter(theEnv,WDISPLAY,(char*)".\n");
     }
  }
Exemplo n.º 3
0
void
RPCProxy::Done(FRT_RPCRequest *req)
{
    PrintMethod(req, "RETURN");
    if (IsVerbose()) {
        req->GetReturn()->Print(8);
    }
    req->Return();
}
Exemplo n.º 4
0
S32 dCheckStart(U8 *pData, U32 uiLen, U8 *szTID)
{
	U16			usMethod = 0;
	S32			dRet;

	if((dRet = msrpheader((char*)pData, uiLen, &usMethod, (char*)szTID)) != 0) {
		log_print(LOGN_CRI, "F=%s:%s.%d FAIL PARSING dRet=%d", 
					__FILE__, __FUNCTION__, __LINE__, dRet);
		return 0;	
	}

	if(szTID[0] == 0x00) {
		log_print(LOGN_INFO, "%s msrpheader NO START TID IS NULL", __FUNCTION__);
		return 0;
	}

	log_print(LOGN_INFO, "PARSING Method=%d:%s TID=%s", usMethod, PrintMethod(usMethod), szTID);
	return 1;
}
Exemplo n.º 5
0
void InitLog(stMEMSINFO *pstMEMSINFO, st_MSRPT_INFO *pstMSRPTINFO, TEXT_INFO *pstTEXTINFO, LOG_MSRP_TRANS *pLOG)
{
	/* Call Common */
	pLOG->uiCallTime = pstTEXTINFO->uiStartTime;
	pLOG->uiCallMTime = pstTEXTINFO->uiStartMTime;
//	pLOG->uiNASName = pstTEXTINFO->clientIP;
	pLOG->uiNASName = 0;

	if(pLOG->usSvcL7Type == APP_IM_UP) {
		memcpy(pLOG->szMIN, pstMSRPTINFO->szMIN, MAX_MIN_LEN);
		pLOG->szMIN[MAX_MIN_LEN] = 0x00;
	}

	pLOG->Vendor = pstMSRPTINFO->usVendor;

	/* LOG */
    pLOG->TransStartTime = pstTEXTINFO->uiStartTime;
    pLOG->TransStartMTime = pstTEXTINFO->uiStartMTime;
	memcpy(pLOG->MSGID, pstMSRPTINFO->szMSGID, MSRP_MSGID_LEN);
	pLOG->MSGID[MSRP_MSGID_LEN] = 0x00;
	pLOG->method = pstMSRPTINFO->usMethod;
	sprintf((char*)pLOG->MethodString, "%s", PrintMethod(pstMSRPTINFO->usMethod));
	memcpy(pLOG->ToPath, pstMSRPTINFO->szToPath, MSRP_PATH_LEN);
	pLOG->ToPath[MSRP_PATH_LEN] = 0x00;
	memcpy(pLOG->FromPath, pstMSRPTINFO->szFromPath, MSRP_PATH_LEN);
	pLOG->FromPath[MSRP_PATH_LEN] = 0x00;
	pLOG->SuccessReport = pstMSRPTINFO->usSuccessReport;
	pLOG->FailureReport = pstMSRPTINFO->usFailureReport;
	memcpy(pLOG->ContentsType, pstMSRPTINFO->szContentType, MSRP_CONTENTTYPE_LEN);
	pLOG->ContentsType[MSRP_CONTENTTYPE_LEN] = 0x00;
    pLOG->SrcIP = pstTEXTINFO->clientIP;
    pLOG->DestIP = pstTEXTINFO->serverIP;
    pLOG->SrcPort = pstTEXTINFO->clientPort;
    pLOG->DestPort = pstTEXTINFO->serverPort;
	if(pstTEXTINFO->uiAckTime == 0) {
    	pLOG->TransEndTime = pstTEXTINFO->uiStartTime;
    	pLOG->TransEndMTime = pstTEXTINFO->uiStartMTime;
	} else {
    	pLOG->TransEndTime = pstTEXTINFO->uiAckTime;
    	pLOG->TransEndMTime = pstTEXTINFO->uiAckMTime;
	}
}
Exemplo n.º 6
0
void
RPCProxy::HOOK_Mismatch(FRT_RPCRequest *req)
{
    PrintMethod(req, "INVOKE");
    if (IsVerbose()) {
        req->GetParams()->Print(8);
    }
    req->Detach();
    req->SetError(FRTE_NO_ERROR, "");
    if (req->GetConnection()->IsServer() && GetSession(req)->server != nullptr)
    {
        GetSession(req)->server->InvokeAsync(req, 60.0, &req->getStash().create<ReqDone>(*this));
    } else if (req->GetConnection()->IsClient() && GetSession(req)->client != nullptr)
    {
        FRT_Supervisor::InvokeAsync(GetSession(req)->client->Owner(), GetSession(req)->client,
                                    req, 60.0, &req->getStash().create<ReqDone>(*this));
    } else {
        req->SetError(FRTE_RPC_CONNECTION);
        req->Return();
    }
}
Exemplo n.º 7
0
void Runtime::Debugger::ProcessPrint(Print* print) {
  Expression* expression = print->GetExpression();
  EvaluateExpression(expression);

  if(!is_error) {
    switch(expression->GetExpressionType()) {
    case REF_EXPR:
      if(interpreter) {
        Reference* reference = static_cast<Reference*>(expression);
        while(reference->GetReference()) {
          reference = reference->GetReference();
        }

        const StackDclr& dclr_value =  static_cast<Reference*>(reference)->GetDeclaration();
        switch(dclr_value.type) {
        case CHAR_PARM:
          if(reference->GetIndices()) {
            wcout << L"cannot reference scalar variable" << endl;
          }
          else {
            wcout << L"print: type=Char, value=" << (wchar_t)reference->GetIntValue() << endl;
          }
          break;

        case INT_PARM:
          if(reference->GetIndices()) {
            wcout << L"cannot reference scalar variable" << endl;
          }
          else {
            wcout << L"print: type=Int, value=" << reference->GetIntValue() << endl;
          }
          break;


        case FLOAT_PARM:
          if(reference->GetIndices()) {
            wcout << L"cannot reference scalar variable" << endl;
          }
          else {
            wcout << L"print: type=Float, value=" << reference->GetFloatValue() << endl;
          }
          break;

        case BYTE_ARY_PARM:
          if(reference->GetIndices()) {
            wcout << L"print: type=Int, value=" << (unsigned char)reference->GetIntValue() << endl;
          }
          else {
            wcout << L"print: type=Byte[], value=" << reference->GetIntValue()
									<< L"(" << (void*)reference->GetIntValue() << L")";
            if(reference->GetArrayDimension()) {
              wcout << L", dimension=" << reference->GetArrayDimension() << L", size="
										<< reference->GetArraySize();
            }
            wcout << endl;
          }
          break;

        case CHAR_ARY_PARM:
          if(reference->GetIndices()) {
            wcout << L"print: type=Char, value=" << (wchar_t)reference->GetIntValue() << endl;
          }
          else {
            wcout << L"print: type=Char[], value=" << reference->GetIntValue()
									<< L"(" << (void*)reference->GetIntValue() << L")";
            if(reference->GetArrayDimension()) {
              wcout << L", dimension=" << reference->GetArrayDimension() << L", size="
										<< reference->GetArraySize();
            }
            wcout << endl;
          }
          break;

        case INT_ARY_PARM:
          if(reference->GetIndices()) {
            wcout << L"print: type=Int, value=" << reference->GetIntValue() << endl;
          }
          else {
            wcout << L"print: type=Int[], value=" << reference->GetIntValue()
									<< L"(" << (void*)reference->GetIntValue() << L")";
            if(reference->GetArrayDimension()) {
              wcout << L", dimension=" << reference->GetArrayDimension() << L", size="
										<< reference->GetArraySize();
            }
            wcout << endl;
          }
          break;

        case FLOAT_ARY_PARM:
          if(reference->GetIndices()) {
            wcout << L"print: type=Float, value=" << reference->GetFloatValue() << endl;
          }
          else {
            wcout << L"print: type=Float[], value=" << reference->GetIntValue()
									<< L"(" << (void*)reference->GetIntValue() << L")";
            if(reference->GetArrayDimension()) {
              wcout << L", dimension=" << reference->GetArrayDimension() << L", size="
										<< reference->GetArraySize();
            }
            wcout << endl;
          }
          break;

        case OBJ_PARM:
          if(ref_klass && ref_klass->GetName() == L"System.String") {
            long* instance = (long*)reference->GetIntValue();
            if(instance) {
              long* string_instance = (long*)instance[0];
              const wchar_t* char_string = (wchar_t*)(string_instance + 3);
              wcout << L"print: type=" << ref_klass->GetName() << L", value=\""
										<< char_string << L"\"" << endl;
            }
            else {
              wcout << L"print: type=" << (ref_klass ? ref_klass->GetName() : L"System.Base") << L", value="
										<< (void*)reference->GetIntValue() << endl;
            }
          }
          else {
            wcout << L"print: type=" << (ref_klass ? ref_klass->GetName() : L"System.Base") << L", value="
									<< (void*)reference->GetIntValue() << endl;
          }
          break;

        case OBJ_ARY_PARM:
          if(reference->GetIndices()) {
            StackClass* klass = MemoryManager::GetClass((long*)reference->GetIntValue());
            if(klass) {	      
              long* instance = (long*)reference->GetIntValue();
              if(instance) {
                wcout << L"print: type=" << klass->GetName() << L", value=" << (void*)reference->GetIntValue() << endl;
              }
              else {
                wcout << L"print: type=System.Base, value=" << (void*)reference->GetIntValue() << endl;
              }
            }
            else {
              wcout << L"print: type=System.Base, value=" << (void*)reference->GetIntValue() << endl;
            }
          }
          else {
            wcout << L"print: type=System.Base[], value=" << (void*)reference->GetIntValue();
            if(reference->GetArrayDimension()) {
              wcout << L", dimension=" << reference->GetArrayDimension() << L", size="
										<< reference->GetArraySize();
            }
            wcout << endl;
          }
          break;

        case FUNC_PARM: {
          StackClass* klass = cur_program->GetClass(reference->GetIntValue());
          if(klass) {
            wcout << L"print: type=Functon, class=" << klass->GetName() 
									<< L", method=" << PrintMethod(klass->GetMethod(reference->GetIntValue2())) << endl;
          }
				}
					break;
        }
      }
      else {
        wcout << L"program is not running." << endl;
        is_error = true;
      }
      break;

    case NIL_LIT_EXPR:
      wcout << L"print: type=Nil, value=Nil" << endl;
      break;

    case CHAR_LIT_EXPR:
      wcout << L"print: type=Char, value=" << (char)expression->GetIntValue() << endl;
      break;

    case INT_LIT_EXPR:
      wcout << L"print: type=Int, value=" << expression->GetIntValue() << endl;
      break;

    case FLOAT_LIT_EXPR:
      wcout << L"print: type=Float, value=" << expression->GetFloatValue() << endl;
      break;

    case BOOLEAN_LIT_EXPR:
      wcout << L"print: type=Bool, value=" << (expression->GetIntValue() ? "true" : "false" ) << endl;
      break;

    case AND_EXPR:
    case OR_EXPR:
    case EQL_EXPR:
    case NEQL_EXPR:
    case LES_EXPR:
    case GTR_EQL_EXPR:
    case LES_EQL_EXPR:
    case GTR_EXPR:
      wcout << L"print: type=Bool, value=" << (expression->GetIntValue() ? "true" : "false" ) << endl;
      break;

    case ADD_EXPR:
    case SUB_EXPR:
    case MUL_EXPR:
    case DIV_EXPR:
    case MOD_EXPR:
      if(expression->GetFloatEval()) {
        wcout << L"print: type=Float, value=" << expression->GetFloatValue() << endl;
      }
      else {
        wcout << L"print: type=Int, value=" << expression->GetIntValue() << endl;
      }
      break;

    case CHAR_STR_EXPR:
      break;
    }
  }
}
Exemplo n.º 8
0
void Runtime::Debugger::ProcessInfo(Info* info) {
  const wstring &cls_name = info->GetClassName();
  const wstring &mthd_name = info->GetMethodName();

#ifdef _DEBUG
  wcout << L"--- info class=" << cls_name << L", method=" << mthd_name << L" ---" << endl;
#endif

  if(interpreter) {
    // method info
    if(cls_name.size() > 0 && mthd_name.size() > 0) {
      StackClass* klass = cur_program->GetClass(cls_name);
      if(klass && klass->IsDebug()) {
        vector<StackMethod*> methods = klass->GetMethods(mthd_name);
        if(methods.size() > 0) {
          for(size_t i = 0; i < methods.size(); i++) {
            StackMethod* method = methods[i];
            wcout << L"  class: type=" << klass->GetName() << L", method="
									<< PrintMethod(method) << endl;
						if(method->GetNumberDeclarations() > 0) {
							wcout << L"  parameters:" << endl;
							PrintDeclarations(method->GetDeclarations(), method->GetNumberDeclarations());
						}
          }
        }
        else {
          wcout << L"unable to find method." << endl;
          is_error = true;
        }
      }
      else {
        wcout << L"unable to find class." << endl;
        is_error = true;
      }
    }
    // class info
    else if(cls_name.size() > 0) {
      StackClass* klass = cur_program->GetClass(cls_name);
      if(klass && klass->IsDebug()) {
        wcout << L"  class: type=" << klass->GetName() << endl;
        // print
        wcout << L"  parameters:" << endl;
				if(klass->GetNumberInstanceDeclarations() > 0) {
					PrintDeclarations(klass->GetInstanceDeclarations(), klass->GetNumberInstanceDeclarations());
				}
      }
      else {
        wcout << L"unable to find class." << endl;
        is_error = true;
      }
    }
    // general info
    else {
      wcout << L"general info:" << endl;
      wcout << L"  program executable: file='" << program_file << L"'" << endl;

      // parse method and class names
      const wstring &long_name = cur_frame->method->GetName();
      int end_index = long_name.find_last_of(':');
      const wstring &cls_mthd_name = long_name.substr(0, end_index);

      int mid_index = cls_mthd_name.find_last_of(':');
      const wstring &cls_name = cls_mthd_name.substr(0, mid_index);
      const wstring &mthd_name = cls_mthd_name.substr(mid_index + 1);

      // print
      wcout << L"  current file='" << cur_file_name << L":" << cur_line_num << L"', method='"
						<< cls_name << L"->" << mthd_name << L"(..)'" << endl;
    }
  }
  else {
    wcout << L"program is not running." << endl;
  }
}
Exemplo n.º 9
0
Command* Runtime::Debugger::ProcessCommand(const wstring &line) {
#ifdef _DEBUG
  wcout << L"input: |" << line << L"|" << endl;
#endif

  // parser input
  is_next = is_next_line = false;
  Parser parser;
  Command* command = parser.Parse(L"?" + line);
  if(command) {
    switch(command->GetCommandType()) {
    case EXE_COMMAND:
      ProcessExe(static_cast<Load*>(command));
      break;

    case SRC_COMMAND:
      ProcessSrc(static_cast<Load*>(command));
      break;

    case ARGS_COMMAND:
      ProcessArgs(static_cast<Load*>(command));
      break;

    case QUIT_COMMAND:
      ClearBreaks();
      ClearProgram();
      wcout << L"goodbye." << endl;
      exit(0);
      break;

    case LIST_COMMAND: {
      FilePostion* file_pos = static_cast<FilePostion*>(command);

      wstring file_name;
      if(file_pos->GetFileName().size() > 0) {
        file_name = file_pos->GetFileName();
      }
      else {
        file_name = cur_file_name;
      }

      int line_num;
      if(file_pos->GetLineNumber() > 0) {
        line_num = file_pos->GetLineNumber();
      }
      else {
        line_num = cur_line_num;
      }

      const wstring &path = base_path + file_name;
      if(FileExists(path) && line_num > 0) {
        SourceFile src_file(path, cur_line_num);
        if(!src_file.Print(line_num)) {
          wcout << L"invalid line number." << endl;
          is_error = true;
        }
      }
      else {
        wcout << L"source file or line number doesn't exist, ensure the program is running." << endl;
        is_error = true;
      }
    }
      break;

    case BREAK_COMMAND:
      ProcessBreak(static_cast<FilePostion*>(command));
      break;

    case BREAKS_COMMAND:
      ProcessBreaks();
      break;

    case PRINT_COMMAND:
      ProcessPrint(static_cast<Print*>(command));
      break;

    case RUN_COMMAND:
      if(!cur_program) {
        ProcessRun();
      }
      else {
        wcout << L"instance already running." << endl;
        is_error = true;
      }
      break;

    case CLEAR_COMMAND: {
      wcout << L"  are sure you want to clear all breakpoints? [y/n] ";
      wstring line;
      getline(wcin, line);
      if(line == L"y" || line == L"yes") {
        ClearBreaks();
      }
    }
      break;

    case DELETE_COMMAND:
      ProcessDelete(static_cast<FilePostion*>(command));
      break;

    case NEXT_COMMAND:
      if(interpreter) {
        is_next = true;
      }
      else {
        wcout << L"program is not running." << endl;
      }
      break;

    case NEXT_LINE_COMMAND:
      if(interpreter) {
        is_next_line = true;
      }
      else {
        wcout << L"program is not running." << endl;
      }
      break;

    case JUMP_OUT_COMMAND:
      if(interpreter) {
        is_jmp_out = true;
      }
      else {
        wcout << L"program is not running." << endl;
      }
      break;

    case CONT_COMMAND:
      if(!interpreter) {
        wcout << L"program is not running." << endl;
      }
      cur_line_num = -2;
      break;

    case INFO_COMMAND:
      ProcessInfo(static_cast<Info*>(command));
      break;

    case STACK_COMMAND:
      if(interpreter) {
        wcout << L"stack:" << endl;
        StackMethod* method = cur_frame->method;
        wcerr << L"  frame: pos=" << cur_call_stack_pos << L", class=" << method->GetClass()->GetName() 
							<< L", method=" << PrintMethod(method);
        const long ip = cur_frame->ip;
        if(ip > -1) {
          StackInstr* instr = cur_frame->method->GetInstruction(ip);
          wcerr << L", file=" << method->GetClass()->GetFileName() << L":" << instr->GetLineNumber() << endl;
        }
        else {
          wcerr << endl;
        }

        long pos = cur_call_stack_pos - 1;
        do {
          StackMethod* method = cur_call_stack[pos]->method;
          wcerr << L"  frame: pos=" << pos << L", class=" << method->GetClass()->GetName() 
								<< L", method=" << PrintMethod(method);
          const long ip = cur_call_stack[pos]->ip;
          if(ip > -1) {
            StackInstr* instr = cur_call_stack[pos]->method->GetInstruction(ip);
            wcerr << L", file=" << method->GetClass()->GetFileName() << L":" << instr->GetLineNumber() << endl;
          }
          else {
            wcerr << endl;
          }
        }
        while(--pos);
      }
      else {
        wcout << L"program is not running." << endl;
      }
      break;

    default:
      break;
    }

    is_error = false;
    ref_mem = NULL;
    return command;
  }
  else {
    wcout << L"-- Unable to process command --" << endl;
  }

  is_error = false;
  ref_mem = NULL;
  return NULL;
}