summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lldb/include/lldb/Core/Section.h4
-rw-r--r--lldb/include/lldb/Target/SectionLoadList.h15
-rw-r--r--lldb/source/Commands/CommandObjectImage.cpp2
-rw-r--r--lldb/source/Core/Communication.cpp1
-rw-r--r--lldb/source/Core/ModuleList.cpp4
-rw-r--r--lldb/source/Core/Section.cpp9
-rw-r--r--lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.cpp22
-rw-r--r--lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.h12
-rw-r--r--lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp2
-rw-r--r--lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp2
-rw-r--r--lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp2
-rw-r--r--lldb/source/Target/Process.cpp17
-rw-r--r--lldb/source/Target/SectionLoadList.cpp100
13 files changed, 108 insertions, 84 deletions
diff --git a/lldb/include/lldb/Core/Section.h b/lldb/include/lldb/Core/Section.h
index d2052167626..916f0745850 100644
--- a/lldb/include/lldb/Core/Section.h
+++ b/lldb/include/lldb/Core/Section.h
@@ -46,7 +46,7 @@ public:
ContainsSection(lldb::user_id_t sect_id) const;
void
- Dump (Stream *s, Target *target, bool show_header) const;
+ Dump (Stream *s, Target *target, bool show_header, uint32_t depth) const;
lldb::SectionSP
FindSectionByName (const ConstString &section_dstr) const;
@@ -137,7 +137,7 @@ public:
}
void
- Dump (Stream *s, Target *target) const;
+ Dump (Stream *s, Target *target, uint32_t depth) const;
void
DumpName (Stream *s) const;
diff --git a/lldb/include/lldb/Target/SectionLoadList.h b/lldb/include/lldb/Target/SectionLoadList.h
index 3696383802a..dc961d94938 100644
--- a/lldb/include/lldb/Target/SectionLoadList.h
+++ b/lldb/include/lldb/Target/SectionLoadList.h
@@ -12,10 +12,12 @@
// C Includes
// C++ Includes
+#include <map>
+
// Other libraries and framework includes
// Project includes
#include "lldb/lldb-include.h"
-#include "lldb/Core/ThreadSafeSTLMap.h"
+#include "lldb/Host/Mutex.h"
namespace lldb_private {
@@ -26,7 +28,9 @@ public:
// Constructors and Destructors
//------------------------------------------------------------------
SectionLoadList () :
- m_section_load_info ()
+ m_collection (),
+ m_mutex (Mutex::eMutexTypeRecursive)
+
{
}
@@ -61,10 +65,13 @@ public:
size_t
SetSectionUnloaded (const Section *section);
+ void
+ Dump (Stream &s, Target *target);
protected:
- typedef ThreadSafeSTLMap<lldb::addr_t, const Section *> collection;
- collection m_section_load_info; ///< A mapping of all currently loaded sections.
+ typedef std::map<lldb::addr_t, const Section *> collection;
+ collection m_collection;
+ mutable Mutex m_mutex;
private:
DISALLOW_COPY_AND_ASSIGN (SectionLoadList);
diff --git a/lldb/source/Commands/CommandObjectImage.cpp b/lldb/source/Commands/CommandObjectImage.cpp
index 6a1037ae346..58907bfd2d1 100644
--- a/lldb/source/Commands/CommandObjectImage.cpp
+++ b/lldb/source/Commands/CommandObjectImage.cpp
@@ -185,7 +185,7 @@ DumpModuleSections (CommandInterpreter &interpreter, Stream &strm, Module *modul
strm << module->GetFileSpec();
strm.Printf ("' (%s):\n", module->GetArchitecture().AsCString());
strm.IndentMore();
- section_list->Dump(&strm, interpreter.GetDebugger().GetExecutionContext().target, true);
+ section_list->Dump(&strm, interpreter.GetDebugger().GetExecutionContext().target, true, UINT32_MAX);
strm.IndentLess();
}
}
diff --git a/lldb/source/Core/Communication.cpp b/lldb/source/Core/Communication.cpp
index f9a4be1a6db..f6100d74f39 100644
--- a/lldb/source/Core/Communication.cpp
+++ b/lldb/source/Core/Communication.cpp
@@ -346,6 +346,7 @@ Communication::ReadThread (void *p)
// Let clients know that this thread is exiting
comm->BroadcastEvent (eBroadcastBitReadThreadDidExit);
+ comm->m_read_thread = LLDB_INVALID_HOST_THREAD;
return NULL;
}
diff --git a/lldb/source/Core/ModuleList.cpp b/lldb/source/Core/ModuleList.cpp
index cf408687616..3d9cc5ee03e 100644
--- a/lldb/source/Core/ModuleList.cpp
+++ b/lldb/source/Core/ModuleList.cpp
@@ -223,13 +223,13 @@ public:
return false;
}
- if (m_arch_ptr)
+ if (m_arch_ptr && m_arch_ptr->IsValid())
{
if (module_sp->GetArchitecture() != *m_arch_ptr)
return false;
}
- if (m_uuid_ptr)
+ if (m_uuid_ptr && m_uuid_ptr->IsValid())
{
if (module_sp->GetUUID() != *m_uuid_ptr)
return false;
diff --git a/lldb/source/Core/Section.cpp b/lldb/source/Core/Section.cpp
index 9ce418dead2..d2682f5bded 100644
--- a/lldb/source/Core/Section.cpp
+++ b/lldb/source/Core/Section.cpp
@@ -222,7 +222,7 @@ Section::Compare (const Section& a, const Section& b)
void
-Section::Dump (Stream *s, Target *target) const
+Section::Dump (Stream *s, Target *target, uint32_t depth) const
{
// s->Printf("%.*p: ", (int)sizeof(void*) * 2, this);
s->Indent();
@@ -283,7 +283,8 @@ Section::Dump (Stream *s, Target *target) const
s->Printf(" + 0x%llx\n", m_linked_offset);
}
- m_children.Dump(s, target, false);
+ if (depth > 0)
+ m_children.Dump(s, target, false, depth - 1);
}
void
@@ -666,7 +667,7 @@ SectionList::ContainsSection(user_id_t sect_id) const
}
void
-SectionList::Dump (Stream *s, Target *target, bool show_header) const
+SectionList::Dump (Stream *s, Target *target, bool show_header, uint32_t depth) const
{
bool target_has_loaded_sections = target && !target->GetSectionLoadList().IsEmpty();
if (show_header && !m_sections.empty())
@@ -688,7 +689,7 @@ SectionList::Dump (Stream *s, Target *target, bool show_header) const
const_iterator end = m_sections.end();
for (sect_iter = m_sections.begin(); sect_iter != end; ++sect_iter)
{
- (*sect_iter)->Dump(s, target_has_loaded_sections ? target : NULL);
+ (*sect_iter)->Dump(s, target_has_loaded_sections ? target : NULL, depth);
}
if (show_header && !m_sections.empty())
diff --git a/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.cpp b/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.cpp
index 227a981b809..f0477e85208 100644
--- a/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.cpp
+++ b/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.cpp
@@ -1019,33 +1019,13 @@ DynamicLoaderMacOSXDYLD::PutToLog(Log *log) const
}
}
-//----------------------------------------------------------------------
-// Static callback function that gets called when the process state
-// changes.
-//----------------------------------------------------------------------
-void
-DynamicLoaderMacOSXDYLD::Initialize(void *baton, Process *process)
-{
- ((DynamicLoaderMacOSXDYLD*)baton)->PrivateInitialize(process);
-}
-
void
DynamicLoaderMacOSXDYLD::PrivateInitialize(Process *process)
{
DEBUG_PRINTF("DynamicLoaderMacOSXDYLD::%s() process state = %s\n", __FUNCTION__, StateAsCString(m_process->GetState()));
Clear(true);
m_process = process;
-}
-
-
-//----------------------------------------------------------------------
-// Static callback function that gets called when the process state
-// changes.
-//----------------------------------------------------------------------
-void
-DynamicLoaderMacOSXDYLD::ProcessStateChanged(void *baton, Process *process, StateType state)
-{
- ((DynamicLoaderMacOSXDYLD*)baton)->PrivateProcessStateChanged(process, state);
+ m_process->GetTarget().GetSectionLoadList().Clear();
}
bool
diff --git a/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.h b/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.h
index d8dbe711b3d..f4101eea45d 100644
--- a/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.h
+++ b/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.h
@@ -62,18 +62,6 @@ public:
virtual void
DidLaunch ();
- //------------------------------------------------------------------
- // Process::Notifications callback functions
- //------------------------------------------------------------------
- static void
- Initialize (void *baton,
- lldb_private::Process *process);
-
- static void
- ProcessStateChanged (void *baton,
- lldb_private::Process *process,
- lldb::StateType state);
-
virtual lldb::ThreadPlanSP
GetStepThroughTrampolinePlan (lldb_private::Thread &thread,
bool stop_others);
diff --git a/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp b/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
index 85c337f7ae1..3f6dd20fa95 100644
--- a/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
+++ b/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
@@ -684,7 +684,7 @@ ObjectFileELF::Dump(Stream *s)
s->EOL();
SectionList *section_list = GetSectionList();
if (section_list)
- section_list->Dump(s, NULL, true);
+ section_list->Dump(s, NULL, true, UINT32_MAX);
Symtab *symtab = GetSymtab();
if (symtab)
symtab->Dump(s, NULL, lldb::eSortOrderNone);
diff --git a/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp b/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
index 51914f469b1..0e82a15f391 100644
--- a/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
+++ b/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
@@ -1346,7 +1346,7 @@ ObjectFileMachO::Dump (Stream *s)
*s << ", file = '" << m_file << "', arch = " << header_arch.AsCString() << "\n";
if (m_sections_ap.get())
- m_sections_ap->Dump(s, NULL, true);
+ m_sections_ap->Dump(s, NULL, true, UINT32_MAX);
if (m_symtab_ap.get())
m_symtab_ap->Dump(s, NULL, eSortOrderNone);
diff --git a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
index 4cc5382dca9..bb36cee5735 100644
--- a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
+++ b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
@@ -1242,7 +1242,7 @@ ProcessGDBRemote::DoDestroy ()
bool
ProcessGDBRemote::IsAlive ()
{
- return m_gdb_comm.IsConnected();
+ return m_gdb_comm.IsConnected() && m_private_state.GetValue() != eStateExited;
}
addr_t
diff --git a/lldb/source/Target/Process.cpp b/lldb/source/Target/Process.cpp
index 26f35460842..f91c6194ea5 100644
--- a/lldb/source/Target/Process.cpp
+++ b/lldb/source/Target/Process.cpp
@@ -414,13 +414,18 @@ Process::GetExitDescription ()
void
Process::SetExitStatus (int status, const char *cstr)
{
- m_exit_status = status;
- if (cstr)
- m_exit_string = cstr;
- else
- m_exit_string.clear();
+ if (m_private_state.GetValue() != eStateExited)
+ {
+ m_exit_status = status;
+ if (cstr)
+ m_exit_string = cstr;
+ else
+ m_exit_string.clear();
- SetPrivateState (eStateExited);
+ DidExit ();
+
+ SetPrivateState (eStateExited);
+ }
}
// This static callback can be used to watch for local child processes on
diff --git a/lldb/source/Target/SectionLoadList.cpp b/lldb/source/Target/SectionLoadList.cpp
index fc806a55cb9..0dcbba42fcb 100644
--- a/lldb/source/Target/SectionLoadList.cpp
+++ b/lldb/source/Target/SectionLoadList.cpp
@@ -28,13 +28,15 @@ using namespace lldb_private;
bool
SectionLoadList::IsEmpty() const
{
- return m_section_load_info.IsEmpty();
+ Mutex::Locker locker(m_mutex);
+ return m_collection.empty();
}
void
SectionLoadList::Clear ()
{
- m_section_load_info.Clear();
+ Mutex::Locker locker(m_mutex);
+ return m_collection.clear();
}
addr_t
@@ -42,9 +44,22 @@ SectionLoadList::GetSectionLoadAddress (const Section *section) const
{
// TODO: add support for the same section having multiple load addresses
addr_t section_load_addr = LLDB_INVALID_ADDRESS;
- if (m_section_load_info.GetFirstKeyForValue (section, section_load_addr))
- return section_load_addr;
- return LLDB_INVALID_ADDRESS;
+ if (section)
+ {
+ Mutex::Locker locker(m_mutex);
+ collection::const_iterator pos, end = m_collection.end();
+ for (pos = m_collection.begin(); pos != end; ++pos)
+ {
+ const addr_t pos_load_addr = pos->first;
+ const Section *pos_section = pos->second;
+ if (pos_section == section)
+ {
+ section_load_addr = pos_load_addr;
+ break;
+ }
+ }
+ }
+ return section_load_addr;
}
bool
@@ -60,16 +75,19 @@ SectionLoadList::SetSectionLoadAddress (const Section *section, addr_t load_addr
section->GetName().AsCString(),
load_addr);
-
- const Section *existing_section = NULL;
- Mutex::Locker locker(m_section_load_info.GetMutex());
-
- if (m_section_load_info.GetValueForKeyNoLock (load_addr, existing_section))
+ Mutex::Locker locker(m_mutex);
+ collection::iterator pos = m_collection.find(load_addr);
+ if (pos != m_collection.end())
{
- if (existing_section == section)
- return false; // No change
+ if (section == pos->second)
+ return false; // No change...
+ else
+ pos->second = section;
+ }
+ else
+ {
+ m_collection[load_addr] = section;
}
- m_section_load_info.SetValueForKeyNoLock (load_addr, section);
return true; // Changed
}
@@ -85,14 +103,22 @@ SectionLoadList::SetSectionUnloaded (const Section *section)
section->GetModule()->GetFileSpec().GetFilename().AsCString(),
section->GetName().AsCString());
- Mutex::Locker locker(m_section_load_info.GetMutex());
-
size_t unload_count = 0;
- addr_t section_load_addr;
- while (m_section_load_info.GetFirstKeyForValueNoLock (section, section_load_addr))
+ Mutex::Locker locker(m_mutex);
+ bool erased = false;
+ do
{
- unload_count += m_section_load_info.EraseNoLock (section_load_addr);
- }
+ erased = false;
+ for (collection::iterator pos = m_collection.begin(); pos != m_collection.end(); ++pos)
+ {
+ if (pos->second == section)
+ {
+ m_collection.erase(pos);
+ erased = true;
+ }
+ }
+ } while (erased);
+
return unload_count;
}
@@ -108,28 +134,44 @@ SectionLoadList::SetSectionUnloaded (const Section *section, addr_t load_addr)
section->GetModule()->GetFileSpec().GetFilename().AsCString(),
section->GetName().AsCString(),
load_addr);
-
- return m_section_load_info.Erase (load_addr) == 1;
+ Mutex::Locker locker(m_mutex);
+ return m_collection.erase (load_addr) != 0;
}
bool
SectionLoadList::ResolveLoadAddress (addr_t load_addr, Address &so_addr) const
{
- addr_t section_load_addr = LLDB_INVALID_ADDRESS;
- const Section *section = NULL;
-
- // First find the top level section that this load address exists in
- if (m_section_load_info.LowerBound (load_addr, section_load_addr, section, true))
+ // First find the top level section that this load address exists in
+ Mutex::Locker locker(m_mutex);
+ collection::const_iterator pos = m_collection.lower_bound (load_addr);
+ if (pos != m_collection.end())
{
- addr_t offset = load_addr - section_load_addr;
- if (offset < section->GetByteSize())
+ if (load_addr != pos->first && pos != m_collection.begin())
+ --pos;
+ assert (load_addr >= pos->first);
+ addr_t offset = load_addr - pos->first;
+ if (offset < pos->second->GetByteSize())
{
// We have found the top level section, now we need to find the
// deepest child section.
- return section->ResolveContainedAddress (offset, so_addr);
+ return pos->second->ResolveContainedAddress (offset, so_addr);
}
}
so_addr.Clear();
return false;
}
+
+void
+SectionLoadList::Dump (Stream &s, Target *target)
+{
+ Mutex::Locker locker(m_mutex);
+ collection::const_iterator pos, end;
+ for (pos = m_collection.begin(), end = m_collection.end(); pos != end; ++pos)
+ {
+ s.Printf("addr = 0x%16.16llx, section = %p: ", pos->first, pos->second);
+ pos->second->Dump (&s, target, 0);
+ }
+}
+
+
OpenPOWER on IntegriCloud