Пример #1
0
void
LLDBGetRegisters::HandleSuccess
	(
	const JString& data
	)
{
	LLDBLink* link = dynamic_cast<LLDBLink*>(CMGetLink());
	if (link == NULL)
		{
		return;
		}

	lldb::SBCommandInterpreter interp = link->GetDebugger()->GetCommandInterpreter();
	if (!interp.IsValid())
		{
		return;
		}

	lldb::SBCommandReturnObject result;
	interp.HandleCommand("register read", result);

	// https://llvm.org/bugs/show_bug.cgi?id=26421
	if (result.IsValid() && result.Succeeded() /* && result.HasResult() */)
		{
		(GetDirector())->Update(result.GetOutput());
		}
}
Пример #2
0
void
LLDBSymbolsLoadedTask::Perform()
{
	LLDBLink* link = dynamic_cast<LLDBLink*>(CMGetLink());
	if (link != NULL)
		{
		link->SymbolsLoaded(itsFileName);
		}
}
void
LLDBWelcomeTask::Perform()
{
	LLDBLink* link = dynamic_cast<LLDBLink*>(CMGetLink());
	if (link != NULL)
		{
		link->BroadcastWelcome(itsMessage, itsRestartFlag);
		}
}
Пример #4
0
void
LLDBRunBackgroundCommandTask::Perform()
{
	LLDBLink* link = dynamic_cast<LLDBLink*>(CMGetLink());
	if (link != NULL)
		{
		link->SendMedicCommandSync(itsCmd);
		}
}
Пример #5
0
void
LLDBGetLocalVars::HandleSuccess
	(
	const JString& data
	)
{
	LLDBLink* link = dynamic_cast<LLDBLink*>(CMGetLink());
	if (link == NULL)
		{
		itsRootNode->DeleteAllChildren();
		return;
		}

	lldb::SBFrame f = link->GetDebugger()->GetSelectedTarget().GetProcess().GetSelectedThread().GetSelectedFrame();
	if (!f.IsValid())
		{
		itsRootNode->DeleteAllChildren();
		return;
		}

	lldb::SBValueList vars = f.GetVariables(true, true, false, false, lldb::eDynamicDontRunTarget);
	if (!vars.IsValid())
		{
		itsRootNode->DeleteAllChildren();
		return;
		}

	// delete existing nodes beyond the first one that doesn't match the
	// new variable names

	const JSize newCount = vars.GetSize();
	JSize origCount      = itsRootNode->GetChildCount();

	while (origCount > newCount)
		{
		delete itsRootNode->GetChild(origCount);
		origCount--;
		}

	// origCount <= newCount

	for (JIndex i=1; i<=origCount; i++)
		{
		if ((itsRootNode->GetVarChild(i))->GetName() !=
			vars.GetValueAtIndex(i-1).GetName())
			{
			if (i == 1)		// optimize since likely to be most common case
				{
				itsRootNode->DeleteAllChildren();
				origCount = 0;
				}
			else
				{
				while (origCount >= i)
					{
					delete itsRootNode->GetChild(origCount);
					origCount--;
					}
				}
			break;	// for clarity:  would happen anyway
			}
		}

	// update/create nodes

	for (JIndex i=1; i<=newCount; i++)
		{
		lldb::SBValue v = vars.GetValueAtIndex(i-1);
		if (v.IsValid())	// paranoia
			{
			CMVarNode* node = LLDBVarNode::BuildTree(f, v);

			if (i <= origCount)
				{
				itsRootNode->GetVarChild(i)->UpdateValue(node);
				}
			else
				{
				itsRootNode->Append(node);	// avoid automatic update
				}
			}
		}
}
Пример #6
0
void
LLDBGetAssembly::HandleSuccess
	(
	const JString& cmdData
	)
{
	LLDBLink* link = dynamic_cast<LLDBLink*>(CMGetLink());
	if (link == NULL)
		{
		return;
		}

	lldb::SBCommandInterpreter interp = link->GetDebugger()->GetCommandInterpreter();
	if (!interp.IsValid())
		{
		return;
		}

	const CMLocation& loc = (GetDirector())->GetDisassemblyLocation();

	const JString cmd = "disassemble -n " + JPrepArgForExec(loc.GetFunctionName());
	lldb::SBCommandReturnObject result;
	interp.HandleCommand(cmd, result);

	JPtrArray<JString> addrList(JPtrArrayT::kDeleteAll);
	JString instText;

	if (result.IsValid() && result.Succeeded() && result.HasResult())
		{
		std::istringstream input(result.GetOutput());
		JString line, s;
		JSize maxOffsetLength = 0;
		while (!input.eof() && !input.fail())
			{
			line = JReadLine(input);

			JIndex i;
			if (line.LocateSubstring(":", &i) && i < line.GetLength())
				{
				s = line.GetSubstring(1, i-1);
				if (s.BeginsWith("->") && s.GetLength() > 2)
					{
					s = s.GetSubstring(3, s.GetLength());
					}
				s.TrimWhitespace();
				addrList.Append(s);

				JIndexRange r;
				if (offsetPattern.Match(s, &r))
					{
					maxOffsetLength = JMax(maxOffsetLength, r.GetLength());
					}

				if (!instText.IsEmpty())
					{
					instText.AppendCharacter('\n');
					}
				s = line.GetSubstring(i+1, line.GetLength());
				s.TrimWhitespace();
				instText.Append(s);
				}
			}

		const JSize count = addrList.GetElementCount();
		for (JIndex i=1; i<count; i++)
			{
			JString* s = addrList.NthElement(i);
			JIndexRange r;
			if (offsetPattern.Match(*s, &r))
				{
				const JSize pad = maxOffsetLength - r.GetLength();
				for (JIndex j=0; j<pad; j++)
					{
					s->InsertCharacter('0', r.first+2);
					}
				}
			}
		}

	(GetDirector())->DisplayDisassembly(&addrList, instText);
}