CMSourceDirector::CMSourceDirector ( CMCommandDirector* commandDir, const JCharacter* fileOrFn, const Type type ) : JXWindowDirector(JXGetApplication()), itsType(type), itsSrcMainCmd(NULL), itsGetAssemblyCmd(NULL) { CMSourceViewDirectorX(commandDir); if (itsType == kAsmType && !JStringEmpty(fileOrFn)) { CMLocation loc; loc.SetFunctionName(fileOrFn); loc.SetMemoryAddress("0x0"); // not allowed to be null DisplayDisassembly(loc); } else if (itsType == kSourceType && JFileReadable(fileOrFn)) { DisplayFile(fileOrFn); } }
void CMLink::SetBreakpoint ( const CMLocation& loc, const JBoolean temporary ) { SetBreakpoint(loc.GetFileName(), loc.GetLineNumber(), temporary); }
JBoolean CMBreakpointManager::HasBreakpointAt ( const CMLocation& loc ) const { CMBreakpoint target(loc.GetFileName(), loc.GetLineNumber()); JIndex i; return itsBPList->SearchSorted(&target, JOrderedSetT::kAnyMatch, &i); }
CMLocation GDBGetStopLocation::GetLocation() const { const JString& data = GetLastResult(); CMLocation loc; JIndexRange r; if (locationPattern.Match(data, &r)) { std::istringstream stream(data.GetCString()); stream.seekg(r.last); JStringPtrMap<JString> map(JPtrArrayT::kDeleteAll); JString *s, *s1, *fullName; JIndex lineIndex; const JBoolean parsed = GDBLink::ParseMap(stream, &map); if (!parsed) { (CMGetLink())->Log("invalid data map"); } else if (!map.GetElement("fullname", &fullName)) { (CMGetLink())->Log("missing file name"); } else if (!map.GetElement("line", &s)) { (CMGetLink())->Log("missing line index"); } else if (!s->ConvertToUInt(&lineIndex)) { (CMGetLink())->Log("line index is not integer"); } else { loc.SetFileName(*fullName); loc.SetLineNumber(lineIndex); } if (parsed && map.GetElement("func", &s) && map.GetElement("addr", &s1)) { loc.SetFunctionName(*s); loc.SetMemoryAddress(*s1); } } else { (CMGetLink())->Log("GDBGetStopLocation failed to match"); } return loc; }
JBoolean CMBreakpointManager::GetBreakpoints ( const CMLocation& loc, JPtrArray<CMBreakpoint>* list ) const { list->RemoveAll(); list->SetCleanUpAction(JPtrArrayT::kForgetAll); if ((loc.GetFileID()).IsValid()) { CMBreakpoint target(loc.GetFileName(), loc.GetLineNumber()); JBoolean found; const JIndex startIndex = itsBPList->SearchSorted1(&target, JOrderedSetT::kFirstMatch, &found); const JSize count = itsBPList->GetElementCount(); for (JIndex i=startIndex; i<=count; i++) { CMBreakpoint* bp = itsBPList->NthElement(i); if (bp->GetLocation() == loc) { list->Append(bp); } else { break; } } } else if (!loc.GetFunctionName().IsEmpty()) { const JSize count = itsBPList->GetElementCount(); for (JIndex i=1; i<=count; i++) { CMBreakpoint* bp = itsBPList->NthElement(i); if (bp->GetFunctionName() == loc.GetFunctionName()) { list->Append(bp); } } } return !list->IsEmpty(); }
void CMSourceDirector::DisplayDisassembly ( const CMLocation& loc ) { const JString& fnName = loc.GetFunctionName(); const JString& addr = loc.GetMemoryAddress(); assert( !JStringEmpty(fnName) ); assert( !JStringEmpty(addr) ); if (fnName == itsCurrentFn) { JIndex i; if (dynamic_cast<CMLineAddressTable*>(itsTable)->FindAddressLineNumber(addr, &i)) { DisplayLine(i); } else { itsTable->SetCurrentLine(0); } UpdateWindowTitle(NULL); } else { itsCurrentFn = fnName; if (itsGetAssemblyCmd == NULL) { itsGetAssemblyCmd = (CMGetLink())->CreateGetAssembly(this); } if (itsGetAssemblyCmd != NULL) { itsAsmLocation = loc; itsGetAssemblyCmd->Send(); } UpdateWindowTitle(NULL); } }
void CMLineAddressTable::GetBreakpoints ( JPtrArray<CMBreakpoint>* list ) { itsVisualBPIndexList->RemoveAll(); const JString* fnName; if (!GetDirector()->GetFunctionName(&fnName)) { list->CleanOut(); return; } CMLocation loc; loc.SetFunctionName(*fnName); if (!GetLink()->GetBreakpointManager()->GetBreakpoints(loc, list)) { return; } list->Sort(); const JSize count = list->GetElementCount(); JString target; for (JIndex i=1; i<=count; i++) { const CMBreakpoint* bp = list->NthElement(i); target = GetLineTextFromAddress(bp->GetAddress()); JBoolean found; const JIndex j = itsLineTextList->SearchSorted1(&target, JOrderedSetT::kAnyMatch, &found); itsVisualBPIndexList->AppendElement(j); } }