UT_ErrorSeverity GusdTfErrorScope::_Update() { int sev = UT_ERROR_NONE; if(_mgr && _sev > UT_ERROR_NONE) { auto end = _mark.GetEnd(); UT_WorkBuffer buf; for(auto it = _mark.GetBegin(); it != end; ++it) { UT_SourceLocation loc(it->GetSourceFileName().c_str(), it->GetSourceLineNumber()); buf.clear(); // XXX: Not sure what verbosity level we want for errors. // Maybe make it configurable from the environment? if(1) { _FormatErrorVerbose(it->GetDiagnosticCode(), it->GetContext(), it->GetCommentary(), buf); } else { _FormatErrorSimple(it->GetDiagnosticCode(), it->GetContext(), it->GetCommentary(), buf); } sev = _mgr->addGeneric("Common", UT_ERROR_JUST_STRING, buf.buffer(), _sev, &loc); } } _mark.Clear(); return UT_ErrorSeverity(sev); }
Import* GenImport (const char* Name, unsigned char AddrSize) /* Generate a new import with the given name and address size and return it */ { /* Create a new import */ Import* I = NewImport (AddrSize, 0); /* Read the name */ I->Name = GetStringId (Name); /* Check the address size */ if (I->AddrSize == ADDR_SIZE_DEFAULT || I->AddrSize > ADDR_SIZE_LONG) { /* Beware: This function may be called in cases where the object file * is not read completely into memory. In this case, the file list is * invalid. Be sure not to access it in this case. */ if (ObjHasFiles (I->Obj)) { Error ("Invalid import size in for `%s', imported from %s(%lu): 0x%02X", GetString (I->Name), GetSourceFileName (I->Obj, I->Pos.Name), I->Pos.Line, I->AddrSize); } else { Error ("Invalid import size in for `%s', imported from %s: 0x%02X", GetString (I->Name), GetObjFileName (I->Obj), I->AddrSize); } } /* Return the new import */ return I; }
void CircularRefError (const Export* E) /* Print an error about a circular reference using to define the given export */ { Error ("Circular reference for symbol `%s', %s(%lu)", GetString (E->Name), GetSourceFileName (E->Obj, E->Pos.Name), E->Pos.Line); }
static void CheckSymType (const Export* E) /* Check the types for one export */ { /* External with matching imports */ Import* Imp = E->ImpList; while (Imp) { if (E->AddrSize != Imp->AddrSize) { /* Export is ZP, import is abs or the other way round */ const char* ExpAddrSize = AddrSizeToStr (E->AddrSize); const char* ImpAddrSize = AddrSizeToStr (Imp->AddrSize); const char* ExpObjName = GetObjFileName (E->Obj); const char* ImpObjName = GetObjFileName (Imp->Obj); if (E->Obj) { /* User defined export */ Warning ("Address size mismatch for `%s': Exported from %s, " "%s(%lu) as `%s', import in %s, %s(%lu) as `%s'", GetString (E->Name), ExpObjName, GetSourceFileName (E->Obj, E->Pos.Name), E->Pos.Line, ExpAddrSize, ImpObjName, GetSourceFileName (Imp->Obj, Imp->Pos.Name), Imp->Pos.Line, ImpAddrSize); } else { /* Export created by the linker */ Warning ("Address size mismatch for `%s': Symbol is `%s'" ", but imported from %s, %s(%lu) as `%s'", GetString (E->Name), ExpAddrSize, ImpObjName, GetSourceFileName (Imp->Obj, Imp->Pos.Name), Imp->Pos.Line, ImpAddrSize); } } Imp = Imp->Next; } }
void CCreateToySourcePanel::CreateCallback(const tstring& sArgs) { if (!m_pSourceFileText->GetText().length() || !m_pToyFileText->GetText().length()) return; ToyEditor()->NewToy(); ToyEditor()->GetToyToModify().m_sFilename = GetSourceFileName(); ToyEditor()->GetToyToModify().m_sToyFile = GetToyFileName(); SetVisible(false); ToyEditor()->Layout(); }
DBGSERV_API const TraceService& TraceService::operator << (LPCSTR lpcstr) const { const CHAR* szSourceFileName = GetSourceFileName(); int nCodeLineNumber = GetCodeLineNumber(); #ifdef _DEBUG // Always use the OutputDebugString in debug version. if (nCodeLineNumber != 0) { std::ostringstream outputStream; outputStream << szSourceFileName << "(" << nCodeLineNumber << ") "; ::OutputDebugStringA(outputStream.str().c_str()); if (!m_bLogEnabled) { nCodeLineNumber = 0; SetCodeLineNumber(0); } } ::OutputDebugStringA(lpcstr); #endif if (m_bLogEnabled) { // Compute the trace file name. The name includes the thread id. There will be // on tace log file per thread. std::ostringstream oFileNameStream; oFileNameStream << m_sLogFile << ::GetCurrentThreadId() << ".txt"; // Open the log file. Log file is always ASCII. std::ofstream traceFile(oFileNameStream.str().c_str(), std::ios_base::app); if (traceFile.is_open()) { if (nCodeLineNumber != 0) { traceFile << szSourceFileName << "(" << nCodeLineNumber << ") "; } traceFile << lpcstr; traceFile.close(); } SetCodeLineNumber(0); } return *this; }
void PrintImportMap (FILE* F) /* Print an import map to the given file */ { unsigned I; const Import* Imp; /* Loop over all exports */ for (I = 0; I < ExpCount; ++I) { /* Get the export */ const Export* Exp = ExpPool [I]; /* Print the symbol only if there are imports, or if a verbose map * file is requested. */ if (VerboseMap || Exp->ImpCount > 0) { /* Print the export */ fprintf (F, "%s (%s):\n", GetString (Exp->Name), GetObjFileName (Exp->Obj)); /* Print all imports for this symbol */ Imp = Exp->ImpList; while (Imp) { /* Print the import */ fprintf (F, " %-25s %s(%lu)\n", GetObjFileName (Imp->Obj), GetSourceFileName (Imp->Obj, Imp->Pos.Name), Imp->Pos.Line); /* Next import */ Imp = Imp->Next; } } } fprintf (F, "\n"); }
void CCreateToySourcePanel::FileNamesChanged() { m_pWarnings->SetText(""); tstring sToyFile = GetToyFileName(); if (IsFile(sToyFile)) m_pWarnings->SetText("WARNING: This toy file already exists. It will be overwritten when the new source file is built."); tstring sSourceFile = GetSourceFileName(); if (IsFile(sSourceFile)) { if (m_pWarnings->GetText().length()) m_pWarnings->AppendText("\n\n"); m_pWarnings->AppendText("WARNING: This source file already exists. It will be overwritten."); } m_pCreate->SetVisible(false); if (m_pSourceFileText->GetText().length() && m_pToyFileText->GetText().length()) m_pCreate->SetVisible(true); }
Import* ReadImport (FILE* F, ObjData* Obj) /* Read an import from a file and return it */ { Import* I; /* Read the import address size */ unsigned char AddrSize = Read8 (F); /* Create a new import */ I = NewImport (AddrSize, Obj); /* Read the name */ I->Name = MakeGlobalStringId (Obj, ReadVar (F)); /* Read the file position */ ReadFilePos (F, &I->Pos); /* Check the address size */ if (I->AddrSize == ADDR_SIZE_DEFAULT || I->AddrSize > ADDR_SIZE_LONG) { /* Beware: This function may be called in cases where the object file * is not read completely into memory. In this case, the file list is * invalid. Be sure not to access it in this case. */ if (ObjHasFiles (I->Obj)) { Error ("Invalid import size in for `%s', imported from %s(%lu): 0x%02X", GetString (I->Name), GetSourceFileName (I->Obj, I->Pos.Name), I->Pos.Line, I->AddrSize); } else { Error ("Invalid import size in for `%s', imported from %s: 0x%02X", GetString (I->Name), GetObjFileName (I->Obj), I->AddrSize); } } /* Return the new import */ return I; }
static void PrintUnresolved (ExpCheckFunc F, void* Data) /* Print a list of unresolved symbols. On unresolved symbols, F is * called (see the comments on ExpCheckFunc in the data section). */ { unsigned I; /* Print all open imports */ for (I = 0; I < ExpCount; ++I) { Export* E = ExpPool [I]; if (E->Expr == 0 && E->ImpCount > 0 && F (E->Name, Data) == 0) { /* Unresolved external */ Import* Imp = E->ImpList; fprintf (stderr, "Unresolved external `%s' referenced in:\n", GetString (E->Name)); while (Imp) { const char* Name = GetSourceFileName (Imp->Obj, Imp->Pos.Name); fprintf (stderr, " %s(%lu)\n", Name, Imp->Pos.Line); Imp = Imp->Next; } } } }
HRESULT _stdcall CContainer::DragEnter(IDataObject *pDataObject, DWORD grfKeyState,POINTL pt,DWORD *pdwEffect) { m_iTabDragTab = m_iTabSelectedItem; g_bTabDragTimerElapsed = FALSE; std::list<FORMATETC> ftcList; CDropHandler::GetDropFormats(&ftcList); BOOL bDataAccept = FALSE; /* Check whether the drop source has the type of data that is needed for this drag operation. */ for each(auto ftc in ftcList) { if(pDataObject->QueryGetData(&ftc) == S_OK) { bDataAccept = TRUE; break; } } if(bDataAccept) { m_bDataAccept = TRUE; GetSourceFileName(pDataObject); TCHITTESTINFO tchi; TCITEM tcItem; BOOL bOnSameDrive; int iTab; tchi.pt.x = pt.x; tchi.pt.y = pt.y; ScreenToClient(m_hTabCtrl,&tchi.pt); iTab = TabCtrl_HitTest(m_hTabCtrl,&tchi); if(iTab != -1) { tcItem.mask = TCIF_PARAM; TabCtrl_GetItem(m_hTabCtrl,iTab,&tcItem); bOnSameDrive = CheckItemLocations((int)tcItem.lParam); *pdwEffect = DetermineCurrentDragEffect(grfKeyState, *pdwEffect,m_bDataAccept,bOnSameDrive); } else { *pdwEffect = DROPEFFECT_NONE; } } else { m_bDataAccept = FALSE; *pdwEffect = DROPEFFECT_NONE; } if(grfKeyState & MK_LBUTTON) m_DragType = DRAG_TYPE_LEFTCLICK; else if(grfKeyState & MK_RBUTTON) m_DragType = DRAG_TYPE_RIGHTCLICK; m_pDropTargetHelper->DragEnter(m_hTabCtrl,pDataObject,(POINT *)&pt,*pdwEffect); return S_OK; }