void CIpuTestHarness::ResourceLeakTest()
//
// Creates a new test that fails if any there are any leaked resource handles
	{
	// Start new test
	_LIT(KResourceTestName, "Resource Handle Leak Test");
	TRAPD(testError, StartTestL(KResourceTestName));
	if(testError==KErrNone)
		{
		//	Find number of opened handles
		TInt processHandleCount=0;
		TInt threadHandleCount=0;
		RThread().HandleCount(processHandleCount,threadHandleCount);
		TInt openHandleCount = iStartHandleCount-threadHandleCount;
		TInt err = KErrNone;
		if ( openHandleCount !=0 )
			{
			err = KErrGeneral;
			LogIt(_L("Number leaked handles is %D"), openHandleCount);
			}
		EndTest(err);
		}
	else
		{
		_LIT(KTxtResourceTestRunError, "Unable to complete Resource Leak Test, error: %d");
		LogIt(KTxtResourceTestRunError, testError);
		EndTest(testError);
		}
	}
Example #2
0
bool ProjectManagerXML::Save()
{
    bool ret = false;
    wxXmlDocument   xml_doc;

    if (named)
    {
        LogIt("Preparing to write...\n");
        wxStopWatch sw;
        writeHeader(xml_doc);
        writeDasmData(xml_doc);
        writeCodeLine(xml_doc);
        writeLabel(xml_doc, process->prog_labels, SECTION_PROGRAMLABEL_STR);
        writeLabel(xml_doc, process->var_labels, SECTION_VARLABEL_STR);
        writeLabel(xml_doc, process->io_labels, SECTION_IOLABEL_STR);
        writeLabel(xml_doc, process->constant_labels, SECTION_CONSTANTLABEL_STR);
        writeFileProperties(xml_doc);
        LogIt(wxString::Format("It took %dms...\n", sw.Time()));
        LogIt("Now saving...\n");
        sw.Start(0);
        ret = xml_doc.Save(project_filename, 4);
        LogIt(wxString::Format("It took %dms...\n", sw.Time()));

    }
    else
        ret = false;

    return ret;
}
Example #3
0
bool RawData::Open(wxString filename)
{
    wxFile 	f;
    void 	*tempbuffer;
    uint 	bytesread = 0,
            buffer_size = 0;
    wxString ext;
    bool    ret;


    ret = false;


    if (f.Open(filename))
    {
        if (IsLoaded())
            Close();

        m_header_offset = 0;

        buffer_size = (uint)f.Length();
        tempbuffer = m_buffer.GetWriteBuf(buffer_size);
        if (tempbuffer != 0)
            bytesread = (uint)f.Read(tempbuffer, buffer_size);
        f.Close();

        if (bytesread == buffer_size)
        {
            m_buffer.UngetWriteBuf(buffer_size);
            rawdata_filename.Assign(filename);
            ext = filename.AfterLast('.');
            ext = ext.Lower();
            if (ext == "com")
                SetFileType(COM);
            else if (ext == "rom")
            {
                SetFileType(ROM);
            }
            else if (!SetFileType(BIN))
                SetFileType(UNKNOWN);

            ret = true;
        }
        else
            m_buffer.SetDataLen(0);
    }

#ifdef IDZ80DEBUG
    if (ret)
        LogIt(wxString::Format("File opened is %s.\n",filename.c_str()));
    else
        LogIt("File not found !\n");
#endif

    return ret;
}
Example #4
0
int __cdecl
Inform( struct Globals *pG, int err, int type, const char *format, ... )
{
  va_list argptr;
  char    buf[513 + 15];
  char    *buffer = buf + 8;
  int     blen = 512;;
  
  if ( !pG )
    pG = ( struct Globals * )GlobalPointer; 
  if ( !pG )
    return -1;  // should not happen
  buf[0] = 0;
  if ( type != IWARNING && type <= IDEBUG )
  {
    lstrcpy( buffer, errs[type] );
    blen = lstrlen( buffer );
    buffer = buffer + blen;
    blen = 512 - blen;
  }

  va_start( argptr, format );
  vsnprintf( buffer, blen, format, argptr );
  buf[512 + 8] = 0;
  if (pG->LogName && *(pG->LogName))
    LogIt(pG, err, buf);

  // warning message, or info message only
  user_callback( 4, err, 0, buf + 8, pG );
  va_end( argptr );

  return 0;
}
Example #5
0
void CodeView::OnGetFocus(wxFocusEvent& event)
{
    if (!IsFocused)
    {
        IsFocused = true;
        LogIt("Entrei...");
    }
}
Example #6
0
bool ProjectManagerXML::readHeader(wxXmlDocument &doc)
{
    wxXmlNode   *node;
    wxString    str;

    node = doc.GetRoot();
    if (node->GetName() != ROOT_STR)
        return false;

    str = node->GetAttribute(ATTRIBUTE_VERSION_STR);
    if (str.IsEmpty())
        LogIt("Version not found !!\n");
    else
        LogIt("Version is " + str + ".\n");

    return true;
}
EXPORT_C void CIpuTestHarness::SetScript(RFile& scriptFile)
//
//	Sets the file to be used for a test script - ie. a file that contains commands used by
//  GetEntry() and GetSelection()
	{
	iScriptFile = &scriptFile;
	iScriptRunning = ETrue;
	LogIt(_L("***SCRIPT STARTING***\n"));
	}
Example #8
0
void CodeView::OnKillFocus(wxFocusEvent& event)
{
    if (IsFocused)
    {
        IsFocused = false;
        LogIt("SaĆ­...");
        wxClientDC dc(this);
        DisassembleWindowBitmap = dc.GetAsBitmap();
    }
}
Example #9
0
void ProjectManagerXML::readCodeLine(wxXmlDocument &doc)
{
    wxXmlNode   *section, *node;
    wxString    str;
    uint    total_lines, linecount;
    long    conv;


    section = findSection(doc.GetRoot()->GetChildren(), SECTION_CODEVIEWLINE_STR);
    if (!section)
    {
        LogIt("Failed to load CodeViewLine section\n");
        return;
    }
    else
        LogIt("Found CodeviewLines \n");

    str = section->GetAttribute(ATTRIBUTE_TOTALLINES_STR);
    if (!str.IsEmpty() && str.ToLong(&conv))
    {
        total_lines = static_cast<uint>(conv);
    }
    else
    {
        LogIt("Fatal error ! TotalLines attribute is missing !\n");
        return;
    }


    node = section->GetChildren();

    linecount = 0;
    while (node)
    {
        if (fillCodeViewLine(node))
            linecount++;
        node = node->GetNext();
    }

    if (linecount != total_lines)
        LogIt(wxString::Format("Failed code view lines = %d\n", (total_lines - linecount)));
}
CIpuTestHarness::~CIpuTestHarness()
//
//	D'tor
	{
	TTime endtime;
	endtime.UniversalTime();

	// Do resource handle leak test?
	if (iDoResourceLeakTest)
		ResourceLeakTest();

	//	End of tests - see if failed or ok
	if (iFailedTests->Count())
		{
		TestHarnessFailed();
		}
	else
		{
		TestHarnessComplete();
		}

	iFailedTests->ResetAndDestroy();
	delete iFailedTests;

	//	Log finish time
	TDateTime t = endtime.DateTime();
	LogIt(_L("Ended @ %d:%d:%d:%d"),t.Hour(),t.Minute(),t.Second(),t.MicroSecond());
	TTime difftime(endtime.Int64() - iStartTime.Int64());
	t = difftime.DateTime();
	LogIt(_L("Execution time %d:%d:%d:%d"),t.Hour(),t.Minute(),t.Second(),t.MicroSecond());

	//	Close logs and test harness
	iFlogger.CloseLog();
	
	// iTest test harness performs UHEAP MARK/UNMARK check upon creation/destruction
	//   therefore, it must be destroyed last since it is created first in 
	//   CIpuTestHarness
	iTest.Close();
	}
void CIpuTestHarness::TestHarnessFailed()
//
//	Test harness has a failure - log information
	{
	TBuf<KMaxFileName + 4> buf;
	buf.Format(KTestHarnessFailed, iFailedTests->Count());
	WriteComment(buf);
	//	Log fialed tests' information
	for (TInt ii=0; ii<iFailedTests->Count(); ++ii)
		{
		CTestInfo* failed = iFailedTests->At(ii);
		TPtrC name = failed->Name();
		LogIt(KTestFailInfo, failed->Number(), &name, failed->ErrorCode());
		}
	}
Example #12
0
/** 
  Terminates the timer
  @param aComment Name of API.
*/
EXPORT_C void TTimerLogger::EndTimer(const TDesC& aComment)
	{
    #if defined (__LOG_PERFORMANCE) && !defined (_DEBUG)
	iEndTime.UniversalTime();
	TTimeIntervalMicroSeconds iTimeDifference = iEndTime.MicroSecondsFrom(iStartTime);	
	_LIT(KTimeDiff, ",%d microseconds\n");
	RBuf myBuf;
	TInt err = myBuf.Create (aComment.Length()+64);
	__ASSERT_ALWAYS(KErrNone == err, User::Invariant() );
	myBuf.Append (aComment );
	myBuf.AppendFormat(KTimeDiff, iTimeDifference.Int64());
    LogIt(myBuf);
	myBuf.Close();	
	iStartTime = 0;
	iEndTime = 0;
	#endif
	}
Example #13
0
void CodeView::OnPopUpMenuGotoAddress(wxCommandEvent& event)
{
    long address = 0;
    wxTextEntryDialog enter_address(0, "Enter Address", "Address to go");

    if (enter_address.ShowModal() == wxID_OK)
    {
        if (enter_address.GetValue().ToLong(&address) ||
            enter_address.GetValue().ToLong(&address, 16))
        {
            #ifdef IDZ80DEBUG
            LogIt(wxString::Format("Going to %X", address));
            #endif

            CenterAddress(address);
        }
    }
}
void CIpuTestHarness::ConstructL(const TDesC& aTitle)
//
//	Non-trivial c'tor
	{
	//	Create iFailedTests
	iFailedTests = new (ELeave) CArrayPtrFlat<CTestInfo> (KFailedTestsGranularity);

	//	Start up logging server connection
	TBuf<64> temp(aTitle);
	DefaultLogFileName(temp);
	CreateFlogger(temp, EFalse, EFalse);

	iStartTime.UniversalTime();
	TDateTime t = iStartTime.DateTime();
	LogIt(_L("Started @ %d:%d:%d:%d"),t.Hour(),t.Minute(),t.Second(),t.MicroSecond());

	// Find number of open resource handles
	TInt processHandleCount=0;
	RThread().HandleCount(processHandleCount,iStartHandleCount);
	}
Example #15
0
//---------------------------------------------------------------------------
void __fastcall TForm1::btnStartClick(TObject *Sender)
{
    int i;

    for( i = 0; i < pass->Text.Length(); i++ )
    {
        m_pass[i] = pass->Text[i+1];
    }

    for( ; i < 25; i++ )
    {
        m_pass[i] = 0x1f;
    }


    LogIt( "--> starting... <--" );
    m_bStop = false;

    btnStart->Enabled = false;

    mythread = new TMyThread(false);
}
Example #16
0
void CodeView::OnPopUpMenuCreateLabel(wxCommandEvent& event)
{
    if (line_info.type == siData)
        LogIt(wxString::Format("Label created for address %.4X.", line_info.firstAddress));
}
Example #17
0
void CodeView::OnPopUpMenuOD_Number(wxCommandEvent& event)
{
	LogIt("Data numbered !!\n");
}
Example #18
0
void CodeView::OnPopUpMenuOD_String(wxCommandEvent& event)
{
	LogIt("Data stringed !!\n");
}
Example #19
0
void CodeView::OnPopUpMenuOD_Matrix(wxCommandEvent &event)
{
	LogIt("Data Matrixed !!\n");
}
Example #20
0
void CodeView::OnPopUpMenuSearch(wxCommandEvent& event)
{
    LogIt("Search Menu Clicked !!!\n");
}
EXPORT_C void CIpuTestHarness::GetAnEntry(const TDesC& ourPrompt, TDes& currentstring)
//
//	Get an input string from the user, displaying a supplied prompt and default string value
	{
	// If we're scripting, try reading from script first
	TInt readScriptErr = KErrNotFound;
	if (iScriptRunning)
		{
		readScriptErr = ReadLineFromScript(currentstring);
		}
	if (!readScriptErr)
		return;

	// Either not scripting, or hit end of script - continue with user input
	TBuf16<KMaxUserEntrySize> ourLine;
	TBuf<KMaxUserEntrySize> tempstring;				//tempstring is a unicode descriptor
										//create a temporary buffer where the
										//unicode strings are stored in order to 
										//be displayed
	ourLine.Zero ();
	tempstring.Copy(currentstring);		//Copy current string to Unicode buffer
	TKeyCode key = EKeyNull;						//current string buffer is 8 bits wide.
										//Unicode string bufffer (tempstring) is 16 bits wide.
	for (;;)
		{
		if (ourLine.Length () == 0)
			{
			iTest.Console()->SetPos (0, iTest.Console()->WhereY ());
			iTest.Console()->Printf (_L ("%S"), &ourPrompt);
			if (tempstring.Length () != 0)						//get tempstring's number of items
				iTest.Console()->Printf (_L (" = %S"), &tempstring);	//if not zero print them to iTest.Console()
			iTest.Console()->Printf (_L (" : "));
			iTest.Console()->ClearToEndOfLine ();
			}
		key = iTest.Getch();
		
		  if (key == EKeyBackspace)
				{
					if (ourLine.Length() !=0)
					{
						ourLine.SetLength(ourLine.Length()-1);
						iTest.Console()->Printf (_L ("%c"), key);
						iTest.Console()->SetPos(iTest.Console()->WhereX(),iTest.Console()->WhereY());
						iTest.Console()->ClearToEndOfLine();
					}	// end if (ourLine.Length() !=0)
				}	// end if (key == KeyBackSpace)
		  
		  		  
		  if (key == EKeyDelete) 			
				{
					ourLine.Zero();
					iTest.Console()->SetPos (0, iTest.Console()->WhereY ());
					iTest.Console()->ClearToEndOfLine ();
					tempstring.Copy(ourLine);
					break;
				}
		  
		  if (key == EKeyEnter)
			break;
		
		  if (key < 32)
			{
			continue;
			}
		
		ourLine.Append (key);
		iTest.Console()->Printf (_L ("%c"), key);
		iTest.Console()->SetPos(iTest.Console()->WhereX(),iTest.Console()->WhereY());
		iTest.Console()->ClearToEndOfLine();
		if (ourLine.Length () == ourLine.MaxLength ())
			break;
		}	// end of for statement

	if ((key == EKeyEnter) && (ourLine.Length () == 0))
		tempstring.Copy (currentstring);				//copy contents of 8 bit "ourLine" descriptor
	
	iTest.Console()->SetPos (0, iTest.Console()->WhereY ());		
	iTest.Console()->ClearToEndOfLine ();
	iTest.Console()->Printf (_L ("%S"), &ourPrompt);
	
	if ((key == EKeyEnter) && (ourLine.Length() !=0))
		tempstring.Copy(ourLine);
	if (tempstring.Length () != 0)						//if temstring length is not zero
		{
		iTest.Console()->Printf (_L (" = %S\n"), &tempstring);	//print the contents to iTest.Console()
		LogIt(_L ("%S = %S\n"), &ourPrompt, &tempstring);
		}

	else
		//iTest.Console()->Printf (_L (" is empty"));
	iTest.Console()->Printf (_L ("\n"));
	currentstring.Copy(tempstring);						//copy 16 bit tempstring descriptor back 
	}
Example #22
0
void CodeView::OnMouseCaptureLost(wxMouseCaptureLostEvent& event)
{
    LogIt("Mouse Lost !!!!");
}
Example #23
0
bool ProjectManagerXML::fillCodeViewLine(wxXmlNode *datanode)
{
    wxString	str, str_comment;
    long		conv;
    bool    commentary_line;

    int health = 0;


    str_comment = datanode->GetAttribute(ATTRIBUTE_COMMENT_STR);
    commentary_line = !str_comment.IsEmpty();


    str = datanode->GetAttribute(ATTRIBUTE_ORG_STR);

    if (!str.IsEmpty() && str.ToLong(&conv))
    {
        CodeViewLines->AddOrg(static_cast<int>(conv), str_comment);
        commentary_line = false;
        health++;
    }

    str = datanode->GetAttribute(ATTRIBUTE_DASMITEM_STR);
    if (!str.IsEmpty() && str.ToLong(&conv))
    {
        CodeViewLines->AddDasm(static_cast<int>(conv), str_comment);
        commentary_line = false;
        health++;
    }

    str = datanode->GetAttribute(ATTRIBUTE_LINEPROGRAMLABEL_STR);
    if (!str.IsEmpty() && str.ToLong(&conv))
    {
        CodeViewLines->AddProgLabel(static_cast<int>(conv), str_comment);
        commentary_line = false;
        health++;
    }

    str = datanode->GetAttribute(ATTRIBUTE_LINEVARLABEL_STR);
    if (!str.IsEmpty() && str.ToLong(&conv))
    {
        CodeViewLines->AddVarLabel(static_cast<int>(conv), str_comment);
        commentary_line = false;
        health++;
    }

    if (commentary_line)
    {
        CodeViewLines->Add(str_comment);
        health++;
    }

    // Empty line
    if (health == 0)
    {
        CodeViewLines->Add("");

        #ifdef IDZ80DEBUG
        LogIt(wxString::Format("Empty line: %d\n", datanode->GetLineNumber()));
        #endif // IDZ80DEBUG
    }

    return (health != 0);

}
Example #24
0
bool ProjectManagerXML::fillDasmData(wxXmlNode *datanode)
{
    wxString	str;
    uint		i;
    long		conv;
    wxArrayString   arr_str;
    uint		len,
                arg_num = 0,
				arg_size = 0,
				arg_aux = 0;
    ByteCode		bc;
    OpCodeArguments	args;
    DisassembledItem		*de;
    MnemonicItem	*mi;
    bool    hasArguments = false;
    uint    health = 0;

    de = new DisassembledItem(process->Program);

    str = datanode->GetAttribute(ATTRIBUTE_OPCODETYPE_STR);
    if (!str.IsEmpty() && str.ToLong(&conv, 16))
    {
        de->SetType(static_cast<enum ElementType>(conv));
        health = 1;
    }

    str = datanode->GetAttribute(ATTRIBUTE_OPCODELENGTH_STR);
    if (!str.IsEmpty() && str.ToLong(&conv, 16))
    {
        len = static_cast<uint>(conv);
        de->SetLength(len);
        health += 2;
    }

    str = datanode->GetAttribute(ATTRIBUTE_OPCODEOFFSET_STR);
    if (!str.IsEmpty() && str.ToLong(&conv, 16))
    {
        de->SetOffset(static_cast<uint>(conv));
        health += 4;
    }


    str = datanode->GetAttribute(ATTRIBUTE_OPCODE_STR);
    if (!str.IsEmpty() && len)
    {
        ParseString(str, arr_str);
        memset(&bc, 0, MAX_OPCODE_SIZE);
        for (i = 0; i < len; i++)
        {
            str = arr_str[i];
            str.ToLong(&conv, 16);
            if (i < sizeof(ByteCode))
                bc[i] = static_cast<unsigned char>(conv);
        }
        de->CopyOpCode(bc);
        mi = process->Mnemonics->FindByOpCode(bc);
        if (mi != 0)
        {
            de->SetMnemonic(mi);
            health += 8;
            hasArguments = mi->HasArgument();
        }
    }

    if (health < 0xF)
    {
        LogIt(wxString::Format("[%d] Failed to load new instruction (health = %X)\n", datanode->GetLineNumber(), health));
        delete de;
        return false;
    }

    if (hasArguments)
    {
        str = datanode->GetAttribute(ATTRIBUTE_ARGUMENTNUM_STR);
        if (!str.IsEmpty() && str.ToLong(&conv, 16))
        {
            arg_num = static_cast<uint>(conv);
            health += 16;
        }

        str = datanode->GetAttribute(ATTRIBUTE_ARGUMENTSIZE_STR);
        if (!str.IsEmpty() && str.ToLong(&conv, 16))
        {
            arg_size = static_cast<uint>(conv);
            health += 32;
        }

        arg_aux = arg_size * arg_num;

        str = datanode->GetAttribute(ATTRIBUTE_ARGUMENTS_STR);
        if (!str.IsEmpty() && arg_aux)
        {
            memset(&args, 0, sizeof(OpCodeArguments));
            ParseString(str, arr_str);
            for (i = 0; i < arg_aux; i++)
            {
                str = arr_str[i];
                str.ToLong(&conv, 16);
                if (i < sizeof(OpCodeArguments))
                    args[i] = static_cast<unsigned char>(conv);
            }
            de->CopyArguments(args, arg_aux);
            health += 64;
        }

        if (health < 0x7F)
        {
            LogIt(wxString::Format("[%d] Failed to load new instruction arguments (health = %X)\n", datanode->GetLineNumber(), health));
            delete de;
            return false;
        }
    }

    process->Disassembled->AddDasm(de);
    return true;
}
Example #25
0
void ProjectManagerXML::readLabel(wxXmlDocument &doc, LabelListCtrl *current_label, const wxString &labelstr)
{
    wxXmlNode   *node, *section;
    wxXmlAttribute *attribute;
    wxString		str_name, str_addr, str_users;
    wxArrayString	arrstr;
    wxArrayInt		labelusers;
    uint			addr, i, linecount, total_lines;
    long			conv;


    section = findSection(doc.GetRoot()->GetChildren(), labelstr);

    if (section)
        LogIt("Found label [" + labelstr + "]\n");
    else
        return;

    str_addr = section->GetAttribute(ATTRIBUTE_TOTALLINES_STR);
    if (!str_addr.IsEmpty() && str_addr.ToLong(&conv))
    {
        total_lines = static_cast<uint>(conv);
    }
    else
    {
        LogIt("Fatal error ! TotalLines attribute is missing !\n");
        return;
    }

    node = section->GetChildren();

    linecount = 0;
    while (node)
    {
        attribute = node->GetAttributes();
        if (attribute)
        {
            str_name = attribute->GetName();
            str_addr = attribute->GetValue();
            str_users = node->GetAttribute(ATTRIBUTE_LABELUSERS_STR);
            ParseString(str_users, arrstr);
            for(i = 0; i < arrstr.Count(); i++)
                if (arrstr.Item(i).ToLong(&conv))
                    labelusers.Add(static_cast<int>(conv));
        }

        if (str_addr.ToLong(&conv, 16) && !labelusers.IsEmpty())
        {
            addr = static_cast<uint>(conv);
            current_label->AddLabel(addr, str_name, labelusers);
            linkLabels(&labelusers);
            linecount++;
        }

        labelusers.Clear();
        str_addr.Clear();

        node = node->GetNext();
    }

    if (linecount != total_lines)
        LogIt(wxString::Format("Failed Labels = %d\n", (total_lines - linecount)));
}
Example #26
0
bool ProjectManagerXML::readFileProperties(wxXmlDocument &doc)
{
    wxXmlNode   *node, *section;
    wxString    str, fullfilename, typeStr;
    long        conv;
    uint        start_address, execution_address, end_address;


    section = findSection(doc.GetRoot()->GetChildren(), SECTION_FILEPROPERTIES_STR);
    if (section)
    {
        LogIt(wxString::Format("Found Configuration section in line %d !!\n", section->GetLineNumber()));
    }
    else
    {
        LogIt("Configuration section NOT found !!\n");
        return false;
    }

    node = findSection(section->GetChildren(), SUBSECTION_FILENAME_STR);
    if (!node)
        return false;
    fullfilename = node->GetAttribute(ATTRIBUTE_FILENAME_STR);
    if (fullfilename.IsEmpty())
    {
        LogIt("File name NOT found !!\n");
        return false;
    }

    node = findSection(section->GetChildren(), SUBSECTION_FILEPATH_STR);
    if (!node)
        return false;
    str = node->GetAttribute(ATTRIBUTE_ORIGINALPATH_STR);
    if (str.IsEmpty())
    {
        LogIt("Original path NOT found !!\n");
        return false;
    }
    fullfilename = str + "\\" + fullfilename;

    if (wxFileExists(fullfilename))
        LogIt("Original file:" + fullfilename + ", found !!\n");
    else
    {
        LogIt("Original file NOT found !\n");
        return false;
    }

    node = findSection(section->GetChildren(), SUBSECTION_FILETYPE_STR);
    if (!node)
        return false;
    typeStr = node->GetAttribute(ATTRIBUTE_FILETYPE_STR);
    LogIt("File type is " + typeStr + "\n");


    node = findSection(section->GetChildren(), SUBSECTION_ADDRESS_STR);
    if (!node)
        return false;
    str = node->GetAttribute(ATTRIBUTE_STARTADDRESS_STR);
    if (!str.IsEmpty())
    {
        if (!str.ToLong(&conv, 16))
        {
            LogIt("Invalid Start(" + str +") address!\n");
            return false;
        }
    }
    LogIt("Start =" + str + "\n");
    start_address = conv;

    str = node->GetAttribute(ATTRIBUTE_EXECUTIONADDRESS_STR);
    if (!str.IsEmpty())
    {
        if (!str.ToLong(&conv, 16))
        {
            LogIt("Invalid Execution(" + str +") address!\n");
            return false;
        }
    }
    LogIt("Execution =" + str + "\n");
    execution_address = conv;

    str = node->GetAttribute(ATTRIBUTE_ENDADDRESS_STR);
    if (!str.IsEmpty() && !str.ToLong(&conv, 16))
    {
        LogIt("Invalid End(" + str +") address!\n");
        return false;
    }
    LogIt("End =" + str + "\n");
    end_address = conv;

    process->Program->Open(fullfilename);
    process->Program->SetStrFileType(typeStr);
    process->Program->StartAddress = start_address;
    process->Program->ExecAddress = execution_address;
    process->Program->EndAddress = end_address;


    return true;
}
Example #27
0
// Event handler for Page up/down and direction keys
void CodeView::OnKeyPress(wxKeyEvent& event)
{
    int key;
    ProgramAddress address;
    key = event.GetKeyCode();

    wxCommandEvent evtMakeData(wxEVT_MENU, idPOPUP_MAKEDATA);
    wxCommandEvent evtDisassemble(wxEVT_MENU, idPOPUP_DISASM);
    wxScrollWinEvent evtLineDown(wxEVT_SCROLLWIN_LINEDOWN);
    wxScrollWinEvent evtLineUp(wxEVT_SCROLLWIN_LINEUP);
    wxScrollWinEvent evtPageDown(wxEVT_SCROLLWIN_PAGEDOWN);
    wxScrollWinEvent evtPageUp(wxEVT_SCROLLWIN_PAGEUP);

#define C_KEY   67
#define D_KEY   68

    switch (key)
    {
        case WXK_DOWN:
                        if (line_info.cursorPosition < static_cast<int>(m_CodeViewLine->GetCount() - 1))
                        {
                            if (!MultiSelection)
                                line_info.cursorLastPosition = line_info.cursorPosition;

                            line_info.cursorPosition++;

                            ClearCursor();
                            DoSelection();

                            if (line_info.cursorPosition > GetLastLine())
                                AddPendingEvent(evtLineDown);
                            else
                                RefreshRect(CalcCursorRfshRect());

                            if (line_info.selectedLineCount == 1)
                                TreatSingleSelection();
                            else
                                if (line_info.selectedLineCount > 1)
                                    TreatMultiSelection();

                            if (Selecting)
                                LogIt(wxString::Format("Selection = (%d, %d)", line_info.firstLine, line_info.lastLine));
                        }
                        break;
        case WXK_UP:
                        if (line_info.cursorPosition > 0)
                        {
                            if (!MultiSelection)
                                line_info.cursorLastPosition = line_info.cursorPosition;

                            line_info.cursorPosition--;

                            ClearCursor();
                            DoSelection();

                            if (line_info.cursorPosition < GetFirstLine())
                                AddPendingEvent(evtLineUp);
                            else
                                RefreshRect(CalcCursorRfshRect());

                            if (line_info.selectedLineCount == 1)
                                TreatSingleSelection();
                            else
                                if (line_info.selectedLineCount > 1)
                                    TreatMultiSelection();

                            if (Selecting)
                                LogIt(wxString::Format("Selection = (%d, %d)", line_info.firstLine, line_info.lastLine));
                        }
                        break;
        case WXK_NUMPAD_PAGEDOWN:
        case WXK_PAGEDOWN:
                        AddPendingEvent(evtPageDown);
                        break;
        case WXK_NUMPAD_PAGEUP:
        case WXK_PAGEUP:
                        AddPendingEvent(evtPageUp);
                        break;
        case WXK_SHIFT:
                        if (!Selecting)
							Selecting = true;
                        MultiSelection = true;
                        break;
        case C_KEY:
                        AddPendingEvent(evtDisassemble);
                        break;
        case D_KEY:
                        AddPendingEvent(evtMakeData);
                        break;
        case WXK_F3:
                        if (Process->SearchInstructionArgumentContinue(address))
                        {
                            CenterAddress(address);
                        }

                        LogIt("F3 Key pressed !");
                        break;

        default:
                        LogIt(wxString::Format("%X pressed !",key));
                        event.Skip();
    }
}
TInt CIpuTestHarness::ReadLineFromScript(TDes& aBuffer)
//
// Reads the next line from the script file, and sets the passed-in descriptor with its contents.
// Returns KErrNone if reading succeeded; KErrNotFound if the EOF was reached. When EOF is reached,
// the file is closed.
	{
	// *********************************
	// Assume script is 8-bit text file
	// *********************************
	TBool isAComment = ETrue;
	TInt err = KErrNone;
	TBuf<512> line;
	while (isAComment && !err)
		{
		TFileText text;
		text.Set(*iScriptFile);
		line.SetLength(0);
		for(;;)
			{
			TBuf8<2> c;
			err = iScriptFile->Read(c,1);
			if (err && err != KErrEof)
				{
				iTest.Printf(_L("Error reading file: %d\n"), err);
				break;
				}
			if (c.Length() == 0)
				{
				err = KErrEof;
				break;
				}
			else
				{
				if (c[0] == '\n') // break out if it is CR
					break;
				else if (c[0] != (TUint8)(0x0d)) // otherwise append the char, _unless_ it is a LF
					line.Append(c[0]);
				}
			}
		if (err == KErrNone && line.Locate('/') != 0) // comment (only works if it's the first character)
			{
			isAComment = EFalse;
			}
		}

	// The line read is not a comment, or have hit end of file
	if (!err)
		{
		// copy to passed in descriptor, but do not allow an overflow
		aBuffer.Copy(line.Left(aBuffer.MaxLength()));
		LogIt(_L("***SCRIPT : read command '%S' ***\n"), &aBuffer);
		}
	else
		{
		iScriptFile->Close();
		err = KErrNotFound;
		iScriptRunning = EFalse;
		LogIt(_L("***SCRIPT ENDED***\n"));
		}
	return err;
	}
Example #29
0
EXPORT_C
#if defined (_DEBUG)
/**
Function to do a formatted dump of binary data.
@param aData The descriptor that holds the binary data
*/
void THttpLogger::DumpIt(const TDesC8& aData)
//Do a formatted dump of binary data
	{
	// Iterate the supplied block of data in blocks of cols=80 bytes
	const TInt cols=16;
	TInt pos = 0;
	TBuf<KMaxLogLineLength> logLine;
	TBuf<KMaxLogLineLength> anEntry;
	while (pos < aData.Length())
		{
		//start-line exadecimal( a 4 digit number)
		anEntry.Format(TRefByValue<const TDesC>_L("%04x : "), pos);
		logLine.Append(anEntry.Left(KMaxLogLineLength));

		// Hex output
		TInt offset;
		for (offset = 0; offset < cols; offset++)
			{
			if (pos + offset < aData.Length())
				{
				TInt nextByte = aData[pos + offset];
				anEntry.Format(TRefByValue<const TDesC>_L("%02x "), nextByte);
				logLine.Append(anEntry);
				}
			else
				{
				//fill the remaining spaces with blanks untill the cols-th Hex number 
				anEntry.Format(TRefByValue<const TDesC>_L("   "));
				logLine.Append(anEntry);
				}
			}
			anEntry.Format(TRefByValue<const TDesC>_L(": "));
			logLine.Append(anEntry);

		// Char output
		for (offset = 0; offset < cols; offset++)
			{
			if (pos + offset < aData.Length())
				{
				TInt nextByte = aData[pos + offset];
				if ((nextByte >= 32) && (nextByte <= 127))
					{
					anEntry.Format(TRefByValue<const TDesC>_L("%c"), nextByte);
					logLine.Append(anEntry);
					}
				else
					{
					anEntry.Format(TRefByValue<const TDesC>_L("."));
					logLine.Append(anEntry);
					}
				}
			else
				{
				anEntry.Format(TRefByValue<const TDesC>_L(" "));
				logLine.Append(anEntry);
				}
			}
			LogIt(TRefByValue<const TDesC>_L("%S\n"), &logLine);	
			logLine.Zero();

		// Advance to next  byte segment (1 seg= cols)
		pos += cols;
		}
	}
Example #30
0
/**
 Displays the test case name
 @param aComment Name of API.
*/
EXPORT_C void TTimerLogger::TestName(const TDesC& aComment)
	{
	#if defined (__LOG_PERFORMANCE) && !defined (_DEBUG)
    LogIt(aComment);
	#endif
	}