llvm-project/lldb/source/Expression/ProcessDataAllocator.cpp

44 lines
1.6 KiB
C++
Raw Normal View History

//===-- ProcessDataAllocator.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/DataBufferHeap.h"
#include "lldb/Core/DataExtractor.h"
#include "lldb/Expression/ProcessDataAllocator.h"
using namespace lldb_private;
void
ProcessDataAllocator::Dump(Stream &stream)
{
size_t data_size = m_stream_string.GetSize();
if (!m_allocation)
return;
lldb::DataBufferSP data(new DataBufferHeap(data_size, 0));
Error error;
if (m_process.ReadMemory (m_allocation, data->GetBytes(), data_size, error) != data_size)
return;
DataExtractor extractor(data, m_process.GetByteOrder(), m_process.GetAddressByteSize());
extractor.Dump(&stream, // stream
0, // offset
lldb::eFormatBytesWithASCII, // format
1, // byte size of individual entries
data_size, // number of entries
16, // entries per line
m_allocation, // address to print
0, // bit size (bitfields only; 0 means ignore)
0); // bit alignment (bitfields only; 0 means ignore)
stream.PutChar('\n');
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
}