[Lldb-commits] [lldb] r113869 - in /lldb/trunk: include/lldb/Core/Mangled.h include/lldb/Target/ThreadPlanRunToAddress.h lldb.xcodeproj/project.pbxproj source/Core/Mangled.cpp source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.cpp source/Target/ThreadPlanRunToAddress.cpp source/Target/ThreadPlanStepInRange.cpp
Jim Ingham
jingham at apple.com
Tue Sep 14 15:03:00 PDT 2010
Author: jingham
Date: Tue Sep 14 17:03:00 2010
New Revision: 113869
URL: http://llvm.org/viewvc/llvm-project?rev=113869&view=rev
Log:
Add the ability for "ThreadPlanRunToAddress" to run to multiple addresses.
Added the ability to specify a preference for mangled or demangled to Mangled::GetName.
Changed one place where mangled was prefered in GetName.
The Dynamic loader should look up the target of a stub by mangled name if it exists.
Modified:
lldb/trunk/include/lldb/Core/Mangled.h
lldb/trunk/include/lldb/Target/ThreadPlanRunToAddress.h
lldb/trunk/lldb.xcodeproj/project.pbxproj
lldb/trunk/source/Core/Mangled.cpp
lldb/trunk/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.cpp
lldb/trunk/source/Target/ThreadPlanRunToAddress.cpp
lldb/trunk/source/Target/ThreadPlanStepInRange.cpp
Modified: lldb/trunk/include/lldb/Core/Mangled.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/Mangled.h?rev=113869&r1=113868&r2=113869&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Core/Mangled.h (original)
+++ lldb/trunk/include/lldb/Core/Mangled.h Tue Sep 14 17:03:00 2010
@@ -51,6 +51,12 @@
eQualifier, ///< A language qualifier
eError ///< The token failed to parse
};
+
+ enum NamePreference
+ {
+ ePreferMangled,
+ ePreferDemangled
+ };
//------------------------------------------------------------------
/// Mangled::Token structure
@@ -415,13 +421,16 @@
//----------------------------------------------------------------------
/// Best name get accessor.
///
+ /// @param[in] preference
+ /// Which name would you prefer to get?
+ ///
/// @return
- /// A const reference to the the mangled name string object if this
- /// object has a valid mangled name, else a const reference to the
- /// demangled name is returned.
+ /// A const reference to the the preferred name string object if this
+ /// object has a valid name of that kind, else a const reference to the
+ /// other name is returned.
//----------------------------------------------------------------------
const ConstString&
- GetName () const;
+ GetName (NamePreference preference = ePreferDemangled) const;
//----------------------------------------------------------------------
/// Generate the tokens from the demangled name.
Modified: lldb/trunk/include/lldb/Target/ThreadPlanRunToAddress.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/ThreadPlanRunToAddress.h?rev=113869&r1=113868&r2=113869&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Target/ThreadPlanRunToAddress.h (original)
+++ lldb/trunk/include/lldb/Target/ThreadPlanRunToAddress.h Tue Sep 14 17:03:00 2010
@@ -12,6 +12,8 @@
// C Includes
// C++ Includes
+#include <vector>
+
// Other libraries and framework includes
// Project includes
#include "lldb/lldb-private.h"
@@ -30,6 +32,11 @@
lldb::addr_t address,
bool stop_others);
+ ThreadPlanRunToAddress (Thread &thread,
+ std::vector<lldb::addr_t> &addresses,
+ bool stop_others);
+
+
virtual
~ThreadPlanRunToAddress ();
@@ -61,13 +68,13 @@
MischiefManaged ();
protected:
- void SetInitialBreakpoint();
+ void SetInitialBreakpoints();
bool AtOurAddress();
private:
bool m_stop_others;
- lldb::addr_t m_address; // This is the address we are going to run to.
+ std::vector<lldb::addr_t> m_addresses; // This is the address we are going to run to.
// TODO: Would it be useful to have multiple addresses?
- lldb::user_id_t m_break_id; // This is the breakpoint we are using to stop us at m_address.
+ std::vector<lldb::user_id_t> m_break_ids; // This is the breakpoint we are using to stop us at m_address.
DISALLOW_COPY_AND_ASSIGN (ThreadPlanRunToAddress);
Modified: lldb/trunk/lldb.xcodeproj/project.pbxproj
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/lldb.xcodeproj/project.pbxproj?rev=113869&r1=113868&r2=113869&view=diff
==============================================================================
--- lldb/trunk/lldb.xcodeproj/project.pbxproj (original)
+++ lldb/trunk/lldb.xcodeproj/project.pbxproj Tue Sep 14 17:03:00 2010
@@ -2325,7 +2325,6 @@
isa = PBXProject;
buildConfigurationList = 1DEB91EF08733DB70010E9CD /* Build configuration list for PBXProject "lldb" */;
compatibilityVersion = "Xcode 3.1";
- developmentRegion = English;
hasScannedForEncodings = 1;
knownRegions = (
en,
Modified: lldb/trunk/source/Core/Mangled.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/Mangled.cpp?rev=113869&r1=113868&r2=113869&view=diff
==============================================================================
--- lldb/trunk/source/Core/Mangled.cpp (original)
+++ lldb/trunk/source/Core/Mangled.cpp Tue Sep 14 17:03:00 2010
@@ -95,7 +95,7 @@
int
Mangled::Compare (const Mangled& a, const Mangled& b)
{
- return ConstString::Compare(a.GetName(), a.GetName());
+ return ConstString::Compare(a.GetName(ePreferDemangled), a.GetName(ePreferDemangled));
}
@@ -214,12 +214,28 @@
// Get the demangled name if there is one, else return the mangled name.
//----------------------------------------------------------------------
const ConstString&
-Mangled::GetName () const
+Mangled::GetName (Mangled::NamePreference preference) const
{
- const ConstString& name = GetDemangledName();
- if (name && !name.IsEmpty())
- return name;
- return m_mangled;
+ switch (preference)
+ {
+ case ePreferDemangled:
+ {
+ const ConstString& name = GetDemangledName();
+ if (name && !name.IsEmpty())
+ return name;
+ return m_mangled;
+ }
+ break;
+ case ePreferMangled:
+ {
+ const ConstString& name = GetMangledName();
+ if (name && !name.IsEmpty())
+ return name;
+ return m_demangled;
+
+ }
+ break;
+ }
}
//----------------------------------------------------------------------
Modified: lldb/trunk/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.cpp?rev=113869&r1=113868&r2=113869&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.cpp (original)
+++ lldb/trunk/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.cpp Tue Sep 14 17:03:00 2010
@@ -1067,12 +1067,14 @@
StackFrame *current_frame = thread.GetStackFrameAtIndex(0).get();
const SymbolContext ¤t_context = current_frame->GetSymbolContext(eSymbolContextSymbol);
Symbol *current_symbol = current_context.symbol;
+ Log *log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_STEP);
if (current_symbol != NULL)
{
if (current_symbol->IsTrampoline())
{
- const ConstString &trampoline_name = current_symbol->GetMangled().GetName();
+ const ConstString &trampoline_name = current_symbol->GetMangled().GetName(Mangled::ePreferMangled);
+
if (trampoline_name)
{
SymbolContextList target_symbols;
@@ -1080,7 +1082,8 @@
images.FindSymbolsWithNameAndType(trampoline_name, eSymbolTypeCode, target_symbols);
// FIXME - Make the Run to Address take multiple addresses, and
// run to any of them.
- if (target_symbols.GetSize() == 1)
+ uint32_t num_symbols = target_symbols.GetSize();
+ if (num_symbols == 1)
{
SymbolContext context;
AddressRange addr_range;
@@ -1089,18 +1092,37 @@
context.GetAddressRange (eSymbolContextEverything, addr_range);
thread_plan_sp.reset (new ThreadPlanRunToAddress (thread, addr_range.GetBaseAddress(), stop_others));
}
+ else
+ {
+ if (log)
+ log->Printf ("Couldn't resolve the symbol context.");
+ }
}
- else if (target_symbols.GetSize() > 1)
+ else if (num_symbols > 1)
{
- Log *log = DynamicLoaderMacOSXDYLDLog::GetLogIfAllCategoriesSet (1);
- if (log)
+ std::vector<lldb::addr_t> addresses;
+ addresses.resize (num_symbols);
+ for (uint32_t i = 0; i < num_symbols; i++)
{
- log->Printf ("Found more than one symbol for trampoline target: \"%s\"", trampoline_name.AsCString());
+ SymbolContext context;
+ AddressRange addr_range;
+ if (target_symbols.GetContextAtIndex(i, context))
+ {
+ context.GetAddressRange (eSymbolContextEverything, addr_range);
+ lldb::addr_t load_addr = addr_range.GetBaseAddress().GetLoadAddress(&(thread.GetProcess()));
+ addresses[i] = load_addr;
+ }
+ }
+ if (addresses.size() > 0)
+ thread_plan_sp.reset (new ThreadPlanRunToAddress (thread, addresses, stop_others));
+ else
+ {
+ if (log)
+ log->Printf ("Couldn't resolve the symbol contexts.");
}
}
else
{
- Log *log = DynamicLoaderMacOSXDYLDLog::GetLogIfAllCategoriesSet (1);
if (log)
{
log->Printf ("Could not find symbol for trampoline target: \"%s\"", trampoline_name.AsCString());
@@ -1109,6 +1131,11 @@
}
}
}
+ else
+ {
+ if (log)
+ log->Printf ("Could not find symbol for step through.");
+ }
if (thread_plan_sp == NULL && m_objc_trampoline_handler_ap.get())
thread_plan_sp = m_objc_trampoline_handler_ap->GetStepThroughDispatchPlan (thread, stop_others);
Modified: lldb/trunk/source/Target/ThreadPlanRunToAddress.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/ThreadPlanRunToAddress.cpp?rev=113869&r1=113868&r2=113869&view=diff
==============================================================================
--- lldb/trunk/source/Target/ThreadPlanRunToAddress.cpp (original)
+++ lldb/trunk/source/Target/ThreadPlanRunToAddress.cpp Tue Sep 14 17:03:00 2010
@@ -34,13 +34,13 @@
Address &address,
bool stop_others
) :
- ThreadPlan (ThreadPlan::eKindRunToAddress, "Run to breakpoint plan", thread, eVoteNoOpinion, eVoteNoOpinion),
+ ThreadPlan (ThreadPlan::eKindRunToAddress, "Run to address plan", thread, eVoteNoOpinion, eVoteNoOpinion),
m_stop_others (stop_others),
- m_address (LLDB_INVALID_ADDRESS),
- m_break_id (LLDB_INVALID_BREAK_ID)
+ m_addresses (),
+ m_break_ids ()
{
- m_address = address.GetLoadAddress(&m_thread.GetProcess());
- SetInitialBreakpoint();
+ m_addresses.push_back (address.GetLoadAddress(&m_thread.GetProcess()));
+ SetInitialBreakpoints();
}
ThreadPlanRunToAddress::ThreadPlanRunToAddress
@@ -49,52 +49,109 @@
lldb::addr_t address,
bool stop_others
) :
- ThreadPlan (ThreadPlan::eKindRunToAddress, "Run to breakpoint plan", thread, eVoteNoOpinion, eVoteNoOpinion),
+ ThreadPlan (ThreadPlan::eKindRunToAddress, "Run to address plan", thread, eVoteNoOpinion, eVoteNoOpinion),
m_stop_others (stop_others),
- m_address (address),
- m_break_id (LLDB_INVALID_BREAK_ID)
+ m_addresses (),
+ m_break_ids ()
{
- SetInitialBreakpoint();
+ m_addresses.push_back(address);
+ SetInitialBreakpoints();
+}
+
+ThreadPlanRunToAddress::ThreadPlanRunToAddress
+(
+ Thread &thread,
+ std::vector<lldb::addr_t> &addresses,
+ bool stop_others
+) :
+ ThreadPlan (ThreadPlan::eKindRunToAddress, "Run to address plan", thread, eVoteNoOpinion, eVoteNoOpinion),
+ m_stop_others (stop_others),
+ m_addresses (addresses),
+ m_break_ids ()
+{
+ SetInitialBreakpoints();
}
void
-ThreadPlanRunToAddress::SetInitialBreakpoint ()
+ThreadPlanRunToAddress::SetInitialBreakpoints ()
{
- Breakpoint *breakpoint;
- breakpoint = m_thread.GetProcess().GetTarget().CreateBreakpoint (m_address, true).get();
- if (breakpoint != NULL)
+ size_t num_addresses = m_addresses.size();
+ m_break_ids.resize(num_addresses);
+
+ for (size_t i = 0; i < num_addresses; i++)
{
- m_break_id = breakpoint->GetID();
- breakpoint->SetThreadID(m_thread.GetID());
+ Breakpoint *breakpoint;
+ breakpoint = m_thread.GetProcess().GetTarget().CreateBreakpoint (m_addresses[i], true).get();
+ if (breakpoint != NULL)
+ {
+ m_break_ids[i] = breakpoint->GetID();
+ breakpoint->SetThreadID(m_thread.GetID());
+ }
}
}
ThreadPlanRunToAddress::~ThreadPlanRunToAddress ()
{
- if (m_break_id != LLDB_INVALID_BREAK_ID)
+ size_t num_break_ids = m_break_ids.size();
+ for (size_t i = 0; i < num_break_ids; i++)
{
- m_thread.GetProcess().GetTarget().RemoveBreakpointByID (m_break_id);
+ m_thread.GetProcess().GetTarget().RemoveBreakpointByID (m_break_ids[i]);
}
}
void
ThreadPlanRunToAddress::GetDescription (Stream *s, lldb::DescriptionLevel level)
{
+ size_t num_addresses = m_addresses.size();
+
if (level == lldb::eDescriptionLevelBrief)
{
- s->Printf ("run to address: ");
- s->Address (m_address, sizeof (addr_t));
+ if (num_addresses == 0)
+ {
+ s->Printf ("run to address with no addresses given.");
+ return;
+ }
+ else if (num_addresses == 1)
+ s->Printf ("run to address: ");
+ else
+ s->Printf ("run to addresses: ");
+
+ for (size_t i = 0; i < num_addresses; i++)
+ {
+ s->Address (m_addresses[i], sizeof (addr_t));
+ s->Printf(" ");
+ }
}
else
{
- s->Printf ("Run to address: ");
- s->Address(m_address, sizeof (addr_t));
- s->Printf (" using breakpoint: %d - ", m_break_id);
- Breakpoint *breakpoint = m_thread.GetProcess().GetTarget().GetBreakpointByID (m_break_id).get();
- if (breakpoint)
- breakpoint->Dump (s);
+ if (num_addresses == 0)
+ {
+ s->Printf ("run to address with no addresses given.");
+ return;
+ }
+ else if (num_addresses == 1)
+ s->Printf ("Run to address: ");
else
- s->Printf ("but the breakpoint has been deleted.");
+ {
+ s->Printf ("Run to addresses: ");
+ }
+
+ for (size_t i = 0; i < num_addresses; i++)
+ {
+ if (num_addresses > 1)
+ {
+ s->Printf("\n");
+ s->Indent();
+ }
+
+ s->Address(m_addresses[i], sizeof (addr_t));
+ s->Printf (" using breakpoint: %d - ", m_break_ids[i]);
+ Breakpoint *breakpoint = m_thread.GetProcess().GetTarget().GetBreakpointByID (m_break_ids[i]).get();
+ if (breakpoint)
+ breakpoint->Dump (s);
+ else
+ s->Printf ("but the breakpoint has been deleted.");
+ }
}
}
@@ -103,10 +160,20 @@
{
// If we couldn't set the breakpoint for some reason, then this won't
// work.
- if(m_break_id == LLDB_INVALID_BREAK_ID)
- return false;
- else
- return true;
+ bool all_bps_good = true;
+ size_t num_break_ids = m_break_ids.size();
+
+ for (size_t i = 0; i < num_break_ids; i++)
+ {
+ if (m_break_ids[i] == LLDB_INVALID_BREAK_ID)
+ {
+ all_bps_good = false;
+ error->Printf ("Could not set breakpoint for address: ");
+ error->Address (m_addresses[i], sizeof (addr_t));
+ error->Printf ("\n");
+ }
+ }
+ return all_bps_good;
}
bool
@@ -153,12 +220,16 @@
if (AtOurAddress())
{
// Remove the breakpoint
- if (m_break_id != LLDB_INVALID_BREAK_ID)
+ size_t num_break_ids = m_break_ids.size();
+
+ for (size_t i = 0; i < num_break_ids; i++)
{
- m_thread.GetProcess().GetTarget().RemoveBreakpointByID (m_break_id);
- m_break_id = LLDB_INVALID_BREAK_ID;
+ if (m_break_ids[i] != LLDB_INVALID_BREAK_ID)
+ {
+ m_thread.GetProcess().GetTarget().RemoveBreakpointByID (m_break_ids[i]);
+ m_break_ids[i] = LLDB_INVALID_BREAK_ID;
+ }
}
-
if (log)
log->Printf("Completed run to address plan.");
ThreadPlan::MischiefManaged ();
@@ -172,5 +243,14 @@
ThreadPlanRunToAddress::AtOurAddress ()
{
lldb::addr_t current_address = m_thread.GetRegisterContext()->GetPC();
- return m_address == current_address;
+ bool found_it = false;
+ for (size_t i = 0; i < m_addresses[i]; i++)
+ {
+ if (m_addresses[i] == current_address)
+ {
+ found_it = true;
+ break;
+ }
+ }
+ return found_it;
}
Modified: lldb/trunk/source/Target/ThreadPlanStepInRange.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/ThreadPlanStepInRange.cpp?rev=113869&r1=113868&r2=113869&view=diff
==============================================================================
--- lldb/trunk/source/Target/ThreadPlanStepInRange.cpp (original)
+++ lldb/trunk/source/Target/ThreadPlanStepInRange.cpp Tue Sep 14 17:03:00 2010
@@ -111,6 +111,15 @@
stop_others = false;
new_plan = m_thread.QueueThreadPlanForStepThrough (false, stop_others);
+
+ if (log)
+ {
+ if (new_plan != NULL)
+ log->Printf ("Found a step through plan: %s", new_plan->GetName());
+ else
+ log->Printf ("No step through plan found.");
+ }
+
// If not, give the "should_stop" callback a chance to push a plan to get us out of here.
// But only do that if we actually have stepped in.
if (!new_plan && FrameIsYounger())
More information about the lldb-commits
mailing list