Skip to content

Commit

Permalink
Add a new target.process.memory-cache-line-size to change the size of
Browse files Browse the repository at this point in the history
lldb's internal memory cache chunks that are read from the remote
system.  For a remote connection that is especially slow, a user may
need to reduce it; reading a 512 byte chunk of memory whenever a
4-byte region is requested may not be the right decision in these
kinds of environments.
<rdar://problem/18175117> 

llvm-svn: 217083
  • Loading branch information
jasonmolenda committed Sep 3, 2014
1 parent b67bc4e commit f0340c9
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 3 deletions.
2 changes: 1 addition & 1 deletion lldb/include/lldb/Interpreter/Property.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ namespace lldb_private {
{
const char *name;
OptionValue::Type type;
bool global;
bool global; // false == this setting is a global setting by default
uintptr_t default_uint_value;
const char *default_cstr_value;
OptionEnumValueElement *enum_values;
Expand Down
3 changes: 3 additions & 0 deletions lldb/include/lldb/Target/Process.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,9 @@ class ProcessProperties : public Properties
bool
GetDisableMemoryCache() const;

uint64_t
GetMemoryCacheLineSize () const;

Args
GetExtraStartupCommands () const;

Expand Down
3 changes: 2 additions & 1 deletion lldb/source/Target/Memory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ using namespace lldb_private;
//----------------------------------------------------------------------
MemoryCache::MemoryCache(Process &process) :
m_process (process),
m_cache_line_byte_size (512),
m_cache_line_byte_size (process.GetMemoryCacheLineSize()),
m_mutex (Mutex::eMutexTypeRecursive),
m_cache (),
m_invalid_ranges ()
Expand All @@ -47,6 +47,7 @@ MemoryCache::Clear(bool clear_invalid_ranges)
m_cache.clear();
if (clear_invalid_ranges)
m_invalid_ranges.Clear();
m_cache_line_byte_size = m_process.GetMemoryCacheLineSize();
}

void
Expand Down
11 changes: 10 additions & 1 deletion lldb/source/Target/Process.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ g_properties[] =
{ "python-os-plugin-path", OptionValue::eTypeFileSpec, false, true, NULL, NULL, "A path to a python OS plug-in module file that contains a OperatingSystemPlugIn class." },
{ "stop-on-sharedlibrary-events" , OptionValue::eTypeBoolean, true, false, NULL, NULL, "If true, stop when a shared library is loaded or unloaded." },
{ "detach-keeps-stopped" , OptionValue::eTypeBoolean, true, false, NULL, NULL, "If true, detach will attempt to keep the process stopped." },
{ "memory-cache-line-size" , OptionValue::eTypeUInt64, false, 512, NULL, NULL, "The memory cache line size" },
{ NULL , OptionValue::eTypeInvalid, false, 0, NULL, NULL, NULL }
};

Expand All @@ -118,7 +119,8 @@ enum {
ePropertyUnwindOnErrorInExpressions,
ePropertyPythonOSPluginPath,
ePropertyStopOnSharedLibraryEvents,
ePropertyDetachKeepsStopped
ePropertyDetachKeepsStopped,
ePropertyMemCacheLineSize
};

ProcessProperties::ProcessProperties (bool is_global) :
Expand Down Expand Up @@ -148,6 +150,13 @@ ProcessProperties::GetDisableMemoryCache() const
return m_collection_sp->GetPropertyAtIndexAsBoolean (NULL, idx, g_properties[idx].default_uint_value != 0);
}

uint64_t
ProcessProperties::GetMemoryCacheLineSize() const
{
const uint32_t idx = ePropertyMemCacheLineSize;
return m_collection_sp->GetPropertyAtIndexAsUInt64 (NULL, idx, g_properties[idx].default_uint_value);
}

Args
ProcessProperties::GetExtraStartupCommands () const
{
Expand Down
5 changes: 5 additions & 0 deletions lldb/source/Target/Target.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1436,7 +1436,12 @@ Target::ReadCStringFromMemory (const Address& addr, char *dst, size_t dst_max_le
Error error;
addr_t curr_addr = addr.GetLoadAddress(this);
Address address(addr);

// We could call m_process_sp->GetMemoryCacheLineSize() but I don't
// think this really needs to be tied to the memory cache subsystem's
// cache line size, so leave this as a fixed constant.
const size_t cache_line_size = 512;

size_t bytes_left = dst_max_len - 1;
char *curr_dst = dst;

Expand Down

0 comments on commit f0340c9

Please sign in to comment.