Fixed a crasher that was happened when a log shared pointer wasn't valid.

Fixed ThreadPlanCallFunction::ReportRegisterState(...) to only dump when
verbose logging is enabled and fixed the function to use the new
RegisterValue method of reading registers.

Fixed the GDB remote client to not send a continue packet after receiving
stdout or stderr from the inferior process.

llvm-svn: 131628
This commit is contained in:
Greg Clayton 2011-05-19 03:54:16 +00:00
parent 41025dc95b
commit af247d7b98
3 changed files with 31 additions and 16 deletions

View File

@ -361,14 +361,21 @@ GDBRemoteCommunicationClient::SendContinuePacketAndWaitForResponse
// make change if we are interrupted and we continue after an async packet...
std::string continue_packet(payload, packet_length);
bool got_stdout = false;
while (state == eStateRunning)
{
if (log)
log->Printf ("GDBRemoteCommunicationClient::%s () sending continue packet: %s", __FUNCTION__, continue_packet.c_str());
if (SendPacket(continue_packet.c_str(), continue_packet.size()) == 0)
state = eStateInvalid;
if (!got_stdout)
{
if (log)
log->Printf ("GDBRemoteCommunicationClient::%s () sending continue packet: %s", __FUNCTION__, continue_packet.c_str());
if (SendPacket(continue_packet.c_str(), continue_packet.size()) == 0)
state = eStateInvalid;
m_private_is_running.SetValue (true, eBroadcastNever);
m_private_is_running.SetValue (true, eBroadcastNever);
}
got_stdout = false;
if (log)
log->Printf ("GDBRemoteCommunicationClient::%s () WaitForPacket(%.*s)", __FUNCTION__);
@ -489,6 +496,7 @@ GDBRemoteCommunicationClient::SendContinuePacketAndWaitForResponse
case 'O':
// STDOUT
{
got_stdout = true;
std::string inferior_stdout;
inferior_stdout.reserve(response.GetBytesLeft () / 2);
char ch;

View File

@ -266,7 +266,7 @@ Thread::ShouldStop (Event* event_ptr)
{
should_stop = current_plan->ShouldStop (event_ptr);
if (log)
log->Printf("Base plan says should stop: %d.", current_plan->GetName(), should_stop);
log->Printf("Base plan says should stop: %i.", should_stop);
}
else
{

View File

@ -197,8 +197,9 @@ ThreadPlanCallFunction::ThreadPlanCallFunction (Thread &thread,
m_start_addr = objectFile->GetEntryPointAddress();
if (!m_start_addr.IsValid())
{
log->Printf ("Could not find entry point address for executable module \"%s\".",
executableModuleSP->GetFileSpec().GetFilename().AsCString());
if (log)
log->Printf ("Could not find entry point address for executable module \"%s\".",
executableModuleSP->GetFileSpec().GetFilename().AsCString());
return;
}
}
@ -247,22 +248,28 @@ ThreadPlanCallFunction::~ThreadPlanCallFunction ()
void
ThreadPlanCallFunction::ReportRegisterState (const char *message)
{
LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_STEP));
LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_STEP | LIBLLDB_LOG_VERBOSE));
if (log)
{
StreamString strm;
RegisterContext *reg_ctx = m_thread.GetRegisterContext().get();
log->PutCString(message);
for (uint32_t register_index = 0, num_registers = reg_ctx->GetRegisterCount();
register_index < num_registers;
++register_index)
RegisterValue reg_value;
for (uint32_t reg_idx = 0, num_registers = reg_ctx->GetRegisterCount();
reg_idx < num_registers;
++reg_idx)
{
const char *register_name = reg_ctx->GetRegisterName(register_index);
uint64_t register_value = reg_ctx->ReadRegisterAsUnsigned(register_index, LLDB_INVALID_ADDRESS);
log->Printf(" %s = 0x%llx", register_name, register_value);
const RegisterInfo *reg_info = reg_ctx->GetRegisterInfoAtIndex (reg_idx);
if (reg_ctx->ReadRegister(reg_info, reg_value))
{
reg_value.Dump(&strm, reg_info, true, false, eFormatDefault);
strm.EOL();
}
}
log->PutCString(strm.GetData());
}
}