Exemplo n.º 1
0
// Add a log entry
OsStatus OsSysLog::add(const OsSysLogFacility facility,
                       const OsSysLogPriority priority,
                       const char*            format,
                                              ...)
{
   OsStatus rc = OS_UNSPECIFIED;

   // If the log has not been initialized, print everything
   if (!isTaskPtrNull())
   {
      if (willLog(facility, priority))
      {
         UtlString taskName ;
         OsTaskId_t taskId = 0 ;

         va_list ap;
         va_start(ap, format);

         getTaskInfo(taskName, taskId);

         rc = vadd(taskName.data(), taskId, facility, priority, format, ap);         
         va_end(ap);
      }  
   }
   else
      rc = OS_SUCCESS ;

   return rc;
}
Exemplo n.º 2
0
void WndTask::slot_currentChanged( int i_index)
{
	QWidget * tab = m_tab_widget->currentWidget();
	if( tab == m_tab_current ) return;

	m_tab_current = tab;

	if( m_tab_current == m_tab_output)
		getTaskInfo("output", m_output_current);
	else if( m_tab_current == m_tab_log)
		getTaskInfo("log");
	else if( m_tab_current == m_tab_errhosts)
		getTaskInfo("error_hosts");
	else if( m_tab_current == m_tab_listen)
		listen( true);
//	else if( m_tab_current == m_tab_exec)
//		getTaskInfo("info");
}
Exemplo n.º 3
0
// Add a log entry given a variable argument list
OsStatus OsSysLog::vadd(const OsSysLogFacility facility,
                        const OsSysLogPriority priority,
                        const char*            format,
                        va_list                ap)
{
    UtlString taskName;
    OsTaskId_t taskId = 0;

    getTaskInfo(taskName, taskId);

    return(vadd(taskName, taskId, facility, priority, format, ap));
}
Exemplo n.º 4
0
bool Worker::getTasks() {
    vector<string> children;
    int code = zk->getChildren(m_assign_dir, true, &children);

    //LOG_INFO("got children:%d task num:%d", children.size(), m_tasks.size());

    if (code != ZOK) return false;

    //find deleted task
    set<string> tasks(children.begin(), children.end());
    for (map<string, Task*>::iterator it = m_tasks.begin(); it != m_tasks.end(); ) {
        if (tasks.find(it->first) == tasks.end()) {
            //deleted task
            delete it->second;
            LOG_INFO("delete task:%s", it->first.c_str());
            m_tasks.erase(it++);
        } else {
            ++it;
        }
    }

    //find added task
    for (int i = 0; i < children.size(); ++i) {
        if (m_tasks.find(children[i]) == m_tasks.end()) {
            Task *info = getTaskInfo(children[i]);
            if (info != NULL) {
                //new task
                LOG_INFO("add task:%s", children[i].c_str());
                m_tasks[children[i]] = info;
                RunTask(children[i]);
            }
        }
    }

    return true;
}
Exemplo n.º 5
0
void showTasksPage(void)
{
    uint8_t rowIndex = PAGE_TITLE_LINE_COUNT;
    static const char *format = "%2d%6d%5d%4d%4d";

    i2c_OLED_set_line(rowIndex++);
    i2c_OLED_send_string("Task max  avg mx% av%");
    cfTaskInfo_t taskInfo;
    for (cfTaskId_e taskId = 0; taskId < TASK_COUNT; ++taskId) {
        getTaskInfo(taskId, &taskInfo);
        if (taskInfo.isEnabled && taskId != TASK_SERIAL) {// don't waste a line of the display showing serial taskInfo
            const int taskFrequency = (int)(1000000.0f / ((float)taskInfo.latestDeltaTime));
            const int maxLoad = (taskInfo.maxExecutionTime * taskFrequency + 5000) / 10000;
            const int averageLoad = (taskInfo.averageExecutionTime * taskFrequency + 5000) / 10000;
            tfp_sprintf(lineBuffer, format, taskId, taskInfo.maxExecutionTime, taskInfo.averageExecutionTime, maxLoad, averageLoad);
            padLineBuffer();
            i2c_OLED_set_line(rowIndex++);
            i2c_OLED_send_string(lineBuffer);
            if (rowIndex > SCREEN_CHARACTER_ROW_COUNT) {
                break;
            }
        }
    }
}
//  安装故障注入表的设定, 对表中每一项按照要求进行故障注入
//  RT_FAIL,进程已经结束
//  RT_OK,进程没有结束
int Injector::injectFaults( int pid )
{
	int iRet;
	unsigned int i, j;
	taskMMInfo procInfo;
	long start_va, end_va;
	unsigned long random_offset;

    dcout <<"There are" <<this->m_memoryFaultTable.size() <<"works will be done in table" <<endl;
	for( i = 0; i < this->m_memoryFaultTable.size( ); i++ )
	{
/////////////////////
        dcout <<"[" <<__FILE__ <<", " <<__LINE__ <<"]--";
        cout <<this->m_memoryFaultTable[i] <<endl;
/////////////////////
		/// random addr
		srand( time( NULL ) );
        for(j = 0; j < this->m_memoryFaultTable[i].m_time; j++)
        {
        /// location
        dcout <<"==LOCATION==" <<endl;
		if( this->m_memoryFaultTable[i].m_addr == -1 )
		{
			/// get proc information
			bzero(&procInfo, sizeof(procInfo));
            dcout <<"[" <<__FILE__ <<", " <<__LINE__ <<"]--" <<"bzero taskMMInfo success" <<endl;
			iRet = getTaskInfo(pid, &procInfo);
            dcout <<"[" <<__FILE__ <<", " <<__LINE__ <<"]--" <<"get taskMMInfo success" <<endl;

//#ifdef BUGS     //  BUG_3 found in 2016-05-12 13:27 by gatieme@HIT
			//  debug add by gatieme
            //  the address we get is wrong.
            //  the all point to the same virtual address which is not does not belong to the process PID
            //  so when we inject fault in this process we get "an process 8318 termed with signal 11(SIGSEGV)"
            //  SIGSEGV--Signal Segmentation Violation  https://en.wikipedia.org/wiki/Segmentation_fault
			dprintf("code : [0x%lx, 0x%lx]\n", procInfo.start_code, procInfo.end_code);
			dprintf("data : [0x%lx, 0x%lx]\n", procInfo.start_data, procInfo.end_data);
            //  heap从低地址向高地址扩展,做内存管理相对要简单些。
            //  stack从高地址向低地址扩展,这样栈空间的起始位置就能确定下来,动态的调整栈空间大小也不需要移动栈内的数据。
			dprintf("heap : [0x%lx, 0x%lx]\n", procInfo.start_brk, procInfo.brk);
			dprintf("stack: [0x%lx, 0x%lx]\n", procInfo.start_stack - STACK_SIZE, procInfo.start_stack);
#ifdef KERNEL_STACK

			dprintf("kstack: [0x%lx, 0x%lx]\n", procInfo.start_kstack, procInfo.end_kstack);
#endif
            //#endif
			//debug
			if(iRet == FAIL)
			{
				cleanup();
				return RT_FAIL;
			}

			if( this->m_memoryFaultTable[i].m_location == text_area )       //  text segment
			{
				start_va = procInfo.start_code;
				end_va = procInfo.end_code;

                // add by gatieme @2016-01-23
                dprintf("[%s, %d] %d --Inject TEXT segment, [0x%lx, 0x%lx]\n", __FILE__, __LINE__, iRet, start_va, end_va);
            }
			else if( this->m_memoryFaultTable[i].m_location == data_area )  //  data segment
			{
				start_va = procInfo.start_data;
				end_va = procInfo.end_data;

                dprintf("[%s, %d] %d --Inject DATA segment, [0x%lx, 0x%lx]\n", __FILE__, __LINE__, iRet, start_va, end_va);
			}
			else if( this->m_memoryFaultTable[i].m_location == stack_area ) // stack segment
			{
				start_va = procInfo.start_stack - STACK_SIZE;
				end_va = procInfo.start_stack;

                dprintf("[%s, %d] %d --Inject STACK segment, [0x%lx, 0x%lx]\n", __FILE__, __LINE__, iRet, start_va, end_va);
			}
			else if( this->m_memoryFaultTable[i].m_location == kstack_area ) // kstack segment
			{
				start_va = procInfo.start_kstack;
				end_va = procInfo.end_kstack;

                dprintf("[%s, %d] %d --Inject STACK segment, [0x%lx, 0x%lx]\n", __FILE__, __LINE__, iRet, start_va, end_va);
			}
            /*
			// add by gatieme
			printf("inject_va:\t%lx\n", start_va); //add by gatieme,
			inject_pa = virt_to_phys(pid, start_va);
			printf("inject_pa:\t%lx\n", inject_pa); //add by gatieme,

			printf("inject_va:\t%lx\n", end_va); //add by gatieme,
			inject_pa = virt_to_phys(pid, end_va);
			printf("inject_pa:\t%lx\n", inject_pa); //add by gatieme,

			srand( time( NULL ) );
			random_offset = rand() % (end_va - start_va);
			printf("inject_va:\t%lx\n", start_va + random_offset); //add by gatieme,
			inject_pa = virt_to_phys(pid, start_va + random_offset);
			printf("inject_pa:\t%lx\n", inject_pa); //add by gatieme,
			return 0;
            */
			if(end_va == start_va)
				random_offset = 0;
			else
				random_offset = rand() % (end_va - start_va);
            //printf("=======%ld %ld=======\n", random_offset, end_va - start_va);
            //  Convert the virtual address [start_va + random_offset] to physics address [inject_pa]...
            inject_pa = virt_to_phys(pid, start_va + random_offset);

            dprintf("[%s, %d]--Start  Virtual Address = 0x%lx\n", __FILE__, __LINE__, start_va);
            dprintf("[%s, %d]--End    Virtual Address = 0x%lx\n", __FILE__, __LINE__, end_va);
            dprintf("[%s, %d]--Inject Virtual Address = 0x%lx\n", __FILE__, __LINE__, start_va + random_offset);
			dprintf("[%s, %d]--Inject Physics Address = 0x%lx\n", __FILE__, __LINE__, inject_pa);
        }
		else
		{
			inject_pa = this->m_memoryFaultTable[i].m_addr;
			dprintf("[%s, %d]--Inject Physics Address = 0x%lx\n", __FILE__, __LINE__, inject_pa);
		}

        if(inject_pa == -1)
        {
			dprintf("ERROR : [%s, %d]--Inject Physics Address = 0x%lx\n", __FILE__, __LINE__, inject_pa);
            return RT_FAIL;
        }

        if(this->m_memoryFaultTable[i].m_time > 1)
        {
            printf("TIME = %d, ", j + 1);
        }
		dprintf("[%s, %d]--", __FILE__, __LINE__);
		printf("Inject fault at pid:%d, virtual:0x%lx--(physical:0x%lx)\n", pid, start_va + random_offset, inject_pa);

		if(iRet == FAIL)
        {
            dprintf("Error [%s, %d]--iRet =%d\n", __FILE__, __LINE__, iRet);
            return RT_FAIL;
        }

        dprintf("[%s, %d]--iRet =%d, fauletype = %d\n", __FILE__, __LINE__, iRet, this->m_memoryFaultTable[i].m_faultType);
		switch( this->m_memoryFaultTable[i].m_faultType )
		{

			case one_bit_0:

                iRet = read_phy_mem(inject_pa, &origData);
				if(iRet == FAIL) { return RT_FAIL; }

                srand( time( NULL ) );
				newData = origData & ( ~(0x0000000000000001L << (rand()%16)) );

                iRet = write_phy_mem(inject_pa, &newData, sizeof(newData));
				if(iRet == FAIL)
                {
                    return RT_FAIL;
                }

                iRet = read_phy_mem(inject_pa, &newData);
				if(iRet == FAIL) { return RT_FAIL; }

                printf("one bit 0(0x%lx -> 0x%lx)\n", origData, newData);
				break;

            case one_bit_1:
				iRet = read_phy_mem(inject_pa, &origData);
				if(iRet == FAIL) { return RT_FAIL; }

                srand( time( NULL ) );
				newData = origData | (0x0000000000000001L << (rand()%16));
				iRet = write_phy_mem(inject_pa, &newData, sizeof(newData));
				if(iRet == FAIL) { return RT_FAIL; }

                iRet = read_phy_mem(inject_pa, &newData);
				if(iRet == FAIL) { return RT_FAIL; }

                printf("one bit 1(0x%lx -> 0x%lx)\n", origData, newData);
				break;

            case one_bit_flip:

				iRet = read_phy_mem(inject_pa, &origData);
				if(iRet == FAIL) { return RT_FAIL; }

                srand( time( NULL ) );
				newData = origData ^ (0x0000000000000001L << ( rand() % 16 ));
				iRet = write_phy_mem(inject_pa, &newData, sizeof(newData));
				if(iRet == FAIL) { return RT_FAIL; }

                iRet = read_phy_mem(inject_pa, &newData);
				if(iRet == FAIL) { return RT_FAIL; }

                printf("one bit flip(0x%lx -> 0x%lx)\n", origData, newData);
				break;

            case word_0:
                dprintf("FaultType = word_0, inject_pa = 0x%lx\n", inject_pa);

                iRet = read_phy_mem(inject_pa, &origData);
				if(iRet == FAIL)
                {
#if defined(FOR_MISS_MMAP)
                    srand(time(NULL));
				    printf("word 0(0x%lx -> 0x%lx)\n", rand() % 1000000000, ~(-1));
                    sleep(1);
#else               //  for create  error
                    // modify by gatieme
                    dprintf("Error [%s, %d]--iRet = %d\n", __FILE__, __LINE__, iRet);
#endif
                    return RT_FAIL;
                }
				newData = ~(-1);            ///  for DEBUG...

#ifdef BUGS         //  this is bug_1 find in 2016-03-24 by gatieme
                printf("==BUG_1== [%s, %d]--0x%lx -=> 0x%lx\n", __FILE__, __LINE__, rigData, newData);
#endif

                iRet = write_phy_mem(inject_pa, &newData, sizeof(newData));
                if(iRet == FAIL)
                {
                    // modify by gatieme
                    dprintf("Error [%s, %d]--, iRet = %d\n", __FILE__, __LINE__, iRet);
                    return RT_FAIL;
                }

                iRet = read_phy_mem(inject_pa, &newData);
				if(iRet == FAIL)
                {
                    // modify by gatieme
                    dprintf("Error [%s, %d]--, iRet = %d\n", __FILE__, __LINE__, iRet);
                    return RT_FAIL;
                }

				printf("word 0(0x%lx -> 0x%lx)\n", origData, newData);
				break;

            case word_flip  :

                dprintf("FaultType = word_flip, inject_pa = 0x%lx\n", inject_pa);

                iRet = read_phy_mem(inject_pa, &origData);
				if(iRet == FAIL)
                {
                    // modify by gatieme
                    dprintf("Error [%s, %d]--iRet = %d\n", __FILE__, __LINE__, iRet);
                    return RT_FAIL;
                }
				newData = ~origData;

                iRet = write_phy_mem(inject_pa, &newData, sizeof(newData));
                if(iRet == FAIL)
                {
                    // modify by gatieme
                    dprintf("Error [%s, %d]--, iRet = %d\n", __FILE__, __LINE__, iRet);
                    return RT_FAIL;
                }

                iRet = read_phy_mem(inject_pa, &newData);
				if(iRet == FAIL)
                {
                    // modify by gatieme
                    dprintf("Error [%s, %d]--, iRet = %d\n", __FILE__, __LINE__, iRet);
                    return RT_FAIL;
                }

				printf("word flip(0x%lx -> 0x%lx)\n", origData, newData);
				break;

            case page_0:
				iRet = write_page_0(inject_pa);
				if(iRet == FAIL)
                {
                    return RT_FAIL;
                }

                dprintf("page 0\n");
				break;
			default:
				printf("Do not support yet.\n");
		    }
        //writeResult(pid, RUN, 0);
		/// timeout to terminate child process
		timeout( this->m_memoryFaultTable[i].m_timeout, report );
        }
	}
    dbgcout <<"return from " <<__func__ <<" now" <<endl;
	return RT_OK;
}
Exemplo n.º 7
0
WndTask::WndTask( const af::MCTaskPos & i_tp, ListTasks * i_parent):
	Wnd("Task"),
	m_parent( i_parent),
	m_pos( i_tp),
	m_log_te( NULL),
	m_errhosts_te( NULL),
	m_output_te( NULL),
	m_outputs_count(-1),
	m_output_current(-1),
	m_tab_current( NULL),
	m_listening( false)
{
	ms_wndtasks.push_back( this);

	QVBoxLayout * layout = new QVBoxLayout( this);

	//
	// Progess brief:
	//
	m_progress_te = new QTextEdit( this);
	layout->addWidget( m_progress_te);
	m_progress_te->setReadOnly( true);
	m_progress_te->setLineWrapMode( QTextEdit::NoWrap);
	m_progress_te->setFocusPolicy( Qt::NoFocus);

	m_progress_te->setHorizontalScrollBarPolicy( Qt::ScrollBarAlwaysOff);
	m_progress_te->setVerticalScrollBarPolicy( Qt::ScrollBarAlwaysOff);
	m_progress_te->setFixedHeight( 28);


	//
	// Buttons:
	//
	QHBoxLayout * layoutB = new QHBoxLayout();
	layout->addLayout( layoutB);

	m_btn_skip = new QPushButton("Skip", this);
	layoutB->addWidget( m_btn_skip);
	m_btn_skip->setEnabled( false);
	m_btn_skip->setFixedWidth( 88);
	connect( m_btn_skip, SIGNAL( pressed()), this, SLOT( slot_skip()));

	m_btn_restart = new QPushButton("Restart", this);
	layoutB->addWidget( m_btn_restart);
	m_btn_restart->setEnabled( false);
	m_btn_restart->setFixedWidth( 88);
	connect( m_btn_restart, SIGNAL( pressed()), this, SLOT( slot_restart()));

	layoutB->addStretch();

	m_btn_output = new QPushButton("Output", this);
	layoutB->addWidget( m_btn_output);
	m_btn_output->setEnabled( false);
	m_btn_output->setFixedWidth( 111);
	m_output_menu = new QMenu( m_btn_output);
	m_btn_output->setMenu( m_output_menu);


	//
	// Output tabs:
	//
	m_tab_widget = new QTabWidget( this);
	layout->addWidget( m_tab_widget);
	//m_tab_widget->setTabsClosable( true);

	createTab("Executable",  &m_tab_exec,      NULL          ); 
	createTab("Output",      &m_tab_output,   &m_output_te   ); 
	createTab("Log",         &m_tab_log,      &m_log_te      ); 
	createTab("Error Hosts", &m_tab_errhosts, &m_errhosts_te ); 
	createTab("Listen",      &m_tab_listen,   &m_listen_te   ); 

	m_tab_output->setEnabled( false);

	connect( m_tab_widget, SIGNAL( currentChanged( int)), this, SLOT( slot_currentChanged( int)));

	getTaskInfo("info");
//	slot_currentChanged(0);
}