[Lldb-commits] [lldb] r158197 - in /lldb/branches/apple/python-GIL: ./ docs/lldb.1 include/lldb/Core/Section.h include/lldb/Target/Process.h source/API/SBDebugger.cpp source/Core/Section.cpp source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp source/Plugins/SymbolVendor/MacOSX/SymbolVendorMacOSX.cpp source/Target/Process.cpp
Filipe Cabecinhas
me at filcab.net
Fri Jun 8 04:08:17 PDT 2012
Author: filcab
Date: Fri Jun 8 06:08:16 2012
New Revision: 158197
URL: http://llvm.org/viewvc/llvm-project?rev=158197&view=rev
Log:
Merge changes from ToT trunk.
Added:
lldb/branches/apple/python-GIL/docs/lldb.1
- copied unchanged from r158191, lldb/trunk/docs/lldb.1
Modified:
lldb/branches/apple/python-GIL/ (props changed)
lldb/branches/apple/python-GIL/include/lldb/Core/Section.h
lldb/branches/apple/python-GIL/include/lldb/Target/Process.h
lldb/branches/apple/python-GIL/source/API/SBDebugger.cpp
lldb/branches/apple/python-GIL/source/Core/Section.cpp
lldb/branches/apple/python-GIL/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
lldb/branches/apple/python-GIL/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
lldb/branches/apple/python-GIL/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp
lldb/branches/apple/python-GIL/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp
lldb/branches/apple/python-GIL/source/Plugins/SymbolVendor/MacOSX/SymbolVendorMacOSX.cpp
lldb/branches/apple/python-GIL/source/Target/Process.cpp
Propchange: lldb/branches/apple/python-GIL/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Fri Jun 8 06:08:16 2012
@@ -1 +1 @@
-/lldb/trunk:156467-158124
+/lldb/trunk:156467-158191
Modified: lldb/branches/apple/python-GIL/include/lldb/Core/Section.h
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/apple/python-GIL/include/lldb/Core/Section.h?rev=158197&r1=158196&r2=158197&view=diff
==============================================================================
--- lldb/branches/apple/python-GIL/include/lldb/Core/Section.h (original)
+++ lldb/branches/apple/python-GIL/include/lldb/Core/Section.h Fri Jun 8 06:08:16 2012
@@ -15,6 +15,7 @@
#include "lldb/Core/Flags.h"
#include "lldb/Core/ModuleChild.h"
#include "lldb/Core/ConstString.h"
+#include "lldb/Core/RangeMap.h"
#include "lldb/Core/UserID.h"
#include "lldb/Core/VMRange.h"
#include <limits.h>
@@ -85,9 +86,23 @@
size_t
Slide (lldb::addr_t slide_amount, bool slide_children);
+
+ // Update all section lookup caches
+ void
+ Finalize ();
protected:
collection m_sections;
+
+ typedef RangeDataArray<uint64_t, uint64_t, collection::size_type, 1> SectionRangeCache;
+ mutable SectionRangeCache m_range_cache;
+#ifdef LLDB_CONFIGURATION_DEBUG
+ mutable bool m_finalized;
+#endif
+
+ void BuildRangeCache() const;
+
+ void InvalidateRangeCache() const;
};
@@ -273,6 +288,13 @@
{
m_thread_specific = b;
}
+
+ // Update all section lookup caches
+ void
+ Finalize ()
+ {
+ m_children.Finalize();
+ }
protected:
Modified: lldb/branches/apple/python-GIL/include/lldb/Target/Process.h
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/apple/python-GIL/include/lldb/Target/Process.h?rev=158197&r1=158196&r2=158197&view=diff
==============================================================================
--- lldb/branches/apple/python-GIL/include/lldb/Target/Process.h (original)
+++ lldb/branches/apple/python-GIL/include/lldb/Target/Process.h Fri Jun 8 06:08:16 2012
@@ -82,15 +82,23 @@
StringList &value,
Error *err);
-
+ bool GetDisableMemoryCache() const
+ {
+ return m_disable_memory_cache;
+ }
+
protected:
-
+ const ConstString &
+ GetDisableMemoryCacheVarName () const;
+
void
CopyInstanceSettings (const lldb::InstanceSettingsSP &new_settings,
bool pending);
const ConstString
CreateInstanceName ();
+
+ bool m_disable_memory_cache;
};
//----------------------------------------------------------------------
Modified: lldb/branches/apple/python-GIL/source/API/SBDebugger.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/apple/python-GIL/source/API/SBDebugger.cpp?rev=158197&r1=158196&r2=158197&view=diff
==============================================================================
--- lldb/branches/apple/python-GIL/source/API/SBDebugger.cpp (original)
+++ lldb/branches/apple/python-GIL/source/API/SBDebugger.cpp Fri Jun 8 06:08:16 2012
@@ -147,7 +147,14 @@
// non-mandatory. We have seen deadlocks with this function when called
// so we need to safeguard against this until we can determine what is
// causing the deadlocks.
+ LogSP log (GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
+
const bool mandatory = false;
+ if (log)
+ {
+ log->Printf ("SBDebugger::MemoryPressureDetected (), mandatory = %d", mandatory);
+ }
+
ModuleList::RemoveOrphanSharedModules(mandatory);
}
Modified: lldb/branches/apple/python-GIL/source/Core/Section.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/apple/python-GIL/source/Core/Section.cpp?rev=158197&r1=158196&r2=158197&view=diff
==============================================================================
--- lldb/branches/apple/python-GIL/source/Core/Section.cpp (original)
+++ lldb/branches/apple/python-GIL/source/Core/Section.cpp Fri Jun 8 06:08:16 2012
@@ -379,6 +379,9 @@
SectionList::SectionList () :
m_sections()
+#ifdef LLDB_CONFIGURATION_DEBUG
+ , m_finalized(false)
+#endif
{
}
@@ -393,6 +396,7 @@
assert (section_sp.get());
uint32_t section_index = m_sections.size();
m_sections.push_back(section_sp);
+ InvalidateRangeCache();
return section_index;
}
@@ -432,6 +436,7 @@
if ((*sect_iter)->GetID() == sect_id)
{
*sect_iter = sect_sp;
+ InvalidateRangeCache();
return true;
}
else if (depth > 0)
@@ -565,26 +570,69 @@
return sect_sp;
}
+void
+SectionList::BuildRangeCache() const
+{
+ m_range_cache.Clear();
+
+ for (collection::size_type idx = 0, last_idx = m_sections.size();
+ idx < last_idx;
+ ++idx)
+ {
+ Section *sect = m_sections[idx].get();
+
+ addr_t linked_file_address = sect->GetLinkedFileAddress();
+
+ if (linked_file_address != LLDB_INVALID_ADDRESS)
+ m_range_cache.Append(SectionRangeCache::Entry(linked_file_address, sect->GetByteSize(), idx));
+ }
+
+ m_range_cache.Sort();
+
+#ifdef LLDB_CONFIGURATION_DEBUG
+ m_finalized = true;
+#endif
+}
+
+void
+SectionList::InvalidateRangeCache() const
+{
+#ifdef LLDB_CONFIGURATION_DEBUG
+ assert(!m_finalized);
+#endif
+ m_range_cache.Clear();
+}
SectionSP
SectionList::FindSectionContainingLinkedFileAddress (addr_t vm_addr, uint32_t depth) const
{
- SectionSP sect_sp;
- const_iterator sect_iter;
- const_iterator end = m_sections.end();
- for (sect_iter = m_sections.begin(); sect_iter != end && sect_sp.get() == NULL; ++sect_iter)
- {
- Section *sect = sect_iter->get();
- if (sect->ContainsLinkedFileAddress (vm_addr))
- {
- sect_sp = *sect_iter;
- }
- else if (depth > 0)
- {
- sect_sp = sect->GetChildren().FindSectionContainingLinkedFileAddress (vm_addr, depth - 1);
- }
+ //if (m_range_cache.IsEmpty())
+ // BuildRangeCache();
+#ifdef LLDB_CONFIGURATION_DEBUG
+ assert(m_finalized);
+#endif
+
+ SectionRangeCache::Entry *entry = m_range_cache.FindEntryThatContains(vm_addr);
+
+ if (entry)
+ return m_sections[entry->data];
+
+ if (depth == 0)
+ return SectionSP();
+
+ for (const_iterator si = m_sections.begin(), se = m_sections.end();
+ si != se;
+ ++si)
+ {
+ Section *sect = si->get();
+
+ SectionSP sect_sp = sect->GetChildren().FindSectionContainingLinkedFileAddress(vm_addr, depth - 1);
+
+ if (sect_sp)
+ return sect_sp;
}
- return sect_sp;
+
+ return SectionSP();
}
bool
@@ -628,6 +676,22 @@
if ((*pos)->Slide(slide_amount, slide_children))
++count;
}
+ InvalidateRangeCache();
return count;
}
+void
+SectionList::Finalize ()
+{
+ BuildRangeCache();
+
+ for (const_iterator si = m_sections.begin(), se = m_sections.end();
+ si != se;
+ ++si)
+ {
+ Section *sect = si->get();
+
+ sect->GetChildren().Finalize();
+ }
+}
+
Modified: lldb/branches/apple/python-GIL/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/apple/python-GIL/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp?rev=158197&r1=158196&r2=158197&view=diff
==============================================================================
--- lldb/branches/apple/python-GIL/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp (original)
+++ lldb/branches/apple/python-GIL/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp Fri Jun 8 06:08:16 2012
@@ -682,6 +682,8 @@
section_sp->SetIsThreadSpecific (is_thread_specific);
m_sections_ap->AddSection(section_sp);
}
+
+ m_sections_ap->Finalize(); // Now that we're done adding sections, finalize to build fast-lookup caches
}
return m_sections_ap.get();
Modified: lldb/branches/apple/python-GIL/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/apple/python-GIL/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp?rev=158197&r1=158196&r2=158197&view=diff
==============================================================================
--- lldb/branches/apple/python-GIL/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp (original)
+++ lldb/branches/apple/python-GIL/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp Fri Jun 8 06:08:16 2012
@@ -889,7 +889,7 @@
// adjust the child section offsets for all existing children.
const lldb::addr_t slide_amount = sect64_min_addr - curr_seg_min_addr;
segment->Slide(slide_amount, false);
- segment->GetChildren().Slide (-slide_amount, false);
+ segment->GetChildren().Slide(-slide_amount, false);
segment->SetByteSize (curr_seg_max_addr - sect64_min_addr);
}
Modified: lldb/branches/apple/python-GIL/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/apple/python-GIL/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp?rev=158197&r1=158196&r2=158197&view=diff
==============================================================================
--- lldb/branches/apple/python-GIL/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp (original)
+++ lldb/branches/apple/python-GIL/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp Fri Jun 8 06:08:16 2012
@@ -648,6 +648,8 @@
m_sections_ap->AddSection(section_sp);
}
+
+ m_sections_ap->Finalize(); // Now that we're done adding sections, finalize to build fast-lookup caches
}
}
return m_sections_ap.get();
Modified: lldb/branches/apple/python-GIL/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/apple/python-GIL/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp?rev=158197&r1=158196&r2=158197&view=diff
==============================================================================
--- lldb/branches/apple/python-GIL/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp (original)
+++ lldb/branches/apple/python-GIL/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp Fri Jun 8 06:08:16 2012
@@ -426,6 +426,8 @@
}
}
}
+ oso_objfile->GetSectionList()->Finalize(); // Now that we're done adding sections, finalize to build fast-lookup caches
+ comp_unit_info->debug_map_sections_sp->Finalize();
#if defined(DEBUG_OSO_DMAP)
s << "OSO sections after:\n";
oso_objfile->GetSectionList()->Dump(&s, NULL, true);
Modified: lldb/branches/apple/python-GIL/source/Plugins/SymbolVendor/MacOSX/SymbolVendorMacOSX.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/apple/python-GIL/source/Plugins/SymbolVendor/MacOSX/SymbolVendorMacOSX.cpp?rev=158197&r1=158196&r2=158197&view=diff
==============================================================================
--- lldb/branches/apple/python-GIL/source/Plugins/SymbolVendor/MacOSX/SymbolVendorMacOSX.cpp (original)
+++ lldb/branches/apple/python-GIL/source/Plugins/SymbolVendor/MacOSX/SymbolVendorMacOSX.cpp Fri Jun 8 06:08:16 2012
@@ -78,6 +78,8 @@
dsym_section_list->AddSection(exec_sect_sp);
}
}
+
+ dsym_section_list->Finalize(); // Now that we're done adding sections, finalize to build fast-lookup caches
}
}
Modified: lldb/branches/apple/python-GIL/source/Target/Process.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/apple/python-GIL/source/Target/Process.cpp?rev=158197&r1=158196&r2=158197&view=diff
==============================================================================
--- lldb/branches/apple/python-GIL/source/Target/Process.cpp (original)
+++ lldb/branches/apple/python-GIL/source/Target/Process.cpp Fri Jun 8 06:08:16 2012
@@ -1933,64 +1933,55 @@
}
-// Comment out line below to disable memory caching
+// Comment out line below to disable memory caching, overriding the process setting
+// target.process.disable-memory-cache
#define ENABLE_MEMORY_CACHING
// Uncomment to verify memory caching works after making changes to caching code
//#define VERIFY_MEMORY_READS
-#if defined (ENABLE_MEMORY_CACHING)
-
-#if defined (VERIFY_MEMORY_READS)
-
size_t
Process::ReadMemory (addr_t addr, void *buf, size_t size, Error &error)
{
- // Memory caching is enabled, with debug verification
- if (buf && size)
+ if (!GetDisableMemoryCache())
+ {
+#if defined (VERIFY_MEMORY_READS)
+ // Memory caching is enabled, with debug verification
+
+ if (buf && size)
+ {
+ // Uncomment the line below to make sure memory caching is working.
+ // I ran this through the test suite and got no assertions, so I am
+ // pretty confident this is working well. If any changes are made to
+ // memory caching, uncomment the line below and test your changes!
+
+ // Verify all memory reads by using the cache first, then redundantly
+ // reading the same memory from the inferior and comparing to make sure
+ // everything is exactly the same.
+ std::string verify_buf (size, '\0');
+ assert (verify_buf.size() == size);
+ const size_t cache_bytes_read = m_memory_cache.Read (this, addr, buf, size, error);
+ Error verify_error;
+ const size_t verify_bytes_read = ReadMemoryFromInferior (addr, const_cast<char *>(verify_buf.data()), verify_buf.size(), verify_error);
+ assert (cache_bytes_read == verify_bytes_read);
+ assert (memcmp(buf, verify_buf.data(), verify_buf.size()) == 0);
+ assert (verify_error.Success() == error.Success());
+ return cache_bytes_read;
+ }
+ return 0;
+#else // !defined(VERIFY_MEMORY_READS)
+ // Memory caching is enabled, without debug verification
+
+ return m_memory_cache.Read (addr, buf, size, error);
+#endif // defined (VERIFY_MEMORY_READS)
+ }
+ else
{
- // Uncomment the line below to make sure memory caching is working.
- // I ran this through the test suite and got no assertions, so I am
- // pretty confident this is working well. If any changes are made to
- // memory caching, uncomment the line below and test your changes!
-
- // Verify all memory reads by using the cache first, then redundantly
- // reading the same memory from the inferior and comparing to make sure
- // everything is exactly the same.
- std::string verify_buf (size, '\0');
- assert (verify_buf.size() == size);
- const size_t cache_bytes_read = m_memory_cache.Read (this, addr, buf, size, error);
- Error verify_error;
- const size_t verify_bytes_read = ReadMemoryFromInferior (addr, const_cast<char *>(verify_buf.data()), verify_buf.size(), verify_error);
- assert (cache_bytes_read == verify_bytes_read);
- assert (memcmp(buf, verify_buf.data(), verify_buf.size()) == 0);
- assert (verify_error.Success() == error.Success());
- return cache_bytes_read;
+ // Memory caching is disabled
+
+ return ReadMemoryFromInferior (addr, buf, size, error);
}
- return 0;
-}
-
-#else // #if defined (VERIFY_MEMORY_READS)
-
-size_t
-Process::ReadMemory (addr_t addr, void *buf, size_t size, Error &error)
-{
- // Memory caching enabled, no verification
- return m_memory_cache.Read (addr, buf, size, error);
}
-
-#endif // #else for #if defined (VERIFY_MEMORY_READS)
-#else // #if defined (ENABLE_MEMORY_CACHING)
-
-size_t
-Process::ReadMemory (addr_t addr, void *buf, size_t size, Error &error)
-{
- // Memory caching is disabled
- return ReadMemoryFromInferior (addr, buf, size, error);
-}
-
-#endif // #else for #if defined (ENABLE_MEMORY_CACHING)
-
size_t
Process::ReadCStringFromMemory (addr_t addr, std::string &out_str, Error &error)
{
@@ -3993,7 +3984,6 @@
}
}
UserSettingsControllerSP &usc = GetSettingsController();
- usc.reset (new SettingsController);
UserSettingsController::InitializeSettingsController (usc,
SettingsController::global_settings_table,
SettingsController::instance_settings_table);
@@ -4914,16 +4904,36 @@
Error &err,
bool pending)
{
+ if (var_name == GetDisableMemoryCacheVarName())
+ {
+ bool success;
+ bool result = Args::StringToBoolean(value, false, &success);
+
+ if (success)
+ {
+ m_disable_memory_cache = result;
+ }
+ else
+ {
+ err.SetErrorStringWithFormat ("Bad value \"%s\" for %s, should be Boolean.", value, GetDisableMemoryCacheVarName().AsCString());
+ }
+
+ }
}
void
ProcessInstanceSettings::CopyInstanceSettings (const lldb::InstanceSettingsSP &new_settings,
bool pending)
{
-// if (new_settings.get() == NULL)
-// return;
-//
-// ProcessInstanceSettings *new_process_settings = (ProcessInstanceSettings *) new_settings.get();
+ if (new_settings.get() == NULL)
+ return;
+
+ ProcessInstanceSettings *new_settings_ptr = static_cast <ProcessInstanceSettings *> (new_settings.get());
+
+ if (!new_settings_ptr)
+ return;
+
+ *this = *new_settings_ptr;
}
bool
@@ -4932,9 +4942,17 @@
StringList &value,
Error *err)
{
- if (err)
- err->SetErrorStringWithFormat ("unrecognized variable name '%s'", var_name.AsCString());
- return false;
+ if (var_name == GetDisableMemoryCacheVarName())
+ {
+ value.AppendString(m_disable_memory_cache ? "true" : "false");
+ return true;
+ }
+ else
+ {
+ if (err)
+ err->SetErrorStringWithFormat ("unrecognized variable name '%s'", var_name.AsCString());
+ return false;
+ }
}
const ConstString
@@ -4950,6 +4968,14 @@
return ret_val;
}
+const ConstString &
+ProcessInstanceSettings::GetDisableMemoryCacheVarName () const
+{
+ static ConstString disable_memory_cache_var_name ("disable-memory-cache");
+
+ return disable_memory_cache_var_name;
+}
+
//--------------------------------------------------
// SettingsController Variable Tables
//--------------------------------------------------
@@ -4966,6 +4992,13 @@
Process::SettingsController::instance_settings_table[] =
{
//{ "var-name", var-type, "default", enum-table, init'd, hidden, "help-text"},
+ { "disable-memory-cache", eSetVarTypeBoolean,
+#ifdef ENABLE_MEMORY_CACHING
+ "false",
+#else
+ "true",
+#endif
+ NULL, false, false, "Disable reading and caching of memory in fixed-size units." },
{ NULL, eSetVarTypeNone, NULL, NULL, false, false, NULL }
};
More information about the lldb-commits
mailing list