hanchenye-llvm-project/lldb/source/Core/InputReaderEZ.cpp

92 lines
2.7 KiB
C++
Raw Normal View History

//===-- InputReaderEZ.cpp ---------------------------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#include "lldb/Core/InputReaderEZ.h"
using namespace lldb;
using namespace lldb_private;
size_t
InputReaderEZ::Callback_Impl(void *baton,
InputReader &reader,
lldb::InputReaderAction notification,
const char *bytes,
size_t bytes_len)
{
HandlerData hand_data(reader,
bytes,
bytes_len,
baton);
switch (notification)
{
case eInputReaderActivate:
reader.ActivateHandler(hand_data);
break;
case eInputReaderDeactivate:
reader.DeactivateHandler(hand_data);
break;
case eInputReaderReactivate:
reader.ReactivateHandler(hand_data);
break;
case eInputReaderAsynchronousOutputWritten:
reader.AsynchronousOutputWrittenHandler(hand_data);
break;
case eInputReaderGotToken:
{
if (reader.GetSaveUserInput())
reader.GetUserInput().AppendString(bytes, bytes_len);
reader.GotTokenHandler(hand_data);
}
break;
case eInputReaderInterrupt:
reader.InterruptHandler(hand_data);
break;
case eInputReaderEndOfFile:
reader.EOFHandler(hand_data);
break;
case eInputReaderDone:
reader.DoneHandler(hand_data);
break;
}
return bytes_len;
}
Error
InputReaderEZ::Initialize(void* baton,
lldb::InputReaderGranularity token_size,
const char* end_token,
const char *prompt,
bool echo)
{
return InputReader::Initialize(Callback_Impl,
baton,
token_size,
end_token,
prompt,
echo);
}
Error
InputReaderEZ::Initialize(InitializationParameters& params)
{
Error ret = Initialize(params.m_baton,
params.m_token_size,
params.m_end_token,
params.m_prompt,
params.m_echo);
m_save_user_input = params.m_save_user_input;
return ret;
}
InputReaderEZ::~InputReaderEZ ()
{
While tracking down memory consumption issue a few things were needed: the ability to dump more information about modules in "target modules list". We can now dump the shared pointer reference count for modules, the pointer to the module itself (in case performance tools can help track down who has references to said pointer), and the modification time. Added "target delete [target-idx ...]" to be able to delete targets when they are no longer needed. This will help track down memory usage issues and help to resolve when module ref counts keep getting incremented. If the command gets no arguments, the currently selected target will be deleted. If any arguments are given, they must all be valid target indexes (use the "target list" command to get the current target indexes). Took care of a bunch of "no newline at end of file" warnings. TimeValue objects can now dump their time to a lldb_private::Stream object. Modified the "target modules list --global" command to not error out if there are no targets since it doesn't require a target. Fixed an issue in the MacOSX DYLD dynamic loader plug-in where if a shared library was updated on disk, we would keep using the older one, even if it was updated. Don't allow the ModuleList::GetSharedModule(...) to return an empty module. Previously we could specify a valid path on disc to a module, and specify an architecture that wasn't contained in that module and get a shared pointer to a module that wouldn't be able to return an object file or a symbol file. We now make sure an object file can be extracted prior to adding the shared pointer to the module to get added to the shared list. llvm-svn: 137196
2011-08-10 10:10:13 +08:00
}