From ctice at apple.com Mon Dec 20 12:35:50 2010 From: ctice at apple.com (Caroline Tice) Date: Mon, 20 Dec 2010 18:35:50 -0000 Subject: [Lldb-commits] [lldb] r122255 - in /lldb/trunk: include/lldb/Core/Debugger.h source/API/SBDebugger.cpp source/Core/Debugger.cpp Message-ID: <20101220183550.5945C2A6C12C@llvm.org> Author: ctice Date: Mon Dec 20 12:35:50 2010 New Revision: 122255 URL: http://llvm.org/viewvc/llvm-project?rev=122255&view=rev Log: Add code to make sure InputReaders finish and are cleaned up when a Debugger object is destroyed or re-set. (Thus making sure that, for example, the Python interpreter finishes and exits cleanly rather than being left in an undefined state.) Modified: lldb/trunk/include/lldb/Core/Debugger.h lldb/trunk/source/API/SBDebugger.cpp lldb/trunk/source/Core/Debugger.cpp Modified: lldb/trunk/include/lldb/Core/Debugger.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/Debugger.h?rev=122255&r1=122254&r2=122255&view=diff ============================================================================== --- lldb/trunk/include/lldb/Core/Debugger.h (original) +++ lldb/trunk/include/lldb/Core/Debugger.h Mon Dec 20 12:35:50 2010 @@ -372,6 +372,9 @@ const char **end); + void + CleanUpInputReaders (); + protected: static void Modified: lldb/trunk/source/API/SBDebugger.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBDebugger.cpp?rev=122255&r1=122254&r2=122255&view=diff ============================================================================== --- lldb/trunk/source/API/SBDebugger.cpp (original) +++ lldb/trunk/source/API/SBDebugger.cpp Mon Dec 20 12:35:50 2010 @@ -58,6 +58,9 @@ if (log) log->Printf ("SBDebugger(%p)::Clear ()", m_opaque_sp.get()); + + if (m_opaque_sp) + m_opaque_sp->CleanUpInputReaders (); m_opaque_sp.reset(); } Modified: lldb/trunk/source/Core/Debugger.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/Debugger.cpp?rev=122255&r1=122254&r2=122255&view=diff ============================================================================== --- lldb/trunk/source/Core/Debugger.cpp (original) +++ lldb/trunk/source/Core/Debugger.cpp Mon Dec 20 12:35:50 2010 @@ -184,6 +184,7 @@ Debugger::~Debugger () { + CleanUpInputReaders(); int num_targets = m_target_list.GetNumTargets(); for (int i = 0; i < num_targets; i++) { @@ -390,6 +391,24 @@ } void +Debugger::CleanUpInputReaders () +{ + m_input_reader_data.clear(); + + while (m_input_readers.size() > 1) + { + while (CheckIfTopInputReaderIsDone ()) ; + + InputReaderSP reader_sp (m_input_readers.top()); + if (reader_sp) + { + reader_sp->Notify (eInputReaderEndOfFile); + reader_sp->SetIsDone (true); + } + } +} + +void Debugger::WriteToDefaultReader (const char *bytes, size_t bytes_len) { if (bytes && bytes_len) From wilsons at start.ca Mon Dec 20 14:18:43 2010 From: wilsons at start.ca (Stephen Wilson) Date: Mon, 20 Dec 2010 15:18:43 -0500 Subject: [Lldb-commits] [PATCH] linux: qualify includes. Message-ID: Provide full qualification for #include's. diff --git a/include/lldb/Utility/ArchDefaultUnwindPlan.h b/include/lldb/Utility/ArchDefaultUnwindPlan.h index b907558..3a887c3 100644 --- a/include/lldb/Utility/ArchDefaultUnwindPlan.h +++ b/include/lldb/Utility/ArchDefaultUnwindPlan.h @@ -10,7 +10,7 @@ #ifndef utility_ArchDefaultUnwindPlan_h_ #define utility_ArchDefaultUnwindPlan_h_ -#include "lldb-private.h" +#include "lldb/lldb-private.h" #include "lldb/Core/PluginInterface.h" namespace lldb_private { diff --git a/include/lldb/Utility/ArchVolatileRegs.h b/include/lldb/Utility/ArchVolatileRegs.h index 914a786..b42ecdd 100644 --- a/include/lldb/Utility/ArchVolatileRegs.h +++ b/include/lldb/Utility/ArchVolatileRegs.h @@ -10,7 +10,7 @@ #ifndef utility_ArchVolatileRegs_h_ #define utility_ArchVolatileRegs_h_ -#include "lldb-private.h" +#include "lldb/lldb-private.h" #include "lldb/Core/PluginInterface.h" namespace lldb_private { diff --git a/include/lldb/Utility/UnwindAssemblyProfiler.h b/include/lldb/Utility/UnwindAssemblyProfiler.h index 7c127df..df0ceff 100644 --- a/include/lldb/Utility/UnwindAssemblyProfiler.h +++ b/include/lldb/Utility/UnwindAssemblyProfiler.h @@ -10,7 +10,7 @@ #ifndef utility_UnwindAssemblyProfiler_h_ #define utility_UnwindAssemblyProfiler_h_ -#include "lldb-private.h" +#include "lldb/lldb-private.h" #include "lldb/Core/PluginInterface.h" namespace lldb_private { diff --git a/source/Expression/ClangPersistentVariables.cpp b/source/Expression/ClangPersistentVariables.cpp index 4919922..d8f4598 100644 --- a/source/Expression/ClangPersistentVariables.cpp +++ b/source/Expression/ClangPersistentVariables.cpp @@ -7,7 +7,7 @@ // //===----------------------------------------------------------------------===// -#include "ClangPersistentVariables.h" +#include "lldb/Expression/ClangPersistentVariables.h" #include "lldb/Core/DataExtractor.h" #include "lldb/Core/Log.h" #include "lldb/Core/StreamString.h" diff --git a/source/Utility/ArchDefaultUnwindPlan.cpp b/source/Utility/ArchDefaultUnwindPlan.cpp index 913d861..1d5b5b9 100644 --- a/source/Utility/ArchDefaultUnwindPlan.cpp +++ b/source/Utility/ArchDefaultUnwindPlan.cpp @@ -7,7 +7,7 @@ // //===----------------------------------------------------------------------===// -#include "lldb-private.h" +#include "lldb/lldb-private.h" #include "lldb/Core/PluginManager.h" #include "lldb/Core/PluginInterface.h" #include "lldb/Utility/ArchDefaultUnwindPlan.h" diff --git a/source/Utility/ArchVolatileRegs.cpp b/source/Utility/ArchVolatileRegs.cpp index 041237f..207cdd9 100644 --- a/source/Utility/ArchVolatileRegs.cpp +++ b/source/Utility/ArchVolatileRegs.cpp @@ -7,7 +7,7 @@ // //===----------------------------------------------------------------------===// -#include "lldb-private.h" +#include "lldb/lldb-private.h" #include "lldb/Core/PluginManager.h" #include "lldb/Core/PluginInterface.h" #include "lldb/Utility/ArchVolatileRegs.h" diff --git a/source/Utility/UnwindAssemblyProfiler.cpp b/source/Utility/UnwindAssemblyProfiler.cpp index eb4262a..7b4e60a 100644 --- a/source/Utility/UnwindAssemblyProfiler.cpp +++ b/source/Utility/UnwindAssemblyProfiler.cpp @@ -7,7 +7,7 @@ // //===----------------------------------------------------------------------===// -#include "lldb-private.h" +#include "lldb/lldb-private.h" #include "lldb/Core/PluginManager.h" #include "lldb/Core/PluginInterface.h" #include "lldb/Utility/UnwindAssemblyProfiler.h" From wilsons at start.ca Mon Dec 20 14:20:00 2010 From: wilsons at start.ca (Stephen Wilson) Date: Mon, 20 Dec 2010 15:20:00 -0500 Subject: [Lldb-commits] [PATCH] linux: convert label to qualification. Message-ID: Fix a typo where a qualification was being interpreted as a label. diff --git a/source/API/SBDebugger.cpp b/source/API/SBDebugger.cpp index 2777741..cdd2c4c 100644 --- a/source/API/SBDebugger.cpp +++ b/source/API/SBDebugger.cpp @@ -744,7 +744,7 @@ SBDebugger::GetInternalVariableValue (const char *var_name, const char *debugger { SBStringList ret_value; lldb::SettableVariableType var_type; - lldb_private:Error err; + lldb_private::Error err; lldb::UserSettingsControllerSP root_settings_controller = lldb_private::Debugger::GetSettingsController(); From wilsons at start.ca Mon Dec 20 14:25:16 2010 From: wilsons at start.ca (Stephen Wilson) Date: Mon, 20 Dec 2010 15:25:16 -0500 Subject: [Lldb-commits] [PATCH] linux: Add missing FileSpec argument. Message-ID: Provide a missing resolve_path argument in calls to FileSpec's constructor for both Linux and FreeBSD code fragments. diff --git a/source/Host/common/Host.cpp b/source/Host/common/Host.cpp index 527d20a..28a6d00 100644 --- a/source/Host/common/Host.cpp +++ b/source/Host/common/Host.cpp @@ -622,7 +622,7 @@ Host::GetProgramFileSpec () char exe_path[PATH_MAX]; ssize_t len = readlink("/proc/self/exe", exe_path, sizeof(exe_path)); if (len >= 0) - g_program_filespec = FileSpec(exe_path); + g_program_filespec = FileSpec(exe_path, true); #elif defined (__FreeBSD__) int exe_path_mib[4] = { CTL_KERN, KERN_PROC, KERN_PROC_PATHNAME, getpid() }; size_t exe_path_size; @@ -630,7 +630,7 @@ Host::GetProgramFileSpec () { char *exe_path = new char[exe_path_size]; if (sysctl(exe_path_mib, 4, exe_path, &exe_path_size, NULL, 0) == 0) - g_program_filespec = FileSpec(exe_path); + g_program_filespec = FileSpec(exe_path, true); } #endif } From wilsons at start.ca Mon Dec 20 14:28:46 2010 From: wilsons at start.ca (Stephen Wilson) Date: Mon, 20 Dec 2010 15:28:46 -0500 Subject: [Lldb-commits] [PATCH] linux: Set sockaddr_un.sun_len according to platform. Message-ID: POSIX does not define sockaddr_un.sun_len. Set only when required by the platform. diff --git a/source/Core/ConnectionFileDescriptor.cpp b/source/Core/ConnectionFileDescriptor.cpp index da199b9..56b8312 100644 --- a/source/Core/ConnectionFileDescriptor.cpp +++ b/source/Core/ConnectionFileDescriptor.cpp @@ -432,7 +432,10 @@ ConnectionFileDescriptor::NamedSocketAccept (const char *socket_name, Error *err saddr_un.sun_family = AF_UNIX; ::strncpy(saddr_un.sun_path, socket_name, sizeof(saddr_un.sun_path) - 1); saddr_un.sun_path[sizeof(saddr_un.sun_path) - 1] = '\0'; + +#if defined(__APPLE__) || defined(__FreeBSD__) saddr_un.sun_len = SUN_LEN (&saddr_un); +#endif if (::bind (listen_socket, (struct sockaddr *)&saddr_un, SUN_LEN (&saddr_un)) == 0) { From johnny.chen at apple.com Mon Dec 20 14:33:26 2010 From: johnny.chen at apple.com (Johnny Chen) Date: Mon, 20 Dec 2010 20:33:26 -0000 Subject: [Lldb-commits] [lldb] r122260 - /lldb/trunk/source/API/SBDebugger.cpp Message-ID: <20101220203326.A4DAF2A6C12C@llvm.org> Author: johnny Date: Mon Dec 20 14:33:26 2010 New Revision: 122260 URL: http://llvm.org/viewvc/llvm-project?rev=122260&view=rev Log: Patch from Stephen Wilson: Fix a typo where a qualification was being interpreted as a label. Modified: lldb/trunk/source/API/SBDebugger.cpp Modified: lldb/trunk/source/API/SBDebugger.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBDebugger.cpp?rev=122260&r1=122259&r2=122260&view=diff ============================================================================== --- lldb/trunk/source/API/SBDebugger.cpp (original) +++ lldb/trunk/source/API/SBDebugger.cpp Mon Dec 20 14:33:26 2010 @@ -747,7 +747,7 @@ { SBStringList ret_value; lldb::SettableVariableType var_type; - lldb_private:Error err; + lldb_private::Error err; lldb::UserSettingsControllerSP root_settings_controller = lldb_private::Debugger::GetSettingsController(); From gclayton at apple.com Mon Dec 20 14:49:23 2010 From: gclayton at apple.com (Greg Clayton) Date: Mon, 20 Dec 2010 20:49:23 -0000 Subject: [Lldb-commits] [lldb] r122262 - in /lldb/trunk: include/lldb/API/ include/lldb/Breakpoint/ include/lldb/Core/ include/lldb/Target/ source/API/ source/Core/ source/Target/ Message-ID: <20101220204924.0E5942A6C12C@llvm.org> Author: gclayton Date: Mon Dec 20 14:49:23 2010 New Revision: 122262 URL: http://llvm.org/viewvc/llvm-project?rev=122262&view=rev Log: The LLDB API (lldb::SB*) is now thread safe! Modified: lldb/trunk/include/lldb/API/SBDebugger.h lldb/trunk/include/lldb/API/SBProcess.h lldb/trunk/include/lldb/API/SBTarget.h lldb/trunk/include/lldb/API/SBValue.h lldb/trunk/include/lldb/Breakpoint/BreakpointList.h lldb/trunk/include/lldb/Core/ValueObject.h lldb/trunk/include/lldb/Target/Target.h lldb/trunk/source/API/SBAddress.cpp lldb/trunk/source/API/SBBreakpoint.cpp lldb/trunk/source/API/SBBreakpointLocation.cpp lldb/trunk/source/API/SBCommandInterpreter.cpp lldb/trunk/source/API/SBDebugger.cpp lldb/trunk/source/API/SBFrame.cpp lldb/trunk/source/API/SBFunction.cpp lldb/trunk/source/API/SBProcess.cpp lldb/trunk/source/API/SBSymbol.cpp lldb/trunk/source/API/SBTarget.cpp lldb/trunk/source/API/SBThread.cpp lldb/trunk/source/API/SBValue.cpp lldb/trunk/source/API/SBValueList.cpp lldb/trunk/source/Core/ValueObject.cpp lldb/trunk/source/Target/StackFrame.cpp lldb/trunk/source/Target/Target.cpp Modified: lldb/trunk/include/lldb/API/SBDebugger.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBDebugger.h?rev=122262&r1=122261&r2=122262&view=diff ============================================================================== --- lldb/trunk/include/lldb/API/SBDebugger.h (original) +++ lldb/trunk/include/lldb/API/SBDebugger.h Mon Dec 20 14:49:23 2010 @@ -111,9 +111,6 @@ lldb::SBTarget GetSelectedTarget (); - void - UpdateSelectedThread (lldb::SBProcess &process); - lldb::SBSourceManager & GetSourceManager (); @@ -125,10 +122,10 @@ bool GetUseExternalEditor (); - bool + static bool GetDefaultArchitecture (char *arch_name, size_t arch_name_len); - bool + static bool SetDefaultArchitecture (const char *arch_name); lldb::ScriptLanguage Modified: lldb/trunk/include/lldb/API/SBProcess.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBProcess.h?rev=122262&r1=122261&r2=122262&view=diff ============================================================================== --- lldb/trunk/include/lldb/API/SBProcess.h (original) +++ lldb/trunk/include/lldb/API/SBProcess.h Mon Dec 20 14:49:23 2010 @@ -111,17 +111,6 @@ lldb::SBError Destroy (); - lldb::pid_t - AttachByPID (lldb::pid_t pid); // DEPRECATED - - // DEPRECATED: relocated to "SBProcess SBTarget::AttachToProcess (lldb::pid_t pid, lldb::SBError& error)" - lldb::SBError - Attach (lldb::pid_t pid); - - // DEPRECATED: relocated to "SBProcess SBTarget::AttachToProcess (const char *name, bool wait_for_launch, lldb::SBError& error)" - lldb::SBError - AttachByName (const char *name, bool wait_for_launch); - lldb::SBError Continue (); Modified: lldb/trunk/include/lldb/API/SBTarget.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBTarget.h?rev=122262&r1=122261&r2=122262&view=diff ============================================================================== --- lldb/trunk/include/lldb/API/SBTarget.h (original) +++ lldb/trunk/include/lldb/API/SBTarget.h Mon Dec 20 14:49:23 2010 @@ -52,13 +52,8 @@ IsValid() const; lldb::SBProcess - CreateProcess (); // DEPRECATED - - lldb::SBProcess GetProcess (); - // DEPRECATED in favor of the function below that contains an SBError as the - // last parameter. lldb::SBProcess LaunchProcess (char const **argv, char const **envp, @@ -147,17 +142,6 @@ lldb::SBBroadcaster GetBroadcaster () const; - //void - //Disassemble (); - - void - Disassemble (lldb::addr_t start_address, - lldb::addr_t end_address = LLDB_INVALID_ADDRESS, - const char *module_name = NULL); - - void - Disassemble (const char *function_name, const char *module_name = NULL); - #ifndef SWIG bool operator == (const lldb::SBTarget &rhs) const; Modified: lldb/trunk/include/lldb/API/SBValue.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBValue.h?rev=122262&r1=122261&r2=122262&view=diff ============================================================================== --- lldb/trunk/include/lldb/API/SBValue.h (original) +++ lldb/trunk/include/lldb/API/SBValue.h Mon Dec 20 14:49:23 2010 @@ -85,9 +85,6 @@ uint32_t GetNumChildren (); - bool - ValueIsStale (); - void * GetOpaqueType(); Modified: lldb/trunk/include/lldb/Breakpoint/BreakpointList.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Breakpoint/BreakpointList.h?rev=122262&r1=122261&r2=122262&view=diff ============================================================================== --- lldb/trunk/include/lldb/Breakpoint/BreakpointList.h (original) +++ lldb/trunk/include/lldb/Breakpoint/BreakpointList.h Mon Dec 20 14:49:23 2010 @@ -114,7 +114,11 @@ /// The number of elements. //------------------------------------------------------------------ size_t - GetSize() const { return m_breakpoints.size(); } + GetSize() const + { + Mutex::Locker locker(m_mutex); + return m_breakpoints.size(); + } //------------------------------------------------------------------ /// Removes the breakpoint given by \b breakID from this list. Modified: lldb/trunk/include/lldb/Core/ValueObject.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/ValueObject.h?rev=122262&r1=122261&r2=122262&view=diff ============================================================================== --- lldb/trunk/include/lldb/Core/ValueObject.h (original) +++ lldb/trunk/include/lldb/Core/ValueObject.h Mon Dec 20 14:49:23 2010 @@ -207,7 +207,7 @@ CreateConstantValue (ExecutionContextScope *exe_scope, const ConstString &name); virtual lldb::ValueObjectSP - Dereference (ExecutionContextScope *exe_scope, Error &error); + Dereference (Error &error); virtual lldb::ValueObjectSP AddressOf (Error &error); Modified: lldb/trunk/include/lldb/Target/Target.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/Target.h?rev=122262&r1=122261&r2=122262&view=diff ============================================================================== --- lldb/trunk/include/lldb/Target/Target.h (original) +++ lldb/trunk/include/lldb/Target/Target.h Mon Dec 20 14:49:23 2010 @@ -173,6 +173,12 @@ public: ~Target(); + Mutex & + GetAPIMutex () + { + return m_mutex; + } + void DeleteCurrentProcess (); @@ -472,6 +478,7 @@ // Member variables. //------------------------------------------------------------------ Debugger & m_debugger; + Mutex m_mutex; ///< An API mutex that is used by the lldb::SB* classes make the SB interface thread safe ArchSpec m_arch_spec; ModuleList m_images; ///< The list of images for this process (shared libraries and anything dynamically loaded). SectionLoadList m_section_load_list; Modified: lldb/trunk/source/API/SBAddress.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBAddress.cpp?rev=122262&r1=122261&r2=122262&view=diff ============================================================================== --- lldb/trunk/source/API/SBAddress.cpp (original) +++ lldb/trunk/source/API/SBAddress.cpp Mon Dec 20 14:49:23 2010 @@ -12,6 +12,8 @@ #include "lldb/API/SBStream.h" #include "lldb/Core/Address.h" #include "lldb/Core/Log.h" +#include "lldb/Host/Mutex.h" +#include "lldb/Target/Target.h" using namespace lldb; using namespace lldb_private; @@ -89,19 +91,22 @@ { LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); + lldb::addr_t addr = LLDB_INVALID_ADDRESS; if (m_opaque_ap.get()) { - lldb::addr_t addr = m_opaque_ap->GetLoadAddress (target.get()); - if (log) - log->Printf ("SBAddress::GetLoadAddress (SBTarget(%p)) => 0x%llx", target.get(), addr); - return addr; + Mutex::Locker api_locker (target->GetAPIMutex()); + addr = m_opaque_ap->GetLoadAddress (target.get()); } - else + + if (log) { - if (log) + if (addr == LLDB_INVALID_ADDRESS) log->Printf ("SBAddress::GetLoadAddress (SBTarget(%p)) => LLDB_INVALID_ADDRESS", target.get()); - return LLDB_INVALID_ADDRESS; + else + log->Printf ("SBAddress::GetLoadAddress (SBTarget(%p)) => 0x%llx", target.get(), addr); } + + return addr; } bool Modified: lldb/trunk/source/API/SBBreakpoint.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBBreakpoint.cpp?rev=122262&r1=122261&r2=122262&view=diff ============================================================================== --- lldb/trunk/source/API/SBBreakpoint.cpp (original) +++ lldb/trunk/source/API/SBBreakpoint.cpp Mon Dec 20 14:49:23 2010 @@ -105,18 +105,19 @@ { LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); + break_id_t break_id = LLDB_INVALID_BREAK_ID; if (m_opaque_sp) + break_id = m_opaque_sp->GetID(); + + if (log) { - break_id_t break_id = m_opaque_sp->GetID(); - if (log) + if (break_id == LLDB_INVALID_BREAK_ID) + log->Printf ("SBBreakpoint(%p)::GetID () => LLDB_INVALID_BREAK_ID", m_opaque_sp.get()); + else log->Printf ("SBBreakpoint(%p)::GetID () => %u", m_opaque_sp.get(), break_id); - return break_id; } - if (log) - log->Printf ("SBBreakpoint(%p)::GetID () => LLDB_INVALID_BREAK_ID", m_opaque_sp.get()); - - return LLDB_INVALID_BREAK_ID; + return break_id; } @@ -130,7 +131,10 @@ SBBreakpoint::ClearAllBreakpointSites () { if (m_opaque_sp) + { + Mutex::Locker api_locker (m_opaque_sp->GetTarget().GetAPIMutex()); m_opaque_sp->ClearAllBreakpointSites (); + } } SBBreakpointLocation @@ -142,6 +146,7 @@ { if (vm_addr != LLDB_INVALID_ADDRESS) { + Mutex::Locker api_locker (m_opaque_sp->GetTarget().GetAPIMutex()); Address address; Target &target = m_opaque_sp->GetTarget(); if (target.GetSectionLoadList().ResolveLoadAddress (vm_addr, address) == false) @@ -158,24 +163,22 @@ break_id_t SBBreakpoint::FindLocationIDByAddress (addr_t vm_addr) { - break_id_t lldb_id = (break_id_t) 0; + break_id_t break_id = LLDB_INVALID_BREAK_ID; - if (m_opaque_sp) + if (m_opaque_sp && vm_addr != LLDB_INVALID_ADDRESS) { - if (vm_addr != LLDB_INVALID_ADDRESS) + Mutex::Locker api_locker (m_opaque_sp->GetTarget().GetAPIMutex()); + Address address; + Target &target = m_opaque_sp->GetTarget(); + if (target.GetSectionLoadList().ResolveLoadAddress (vm_addr, address) == false) { - Address address; - Target &target = m_opaque_sp->GetTarget(); - if (target.GetSectionLoadList().ResolveLoadAddress (vm_addr, address) == false) - { - address.SetSection (NULL); - address.SetOffset (vm_addr); - } - lldb_id = m_opaque_sp->FindLocationIDByAddress (address); + address.SetSection (NULL); + address.SetOffset (vm_addr); } + break_id = m_opaque_sp->FindLocationIDByAddress (address); } - return lldb_id; + return break_id; } SBBreakpointLocation @@ -184,7 +187,10 @@ SBBreakpointLocation sb_bp_location; if (m_opaque_sp) + { + Mutex::Locker api_locker (m_opaque_sp->GetTarget().GetAPIMutex()); sb_bp_location.SetLocation (m_opaque_sp->FindLocationByID (bp_loc_id)); + } return sb_bp_location; } @@ -195,7 +201,10 @@ SBBreakpointLocation sb_bp_location; if (m_opaque_sp) + { + Mutex::Locker api_locker (m_opaque_sp->GetTarget().GetAPIMutex()); sb_bp_location.SetLocation (m_opaque_sp->GetLocationAtIndex (index)); + } return sb_bp_location; } @@ -209,14 +218,20 @@ log->Printf ("SBBreakpoint(%p)::SetEnabled (enabled=%i)", m_opaque_sp.get(), enable); if (m_opaque_sp) + { + Mutex::Locker api_locker (m_opaque_sp->GetTarget().GetAPIMutex()); m_opaque_sp->SetEnabled (enable); + } } bool SBBreakpoint::IsEnabled () { if (m_opaque_sp) + { + Mutex::Locker api_locker (m_opaque_sp->GetTarget().GetAPIMutex()); return m_opaque_sp->IsEnabled(); + } else return false; } @@ -230,19 +245,31 @@ log->Printf ("SBBreakpoint(%p)::SetIgnoreCount (count=%u)", m_opaque_sp.get(), count); if (m_opaque_sp) + { + Mutex::Locker api_locker (m_opaque_sp->GetTarget().GetAPIMutex()); m_opaque_sp->SetIgnoreCount (count); + } } void SBBreakpoint::SetCondition (const char *condition) { - m_opaque_sp->SetCondition (condition); + if (m_opaque_sp) + { + Mutex::Locker api_locker (m_opaque_sp->GetTarget().GetAPIMutex()); + m_opaque_sp->SetCondition (condition); + } } const char * SBBreakpoint::GetCondition () { - return m_opaque_sp->GetConditionText (); + if (m_opaque_sp) + { + Mutex::Locker api_locker (m_opaque_sp->GetTarget().GetAPIMutex()); + return m_opaque_sp->GetConditionText (); + } + return NULL; } uint32_t @@ -250,7 +277,10 @@ { uint32_t count = 0; if (m_opaque_sp) + { + Mutex::Locker api_locker (m_opaque_sp->GetTarget().GetAPIMutex()); count = m_opaque_sp->GetHitCount(); + } LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); if (log) @@ -264,7 +294,10 @@ { uint32_t count = 0; if (m_opaque_sp) + { + Mutex::Locker api_locker (m_opaque_sp->GetTarget().GetAPIMutex()); count = m_opaque_sp->GetIgnoreCount(); + } LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); if (log) @@ -277,7 +310,10 @@ SBBreakpoint::SetThreadID (tid_t tid) { if (m_opaque_sp) + { + Mutex::Locker api_locker (m_opaque_sp->GetTarget().GetAPIMutex()); m_opaque_sp->SetThreadID (tid); + } LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); if (log) log->Printf ("SBBreakpoint(%p)::SetThreadID (tid=0x%4.4x)", m_opaque_sp.get(), tid); @@ -289,7 +325,10 @@ { tid_t tid = LLDB_INVALID_THREAD_ID; if (m_opaque_sp) + { + Mutex::Locker api_locker (m_opaque_sp->GetTarget().GetAPIMutex()); tid = m_opaque_sp->GetThreadID(); + } LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); if (log) @@ -304,7 +343,10 @@ if (log) log->Printf ("SBBreakpoint(%p)::SetThreadIndex (%u)", m_opaque_sp.get(), index); if (m_opaque_sp) + { + Mutex::Locker api_locker (m_opaque_sp->GetTarget().GetAPIMutex()); m_opaque_sp->GetOptions()->GetThreadSpec()->SetIndex (index); + } } uint32_t @@ -313,7 +355,8 @@ uint32_t thread_idx = UINT32_MAX; if (m_opaque_sp) { - const ThreadSpec *thread_spec = m_opaque_sp->GetOptions()->GetThreadSpec(); + Mutex::Locker api_locker (m_opaque_sp->GetTarget().GetAPIMutex()); + const ThreadSpec *thread_spec = m_opaque_sp->GetOptions()->GetThreadSpecNoCreate(); if (thread_spec != NULL) thread_idx = thread_spec->GetIndex(); } @@ -333,7 +376,10 @@ log->Printf ("SBBreakpoint(%p)::SetThreadName (%s)", m_opaque_sp.get(), thread_name); if (m_opaque_sp) + { + Mutex::Locker api_locker (m_opaque_sp->GetTarget().GetAPIMutex()); m_opaque_sp->GetOptions()->GetThreadSpec()->SetName (thread_name); + } } const char * @@ -342,7 +388,8 @@ const char *name = NULL; if (m_opaque_sp) { - const ThreadSpec *thread_spec = m_opaque_sp->GetOptions()->GetThreadSpec(); + Mutex::Locker api_locker (m_opaque_sp->GetTarget().GetAPIMutex()); + const ThreadSpec *thread_spec = m_opaque_sp->GetOptions()->GetThreadSpecNoCreate(); if (thread_spec != NULL) name = thread_spec->GetName(); } @@ -360,7 +407,10 @@ if (log) log->Printf ("SBBreakpoint(%p)::SetQueueName (%s)", m_opaque_sp.get(), queue_name); if (m_opaque_sp) + { + Mutex::Locker api_locker (m_opaque_sp->GetTarget().GetAPIMutex()); m_opaque_sp->GetOptions()->GetThreadSpec()->SetQueueName (queue_name); + } } const char * @@ -369,7 +419,9 @@ const char *name = NULL; if (m_opaque_sp) { - const ThreadSpec *thread_spec = m_opaque_sp->GetOptions()->GetThreadSpec(); + Mutex::Locker api_locker (m_opaque_sp->GetTarget().GetAPIMutex()); + const ThreadSpec *thread_spec = m_opaque_sp->GetOptions()->GetThreadSpecNoCreate(); + if (thread_spec) name = thread_spec->GetQueueName(); } LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); @@ -384,7 +436,10 @@ { size_t num_resolved = 0; if (m_opaque_sp) + { + Mutex::Locker api_locker (m_opaque_sp->GetTarget().GetAPIMutex()); num_resolved = m_opaque_sp->GetNumResolvedLocations(); + } LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); if (log) log->Printf ("SBBreakpoint(%p)::GetNumResolvedLocations () => %zu", m_opaque_sp.get(), num_resolved); @@ -396,7 +451,10 @@ { size_t num_locs = 0; if (m_opaque_sp) + { + Mutex::Locker api_locker (m_opaque_sp->GetTarget().GetAPIMutex()); num_locs = m_opaque_sp->GetNumLocations(); + } LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); if (log) log->Printf ("SBBreakpoint(%p)::GetNumLocations () => %zu", m_opaque_sp.get(), num_locs); @@ -408,6 +466,7 @@ { if (m_opaque_sp) { + Mutex::Locker api_locker (m_opaque_sp->GetTarget().GetAPIMutex()); s.Printf("SBBreakpoint: id = %i, ", m_opaque_sp->GetID()); m_opaque_sp->GetResolverDescription (s.get()); m_opaque_sp->GetFilterDescription (s.get()); @@ -465,6 +524,7 @@ if (m_opaque_sp.get()) { + Mutex::Locker api_locker (m_opaque_sp->GetTarget().GetAPIMutex()); BatonSP baton_sp(new SBBreakpointCallbackBaton (callback, baton)); m_opaque_sp->SetCallback (SBBreakpoint::PrivateBreakpointHitCallback, baton_sp, false); } Modified: lldb/trunk/source/API/SBBreakpointLocation.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBBreakpointLocation.cpp?rev=122262&r1=122261&r2=122262&view=diff ============================================================================== --- lldb/trunk/source/API/SBBreakpointLocation.cpp (original) +++ lldb/trunk/source/API/SBBreakpointLocation.cpp Mon Dec 20 14:49:23 2010 @@ -20,6 +20,7 @@ #include "lldb/Core/Log.h" #include "lldb/Core/Stream.h" #include "lldb/Core/StreamFile.h" +#include "lldb/Target/Target.h" #include "lldb/Target/ThreadSpec.h" using namespace lldb; @@ -76,6 +77,7 @@ if (m_opaque_sp) { + Mutex::Locker api_locker (m_opaque_sp->GetBreakpoint().GetTarget().GetAPIMutex()); ret_addr = m_opaque_sp->GetLoadAddress(); } @@ -87,6 +89,7 @@ { if (m_opaque_sp) { + Mutex::Locker api_locker (m_opaque_sp->GetBreakpoint().GetTarget().GetAPIMutex()); m_opaque_sp->SetEnabled (enabled); } } @@ -95,7 +98,10 @@ SBBreakpointLocation::IsEnabled () { if (m_opaque_sp) + { + Mutex::Locker api_locker (m_opaque_sp->GetBreakpoint().GetTarget().GetAPIMutex()); return m_opaque_sp->IsEnabled(); + } else return false; } @@ -104,7 +110,10 @@ SBBreakpointLocation::GetIgnoreCount () { if (m_opaque_sp) + { + Mutex::Locker api_locker (m_opaque_sp->GetBreakpoint().GetTarget().GetAPIMutex()); return m_opaque_sp->GetIgnoreCount(); + } else return 0; } @@ -113,56 +122,79 @@ SBBreakpointLocation::SetIgnoreCount (uint32_t n) { if (m_opaque_sp) + { + Mutex::Locker api_locker (m_opaque_sp->GetBreakpoint().GetTarget().GetAPIMutex()); m_opaque_sp->SetIgnoreCount (n); + } } void SBBreakpointLocation::SetCondition (const char *condition) { - m_opaque_sp->SetCondition (condition); + if (m_opaque_sp) + { + Mutex::Locker api_locker (m_opaque_sp->GetBreakpoint().GetTarget().GetAPIMutex()); + m_opaque_sp->SetCondition (condition); + } } const char * SBBreakpointLocation::GetCondition () { - return m_opaque_sp->GetConditionText (); + if (m_opaque_sp) + { + Mutex::Locker api_locker (m_opaque_sp->GetBreakpoint().GetTarget().GetAPIMutex()); + return m_opaque_sp->GetConditionText (); + } + return NULL; } void SBBreakpointLocation::SetThreadID (tid_t thread_id) { if (m_opaque_sp) + { + Mutex::Locker api_locker (m_opaque_sp->GetBreakpoint().GetTarget().GetAPIMutex()); m_opaque_sp->SetThreadID (thread_id); + } } tid_t SBBreakpointLocation::GetThreadID () { - tid_t sb_thread_id = (lldb::tid_t) LLDB_INVALID_THREAD_ID; + tid_t tid = LLDB_INVALID_THREAD_ID; if (m_opaque_sp) - sb_thread_id = m_opaque_sp->GetLocationOptions()->GetThreadSpecNoCreate()->GetTID(); - return sb_thread_id; + { + Mutex::Locker api_locker (m_opaque_sp->GetBreakpoint().GetTarget().GetAPIMutex()); + const ThreadSpec *thread_spec = m_opaque_sp->GetLocationOptions()->GetThreadSpecNoCreate(); + if (thread_spec) + tid = thread_spec->GetTID(); + } + return tid; } void SBBreakpointLocation::SetThreadIndex (uint32_t index) { if (m_opaque_sp) + { + Mutex::Locker api_locker (m_opaque_sp->GetBreakpoint().GetTarget().GetAPIMutex()); m_opaque_sp->GetLocationOptions()->GetThreadSpec()->SetIndex (index); + } } uint32_t SBBreakpointLocation::GetThreadIndex() const { + uint32_t thread_idx = UINT32_MAX; if (m_opaque_sp) { + Mutex::Locker api_locker (m_opaque_sp->GetBreakpoint().GetTarget().GetAPIMutex()); const ThreadSpec *thread_spec = m_opaque_sp->GetOptionsNoCreate()->GetThreadSpecNoCreate(); - if (thread_spec == NULL) - return 0; - else - return thread_spec->GetIndex(); + if (thread_spec) + thread_idx = thread_spec->GetIndex(); } - return 0; + return thread_idx; } @@ -170,7 +202,10 @@ SBBreakpointLocation::SetThreadName (const char *thread_name) { if (m_opaque_sp) + { + Mutex::Locker api_locker (m_opaque_sp->GetBreakpoint().GetTarget().GetAPIMutex()); m_opaque_sp->GetLocationOptions()->GetThreadSpec()->SetName (thread_name); + } } const char * @@ -178,10 +213,9 @@ { if (m_opaque_sp) { + Mutex::Locker api_locker (m_opaque_sp->GetBreakpoint().GetTarget().GetAPIMutex()); const ThreadSpec *thread_spec = m_opaque_sp->GetOptionsNoCreate()->GetThreadSpecNoCreate(); - if (thread_spec == NULL) - return NULL; - else + if (thread_spec) return thread_spec->GetName(); } return NULL; @@ -191,7 +225,10 @@ SBBreakpointLocation::SetQueueName (const char *queue_name) { if (m_opaque_sp) + { + Mutex::Locker api_locker (m_opaque_sp->GetBreakpoint().GetTarget().GetAPIMutex()); m_opaque_sp->GetLocationOptions()->GetThreadSpec()->SetQueueName (queue_name); + } } const char * @@ -199,10 +236,9 @@ { if (m_opaque_sp) { + Mutex::Locker api_locker (m_opaque_sp->GetBreakpoint().GetTarget().GetAPIMutex()); const ThreadSpec *thread_spec = m_opaque_sp->GetOptionsNoCreate()->GetThreadSpecNoCreate(); - if (thread_spec == NULL) - return NULL; - else + if (thread_spec) return thread_spec->GetQueueName(); } return NULL; @@ -212,18 +248,17 @@ SBBreakpointLocation::IsResolved () { if (m_opaque_sp) + { + Mutex::Locker api_locker (m_opaque_sp->GetBreakpoint().GetTarget().GetAPIMutex()); return m_opaque_sp->IsResolved(); - else - return false; + } + return false; } void SBBreakpointLocation::SetLocation (const lldb::BreakpointLocationSP &break_loc_sp) { - if (m_opaque_sp) - { - // Uninstall the callbacks? - } + // Uninstall the callbacks? m_opaque_sp = break_loc_sp; } @@ -232,6 +267,7 @@ { if (m_opaque_sp) { + Mutex::Locker api_locker (m_opaque_sp->GetBreakpoint().GetTarget().GetAPIMutex()); description.ref(); m_opaque_sp->GetDescription (description.get(), level); description.get()->EOL(); @@ -252,7 +288,10 @@ SBBreakpoint sb_bp; if (m_opaque_sp) - *sb_bp = m_opaque_sp->GetBreakpoint ().GetSP(); + { + Mutex::Locker api_locker (m_opaque_sp->GetBreakpoint().GetTarget().GetAPIMutex()); + *sb_bp = m_opaque_sp->GetBreakpoint ().GetSP(); + } if (log) { Modified: lldb/trunk/source/API/SBCommandInterpreter.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBCommandInterpreter.cpp?rev=122262&r1=122261&r2=122262&view=diff ============================================================================== --- lldb/trunk/source/API/SBCommandInterpreter.cpp (original) +++ lldb/trunk/source/API/SBCommandInterpreter.cpp Mon Dec 20 14:49:23 2010 @@ -91,6 +91,10 @@ result.Clear(); if (m_opaque_ptr) { + TargetSP target_sp(m_opaque_ptr->GetDebugger().GetSelectedTarget()); + Mutex::Locker api_locker; + if (target_sp) + api_locker.Reset(target_sp->GetAPIMutex().GetMutex()); m_opaque_ptr->HandleCommand (command_line, add_to_history, result.ref()); } else @@ -163,10 +167,12 @@ SBProcess process; if (m_opaque_ptr) { - Debugger &debugger = m_opaque_ptr->GetDebugger(); - Target *target = debugger.GetSelectedTarget().get(); - if (target) - process.SetProcess(target->GetProcessSP()); + TargetSP target_sp(m_opaque_ptr->GetDebugger().GetSelectedTarget()); + if (target_sp) + { + Mutex::Locker api_locker(target_sp->GetAPIMutex()); + process.SetProcess(target_sp->GetProcessSP()); + } } LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); @@ -229,6 +235,10 @@ result.Clear(); if (m_opaque_ptr) { + TargetSP target_sp(m_opaque_ptr->GetDebugger().GetSelectedTarget()); + Mutex::Locker api_locker; + if (target_sp) + api_locker.Reset(target_sp->GetAPIMutex().GetMutex()); m_opaque_ptr->SourceInitFile (false, result.ref()); } else @@ -250,6 +260,10 @@ result.Clear(); if (m_opaque_ptr) { + TargetSP target_sp(m_opaque_ptr->GetDebugger().GetSelectedTarget()); + Mutex::Locker api_locker; + if (target_sp) + api_locker.Reset(target_sp->GetAPIMutex().GetMutex()); m_opaque_ptr->SourceInitFile (true, result.ref()); } else Modified: lldb/trunk/source/API/SBDebugger.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBDebugger.cpp?rev=122262&r1=122261&r2=122262&view=diff ============================================================================== --- lldb/trunk/source/API/SBDebugger.cpp (original) +++ lldb/trunk/source/API/SBDebugger.cpp Mon Dec 20 14:49:23 2010 @@ -216,6 +216,11 @@ { if (m_opaque_sp) { + TargetSP target_sp (m_opaque_sp->GetSelectedTarget()); + Mutex::Locker api_locker; + if (target_sp) + api_locker.Reset(target_sp->GetAPIMutex().GetMutex()); + SBCommandInterpreter sb_interpreter(GetCommandInterpreter ()); SBCommandReturnObject result; @@ -262,110 +267,41 @@ void SBDebugger::HandleProcessEvent (const SBProcess &process, const SBEvent &event, FILE *out, FILE *err) { - const uint32_t event_type = event.GetType(); - char stdio_buffer[1024]; - size_t len; - - if (event_type & Process::eBroadcastBitSTDOUT) - { - while ((len = process.GetSTDOUT (stdio_buffer, sizeof (stdio_buffer))) > 0) - if (out != NULL) - ::fwrite (stdio_buffer, 1, len, out); - } - else if (event_type & Process::eBroadcastBitSTDERR) - { - while ((len = process.GetSTDERR (stdio_buffer, sizeof (stdio_buffer))) > 0) - if (out != NULL) - ::fwrite (stdio_buffer, 1, len, out); - } - else if (event_type & Process::eBroadcastBitStateChanged) - { - // Drain any stdout messages. - while ((len = process.GetSTDOUT (stdio_buffer, sizeof (stdio_buffer))) > 0) - if (out != NULL) - ::fwrite (stdio_buffer, 1, len, out); - - // Drain any stderr messages. - while ((len = process.GetSTDERR (stdio_buffer, sizeof (stdio_buffer))) > 0) - if (out != NULL) - ::fwrite (stdio_buffer, 1, len, out); - - StateType event_state = SBProcess::GetStateFromEvent (event); - - if (event_state == eStateInvalid) - return; - - bool is_stopped = StateIsStoppedState (event_state); - if (!is_stopped) - process.ReportEventState (event, out); - } -} + if (!process.IsValid()) + return; -void -SBDebugger::UpdateSelectedThread (SBProcess &process) -{ - if (process.IsValid()) - { - SBThread curr_thread = process.GetSelectedThread (); - SBThread thread; - StopReason curr_thread_stop_reason = eStopReasonInvalid; - if (curr_thread.IsValid()) - { - if (curr_thread.GetStopReason() != eStopReasonInvalid) - curr_thread_stop_reason = curr_thread.GetStopReason (); - } + const uint32_t event_type = event.GetType(); + char stdio_buffer[1024]; + size_t len; - if (! curr_thread.IsValid() - || curr_thread_stop_reason == eStopReasonInvalid - || curr_thread_stop_reason == eStopReasonNone) - { - // Prefer a thread that has just completed its plan over another thread as current thread. - SBThread plan_thread; - SBThread other_thread; - const size_t num_threads = process.GetNumThreads (); - size_t i; - for (i = 0; i < num_threads; ++i) - { - thread = process.GetThreadAtIndex(i); - if (thread.GetStopReason () != eStopReasonInvalid) - { - switch (thread.GetStopReason ()) - { - default: - case eStopReasonInvalid: - case eStopReasonNone: - break; - - case eStopReasonTrace: - case eStopReasonBreakpoint: - case eStopReasonWatchpoint: - case eStopReasonSignal: - case eStopReasonException: - if (! other_thread.IsValid()) - other_thread = thread; - break; - case eStopReasonPlanComplete: - if (! plan_thread.IsValid()) - plan_thread = thread; - break; - } - } - } - if (plan_thread.IsValid()) - process.SetSelectedThreadByID (plan_thread.GetThreadID()); - else if (other_thread.IsValid()) - process.SetSelectedThreadByID (other_thread.GetThreadID()); - else - { - if (curr_thread.IsValid()) - thread = curr_thread; - else - thread = process.GetThreadAtIndex(0); - - if (thread.IsValid()) - process.SetSelectedThreadByID (thread.GetThreadID()); - } - } + Mutex::Locker api_locker (process.GetTarget()->GetAPIMutex()); + + if (event_type & (Process::eBroadcastBitSTDOUT | Process::eBroadcastBitStateChanged)) + { + // Drain stdout when we stop just in case we have any bytes + while ((len = process.GetSTDOUT (stdio_buffer, sizeof (stdio_buffer))) > 0) + if (out != NULL) + ::fwrite (stdio_buffer, 1, len, out); + } + + if (event_type & (Process::eBroadcastBitSTDERR | Process::eBroadcastBitStateChanged)) + { + // Drain stderr when we stop just in case we have any bytes + while ((len = process.GetSTDERR (stdio_buffer, sizeof (stdio_buffer))) > 0) + if (err != NULL) + ::fwrite (stdio_buffer, 1, len, err); + } + + if (event_type & Process::eBroadcastBitStateChanged) + { + StateType event_state = SBProcess::GetStateFromEvent (event); + + if (event_state == eStateInvalid) + return; + + bool is_stopped = StateIsStoppedState (event_state); + if (!is_stopped) + process.ReportEventState (event, out); } } @@ -415,6 +351,7 @@ ScriptLanguage SBDebugger::GetScriptingLanguage (const char *script_language_name) { + return Args::StringToScriptLanguage (script_language_name, eScriptLanguageDefault, NULL); @@ -582,7 +519,10 @@ { SBTarget sb_target; if (m_opaque_sp) + { + // No need to lock, the target list is thread safe sb_target.reset(m_opaque_sp->GetTargetList().GetTargetAtIndex (idx)); + } return sb_target; } @@ -591,7 +531,10 @@ { SBTarget sb_target; if (m_opaque_sp) + { + // No need to lock, the target list is thread safe sb_target.reset(m_opaque_sp->GetTargetList().FindTargetWithProcessID (pid)); + } return sb_target; } @@ -601,6 +544,7 @@ SBTarget sb_target; if (m_opaque_sp && filename && filename[0]) { + // No need to lock, the target list is thread safe ArchSpec arch; if (arch_name) arch.SetArch(arch_name); @@ -615,7 +559,10 @@ { SBTarget sb_target; if (m_opaque_sp) + { + // No need to lock, the target list is thread safe sb_target.reset(m_opaque_sp->GetTargetList().FindTargetWithProcess (process_sp.get())); + } return sb_target; } @@ -624,7 +571,10 @@ SBDebugger::GetNumTargets () { if (m_opaque_sp) + { + // No need to lock, the target list is thread safe return m_opaque_sp->GetTargetList().GetNumTargets (); + } return 0; } @@ -635,7 +585,10 @@ SBTarget sb_target; if (m_opaque_sp) + { + // No need to lock, the target list is thread safe sb_target.reset(m_opaque_sp->GetTargetList().GetSelectedTarget ()); + } if (log) { @@ -685,6 +638,10 @@ if (m_opaque_sp && reader.IsValid()) { + TargetSP target_sp (m_opaque_sp->GetSelectedTarget()); + Mutex::Locker api_locker; + if (target_sp) + api_locker.Reset(target_sp->GetAPIMutex().GetMutex()); InputReaderSP reader_sp(*reader); m_opaque_sp->PushInputReader (reader_sp); } @@ -713,6 +670,7 @@ SBDebugger SBDebugger::FindDebuggerWithID (int id) { + // No need to lock, the debugger list is thread safe SBDebugger sb_debugger; lldb::DebuggerSP debugger_sp = Debugger::FindDebuggerWithID (id); if (debugger_sp) @@ -816,19 +774,17 @@ SBDebugger::SetScriptLanguage (lldb::ScriptLanguage script_lang) { if (m_opaque_sp) + { m_opaque_sp->SetScriptLanguage (script_lang); + } } - - - bool SBDebugger::SetUseExternalEditor (bool value) { if (m_opaque_sp) return m_opaque_sp->SetUseExternalEditor (value); - else - return false; + return false; } bool @@ -836,8 +792,7 @@ { if (m_opaque_sp) return m_opaque_sp->GetUseExternalEditor (); - else - return false; + return false; } bool Modified: lldb/trunk/source/API/SBFrame.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBFrame.cpp?rev=122262&r1=122261&r2=122262&view=diff ============================================================================== --- lldb/trunk/source/API/SBFrame.cpp (original) +++ lldb/trunk/source/API/SBFrame.cpp Mon Dec 20 14:49:23 2010 @@ -109,7 +109,10 @@ SBSymbolContext sb_sym_ctx; if (m_opaque_sp) + { + Mutex::Locker api_locker (m_opaque_sp->GetThread().GetProcess().GetTarget().GetAPIMutex()); sb_sym_ctx.SetSymbolContext(&m_opaque_sp->GetSymbolContext (resolve_scope)); + } LogSP log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); if (log) @@ -124,7 +127,10 @@ { SBModule sb_module; if (m_opaque_sp) + { + Mutex::Locker api_locker (m_opaque_sp->GetThread().GetProcess().GetTarget().GetAPIMutex()); *sb_module = m_opaque_sp->GetSymbolContext (eSymbolContextModule).module_sp; + } LogSP log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); if (log) @@ -139,7 +145,10 @@ { SBCompileUnit sb_comp_unit; if (m_opaque_sp) + { + Mutex::Locker api_locker (m_opaque_sp->GetThread().GetProcess().GetTarget().GetAPIMutex()); sb_comp_unit.reset (m_opaque_sp->GetSymbolContext (eSymbolContextCompUnit).comp_unit); + } LogSP log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); if (log) log->Printf ("SBFrame(%p)::GetModule () => SBCompileUnit(%p)", @@ -153,7 +162,10 @@ { SBFunction sb_function; if (m_opaque_sp) + { + Mutex::Locker api_locker (m_opaque_sp->GetThread().GetProcess().GetTarget().GetAPIMutex()); sb_function.reset(m_opaque_sp->GetSymbolContext (eSymbolContextFunction).function); + } LogSP log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); if (log) log->Printf ("SBFrame(%p)::GetFunction () => SBFunction(%p)", @@ -167,7 +179,10 @@ { SBSymbol sb_symbol; if (m_opaque_sp) + { + Mutex::Locker api_locker (m_opaque_sp->GetThread().GetProcess().GetTarget().GetAPIMutex()); sb_symbol.reset(m_opaque_sp->GetSymbolContext (eSymbolContextSymbol).symbol); + } LogSP log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); if (log) log->Printf ("SBFrame(%p)::GetSymbol () => SBSymbol(%p)", @@ -180,7 +195,10 @@ { SBBlock sb_block; if (m_opaque_sp) + { + Mutex::Locker api_locker (m_opaque_sp->GetThread().GetProcess().GetTarget().GetAPIMutex()); sb_block.reset (m_opaque_sp->GetSymbolContext (eSymbolContextBlock).block); + } LogSP log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); if (log) log->Printf ("SBFrame(%p)::GetBlock () => SBBlock(%p)", @@ -193,7 +211,10 @@ { SBBlock sb_block; if (m_opaque_sp) + { + Mutex::Locker api_locker (m_opaque_sp->GetThread().GetProcess().GetTarget().GetAPIMutex()); sb_block.reset(m_opaque_sp->GetFrameBlock ()); + } LogSP log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); if (log) log->Printf ("SBFrame(%p)::GetFrameBlock () => SBBlock(%p)", @@ -206,7 +227,10 @@ { SBLineEntry sb_line_entry; if (m_opaque_sp) + { + Mutex::Locker api_locker (m_opaque_sp->GetThread().GetProcess().GetTarget().GetAPIMutex()); sb_line_entry.SetLineEntry (m_opaque_sp->GetSymbolContext (eSymbolContextLineEntry).line_entry); + } LogSP log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); if (log) log->Printf ("SBFrame(%p)::GetLineEntry () => SBLineEntry(%p)", @@ -231,7 +255,10 @@ { addr_t addr = LLDB_INVALID_ADDRESS; if (m_opaque_sp) + { + Mutex::Locker api_locker (m_opaque_sp->GetThread().GetProcess().GetTarget().GetAPIMutex()); addr = m_opaque_sp->GetFrameCodeAddress().GetLoadAddress (&m_opaque_sp->GetThread().GetProcess().GetTarget()); + } LogSP log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); if (log) @@ -245,7 +272,10 @@ { bool ret_val = false; if (m_opaque_sp) + { + Mutex::Locker api_locker (m_opaque_sp->GetThread().GetProcess().GetTarget().GetAPIMutex()); ret_val = m_opaque_sp->GetRegisterContext()->SetPC (new_pc); + } LogSP log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); if (log) @@ -260,7 +290,10 @@ { addr_t addr = LLDB_INVALID_ADDRESS; if (m_opaque_sp) + { + Mutex::Locker api_locker (m_opaque_sp->GetThread().GetProcess().GetTarget().GetAPIMutex()); addr = m_opaque_sp->GetRegisterContext()->GetSP(); + } LogSP log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); if (log) log->Printf ("SBFrame(%p)::GetSP () => 0x%llx", m_opaque_sp.get(), addr); @@ -274,7 +307,10 @@ { addr_t addr = LLDB_INVALID_ADDRESS; if (m_opaque_sp) + { + Mutex::Locker api_locker (m_opaque_sp->GetThread().GetProcess().GetTarget().GetAPIMutex()); addr = m_opaque_sp->GetRegisterContext()->GetFP(); + } LogSP log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); if (log) @@ -288,7 +324,10 @@ { SBAddress sb_addr; if (m_opaque_sp) + { + Mutex::Locker api_locker (m_opaque_sp->GetThread().GetProcess().GetTarget().GetAPIMutex()); sb_addr.SetAddress (&m_opaque_sp->GetFrameCodeAddress()); + } LogSP log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); if (log) log->Printf ("SBFrame(%p)::GetPCAddress () => SBAddress(%p)", m_opaque_sp.get(), sb_addr.get()); @@ -308,7 +347,7 @@ if (m_opaque_sp && name && name[0]) { VariableList variable_list; - + Mutex::Locker api_locker (m_opaque_sp->GetThread().GetProcess().GetTarget().GetAPIMutex()); SymbolContext sc (m_opaque_sp->GetSymbolContext (eSymbolContextBlock)); if (sc.block) @@ -346,6 +385,7 @@ SBValue sb_value; if (m_opaque_sp && name && name[0]) { + Mutex::Locker api_locker (m_opaque_sp->GetThread().GetProcess().GetTarget().GetAPIMutex()); switch (value_type) { @@ -479,7 +519,10 @@ SBThread sb_thread; if (m_opaque_sp) + { + Mutex::Locker api_locker (m_opaque_sp->GetThread().GetProcess().GetTarget().GetAPIMutex()); sb_thread.SetThread (m_opaque_sp->GetThread().GetSP()); + } if (log) { @@ -497,7 +540,10 @@ { const char *disassembly = NULL; if (m_opaque_sp) + { + Mutex::Locker api_locker (m_opaque_sp->GetThread().GetProcess().GetTarget().GetAPIMutex()); disassembly = m_opaque_sp->Disassemble(); + } LogSP log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); if (log) @@ -526,8 +572,14 @@ SBValueList value_list; if (m_opaque_sp) { + size_t i; - VariableList *variable_list = m_opaque_sp->GetVariableList(true); + VariableList *variable_list = NULL; + // Scope for locker + { + Mutex::Locker api_locker (m_opaque_sp->GetThread().GetProcess().GetTarget().GetAPIMutex()); + variable_list = m_opaque_sp->GetVariableList(true); + } if (variable_list) { const size_t num_variables = variable_list->GetSize(); @@ -587,6 +639,7 @@ SBValueList value_list; if (m_opaque_sp) { + Mutex::Locker api_locker (m_opaque_sp->GetThread().GetProcess().GetTarget().GetAPIMutex()); RegisterContext *reg_ctx = m_opaque_sp->GetRegisterContext(); if (reg_ctx) { @@ -609,6 +662,7 @@ { if (m_opaque_sp) { + Mutex::Locker api_locker (m_opaque_sp->GetThread().GetProcess().GetTarget().GetAPIMutex()); Stream &s = description.ref(); m_opaque_sp->DumpUsingSettingsFormat (&s); } @@ -621,6 +675,8 @@ SBValue SBFrame::EvaluateExpression (const char *expr) { + Mutex::Locker api_locker (m_opaque_sp->GetThread().GetProcess().GetTarget().GetAPIMutex()); + LogSP log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); LogSP expr_log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS)); Modified: lldb/trunk/source/API/SBFunction.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBFunction.cpp?rev=122262&r1=122261&r2=122262&view=diff ============================================================================== --- lldb/trunk/source/API/SBFunction.cpp (original) +++ lldb/trunk/source/API/SBFunction.cpp Mon Dec 20 14:49:23 2010 @@ -125,9 +125,11 @@ SBInstructionList sb_instructions; if (m_opaque_ptr) { + Mutex::Locker api_locker; ExecutionContext exe_ctx; if (target.IsValid()) { + api_locker.Reset (target->GetAPIMutex().GetMutex()); target->CalculateExecutionContext (exe_ctx); exe_ctx.process = target->GetProcessSP().get(); } Modified: lldb/trunk/source/API/SBProcess.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBProcess.cpp?rev=122262&r1=122261&r2=122262&view=diff ============================================================================== --- lldb/trunk/source/API/SBProcess.cpp (original) +++ lldb/trunk/source/API/SBProcess.cpp Mon Dec 20 14:49:23 2010 @@ -104,6 +104,7 @@ uint32_t num_threads = 0; if (m_opaque_sp) { + Mutex::Locker api_locker (m_opaque_sp->GetTarget().GetAPIMutex()); const bool can_update = true; num_threads = m_opaque_sp->GetThreadList().GetSize(can_update); } @@ -121,7 +122,10 @@ SBThread sb_thread; if (m_opaque_sp) + { + Mutex::Locker api_locker (m_opaque_sp->GetTarget().GetAPIMutex()); sb_thread.SetThread (m_opaque_sp->GetThreadList().GetSelectedThread()); + } if (log) { @@ -153,7 +157,7 @@ LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); size_t ret_val = 0; - if (m_opaque_sp != NULL) + if (m_opaque_sp) { Error error; ret_val = m_opaque_sp->PutSTDIN (src, src_len, error); @@ -173,7 +177,7 @@ SBProcess::GetSTDOUT (char *dst, size_t dst_len) const { size_t bytes_read = 0; - if (m_opaque_sp != NULL) + if (m_opaque_sp) { Error error; bytes_read = m_opaque_sp->GetSTDOUT (dst, dst_len, error); @@ -191,7 +195,7 @@ SBProcess::GetSTDERR (char *dst, size_t dst_len) const { size_t bytes_read = 0; - if (m_opaque_sp != NULL) + if (m_opaque_sp) { Error error; bytes_read = m_opaque_sp->GetSTDERR (dst, dst_len, error); @@ -211,7 +215,7 @@ if (out == NULL) return; - if (m_opaque_sp != NULL) + if (m_opaque_sp) { const StateType event_state = SBProcess::GetStateFromEvent (event); char message[1024]; @@ -229,7 +233,7 @@ void SBProcess::AppendEventStateReport (const SBEvent &event, SBCommandReturnObject &result) { - if (m_opaque_sp != NULL) + if (m_opaque_sp) { const StateType event_state = SBProcess::GetStateFromEvent (event); char message[1024]; @@ -246,8 +250,11 @@ bool SBProcess::SetSelectedThread (const SBThread &thread) { - if (m_opaque_sp != NULL) + if (m_opaque_sp) + { + Mutex::Locker api_locker (m_opaque_sp->GetTarget().GetAPIMutex()); return m_opaque_sp->GetThreadList().SetSelectedThreadByID (thread.GetThreadID()); + } return false; } @@ -257,8 +264,11 @@ LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); bool ret_val = false; - if (m_opaque_sp != NULL) + if (m_opaque_sp) + { + Mutex::Locker api_locker (m_opaque_sp->GetTarget().GetAPIMutex()); ret_val = m_opaque_sp->GetThreadList().SetSelectedThreadByID (tid); + } if (log) log->Printf ("SBProcess(%p)::SetSelectedThreadByID (tid=0x%4.4x) => %s", @@ -274,7 +284,10 @@ SBThread thread; if (m_opaque_sp) + { + Mutex::Locker api_locker (m_opaque_sp->GetTarget().GetAPIMutex()); thread.SetThread (m_opaque_sp->GetThreadList().GetThreadAtIndex(index)); + } if (log) { @@ -290,8 +303,11 @@ { StateType ret_val = eStateInvalid; - if (m_opaque_sp != NULL) + if (m_opaque_sp) + { + Mutex::Locker api_locker (m_opaque_sp->GetTarget().GetAPIMutex()); ret_val = m_opaque_sp->GetState(); + } LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); if (log) @@ -308,7 +324,10 @@ { int exit_status = 0; if (m_opaque_sp) + { + Mutex::Locker api_locker (m_opaque_sp->GetTarget().GetAPIMutex()); exit_status = m_opaque_sp->GetExitStatus (); + } LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); if (log) log->Printf ("SBProcess(%p)::GetExitStatus () => %i (0x%8.8x)", @@ -321,8 +340,11 @@ SBProcess::GetExitDescription () { const char *exit_desc = NULL; - if (m_opaque_sp != NULL) + if (m_opaque_sp) + { + Mutex::Locker api_locker (m_opaque_sp->GetTarget().GetAPIMutex()); exit_desc = m_opaque_sp->GetExitDescription (); + } LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); if (log) log->Printf ("SBProcess(%p)::GetExitDescription () => %s", @@ -361,6 +383,8 @@ SBError SBProcess::Continue () { + Mutex::Locker api_locker (m_opaque_sp->GetTarget().GetAPIMutex()); + LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); if (log) log->Printf ("SBProcess(%p)::Continue ()...", m_opaque_sp.get()); @@ -397,6 +421,8 @@ SBError SBProcess::Destroy () { + Mutex::Locker api_locker (m_opaque_sp->GetTarget().GetAPIMutex()); + SBError sb_error; if (m_opaque_sp) sb_error.SetError(m_opaque_sp->Destroy()); @@ -418,10 +444,12 @@ SBError SBProcess::Stop () { - SBError sb_error; if (IsValid()) + { + Mutex::Locker api_locker (m_opaque_sp->GetTarget().GetAPIMutex()); sb_error.SetError (m_opaque_sp->Halt()); + } else sb_error.SetErrorString ("SBProcess is invalid"); @@ -442,10 +470,12 @@ SBError SBProcess::Kill () { - SBError sb_error; if (m_opaque_sp) + { + Mutex::Locker api_locker (m_opaque_sp->GetTarget().GetAPIMutex()); sb_error.SetError (m_opaque_sp->Destroy()); + } else sb_error.SetErrorString ("SBProcess is invalid"); @@ -463,43 +493,15 @@ return sb_error; } - -SBError -SBProcess::AttachByName (const char *name, bool wait_for_launch) // DEPRECATED -{ - SBError sb_error; - if (m_opaque_sp) - sb_error.SetError (m_opaque_sp->Attach (name, wait_for_launch)); - else - sb_error.SetErrorString ("SBProcess is invalid"); - return sb_error; -} - -lldb::pid_t -SBProcess::AttachByPID (lldb::pid_t attach_pid) // DEPRECATED -{ - Attach (attach_pid); - return GetProcessID(); -} - - -SBError -SBProcess::Attach (lldb::pid_t attach_pid) // DEPRECATED -{ - SBError sb_error; - if (m_opaque_sp) - sb_error.SetError (m_opaque_sp->Attach (attach_pid)); - else - sb_error.SetErrorString ("SBProcess is invalid"); - return sb_error; -} - SBError SBProcess::Detach () { SBError sb_error; if (m_opaque_sp) + { + Mutex::Locker api_locker (m_opaque_sp->GetTarget().GetAPIMutex()); sb_error.SetError (m_opaque_sp->Detach()); + } else sb_error.SetErrorString ("SBProcess is invalid"); @@ -511,7 +513,10 @@ { SBError sb_error; if (m_opaque_sp) + { + Mutex::Locker api_locker (m_opaque_sp->GetTarget().GetAPIMutex()); sb_error.SetError (m_opaque_sp->Signal (signo)); + } else sb_error.SetErrorString ("SBProcess is invalid"); LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); @@ -533,7 +538,10 @@ { SBThread sb_thread; if (m_opaque_sp) + { + Mutex::Locker api_locker (m_opaque_sp->GetTarget().GetAPIMutex()); sb_thread.SetThread (m_opaque_sp->GetThreadList().FindThreadByID ((tid_t) tid)); + } LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); if (log) @@ -612,9 +620,10 @@ sb_error.get()); } - if (IsValid()) + if (m_opaque_sp) { Error error; + Mutex::Locker api_locker (m_opaque_sp->GetTarget().GetAPIMutex()); bytes_read = m_opaque_sp->ReadMemory (addr, dst, dst_len, error); sb_error.SetError (error); } @@ -656,9 +665,10 @@ sb_error.get()); } - if (IsValid()) + if (m_opaque_sp) { Error error; + Mutex::Locker api_locker (m_opaque_sp->GetTarget().GetAPIMutex()); bytes_written = m_opaque_sp->WriteMemory (addr, src, src_len, error); sb_error.SetError (error); } @@ -716,7 +726,10 @@ SBProcess::LoadImage (lldb::SBFileSpec &sb_image_spec, lldb::SBError &sb_error) { if (m_opaque_sp) + { + Mutex::Locker api_locker (m_opaque_sp->GetTarget().GetAPIMutex()); return m_opaque_sp->LoadImage (*sb_image_spec, sb_error.ref()); + } return LLDB_INVALID_IMAGE_TOKEN; } @@ -725,7 +738,10 @@ { lldb::SBError sb_error; if (m_opaque_sp) + { + Mutex::Locker api_locker (m_opaque_sp->GetTarget().GetAPIMutex()); sb_error.SetError (m_opaque_sp->UnloadImage (image_token)); + } else sb_error.SetErrorString("invalid process"); return sb_error; Modified: lldb/trunk/source/API/SBSymbol.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBSymbol.cpp?rev=122262&r1=122261&r2=122262&view=diff ============================================================================== --- lldb/trunk/source/API/SBSymbol.cpp (original) +++ lldb/trunk/source/API/SBSymbol.cpp Mon Dec 20 14:49:23 2010 @@ -120,9 +120,13 @@ SBInstructionList sb_instructions; if (m_opaque_ptr) { + Mutex::Locker api_locker; ExecutionContext exe_ctx; if (target.IsValid()) + { + api_locker.Reset (target->GetAPIMutex().GetMutex()); target->CalculateExecutionContext (exe_ctx); + } const AddressRange *symbol_range = m_opaque_ptr->GetAddressRangePtr(); if (symbol_range) { Modified: lldb/trunk/source/API/SBTarget.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBTarget.cpp?rev=122262&r1=122261&r2=122262&view=diff ============================================================================== --- lldb/trunk/source/API/SBTarget.cpp (original) +++ lldb/trunk/source/API/SBTarget.cpp Mon Dec 20 14:49:23 2010 @@ -92,7 +92,10 @@ SBProcess sb_process; if (m_opaque_sp) + { + Mutex::Locker api_locker (m_opaque_sp->GetAPIMutex()); sb_process.SetProcess (m_opaque_sp->GetProcessSP()); + } LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); if (log) @@ -113,28 +116,6 @@ return debugger; } - -// DEPRECATED -SBProcess -SBTarget::CreateProcess () -{ - - SBProcess sb_process; - - if (m_opaque_sp) - sb_process.SetProcess (m_opaque_sp->CreateProcess (m_opaque_sp->GetDebugger().GetListener())); - - LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); - if (log) - { - log->Printf ("SBTarget(%p)::CreateProcess () => SBProcess(%p)", - m_opaque_sp.get(), sb_process.get()); - } - - return sb_process; -} - - SBProcess SBTarget::LaunchProcess ( @@ -185,17 +166,8 @@ SBProcess sb_process; if (m_opaque_sp) { - // DEPRECATED, this will change when CreateProcess is removed... - if (m_opaque_sp->GetProcessSP()) - { - sb_process.SetProcess(m_opaque_sp->GetProcessSP()); - } - else - { - // When launching, we always want to create a new process When - // SBTarget::CreateProcess is removed, this will always happen. - sb_process.SetProcess (m_opaque_sp->CreateProcess (m_opaque_sp->GetDebugger().GetListener())); - } + Mutex::Locker api_locker (m_opaque_sp->GetAPIMutex()); + sb_process.SetProcess (m_opaque_sp->CreateProcess (m_opaque_sp->GetDebugger().GetListener())); if (sb_process.IsValid()) { @@ -253,17 +225,8 @@ SBProcess sb_process; if (m_opaque_sp) { - // DEPRECATED, this will change when CreateProcess is removed... - if (m_opaque_sp->GetProcessSP()) - { - sb_process.SetProcess(m_opaque_sp->GetProcessSP()); - } - else - { - // When launching, we always want to create a new process When - // SBTarget::CreateProcess is removed, this will always happen. - sb_process.SetProcess (m_opaque_sp->CreateProcess (m_opaque_sp->GetDebugger().GetListener())); - } + Mutex::Locker api_locker (m_opaque_sp->GetAPIMutex()); + sb_process.SetProcess (m_opaque_sp->CreateProcess (m_opaque_sp->GetDebugger().GetListener())); if (sb_process.IsValid()) { @@ -293,17 +256,9 @@ SBProcess sb_process; if (m_opaque_sp) { - // DEPRECATED, this will change when CreateProcess is removed... - if (m_opaque_sp->GetProcessSP()) - { - sb_process.SetProcess(m_opaque_sp->GetProcessSP()); - } - else - { - // When launching, we always want to create a new process When - // SBTarget::CreateProcess is removed, this will always happen. - sb_process.SetProcess (m_opaque_sp->CreateProcess (m_opaque_sp->GetDebugger().GetListener())); - } + Mutex::Locker api_locker (m_opaque_sp->GetAPIMutex()); + + sb_process.SetProcess (m_opaque_sp->CreateProcess (m_opaque_sp->GetDebugger().GetListener())); if (sb_process.IsValid()) { @@ -389,7 +344,10 @@ lldb::SBAddress& addr) { if (m_opaque_sp) + { + Mutex::Locker api_locker (m_opaque_sp->GetAPIMutex()); return m_opaque_sp->GetSectionLoadList().ResolveLoadAddress (vm_addr, *addr); + } addr->Clear(); return false; @@ -408,7 +366,10 @@ SBBreakpoint sb_bp; if (m_opaque_sp.get() && line != 0) + { + Mutex::Locker api_locker (m_opaque_sp->GetAPIMutex()); *sb_bp = m_opaque_sp->CreateBreakpoint (NULL, *sb_file_spec, line, true, false); + } if (log) { @@ -435,6 +396,7 @@ SBBreakpoint sb_bp; if (m_opaque_sp.get() && symbol_name && symbol_name[0]) { + Mutex::Locker api_locker (m_opaque_sp->GetAPIMutex()); if (module_name && module_name[0]) { FileSpec module_file_spec(module_name, false); @@ -463,6 +425,7 @@ SBBreakpoint sb_bp; if (m_opaque_sp.get() && symbol_name_regex && symbol_name_regex[0]) { + Mutex::Locker api_locker (m_opaque_sp->GetAPIMutex()); RegularExpression regexp(symbol_name_regex); if (module_name && module_name[0]) @@ -495,7 +458,10 @@ SBBreakpoint sb_bp; if (m_opaque_sp.get()) + { + Mutex::Locker api_locker (m_opaque_sp->GetAPIMutex()); *sb_bp = m_opaque_sp->CreateBreakpoint (address, false); + } if (log) { @@ -512,7 +478,10 @@ SBBreakpoint sb_breakpoint; if (m_opaque_sp && bp_id != LLDB_INVALID_BREAK_ID) + { + Mutex::Locker api_locker (m_opaque_sp->GetAPIMutex()); *sb_breakpoint = m_opaque_sp->GetBreakpointByID (bp_id); + } if (log) { @@ -527,7 +496,10 @@ SBTarget::GetNumBreakpoints () const { if (m_opaque_sp) + { + // The breakpoint list is thread safe, no need to lock return m_opaque_sp->GetBreakpointList().GetSize(); + } return 0; } @@ -536,7 +508,10 @@ { SBBreakpoint sb_breakpoint; if (m_opaque_sp) + { + // The breakpoint list is thread safe, no need to lock *sb_breakpoint = m_opaque_sp->GetBreakpointList().GetBreakpointAtIndex(idx); + } return sb_breakpoint; } @@ -547,7 +522,10 @@ bool result = false; if (m_opaque_sp) + { + Mutex::Locker api_locker (m_opaque_sp->GetAPIMutex()); result = m_opaque_sp->RemoveBreakpointByID (bp_id); + } if (log) { @@ -562,6 +540,7 @@ { if (m_opaque_sp) { + Mutex::Locker api_locker (m_opaque_sp->GetAPIMutex()); m_opaque_sp->EnableAllBreakpoints (); return true; } @@ -573,6 +552,7 @@ { if (m_opaque_sp) { + Mutex::Locker api_locker (m_opaque_sp->GetAPIMutex()); m_opaque_sp->DisableAllBreakpoints (); return true; } @@ -584,6 +564,7 @@ { if (m_opaque_sp) { + Mutex::Locker api_locker (m_opaque_sp->GetAPIMutex()); m_opaque_sp->RemoveAllBreakpoints (); return true; } @@ -598,7 +579,10 @@ uint32_t num = 0; if (m_opaque_sp) - num = m_opaque_sp->GetImages().GetSize(); + { + // The module list is thread safe, no need to lock + num = m_opaque_sp->GetImages().GetSize(); + } if (log) log->Printf ("SBTarget(%p)::GetNumModules () => %d", m_opaque_sp.get(), num); @@ -623,7 +607,10 @@ { SBModule sb_module; if (m_opaque_sp && sb_file_spec.IsValid()) + { + // The module list is thread safe, no need to lock sb_module.SetModule (m_opaque_sp->GetImages().FindFirstModuleForFileSpec (*sb_file_spec, NULL)); + } return sb_module; } @@ -634,7 +621,10 @@ SBModule sb_module; if (m_opaque_sp) + { + // The module list is thread safe, no need to lock sb_module.SetModule(m_opaque_sp->GetImages().GetModuleAtIndex(idx)); + } if (log) { @@ -660,130 +650,6 @@ return broadcaster; } -void -SBTarget::Disassemble (lldb::addr_t start_addr, lldb::addr_t end_addr, const char *module_name) -{ - if (start_addr == LLDB_INVALID_ADDRESS) - return; - - FILE *out = m_opaque_sp->GetDebugger().GetOutputFileHandle(); - if (out == NULL) - return; - - if (m_opaque_sp) - { - ModuleSP module_sp; - if (module_name != NULL) - { - FileSpec module_file_spec (module_name, false); - module_sp = m_opaque_sp->GetImages().FindFirstModuleForFileSpec (module_file_spec, NULL); - } - - AddressRange range; - - // Make sure the process object is alive if we have one (it might be - // created but we might not be launched yet). - - Process *sb_process = m_opaque_sp->GetProcessSP().get(); - if (sb_process && !sb_process->IsAlive()) - sb_process = NULL; - - // If we are given a module, then "start_addr" is a file address in - // that module. - if (module_sp) - { - if (!module_sp->ResolveFileAddress (start_addr, range.GetBaseAddress())) - range.GetBaseAddress().SetOffset(start_addr); - } - else if (m_opaque_sp->GetSectionLoadList().IsEmpty() == false) - { - // We don't have a module, se we need to figure out if "start_addr" - // resolves to anything in a running process. - if (!m_opaque_sp->GetSectionLoadList().ResolveLoadAddress (start_addr, range.GetBaseAddress())) - range.GetBaseAddress().SetOffset(start_addr); - } - else - { - if (m_opaque_sp->GetImages().ResolveFileAddress (start_addr, range.GetBaseAddress())) - range.GetBaseAddress().SetOffset(start_addr); - } - - // For now, we need a process; the disassembly functions insist. If we don't have one already, - // make one. - - ExecutionContext exe_ctx; - - if (sb_process) - sb_process->CalculateExecutionContext(exe_ctx); - else - m_opaque_sp->CalculateExecutionContext(exe_ctx); - - if (end_addr == LLDB_INVALID_ADDRESS || end_addr < start_addr) - range.SetByteSize( DEFAULT_DISASM_BYTE_SIZE); - else - range.SetByteSize(end_addr - start_addr); - - StreamFile out_stream (out); - - Disassembler::Disassemble (m_opaque_sp->GetDebugger(), - m_opaque_sp->GetArchitecture(), - exe_ctx, - range, - 3, - false, - out_stream); - } -} - -void -SBTarget::Disassemble (const char *function_name, const char *module_name) -{ - if (function_name == NULL) - return; - - FILE *out = m_opaque_sp->GetDebugger().GetOutputFileHandle(); - if (out == NULL) - return; - - if (m_opaque_sp) - { - Disassembler *disassembler = Disassembler::FindPlugin (m_opaque_sp->GetArchitecture()); - if (disassembler == NULL) - return; - - ModuleSP module_sp; - if (module_name != NULL) - { - FileSpec module_file_spec (module_name, false); - module_sp = m_opaque_sp->GetImages().FindFirstModuleForFileSpec (module_file_spec, NULL); - } - - ExecutionContext exe_ctx; - - // Make sure the process object is alive if we have one (it might be - // created but we might not be launched yet). - Process *sb_process = m_opaque_sp->GetProcessSP().get(); - if (sb_process && !sb_process->IsAlive()) - sb_process = NULL; - - if (sb_process) - sb_process->CalculateExecutionContext(exe_ctx); - else - m_opaque_sp->CalculateExecutionContext(exe_ctx); - - - StreamFile out_stream (out); - - Disassembler::Disassemble (m_opaque_sp->GetDebugger(), - m_opaque_sp->GetArchitecture(), - exe_ctx, - ConstString (function_name), - module_sp.get(), - 3, - false, - out_stream); - } -} bool SBTarget::GetDescription (SBStream &description, lldb::DescriptionLevel description_level) Modified: lldb/trunk/source/API/SBThread.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBThread.cpp?rev=122262&r1=122261&r2=122262&view=diff ============================================================================== --- lldb/trunk/source/API/SBThread.cpp (original) +++ lldb/trunk/source/API/SBThread.cpp Mon Dec 20 14:49:23 2010 @@ -97,6 +97,7 @@ StopReason reason = eStopReasonInvalid; if (m_opaque_sp) { + Mutex::Locker api_locker (m_opaque_sp->GetProcess().GetTarget().GetAPIMutex()); StopInfoSP stop_info_sp = m_opaque_sp->GetStopInfo (); if (stop_info_sp) reason = stop_info_sp->GetStopReason(); @@ -114,6 +115,7 @@ { if (m_opaque_sp) { + Mutex::Locker api_locker (m_opaque_sp->GetProcess().GetTarget().GetAPIMutex()); StopInfoSP stop_info_sp = m_opaque_sp->GetStopInfo (); if (stop_info_sp) { @@ -158,6 +160,7 @@ { if (m_opaque_sp) { + Mutex::Locker api_locker (m_opaque_sp->GetProcess().GetTarget().GetAPIMutex()); StopInfoSP stop_info_sp = m_opaque_sp->GetStopInfo (); if (stop_info_sp) { @@ -219,6 +222,7 @@ if (m_opaque_sp) { + Mutex::Locker api_locker (m_opaque_sp->GetProcess().GetTarget().GetAPIMutex()); StopInfoSP stop_info_sp = m_opaque_sp->GetStopInfo (); if (stop_info_sp) { @@ -324,14 +328,14 @@ { LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); - lldb::tid_t id = LLDB_INVALID_THREAD_ID; + lldb::tid_t tid = LLDB_INVALID_THREAD_ID; if (m_opaque_sp) - id = m_opaque_sp->GetID(); + tid = m_opaque_sp->GetID(); if (log) - log->Printf ("SBThread(%p)::GetThreadID () => 0x%4.4x", m_opaque_sp.get(), id); + log->Printf ("SBThread(%p)::GetThreadID () => 0x%4.4x", m_opaque_sp.get(), tid); - return id; + return tid; } uint32_t @@ -346,7 +350,10 @@ { const char *name = NULL; if (m_opaque_sp) + { + Mutex::Locker api_locker (m_opaque_sp->GetProcess().GetTarget().GetAPIMutex()); name = m_opaque_sp->GetName(); + } LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); if (log) @@ -360,7 +367,10 @@ { const char *name = NULL; if (m_opaque_sp) + { + Mutex::Locker api_locker (m_opaque_sp->GetProcess().GetTarget().GetAPIMutex()); name = m_opaque_sp->GetQueueName(); + } LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); if (log) @@ -381,6 +391,7 @@ if (m_opaque_sp) { + Mutex::Locker api_locker (m_opaque_sp->GetProcess().GetTarget().GetAPIMutex()); bool abort_other_plans = true; StackFrameSP frame_sp(m_opaque_sp->GetStackFrameAtIndex (0)); @@ -430,6 +441,7 @@ if (m_opaque_sp) { + Mutex::Locker api_locker (m_opaque_sp->GetProcess().GetTarget().GetAPIMutex()); bool abort_other_plans = true; StackFrameSP frame_sp(m_opaque_sp->GetStackFrameAtIndex (0)); @@ -476,6 +488,7 @@ if (m_opaque_sp) { + Mutex::Locker api_locker (m_opaque_sp->GetProcess().GetTarget().GetAPIMutex()); bool abort_other_plans = true; bool stop_other_threads = true; @@ -504,6 +517,7 @@ if (m_opaque_sp) { + Mutex::Locker api_locker (m_opaque_sp->GetProcess().GetTarget().GetAPIMutex()); m_opaque_sp->QueueThreadPlanForStepSingleInstruction (step_over, true, true); Process &process = m_opaque_sp->GetProcess(); process.GetThreadList().SetSelectedThreadByID (m_opaque_sp->GetID()); @@ -578,7 +592,10 @@ uint32_t num_frames = 0; if (m_opaque_sp) + { + Mutex::Locker api_locker (m_opaque_sp->GetProcess().GetTarget().GetAPIMutex()); num_frames = m_opaque_sp->GetStackFrameCount(); + } if (log) log->Printf ("SBThread(%p)::GetNumFrames () => %u", m_opaque_sp.get(), num_frames); @@ -593,7 +610,10 @@ SBFrame sb_frame; if (m_opaque_sp) + { + Mutex::Locker api_locker (m_opaque_sp->GetProcess().GetTarget().GetAPIMutex()); sb_frame.SetFrame (m_opaque_sp->GetStackFrameAtIndex (idx)); + } if (log) { @@ -613,7 +633,10 @@ SBFrame sb_frame; if (m_opaque_sp) + { + Mutex::Locker api_locker (m_opaque_sp->GetProcess().GetTarget().GetAPIMutex()); sb_frame.SetFrame (m_opaque_sp->GetSelectedFrame ()); + } if (log) { @@ -634,6 +657,7 @@ SBFrame sb_frame; if (m_opaque_sp) { + Mutex::Locker api_locker (m_opaque_sp->GetProcess().GetTarget().GetAPIMutex()); lldb::StackFrameSP frame_sp (m_opaque_sp->GetStackFrameAtIndex (idx)); if (frame_sp) { Modified: lldb/trunk/source/API/SBValue.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBValue.cpp?rev=122262&r1=122261&r2=122262&view=diff ============================================================================== --- lldb/trunk/source/API/SBValue.cpp (original) +++ lldb/trunk/source/API/SBValue.cpp Mon Dec 20 14:49:23 2010 @@ -23,6 +23,7 @@ #include "lldb/Target/ExecutionContext.h" #include "lldb/Target/Process.h" #include "lldb/Target/StackFrame.h" +#include "lldb/Target/Target.h" #include "lldb/Target/Thread.h" #include "lldb/API/SBProcess.h" @@ -135,12 +136,19 @@ } bool -SBValue::IsInScope (const SBFrame &frame) +SBValue::IsInScope (const SBFrame &sb_frame) { bool result = false; if (m_opaque_sp) - result = m_opaque_sp->IsInScope (frame.get()); + { + StackFrame *frame = sb_frame.get(); + if (frame) + { + Mutex::Locker api_locker (frame->GetThread().GetProcess().GetTarget().GetAPIMutex()); + result = m_opaque_sp->IsInScope (frame); + } + } LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); if (log) @@ -150,18 +158,25 @@ } const char * -SBValue::GetValue (const SBFrame &frame) +SBValue::GetValue (const SBFrame &sb_frame) { const char *cstr = NULL; - if ( m_opaque_sp) - cstr = m_opaque_sp->GetValueAsCString (frame.get()); + if (m_opaque_sp) + { + StackFrame *frame = sb_frame.get(); + if (frame) + { + Mutex::Locker api_locker (frame->GetThread().GetProcess().GetTarget().GetAPIMutex()); + cstr = m_opaque_sp->GetValueAsCString (frame); + } + } LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); if (log) { if (cstr) - log->Printf ("SBValue(%p)::GetValue (SBFrame(%p)) => \"%s\"", m_opaque_sp.get(), frame.get(), cstr); + log->Printf ("SBValue(%p)::GetValue (SBFrame(%p)) => \"%s\"", m_opaque_sp.get(), sb_frame.get(), cstr); else - log->Printf ("SBValue(%p)::GetValue (SBFrame(%p)) => NULL", m_opaque_sp.get(), frame.get()); + log->Printf ("SBValue(%p)::GetValue (SBFrame(%p)) => NULL", m_opaque_sp.get(), sb_frame.get()); } return cstr; @@ -193,75 +208,110 @@ } const char * -SBValue::GetObjectDescription (const SBFrame &frame) +SBValue::GetObjectDescription (const SBFrame &sb_frame) { const char *cstr = NULL; if ( m_opaque_sp) - cstr = m_opaque_sp->GetObjectDescription (frame.get()); + { + StackFrame *frame = sb_frame.get(); + if (frame) + { + Mutex::Locker api_locker (frame->GetThread().GetProcess().GetTarget().GetAPIMutex()); + cstr = m_opaque_sp->GetObjectDescription (frame); + } + } LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); if (log) { if (cstr) - log->Printf ("SBValue(%p)::GetObjectDescription (SBFrame(%p)) => \"%s\"", m_opaque_sp.get(), frame.get(), cstr); + log->Printf ("SBValue(%p)::GetObjectDescription (SBFrame(%p)) => \"%s\"", m_opaque_sp.get(), sb_frame.get(), cstr); else - log->Printf ("SBValue(%p)::GetObjectDescription (SBFrame(%p)) => NULL", m_opaque_sp.get(), frame.get()); + log->Printf ("SBValue(%p)::GetObjectDescription (SBFrame(%p)) => NULL", m_opaque_sp.get(), sb_frame.get()); } return cstr; } bool -SBValue::GetValueDidChange (const SBFrame &frame) +SBValue::GetValueDidChange (const SBFrame &sb_frame) { bool result = false; if (m_opaque_sp) - result = m_opaque_sp->GetValueDidChange (frame.get()); + { + StackFrame *frame = sb_frame.get(); + if (frame) + { + Mutex::Locker api_locker (frame->GetThread().GetProcess().GetTarget().GetAPIMutex()); + result = m_opaque_sp->GetValueDidChange (frame); + } + } LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); if (log) - log->Printf ("SBValue(%p)::GetValueDidChange (SBFrame(%p)) => %i", m_opaque_sp.get(), frame.get(), result); + log->Printf ("SBValue(%p)::GetValueDidChange (SBFrame(%p)) => %i", m_opaque_sp.get(), sb_frame.get(), result); return result; } const char * -SBValue::GetSummary (const SBFrame &frame) +SBValue::GetSummary (const SBFrame &sb_frame) { const char *cstr = NULL; if (m_opaque_sp) - cstr = m_opaque_sp->GetSummaryAsCString(frame.get()); + { + StackFrame *frame = sb_frame.get(); + if (frame) + { + Mutex::Locker api_locker (frame->GetThread().GetProcess().GetTarget().GetAPIMutex()); + cstr = m_opaque_sp->GetSummaryAsCString(frame); + } + } LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); if (log) { if (cstr) - log->Printf ("SBValue(%p)::GetSummary (SBFrame(%p)) => \"%s\"", m_opaque_sp.get(), frame.get(), cstr); + log->Printf ("SBValue(%p)::GetSummary (SBFrame(%p)) => \"%s\"", m_opaque_sp.get(), sb_frame.get(), cstr); else - log->Printf ("SBValue(%p)::GetSummary (SBFrame(%p)) => NULL", m_opaque_sp.get(), frame.get()); + log->Printf ("SBValue(%p)::GetSummary (SBFrame(%p)) => NULL", m_opaque_sp.get(), sb_frame.get()); } return cstr; } const char * -SBValue::GetLocation (const SBFrame &frame) +SBValue::GetLocation (const SBFrame &sb_frame) { const char *cstr = NULL; if (m_opaque_sp) - cstr = m_opaque_sp->GetLocationAsCString(frame.get()); + { + StackFrame *frame = sb_frame.get(); + if (frame) + { + Mutex::Locker api_locker (frame->GetThread().GetProcess().GetTarget().GetAPIMutex()); + cstr = m_opaque_sp->GetLocationAsCString(frame); + } + } LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); if (log) { if (cstr) - log->Printf ("SBValue(%p)::GetSummary (SBFrame(%p)) => \"%s\"", m_opaque_sp.get(), frame.get(), cstr); + log->Printf ("SBValue(%p)::GetSummary (SBFrame(%p)) => \"%s\"", m_opaque_sp.get(), sb_frame.get(), cstr); else - log->Printf ("SBValue(%p)::GetSummary (SBFrame(%p)) => NULL", m_opaque_sp.get(), frame.get()); + log->Printf ("SBValue(%p)::GetSummary (SBFrame(%p)) => NULL", m_opaque_sp.get(), sb_frame.get()); } return cstr; } bool -SBValue::SetValueFromCString (const SBFrame &frame, const char *value_str) +SBValue::SetValueFromCString (const SBFrame &sb_frame, const char *value_str) { bool success = false; if (m_opaque_sp) - success = m_opaque_sp->SetValueFromCString (frame.get(), value_str); + { + StackFrame *frame = sb_frame.get(); + if (frame) + { + Mutex::Locker api_locker (frame->GetThread().GetProcess().GetTarget().GetAPIMutex()); + success = m_opaque_sp->SetValueFromCString (frame, value_str); + } + } return success; } @@ -336,17 +386,6 @@ return num_children; } -bool -SBValue::ValueIsStale () -{ - bool result = true; - - if (m_opaque_sp) - result = m_opaque_sp->GetValueIsValid(); - - return result; -} - SBValue SBValue::Dereference () @@ -354,8 +393,8 @@ SBValue sb_value; if (m_opaque_sp) { - if (m_opaque_sp->IsPointerType()) - sb_value = GetChildAtIndex(0); + Error error; + sb_value = m_opaque_sp->Dereference (error); } LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); if (log) Modified: lldb/trunk/source/API/SBValueList.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBValueList.cpp?rev=122262&r1=122261&r2=122262&view=diff ============================================================================== --- lldb/trunk/source/API/SBValueList.cpp (original) +++ lldb/trunk/source/API/SBValueList.cpp Mon Dec 20 14:49:23 2010 @@ -11,8 +11,6 @@ #include "lldb/API/SBValueList.h" #include "lldb/API/SBValue.h" #include "lldb/API/SBStream.h" - - #include "lldb/Core/Log.h" #include "lldb/Core/ValueObjectList.h" @@ -35,16 +33,8 @@ if (log) { log->Printf ("SBValueList::SBValueList (rhs.ap=%p) => this.ap = %p", - (rhs.IsValid() ? rhs.m_opaque_ap.get() : NULL), m_opaque_ap.get()); - - uint32_t num_vars = GetSize(); - for (uint32_t i = 0; i < num_vars; ++i) - { - SBValue value = GetValueAtIndex (i); - SBStream sstr; - value.GetDescription (sstr); - log->Printf (" %s", sstr.GetData()); - } + (rhs.IsValid() ? rhs.m_opaque_ap.get() : NULL), + m_opaque_ap.get()); } } @@ -58,18 +48,9 @@ if (log) { - log->Printf ("SBValueList::SBValueList (lldb_object_ptr=%p) => this.ap = %p", lldb_object_ptr, + log->Printf ("SBValueList::SBValueList (lldb_object_ptr=%p) => this.ap = %p", + lldb_object_ptr, m_opaque_ap.get()); - - - uint32_t num_vars = GetSize(); - for (uint32_t i = 0; i < num_vars; ++i) - { - SBValue value = GetValueAtIndex (i); - SBStream sstr; - value.GetDescription (sstr); - log->Printf (" %s", sstr.GetData()); - } } } @@ -194,7 +175,7 @@ SBValueList::FindValueObjectByUID (lldb::user_id_t uid) { SBValue sb_value; - if ( m_opaque_ap.get()) + if (m_opaque_ap.get()) *sb_value = m_opaque_ap->FindValueObjectByUID (uid); return sb_value; } Modified: lldb/trunk/source/Core/ValueObject.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/ValueObject.cpp?rev=122262&r1=122261&r2=122262&view=diff ============================================================================== --- lldb/trunk/source/Core/ValueObject.cpp (original) +++ lldb/trunk/source/Core/ValueObject.cpp Mon Dec 20 14:49:23 2010 @@ -1203,7 +1203,7 @@ } lldb::ValueObjectSP -ValueObject::Dereference (ExecutionContextScope *exe_scope, Error &error) +ValueObject::Dereference (Error &error) { lldb::ValueObjectSP valobj_sp; const bool is_pointer_type = IsPointerType(); Modified: lldb/trunk/source/Target/StackFrame.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/StackFrame.cpp?rev=122262&r1=122261&r2=122262&view=diff ============================================================================== --- lldb/trunk/source/Target/StackFrame.cpp (original) +++ lldb/trunk/source/Target/StackFrame.cpp Mon Dec 20 14:49:23 2010 @@ -688,7 +688,7 @@ { if (deref) { - ValueObjectSP deref_valobj_sp (valobj_sp->Dereference(this, error)); + ValueObjectSP deref_valobj_sp (valobj_sp->Dereference(error)); valobj_sp = deref_valobj_sp; } else if (address_of) Modified: lldb/trunk/source/Target/Target.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/Target.cpp?rev=122262&r1=122261&r2=122262&view=diff ============================================================================== --- lldb/trunk/source/Target/Target.cpp (original) +++ lldb/trunk/source/Target/Target.cpp Mon Dec 20 14:49:23 2010 @@ -40,6 +40,7 @@ Broadcaster("lldb.target"), TargetInstanceSettings (*GetSettingsController()), m_debugger (debugger), + m_mutex (Mutex::eMutexTypeRecursive), m_images(), m_section_load_list (), m_breakpoint_list (false), From johnny.chen at apple.com Mon Dec 20 15:07:54 2010 From: johnny.chen at apple.com (Johnny Chen) Date: Mon, 20 Dec 2010 21:07:54 -0000 Subject: [Lldb-commits] [lldb] r122266 - /lldb/trunk/source/Core/ConnectionFileDescriptor.cpp Message-ID: <20101220210754.C93522A6C12C@llvm.org> Author: johnny Date: Mon Dec 20 15:07:54 2010 New Revision: 122266 URL: http://llvm.org/viewvc/llvm-project?rev=122266&view=rev Log: Patch from Stephen Wilson: POSIX does not define sockaddr_un.sun_len. Set only when required by the platform. Modified: lldb/trunk/source/Core/ConnectionFileDescriptor.cpp Modified: lldb/trunk/source/Core/ConnectionFileDescriptor.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/ConnectionFileDescriptor.cpp?rev=122266&r1=122265&r2=122266&view=diff ============================================================================== --- lldb/trunk/source/Core/ConnectionFileDescriptor.cpp (original) +++ lldb/trunk/source/Core/ConnectionFileDescriptor.cpp Mon Dec 20 15:07:54 2010 @@ -432,7 +432,9 @@ saddr_un.sun_family = AF_UNIX; ::strncpy(saddr_un.sun_path, socket_name, sizeof(saddr_un.sun_path) - 1); saddr_un.sun_path[sizeof(saddr_un.sun_path) - 1] = '\0'; +#if defined(__APPLE__) || defined(__FreeBSD__) saddr_un.sun_len = SUN_LEN (&saddr_un); +#endif if (::bind (listen_socket, (struct sockaddr *)&saddr_un, SUN_LEN (&saddr_un)) == 0) { From johnny.chen at apple.com Mon Dec 20 15:29:35 2010 From: johnny.chen at apple.com (Johnny Chen) Date: Mon, 20 Dec 2010 21:29:35 -0000 Subject: [Lldb-commits] [lldb] r122272 - /lldb/trunk/test/settings/TestSettings.py Message-ID: <20101220212935.113932A6C12C@llvm.org> Author: johnny Date: Mon Dec 20 15:29:34 2010 New Revision: 122272 URL: http://llvm.org/viewvc/llvm-project?rev=122272&view=rev Log: Change the test case test_set_prompt() to no longer require quotes around lldb2 in: # Set prompt to 'lldb2'. self.runCmd("settings set prompt lldb2") Modified: lldb/trunk/test/settings/TestSettings.py Modified: lldb/trunk/test/settings/TestSettings.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/settings/TestSettings.py?rev=122272&r1=122271&r2=122272&view=diff ============================================================================== --- lldb/trunk/test/settings/TestSettings.py (original) +++ lldb/trunk/test/settings/TestSettings.py Mon Dec 20 15:29:34 2010 @@ -22,7 +22,7 @@ """Test that 'set prompt' actually changes the prompt.""" # Set prompt to 'lldb2'. - self.runCmd("settings set prompt 'lldb2'") + self.runCmd("settings set prompt lldb2") # Immediately test the setting. self.expect("settings show prompt", SETTING_MSG("prompt"), From johnny.chen at apple.com Mon Dec 20 15:45:22 2010 From: johnny.chen at apple.com (Johnny Chen) Date: Mon, 20 Dec 2010 21:45:22 -0000 Subject: [Lldb-commits] [lldb] r122274 - in /lldb/trunk: include/lldb/Utility/ArchDefaultUnwindPlan.h include/lldb/Utility/ArchVolatileRegs.h include/lldb/Utility/UnwindAssemblyProfiler.h source/Expression/ClangPersistentVariables.cpp source/Utility/ArchDefaultUnwindPlan.cpp source/Utility/ArchVolatileRegs.cpp source/Utility/UnwindAssemblyProfiler.cpp Message-ID: <20101220214522.CAC312A6C12C@llvm.org> Author: johnny Date: Mon Dec 20 15:45:22 2010 New Revision: 122274 URL: http://llvm.org/viewvc/llvm-project?rev=122274&view=rev Log: Patch from Stephen Wilson: Provide full qualification for #include's. Modified: lldb/trunk/include/lldb/Utility/ArchDefaultUnwindPlan.h lldb/trunk/include/lldb/Utility/ArchVolatileRegs.h lldb/trunk/include/lldb/Utility/UnwindAssemblyProfiler.h lldb/trunk/source/Expression/ClangPersistentVariables.cpp lldb/trunk/source/Utility/ArchDefaultUnwindPlan.cpp lldb/trunk/source/Utility/ArchVolatileRegs.cpp lldb/trunk/source/Utility/UnwindAssemblyProfiler.cpp Modified: lldb/trunk/include/lldb/Utility/ArchDefaultUnwindPlan.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Utility/ArchDefaultUnwindPlan.h?rev=122274&r1=122273&r2=122274&view=diff ============================================================================== --- lldb/trunk/include/lldb/Utility/ArchDefaultUnwindPlan.h (original) +++ lldb/trunk/include/lldb/Utility/ArchDefaultUnwindPlan.h Mon Dec 20 15:45:22 2010 @@ -10,7 +10,7 @@ #ifndef utility_ArchDefaultUnwindPlan_h_ #define utility_ArchDefaultUnwindPlan_h_ -#include "lldb-private.h" +#include "lldb/lldb-private.h" #include "lldb/Core/PluginInterface.h" namespace lldb_private { Modified: lldb/trunk/include/lldb/Utility/ArchVolatileRegs.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Utility/ArchVolatileRegs.h?rev=122274&r1=122273&r2=122274&view=diff ============================================================================== --- lldb/trunk/include/lldb/Utility/ArchVolatileRegs.h (original) +++ lldb/trunk/include/lldb/Utility/ArchVolatileRegs.h Mon Dec 20 15:45:22 2010 @@ -10,7 +10,7 @@ #ifndef utility_ArchVolatileRegs_h_ #define utility_ArchVolatileRegs_h_ -#include "lldb-private.h" +#include "lldb/lldb-private.h" #include "lldb/Core/PluginInterface.h" namespace lldb_private { Modified: lldb/trunk/include/lldb/Utility/UnwindAssemblyProfiler.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Utility/UnwindAssemblyProfiler.h?rev=122274&r1=122273&r2=122274&view=diff ============================================================================== --- lldb/trunk/include/lldb/Utility/UnwindAssemblyProfiler.h (original) +++ lldb/trunk/include/lldb/Utility/UnwindAssemblyProfiler.h Mon Dec 20 15:45:22 2010 @@ -10,7 +10,7 @@ #ifndef utility_UnwindAssemblyProfiler_h_ #define utility_UnwindAssemblyProfiler_h_ -#include "lldb-private.h" +#include "lldb/lldb-private.h" #include "lldb/Core/PluginInterface.h" namespace lldb_private { Modified: lldb/trunk/source/Expression/ClangPersistentVariables.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/ClangPersistentVariables.cpp?rev=122274&r1=122273&r2=122274&view=diff ============================================================================== --- lldb/trunk/source/Expression/ClangPersistentVariables.cpp (original) +++ lldb/trunk/source/Expression/ClangPersistentVariables.cpp Mon Dec 20 15:45:22 2010 @@ -7,7 +7,7 @@ // //===----------------------------------------------------------------------===// -#include "ClangPersistentVariables.h" +#include "lldb/Expression/ClangPersistentVariables.h" #include "lldb/Core/DataExtractor.h" #include "lldb/Core/Log.h" #include "lldb/Core/StreamString.h" Modified: lldb/trunk/source/Utility/ArchDefaultUnwindPlan.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Utility/ArchDefaultUnwindPlan.cpp?rev=122274&r1=122273&r2=122274&view=diff ============================================================================== --- lldb/trunk/source/Utility/ArchDefaultUnwindPlan.cpp (original) +++ lldb/trunk/source/Utility/ArchDefaultUnwindPlan.cpp Mon Dec 20 15:45:22 2010 @@ -7,7 +7,7 @@ // //===----------------------------------------------------------------------===// -#include "lldb-private.h" +#include "lldb/lldb-private.h" #include "lldb/Core/PluginManager.h" #include "lldb/Core/PluginInterface.h" #include "lldb/Utility/ArchDefaultUnwindPlan.h" Modified: lldb/trunk/source/Utility/ArchVolatileRegs.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Utility/ArchVolatileRegs.cpp?rev=122274&r1=122273&r2=122274&view=diff ============================================================================== --- lldb/trunk/source/Utility/ArchVolatileRegs.cpp (original) +++ lldb/trunk/source/Utility/ArchVolatileRegs.cpp Mon Dec 20 15:45:22 2010 @@ -7,7 +7,7 @@ // //===----------------------------------------------------------------------===// -#include "lldb-private.h" +#include "lldb/lldb-private.h" #include "lldb/Core/PluginManager.h" #include "lldb/Core/PluginInterface.h" #include "lldb/Utility/ArchVolatileRegs.h" Modified: lldb/trunk/source/Utility/UnwindAssemblyProfiler.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Utility/UnwindAssemblyProfiler.cpp?rev=122274&r1=122273&r2=122274&view=diff ============================================================================== --- lldb/trunk/source/Utility/UnwindAssemblyProfiler.cpp (original) +++ lldb/trunk/source/Utility/UnwindAssemblyProfiler.cpp Mon Dec 20 15:45:22 2010 @@ -7,7 +7,7 @@ // //===----------------------------------------------------------------------===// -#include "lldb-private.h" +#include "lldb/lldb-private.h" #include "lldb/Core/PluginManager.h" #include "lldb/Core/PluginInterface.h" #include "lldb/Utility/UnwindAssemblyProfiler.h" From johnny.chen at apple.com Mon Dec 20 15:52:18 2010 From: johnny.chen at apple.com (Johnny Chen) Date: Mon, 20 Dec 2010 21:52:18 -0000 Subject: [Lldb-commits] [lldb] r122275 - /lldb/trunk/source/Host/common/Host.cpp Message-ID: <20101220215218.8543E2A6C12C@llvm.org> Author: johnny Date: Mon Dec 20 15:52:18 2010 New Revision: 122275 URL: http://llvm.org/viewvc/llvm-project?rev=122275&view=rev Log: Patch from Stephen: Provide a missing resolve_path argument in calls to FileSpec's constructor for both Linux and FreeBSD code fragments. Modified: lldb/trunk/source/Host/common/Host.cpp Modified: lldb/trunk/source/Host/common/Host.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/common/Host.cpp?rev=122275&r1=122274&r2=122275&view=diff ============================================================================== --- lldb/trunk/source/Host/common/Host.cpp (original) +++ lldb/trunk/source/Host/common/Host.cpp Mon Dec 20 15:52:18 2010 @@ -622,7 +622,7 @@ char exe_path[PATH_MAX]; ssize_t len = readlink("/proc/self/exe", exe_path, sizeof(exe_path)); if (len >= 0) - g_program_filespec = FileSpec(exe_path); + g_program_filespec = FileSpec(exe_path, true); #elif defined (__FreeBSD__) int exe_path_mib[4] = { CTL_KERN, KERN_PROC, KERN_PROC_PATHNAME, getpid() }; size_t exe_path_size; @@ -630,7 +630,7 @@ { char *exe_path = new char[exe_path_size]; if (sysctl(exe_path_mib, 4, exe_path, &exe_path_size, NULL, 0) == 0) - g_program_filespec = FileSpec(exe_path); + g_program_filespec = FileSpec(exe_path, true); } #endif } From johnny.chen at apple.com Mon Dec 20 16:58:58 2010 From: johnny.chen at apple.com (Johnny Chen) Date: Mon, 20 Dec 2010 22:58:58 -0000 Subject: [Lldb-commits] [lldb] r122286 - /lldb/trunk/utils/emacs/gud.el Message-ID: <20101220225858.731E92A6C12C@llvm.org> Author: johnny Date: Mon Dec 20 16:58:58 2010 New Revision: 122286 URL: http://llvm.org/viewvc/llvm-project?rev=122286&view=rev Log: The recent change in argument parsing is messing up the emacs lldb mode's capability to properly scan the debugger output for program counter when it comes to the output of 'Up Stack' or 'Down Stack' gud commands. Remove the single quotes around the argument strings for "settings set frame-format" and "settings set thread-format" commands to avoid the single quotes which were being emitted as part of the debugger output. Modified: lldb/trunk/utils/emacs/gud.el Modified: lldb/trunk/utils/emacs/gud.el URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/utils/emacs/gud.el?rev=122286&r1=122285&r2=122286&view=diff ============================================================================== --- lldb/trunk/utils/emacs/gud.el (original) +++ lldb/trunk/utils/emacs/gud.el Mon Dec 20 16:58:58 2010 @@ -1001,9 +1001,9 @@ ;; Make lldb dump fullpath instead of basename for a file. ;; See also gud-lldb-marker-filter where gud-last-frame is grokked from lldb output. (progn - (gud-call "settings set frame-format 'frame #${frame.index}: ${frame.pc}{ ${module.file.basename}{`${function.name}${function.pc-offset}}}{ at ${line.file.fullpath}:${line.number}}\\n'") + (gud-call "settings set frame-format frame #${frame.index}: ${frame.pc}{ ${module.file.basename}{`${function.name}${function.pc-offset}}}{ at ${line.file.fullpath}:${line.number}}\\n") (sit-for 1) - (gud-call "settings set thread-format 'thread #${thread.index}: tid = ${thread.id}{, ${frame.pc}}{ ${module.file.basename}{`${function.name}${function.pc-offset}}}{ at ${line.file.fullpath}:${line.number}}{, stop reason = ${thread.stop-reason}}\\n'") + (gud-call "settings set thread-format thread #${thread.index}: tid = ${thread.id}{, ${frame.pc}}{ ${module.file.basename}{`${function.name}${function.pc-offset}}}{ at ${line.file.fullpath}:${line.number}}{, stop reason = ${thread.stop-reason}}\\n") (sit-for 1)) (gud-def gud-listb "breakpoint list" From gclayton at apple.com Mon Dec 20 17:42:12 2010 From: gclayton at apple.com (Greg Clayton) Date: Mon, 20 Dec 2010 23:42:12 -0000 Subject: [Lldb-commits] [lldb] r122290 - /lldb/trunk/source/Core/ModuleList.cpp Message-ID: <20101220234212.546B42A6C12C@llvm.org> Author: gclayton Date: Mon Dec 20 17:42:12 2010 New Revision: 122290 URL: http://llvm.org/viewvc/llvm-project?rev=122290&view=rev Log: Remove an assertion that is causing crashes. We do need to find a way to reproduce when this assertion asserts, but we should crash our debug session because of it. For now we log to stderr in hope of tracking it down. Modified: lldb/trunk/source/Core/ModuleList.cpp Modified: lldb/trunk/source/Core/ModuleList.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/ModuleList.cpp?rev=122290&r1=122289&r2=122290&view=diff ============================================================================== --- lldb/trunk/source/Core/ModuleList.cpp (original) +++ lldb/trunk/source/Core/ModuleList.cpp Mon Dec 20 17:42:12 2010 @@ -502,7 +502,17 @@ { ModuleList &shared_module_list = GetSharedModuleList (); module_sp = shared_module_list.FindModule (module_ptr); - assert (module_sp.get()); // This might fire off a few times and we need to make sure it never fires... + if (module_sp.get() == NULL) + { + char uuid_cstr[256]; + const_cast(module_ptr)->GetUUID().GetAsCString (uuid_cstr, sizeof(uuid_cstr)); + const FileSpec &module_file_spec = module_ptr->GetFileSpec(); + fprintf (stderr, "warning: module not in shared module list: %s (%s) \"%s/%s\"\n", + uuid_cstr, + module_ptr->GetArchitecture().AsCString(), + module_file_spec.GetDirectory().GetCString(), + module_file_spec.GetFilename().GetCString()); + } } return module_sp; } From johnny.chen at apple.com Mon Dec 20 20:06:56 2010 From: johnny.chen at apple.com (Johnny Chen) Date: Tue, 21 Dec 2010 02:06:56 -0000 Subject: [Lldb-commits] [lldb] r122304 - in /lldb/trunk/test/python_api/event: ./ Makefile TestEvents.py main.c Message-ID: <20101221020656.EF4E82A6C12C@llvm.org> Author: johnny Date: Mon Dec 20 20:06:56 2010 New Revision: 122304 URL: http://llvm.org/viewvc/llvm-project?rev=122304&view=rev Log: Added python_api/event/TestEvents.py to get the listener object associated with the debugger and to exercise some event APIs. Added: lldb/trunk/test/python_api/event/ lldb/trunk/test/python_api/event/Makefile lldb/trunk/test/python_api/event/TestEvents.py lldb/trunk/test/python_api/event/main.c Added: lldb/trunk/test/python_api/event/Makefile URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/python_api/event/Makefile?rev=122304&view=auto ============================================================================== --- lldb/trunk/test/python_api/event/Makefile (added) +++ lldb/trunk/test/python_api/event/Makefile Mon Dec 20 20:06:56 2010 @@ -0,0 +1,5 @@ +LEVEL = ../../make + +C_SOURCES := main.c + +include $(LEVEL)/Makefile.rules Added: lldb/trunk/test/python_api/event/TestEvents.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/python_api/event/TestEvents.py?rev=122304&view=auto ============================================================================== --- lldb/trunk/test/python_api/event/TestEvents.py (added) +++ lldb/trunk/test/python_api/event/TestEvents.py Mon Dec 20 20:06:56 2010 @@ -0,0 +1,100 @@ +""" +Test lldb Python event APIs. +""" + +import os, time +import re +import unittest2 +import lldb, lldbutil +from lldbtest import * + +class EventAPITestCase(TestBase): + + mydir = os.path.join("python_api", "event") + + @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin") + @python_api_test + def test_with_dsym(self): + """Exercise SBEvent APIs.""" + self.buildDsym() + self.do_events() + + @python_api_test + def test_with_dwarf(self): + """Exercise SBEvent APIs.""" + self.buildDwarf() + self.do_events() + + def setUp(self): + # Call super's setUp(). + TestBase.setUp(self) + # Find the line number to of function 'c'. + self.line = line_number('main.c', '// Find the line number of function "c" here.') + + def do_events(self): + """Get the listener associated with the debugger and exercise some event APIs.""" + exe = os.path.join(os.getcwd(), "a.out") + + # Create a target by the debugger. + target = self.dbg.CreateTarget(exe) + self.assertTrue(target.IsValid(), VALID_TARGET) + + # Now create a breakpoint on main.c by name 'c'. + breakpoint = target.BreakpointCreateByName('c', 'a.out') + #print "breakpoint:", breakpoint + self.assertTrue(breakpoint.IsValid() and + breakpoint.GetNumLocations() == 1, + VALID_BREAKPOINT) + + # Now launch the process, and do not stop at entry point. + self.process = target.LaunchProcess([''], [''], os.ctermid(), 0, False) + + self.process = target.GetProcess() + self.assertTrue(self.process.IsValid(), PROCESS_IS_VALID) + + # Get a handle on the process's broadcaster. + broadcaster = self.process.GetBroadcaster() + self.assertTrue(broadcaster.IsValid(), "Process with valid broadcaster") + + # Create an empty event object. + event = lldb.SBEvent() + self.assertFalse(event.IsValid(), "Event should not be valid initially") + + # Get the debugger listenr. + listener = self.dbg.GetListener() + + # Create MyListeningThread to wait for any kind of event. + import threading + class MyListeningThread(threading.Thread): + def run(self): + print "Running MyListeningThread:", self + count = 0 + # Let's only try at most 3 times to retrieve any kind of event. + while not count > 3: + if listener.WaitForEvent(5, event): + print "Got a valid event:", event + print "Event type:", event.GetType() + print "Event broadcaster:", event.GetBroadcaster().GetName() + return + count = count + 1 + print "Timeout: listener.WaitForEvent" + + return + + # Let's start the listening thread before we launch the inferior process. + my_thread = MyListeningThread() + my_thread.start() + + # Use Python API to continue the process. The listening thread should be + # able to receive a state changed event. + self.process.Continue() + + my_thread.join() + self.assertTrue(event.IsValid()) + + +if __name__ == '__main__': + import atexit + lldb.SBDebugger.Initialize() + atexit.register(lambda: lldb.SBDebugger.Terminate()) + unittest2.main() Added: lldb/trunk/test/python_api/event/main.c URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/python_api/event/main.c?rev=122304&view=auto ============================================================================== --- lldb/trunk/test/python_api/event/main.c (added) +++ lldb/trunk/test/python_api/event/main.c Mon Dec 20 20:06:56 2010 @@ -0,0 +1,49 @@ +//===-- main.c --------------------------------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +#include + +// This simple program is to test the lldb Python API related to events. + +int a(int); +int b(int); +int c(int); + +int a(int val) +{ + if (val <= 1) + return b(val); + else if (val >= 3) + return c(val); + + return val; +} + +int b(int val) +{ + return c(val); +} + +int c(int val) +{ + return val + 3; // Find the line number of function "c" here. +} + +int main (int argc, char const *argv[]) +{ + int A1 = a(1); // a(1) -> b(1) -> c(1) + printf("a(1) returns %d\n", A1); + + int B2 = b(2); // b(2) -> c(2) + printf("b(2) returns %d\n", B2); + + int A3 = a(3); // a(3) -> c(3) + printf("a(3) returns %d\n", A3); + + return 0; +} From johnny.chen at apple.com Mon Dec 20 20:10:18 2010 From: johnny.chen at apple.com (Johnny Chen) Date: Tue, 21 Dec 2010 02:10:18 -0000 Subject: [Lldb-commits] [lldb] r122306 - /lldb/trunk/test/python_api/event/TestEvents.py Message-ID: <20101221021018.89FF12A6C12C@llvm.org> Author: johnny Date: Mon Dec 20 20:10:18 2010 New Revision: 122306 URL: http://llvm.org/viewvc/llvm-project?rev=122306&view=rev Log: Fix typo. Modified: lldb/trunk/test/python_api/event/TestEvents.py Modified: lldb/trunk/test/python_api/event/TestEvents.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/python_api/event/TestEvents.py?rev=122306&r1=122305&r2=122306&view=diff ============================================================================== --- lldb/trunk/test/python_api/event/TestEvents.py (original) +++ lldb/trunk/test/python_api/event/TestEvents.py Mon Dec 20 20:10:18 2010 @@ -60,7 +60,7 @@ event = lldb.SBEvent() self.assertFalse(event.IsValid(), "Event should not be valid initially") - # Get the debugger listenr. + # Get the debugger listener. listener = self.dbg.GetListener() # Create MyListeningThread to wait for any kind of event. From gclayton at apple.com Mon Dec 20 20:23:58 2010 From: gclayton at apple.com (Greg Clayton) Date: Tue, 21 Dec 2010 02:23:58 -0000 Subject: [Lldb-commits] [lldb] r122308 - in /lldb/trunk: lldb.xcodeproj/project.pbxproj resources/LLDB-Info.plist tools/debugserver/debugserver.xcodeproj/project.pbxproj Message-ID: <20101221022359.0106B2A6C12C@llvm.org> Author: gclayton Date: Mon Dec 20 20:23:58 2010 New Revision: 122308 URL: http://llvm.org/viewvc/llvm-project?rev=122308&view=rev Log: Updated Xcode build version to lldb-37 and debugserver-123. Modified: lldb/trunk/lldb.xcodeproj/project.pbxproj lldb/trunk/resources/LLDB-Info.plist lldb/trunk/tools/debugserver/debugserver.xcodeproj/project.pbxproj Modified: lldb/trunk/lldb.xcodeproj/project.pbxproj URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/lldb.xcodeproj/project.pbxproj?rev=122308&r1=122307&r2=122308&view=diff ============================================================================== --- lldb/trunk/lldb.xcodeproj/project.pbxproj (original) +++ lldb/trunk/lldb.xcodeproj/project.pbxproj Mon Dec 20 20:23:58 2010 @@ -2920,9 +2920,9 @@ buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; COPY_PHASE_STRIP = NO; - CURRENT_PROJECT_VERSION = 36; + CURRENT_PROJECT_VERSION = 37; DYLIB_COMPATIBILITY_VERSION = 1; - DYLIB_CURRENT_VERSION = 36; + DYLIB_CURRENT_VERSION = 37; EXPORTED_SYMBOLS_FILE = "resources/lldb-framework-exports"; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", @@ -2972,11 +2972,11 @@ buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; COPY_PHASE_STRIP = NO; - CURRENT_PROJECT_VERSION = 36; + CURRENT_PROJECT_VERSION = 37; DEAD_CODE_STRIPPING = YES; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; DYLIB_COMPATIBILITY_VERSION = 1; - DYLIB_CURRENT_VERSION = 36; + DYLIB_CURRENT_VERSION = 37; EXPORTED_SYMBOLS_FILE = "resources/lldb-framework-exports"; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", @@ -3046,7 +3046,7 @@ isa = XCBuildConfiguration; buildSettings = { COPY_PHASE_STRIP = YES; - CURRENT_PROJECT_VERSION = 36; + CURRENT_PROJECT_VERSION = 37; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", @@ -3081,11 +3081,11 @@ buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; COPY_PHASE_STRIP = YES; - CURRENT_PROJECT_VERSION = 36; + CURRENT_PROJECT_VERSION = 37; DEAD_CODE_STRIPPING = YES; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; DYLIB_COMPATIBILITY_VERSION = 1; - DYLIB_CURRENT_VERSION = 36; + DYLIB_CURRENT_VERSION = 37; EXPORTED_SYMBOLS_FILE = "resources/lldb-framework-exports"; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", @@ -3134,7 +3134,7 @@ buildSettings = { CODE_SIGN_IDENTITY = lldb_codesign; COPY_PHASE_STRIP = NO; - CURRENT_PROJECT_VERSION = 36; + CURRENT_PROJECT_VERSION = 37; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", "\"$(SYSTEM_LIBRARY_DIR)/PrivateFrameworks\"", @@ -3172,7 +3172,7 @@ ); CODE_SIGN_IDENTITY = lldb_codesign; COPY_PHASE_STRIP = YES; - CURRENT_PROJECT_VERSION = 36; + CURRENT_PROJECT_VERSION = 37; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", Modified: lldb/trunk/resources/LLDB-Info.plist URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/resources/LLDB-Info.plist?rev=122308&r1=122307&r2=122308&view=diff ============================================================================== --- lldb/trunk/resources/LLDB-Info.plist (original) +++ lldb/trunk/resources/LLDB-Info.plist Mon Dec 20 20:23:58 2010 @@ -17,7 +17,7 @@ CFBundleSignature ???? CFBundleVersion - 36 + 37 CFBundleName ${EXECUTABLE_NAME} Modified: lldb/trunk/tools/debugserver/debugserver.xcodeproj/project.pbxproj URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/debugserver/debugserver.xcodeproj/project.pbxproj?rev=122308&r1=122307&r2=122308&view=diff ============================================================================== --- lldb/trunk/tools/debugserver/debugserver.xcodeproj/project.pbxproj (original) +++ lldb/trunk/tools/debugserver/debugserver.xcodeproj/project.pbxproj Mon Dec 20 20:23:58 2010 @@ -460,7 +460,7 @@ i386, ); COPY_PHASE_STRIP = NO; - CURRENT_PROJECT_VERSION = 122; + CURRENT_PROJECT_VERSION = 123; GCC_WARN_ABOUT_RETURN_TYPE = YES; GCC_WARN_UNUSED_VARIABLE = YES; STRIP_INSTALLED_PRODUCT = NO; @@ -478,7 +478,7 @@ x86_64, i386, ); - CURRENT_PROJECT_VERSION = 122; + CURRENT_PROJECT_VERSION = 123; DEAD_CODE_STRIPPING = YES; GCC_WARN_ABOUT_RETURN_TYPE = YES; GCC_WARN_UNUSED_VARIABLE = YES; @@ -498,7 +498,7 @@ x86_64, i386, ); - CURRENT_PROJECT_VERSION = 122; + CURRENT_PROJECT_VERSION = 123; DEAD_CODE_STRIPPING = YES; GCC_WARN_ABOUT_RETURN_TYPE = YES; GCC_WARN_UNUSED_VARIABLE = YES; @@ -515,7 +515,7 @@ buildSettings = { "CODE_SIGN_ENTITLEMENTS[sdk=iphoneos*]" = "source/debugserver-entitlements.plist"; COPY_PHASE_STRIP = YES; - CURRENT_PROJECT_VERSION = 122; + CURRENT_PROJECT_VERSION = 123; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; FRAMEWORK_SEARCH_PATHS = $SDKROOT/System/Library/PrivateFrameworks; "FRAMEWORK_SEARCH_PATHS[sdk=iphoneos*][arch=*]" = ( @@ -556,7 +556,7 @@ "CODE_SIGN_ENTITLEMENTS[sdk=iphoneos*]" = "source/debugserver-entitlements.plist"; "CODE_SIGN_IDENTITY[sdk=macosx*]" = lldb_codesign; COPY_PHASE_STRIP = YES; - CURRENT_PROJECT_VERSION = 122; + CURRENT_PROJECT_VERSION = 123; FRAMEWORK_SEARCH_PATHS = $SDKROOT/System/Library/PrivateFrameworks; "FRAMEWORK_SEARCH_PATHS[sdk=iphoneos*][arch=*]" = ( "$(SDKROOT)/System/Library/PrivateFrameworks", @@ -597,7 +597,7 @@ "CODE_SIGN_ENTITLEMENTS[sdk=iphoneos*]" = "source/debugserver-entitlements.plist"; "CODE_SIGN_IDENTITY[sdk=macosx*]" = lldb_codesign; COPY_PHASE_STRIP = YES; - CURRENT_PROJECT_VERSION = 122; + CURRENT_PROJECT_VERSION = 123; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; FRAMEWORK_SEARCH_PATHS = $SDKROOT/System/Library/PrivateFrameworks; "FRAMEWORK_SEARCH_PATHS[sdk=iphoneos*][arch=*]" = ( From johnny.chen at apple.com Mon Dec 20 23:43:37 2010 From: johnny.chen at apple.com (Johnny Chen) Date: Tue, 21 Dec 2010 05:43:37 -0000 Subject: [Lldb-commits] [lldb] r122316 - /lldb/trunk/test/python_api/event/TestEvents.py Message-ID: <20101221054338.002372A6C12D@llvm.org> Author: johnny Date: Mon Dec 20 23:43:37 2010 New Revision: 122316 URL: http://llvm.org/viewvc/llvm-project?rev=122316&view=rev Log: Set the debugger to asynchronous mode before using the Python API call to kill the process. The custom thread started before this point is running in a loop waiting for events to come. Modified: lldb/trunk/test/python_api/event/TestEvents.py Modified: lldb/trunk/test/python_api/event/TestEvents.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/python_api/event/TestEvents.py?rev=122316&r1=122315&r2=122316&view=diff ============================================================================== --- lldb/trunk/test/python_api/event/TestEvents.py (original) +++ lldb/trunk/test/python_api/event/TestEvents.py Mon Dec 20 23:43:37 2010 @@ -85,11 +85,20 @@ my_thread = MyListeningThread() my_thread.start() - # Use Python API to continue the process. The listening thread should be + # Set the debugger to be in asynchronous mode since our listening thread + # is waiting for events to come. + self.dbg.SetAsync(True) + + # Use Python API to kill the process. The listening thread should be # able to receive a state changed event. - self.process.Continue() + self.process.Kill() + # Wait until the 'MyListeningThread' terminates. my_thread.join() + + # Restore the original synchronous mode. + self.dbg.SetAsync(False) + self.assertTrue(event.IsValid()) From johnny.chen at apple.com Tue Dec 21 13:52:54 2010 From: johnny.chen at apple.com (Johnny Chen) Date: Tue, 21 Dec 2010 19:52:54 -0000 Subject: [Lldb-commits] [lldb] r122352 - /lldb/trunk/test/python_api/event/TestEvents.py Message-ID: <20101221195254.53EC92A6C12C@llvm.org> Author: johnny Date: Tue Dec 21 13:52:54 2010 New Revision: 122352 URL: http://llvm.org/viewvc/llvm-project?rev=122352&view=rev Log: Rename the test methods to be more meaningful. Modified: lldb/trunk/test/python_api/event/TestEvents.py Modified: lldb/trunk/test/python_api/event/TestEvents.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/python_api/event/TestEvents.py?rev=122352&r1=122351&r2=122352&view=diff ============================================================================== --- lldb/trunk/test/python_api/event/TestEvents.py (original) +++ lldb/trunk/test/python_api/event/TestEvents.py Tue Dec 21 13:52:54 2010 @@ -14,16 +14,16 @@ @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin") @python_api_test - def test_with_dsym(self): - """Exercise SBEvent APIs.""" + def test_wait_for_event_with_dsym(self): + """Exercise SBListener.WaitForEvent() APIs.""" self.buildDsym() - self.do_events() + self.do_wait_for_event() @python_api_test - def test_with_dwarf(self): - """Exercise SBEvent APIs.""" + def test_wait_for_event_with_dwarf(self): + """Exercise SBListener.WaitForEvent() APIs.""" self.buildDwarf() - self.do_events() + self.do_wait_for_event() def setUp(self): # Call super's setUp(). @@ -31,8 +31,8 @@ # Find the line number to of function 'c'. self.line = line_number('main.c', '// Find the line number of function "c" here.') - def do_events(self): - """Get the listener associated with the debugger and exercise some event APIs.""" + def do_wait_for_event(self): + """Get the listener associated with the debugger and exercise WaitForEvent API.""" exe = os.path.join(os.getcwd(), "a.out") # Create a target by the debugger. From johnny.chen at apple.com Tue Dec 21 18:32:54 2010 From: johnny.chen at apple.com (Johnny Chen) Date: Wed, 22 Dec 2010 00:32:54 -0000 Subject: [Lldb-commits] [lldb] r122380 - /lldb/trunk/test/python_api/event/TestEvents.py Message-ID: <20101222003254.E1D3D2A6C12C@llvm.org> Author: johnny Date: Tue Dec 21 18:32:54 2010 New Revision: 122380 URL: http://llvm.org/viewvc/llvm-project?rev=122380&view=rev Log: Add test cases for registering a listener object with the broadcaster of a process and waiting for two expected state changed events to arrive: "running" followed by "stopped". Modified: lldb/trunk/test/python_api/event/TestEvents.py Modified: lldb/trunk/test/python_api/event/TestEvents.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/python_api/event/TestEvents.py?rev=122380&r1=122379&r2=122380&view=diff ============================================================================== --- lldb/trunk/test/python_api/event/TestEvents.py (original) +++ lldb/trunk/test/python_api/event/TestEvents.py Tue Dec 21 18:32:54 2010 @@ -15,16 +15,29 @@ @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin") @python_api_test def test_wait_for_event_with_dsym(self): - """Exercise SBListener.WaitForEvent() APIs.""" + """Exercise SBListener.WaitForEvent() API.""" self.buildDsym() self.do_wait_for_event() @python_api_test def test_wait_for_event_with_dwarf(self): - """Exercise SBListener.WaitForEvent() APIs.""" + """Exercise SBListener.WaitForEvent() API.""" self.buildDwarf() self.do_wait_for_event() + @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin") + @python_api_test + def test_broadcast_event_with_dsym(self): + """Exercise SBBroadcaster.BroadcastEvent() API.""" + self.buildDsym() + self.do_broadcast_event() + + @python_api_test + def test_broadcast_event_with_dwarf(self): + """Exercise SBBroadcaster.BroadcastEvent() API.""" + self.buildDwarf() + self.do_broadcast_event() + def setUp(self): # Call super's setUp(). TestBase.setUp(self) @@ -67,39 +80,136 @@ import threading class MyListeningThread(threading.Thread): def run(self): - print "Running MyListeningThread:", self + #print "Running MyListeningThread:", self count = 0 # Let's only try at most 3 times to retrieve any kind of event. while not count > 3: if listener.WaitForEvent(5, event): - print "Got a valid event:", event - print "Event type:", event.GetType() - print "Event broadcaster:", event.GetBroadcaster().GetName() + #print "Got a valid event:", event + #print "Event type:", event.GetType() + #print "Event broadcaster:", event.GetBroadcaster().GetName() return count = count + 1 print "Timeout: listener.WaitForEvent" return - # Let's start the listening thread before we launch the inferior process. - my_thread = MyListeningThread() - my_thread.start() - - # Set the debugger to be in asynchronous mode since our listening thread - # is waiting for events to come. - self.dbg.SetAsync(True) - # Use Python API to kill the process. The listening thread should be # able to receive a state changed event. self.process.Kill() + # Let's start the listening thread to retrieve the event. + my_thread = MyListeningThread() + my_thread.start() + # Wait until the 'MyListeningThread' terminates. my_thread.join() - # Restore the original synchronous mode. - self.dbg.SetAsync(False) + self.assertTrue(event.IsValid(), + "My listening thread successfully received an event") + + def do_broadcast_event(self): + """Get the broadcaster associated with the process and exercise BroadcastEvent API.""" + exe = os.path.join(os.getcwd(), "a.out") + + # Create a target by the debugger. + target = self.dbg.CreateTarget(exe) + self.assertTrue(target.IsValid(), VALID_TARGET) + + # Now create a breakpoint on main.c by name 'c'. + breakpoint = target.BreakpointCreateByName('c', 'a.out') + #print "breakpoint:", breakpoint + self.assertTrue(breakpoint.IsValid() and + breakpoint.GetNumLocations() == 1, + VALID_BREAKPOINT) + + # Now launch the process, and do not stop at the entry point. + self.process = target.LaunchProcess([''], [''], os.ctermid(), 0, False) + + self.process = target.GetProcess() + self.assertTrue(self.process.GetState() == lldb.eStateStopped, + PROCESS_STOPPED) + + # Get a handle on the process's broadcaster. + broadcaster = self.process.GetBroadcaster() + self.assertTrue(broadcaster.IsValid(), "Process with valid broadcaster") + + # Create an empty event object. + event = lldb.SBEvent() + self.assertFalse(event.IsValid(), "Event should not be valid initially") + + # Create a listener object and register with the broadcaster. + listener = lldb.SBListener("TestEvents.listener") + rc = broadcaster.AddListener(listener, lldb.SBProcess.eBroadcastBitStateChanged) + self.assertTrue(rc, "AddListener successfully retruns") + + # The finite state machine for our custom listening thread, with an + # initail state of 0, which means a "running" event is expected. + # It changes to 1 after "running" is received. + # It cahnges to 2 after "stopped" is received. + # 2 will be our final state and the test is complete. + self.state = 0 + + # Create MyListeningThread to wait for state changed events. + # By design, a "running" event is expected following by a "stopped" event. + import threading + class MyListeningThread(threading.Thread): + def run(self): + #print "Running MyListeningThread:", self + + # Regular expression pattern for the event description. + pattern = re.compile("data = {.*, state = (.*)}$") + + # Let's only try at most 6 times to retrieve our events. + count = 0 + while True: + if listener.WaitForEvent(5, event): + stream = lldb.SBStream() + event.GetDescription(stream) + description = stream.GetData() + #print "Event data flavor:", event.GetDataFlavor() + #print "Event description:", description + match = pattern.search(description) + if not match: + break; + if self.context.state == 0 and match.group(1) == 'running': + self.context.state = 1 + continue + elif self.context.state == 1 and match.group(1) == 'stopped': + # Whoopee, both events have been received! + self.context.state = 2 + break + else: + break + print "Timeout: listener.WaitForEvent" + count = count + 1 + if count > 6: + break + + return + + # Use Python API to continue the process. The listening thread should be + # able to receive the state changed events. + self.process.Continue() + + # Start the listening thread to receive the "running" followed by the + # "stopped" events. + my_thread = MyListeningThread() + # Supply the enclosing context so that our listening thread can access + # the 'state' variable. + my_thread.context = self + my_thread.start() + + # Wait until the 'MyListeningThread' terminates. + my_thread.join() - self.assertTrue(event.IsValid()) + # We are no longer interested in receiving state changed events. + # Remove our custom listener before the inferior is killed. + broadcaster.RemoveListener(listener, lldb.SBProcess.eBroadcastBitStateChanged) + + # The final judgement. :-) + self.assertTrue(self.state == 2, + "Both expected state changed events received") if __name__ == '__main__': From johnny.chen at apple.com Tue Dec 21 18:56:47 2010 From: johnny.chen at apple.com (Johnny Chen) Date: Wed, 22 Dec 2010 00:56:47 -0000 Subject: [Lldb-commits] [lldb] r122382 - /lldb/trunk/test/python_api/event/TestEvents.py Message-ID: <20101222005647.52B7C2A6C12C@llvm.org> Author: johnny Date: Tue Dec 21 18:56:47 2010 New Revision: 122382 URL: http://llvm.org/viewvc/llvm-project?rev=122382&view=rev Log: Fix some typos in the docstrings and also update the test method names. Modified: lldb/trunk/test/python_api/event/TestEvents.py Modified: lldb/trunk/test/python_api/event/TestEvents.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/python_api/event/TestEvents.py?rev=122382&r1=122381&r2=122382&view=diff ============================================================================== --- lldb/trunk/test/python_api/event/TestEvents.py (original) +++ lldb/trunk/test/python_api/event/TestEvents.py Tue Dec 21 18:56:47 2010 @@ -27,16 +27,16 @@ @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin") @python_api_test - def test_broadcast_event_with_dsym(self): - """Exercise SBBroadcaster.BroadcastEvent() API.""" + def test_add_listener_to_broadcaster_dsym(self): + """Exercise some SBBroadcaster APIs.""" self.buildDsym() - self.do_broadcast_event() + self.do_add_listener_to_broadcaster() @python_api_test - def test_broadcast_event_with_dwarf(self): - """Exercise SBBroadcaster.BroadcastEvent() API.""" + def test_add_listener_to_broadcaster_dwarf(self): + """Exercise some SBBroadcaster APIs.""" self.buildDwarf() - self.do_broadcast_event() + self.do_add_listener_to_broadcaster() def setUp(self): # Call super's setUp(). @@ -80,14 +80,11 @@ import threading class MyListeningThread(threading.Thread): def run(self): - #print "Running MyListeningThread:", self count = 0 # Let's only try at most 3 times to retrieve any kind of event. while not count > 3: if listener.WaitForEvent(5, event): #print "Got a valid event:", event - #print "Event type:", event.GetType() - #print "Event broadcaster:", event.GetBroadcaster().GetName() return count = count + 1 print "Timeout: listener.WaitForEvent" @@ -108,8 +105,8 @@ self.assertTrue(event.IsValid(), "My listening thread successfully received an event") - def do_broadcast_event(self): - """Get the broadcaster associated with the process and exercise BroadcastEvent API.""" + def do_add_listener_to_broadcaster(self): + """Get the broadcaster associated with the process and wait for broadcaster events.""" exe = os.path.join(os.getcwd(), "a.out") # Create a target by the debugger. @@ -163,11 +160,13 @@ # Let's only try at most 6 times to retrieve our events. count = 0 while True: - if listener.WaitForEvent(5, event): + if listener.WaitForEventForBroadcasterWithType(5, + broadcaster, + lldb.SBProcess.eBroadcastBitStateChanged, + event): stream = lldb.SBStream() event.GetDescription(stream) description = stream.GetData() - #print "Event data flavor:", event.GetDataFlavor() #print "Event description:", description match = pattern.search(description) if not match: From jmolenda at apple.com Tue Dec 21 20:02:45 2010 From: jmolenda at apple.com (Jason Molenda) Date: Wed, 22 Dec 2010 02:02:45 -0000 Subject: [Lldb-commits] [lldb] r122386 - in /lldb/trunk/source: Plugins/Process/Utility/RegisterContextLLDB.cpp Target/SectionLoadList.cpp Message-ID: <20101222020245.879012A6C12C@llvm.org> Author: jmolenda Date: Tue Dec 21 20:02:45 2010 New Revision: 122386 URL: http://llvm.org/viewvc/llvm-project?rev=122386&view=rev Log: RegisterContextLLDB.cpp (InitializeNonZerothFrame): If we get a 0 mid-stack, stop backtracing. SectionLoadList.cpp (ResolveLoadAddress): Don't assert on an out-of-range address, just return an invalid Address object. The unwinder may be passing in invalid addresses on the final stack frame and the assert is a problem. Modified: lldb/trunk/source/Plugins/Process/Utility/RegisterContextLLDB.cpp lldb/trunk/source/Target/SectionLoadList.cpp Modified: lldb/trunk/source/Plugins/Process/Utility/RegisterContextLLDB.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Utility/RegisterContextLLDB.cpp?rev=122386&r1=122385&r2=122386&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Process/Utility/RegisterContextLLDB.cpp (original) +++ lldb/trunk/source/Plugins/Process/Utility/RegisterContextLLDB.cpp Tue Dec 21 20:02:45 2010 @@ -210,6 +210,12 @@ m_frame_type = eNotAValidFrame; return; } + // A pc value of 0 up on the stack indicates we've hit the end of the stack + if (pc == 0) + { + m_frame_type = eNotAValidFrame; + return; + } m_thread.GetProcess().GetTarget().GetSectionLoadList().ResolveLoadAddress (pc, m_current_pc); // If we don't have a Module for some reason, we're not going to find symbol/function information - just Modified: lldb/trunk/source/Target/SectionLoadList.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/SectionLoadList.cpp?rev=122386&r1=122385&r2=122386&view=diff ============================================================================== --- lldb/trunk/source/Target/SectionLoadList.cpp (original) +++ lldb/trunk/source/Target/SectionLoadList.cpp Tue Dec 21 20:02:45 2010 @@ -164,13 +164,15 @@ { 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()) + if (load_addr >= pos->first) { - // We have found the top level section, now we need to find the - // deepest child section. - return pos->second->ResolveContainedAddress (offset, so_addr); + 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 pos->second->ResolveContainedAddress (offset, so_addr); + } } } so_addr.Clear(); From johnny.chen at apple.com Wed Dec 22 13:23:44 2010 From: johnny.chen at apple.com (Johnny Chen) Date: Wed, 22 Dec 2010 19:23:44 -0000 Subject: [Lldb-commits] [lldb] r122428 - /lldb/trunk/test/breakpoint_command/TestBreakpointCommand.py Message-ID: <20101222192344.81D992A6C12C@llvm.org> Author: johnny Date: Wed Dec 22 13:23:44 2010 New Revision: 122428 URL: http://llvm.org/viewvc/llvm-project?rev=122428&view=rev Log: Modify one assertion message. Modified: lldb/trunk/test/breakpoint_command/TestBreakpointCommand.py Modified: lldb/trunk/test/breakpoint_command/TestBreakpointCommand.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/breakpoint_command/TestBreakpointCommand.py?rev=122428&r1=122427&r2=122428&view=diff ============================================================================== --- lldb/trunk/test/breakpoint_command/TestBreakpointCommand.py (original) +++ lldb/trunk/test/breakpoint_command/TestBreakpointCommand.py Wed Dec 22 13:23:44 2010 @@ -79,7 +79,7 @@ # The 'output.txt' file should now exist. self.assertTrue(os.path.isfile("output.txt"), - "'output.txt' exists due breakpoint command for breakpoint 2.") + "'output.txt' exists due to breakpoint command for breakpoint 2.") # Read the output file produced by running the program. with open('output.txt', 'r') as f: From johnny.chen at apple.com Wed Dec 22 13:29:31 2010 From: johnny.chen at apple.com (Johnny Chen) Date: Wed, 22 Dec 2010 19:29:31 -0000 Subject: [Lldb-commits] [lldb] r122429 - /lldb/trunk/source/Core/Broadcaster.cpp Message-ID: <20101222192931.E4A4A2A6C12C@llvm.org> Author: johnny Date: Wed Dec 22 13:29:31 2010 New Revision: 122429 URL: http://llvm.org/viewvc/llvm-project?rev=122429&view=rev Log: Broadcaster::AddListener(): Bail out early if the passed in Listener pointer is NULL, instead of registering a NULL listener and to crash later. Modified: lldb/trunk/source/Core/Broadcaster.cpp Modified: lldb/trunk/source/Core/Broadcaster.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/Broadcaster.cpp?rev=122429&r1=122428&r2=122429&view=diff ============================================================================== --- lldb/trunk/source/Core/Broadcaster.cpp (original) +++ lldb/trunk/source/Core/Broadcaster.cpp Wed Dec 22 13:29:31 2010 @@ -102,6 +102,9 @@ uint32_t Broadcaster::AddListener (Listener* listener, uint32_t event_mask) { + if (listener == NULL) + return 0; + Mutex::Locker locker(m_listeners_mutex); collection::iterator pos, end = m_listeners.end(); From johnny.chen at apple.com Wed Dec 22 14:36:30 2010 From: johnny.chen at apple.com (Johnny Chen) Date: Wed, 22 Dec 2010 20:36:30 -0000 Subject: [Lldb-commits] [lldb] r122434 - /lldb/trunk/test/conditional_break/conditional_break.py Message-ID: <20101222203630.1C74C2A6C12C@llvm.org> Author: johnny Date: Wed Dec 22 14:36:29 2010 New Revision: 122434 URL: http://llvm.org/viewvc/llvm-project?rev=122434&view=rev Log: Simplify the breakpoint command function. Instead of fetching the command interpreter and run the "process continue" command, use the SBProcess.Continue() API. Modified: lldb/trunk/test/conditional_break/conditional_break.py Modified: lldb/trunk/test/conditional_break/conditional_break.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/conditional_break/conditional_break.py?rev=122434&r1=122433&r2=122434&view=diff ============================================================================== --- lldb/trunk/test/conditional_break/conditional_break.py (original) +++ lldb/trunk/test/conditional_break/conditional_break.py Wed Dec 22 14:36:29 2010 @@ -9,12 +9,6 @@ # Perform synchronous interaction with the debugger. dbg.SetAsync(False) - # Get the command interpreter. - ci = dbg.GetCommandInterpreter() - - # And the result object for ci interaction. - res = lldb.SBCommandReturnObject() - # Retrieve the target, process, and the only thread. target = dbg.GetSelectedTarget() process = target.GetProcess() @@ -34,7 +28,7 @@ pass else: #print >> sys.stdout, "Continuing..." - ci.HandleCommand("process continue", res) + process.Continue() return True From johnny.chen at apple.com Wed Dec 22 16:56:19 2010 From: johnny.chen at apple.com (Johnny Chen) Date: Wed, 22 Dec 2010 22:56:19 -0000 Subject: [Lldb-commits] [lldb] r122450 - in /lldb/trunk/test: breakpoint_conditions/TestBreakpointConditions.py breakpoint_ignore_count/TestBreakpointIgnoreCount.py python_api/event/TestEvents.py python_api/symbol-context/TestSymbolContext.py Message-ID: <20101222225619.E19182A6C12C@llvm.org> Author: johnny Date: Wed Dec 22 16:56:19 2010 New Revision: 122450 URL: http://llvm.org/viewvc/llvm-project?rev=122450&view=rev Log: No need to pass an empty string as an arg or as an env string to the SBTarget.LaunchProcess() API. Modified: lldb/trunk/test/breakpoint_conditions/TestBreakpointConditions.py lldb/trunk/test/breakpoint_ignore_count/TestBreakpointIgnoreCount.py lldb/trunk/test/python_api/event/TestEvents.py lldb/trunk/test/python_api/symbol-context/TestSymbolContext.py Modified: lldb/trunk/test/breakpoint_conditions/TestBreakpointConditions.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/breakpoint_conditions/TestBreakpointConditions.py?rev=122450&r1=122449&r2=122450&view=diff ============================================================================== --- lldb/trunk/test/breakpoint_conditions/TestBreakpointConditions.py (original) +++ lldb/trunk/test/breakpoint_conditions/TestBreakpointConditions.py Wed Dec 22 16:56:19 2010 @@ -139,7 +139,7 @@ startstr = 'val == 3') # Now launch the process, and do not stop at entry point. - self.process = target.LaunchProcess([''], [''], os.ctermid(), 0, False) + self.process = target.LaunchProcess([], [], os.ctermid(), 0, False) self.process = target.GetProcess() self.assertTrue(self.process.IsValid(), PROCESS_IS_VALID) Modified: lldb/trunk/test/breakpoint_ignore_count/TestBreakpointIgnoreCount.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/breakpoint_ignore_count/TestBreakpointIgnoreCount.py?rev=122450&r1=122449&r2=122450&view=diff ============================================================================== --- lldb/trunk/test/breakpoint_ignore_count/TestBreakpointIgnoreCount.py (original) +++ lldb/trunk/test/breakpoint_ignore_count/TestBreakpointIgnoreCount.py Wed Dec 22 16:56:19 2010 @@ -101,7 +101,7 @@ "SetIgnoreCount() works correctly") # Now launch the process, and do not stop at entry point. - self.process = target.LaunchProcess([''], [''], os.ctermid(), 0, False) + self.process = target.LaunchProcess([], [], os.ctermid(), 0, False) self.process = target.GetProcess() self.assertTrue(self.process.IsValid(), PROCESS_IS_VALID) Modified: lldb/trunk/test/python_api/event/TestEvents.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/python_api/event/TestEvents.py?rev=122450&r1=122449&r2=122450&view=diff ============================================================================== --- lldb/trunk/test/python_api/event/TestEvents.py (original) +++ lldb/trunk/test/python_api/event/TestEvents.py Wed Dec 22 16:56:19 2010 @@ -60,7 +60,7 @@ VALID_BREAKPOINT) # Now launch the process, and do not stop at entry point. - self.process = target.LaunchProcess([''], [''], os.ctermid(), 0, False) + self.process = target.LaunchProcess([], [], os.ctermid(), 0, False) self.process = target.GetProcess() self.assertTrue(self.process.IsValid(), PROCESS_IS_VALID) @@ -121,7 +121,7 @@ VALID_BREAKPOINT) # Now launch the process, and do not stop at the entry point. - self.process = target.LaunchProcess([''], [''], os.ctermid(), 0, False) + self.process = target.LaunchProcess([], [], os.ctermid(), 0, False) self.process = target.GetProcess() self.assertTrue(self.process.GetState() == lldb.eStateStopped, Modified: lldb/trunk/test/python_api/symbol-context/TestSymbolContext.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/python_api/symbol-context/TestSymbolContext.py?rev=122450&r1=122449&r2=122450&view=diff ============================================================================== --- lldb/trunk/test/python_api/symbol-context/TestSymbolContext.py (original) +++ lldb/trunk/test/python_api/symbol-context/TestSymbolContext.py Wed Dec 22 16:56:19 2010 @@ -47,7 +47,7 @@ VALID_BREAKPOINT) # Now launch the process, and do not stop at entry point. - self.process = target.LaunchProcess([''], [''], os.ctermid(), 0, False) + self.process = target.LaunchProcess([], [], os.ctermid(), 0, False) self.process = target.GetProcess() self.assertTrue(self.process.IsValid(), PROCESS_IS_VALID) From johnny.chen at apple.com Wed Dec 22 19:12:19 2010 From: johnny.chen at apple.com (Johnny Chen) Date: Thu, 23 Dec 2010 01:12:19 -0000 Subject: [Lldb-commits] [lldb] r122460 - in /lldb/trunk/test: lldbtest.py python_api/frame/ python_api/frame/Makefile python_api/frame/TestFrames.py python_api/frame/main.c Message-ID: <20101223011219.85ED32A6C12C@llvm.org> Author: johnny Date: Wed Dec 22 19:12:19 2010 New Revision: 122460 URL: http://llvm.org/viewvc/llvm-project?rev=122460&view=rev Log: Add a test case for the SBFrame APIs. In particular, it uses the frame API to get the argument values of the call stacks when stopped on the breakpoint. Radar has been filed for the expected failures: test failure: ./dotest.py -v -w -t -p TestFrames (argument values are wrong) Added: lldb/trunk/test/python_api/frame/ lldb/trunk/test/python_api/frame/Makefile lldb/trunk/test/python_api/frame/TestFrames.py lldb/trunk/test/python_api/frame/main.c Modified: lldb/trunk/test/lldbtest.py Modified: lldb/trunk/test/lldbtest.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/lldbtest.py?rev=122460&r1=122459&r2=122460&view=diff ============================================================================== --- lldb/trunk/test/lldbtest.py (original) +++ lldb/trunk/test/lldbtest.py Wed Dec 22 19:12:19 2010 @@ -133,6 +133,10 @@ PROCESS_KILLED = "Process is killed successfully" +PROCESS_EXITED = "Process exited successfully" + +PROCESS_STOPPED = "Process status should be stopped" + RUN_SUCCEEDED = "Process is launched successfully" RUN_COMPLETED = "Process exited successfully" @@ -155,8 +159,6 @@ STEP_OUT_SUCCEEDED = "Thread step-out succeeded" -PROCESS_STOPPED = "Process status should be stopped" - STOPPED_DUE_TO_BREAKPOINT = "Process should be stopped due to breakpoint" STOPPED_DUE_TO_BREAKPOINT_WITH_STOP_REASON_AS = "%s, %s" % ( Added: lldb/trunk/test/python_api/frame/Makefile URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/python_api/frame/Makefile?rev=122460&view=auto ============================================================================== --- lldb/trunk/test/python_api/frame/Makefile (added) +++ lldb/trunk/test/python_api/frame/Makefile Wed Dec 22 19:12:19 2010 @@ -0,0 +1,5 @@ +LEVEL = ../../make + +C_SOURCES := main.c + +include $(LEVEL)/Makefile.rules Added: lldb/trunk/test/python_api/frame/TestFrames.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/python_api/frame/TestFrames.py?rev=122460&view=auto ============================================================================== --- lldb/trunk/test/python_api/frame/TestFrames.py (added) +++ lldb/trunk/test/python_api/frame/TestFrames.py Wed Dec 22 19:12:19 2010 @@ -0,0 +1,118 @@ +""" +Use lldb Python SBFrame API to get the argument values of the call stacks. +""" + +import os, time +import re +import unittest2 +import lldb, lldbutil +from lldbtest import * + +class FrameAPITestCase(TestBase): + + mydir = os.path.join("python_api", "frame") + + @unittest2.expectedFailure + @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin") + @python_api_test + def test_get_arg_vals_for_call_stack_with_dsym(self): + """Exercise SBFrame.GetVariables() API to get argument vals.""" + self.buildDsym() + self.do_get_arg_vals() + + @unittest2.expectedFailure + @python_api_test + def test_get_arg_vals_for_call_stack_with_dwarf(self): + """Exercise SBFrame.GetVariables() API to get argument vals.""" + self.buildDwarf() + self.do_get_arg_vals() + + def do_get_arg_vals(self): + """Get argument vals for the call stack when stopped on a breakpoint.""" + exe = os.path.join(os.getcwd(), "a.out") + + # Create a target by the debugger. + target = self.dbg.CreateTarget(exe) + self.assertTrue(target.IsValid(), VALID_TARGET) + + # Now create a breakpoint on main.c by name 'c'. + breakpoint = target.BreakpointCreateByName('c', 'a.out') + #print "breakpoint:", breakpoint + self.assertTrue(breakpoint.IsValid() and + breakpoint.GetNumLocations() == 1, + VALID_BREAKPOINT) + + # Now launch the process, and do not stop at the entry point. + # Note that we don't assign the process to self.process as in other test + # cases. We want the inferior to run till it exits and there's no need + # for the testing framework to kill the inferior upon tearDown(). + process = target.LaunchProcess([], [], os.ctermid(), 0, False) + + process = target.GetProcess() + self.assertTrue(process.GetState() == lldb.eStateStopped, + PROCESS_STOPPED) + + # Keeps track of the number of times 'a' is called where it is within a + # depth of 3 of the 'c' leaf function. + callsOfA = 0 + + import StringIO + session = StringIO.StringIO() + while process.GetState() == lldb.eStateStopped: + thread = process.GetThreadAtIndex(0) + # Inspect at most 3 frames. + numFrames = min(3, thread.GetNumFrames()) + for i in range(numFrames): + frame = thread.GetFrameAtIndex(i) + print "frame:", frame + #print "frame.FindValue('val', lldb.eValueTypeVariableArgument)", frame.FindValue('val', lldb.eValueTypeVariableArgument).GetValue(frame) + #print "frame.FindValue('ch', lldb.eValueTypeVariableArgument)", frame.FindValue('ch', lldb.eValueTypeVariableArgument).GetValue(frame) + #print "frame.EvaluateExpression('val'):", frame.EvaluateExpression('val').GetValue(frame) + #print "frame.EvaluateExpression('ch'):", frame.EvaluateExpression('ch').GetValue(frame) + name = frame.GetFunction().GetName() + if name == 'a': + callsOfA = callsOfA + 1 + + # We'll inspect only the arguments for the current frame: + # + # arguments => True + # locals => False + # statics => False + # in_scope_only => True + valList = frame.GetVariables(True, False, False, True) + argList = [] + from lldbutil import lldb_iter + for val in lldb_iter(valList, 'GetSize', 'GetValueAtIndex'): + #self.DebugSBValue(frame, val) + argList.append("(%s)%s=%s" % (val.GetTypeName(), + val.GetName(), + val.GetValue(frame))) + print >> session, "%s(%s)" % (name, ", ".join(argList)) + + print >> session, "---" + process.Continue() + + # At this point, the inferior process should have exited. + self.assertTrue(process.GetState() == lldb.eStateExited, PROCESS_EXITED) + + # Expect to find 'a' on the call stacks two times. + self.assertTrue(callsOfA == 2, + "Expect to find 'a' on the call stacks two times") + # By design, the 'a' call frame has the following arg vals: + # o a((int)val=1, (char)ch='A') + # o a((int)val=3, (char)ch='A') + print "Full stack traces when stopped on the breakpoint 'c':" + print session.getvalue() + # rdar://problem/8801262 + # test failure: ./dotest.py -v -w -t -p TestFrames (argument values are wrong) + self.expect(session.getvalue(), "Argugment values displayed correctly", + exe=False, + substrs = ["a((int)val=1, (char)ch='A')", + "a((int)val=3, (char)ch='A')"]) + + +if __name__ == '__main__': + import atexit + lldb.SBDebugger.Initialize() + atexit.register(lambda: lldb.SBDebugger.Terminate()) + unittest2.main() Added: lldb/trunk/test/python_api/frame/main.c URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/python_api/frame/main.c?rev=122460&view=auto ============================================================================== --- lldb/trunk/test/python_api/frame/main.c (added) +++ lldb/trunk/test/python_api/frame/main.c Wed Dec 22 19:12:19 2010 @@ -0,0 +1,58 @@ +//===-- main.c --------------------------------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +#include + +// This simple program is to test the lldb Python API related to frames. + +int a(int, char); +int b(int, char); +int c(int, char); + +int a(int val, char ch) +{ + int my_val = val; + char my_ch = ch; + printf("a(val=%d, ch='%c')\n", val, ch); + if (val <= 1) + return b(++val, ++ch); + else if (val >= 3) + return c(++val, ++ch); + + return val; +} + +int b(int val, char ch) +{ + int my_val = val; + char my_ch = ch; + printf("b(val=%d, ch='%c')\n", val, ch); + return c(++val, ++ch); +} + +int c(int val, char ch) +{ + int my_val = val; + char my_ch = ch; + printf("c(val=%d, ch='%c')\n", val, ch); + return val + 3 + ch; +} + +int main (int argc, char const *argv[]) +{ + int A1 = a(1, 'A'); // a(1, 'A') -> b(2, 'B') -> c(3, 'C') + printf("a(1, 'A') returns %d\n", A1); + + int B2 = b(2, 'B'); // b(2, 'B') -> c(3, 'C') + printf("b(2, 'B') returns %d\n", B2); + + int A3 = a(3, 'A'); // a(3, 'A') -> c(4, 'B') + printf("a(3, 'A') returns %d\n", A3); + + return 0; +} From jingham at apple.com Wed Dec 22 20:17:54 2010 From: jingham at apple.com (Jim Ingham) Date: Thu, 23 Dec 2010 02:17:54 -0000 Subject: [Lldb-commits] [lldb] r122464 - /lldb/trunk/source/Commands/CommandObjectFrame.cpp Message-ID: <20101223021754.2EECE2A6C12C@llvm.org> Author: jingham Date: Wed Dec 22 20:17:54 2010 New Revision: 122464 URL: http://llvm.org/viewvc/llvm-project?rev=122464&view=rev Log: "frame variable" requires that the process be running and paused or there aren't any frames... So mark the command properly as such. Modified: lldb/trunk/source/Commands/CommandObjectFrame.cpp Modified: lldb/trunk/source/Commands/CommandObjectFrame.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectFrame.cpp?rev=122464&r1=122463&r2=122464&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectFrame.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectFrame.cpp Wed Dec 22 20:17:54 2010 @@ -405,7 +405,8 @@ "argument, local, file static and file global variables. " "Children of aggregate variables can be specified such as " "'var->child.x'.", - NULL) + NULL, + eFlagProcessMustBeLaunched | eFlagProcessMustBePaused) { CommandArgumentEntry arg; CommandArgumentData var_name_arg; From jingham at apple.com Wed Dec 22 20:29:54 2010 From: jingham at apple.com (Jim Ingham) Date: Thu, 23 Dec 2010 02:29:54 -0000 Subject: [Lldb-commits] [lldb] r122465 - /lldb/trunk/source/Core/ValueObject.cpp Message-ID: <20101223022954.2AA882A6C12C@llvm.org> Author: jingham Date: Wed Dec 22 20:29:54 2010 New Revision: 122465 URL: http://llvm.org/viewvc/llvm-project?rev=122465&view=rev Log: For the language check in GetObjectDescription, if we can't find a language runtime for the value we're looking at, BUT it IS at least a pointer, try the ObjCRuntime language. That's currently the only language runtime that has an object description method anyway... Modified: lldb/trunk/source/Core/ValueObject.cpp Modified: lldb/trunk/source/Core/ValueObject.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/ValueObject.cpp?rev=122465&r1=122464&r2=122465&view=diff ============================================================================== --- lldb/trunk/source/Core/ValueObject.cpp (original) +++ lldb/trunk/source/Core/ValueObject.cpp Wed Dec 22 20:29:54 2010 @@ -590,6 +590,18 @@ lldb::LanguageType language = GetObjectRuntimeLanguage(); LanguageRuntime *runtime = process->GetLanguageRuntime(language); + if (runtime == NULL) + { + // Aw, hell, if the things a pointer, let's try ObjC anyway... + clang_type_t opaque_qual_type = GetClangType(); + if (opaque_qual_type != NULL) + { + clang::QualType qual_type (clang::QualType::getFromOpaquePtr(opaque_qual_type).getNonReferenceType()); + if (qual_type->isAnyPointerType()) + runtime = process->GetLanguageRuntime(lldb::eLanguageTypeObjC); + } + } + if (runtime && runtime->GetObjectDescription(s, *this, exe_scope)) { m_object_desc_str.append (s.GetData()); From johnny.chen at apple.com Thu Dec 23 14:21:44 2010 From: johnny.chen at apple.com (Johnny Chen) Date: Thu, 23 Dec 2010 20:21:44 -0000 Subject: [Lldb-commits] [lldb] r122515 - in /lldb/trunk: lldb.xcodeproj/project.pbxproj source/Commands/CommandObjectVersion.cpp source/Commands/CommandObjectVersion.h source/Interpreter/CommandInterpreter.cpp test/help/TestHelp.py Message-ID: <20101223202144.B0D132A6C12D@llvm.org> Author: johnny Date: Thu Dec 23 14:21:44 2010 New Revision: 122515 URL: http://llvm.org/viewvc/llvm-project?rev=122515&view=rev Log: Add a simple command: 'version' to the command interpreter, and an accompanying test case test_help_version(). Added: lldb/trunk/source/Commands/CommandObjectVersion.cpp lldb/trunk/source/Commands/CommandObjectVersion.h Modified: lldb/trunk/lldb.xcodeproj/project.pbxproj lldb/trunk/source/Interpreter/CommandInterpreter.cpp lldb/trunk/test/help/TestHelp.py Modified: lldb/trunk/lldb.xcodeproj/project.pbxproj URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/lldb.xcodeproj/project.pbxproj?rev=122515&r1=122514&r2=122515&view=diff ============================================================================== --- lldb/trunk/lldb.xcodeproj/project.pbxproj (original) +++ lldb/trunk/lldb.xcodeproj/project.pbxproj Thu Dec 23 14:21:44 2010 @@ -377,6 +377,7 @@ AF68D2561255416E002FF25B /* RegisterContextLLDB.cpp in Sources */ = {isa = PBXBuildFile; fileRef = AF68D2541255416E002FF25B /* RegisterContextLLDB.cpp */; }; AF68D3311255A111002FF25B /* UnwindLLDB.cpp in Sources */ = {isa = PBXBuildFile; fileRef = AF68D32F1255A110002FF25B /* UnwindLLDB.cpp */; }; AF94005911C03F6500085DB9 /* SymbolVendor.cpp in Sources */ = {isa = PBXBuildFile; fileRef = AF94005711C03F6500085DB9 /* SymbolVendor.cpp */; }; + B296983712C2FB98002D92C3 /* CommandObjectVersion.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B296983412C2FB2B002D92C3 /* CommandObjectVersion.cpp */; }; /* End PBXBuildFile section */ /* Begin PBXContainerItemProxy section */ @@ -1081,6 +1082,8 @@ AF68D32F1255A110002FF25B /* UnwindLLDB.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = UnwindLLDB.cpp; path = Utility/UnwindLLDB.cpp; sourceTree = ""; }; AF68D3301255A110002FF25B /* UnwindLLDB.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = UnwindLLDB.h; path = Utility/UnwindLLDB.h; sourceTree = ""; }; AF94005711C03F6500085DB9 /* SymbolVendor.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = SymbolVendor.cpp; path = source/Symbol/SymbolVendor.cpp; sourceTree = ""; }; + B296983412C2FB2B002D92C3 /* CommandObjectVersion.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = CommandObjectVersion.cpp; path = source/Commands/CommandObjectVersion.cpp; sourceTree = ""; }; + B296983512C2FB2B002D92C3 /* CommandObjectVersion.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CommandObjectVersion.h; path = source/Commands/CommandObjectVersion.h; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -1840,6 +1843,8 @@ 26BC7D0D10F1B71D00F91463 /* Commands */ = { isa = PBXGroup; children = ( + B296983512C2FB2B002D92C3 /* CommandObjectVersion.h */, + B296983412C2FB2B002D92C3 /* CommandObjectVersion.cpp */, 4CA9637A11B6E99A00780E28 /* CommandObjectApropos.h */, 4CA9637911B6E99A00780E28 /* CommandObjectApropos.cpp */, 499F381E11A5B3F300F5CE02 /* CommandObjectArgs.h */, @@ -2358,7 +2363,6 @@ isa = PBXProject; buildConfigurationList = 1DEB91EF08733DB70010E9CD /* Build configuration list for PBXProject "lldb" */; compatibilityVersion = "Xcode 3.1"; - developmentRegion = English; hasScannedForEncodings = 1; knownRegions = ( en, @@ -2786,6 +2790,7 @@ 4CC2A149128C73ED001531C4 /* ThreadPlanTracer.cpp in Sources */, 266A42D6128E3FFB0090CF7C /* ClangNamespaceDecl.cpp in Sources */, 4C7CF7E61295E12B00B4FBB5 /* ThreadPlanCallUserExpression.cpp in Sources */, + B296983712C2FB98002D92C3 /* CommandObjectVersion.cpp in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; Added: lldb/trunk/source/Commands/CommandObjectVersion.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectVersion.cpp?rev=122515&view=auto ============================================================================== --- lldb/trunk/source/Commands/CommandObjectVersion.cpp (added) +++ lldb/trunk/source/Commands/CommandObjectVersion.cpp Thu Dec 23 14:21:44 2010 @@ -0,0 +1,48 @@ +//===-- CommandObjectVersion.cpp --------------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#include "CommandObjectVersion.h" + +// C Includes +// C++ Includes +// Other libraries and framework includes +// Project includes +#include "lldb/lldb-private.h" +#include "lldb/Interpreter/CommandInterpreter.h" +#include "lldb/Interpreter/CommandReturnObject.h" + +using namespace lldb; +using namespace lldb_private; + +//------------------------------------------------------------------------- +// CommandObjectVersion +//------------------------------------------------------------------------- + +CommandObjectVersion::CommandObjectVersion (CommandInterpreter &interpreter) : + CommandObject (interpreter, "version", "Show version of LLDB debugger.", "version") +{ +} + +CommandObjectVersion::~CommandObjectVersion () +{ +} + +bool +CommandObjectVersion::Execute +( + Args& args, + CommandReturnObject &result +) +{ + StreamString &output_stream = result.GetOutputStream(); + output_stream.Printf ("%s\n", lldb_private::GetVersion()); + result.SetStatus (eReturnStatusSuccessFinishResult); + return true; +} + Added: lldb/trunk/source/Commands/CommandObjectVersion.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectVersion.h?rev=122515&view=auto ============================================================================== --- lldb/trunk/source/Commands/CommandObjectVersion.h (added) +++ lldb/trunk/source/Commands/CommandObjectVersion.h Thu Dec 23 14:21:44 2010 @@ -0,0 +1,42 @@ +//===-- CommandObjectVersion.h ----------------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#ifndef liblldb_CommandObjectVersion_h_ +#define liblldb_CommandObjectVersion_h_ + +// C Includes +// C++ Includes +// Other libraries and framework includes +// Project includes +#include "lldb/Interpreter/CommandObject.h" + +namespace lldb_private { + +//------------------------------------------------------------------------- +// CommandObjectVersion +//------------------------------------------------------------------------- + +class CommandObjectVersion : public CommandObject +{ +public: + + CommandObjectVersion (CommandInterpreter &interpreter); + + virtual + ~CommandObjectVersion (); + + virtual bool + Execute (Args& args, + CommandReturnObject &result); + +}; + +} // namespace lldb_private + +#endif // liblldb_CommandObjectVersion_h_ Modified: lldb/trunk/source/Interpreter/CommandInterpreter.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Interpreter/CommandInterpreter.cpp?rev=122515&r1=122514&r2=122515&view=diff ============================================================================== --- lldb/trunk/source/Interpreter/CommandInterpreter.cpp (original) +++ lldb/trunk/source/Interpreter/CommandInterpreter.cpp Thu Dec 23 14:21:44 2010 @@ -36,6 +36,7 @@ #include "../Commands/CommandObjectSyntax.h" #include "../Commands/CommandObjectTarget.h" #include "../Commands/CommandObjectThread.h" +#include "../Commands/CommandObjectVersion.h" #include "lldb/Interpreter/Args.h" #include "lldb/Core/Debugger.h" @@ -168,6 +169,7 @@ m_command_dict["source"] = CommandObjectSP (new CommandObjectMultiwordSource (*this)); m_command_dict["target"] = CommandObjectSP (new CommandObjectMultiwordTarget (*this)); m_command_dict["thread"] = CommandObjectSP (new CommandObjectMultiwordThread (*this)); + m_command_dict["version"] = CommandObjectSP (new CommandObjectVersion (*this)); std::auto_ptr break_regex_cmd_ap(new CommandObjectRegexCommand (*this, Modified: lldb/trunk/test/help/TestHelp.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/help/TestHelp.py?rev=122515&r1=122514&r2=122515&view=diff ============================================================================== --- lldb/trunk/test/help/TestHelp.py (original) +++ lldb/trunk/test/help/TestHelp.py Thu Dec 23 14:21:44 2010 @@ -18,6 +18,13 @@ self.expect("help", startstr = 'The following is a list of built-in, permanent debugger commands') + def test_help_version(self): + """Test 'help version' and 'version' commands.""" + self.expect("help version", + substrs = ['Show version of LLDB debugger.']) + self.expect("version", + patterns = ['LLDB-[0-9]+']) + def test_help_should_not_hang_emacsshell(self): """Command 'settings set term-width 0' should not hang the help command.""" self.runCmd("settings set term-width 0") From johnny.chen at apple.com Thu Dec 23 17:26:05 2010 From: johnny.chen at apple.com (Johnny Chen) Date: Thu, 23 Dec 2010 23:26:05 -0000 Subject: [Lldb-commits] [lldb] r122525 - /lldb/trunk/test/namespace/TestNamespace.py Message-ID: <20101223232605.8115C2A6C12C@llvm.org> Author: johnny Date: Thu Dec 23 17:26:05 2010 New Revision: 122525 URL: http://llvm.org/viewvc/llvm-project?rev=122525&view=rev Log: Uncomment the two failed 'expression' commands regarding fully qualified namespace variables. And decorate the test cases as @expectedFailure. Modified: lldb/trunk/test/namespace/TestNamespace.py Modified: lldb/trunk/test/namespace/TestNamespace.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/namespace/TestNamespace.py?rev=122525&r1=122524&r2=122525&view=diff ============================================================================== --- lldb/trunk/test/namespace/TestNamespace.py (original) +++ lldb/trunk/test/namespace/TestNamespace.py Thu Dec 23 17:26:05 2010 @@ -11,16 +11,16 @@ mydir = "namespace" + # rdar://problem/8668674 + @unittest2.expectedFailure @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin") def test_with_dsym_and_run_command(self): """Test that anonymous and named namespace variables display correctly.""" self.buildDsym() self.namespace_variable_commands() - # rdar://problem/8659840 - # runCmd: frame variable -c -G i - # runCmd failed! - # error: can't find global variable 'i' + # rdar://problem/8668674 + @unittest2.expectedFailure def test_with_dwarf_and_run_command(self): """Test that anonymous and named namespace variables display correctly.""" self.buildDwarf() @@ -81,24 +81,29 @@ self.runCmd("frame variable &i") # 'frame variable' with fully qualified name 'A::B::j' should work. - self.expect("frame variable 'A::B::j", VARIABLES_DISPLAYED_CORRECTLY, + self.expect("frame variable A::B::j", VARIABLES_DISPLAYED_CORRECTLY, startstr = '(int) A::B::j = 4') # So should the anonymous namespace case. - self.expect("frame variable '(anonymous namespace)::i", VARIABLES_DISPLAYED_CORRECTLY, + self.expect("frame variable '(anonymous namespace)::i'", VARIABLES_DISPLAYED_CORRECTLY, startstr = '(int) (anonymous namespace)::i = 3') # rdar://problem/8660275 # test/namespace: 'expression -- i+j' not working + # This has been fixed. self.expect("expression -- i + j", startstr = "(int) $0 = 7") # (int) $0 = 7 + self.runCmd("expression -- i") + self.runCmd("expression -- j") + # rdar://problem/8668674 # expression command with fully qualified namespace for a variable does not work - #self.runCmd("expression -- '(anonymous namespace)::i'") - # - #self.runCmd("expression -- 'A::B::j'") + self.expect("expression -- '(anonymous namespace)::i'", VARIABLES_DISPLAYED_CORRECTLY, + substrs = [" = 3"]) + self.expect("expression -- 'A::B::j'", VARIABLES_DISPLAYED_CORRECTLY, + substrs = [" = 4"]) if __name__ == '__main__':