From benny.kra at googlemail.com Mon Jun 21 09:34:03 2010 From: benny.kra at googlemail.com (Benjamin Kramer) Date: Mon, 21 Jun 2010 14:34:03 -0000 Subject: [Lldb-commits] [lldb] r106416 - /lldb/trunk/source/Core/Error.cpp Message-ID: <20100621143403.B27462A6C12C@llvm.org> Author: d0k Date: Mon Jun 21 09:34:03 2010 New Revision: 106416 URL: http://llvm.org/viewvc/llvm-project?rev=106416&view=rev Log: Don't snprintf directly into a std::string, it's undefined behavior per C++03. This also fixes a bug where we were trying to copy m_string into itself via a format string. The pointer was invalidated by m_string.resize and lldb (sometimes) crashed inside vsnprintf. Modified: lldb/trunk/source/Core/Error.cpp Modified: lldb/trunk/source/Core/Error.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/Error.cpp?rev=106416&r1=106415&r2=106416&view=diff ============================================================================== --- lldb/trunk/source/Core/Error.cpp (original) +++ lldb/trunk/source/Core/Error.cpp Mon Jun 21 09:34:03 2010 @@ -15,6 +15,7 @@ // Project includes #include "lldb/Core/Error.h" #include "lldb/Core/Log.h" +#include "llvm/ADT/SmallVector.h" #include #include #include @@ -327,27 +328,23 @@ SetErrorToGenericError(); // Try and fit our error into a 1024 byte buffer first... - m_string.resize(1024); + llvm::SmallVector buf; + buf.resize(1024); // Copy in case our first call to vsnprintf doesn't fit into our // allocated buffer above va_list copy_args; va_copy (copy_args, args); - int length = ::vsnprintf (&m_string[0], m_string.size(), format, args); - if (length < m_string.size()) - { - // The error formatted string fit into our buffer, just chop it down - // to size - m_string.erase (length); - } - else + int length = ::vsnprintf (buf.data(), buf.size(), format, args); + if (length >= buf.size()) { // The error formatted string didn't fit into our buffer, resize it // to the exact needed size, and retry - m_string.resize(length + 1); - length = ::vsnprintf (&m_string[0], m_string.size(), format, copy_args); + buf.resize(length + 1); + length = ::vsnprintf (buf.data(), buf.size(), format, copy_args); va_end (copy_args); - assert (length < m_string.size()); + assert (length < buf.size()); } + m_string.assign(buf.data(), length); va_end (args); return length; } From benny.kra at googlemail.com Mon Jun 21 09:39:40 2010 From: benny.kra at googlemail.com (Benjamin Kramer) Date: Mon, 21 Jun 2010 14:39:40 -0000 Subject: [Lldb-commits] [lldb] r106418 - /lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.cpp Message-ID: <20100621143940.9A0212A6C12D@llvm.org> Author: d0k Date: Mon Jun 21 09:39:40 2010 New Revision: 106418 URL: http://llvm.org/viewvc/llvm-project?rev=106418&view=rev Log: Initialize member so GDBRemoteRegisterContext::ReadRegisterBytes doesn't rely on an unitialized variable. valgrind_errors -= 1; Modified: lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.cpp Modified: lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.cpp?rev=106418&r1=106417&r2=106418&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.cpp (original) +++ lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.cpp Mon Jun 21 09:39:40 2010 @@ -39,6 +39,7 @@ RegisterContext (thread, frame), m_reg_info (reg_info), m_reg_valid (), + m_reg_valid_stop_id (), m_reg_data (), m_read_all_at_once (read_all_at_once) { From benny.kra at googlemail.com Mon Jun 21 09:36:20 2010 From: benny.kra at googlemail.com (Benjamin Kramer) Date: Mon, 21 Jun 2010 14:36:20 -0000 Subject: [Lldb-commits] [lldb] r106417 - /lldb/trunk/source/Core/FileSpec.cpp Message-ID: <20100621143620.5DFE42A6C12C@llvm.org> Author: d0k Date: Mon Jun 21 09:36:20 2010 New Revision: 106417 URL: http://llvm.org/viewvc/llvm-project?rev=106417&view=rev Log: Return false from FileSpec::GetPath early instead of making the return value dependent on the last byte of the buffer, which could be unitialized. Modified: lldb/trunk/source/Core/FileSpec.cpp Modified: lldb/trunk/source/Core/FileSpec.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/FileSpec.cpp?rev=106417&r1=106416&r2=106417&view=diff ============================================================================== --- lldb/trunk/source/Core/FileSpec.cpp (original) +++ lldb/trunk/source/Core/FileSpec.cpp Mon Jun 21 09:36:20 2010 @@ -442,6 +442,10 @@ { strncpy (path, filename, max_path_length); } + else + { + return false; + } // Any code paths that reach here assume that strncpy, or a similar function was called // where any remaining bytes will be filled with NULLs and that the string won't be From clattner at apple.com Mon Jun 21 11:15:34 2010 From: clattner at apple.com (Chris Lattner) Date: Mon, 21 Jun 2010 09:15:34 -0700 Subject: [Lldb-commits] [lldb] r106416 - /lldb/trunk/source/Core/Error.cpp In-Reply-To: <20100621143403.B27462A6C12C@llvm.org> References: <20100621143403.B27462A6C12C@llvm.org> Message-ID: <211303C0-F038-4938-BDC1-E81A46733153@apple.com> On Jun 21, 2010, at 7:34 AM, Benjamin Kramer wrote: > Author: d0k > Date: Mon Jun 21 09:34:03 2010 > New Revision: 106416 > > URL: http://llvm.org/viewvc/llvm-project?rev=106416&view=rev > Log: > Don't snprintf directly into a std::string, it's undefined behavior per C++03. > > This also fixes a bug where we were trying to copy m_string into itself > via a format string. The pointer was invalidated by m_string.resize and > lldb (sometimes) crashed inside vsnprintf. I haven't looked at the surrounding code, but would it be better to change this method to take a Twine? -Chris > > Modified: > lldb/trunk/source/Core/Error.cpp > > Modified: lldb/trunk/source/Core/Error.cpp > URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/Error.cpp?rev=106416&r1=106415&r2=106416&view=diff > ============================================================================== > --- lldb/trunk/source/Core/Error.cpp (original) > +++ lldb/trunk/source/Core/Error.cpp Mon Jun 21 09:34:03 2010 > @@ -15,6 +15,7 @@ > // Project includes > #include "lldb/Core/Error.h" > #include "lldb/Core/Log.h" > +#include "llvm/ADT/SmallVector.h" > #include > #include > #include > @@ -327,27 +328,23 @@ > SetErrorToGenericError(); > > // Try and fit our error into a 1024 byte buffer first... > - m_string.resize(1024); > + llvm::SmallVector buf; > + buf.resize(1024); > // Copy in case our first call to vsnprintf doesn't fit into our > // allocated buffer above > va_list copy_args; > va_copy (copy_args, args); > - int length = ::vsnprintf (&m_string[0], m_string.size(), format, args); > - if (length < m_string.size()) > - { > - // The error formatted string fit into our buffer, just chop it down > - // to size > - m_string.erase (length); > - } > - else > + int length = ::vsnprintf (buf.data(), buf.size(), format, args); > + if (length >= buf.size()) > { > // The error formatted string didn't fit into our buffer, resize it > // to the exact needed size, and retry > - m_string.resize(length + 1); > - length = ::vsnprintf (&m_string[0], m_string.size(), format, copy_args); > + buf.resize(length + 1); > + length = ::vsnprintf (buf.data(), buf.size(), format, copy_args); > va_end (copy_args); > - assert (length < m_string.size()); > + assert (length < buf.size()); > } > + m_string.assign(buf.data(), length); > va_end (args); > return length; > } > > > _______________________________________________ > lldb-commits mailing list > lldb-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/lldb-commits From benny.kra at googlemail.com Mon Jun 21 11:54:10 2010 From: benny.kra at googlemail.com (Benjamin Kramer) Date: Mon, 21 Jun 2010 18:54:10 +0200 Subject: [Lldb-commits] [lldb] r106416 - /lldb/trunk/source/Core/Error.cpp In-Reply-To: <211303C0-F038-4938-BDC1-E81A46733153@apple.com> References: <20100621143403.B27462A6C12C@llvm.org> <211303C0-F038-4938-BDC1-E81A46733153@apple.com> Message-ID: <96BFFA07-21A3-4FC6-AD64-EC51C4112CAC@gmail.com> On 21.06.2010, at 18:15, Chris Lattner wrote: >> >> Don't snprintf directly into a std::string, it's undefined behavior per C++03. >> >> This also fixes a bug where we were trying to copy m_string into itself >> via a format string. The pointer was invalidated by m_string.resize and >> lldb (sometimes) crashed inside vsnprintf. > > I haven't looked at the surrounding code, but would it be better to change this method to take a Twine? > > -Chris That would be nice but this method is used all over the place in lldb and I don't feel like doing big refactorings without a test suite ? From clattner at apple.com Mon Jun 21 12:42:41 2010 From: clattner at apple.com (Chris Lattner) Date: Mon, 21 Jun 2010 10:42:41 -0700 Subject: [Lldb-commits] [lldb] r106416 - /lldb/trunk/source/Core/Error.cpp In-Reply-To: <96BFFA07-21A3-4FC6-AD64-EC51C4112CAC@gmail.com> References: <20100621143403.B27462A6C12C@llvm.org> <211303C0-F038-4938-BDC1-E81A46733153@apple.com> <96BFFA07-21A3-4FC6-AD64-EC51C4112CAC@gmail.com> Message-ID: <2E35AC8D-D307-4CD0-8206-3ED5CB00B654@apple.com> >> >> I haven't looked at the surrounding code, but would it be better to change this method to take a Twine? >> >> -Chris > > That would be nice but this method is used all over the place in lldb and I don't feel like doing big > refactorings without a test suite ? Fair enough! From benny.kra at googlemail.com Mon Jun 21 14:26:54 2010 From: benny.kra at googlemail.com (Benjamin Kramer) Date: Mon, 21 Jun 2010 19:26:54 -0000 Subject: [Lldb-commits] [lldb] r106450 - in /lldb/trunk: include/lldb/Core/Address.h include/lldb/Core/AddressRange.h include/lldb/Symbol/Symbol.h source/Core/Address.cpp source/Core/AddressRange.cpp source/Symbol/Symbol.cpp Message-ID: <20100621192654.606CF2A6C12C@llvm.org> Author: d0k Date: Mon Jun 21 14:26:54 2010 New Revision: 106450 URL: http://llvm.org/viewvc/llvm-project?rev=106450&view=rev Log: Move a bunch of trivial methods into the header. These compile down to 1-2 instructions so it's really profitable to inline them. Modified: lldb/trunk/include/lldb/Core/Address.h lldb/trunk/include/lldb/Core/AddressRange.h lldb/trunk/include/lldb/Symbol/Symbol.h lldb/trunk/source/Core/Address.cpp lldb/trunk/source/Core/AddressRange.cpp lldb/trunk/source/Symbol/Symbol.cpp Modified: lldb/trunk/include/lldb/Core/Address.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/Address.h?rev=106450&r1=106449&r2=106450&view=diff ============================================================================== --- lldb/trunk/include/lldb/Core/Address.h (original) +++ lldb/trunk/include/lldb/Core/Address.h Mon Jun 21 14:26:54 2010 @@ -133,11 +133,6 @@ Address (lldb::addr_t file_addr, const SectionList * section_list); //------------------------------------------------------------------ - /// Destructor. - //------------------------------------------------------------------ - ~Address (); - - //------------------------------------------------------------------ /// Assignment operator. /// /// Copies the address value from another Address object \a rhs @@ -283,7 +278,7 @@ /// doesn't contain a valid offset. //------------------------------------------------------------------ lldb::addr_t - GetOffset () const; + GetOffset () const { return m_offset; } //------------------------------------------------------------------ /// Check if an address is section offset. @@ -362,7 +357,7 @@ /// offset in, or NULL if this address is absolute. //------------------------------------------------------------------ const Section* - GetSection() const; + GetSection() const { return m_section; } //------------------------------------------------------------------ /// Set accessor for the offset. @@ -385,7 +380,7 @@ /// any section. //------------------------------------------------------------------ void - SetSection (const Section* section); + SetSection (const Section* section) { m_section = section; } //------------------------------------------------------------------ /// @copydoc SymbolContextScope::CalculateSymbolContext(SymbolContext*) Modified: lldb/trunk/include/lldb/Core/AddressRange.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/AddressRange.h?rev=106450&r1=106449&r2=106450&view=diff ============================================================================== --- lldb/trunk/include/lldb/Core/AddressRange.h (original) +++ lldb/trunk/include/lldb/Core/AddressRange.h Mon Jun 21 14:26:54 2010 @@ -227,7 +227,7 @@ /// A reference to the base address object. //------------------------------------------------------------------ Address & - GetBaseAddress(); + GetBaseAddress() { return m_base_addr; } //------------------------------------------------------------------ /// Get const accessor for the base address of the range. @@ -236,7 +236,7 @@ /// A const reference to the base address object. //------------------------------------------------------------------ const Address & - GetBaseAddress() const; + GetBaseAddress() const { return m_base_addr; } //------------------------------------------------------------------ /// Get accessor for the byte size of this range. @@ -245,7 +245,7 @@ /// The size in bytes of this address range. //------------------------------------------------------------------ lldb::addr_t - GetByteSize () const; + GetByteSize () const { return m_byte_size; } //------------------------------------------------------------------ /// Get the memory cost of this object. @@ -254,7 +254,11 @@ /// The number of bytes that this object occupies in memory. //------------------------------------------------------------------ size_t - MemorySize () const; + MemorySize () const { + // Noting special for the memory size of a single AddressRange object, + // it is just the size of itself. + return sizeof(AddressRange); + } //------------------------------------------------------------------ /// Set accessor for the byte size of this range. @@ -263,7 +267,7 @@ /// The new size in bytes of this address range. //------------------------------------------------------------------ void - SetByteSize (lldb::addr_t byte_size); + SetByteSize (lldb::addr_t byte_size) { m_byte_size = byte_size; } protected: //------------------------------------------------------------------ Modified: lldb/trunk/include/lldb/Symbol/Symbol.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Symbol/Symbol.h?rev=106450&r1=106449&r2=106450&view=diff ============================================================================== --- lldb/trunk/include/lldb/Symbol/Symbol.h (original) +++ lldb/trunk/include/lldb/Symbol/Symbol.h Mon Jun 21 14:26:54 2010 @@ -68,88 +68,88 @@ GetAddressRangePtr () const; AddressRange & - GetAddressRangeRef(); + GetAddressRangeRef() { return m_addr_range; } const AddressRange & - GetAddressRangeRef() const; + GetAddressRangeRef() const { return m_addr_range; } Mangled& - GetMangled (); + GetMangled () { return m_mangled; } const Mangled& - GetMangled () const; + GetMangled () const { return m_mangled; } bool - GetSizeIsSibling () const; + GetSizeIsSibling () const { return m_size_is_sibling; } bool - GetSizeIsSynthesized() const; + GetSizeIsSynthesized() const { return m_size_is_synthesized; } uint32_t GetSiblingIndex () const; uint32_t - GetByteSize () const; + GetByteSize () const { return m_addr_range.GetByteSize(); } lldb::SymbolType - GetType () const; + GetType () const { return m_type; } void - SetType (lldb::SymbolType type); + SetType (lldb::SymbolType type) { m_type = type; } const char * GetTypeAsString () const; uint32_t - GetFlags () const; + GetFlags () const { return m_flags; } void - SetFlags (uint32_t flags); + SetFlags (uint32_t flags) { m_flags = flags; } Function * GetFunction (); Address & - GetValue (); + GetValue () { return m_addr_range.GetBaseAddress(); } const Address & - GetValue () const; + GetValue () const { return m_addr_range.GetBaseAddress(); } bool - IsSynthetic () const; + IsSynthetic () const { return m_is_synthetic; } void - SetIsSynthetic (bool b); + SetIsSynthetic (bool b) { m_is_synthetic = b; } void - SetSizeIsSynthesized(bool b); + SetSizeIsSynthesized(bool b) { m_size_is_synthesized = b; } bool - IsDebug () const; + IsDebug () const { return m_is_debug; } void - SetDebug (bool b); + SetDebug (bool b) { m_is_debug = b; } bool - IsExternal () const; + IsExternal () const { return m_is_external; } void - SetExternal (bool b); + SetExternal (bool b) { m_is_external = b; } bool IsTrampoline () const; void - SetByteSize (uint32_t size); + SetByteSize (uint32_t size) { m_addr_range.SetByteSize(size); } void - SetSizeIsSibling (bool b); + SetSizeIsSibling (bool b) { m_size_is_sibling = b; } void - SetValue (Address &value); + SetValue (Address &value) { m_addr_range.GetBaseAddress() = value; } void - SetValue (const AddressRange &range); + SetValue (const AddressRange &range) { m_addr_range = range; } void SetValue (lldb::addr_t value); Modified: lldb/trunk/source/Core/Address.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/Address.cpp?rev=106450&r1=106449&r2=106450&view=diff ============================================================================== --- lldb/trunk/source/Core/Address.cpp (original) +++ lldb/trunk/source/Core/Address.cpp Mon Jun 21 14:26:54 2010 @@ -247,11 +247,6 @@ ResolveAddressUsingFileSections(address, sections); } -Address::~Address () -{ -} - - const Address& Address::operator= (const Address& rhs) { @@ -321,13 +316,6 @@ return NULL; } -const Section* -Address::GetSection () const -{ - return m_section; -} - - //addr_t //Address::Address() const //{ @@ -381,12 +369,6 @@ return m_offset; } -addr_t -Address::GetOffset () const -{ - return m_offset; -} - bool Address::SetOffset (addr_t offset) { @@ -396,12 +378,6 @@ } void -Address::SetSection (const Section* section) -{ - m_section = section; -} - -void Address::Clear() { m_section = NULL; Modified: lldb/trunk/source/Core/AddressRange.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/AddressRange.cpp?rev=106450&r1=106449&r2=106450&view=diff ============================================================================== --- lldb/trunk/source/Core/AddressRange.cpp (original) +++ lldb/trunk/source/Core/AddressRange.cpp Mon Jun 21 14:26:54 2010 @@ -42,30 +42,6 @@ { } -Address & -AddressRange::GetBaseAddress() -{ - return m_base_addr; -} - -const Address & -AddressRange::GetBaseAddress() const -{ - return m_base_addr; -} - -addr_t -AddressRange::GetByteSize() const -{ - return m_byte_size; -} - -void -AddressRange::SetByteSize(addr_t byte_size) -{ - m_byte_size = byte_size; -} - //bool //AddressRange::Contains (const Address &addr) const //{ @@ -204,14 +180,6 @@ { s->Printf("%.*p: AddressRange section = %*p, offset = 0x%16.16llx, byte_size = 0x%16.16llx\n", (int)sizeof(void*) * 2, this, (int)sizeof(void*) * 2, m_base_addr.GetSection(), m_base_addr.GetOffset(), GetByteSize()); } - -size_t -AddressRange::MemorySize () const -{ - // Noting special for the memory size of a single AddressRange object, - // it is just the size of itself. - return sizeof(AddressRange); -} // //bool //lldb::operator== (const AddressRange& lhs, const AddressRange& rhs) Modified: lldb/trunk/source/Symbol/Symbol.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/Symbol.cpp?rev=106450&r1=106449&r2=106450&view=diff ============================================================================== --- lldb/trunk/source/Symbol/Symbol.cpp (original) +++ lldb/trunk/source/Symbol/Symbol.cpp Mon Jun 21 14:26:54 2010 @@ -139,18 +139,6 @@ return *this; } -AddressRange & -Symbol::GetAddressRangeRef() -{ - return m_addr_range; -} - -const AddressRange & -Symbol::GetAddressRangeRef() const -{ - return m_addr_range; -} - AddressRange * Symbol::GetAddressRangePtr() { @@ -167,115 +155,18 @@ return NULL; } -bool -Symbol::GetSizeIsSibling() const -{ - return m_size_is_sibling; -} - -bool -Symbol::GetSizeIsSynthesized() const -{ - return m_size_is_synthesized; -} - uint32_t Symbol::GetSiblingIndex() const { return m_size_is_sibling ? m_addr_range.GetByteSize() : 0; } -uint32_t -Symbol::GetFlags() const -{ - return m_flags; -} - -void -Symbol::SetFlags (uint32_t flags) -{ - m_flags = flags; -} - -SymbolType -Symbol::GetType() const -{ - return m_type; -} - -void -Symbol::SetType(SymbolType type) -{ - m_type = type; -} - -bool -Symbol::IsSynthetic () const -{ - return m_is_synthetic; -} - -void -Symbol::SetIsSynthetic (bool b) -{ - m_is_synthetic = b; -} - -void -Symbol::SetSizeIsSynthesized(bool b) -{ - m_size_is_synthesized = b; -} - - -bool -Symbol::IsDebug() const -{ - return m_is_debug; -} - -void -Symbol::SetDebug (bool b) -{ - m_is_debug = b; -} - -bool -Symbol::IsExternal() const -{ - return m_is_external; -} - -void -Symbol::SetExternal(bool b) -{ - m_is_external = b; -} - bool Symbol::IsTrampoline () const { return m_type == eSymbolTypeTrampoline; } -uint32_t -Symbol::GetByteSize() const -{ - return m_addr_range.GetByteSize(); -} - -void -Symbol::SetByteSize (uint32_t size) -{ - m_addr_range.SetByteSize(size); -} - -void -Symbol::SetSizeIsSibling (bool b) -{ - m_size_is_sibling = b; -} - void Symbol::Dump(Stream *s, Process *process, uint32_t index) const { @@ -322,36 +213,6 @@ } } -const Mangled& -Symbol::GetMangled() const -{ - return m_mangled; -} - -Mangled& -Symbol::GetMangled() -{ - return m_mangled; -} - -Address & -Symbol::GetValue() -{ - return m_addr_range.GetBaseAddress(); -} - -const Address & -Symbol::GetValue() const -{ - return m_addr_range.GetBaseAddress(); -} - -void -Symbol::SetValue (Address &value) -{ - m_addr_range.GetBaseAddress() = value; -} - Function * Symbol::GetFunction () { @@ -397,13 +258,6 @@ } void -Symbol::SetValue (const AddressRange &range) -{ - m_addr_range = range; -} - - -void Symbol::SetValue(addr_t value) { m_addr_range.GetBaseAddress().SetSection(NULL); From gclayton at apple.com Mon Jun 21 16:49:04 2010 From: gclayton at apple.com (Greg Clayton) Date: Mon, 21 Jun 2010 14:49:04 -0700 Subject: [Lldb-commits] [lldb] r106450 - in /lldb/trunk: include/lldb/Core/Address.h include/lldb/Core/AddressRange.h include/lldb/Symbol/Symbol.h source/Core/Address.cpp source/Core/AddressRange.cpp source/Symbol/Symbol.cpp In-Reply-To: <20100621192654.606CF2A6C12C@llvm.org> References: <20100621192654.606CF2A6C12C@llvm.org> Message-ID: Thanks Benjamin, There should be plenty more of these to go around. A little background to explain why: we used to export all classes that were in lldb_private and gcc (on MacOSX at least) wasn't exporting inlined functions, so we tended to put a lot of the simple accessor functions into the cpp files. Now we only export the lldb::SB* functions so we are free to now inlined as much as we want in the classes in the lldb_private namespace. Feel free to make more similar changes to any classes in the lldb_private namespace, but not in the lldb namespace. Greg Clayton On Jun 21, 2010, at 12:26 PM, Benjamin Kramer wrote: > Author: d0k > Date: Mon Jun 21 14:26:54 2010 > New Revision: 106450 > > URL: http://llvm.org/viewvc/llvm-project?rev=106450&view=rev > Log: > Move a bunch of trivial methods into the header. These compile down to 1-2 > instructions so it's really profitable to inline them. > > Modified: > lldb/trunk/include/lldb/Core/Address.h > lldb/trunk/include/lldb/Core/AddressRange.h > lldb/trunk/include/lldb/Symbol/Symbol.h > lldb/trunk/source/Core/Address.cpp > lldb/trunk/source/Core/AddressRange.cpp > lldb/trunk/source/Symbol/Symbol.cpp > > Modified: lldb/trunk/include/lldb/Core/Address.h > URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/Address.h?rev=106450&r1=106449&r2=106450&view=diff > ============================================================================== > --- lldb/trunk/include/lldb/Core/Address.h (original) > +++ lldb/trunk/include/lldb/Core/Address.h Mon Jun 21 14:26:54 2010 > @@ -133,11 +133,6 @@ > Address (lldb::addr_t file_addr, const SectionList * section_list); > > //------------------------------------------------------------------ > - /// Destructor. > - //------------------------------------------------------------------ > - ~Address (); > - > - //------------------------------------------------------------------ > /// Assignment operator. > /// > /// Copies the address value from another Address object \a rhs > @@ -283,7 +278,7 @@ > /// doesn't contain a valid offset. > //------------------------------------------------------------------ > lldb::addr_t > - GetOffset () const; > + GetOffset () const { return m_offset; } > > //------------------------------------------------------------------ > /// Check if an address is section offset. > @@ -362,7 +357,7 @@ > /// offset in, or NULL if this address is absolute. > //------------------------------------------------------------------ > const Section* > - GetSection() const; > + GetSection() const { return m_section; } > > //------------------------------------------------------------------ > /// Set accessor for the offset. > @@ -385,7 +380,7 @@ > /// any section. > //------------------------------------------------------------------ > void > - SetSection (const Section* section); > + SetSection (const Section* section) { m_section = section; } > > //------------------------------------------------------------------ > /// @copydoc SymbolContextScope::CalculateSymbolContext(SymbolContext*) > > Modified: lldb/trunk/include/lldb/Core/AddressRange.h > URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/AddressRange.h?rev=106450&r1=106449&r2=106450&view=diff > ============================================================================== > --- lldb/trunk/include/lldb/Core/AddressRange.h (original) > +++ lldb/trunk/include/lldb/Core/AddressRange.h Mon Jun 21 14:26:54 2010 > @@ -227,7 +227,7 @@ > /// A reference to the base address object. > //------------------------------------------------------------------ > Address & > - GetBaseAddress(); > + GetBaseAddress() { return m_base_addr; } > > //------------------------------------------------------------------ > /// Get const accessor for the base address of the range. > @@ -236,7 +236,7 @@ > /// A const reference to the base address object. > //------------------------------------------------------------------ > const Address & > - GetBaseAddress() const; > + GetBaseAddress() const { return m_base_addr; } > > //------------------------------------------------------------------ > /// Get accessor for the byte size of this range. > @@ -245,7 +245,7 @@ > /// The size in bytes of this address range. > //------------------------------------------------------------------ > lldb::addr_t > - GetByteSize () const; > + GetByteSize () const { return m_byte_size; } > > //------------------------------------------------------------------ > /// Get the memory cost of this object. > @@ -254,7 +254,11 @@ > /// The number of bytes that this object occupies in memory. > //------------------------------------------------------------------ > size_t > - MemorySize () const; > + MemorySize () const { > + // Noting special for the memory size of a single AddressRange object, > + // it is just the size of itself. > + return sizeof(AddressRange); > + } > > //------------------------------------------------------------------ > /// Set accessor for the byte size of this range. > @@ -263,7 +267,7 @@ > /// The new size in bytes of this address range. > //------------------------------------------------------------------ > void > - SetByteSize (lldb::addr_t byte_size); > + SetByteSize (lldb::addr_t byte_size) { m_byte_size = byte_size; } > > protected: > //------------------------------------------------------------------ > > Modified: lldb/trunk/include/lldb/Symbol/Symbol.h > URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Symbol/Symbol.h?rev=106450&r1=106449&r2=106450&view=diff > ============================================================================== > --- lldb/trunk/include/lldb/Symbol/Symbol.h (original) > +++ lldb/trunk/include/lldb/Symbol/Symbol.h Mon Jun 21 14:26:54 2010 > @@ -68,88 +68,88 @@ > GetAddressRangePtr () const; > > AddressRange & > - GetAddressRangeRef(); > + GetAddressRangeRef() { return m_addr_range; } > > const AddressRange & > - GetAddressRangeRef() const; > + GetAddressRangeRef() const { return m_addr_range; } > > Mangled& > - GetMangled (); > + GetMangled () { return m_mangled; } > > const Mangled& > - GetMangled () const; > + GetMangled () const { return m_mangled; } > > bool > - GetSizeIsSibling () const; > + GetSizeIsSibling () const { return m_size_is_sibling; } > > bool > - GetSizeIsSynthesized() const; > + GetSizeIsSynthesized() const { return m_size_is_synthesized; } > > uint32_t > GetSiblingIndex () const; > > uint32_t > - GetByteSize () const; > + GetByteSize () const { return m_addr_range.GetByteSize(); } > > lldb::SymbolType > - GetType () const; > + GetType () const { return m_type; } > > void > - SetType (lldb::SymbolType type); > + SetType (lldb::SymbolType type) { m_type = type; } > > const char * > GetTypeAsString () const; > > uint32_t > - GetFlags () const; > + GetFlags () const { return m_flags; } > > void > - SetFlags (uint32_t flags); > + SetFlags (uint32_t flags) { m_flags = flags; } > > Function * > GetFunction (); > > Address & > - GetValue (); > + GetValue () { return m_addr_range.GetBaseAddress(); } > > const Address & > - GetValue () const; > + GetValue () const { return m_addr_range.GetBaseAddress(); } > > bool > - IsSynthetic () const; > + IsSynthetic () const { return m_is_synthetic; } > > void > - SetIsSynthetic (bool b); > + SetIsSynthetic (bool b) { m_is_synthetic = b; } > > void > - SetSizeIsSynthesized(bool b); > + SetSizeIsSynthesized(bool b) { m_size_is_synthesized = b; } > > bool > - IsDebug () const; > + IsDebug () const { return m_is_debug; } > > void > - SetDebug (bool b); > + SetDebug (bool b) { m_is_debug = b; } > > bool > - IsExternal () const; > + IsExternal () const { return m_is_external; } > > void > - SetExternal (bool b); > + SetExternal (bool b) { m_is_external = b; } > > bool > IsTrampoline () const; > > void > - SetByteSize (uint32_t size); > + SetByteSize (uint32_t size) { m_addr_range.SetByteSize(size); } > > void > - SetSizeIsSibling (bool b); > + SetSizeIsSibling (bool b) { m_size_is_sibling = b; } > > void > - SetValue (Address &value); > + SetValue (Address &value) { m_addr_range.GetBaseAddress() = value; } > > void > - SetValue (const AddressRange &range); > + SetValue (const AddressRange &range) { m_addr_range = range; } > > void > SetValue (lldb::addr_t value); > > Modified: lldb/trunk/source/Core/Address.cpp > URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/Address.cpp?rev=106450&r1=106449&r2=106450&view=diff > ============================================================================== > --- lldb/trunk/source/Core/Address.cpp (original) > +++ lldb/trunk/source/Core/Address.cpp Mon Jun 21 14:26:54 2010 > @@ -247,11 +247,6 @@ > ResolveAddressUsingFileSections(address, sections); > } > > -Address::~Address () > -{ > -} > - > - > const Address& > Address::operator= (const Address& rhs) > { > @@ -321,13 +316,6 @@ > return NULL; > } > > -const Section* > -Address::GetSection () const > -{ > - return m_section; > -} > - > - > //addr_t > //Address::Address() const > //{ > @@ -381,12 +369,6 @@ > return m_offset; > } > > -addr_t > -Address::GetOffset () const > -{ > - return m_offset; > -} > - > bool > Address::SetOffset (addr_t offset) > { > @@ -396,12 +378,6 @@ > } > > void > -Address::SetSection (const Section* section) > -{ > - m_section = section; > -} > - > -void > Address::Clear() > { > m_section = NULL; > > Modified: lldb/trunk/source/Core/AddressRange.cpp > URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/AddressRange.cpp?rev=106450&r1=106449&r2=106450&view=diff > ============================================================================== > --- lldb/trunk/source/Core/AddressRange.cpp (original) > +++ lldb/trunk/source/Core/AddressRange.cpp Mon Jun 21 14:26:54 2010 > @@ -42,30 +42,6 @@ > { > } > > -Address & > -AddressRange::GetBaseAddress() > -{ > - return m_base_addr; > -} > - > -const Address & > -AddressRange::GetBaseAddress() const > -{ > - return m_base_addr; > -} > - > -addr_t > -AddressRange::GetByteSize() const > -{ > - return m_byte_size; > -} > - > -void > -AddressRange::SetByteSize(addr_t byte_size) > -{ > - m_byte_size = byte_size; > -} > - > //bool > //AddressRange::Contains (const Address &addr) const > //{ > @@ -204,14 +180,6 @@ > { > s->Printf("%.*p: AddressRange section = %*p, offset = 0x%16.16llx, byte_size = 0x%16.16llx\n", (int)sizeof(void*) * 2, this, (int)sizeof(void*) * 2, m_base_addr.GetSection(), m_base_addr.GetOffset(), GetByteSize()); > } > - > -size_t > -AddressRange::MemorySize () const > -{ > - // Noting special for the memory size of a single AddressRange object, > - // it is just the size of itself. > - return sizeof(AddressRange); > -} > // > //bool > //lldb::operator== (const AddressRange& lhs, const AddressRange& rhs) > > Modified: lldb/trunk/source/Symbol/Symbol.cpp > URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/Symbol.cpp?rev=106450&r1=106449&r2=106450&view=diff > ============================================================================== > --- lldb/trunk/source/Symbol/Symbol.cpp (original) > +++ lldb/trunk/source/Symbol/Symbol.cpp Mon Jun 21 14:26:54 2010 > @@ -139,18 +139,6 @@ > return *this; > } > > -AddressRange & > -Symbol::GetAddressRangeRef() > -{ > - return m_addr_range; > -} > - > -const AddressRange & > -Symbol::GetAddressRangeRef() const > -{ > - return m_addr_range; > -} > - > AddressRange * > Symbol::GetAddressRangePtr() > { > @@ -167,115 +155,18 @@ > return NULL; > } > > -bool > -Symbol::GetSizeIsSibling() const > -{ > - return m_size_is_sibling; > -} > - > -bool > -Symbol::GetSizeIsSynthesized() const > -{ > - return m_size_is_synthesized; > -} > - > uint32_t > Symbol::GetSiblingIndex() const > { > return m_size_is_sibling ? m_addr_range.GetByteSize() : 0; > } > > -uint32_t > -Symbol::GetFlags() const > -{ > - return m_flags; > -} > - > -void > -Symbol::SetFlags (uint32_t flags) > -{ > - m_flags = flags; > -} > - > -SymbolType > -Symbol::GetType() const > -{ > - return m_type; > -} > - > -void > -Symbol::SetType(SymbolType type) > -{ > - m_type = type; > -} > - > -bool > -Symbol::IsSynthetic () const > -{ > - return m_is_synthetic; > -} > - > -void > -Symbol::SetIsSynthetic (bool b) > -{ > - m_is_synthetic = b; > -} > - > -void > -Symbol::SetSizeIsSynthesized(bool b) > -{ > - m_size_is_synthesized = b; > -} > - > - > -bool > -Symbol::IsDebug() const > -{ > - return m_is_debug; > -} > - > -void > -Symbol::SetDebug (bool b) > -{ > - m_is_debug = b; > -} > - > -bool > -Symbol::IsExternal() const > -{ > - return m_is_external; > -} > - > -void > -Symbol::SetExternal(bool b) > -{ > - m_is_external = b; > -} > - > bool > Symbol::IsTrampoline () const > { > return m_type == eSymbolTypeTrampoline; > } > > -uint32_t > -Symbol::GetByteSize() const > -{ > - return m_addr_range.GetByteSize(); > -} > - > -void > -Symbol::SetByteSize (uint32_t size) > -{ > - m_addr_range.SetByteSize(size); > -} > - > -void > -Symbol::SetSizeIsSibling (bool b) > -{ > - m_size_is_sibling = b; > -} > - > void > Symbol::Dump(Stream *s, Process *process, uint32_t index) const > { > @@ -322,36 +213,6 @@ > } > } > > -const Mangled& > -Symbol::GetMangled() const > -{ > - return m_mangled; > -} > - > -Mangled& > -Symbol::GetMangled() > -{ > - return m_mangled; > -} > - > -Address & > -Symbol::GetValue() > -{ > - return m_addr_range.GetBaseAddress(); > -} > - > -const Address & > -Symbol::GetValue() const > -{ > - return m_addr_range.GetBaseAddress(); > -} > - > -void > -Symbol::SetValue (Address &value) > -{ > - m_addr_range.GetBaseAddress() = value; > -} > - > Function * > Symbol::GetFunction () > { > @@ -397,13 +258,6 @@ > } > > void > -Symbol::SetValue (const AddressRange &range) > -{ > - m_addr_range = range; > -} > - > - > -void > Symbol::SetValue(addr_t value) > { > m_addr_range.GetBaseAddress().SetSection(NULL); > > > _______________________________________________ > lldb-commits mailing list > lldb-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/lldb-commits From johnny.chen at apple.com Mon Jun 21 19:11:26 2010 From: johnny.chen at apple.com (Johnny Chen) Date: Tue, 22 Jun 2010 00:11:26 -0000 Subject: [Lldb-commits] [lldb] r106509 - /lldb/trunk/test/tester.py Message-ID: <20100622001126.B74912A6C12C@llvm.org> Author: johnny Date: Mon Jun 21 19:11:26 2010 New Revision: 106509 URL: http://llvm.org/viewvc/llvm-project?rev=106509&view=rev Log: Remove stale reference to the lldb path component. Modified: lldb/trunk/test/tester.py Modified: lldb/trunk/test/tester.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/tester.py?rev=106509&r1=106508&r2=106509&view=diff ============================================================================== --- lldb/trunk/test/tester.py (original) +++ lldb/trunk/test/tester.py Mon Jun 21 19:11:26 2010 @@ -5,9 +5,10 @@ def setupSysPath(): testPath = sys.path[0] - rem = re.match("(^.*lldb/)test$", testPath) + print "sys.path[0] =", testPath + rem = re.match("(^.*/)test$", testPath) if not rem: - print "This script expects to reside in .../lldb/test." + print "This script expects to reside in .../test." sys.exit(-1) lldbBasePath = rem.group(1) lldbDebugPythonPath = "build/Debug/LLDB.framework/Resources/Python" From johnny.chen at apple.com Mon Jun 21 19:13:20 2010 From: johnny.chen at apple.com (Johnny Chen) Date: Tue, 22 Jun 2010 00:13:20 -0000 Subject: [Lldb-commits] [lldb] r106510 - /lldb/trunk/test/tester.py Message-ID: <20100622001320.40A992A6C12C@llvm.org> Author: johnny Date: Mon Jun 21 19:13:20 2010 New Revision: 106510 URL: http://llvm.org/viewvc/llvm-project?rev=106510&view=rev Log: Left a debug statement in the previous checkin. Modified: lldb/trunk/test/tester.py Modified: lldb/trunk/test/tester.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/tester.py?rev=106510&r1=106509&r2=106510&view=diff ============================================================================== --- lldb/trunk/test/tester.py (original) +++ lldb/trunk/test/tester.py Mon Jun 21 19:13:20 2010 @@ -5,7 +5,6 @@ def setupSysPath(): testPath = sys.path[0] - print "sys.path[0] =", testPath rem = re.match("(^.*/)test$", testPath) if not rem: print "This script expects to reside in .../test." From benny.kra at googlemail.com Tue Jun 22 05:44:12 2010 From: benny.kra at googlemail.com (Benjamin Kramer) Date: Tue, 22 Jun 2010 10:44:12 -0000 Subject: [Lldb-commits] [lldb] r106535 - in /lldb/trunk: include/lldb/Core/UserID.h source/Core/UserID.cpp Message-ID: <20100622104412.398292A6C12C@llvm.org> Author: d0k Date: Tue Jun 22 05:44:12 2010 New Revision: 106535 URL: http://llvm.org/viewvc/llvm-project?rev=106535&view=rev Log: Move trivial parts of UserID into the header. Modified: lldb/trunk/include/lldb/Core/UserID.h lldb/trunk/source/Core/UserID.cpp Modified: lldb/trunk/include/lldb/Core/UserID.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/UserID.h?rev=106535&r1=106534&r2=106535&view=diff ============================================================================== --- lldb/trunk/include/lldb/Core/UserID.h (original) +++ lldb/trunk/include/lldb/Core/UserID.h Tue Jun 22 05:44:12 2010 @@ -35,7 +35,7 @@ //------------------------------------------------------------------ /// Construct with optional user ID. //------------------------------------------------------------------ - UserID (lldb::user_id_t uid = LLDB_INVALID_UID); + UserID (lldb::user_id_t uid = LLDB_INVALID_UID) : m_uid(uid) {} //------------------------------------------------------------------ /// Destructor. @@ -51,7 +51,7 @@ /// Clears the object contents back to a default invalid state. //------------------------------------------------------------------ void - Clear (); + Clear () { m_uid = LLDB_INVALID_UID; } //------------------------------------------------------------------ /// Get accessor for the user ID. @@ -60,7 +60,7 @@ /// The user ID. //------------------------------------------------------------------ lldb::user_id_t - GetID () const; + GetID () const { return m_uid; } //------------------------------------------------------------------ /// Set accessor for the user ID. @@ -69,7 +69,7 @@ /// The new user ID. //------------------------------------------------------------------ void - SetID (lldb::user_id_t uid); + SetID (lldb::user_id_t uid) { m_uid = uid; } //------------------------------------------------------------------ /// Unary predicate function object that can search for a matching @@ -88,13 +88,13 @@ //-------------------------------------------------------------- /// Construct with the user ID to look for. //-------------------------------------------------------------- - IDMatches (lldb::user_id_t uid); + IDMatches (lldb::user_id_t uid) : m_uid(uid) {} //-------------------------------------------------------------- /// Unary predicate function object callback. //-------------------------------------------------------------- bool - operator () (const UserID& rhs) const; + operator () (const UserID& rhs) const { return m_uid == rhs.GetID(); } private: //-------------------------------------------------------------- @@ -114,8 +114,16 @@ //-------------------------------------------------------------- /// Stream the UserID object to a Stream. //-------------------------------------------------------------- -bool operator== (const UserID& lhs, const UserID& rhs); -bool operator!= (const UserID& lhs, const UserID& rhs); +inline bool operator== (const UserID& lhs, const UserID& rhs) +{ + return lhs.GetID() == rhs.GetID(); +} + +inline bool operator!= (const UserID& lhs, const UserID& rhs) +{ + return lhs.GetID() != rhs.GetID(); +} + Stream& operator << (Stream& strm, const UserID& uid); } // namespace lldb_private Modified: lldb/trunk/source/Core/UserID.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/UserID.cpp?rev=106535&r1=106534&r2=106535&view=diff ============================================================================== --- lldb/trunk/source/Core/UserID.cpp (original) +++ lldb/trunk/source/Core/UserID.cpp Tue Jun 22 05:44:12 2010 @@ -13,61 +13,13 @@ using namespace lldb; using namespace lldb_private; -UserID::UserID (user_id_t uid) : - m_uid(uid) -{ -} - UserID::~UserID () { } -void -UserID::Clear () -{ - m_uid = LLDB_INVALID_UID; -} - - -user_id_t -UserID::GetID () const -{ - return m_uid; -} - -void -UserID::SetID (user_id_t uid) -{ - m_uid = uid; -} - -UserID::IDMatches::IDMatches (user_id_t uid) : - m_uid(uid) -{ -} - -bool -UserID::IDMatches::operator() (const UserID& rhs) const -{ - return m_uid == rhs.GetID(); -} - Stream& lldb_private::operator << (Stream& strm, const UserID& uid) { strm.Printf("{0x%8.8x}", uid.GetID()); return strm; } - -bool -lldb_private::operator== (const UserID& lhs, const UserID& rhs) -{ - return lhs.GetID() == rhs.GetID(); -} - -bool -lldb_private::operator!= (const UserID& lhs, const UserID& rhs) -{ - return lhs.GetID() != rhs.GetID(); -} - From benny.kra at googlemail.com Tue Jun 22 10:28:29 2010 From: benny.kra at googlemail.com (Benjamin Kramer) Date: Tue, 22 Jun 2010 15:28:29 -0000 Subject: [Lldb-commits] [lldb] r106544 - /lldb/trunk/source/Core/Mangled.cpp Message-ID: <20100622152829.29CD52A6C12C@llvm.org> Author: d0k Date: Tue Jun 22 10:28:29 2010 New Revision: 106544 URL: http://llvm.org/viewvc/llvm-project?rev=106544&view=rev Log: Ensure GetDemangledName's thread safety by making the demangle buffer thread specific. I'm not sure when multiple threads enter this method but a race-condition causing a crash in malloc can be reproduced with this little script: echo file $(which lldb) > cmd echo "run\nbreak set -n main\nrun\nexit" >> cmd lldb -s cmd It may need a few runs before it crashes though. Modified: lldb/trunk/source/Core/Mangled.cpp Modified: lldb/trunk/source/Core/Mangled.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/Mangled.cpp?rev=106544&r1=106543&r2=106544&view=diff ============================================================================== --- lldb/trunk/source/Core/Mangled.cpp (original) +++ lldb/trunk/source/Core/Mangled.cpp Tue Jun 22 10:28:29 2010 @@ -118,6 +118,40 @@ } } +namespace +{ + //------------------------------------------------------------------ + // Convenience wrapper for __cxa_demangle. + //------------------------------------------------------------------ + class DemangleBuffer + { + char *m_demangle_buf; + size_t m_demangle_buf_len; + public: + DemangleBuffer () : m_demangle_buf (NULL), m_demangle_buf_len (0) {} + ~DemangleBuffer () + { + free (m_demangle_buf); + } + int Demangle (const char *mangled) + { + int status = 0; + m_demangle_buf = abi::__cxa_demangle(mangled, m_demangle_buf, + &m_demangle_buf_len, &status); + return status; + } + const char *GetBuffer () const { return m_demangle_buf; } + size_t GetLength () const { return m_demangle_buf_len; } + }; +} + +//---------------------------------------------------------------------- +// Used to delete the thread specific buffer when the thread exits. +//---------------------------------------------------------------------- +static void FreeDemangleBuffer (void *buf) +{ + delete static_cast (buf); +} //---------------------------------------------------------------------- // Generate the demangled name on demand using this accessor. Code in @@ -147,19 +181,27 @@ // return a buffer value and length and we will continue to // re-use that buffer so we don't always have to malloc/free // a buffer for each demangle. The buffer can be realloc'ed - // by abi::__cxa_demangle, so we may need to make it thread - // specific if we ever start doing multi-threaded calls to - // this function. g_demangle_buf will currently leak one - // malloc entry that can vary in size. If we need to reclaim - // this memory, we will need to add some code to free this - // buffer at exit time. - static char *g_demangle_buf = NULL; - static size_t g_demangle_buf_len = 0; - int status = 0; - g_demangle_buf = abi::__cxa_demangle(mangled, g_demangle_buf, &g_demangle_buf_len, &status); - if (g_demangle_buf != NULL) + // by abi::__cxa_demangle, so we need to make it thread + // specific. + + // Set up thread specific storage. + static pthread_key_t g_demangle_key = 0; + if (!g_demangle_key) + ::pthread_key_create (&g_demangle_key, FreeDemangleBuffer); + + DemangleBuffer *buf = static_cast ( + ::pthread_getspecific (g_demangle_key)); + if (!buf) // No buffer for this thread, create a new one. + { + buf = new DemangleBuffer (); + ::pthread_setspecific (g_demangle_key, buf); + } + + int status = buf->Demangle (mangled); + if (status == 0) { - m_demangled.SetCString(g_demangle_buf); + m_demangled.SetCStringWithLength(buf->GetBuffer(), + buf->GetLength()); } else { From benny.kra at googlemail.com Tue Jun 22 10:28:34 2010 From: benny.kra at googlemail.com (Benjamin Kramer) Date: Tue, 22 Jun 2010 15:28:34 -0000 Subject: [Lldb-commits] [lldb] r106545 - /lldb/trunk/source/Core/ConstString.cpp Message-ID: <20100622152834.93BD62A6C12D@llvm.org> Author: d0k Date: Tue Jun 22 10:28:34 2010 New Revision: 106545 URL: http://llvm.org/viewvc/llvm-project?rev=106545&view=rev Log: Reduce code duplication. This also moves strlen out of the mutex scope. Modified: lldb/trunk/source/Core/ConstString.cpp Modified: lldb/trunk/source/Core/ConstString.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/ConstString.cpp?rev=106545&r1=106544&r2=106545&view=diff ============================================================================== --- lldb/trunk/source/Core/ConstString.cpp (original) +++ lldb/trunk/source/Core/ConstString.cpp Tue Jun 22 10:28:34 2010 @@ -73,15 +73,7 @@ GetConstCString (const char *cstr) { if (cstr) - { - Mutex::Locker locker (m_mutex); - llvm::StringRef string_ref (cstr); - llvm::StringMapEntry& entry = m_string_map.GetOrCreateValue (string_ref); - const char *ccstr = entry.getKeyData(); - llvm::StringMapEntry&reconstituted_entry = GetStringMapEntryFromKeyData (ccstr); - assert (&entry == &reconstituted_entry); - return ccstr; - } + return GetConstCStringWithLength (cstr, strlen (cstr)); return NULL; } @@ -106,14 +98,8 @@ { if (cstr) { - Mutex::Locker locker (m_mutex); - int actual_cstr_len = strlen (cstr); - llvm::StringRef string_ref (cstr, std::min(actual_cstr_len, cstr_len)); - llvm::StringMapEntry& entry = m_string_map.GetOrCreateValue (string_ref); - const char *ccstr = entry.getKeyData(); - llvm::StringMapEntry&reconstituted_entry = GetStringMapEntryFromKeyData (ccstr); - assert (&entry == &reconstituted_entry); - return ccstr; + int trimmed_len = std::min (strlen (cstr), cstr_len); + return GetConstCStringWithLength (cstr, trimmed_len); } return NULL; } From jingham at apple.com Tue Jun 22 16:12:54 2010 From: jingham at apple.com (Jim Ingham) Date: Tue, 22 Jun 2010 21:12:54 -0000 Subject: [Lldb-commits] [lldb] r106578 - in /lldb/trunk: include/lldb/Breakpoint/BreakpointLocation.h include/lldb/Breakpoint/BreakpointOptions.h source/API/SBBreakpointLocation.cpp source/Breakpoint/BreakpointLocation.cpp source/Breakpoint/BreakpointOptions.cpp source/Commands/CommandObjectBreakpointCommand.cpp Message-ID: <20100622211254.DC1DB2A6C12C@llvm.org> Author: jingham Date: Tue Jun 22 16:12:54 2010 New Revision: 106578 URL: http://llvm.org/viewvc/llvm-project?rev=106578&view=rev Log: Make an explicit GetThreadSpecNoCreate accessor so you don't have to get the const-ness right to ensure you are not making a copy of the owning breakpoint's ThreadSpec in a breakpoint location. Also change the name from NoCopy to NoCreate since that's clearer. Modified: lldb/trunk/include/lldb/Breakpoint/BreakpointLocation.h lldb/trunk/include/lldb/Breakpoint/BreakpointOptions.h lldb/trunk/source/API/SBBreakpointLocation.cpp lldb/trunk/source/Breakpoint/BreakpointLocation.cpp lldb/trunk/source/Breakpoint/BreakpointOptions.cpp lldb/trunk/source/Commands/CommandObjectBreakpointCommand.cpp Modified: lldb/trunk/include/lldb/Breakpoint/BreakpointLocation.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Breakpoint/BreakpointLocation.h?rev=106578&r1=106577&r2=106578&view=diff ============================================================================== --- lldb/trunk/include/lldb/Breakpoint/BreakpointLocation.h (original) +++ lldb/trunk/include/lldb/Breakpoint/BreakpointLocation.h Tue Jun 22 16:12:54 2010 @@ -251,14 +251,16 @@ GetLocationOptions (); //------------------------------------------------------------------ - /// Use this to access location specific breakpoint options. + /// Use this to access breakpoint options from this breakpoint location. + /// This will point to the owning breakpoint's options unless options have + /// been set specifically on this location. /// /// @return /// A pointer to the containing breakpoint's options if this /// location doesn't have its own copy. //------------------------------------------------------------------ const BreakpointOptions * - GetOptionsNoCopy () const; + GetOptionsNoCreate () const; bool ValidForThisThread (Thread *thread); Modified: lldb/trunk/include/lldb/Breakpoint/BreakpointOptions.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Breakpoint/BreakpointOptions.h?rev=106578&r1=106577&r2=106578&view=diff ============================================================================== --- lldb/trunk/include/lldb/Breakpoint/BreakpointOptions.h (original) +++ lldb/trunk/include/lldb/Breakpoint/BreakpointOptions.h Tue Jun 22 16:12:54 2010 @@ -125,13 +125,14 @@ //------------------------------------------------------------------ //------------------------------------------------------------------ - /// Return the current thread spec. This is used to pass to Thread::MatchesSpec. + /// Return the current thread spec for this option. This will return NULL if the no thread + /// specifications have been set for this Option yet. /// @return /// The thread specification pointer for this option, or NULL if none has /// been set yet. //------------------------------------------------------------------ const ThreadSpec * - GetThreadSpec () const; + GetThreadSpecNoCreate () const; //------------------------------------------------------------------ /// Returns a pointer to the ThreadSpec for this option, creating it. Modified: lldb/trunk/source/API/SBBreakpointLocation.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBBreakpointLocation.cpp?rev=106578&r1=106577&r2=106578&view=diff ============================================================================== --- lldb/trunk/source/API/SBBreakpointLocation.cpp (original) +++ lldb/trunk/source/API/SBBreakpointLocation.cpp Tue Jun 22 16:12:54 2010 @@ -104,7 +104,7 @@ { tid_t sb_thread_id = (lldb::tid_t) LLDB_INVALID_THREAD_ID; if (m_break_loc_sp) - sb_thread_id = m_break_loc_sp->GetLocationOptions()->GetThreadSpec()->GetTID(); + sb_thread_id = m_break_loc_sp->GetLocationOptions()->GetThreadSpecNoCreate()->GetTID(); return sb_thread_id; } @@ -121,7 +121,7 @@ { if (m_break_loc_sp) { - const ThreadSpec *thread_spec = m_break_loc_sp->GetOptionsNoCopy()->GetThreadSpec(); + const ThreadSpec *thread_spec = m_break_loc_sp->GetOptionsNoCreate()->GetThreadSpecNoCreate(); if (thread_spec == NULL) return 0; else @@ -143,7 +143,7 @@ { if (m_break_loc_sp) { - const ThreadSpec *thread_spec = m_break_loc_sp->GetOptionsNoCopy()->GetThreadSpec(); + const ThreadSpec *thread_spec = m_break_loc_sp->GetOptionsNoCreate()->GetThreadSpecNoCreate(); if (thread_spec == NULL) return NULL; else @@ -164,7 +164,7 @@ { if (m_break_loc_sp) { - const ThreadSpec *thread_spec = m_break_loc_sp->GetOptionsNoCopy()->GetThreadSpec(); + const ThreadSpec *thread_spec = m_break_loc_sp->GetOptionsNoCreate()->GetThreadSpecNoCreate(); if (thread_spec == NULL) return NULL; else Modified: lldb/trunk/source/Breakpoint/BreakpointLocation.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Breakpoint/BreakpointLocation.cpp?rev=106578&r1=106577&r2=106578&view=diff ============================================================================== --- lldb/trunk/source/Breakpoint/BreakpointLocation.cpp (original) +++ lldb/trunk/source/Breakpoint/BreakpointLocation.cpp Tue Jun 22 16:12:54 2010 @@ -140,7 +140,7 @@ int32_t BreakpointLocation::GetIgnoreCount () { - return GetOptionsNoCopy()->GetIgnoreCount(); + return GetOptionsNoCreate()->GetIgnoreCount(); } void @@ -150,7 +150,7 @@ } const BreakpointOptions * -BreakpointLocation::GetOptionsNoCopy () const +BreakpointLocation::GetOptionsNoCreate () const { if (m_options_ap.get() != NULL) return m_options_ap.get(); @@ -173,7 +173,7 @@ bool BreakpointLocation::ValidForThisThread (Thread *thread) { - return thread->MatchesSpec(GetOptionsNoCopy()->GetThreadSpec()); + return thread->MatchesSpec(GetOptionsNoCreate()->GetThreadSpecNoCreate()); } // RETURNS - true if we should stop at this breakpoint, false if we @@ -383,7 +383,7 @@ s->Printf("BreakpointLocation %u: tid = %4.4x load addr = 0x%8.8llx state = %s type = %s breakpoint " "hw_index = %i hit_count = %-4u ignore_count = %-4u", GetID(), - GetOptionsNoCopy()->GetThreadSpec()->GetTID(), + GetOptionsNoCreate()->GetThreadSpecNoCreate()->GetTID(), (uint64_t) m_address.GetLoadAddress(m_owner.GetTarget().GetProcessSP().get()), (m_options_ap.get() ? m_options_ap->IsEnabled() : m_owner.IsEnabled()) ? "enabled " : "disabled", IsHardware() ? "hardware" : "software", Modified: lldb/trunk/source/Breakpoint/BreakpointOptions.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Breakpoint/BreakpointOptions.cpp?rev=106578&r1=106577&r2=106578&view=diff ============================================================================== --- lldb/trunk/source/Breakpoint/BreakpointOptions.cpp (original) +++ lldb/trunk/source/Breakpoint/BreakpointOptions.cpp Tue Jun 22 16:12:54 2010 @@ -173,7 +173,7 @@ } const ThreadSpec * -BreakpointOptions::GetThreadSpec () const +BreakpointOptions::GetThreadSpecNoCreate () const { return m_thread_spec_ap.get(); } @@ -200,7 +200,7 @@ // Figure out if there are any options not at their default value, and only print // anything if there are: - if (m_ignore_count != 0 || !m_enabled || (GetThreadSpec() != NULL && GetThreadSpec()->HasSpecification ())) + if (m_ignore_count != 0 || !m_enabled || (GetThreadSpecNoCreate() != NULL && GetThreadSpecNoCreate()->HasSpecification ())) { if (level == lldb::eDescriptionLevelVerbose) { Modified: lldb/trunk/source/Commands/CommandObjectBreakpointCommand.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectBreakpointCommand.cpp?rev=106578&r1=106577&r2=106578&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectBreakpointCommand.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectBreakpointCommand.cpp Tue Jun 22 16:12:54 2010 @@ -536,7 +536,7 @@ { BreakpointLocationSP bp_loc_sp(bp->FindLocationByID (cur_bp_id.GetLocationID())); if (bp_loc_sp) - bp_options = bp_loc_sp->GetOptionsNoCopy(); + bp_options = bp_loc_sp->GetOptionsNoCreate(); else { result.AppendErrorWithFormat("Invalid breakpoint ID: %u.%u.\n", From benny.kra at googlemail.com Tue Jun 22 16:27:56 2010 From: benny.kra at googlemail.com (Benjamin Kramer) Date: Tue, 22 Jun 2010 21:27:56 -0000 Subject: [Lldb-commits] [lldb] r106579 - /lldb/trunk/source/Core/Mangled.cpp Message-ID: <20100622212756.16E612A6C12C@llvm.org> Author: d0k Date: Tue Jun 22 16:27:55 2010 New Revision: 106579 URL: http://llvm.org/viewvc/llvm-project?rev=106579&view=rev Log: Turns out __cxa_demangle returns the size of the buffer instead of the size of the demangled name. Fall back to strlen. Modified: lldb/trunk/source/Core/Mangled.cpp Modified: lldb/trunk/source/Core/Mangled.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/Mangled.cpp?rev=106579&r1=106578&r2=106579&view=diff ============================================================================== --- lldb/trunk/source/Core/Mangled.cpp (original) +++ lldb/trunk/source/Core/Mangled.cpp Tue Jun 22 16:27:55 2010 @@ -141,7 +141,6 @@ return status; } const char *GetBuffer () const { return m_demangle_buf; } - size_t GetLength () const { return m_demangle_buf_len; } }; } @@ -197,11 +196,9 @@ ::pthread_setspecific (g_demangle_key, buf); } - int status = buf->Demangle (mangled); - if (status == 0) + if (buf->Demangle (mangled) == 0) { - m_demangled.SetCStringWithLength(buf->GetBuffer(), - buf->GetLength()); + m_demangled.SetCString(buf->GetBuffer()); } else { From benny.kra at googlemail.com Tue Jun 22 16:28:05 2010 From: benny.kra at googlemail.com (Benjamin Kramer) Date: Tue, 22 Jun 2010 21:28:05 -0000 Subject: [Lldb-commits] [lldb] r106580 - /lldb/trunk/source/Utility/StringExtractor.cpp Message-ID: <20100622212805.7521A2A6C12C@llvm.org> Author: d0k Date: Tue Jun 22 16:28:05 2010 New Revision: 106580 URL: http://llvm.org/viewvc/llvm-project?rev=106580&view=rev Log: Avoid tolower, it's slow and unnecessary. Modified: lldb/trunk/source/Utility/StringExtractor.cpp Modified: lldb/trunk/source/Utility/StringExtractor.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Utility/StringExtractor.cpp?rev=106580&r1=106579&r2=106580&view=diff ============================================================================== --- lldb/trunk/source/Utility/StringExtractor.cpp (original) +++ lldb/trunk/source/Utility/StringExtractor.cpp Tue Jun 22 16:28:05 2010 @@ -17,18 +17,20 @@ static inline int xdigit_to_sint (char ch) { - ch = tolower(ch); if (ch >= 'a' && ch <= 'f') return 10 + ch - 'a'; + if (ch >= 'A' && ch <= 'F') + return 10 + ch - 'A'; return ch - '0'; } static inline unsigned int xdigit_to_uint (uint8_t ch) { - ch = tolower(ch); if (ch >= 'a' && ch <= 'f') return 10u + ch - 'a'; + if (ch >= 'A' && ch <= 'F') + return 10u + ch - 'A'; return ch - '0'; } From scallanan at apple.com Tue Jun 22 18:46:25 2010 From: scallanan at apple.com (Sean Callanan) Date: Tue, 22 Jun 2010 23:46:25 -0000 Subject: [Lldb-commits] [lldb] r106606 - in /lldb/trunk: include/lldb/Expression/ClangASTSource.h include/lldb/Expression/ClangExpressionDeclMap.h source/Expression/ClangASTSource.cpp source/Expression/ClangExpressionDeclMap.cpp Message-ID: <20100622234625.162DF2A6C12C@llvm.org> Author: spyffe Date: Tue Jun 22 18:46:24 2010 New Revision: 106606 URL: http://llvm.org/viewvc/llvm-project?rev=106606&view=rev Log: Added support to the expression parser for locating externally-defined functions. Modified: lldb/trunk/include/lldb/Expression/ClangASTSource.h lldb/trunk/include/lldb/Expression/ClangExpressionDeclMap.h lldb/trunk/source/Expression/ClangASTSource.cpp lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp Modified: lldb/trunk/include/lldb/Expression/ClangASTSource.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Expression/ClangASTSource.h?rev=106606&r1=106605&r2=106606&view=diff ============================================================================== --- lldb/trunk/include/lldb/Expression/ClangASTSource.h (original) +++ lldb/trunk/include/lldb/Expression/ClangASTSource.h Tue Jun 22 18:46:24 2010 @@ -60,6 +60,7 @@ clang::ASTContext *GetASTContext(); clang::NamedDecl *AddVarDecl(void *type); + clang::NamedDecl *AddFunDecl(void *type); }; } Modified: lldb/trunk/include/lldb/Expression/ClangExpressionDeclMap.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Expression/ClangExpressionDeclMap.h?rev=106606&r1=106605&r2=106606&view=diff ============================================================================== --- lldb/trunk/include/lldb/Expression/ClangExpressionDeclMap.h (original) +++ lldb/trunk/include/lldb/Expression/ClangExpressionDeclMap.h Tue Jun 22 18:46:24 2010 @@ -29,6 +29,7 @@ namespace lldb_private { +class Function; class NameSearchContext; class Variable; @@ -63,7 +64,8 @@ ExecutionContext *m_exe_ctx; SymbolContext *m_sym_ctx; /* owned by ClangExpressionDeclMap */ - void AddOneVariable(NameSearchContext &context, Variable* var); + void AddOneVariable(NameSearchContext &context, Variable *var); + void AddOneFunction(NameSearchContext &context, Function *fun); }; } // namespace lldb_private Modified: lldb/trunk/source/Expression/ClangASTSource.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/ClangASTSource.cpp?rev=106606&r1=106605&r2=106606&view=diff ============================================================================== --- lldb/trunk/source/Expression/ClangASTSource.cpp (original) +++ lldb/trunk/source/Expression/ClangASTSource.cpp Tue Jun 22 18:46:24 2010 @@ -97,3 +97,50 @@ return Decl; } + +clang::NamedDecl *NameSearchContext::AddFunDecl(void *type) { + clang::FunctionDecl *Decl = FunctionDecl::Create(ASTSource.Context, + const_cast(DC), + SourceLocation(), + Name.getAsIdentifierInfo(), + QualType::getFromOpaquePtr(type), + NULL, + FunctionDecl::Static, + FunctionDecl::Static, + false, + true); + + QualType QT = QualType::getFromOpaquePtr(type); + clang::Type *T = QT.getTypePtr(); + + if (T->isFunctionProtoType()) + { + FunctionProtoType *FPT = dyn_cast(T); + + unsigned NumArgs = FPT->getNumArgs(); + unsigned ArgIndex; + + ParmVarDecl *ParmVarDecls[NumArgs]; + + for (ArgIndex = 0; ArgIndex < NumArgs; ++ArgIndex) + { + QualType ArgQT = FPT->getArgType(ArgIndex); + + ParmVarDecls[ArgIndex] = ParmVarDecl::Create(ASTSource.Context, + const_cast(DC), + SourceLocation(), + NULL, + ArgQT, + NULL, + ParmVarDecl::Static, + ParmVarDecl::Static, + NULL); + } + + Decl->setParams(ParmVarDecls, NumArgs); + } + + Decls.push_back(Decl); + + return Decl; +} Modified: lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp?rev=106606&r1=106605&r2=106606&view=diff ============================================================================== --- lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp (original) +++ lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp Tue Jun 22 18:46:24 2010 @@ -115,6 +115,13 @@ ConstString name_cs(name); + Function *fn = m_sym_ctx->FindFunctionByName(name_cs.GetCString()); + + if (fn) + { + AddOneFunction(context, fn); + } + for (current_block_id = block->GetID(); current_block_id != Block::InvalidID; current_block_id = blocks.GetParent(current_block_id)) @@ -167,7 +174,7 @@ if (!var_type) { - DEBUG_PRINTF("Skipped a definition for %s because it has no type\n", name); + DEBUG_PRINTF("Skipped a definition because it has no type\n"); return; } @@ -175,7 +182,7 @@ if (!var_opaque_type) { - DEBUG_PRINTF("Skipped a definition for %s because it has no Clang type\n", name); + DEBUG_PRINTF("Skipped a definition because it has no Clang type\n"); return; } @@ -185,7 +192,7 @@ if (!type_list) { - DEBUG_PRINTF("Skipped a definition for %s because the type has no associated type list\n", name); + DEBUG_PRINTF("Skipped a definition because the type has no associated type list\n"); return; } @@ -203,7 +210,7 @@ if (!var_location_expr.Evaluate(m_exe_ctx, exe_ast_ctx, NULL, *var_location.get(), &err)) { - DEBUG_PRINTF("Error evaluating the location of %s: %s\n", name, err.AsCString()); + DEBUG_PRINTF("Error evaluating location: %s\n", err.AsCString()); return; } @@ -242,5 +249,47 @@ m_tuples.push_back(tuple); - DEBUG_PRINTF("Found for a definition for %s\n", name); + DEBUG_PRINTF("Found variable\n"); +} + +void +ClangExpressionDeclMap::AddOneFunction(NameSearchContext &context, + Function* fun) +{ + Type *fun_type = fun->GetType(); + + if (!fun_type) + { + DEBUG_PRINTF("Skipped a function because it has no type\n"); + return; + } + + void *fun_opaque_type = fun_type->GetOpaqueClangQualType(); + + if (!fun_opaque_type) + { + DEBUG_PRINTF("Skipped a function because it has no Clang type\n"); + return; + } + + std::auto_ptr fun_location(new Value); + + const Address &fun_address = fun->GetAddressRange().GetBaseAddress(); + lldb::addr_t load_addr = fun_address.GetLoadAddress(m_exe_ctx->process); + fun_location->SetValueType(Value::eValueTypeLoadAddress); + fun_location->GetScalar() = load_addr; + + TypeList *type_list = fun_type->GetTypeList(); + void *copied_type = ClangASTContext::CopyType(context.GetASTContext(), type_list->GetClangASTContext().getASTContext(), fun_opaque_type); + + NamedDecl *fun_decl = context.AddFunDecl(copied_type); + + Tuple tuple; + + tuple.m_decl = fun_decl; + tuple.m_value = fun_location.release(); + + m_tuples.push_back(tuple); + + DEBUG_PRINTF("Found function\n"); } From scallanan at apple.com Tue Jun 22 19:47:48 2010 From: scallanan at apple.com (Sean Callanan) Date: Wed, 23 Jun 2010 00:47:48 -0000 Subject: [Lldb-commits] [lldb] r106613 - in /lldb/trunk/source/Expression: ClangExpressionDeclMap.cpp DWARFExpression.cpp Message-ID: <20100623004748.4FA8D2A6C12C@llvm.org> Author: spyffe Date: Tue Jun 22 19:47:48 2010 New Revision: 106613 URL: http://llvm.org/viewvc/llvm-project?rev=106613&view=rev Log: Updated the expression parser to use proper logging when looking for external variables. Also cleaned up the log messages coming from the DWARF interpreter. Modified: lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp lldb/trunk/source/Expression/DWARFExpression.cpp Modified: lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp?rev=106613&r1=106612&r2=106613&view=diff ============================================================================== --- lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp (original) +++ lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp Tue Jun 22 19:47:48 2010 @@ -15,6 +15,7 @@ // Project includes #include "lldb/lldb-private.h" #include "lldb/Core/Address.h" +#include "lldb/Core/Log.h" #include "lldb/Core/Module.h" #include "lldb/Expression/ClangASTSource.h" #include "lldb/Symbol/ClangASTContext.h" @@ -29,12 +30,9 @@ #include "lldb/Target/StackFrame.h" #include "lldb/Target/ExecutionContext.h" -//#define DEBUG_CEDM -#ifdef DEBUG_CEDM -#define DEBUG_PRINTF(...) fprintf(stderr, __VA_ARGS__) -#else -#define DEBUG_PRINTF(...) -#endif +#define DEBUG_PRINTF(...) \ + if (log) \ + log->Printf(__VA_ARGS__) using namespace lldb_private; using namespace clang; @@ -94,7 +92,9 @@ ClangExpressionDeclMap::GetDecls(NameSearchContext &context, const char *name) { - DEBUG_PRINTF("Hunting for a definition for %s\n", name); + Log *log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS); + + DEBUG_PRINTF("Hunting for a definition for %s", name); // Back out in all cases where we're not fully initialized if (!m_exe_ctx || !m_exe_ctx->frame || !m_sym_ctx) @@ -105,7 +105,7 @@ if (!function || !block) { - DEBUG_PRINTF("function = %p, block = %p\n", function, block); + DEBUG_PRINTF("function = %p, block = %p", function, block); return; } @@ -147,7 +147,7 @@ if (!compile_unit) { - DEBUG_PRINTF("compile_unit = %p\n", compile_unit); + DEBUG_PRINTF("compile_unit = %p", compile_unit); return; } @@ -170,11 +170,13 @@ ClangExpressionDeclMap::AddOneVariable(NameSearchContext &context, Variable* var) { + Log *log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS); + Type *var_type = var->GetType(); if (!var_type) { - DEBUG_PRINTF("Skipped a definition because it has no type\n"); + DEBUG_PRINTF("Skipped a definition because it has no type"); return; } @@ -182,7 +184,7 @@ if (!var_opaque_type) { - DEBUG_PRINTF("Skipped a definition because it has no Clang type\n"); + DEBUG_PRINTF("Skipped a definition because it has no Clang type"); return; } @@ -192,7 +194,7 @@ if (!type_list) { - DEBUG_PRINTF("Skipped a definition because the type has no associated type list\n"); + DEBUG_PRINTF("Skipped a definition because the type has no associated type list"); return; } @@ -200,7 +202,7 @@ if (!exe_ast_ctx) { - DEBUG_PRINTF("There is no AST context for the current execution context\n"); + DEBUG_PRINTF("There is no AST context for the current execution context"); return; } @@ -210,7 +212,7 @@ if (!var_location_expr.Evaluate(m_exe_ctx, exe_ast_ctx, NULL, *var_location.get(), &err)) { - DEBUG_PRINTF("Error evaluating location: %s\n", err.AsCString()); + DEBUG_PRINTF("Error evaluating location: %s", err.AsCString()); return; } @@ -249,18 +251,20 @@ m_tuples.push_back(tuple); - DEBUG_PRINTF("Found variable\n"); + DEBUG_PRINTF("Found variable"); } void ClangExpressionDeclMap::AddOneFunction(NameSearchContext &context, Function* fun) { + Log *log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS); + Type *fun_type = fun->GetType(); if (!fun_type) { - DEBUG_PRINTF("Skipped a function because it has no type\n"); + DEBUG_PRINTF("Skipped a function because it has no type"); return; } @@ -268,7 +272,7 @@ if (!fun_opaque_type) { - DEBUG_PRINTF("Skipped a function because it has no Clang type\n"); + DEBUG_PRINTF("Skipped a function because it has no Clang type"); return; } @@ -291,5 +295,5 @@ m_tuples.push_back(tuple); - DEBUG_PRINTF("Found function\n"); + DEBUG_PRINTF("Found function"); } Modified: lldb/trunk/source/Expression/DWARFExpression.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/DWARFExpression.cpp?rev=106613&r1=106612&r2=106613&view=diff ============================================================================== --- lldb/trunk/source/Expression/DWARFExpression.cpp (original) +++ lldb/trunk/source/Expression/DWARFExpression.cpp Tue Jun 22 19:47:48 2010 @@ -840,14 +840,14 @@ if (log) { - log->Printf("\n"); size_t count = stack.size(); + log->Printf("Stack before operation has %d values:", count); for (size_t i=0; iPrintf("%s", new_value.GetData()); + log->Printf(" %s", new_value.GetData()); } log->Printf("0x%8.8x: %s", op_offset, DW_OP_value_to_name(op)); } @@ -2572,14 +2572,14 @@ } else if (log) { - log->Printf("\n"); size_t count = stack.size(); + log->Printf("Stack after operation has %d values:", count); for (size_t i=0; iPrintf("%s", new_value.GetData()); + log->Printf(" %s", new_value.GetData()); } } From rjmccall at apple.com Tue Jun 22 20:49:17 2010 From: rjmccall at apple.com (John McCall) Date: Tue, 22 Jun 2010 18:49:17 -0700 Subject: [Lldb-commits] [lldb] r106606 - in /lldb/trunk: include/lldb/Expression/ClangASTSource.h include/lldb/Expression/ClangExpressionDeclMap.h source/Expression/ClangASTSource.cpp source/Expression/ClangExpressionDeclMap.cpp In-Reply-To: <20100622234625.162DF2A6C12C@llvm.org> References: <20100622234625.162DF2A6C12C@llvm.org> Message-ID: On Jun 22, 2010, at 4:46 PM, Sean Callanan wrote: > + if (T->isFunctionProtoType()) > + { > + FunctionProtoType *FPT = dyn_cast(T); It may not matter much, because I'm not sure how well typedef information is preserved through DWARF, but this should be if (const FunctionProtoType *FPT = T->getAs()) { ... } > + > + unsigned NumArgs = FPT->getNumArgs(); > + unsigned ArgIndex; > + > + ParmVarDecl *ParmVarDecls[NumArgs]; FWIW, this is a VLA and therefore not standard C++, although it's likely to be accepted by most implementations (including, recently, Clang). John. From scallanan at apple.com Tue Jun 22 20:53:09 2010 From: scallanan at apple.com (Sean Callanan) Date: Tue, 22 Jun 2010 18:53:09 -0700 Subject: [Lldb-commits] [lldb] r106606 - in /lldb/trunk: include/lldb/Expression/ClangASTSource.h include/lldb/Expression/ClangExpressionDeclMap.h source/Expression/ClangASTSource.cpp source/Expression/ClangExpressionDeclMap.cpp In-Reply-To: References: <20100622234625.162DF2A6C12C@llvm.org> Message-ID: <1BB7159B-9D44-4723-BA59-BC6E191A8BD0@apple.com> Thanks. I'll fix both of these. Sean On Jun 22, 2010, at 6:49 PM, John McCall wrote: > On Jun 22, 2010, at 4:46 PM, Sean Callanan wrote: >> + if (T->isFunctionProtoType()) >> + { >> + FunctionProtoType *FPT = dyn_cast(T); > > It may not matter much, because I'm not sure how well typedef information is preserved > through DWARF, but this should be > if (const FunctionProtoType *FPT = T->getAs()) { ... } > >> + >> + unsigned NumArgs = FPT->getNumArgs(); >> + unsigned ArgIndex; >> + >> + ParmVarDecl *ParmVarDecls[NumArgs]; > > FWIW, this is a VLA and therefore not standard C++, although it's likely to be accepted by > most implementations (including, recently, Clang). > > John. From jingham at apple.com Tue Jun 22 20:57:20 2010 From: jingham at apple.com (Jim Ingham) Date: Tue, 22 Jun 2010 18:57:20 -0700 Subject: [Lldb-commits] [lldb] r106606 - in /lldb/trunk: include/lldb/Expression/ClangASTSource.h include/lldb/Expression/ClangExpressionDeclMap.h source/Expression/ClangASTSource.cpp source/Expression/ClangExpressionDeclMap.cpp In-Reply-To: References: <20100622234625.162DF2A6C12C@llvm.org> Message-ID: <0E669B4A-AE2F-4580-9E3F-42D95FF596B5@apple.com> DWARf is pretty good at expressing typedef chains. We use typedef'ed name of variables for various purposes. For instance the "data formatters" when we get to them will bind to the typedef used in the declaration and only fallback on the actual type if there is no formatter for the typedef'ed version... That's convenient when somebody wants to see "typedef uint32_t bitmask" printed as an array of bits, not as a hex number. Jim On Jun 22, 2010, at 6:49 PM, John McCall wrote: > It may not matter much, because I'm not sure how well typedef information is preserved > through DWARF, but this should be From gclayton at apple.com Tue Jun 22 20:19:30 2010 From: gclayton at apple.com (Greg Clayton) Date: Wed, 23 Jun 2010 01:19:30 -0000 Subject: [Lldb-commits] [lldb] r106615 - in /lldb/trunk: include/lldb/ include/lldb/API/ include/lldb/Breakpoint/ include/lldb/Core/ include/lldb/Interpreter/ include/lldb/Target/ lldb.xcodeproj/ source/API/ source/Breakpoint/ source/Commands/ source/Core/ source/Interpreter/ source/Plugins/Process/gdb-remote/ source/Target/ tools/driver/ Message-ID: <20100623011931.F3EBE2A6C12C@llvm.org> Author: gclayton Date: Tue Jun 22 20:19:29 2010 New Revision: 106615 URL: http://llvm.org/viewvc/llvm-project?rev=106615&view=rev Log: Very large changes that were needed in order to allow multiple connections to the debugger from GUI windows. Previously there was one global debugger instance that could be accessed that had its own command interpreter and current state (current target/process/thread/frame). When a GUI debugger was attached, if it opened more than one window that each had a console window, there were issues where the last one to setup the global debugger object won and got control of the debugger. To avoid this we now create instances of the lldb_private::Debugger that each has its own state: - target list for targets the debugger instance owns - current process/thread/frame - its own command interpreter - its own input, output and error file handles to avoid conflicts - its own input reader stack So now clients should call: SBDebugger::Initialize(); // (static function) SBDebugger debugger (SBDebugger::Create()); // Use which ever file handles you wish debugger.SetErrorFileHandle (stderr, false); debugger.SetOutputFileHandle (stdout, false); debugger.SetInputFileHandle (stdin, true); // main loop SBDebugger::Terminate(); // (static function) SBDebugger::Initialize() and SBDebugger::Terminate() are ref counted to ensure nothing gets destroyed too early when multiple clients might be attached. Cleaned up the command interpreter and the CommandObject and all subclasses to take more appropriate arguments. Removed: lldb/trunk/include/lldb/Interpreter/CommandContext.h lldb/trunk/source/Commands/CommandObjectAdd.cpp lldb/trunk/source/Commands/CommandObjectAdd.h lldb/trunk/source/Commands/CommandObjectRemove.cpp lldb/trunk/source/Commands/CommandObjectRemove.h lldb/trunk/source/Commands/CommandObjectTranslate.cpp lldb/trunk/source/Commands/CommandObjectTranslate.h lldb/trunk/source/Interpreter/CommandContext.cpp Modified: lldb/trunk/include/lldb/API/SBAddress.h lldb/trunk/include/lldb/API/SBBlock.h lldb/trunk/include/lldb/API/SBBreakpoint.h lldb/trunk/include/lldb/API/SBBreakpointLocation.h lldb/trunk/include/lldb/API/SBBroadcaster.h lldb/trunk/include/lldb/API/SBCommandContext.h lldb/trunk/include/lldb/API/SBCommandInterpreter.h lldb/trunk/include/lldb/API/SBCommandReturnObject.h lldb/trunk/include/lldb/API/SBCommunication.h lldb/trunk/include/lldb/API/SBCompileUnit.h lldb/trunk/include/lldb/API/SBDebugger.h lldb/trunk/include/lldb/API/SBError.h lldb/trunk/include/lldb/API/SBEvent.h lldb/trunk/include/lldb/API/SBFileSpec.h lldb/trunk/include/lldb/API/SBFrame.h lldb/trunk/include/lldb/API/SBFunction.h lldb/trunk/include/lldb/API/SBInputReader.h lldb/trunk/include/lldb/API/SBInstruction.h lldb/trunk/include/lldb/API/SBLineEntry.h lldb/trunk/include/lldb/API/SBListener.h lldb/trunk/include/lldb/API/SBModule.h lldb/trunk/include/lldb/API/SBProcess.h lldb/trunk/include/lldb/API/SBSourceManager.h lldb/trunk/include/lldb/API/SBStringList.h lldb/trunk/include/lldb/API/SBSymbol.h lldb/trunk/include/lldb/API/SBSymbolContext.h lldb/trunk/include/lldb/API/SBTarget.h lldb/trunk/include/lldb/API/SBThread.h lldb/trunk/include/lldb/API/SBValue.h lldb/trunk/include/lldb/API/SBValueList.h lldb/trunk/include/lldb/Breakpoint/StoppointCallbackContext.h lldb/trunk/include/lldb/Core/Debugger.h lldb/trunk/include/lldb/Core/Disassembler.h lldb/trunk/include/lldb/Core/InputReader.h lldb/trunk/include/lldb/Interpreter/CommandCompletions.h lldb/trunk/include/lldb/Interpreter/CommandInterpreter.h lldb/trunk/include/lldb/Interpreter/CommandObject.h lldb/trunk/include/lldb/Interpreter/CommandObjectCrossref.h lldb/trunk/include/lldb/Interpreter/CommandObjectMultiword.h lldb/trunk/include/lldb/Interpreter/CommandObjectRegexCommand.h lldb/trunk/include/lldb/Interpreter/Options.h lldb/trunk/include/lldb/Interpreter/ScriptInterpreter.h lldb/trunk/include/lldb/Interpreter/ScriptInterpreterNone.h lldb/trunk/include/lldb/Interpreter/ScriptInterpreterPython.h lldb/trunk/include/lldb/Target/Target.h lldb/trunk/include/lldb/Target/TargetList.h lldb/trunk/include/lldb/lldb-forward-rtti.h lldb/trunk/include/lldb/lldb-forward.h lldb/trunk/lldb.xcodeproj/project.pbxproj lldb/trunk/source/API/SBAddress.cpp lldb/trunk/source/API/SBBlock.cpp lldb/trunk/source/API/SBBreakpoint.cpp lldb/trunk/source/API/SBBreakpointLocation.cpp lldb/trunk/source/API/SBBroadcaster.cpp lldb/trunk/source/API/SBCommandContext.cpp lldb/trunk/source/API/SBCommandInterpreter.cpp lldb/trunk/source/API/SBCommandReturnObject.cpp lldb/trunk/source/API/SBCommunication.cpp lldb/trunk/source/API/SBCompileUnit.cpp lldb/trunk/source/API/SBDebugger.cpp lldb/trunk/source/API/SBError.cpp lldb/trunk/source/API/SBEvent.cpp lldb/trunk/source/API/SBFileSpec.cpp lldb/trunk/source/API/SBFrame.cpp lldb/trunk/source/API/SBFunction.cpp lldb/trunk/source/API/SBInputReader.cpp lldb/trunk/source/API/SBInstruction.cpp lldb/trunk/source/API/SBLineEntry.cpp lldb/trunk/source/API/SBListener.cpp lldb/trunk/source/API/SBModule.cpp lldb/trunk/source/API/SBProcess.cpp lldb/trunk/source/API/SBSourceManager.cpp lldb/trunk/source/API/SBStringList.cpp lldb/trunk/source/API/SBSymbol.cpp lldb/trunk/source/API/SBSymbolContext.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/Breakpoint/StoppointCallbackContext.cpp lldb/trunk/source/Commands/CommandCompletions.cpp lldb/trunk/source/Commands/CommandObjectAlias.cpp lldb/trunk/source/Commands/CommandObjectAlias.h lldb/trunk/source/Commands/CommandObjectAppend.cpp lldb/trunk/source/Commands/CommandObjectAppend.h lldb/trunk/source/Commands/CommandObjectApropos.cpp lldb/trunk/source/Commands/CommandObjectApropos.h lldb/trunk/source/Commands/CommandObjectArgs.cpp lldb/trunk/source/Commands/CommandObjectArgs.h lldb/trunk/source/Commands/CommandObjectBreakpoint.cpp lldb/trunk/source/Commands/CommandObjectBreakpoint.h lldb/trunk/source/Commands/CommandObjectBreakpointCommand.cpp lldb/trunk/source/Commands/CommandObjectBreakpointCommand.h lldb/trunk/source/Commands/CommandObjectCall.cpp lldb/trunk/source/Commands/CommandObjectCall.h lldb/trunk/source/Commands/CommandObjectCrossref.cpp lldb/trunk/source/Commands/CommandObjectDisassemble.cpp lldb/trunk/source/Commands/CommandObjectDisassemble.h lldb/trunk/source/Commands/CommandObjectExpression.cpp lldb/trunk/source/Commands/CommandObjectExpression.h lldb/trunk/source/Commands/CommandObjectFile.cpp lldb/trunk/source/Commands/CommandObjectFile.h lldb/trunk/source/Commands/CommandObjectFrame.cpp lldb/trunk/source/Commands/CommandObjectFrame.h lldb/trunk/source/Commands/CommandObjectHelp.cpp lldb/trunk/source/Commands/CommandObjectHelp.h lldb/trunk/source/Commands/CommandObjectImage.cpp lldb/trunk/source/Commands/CommandObjectImage.h lldb/trunk/source/Commands/CommandObjectLog.cpp lldb/trunk/source/Commands/CommandObjectLog.h lldb/trunk/source/Commands/CommandObjectMemory.cpp lldb/trunk/source/Commands/CommandObjectMemory.h lldb/trunk/source/Commands/CommandObjectMultiword.cpp lldb/trunk/source/Commands/CommandObjectProcess.cpp lldb/trunk/source/Commands/CommandObjectProcess.h lldb/trunk/source/Commands/CommandObjectQuit.cpp lldb/trunk/source/Commands/CommandObjectQuit.h lldb/trunk/source/Commands/CommandObjectRegister.cpp lldb/trunk/source/Commands/CommandObjectRegister.h lldb/trunk/source/Commands/CommandObjectSet.cpp lldb/trunk/source/Commands/CommandObjectSet.h lldb/trunk/source/Commands/CommandObjectSettings.cpp lldb/trunk/source/Commands/CommandObjectSettings.h lldb/trunk/source/Commands/CommandObjectShow.cpp lldb/trunk/source/Commands/CommandObjectShow.h lldb/trunk/source/Commands/CommandObjectSource.cpp lldb/trunk/source/Commands/CommandObjectSource.h lldb/trunk/source/Commands/CommandObjectSourceFile.cpp lldb/trunk/source/Commands/CommandObjectSourceFile.h lldb/trunk/source/Commands/CommandObjectSyntax.cpp lldb/trunk/source/Commands/CommandObjectSyntax.h lldb/trunk/source/Commands/CommandObjectTarget.cpp lldb/trunk/source/Commands/CommandObjectTarget.h lldb/trunk/source/Commands/CommandObjectThread.cpp lldb/trunk/source/Commands/CommandObjectThread.h lldb/trunk/source/Commands/CommandObjectUnalias.cpp lldb/trunk/source/Commands/CommandObjectUnalias.h lldb/trunk/source/Commands/CommandObjectVariable.cpp lldb/trunk/source/Commands/CommandObjectVariable.h lldb/trunk/source/Core/Debugger.cpp lldb/trunk/source/Core/Disassembler.cpp lldb/trunk/source/Core/InputReader.cpp lldb/trunk/source/Core/Log.cpp lldb/trunk/source/Interpreter/CommandInterpreter.cpp lldb/trunk/source/Interpreter/CommandObject.cpp lldb/trunk/source/Interpreter/CommandObjectRegexCommand.cpp lldb/trunk/source/Interpreter/CommandObjectScript.cpp lldb/trunk/source/Interpreter/CommandObjectScript.h lldb/trunk/source/Interpreter/Options.cpp lldb/trunk/source/Interpreter/ScriptInterpreterNone.cpp lldb/trunk/source/Interpreter/ScriptInterpreterPython.cpp lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp lldb/trunk/source/Target/Process.cpp lldb/trunk/source/Target/StackFrame.cpp lldb/trunk/source/Target/Target.cpp lldb/trunk/source/Target/TargetList.cpp lldb/trunk/tools/driver/Driver.cpp lldb/trunk/tools/driver/Driver.h lldb/trunk/tools/driver/IOChannel.cpp Modified: lldb/trunk/include/lldb/API/SBAddress.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBAddress.h?rev=106615&r1=106614&r2=106615&view=diff ============================================================================== --- lldb/trunk/include/lldb/API/SBAddress.h (original) +++ lldb/trunk/include/lldb/API/SBAddress.h Tue Jun 22 20:19:29 2010 @@ -66,7 +66,7 @@ private: - std::auto_ptr m_lldb_object_ap; + std::auto_ptr m_opaque_ap; }; Modified: lldb/trunk/include/lldb/API/SBBlock.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBBlock.h?rev=106615&r1=106614&r2=106615&view=diff ============================================================================== --- lldb/trunk/include/lldb/API/SBBlock.h (original) +++ lldb/trunk/include/lldb/API/SBBlock.h Tue Jun 22 20:19:29 2010 @@ -35,7 +35,7 @@ SBBlock (lldb_private::Block *lldb_object_ptr); - lldb_private::Block *m_lldb_object_ptr; + lldb_private::Block *m_opaque_ptr; }; Modified: lldb/trunk/include/lldb/API/SBBreakpoint.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBBreakpoint.h?rev=106615&r1=106614&r2=106615&view=diff ============================================================================== --- lldb/trunk/include/lldb/API/SBBreakpoint.h (original) +++ lldb/trunk/include/lldb/API/SBBreakpoint.h Tue Jun 22 20:19:29 2010 @@ -140,7 +140,7 @@ lldb::user_id_t break_id, lldb::user_id_t break_loc_id); - lldb::BreakpointSP m_break_sp; + lldb::BreakpointSP m_opaque_sp; }; } // namespace lldb Modified: lldb/trunk/include/lldb/API/SBBreakpointLocation.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBBreakpointLocation.h?rev=106615&r1=106614&r2=106615&view=diff ============================================================================== --- lldb/trunk/include/lldb/API/SBBreakpointLocation.h (original) +++ lldb/trunk/include/lldb/API/SBBreakpointLocation.h Tue Jun 22 20:19:29 2010 @@ -82,7 +82,7 @@ void SetLocation (const lldb::BreakpointLocationSP &break_loc_sp); - lldb::BreakpointLocationSP m_break_loc_sp; + lldb::BreakpointLocationSP m_opaque_sp; }; Modified: lldb/trunk/include/lldb/API/SBBroadcaster.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBBroadcaster.h?rev=106615&r1=106614&r2=106615&view=diff ============================================================================== --- lldb/trunk/include/lldb/API/SBBroadcaster.h (original) +++ lldb/trunk/include/lldb/API/SBBroadcaster.h Tue Jun 22 20:19:29 2010 @@ -66,16 +66,20 @@ SBBroadcaster (lldb_private::Broadcaster *broadcaster, bool owns); +#ifndef SWIG + lldb_private::Broadcaster * - GetLLDBObjectPtr () const; + get () const; void - SetLLDBObjectPtr (lldb_private::Broadcaster *broadcaster, bool owns); + reset (lldb_private::Broadcaster *broadcaster, bool owns); + +#endif private: - lldb_private::Broadcaster *m_lldb_object; - bool m_lldb_object_owned; + lldb_private::Broadcaster *m_opaque; + bool m_opaque_owned; }; } // namespace lldb Modified: lldb/trunk/include/lldb/API/SBCommandContext.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBCommandContext.h?rev=106615&r1=106614&r2=106615&view=diff ============================================================================== --- lldb/trunk/include/lldb/API/SBCommandContext.h (original) +++ lldb/trunk/include/lldb/API/SBCommandContext.h Tue Jun 22 20:19:29 2010 @@ -19,7 +19,7 @@ { public: - SBCommandContext (lldb_private::CommandContext *lldb_object); + SBCommandContext (lldb_private::Debugger *lldb_object); ~SBCommandContext (); @@ -28,7 +28,7 @@ private: - lldb_private::CommandContext *m_lldb_object; + lldb_private::Debugger *m_opaque; }; } // namespace lldb Modified: lldb/trunk/include/lldb/API/SBCommandInterpreter.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBCommandInterpreter.h?rev=106615&r1=106614&r2=106615&view=diff ============================================================================== --- lldb/trunk/include/lldb/API/SBCommandInterpreter.h (original) +++ lldb/trunk/include/lldb/API/SBCommandInterpreter.h Tue Jun 22 20:19:29 2010 @@ -28,6 +28,9 @@ ~SBCommandInterpreter (); bool + IsValid() const; + + bool CommandExists (const char *cmd); bool @@ -86,17 +89,20 @@ protected: lldb_private::CommandInterpreter & - GetLLDBObjectRef (); + ref (); lldb_private::CommandInterpreter * - GetLLDBObjectPtr (); + get (); + void + reset (lldb_private::CommandInterpreter *); private: friend class SBDebugger; - SBCommandInterpreter (lldb_private::CommandInterpreter &interpreter_ptr); // Access using SBDebugger::GetSharedInstance().GetCommandInterpreter(); + SBCommandInterpreter (lldb_private::CommandInterpreter *interpreter_ptr = NULL); // Access using SBDebugger::GetCommandInterpreter(); - lldb_private::CommandInterpreter &m_interpreter; + + lldb_private::CommandInterpreter *m_opaque_ptr; }; Modified: lldb/trunk/include/lldb/API/SBCommandReturnObject.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBCommandReturnObject.h?rev=106615&r1=106614&r2=106615&view=diff ============================================================================== --- lldb/trunk/include/lldb/API/SBCommandReturnObject.h (original) +++ lldb/trunk/include/lldb/API/SBCommandReturnObject.h Tue Jun 22 20:19:29 2010 @@ -62,17 +62,27 @@ friend class SBCommandInterpreter; friend class SBOptions; + +#ifndef SWIG + + lldb_private::CommandReturnObject * + operator->() const; + lldb_private::CommandReturnObject * - GetLLDBObjectPtr(); + get() const; + + lldb_private::CommandReturnObject & + operator*() const; lldb_private::CommandReturnObject & - GetLLDBObjectRef(); + ref() const; +#endif void SetLLDBObjectPtr (lldb_private::CommandReturnObject *ptr); private: - std::auto_ptr m_return_object_ap; + std::auto_ptr m_opaque_ap; }; } // namespace lldb Modified: lldb/trunk/include/lldb/API/SBCommunication.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBCommunication.h?rev=106615&r1=106614&r2=106615&view=diff ============================================================================== --- lldb/trunk/include/lldb/API/SBCommunication.h (original) +++ lldb/trunk/include/lldb/API/SBCommunication.h Tue Jun 22 20:19:29 2010 @@ -87,8 +87,8 @@ // void // CreateIfNeeded (); - lldb_private::Communication *m_lldb_object; - bool m_lldb_object_owned; + lldb_private::Communication *m_opaque; + bool m_opaque_owned; }; Modified: lldb/trunk/include/lldb/API/SBCompileUnit.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBCompileUnit.h?rev=106615&r1=106614&r2=106615&view=diff ============================================================================== --- lldb/trunk/include/lldb/API/SBCompileUnit.h (original) +++ lldb/trunk/include/lldb/API/SBCompileUnit.h Tue Jun 22 20:19:29 2010 @@ -66,7 +66,7 @@ #endif - lldb_private::CompileUnit *m_lldb_object_ptr; + lldb_private::CompileUnit *m_opaque_ptr; }; Modified: lldb/trunk/include/lldb/API/SBDebugger.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBDebugger.h?rev=106615&r1=106614&r2=106615&view=diff ============================================================================== --- lldb/trunk/include/lldb/API/SBDebugger.h (original) +++ lldb/trunk/include/lldb/API/SBDebugger.h Tue Jun 22 20:19:29 2010 @@ -25,95 +25,90 @@ static void Terminate(); - static void - SetAsync (bool b); + static SBDebugger + Create(); - static void - SetInputFile (const char *tty_name); // DEPRECATED: will be removed in next submission + ~SBDebugger(); - static void - SetOutputFile (const char *tty_name); // DEPRECATED: will be removed in next submission + bool + IsValid() const; - static void - SetErrorFile (const char *tty_name); // DEPRECATED: will be removed in next submission + void + SetAsync (bool b); - static void + void SetInputFileHandle (FILE *f, bool transfer_ownership); - static void + void SetOutputFileHandle (FILE *f, bool transfer_ownership); - static void + void SetErrorFileHandle (FILE *f, bool transfer_ownership); - static FILE * + FILE * GetInputFileHandle (); - static FILE * + FILE * GetOutputFileHandle (); - static FILE * + FILE * GetErrorFileHandle (); - static lldb::SBCommandInterpreter + lldb::SBCommandInterpreter GetCommandInterpreter (); - static void + void HandleCommand (const char *command); - static lldb::SBListener + lldb::SBListener GetListener (); - static void + void HandleProcessEvent (const lldb::SBProcess &process, const lldb::SBEvent &event, FILE *out, FILE *err); - static lldb::SBTarget + lldb::SBTarget CreateTargetWithFileAndTargetTriple (const char *filename, const char *target_triple); - static lldb::SBTarget + lldb::SBTarget CreateTargetWithFileAndArch (const char *filename, const char *archname); - static lldb::SBTarget + lldb::SBTarget CreateTarget (const char *filename); - static lldb::SBTarget + lldb::SBTarget GetTargetAtIndex (uint32_t idx); - static lldb::SBTarget + lldb::SBTarget FindTargetWithProcessID (pid_t pid); - static lldb::SBTarget + lldb::SBTarget FindTargetWithFileAndArch (const char *filename, const char *arch); - static uint32_t + uint32_t GetNumTargets (); - static lldb::SBTarget + lldb::SBTarget GetCurrentTarget (); - static void + void UpdateCurrentThread (lldb::SBProcess &process); - static void - ReportCurrentLocation (FILE *out = stdout, - FILE *err = stderr); - - static lldb::SBSourceManager & + lldb::SBSourceManager & GetSourceManager (); - static bool + bool GetDefaultArchitecture (char *arch_name, size_t arch_name_len); - static bool + bool SetDefaultArchitecture (const char *arch_name); - static lldb::ScriptLanguage + lldb::ScriptLanguage GetScriptingLanguage (const char *script_language_name); static const char * @@ -128,19 +123,39 @@ static bool StateIsStoppedState (lldb::StateType state); - static void + void DispatchInput (void *baton, const void *data, size_t data_len); - static void + void PushInputReader (lldb::SBInputReader &reader); private: + + // Use the static function: SBDebugger::Create(); + SBDebugger(); + #ifndef SWIG - friend class SBProcess; - static lldb::SBTarget + friend class SBInputReader; + friend class SBProcess; + friend class SBTarget; + + lldb::SBTarget FindTargetWithLLDBProcess (const lldb::ProcessSP &processSP); + + void + reset (const lldb::DebuggerSP &debugger_sp); + + lldb_private::Debugger * + get () const; + + lldb_private::Debugger & + ref () const; + #endif + + lldb::DebuggerSP m_opaque_sp; + }; // class SBDebugger Modified: lldb/trunk/include/lldb/API/SBError.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBError.h?rev=106615&r1=106614&r2=106615&view=diff ============================================================================== --- lldb/trunk/include/lldb/API/SBError.h (original) +++ lldb/trunk/include/lldb/API/SBError.h Tue Jun 22 20:19:29 2010 @@ -90,7 +90,7 @@ SetError (const lldb_private::Error &lldb_error); private: - std::auto_ptr m_lldb_object_ap; + std::auto_ptr m_opaque_ap; void CreateIfNeeded (); Modified: lldb/trunk/include/lldb/API/SBEvent.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBEvent.h?rev=106615&r1=106614&r2=106615&view=diff ============================================================================== --- lldb/trunk/include/lldb/API/SBEvent.h (original) +++ lldb/trunk/include/lldb/API/SBEvent.h Tue Jun 22 20:19:29 2010 @@ -64,25 +64,26 @@ SBEvent (lldb::EventSP &event_sp); +#ifndef SWIG + lldb::EventSP & - GetSharedPtr () const; + GetSP () const; void - SetEventSP (lldb::EventSP &event_sp); + reset (lldb::EventSP &event_sp); void - SetLLDBObjectPtr (lldb_private::Event* event); + reset (lldb_private::Event* event); lldb_private::Event * - GetLLDBObjectPtr (); + get () const; - const lldb_private::Event * - GetLLDBObjectPtr () const; +#endif private: mutable lldb::EventSP m_event_sp; - mutable lldb_private::Event *m_lldb_object; + mutable lldb_private::Event *m_opaque; }; } // namespace lldb Modified: lldb/trunk/include/lldb/API/SBFileSpec.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBFileSpec.h?rev=106615&r1=106614&r2=106615&view=diff ============================================================================== --- lldb/trunk/include/lldb/API/SBFileSpec.h (original) +++ lldb/trunk/include/lldb/API/SBFileSpec.h Tue Jun 22 20:19:29 2010 @@ -54,6 +54,7 @@ friend class SBHostOS; friend class SBModule; friend class SBSourceManager; + friend class SBThread; friend class SBTarget; void @@ -74,7 +75,7 @@ #endif - std::auto_ptr m_lldb_object_ap; + std::auto_ptr m_opaque_ap; }; Modified: lldb/trunk/include/lldb/API/SBFrame.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBFrame.h?rev=106615&r1=106614&r2=106615&view=diff ============================================================================== --- lldb/trunk/include/lldb/API/SBFrame.h (original) +++ lldb/trunk/include/lldb/API/SBFrame.h Tue Jun 22 20:19:29 2010 @@ -122,7 +122,7 @@ void SetFrame (const lldb::StackFrameSP &lldb_object_sp); - lldb::StackFrameSP m_lldb_object_sp; + lldb::StackFrameSP m_opaque_sp; }; } // namespace lldb Modified: lldb/trunk/include/lldb/API/SBFunction.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBFunction.h?rev=106615&r1=106614&r2=106615&view=diff ============================================================================== --- lldb/trunk/include/lldb/API/SBFunction.h (original) +++ lldb/trunk/include/lldb/API/SBFunction.h Tue Jun 22 20:19:29 2010 @@ -46,7 +46,7 @@ SBFunction (lldb_private::Function *lldb_object_ptr); - lldb_private::Function *m_lldb_object_ptr; + lldb_private::Function *m_opaque_ptr; }; Modified: lldb/trunk/include/lldb/API/SBInputReader.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBInputReader.h?rev=106615&r1=106614&r2=106615&view=diff ============================================================================== --- lldb/trunk/include/lldb/API/SBInputReader.h (original) +++ lldb/trunk/include/lldb/API/SBInputReader.h Tue Jun 22 20:19:29 2010 @@ -36,7 +36,8 @@ SBError - Initialize (Callback callback, + Initialize (SBDebugger &debugger, + Callback callback, void *callback_baton, lldb::InputReaderGranularity granularity, const char *end_token, @@ -76,21 +77,26 @@ const lldb::InputReaderSP & operator *() const; -#endif lldb_private::InputReader * get() const; + lldb_private::InputReader & + ref() const; + +#endif + + private: static size_t PrivateCallback (void *baton, - lldb_private::InputReader *reader, + lldb_private::InputReader &reader, lldb::InputReaderAction notification, const char *bytes, size_t bytes_len); - lldb::InputReaderSP m_reader_sp; + lldb::InputReaderSP m_opaque_sp; Callback m_callback_function; void *m_callback_baton; }; Modified: lldb/trunk/include/lldb/API/SBInstruction.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBInstruction.h?rev=106615&r1=106614&r2=106615&view=diff ============================================================================== --- lldb/trunk/include/lldb/API/SBInstruction.h (original) +++ lldb/trunk/include/lldb/API/SBInstruction.h Tue Jun 22 20:19:29 2010 @@ -48,7 +48,7 @@ private: - //lldb_private::Disassembler::Instruction::SharedPtr m_lldb_object_sp; + //lldb_private::Disassembler::Instruction::SharedPtr m_opaque_sp; }; Modified: lldb/trunk/include/lldb/API/SBLineEntry.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBLineEntry.h?rev=106615&r1=106614&r2=106615&view=diff ============================================================================== --- lldb/trunk/include/lldb/API/SBLineEntry.h (original) +++ lldb/trunk/include/lldb/API/SBLineEntry.h Tue Jun 22 20:19:29 2010 @@ -79,7 +79,7 @@ void SetLineEntry (const lldb_private::LineEntry &lldb_object_ref); - std::auto_ptr m_lldb_object_ap; + std::auto_ptr m_opaque_ap; }; Modified: lldb/trunk/include/lldb/API/SBListener.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBListener.h?rev=106615&r1=106614&r2=106615&view=diff ============================================================================== --- lldb/trunk/include/lldb/API/SBListener.h (original) +++ lldb/trunk/include/lldb/API/SBListener.h Tue Jun 22 20:19:29 2010 @@ -106,12 +106,15 @@ const lldb_private::Listener & operator *() const; + void + reset(lldb_private::Listener *listener, bool transfer_ownership); + #endif - lldb_private::Listener *m_lldb_object_ptr; - bool m_lldb_object_ptr_owned; + lldb_private::Listener *m_opaque_ptr; + bool m_opaque_ptr_owned; }; } // namespace lldb Modified: lldb/trunk/include/lldb/API/SBModule.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBModule.h?rev=106615&r1=106614&r2=106615&view=diff ============================================================================== --- lldb/trunk/include/lldb/API/SBModule.h (original) +++ lldb/trunk/include/lldb/API/SBModule.h Tue Jun 22 20:19:29 2010 @@ -70,7 +70,7 @@ #endif - lldb::ModuleSP m_lldb_object_sp; + lldb::ModuleSP m_opaque_sp; }; Modified: lldb/trunk/include/lldb/API/SBProcess.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBProcess.h?rev=106615&r1=106614&r2=106615&view=diff ============================================================================== --- lldb/trunk/include/lldb/API/SBProcess.h (original) +++ lldb/trunk/include/lldb/API/SBProcess.h Tue Jun 22 20:19:29 2010 @@ -106,12 +106,6 @@ SBError Destroy (); - void - DisplayThreadsInfo (FILE *out = NULL, FILE *err = NULL, bool only_threads_with_stop_reason = true); - - void - ListThreads (); - bool WaitUntilProcessHasStopped (lldb::SBCommandReturnObject &result); @@ -139,9 +133,6 @@ SBError Signal (int signal); - void - Backtrace (bool all_threads = false, uint32_t num_frames = 0); - size_t ReadMemory (addr_t addr, void *buf, size_t size, SBError &error); @@ -188,7 +179,7 @@ void SetProcess (const lldb::ProcessSP &process_sp); - lldb::ProcessSP m_lldb_object_sp; + lldb::ProcessSP m_opaque_sp; }; } // namespace lldb Modified: lldb/trunk/include/lldb/API/SBSourceManager.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBSourceManager.h?rev=106615&r1=106614&r2=106615&view=diff ============================================================================== --- lldb/trunk/include/lldb/API/SBSourceManager.h (original) +++ lldb/trunk/include/lldb/API/SBSourceManager.h Tue Jun 22 20:19:29 2010 @@ -41,7 +41,7 @@ private: - lldb_private::SourceManager &m_source_manager; + lldb_private::SourceManager &m_opaque_ref; }; } // namespace lldb Modified: lldb/trunk/include/lldb/API/SBStringList.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBStringList.h?rev=106615&r1=106614&r2=106615&view=diff ============================================================================== --- lldb/trunk/include/lldb/API/SBStringList.h (original) +++ lldb/trunk/include/lldb/API/SBStringList.h Tue Jun 22 20:19:29 2010 @@ -62,7 +62,7 @@ private: - std::auto_ptr m_lldb_object_ap; + std::auto_ptr m_opaque_ap; }; Modified: lldb/trunk/include/lldb/API/SBSymbol.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBSymbol.h?rev=106615&r1=106614&r2=106615&view=diff ============================================================================== --- lldb/trunk/include/lldb/API/SBSymbol.h (original) +++ lldb/trunk/include/lldb/API/SBSymbol.h Tue Jun 22 20:19:29 2010 @@ -46,7 +46,7 @@ SBSymbol (lldb_private::Symbol *lldb_object_ptr); - lldb_private::Symbol *m_lldb_object_ptr; + lldb_private::Symbol *m_opaque_ptr; }; Modified: lldb/trunk/include/lldb/API/SBSymbolContext.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBSymbolContext.h?rev=106615&r1=106614&r2=106615&view=diff ============================================================================== --- lldb/trunk/include/lldb/API/SBSymbolContext.h (original) +++ lldb/trunk/include/lldb/API/SBSymbolContext.h Tue Jun 22 20:19:29 2010 @@ -64,7 +64,7 @@ SetSymbolContext (const lldb_private::SymbolContext *sc_ptr); private: - std::auto_ptr m_lldb_object_ap; + std::auto_ptr m_opaque_ap; }; Modified: lldb/trunk/include/lldb/API/SBTarget.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBTarget.h?rev=106615&r1=106614&r2=106615&view=diff ============================================================================== --- lldb/trunk/include/lldb/API/SBTarget.h (original) +++ lldb/trunk/include/lldb/API/SBTarget.h Tue Jun 22 20:19:29 2010 @@ -70,6 +70,9 @@ lldb::SBModule GetModuleAtIndex (uint32_t idx); + lldb::SBDebugger + GetDebugger() const; + lldb::SBModule FindModule (const lldb::SBFileSpec &file_spec); @@ -146,20 +149,20 @@ SBTarget (const lldb::TargetSP& target_sp); void - SetLLBDTarget (const lldb::TargetSP& target_sp); + reset (const lldb::TargetSP& target_sp); lldb_private::Target * - GetLLDBObjectPtr(); + operator ->() const; - const lldb_private::Target * - GetLLDBObjectPtr() const; + lldb_private::Target * + get() const; private: //------------------------------------------------------------------ // For Target only //------------------------------------------------------------------ - lldb::TargetSP m_target_sp; + lldb::TargetSP m_opaque_sp; }; } // namespace lldb Modified: lldb/trunk/include/lldb/API/SBThread.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBThread.h?rev=106615&r1=106614&r2=106615&view=diff ============================================================================== --- lldb/trunk/include/lldb/API/SBThread.h (original) +++ lldb/trunk/include/lldb/API/SBThread.h Tue Jun 22 20:19:29 2010 @@ -82,9 +82,6 @@ void RunToAddress (lldb::addr_t addr); - void - Backtrace (uint32_t num_frames = 0); - uint32_t GetNumFrames (); @@ -146,7 +143,7 @@ // Classes that inherit from Thread can see and modify these //------------------------------------------------------------------ - lldb::ThreadSP m_lldb_object_sp; + lldb::ThreadSP m_opaque_sp; }; } // namespace lldb Modified: lldb/trunk/include/lldb/API/SBValue.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBValue.h?rev=106615&r1=106614&r2=106615&view=diff ============================================================================== --- lldb/trunk/include/lldb/API/SBValue.h (original) +++ lldb/trunk/include/lldb/API/SBValue.h Tue Jun 22 20:19:29 2010 @@ -112,11 +112,11 @@ #endif private: - - lldb_private::ExecutionContext - GetCurrentExecutionContext (); - - lldb::ValueObjectSP m_lldb_object_sp; +// +// lldb_private::ExecutionContext +// GetCurrentExecutionContext (); +// + lldb::ValueObjectSP m_opaque_sp; }; } // namespace lldb Modified: lldb/trunk/include/lldb/API/SBValueList.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBValueList.h?rev=106615&r1=106614&r2=106615&view=diff ============================================================================== --- lldb/trunk/include/lldb/API/SBValueList.h (original) +++ lldb/trunk/include/lldb/API/SBValueList.h Tue Jun 22 20:19:29 2010 @@ -68,7 +68,7 @@ void CreateIfNeeded (); - std::auto_ptr m_lldb_object_ap; + std::auto_ptr m_opaque_ap; }; Modified: lldb/trunk/include/lldb/Breakpoint/StoppointCallbackContext.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Breakpoint/StoppointCallbackContext.h?rev=106615&r1=106614&r2=106615&view=diff ============================================================================== --- lldb/trunk/include/lldb/Breakpoint/StoppointCallbackContext.h (original) +++ lldb/trunk/include/lldb/Breakpoint/StoppointCallbackContext.h Tue Jun 22 20:19:29 2010 @@ -48,7 +48,7 @@ //------------------------------------------------------------------ Event *event; // This is the event, the callback can modify this to indicate // the meaning of the breakpoint hit - ExecutionContext context; // This tells us where we have stopped, what thread. + ExecutionContext exe_ctx; // This tells us where we have stopped, what thread. bool is_synchronous; // Is the callback being executed synchronously with the breakpoint, // or asynchronously as the event is retrieved? }; Modified: lldb/trunk/include/lldb/Core/Debugger.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/Debugger.h?rev=106615&r1=106614&r2=106615&view=diff ============================================================================== --- lldb/trunk/include/lldb/Core/Debugger.h (original) +++ lldb/trunk/include/lldb/Core/Debugger.h Tue Jun 22 20:19:29 2010 @@ -17,11 +17,11 @@ #include -#include "lldb/Interpreter/CommandInterpreter.h" #include "lldb/Core/Communication.h" #include "lldb/Core/Listener.h" #include "lldb/Core/StreamFile.h" #include "lldb/Core/SourceManager.h" +#include "lldb/Target/ExecutionContext.h" #include "lldb/Target/TargetList.h" namespace lldb_private { @@ -36,17 +36,23 @@ { public: + static lldb::DebuggerSP + CreateInstance (); + + static lldb::TargetSP + FindTargetWithProcessID (lldb::pid_t pid); + static void Initialize (); static void Terminate (); - static Debugger & - GetSharedInstance (); - ~Debugger (); + lldb::DebuggerSP + GetSP (); + bool GetAsyncExecution (); @@ -123,6 +129,16 @@ bool PopInputReader (const lldb::InputReaderSP& reader_sp); + ExecutionContext & + GetExecutionContext() + { + return m_exe_ctx; + } + + + void + UpdateExecutionContext (ExecutionContext *override_context); + protected: static void @@ -137,7 +153,6 @@ void DisconnectInput(); - bool m_async_execution; Communication m_input_comm; StreamFile m_input_file; StreamFile m_output_file; @@ -145,21 +160,19 @@ TargetList m_target_list; Listener m_listener; SourceManager m_source_manager; - CommandInterpreter m_command_interpreter; + std::auto_ptr m_command_interpreter_ap; + ExecutionContext m_exe_ctx; std::stack m_input_readers; std::string m_input_reader_data; - typedef lldb::SharedPtr::Type DebuggerSP; +private: + + // Use Debugger::CreateInstance() to get a shared pointer to a new + // debugger object + Debugger (); - static DebuggerSP & - GetDebuggerSP(); - - static int g_shared_debugger_refcount; - static bool g_in_terminate; -private: - Debugger (); // Access the single global instance of this class using Debugger::GetSharedInstance(); DISALLOW_COPY_AND_ASSIGN (Debugger); }; Modified: lldb/trunk/include/lldb/Core/Disassembler.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/Disassembler.h?rev=106615&r1=106614&r2=106615&view=diff ============================================================================== --- lldb/trunk/include/lldb/Core/Disassembler.h (original) +++ lldb/trunk/include/lldb/Core/Disassembler.h Tue Jun 22 20:19:29 2010 @@ -86,7 +86,8 @@ FindPlugin (const ArchSpec &arch); static bool - Disassemble (const ArchSpec &arch, + Disassemble (Debugger &debugger, + const ArchSpec &arch, const ExecutionContext &exe_ctx, uint32_t mixed_context_lines, Stream &strm); Modified: lldb/trunk/include/lldb/Core/InputReader.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/InputReader.h?rev=106615&r1=106614&r2=106615&view=diff ============================================================================== --- lldb/trunk/include/lldb/Core/InputReader.h (original) +++ lldb/trunk/include/lldb/Core/InputReader.h Tue Jun 22 20:19:29 2010 @@ -24,12 +24,12 @@ public: typedef size_t (*Callback) (void *baton, - InputReader *reader, + InputReader &reader, lldb::InputReaderAction notification, const char *bytes, size_t bytes_len); - InputReader (); + InputReader (Debugger &debugger); virtual ~InputReader (); @@ -71,11 +71,11 @@ virtual size_t HandleRawBytes (const char *bytes, size_t bytes_len); - FILE * - GetInputFileHandle (); - - FILE * - GetOutputFileHandle (); + Debugger & + GetDebugger() + { + return m_debugger; + } bool IsActive () const @@ -95,6 +95,7 @@ void Notify (lldb::InputReaderAction notification); + Debugger &m_debugger; Callback m_callback; void *m_callback_baton; std::string m_end_token; Modified: lldb/trunk/include/lldb/Interpreter/CommandCompletions.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Interpreter/CommandCompletions.h?rev=106615&r1=106614&r2=106615&view=diff ============================================================================== --- lldb/trunk/include/lldb/Interpreter/CommandCompletions.h (original) +++ lldb/trunk/include/lldb/Interpreter/CommandCompletions.h Tue Jun 22 20:19:29 2010 @@ -29,12 +29,12 @@ // This is the command completion callback that is used to complete the argument of the option // it is bound to (in the OptionDefinition table below). Return the total number of matches. //---------------------------------------------------------------------- - typedef int (*CompletionCallback) (const char *completion_str, // This is the argument we are completing - int match_start_point, // This is the point in the list of matches that you should start returning elements - int max_return_elements, // This is the number of matches requested. - lldb_private::CommandInterpreter *interpreter, // The command interpreter running this command. - lldb_private::SearchFilter *searcher, // A search filter to limit the search... - lldb_private::StringList &matches); // The array of matches we return. + typedef int (*CompletionCallback) (CommandInterpreter &interpreter, + const char *completion_str, // This is the argument we are completing + int match_start_point, // This is the point in the list of matches that you should start returning elements + int max_return_elements, // This is the number of matches requested. + lldb_private::SearchFilter *searcher,// A search filter to limit the search... + lldb_private::StringList &matches); // The array of matches we return. typedef enum { eNoCompletion = 0, @@ -54,41 +54,41 @@ CompletionCallback callback; }; - static bool InvokeCommonCompletionCallbacks (uint32_t completion_mask, - const char *completion_str, - int match_start_point, - int max_return_elements, - lldb_private::CommandInterpreter *interpreter, - SearchFilter *searcher, - StringList &matches); - + static bool InvokeCommonCompletionCallbacks (CommandInterpreter &interpreter, + uint32_t completion_mask, + const char *completion_str, + int match_start_point, + int max_return_elements, + SearchFilter *searcher, + StringList &matches); + //---------------------------------------------------------------------- // These are the generic completer functions: //---------------------------------------------------------------------- static int - SourceFiles (const char *partial_file_name, - int match_start_point, - int max_return_elements, - CommandInterpreter *interpreter, - SearchFilter *searcher, - StringList &matches); - + SourceFiles (CommandInterpreter &interpreter, + const char *partial_file_name, + int match_start_point, + int max_return_elements, + SearchFilter *searcher, + StringList &matches); + static int - Modules (const char *partial_file_name, - int match_start_point, - int max_return_elements, - lldb_private::CommandInterpreter *interpreter, - SearchFilter *searcher, - lldb_private::StringList &matches); - + Modules (CommandInterpreter &interpreter, + const char *partial_file_name, + int match_start_point, + int max_return_elements, + SearchFilter *searcher, + lldb_private::StringList &matches); + static int - Symbols (const char *partial_file_name, - int match_start_point, - int max_return_elements, - lldb_private::CommandInterpreter *interpreter, - SearchFilter *searcher, - lldb_private::StringList &matches); - + Symbols (CommandInterpreter &interpreter, + const char *partial_file_name, + int match_start_point, + int max_return_elements, + SearchFilter *searcher, + lldb_private::StringList &matches); + //---------------------------------------------------------------------- // The Completer class is a convenient base class for building searchers // that go along with the SearchFilter passed to the standard Completer @@ -97,10 +97,10 @@ class Completer : public Searcher { public: - Completer (const char *completion_str, + Completer (CommandInterpreter &interpreter, + const char *completion_str, int match_start_point, int max_return_elements, - CommandInterpreter *interpreter, StringList &matches); virtual ~Completer (); @@ -118,10 +118,10 @@ DoCompletion (SearchFilter *filter) = 0; protected: + CommandInterpreter &m_interpreter; std::string m_completion_str; int m_match_start_point; int m_max_return_elements; - CommandInterpreter *m_interpreter; StringList &m_matches; private: DISALLOW_COPY_AND_ASSIGN (Completer); @@ -134,13 +134,13 @@ { public: - SourceFileCompleter (bool include_support_files, - const char *completion_str, - int match_start_point, - int max_return_elements, - CommandInterpreter *interpreter, - StringList &matches); - + SourceFileCompleter (CommandInterpreter &interpreter, + bool include_support_files, + const char *completion_str, + int match_start_point, + int max_return_elements, + StringList &matches); + virtual Searcher::Depth GetDepth (); virtual Searcher::CallbackReturn @@ -168,12 +168,12 @@ { public: - ModuleCompleter (const char *completion_str, - int match_start_point, - int max_return_elements, - CommandInterpreter *interpreter, - StringList &matches); - + ModuleCompleter (CommandInterpreter &interpreter, + const char *completion_str, + int match_start_point, + int max_return_elements, + StringList &matches); + virtual Searcher::Depth GetDepth (); virtual Searcher::CallbackReturn @@ -199,12 +199,12 @@ { public: - SymbolCompleter (const char *completion_str, - int match_start_point, - int max_return_elements, - CommandInterpreter *interpreter, - StringList &matches); - + SymbolCompleter (CommandInterpreter &interpreter, + const char *completion_str, + int match_start_point, + int max_return_elements, + StringList &matches); + virtual Searcher::Depth GetDepth (); virtual Searcher::CallbackReturn @@ -217,15 +217,15 @@ DoCompletion (SearchFilter *filter); private: - struct NameCmp { - bool operator() (const ConstString& lhs, const ConstString& rhs) const - { - return lhs < rhs; - } - }; +// struct NameCmp { +// bool operator() (const ConstString& lhs, const ConstString& rhs) const +// { +// return lhs < rhs; +// } +// }; RegularExpression m_regex; - typedef std::set collection; + typedef std::set collection; collection m_match_set; DISALLOW_COPY_AND_ASSIGN (SymbolCompleter); Removed: lldb/trunk/include/lldb/Interpreter/CommandContext.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Interpreter/CommandContext.h?rev=106614&view=auto ============================================================================== --- lldb/trunk/include/lldb/Interpreter/CommandContext.h (original) +++ lldb/trunk/include/lldb/Interpreter/CommandContext.h (removed) @@ -1,43 +0,0 @@ -//===-- CommandContext.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_CommandContext_h_ -#define liblldb_CommandContext_h_ - -#include "lldb/lldb-private.h" -#include "lldb/Core/ArchSpec.h" -#include "lldb/Target/ExecutionContext.h" -#include "lldb/Core/FileSpec.h" -#include "lldb/Core/ValueObjectList.h" - -namespace lldb_private { - -class CommandContext -{ -public: - CommandContext (); - - ~CommandContext (); - - void - Update (ExecutionContext *override_context = NULL); - - Target * - GetTarget(); - - ExecutionContext & - GetExecutionContext(); - -private: - ExecutionContext m_exe_ctx; -}; - -} // namespace lldb_private - -#endif // liblldb_CommandContext_h_ Modified: lldb/trunk/include/lldb/Interpreter/CommandInterpreter.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Interpreter/CommandInterpreter.h?rev=106615&r1=106614&r2=106615&view=diff ============================================================================== --- lldb/trunk/include/lldb/Interpreter/CommandInterpreter.h (original) +++ lldb/trunk/include/lldb/Interpreter/CommandInterpreter.h Tue Jun 22 20:19:29 2010 @@ -16,8 +16,8 @@ // Project includes #include "lldb/lldb-private.h" #include "lldb/Core/Broadcaster.h" +#include "lldb/Core/Debugger.h" #include "lldb/Core/Log.h" -#include "lldb/Interpreter/CommandContext.h" #include "lldb/Interpreter/CommandObject.h" #include "lldb/Interpreter/ScriptInterpreter.h" #include "lldb/Interpreter/StateVariable.h" @@ -43,10 +43,9 @@ void SourceInitFile (bool in_cwd, CommandReturnObject &result); - CommandInterpreter (lldb::ScriptLanguage script_language, - bool synchronous_execution, - Listener *listener, // In case this is asked to create or attach to a process - SourceManager& source_manager); + CommandInterpreter (Debugger &debugger, + lldb::ScriptLanguage script_language, + bool synchronous_execution); virtual ~CommandInterpreter (); @@ -88,7 +87,9 @@ AddOrReplaceAliasOptions (const char *alias_name, OptionArgVectorSP &option_arg_vector_sp); bool - HandleCommand (const char *command_line, bool add_to_history, CommandReturnObject &result, + HandleCommand (const char *command_line, + bool add_to_history, + CommandReturnObject &result, ExecutionContext *override_context = NULL); // This handles command line completion. You are given a pointer to the command string buffer, to the current cursor, @@ -147,8 +148,11 @@ void ShowVariableHelp (CommandReturnObject &result); - CommandContext * - Context(); + Debugger & + GetDebugger () + { + return m_debugger; + } const Args * GetProgramArguments (); @@ -159,12 +163,6 @@ const char * ProcessEmbeddedScriptCommands (const char *arg); - Listener * - GetListener (); - - SourceManager & - GetSourceManager (); - const char * GetPrompt (); @@ -244,12 +242,9 @@ private: + Debugger &m_debugger; // The debugger session that this interpreter is associated with lldb::ScriptLanguage m_script_language; - CommandContext m_current_context; bool m_synchronous_execution; - Listener *m_listener; - SourceManager& m_source_manager; - CommandObject::CommandMap m_command_dict; // Stores basic built-in commands (they cannot be deleted, removed or overwritten). CommandObject::CommandMap m_alias_dict; // Stores user aliases/abbreviations for commands CommandObject::CommandMap m_user_dict; // Stores user-defined commands Modified: lldb/trunk/include/lldb/Interpreter/CommandObject.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Interpreter/CommandObject.h?rev=106615&r1=106614&r2=106615&view=diff ============================================================================== --- lldb/trunk/include/lldb/Interpreter/CommandObject.h (original) +++ lldb/trunk/include/lldb/Interpreter/CommandObject.h Tue Jun 22 20:19:29 2010 @@ -83,26 +83,23 @@ // Do not override this bool - ExecuteCommandString (const char *command, - CommandContext *context, - CommandInterpreter *interpreter, + ExecuteCommandString (CommandInterpreter &interpreter, + const char *command, CommandReturnObject &result); bool - ParseOptions(Args& args, - CommandInterpreter *interpreter, - CommandReturnObject &result); + ParseOptions (CommandInterpreter &interpreter, + Args& args, + CommandReturnObject &result); bool - ExecuteWithOptions (Args& command, - CommandContext *context, - CommandInterpreter *interpreter, + ExecuteWithOptions (CommandInterpreter &interpreter, + Args& command, CommandReturnObject &result); virtual bool - ExecuteRawCommandString (const char *command, - CommandContext *context, - CommandInterpreter *interpreter, + ExecuteRawCommandString (CommandInterpreter &interpreter, + const char *command, CommandReturnObject &result) { return false; @@ -110,9 +107,8 @@ virtual bool - Execute (Args& command, - CommandContext *context, - CommandInterpreter *interpreter, + Execute (CommandInterpreter &interpreter, + Args& command, CommandReturnObject &result) = 0; void @@ -134,12 +130,12 @@ // Don't override this method, override HandleArgumentCompletion instead unless // you have special reasons. virtual int - HandleCompletion (Args &input, + HandleCompletion (CommandInterpreter &interpreter, + Args &input, int &cursor_index, int &cursor_char_position, int match_start_point, int max_return_elements, - CommandInterpreter *interpreter, StringList &matches); // The input array contains a parsed version of the line. The insertion @@ -149,16 +145,18 @@ // helpful for the completion. virtual int - HandleArgumentCompletion (Args &input, - int &cursor_index, - int &cursor_char_position, - OptionElementVector &opt_element_vector, - int match_start_point, - int max_return_elements, - CommandInterpreter *interpreter, - StringList &matches); - - + HandleArgumentCompletion (CommandInterpreter &interpreter, + Args &input, + int &cursor_index, + int &cursor_char_position, + OptionElementVector &opt_element_vector, + int match_start_point, + int max_return_elements, + StringList &matches) + { + return 0; + } + bool HelpTextContainsWord (const char *search_word); Modified: lldb/trunk/include/lldb/Interpreter/CommandObjectCrossref.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Interpreter/CommandObjectCrossref.h?rev=106615&r1=106614&r2=106615&view=diff ============================================================================== --- lldb/trunk/include/lldb/Interpreter/CommandObjectCrossref.h (original) +++ lldb/trunk/include/lldb/Interpreter/CommandObjectCrossref.h Tue Jun 22 20:19:29 2010 @@ -37,9 +37,8 @@ GenerateHelpText (CommandReturnObject &result); virtual bool - Execute (Args& command, - CommandContext *context, - CommandInterpreter *interpreter, + Execute (CommandInterpreter &interpreter, + Args& command, CommandReturnObject &result); virtual bool Modified: lldb/trunk/include/lldb/Interpreter/CommandObjectMultiword.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Interpreter/CommandObjectMultiword.h?rev=106615&r1=106614&r2=106615&view=diff ============================================================================== --- lldb/trunk/include/lldb/Interpreter/CommandObjectMultiword.h (original) +++ lldb/trunk/include/lldb/Interpreter/CommandObjectMultiword.h Tue Jun 22 20:19:29 2010 @@ -28,10 +28,10 @@ { public: CommandObjectMultiword (const char *name, - const char *help = NULL, - const char *syntax = NULL, - uint32_t flags = 0); - + const char *help = NULL, + const char *syntax = NULL, + uint32_t flags = 0); + virtual ~CommandObjectMultiword (); @@ -39,10 +39,12 @@ IsMultiwordObject () { return true; } bool - LoadSubCommand (lldb::CommandObjectSP command_obj, const char *cmd_name, CommandInterpreter *interpreter); + LoadSubCommand (CommandInterpreter &interpreter, + const char *cmd_name, + const lldb::CommandObjectSP& command_obj); void - GenerateHelpText (CommandReturnObject &result, CommandInterpreter *interpreter); + GenerateHelpText (CommandInterpreter &interpreter, CommandReturnObject &result); lldb::CommandObjectSP GetSubcommandSP (const char *sub_cmd, StringList *matches = NULL); @@ -51,18 +53,17 @@ GetSubcommandObject (const char *sub_cmd, StringList *matches = NULL); virtual bool - Execute (Args& command, - CommandContext *context, - CommandInterpreter *interpreter, + Execute (CommandInterpreter &interpreter, + Args& command, CommandReturnObject &result); virtual int - HandleCompletion (Args &input, + HandleCompletion (CommandInterpreter &interpreter, + Args &input, int &cursor_index, int &cursor_char_position, int match_start_point, int max_return_elements, - CommandInterpreter *interpreter, StringList &matches); CommandObject::CommandMap m_subcommand_dict; Modified: lldb/trunk/include/lldb/Interpreter/CommandObjectRegexCommand.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Interpreter/CommandObjectRegexCommand.h?rev=106615&r1=106614&r2=106615&view=diff ============================================================================== --- lldb/trunk/include/lldb/Interpreter/CommandObjectRegexCommand.h (original) +++ lldb/trunk/include/lldb/Interpreter/CommandObjectRegexCommand.h Tue Jun 22 20:19:29 2010 @@ -35,18 +35,16 @@ ~CommandObjectRegexCommand (); virtual bool - Execute (Args& command, - CommandContext *context, - CommandInterpreter *interpreter, + Execute (CommandInterpreter &interpreter, + Args& command, CommandReturnObject &result); virtual bool WantsRawCommandString() { return true; } virtual bool - ExecuteRawCommandString (const char *command, - CommandContext *context, - CommandInterpreter *interpreter, + ExecuteRawCommandString (CommandInterpreter &interpreter, + const char *command, CommandReturnObject &result); Modified: lldb/trunk/include/lldb/Interpreter/Options.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Interpreter/Options.h?rev=106615&r1=106614&r2=106615&view=diff ============================================================================== --- lldb/trunk/include/lldb/Interpreter/Options.h (original) +++ lldb/trunk/include/lldb/Interpreter/Options.h Tue Jun 22 20:19:29 2010 @@ -218,13 +218,13 @@ /// \btrue if we were in an option, \bfalse otherwise. //------------------------------------------------------------------ bool - HandleOptionCompletion (Args &input, + HandleOptionCompletion (CommandInterpreter &interpreter, + Args &input, OptionElementVector &option_map, int cursor_index, int char_pos, int match_start_point, int max_return_elements, - lldb_private::CommandInterpreter *interpreter, lldb_private::StringList &matches); //------------------------------------------------------------------ @@ -263,16 +263,16 @@ /// \btrue if we were in an option, \bfalse otherwise. //------------------------------------------------------------------ virtual bool - HandleOptionArgumentCompletion (Args &input, - int cursor_index, - int char_pos, - OptionElementVector &opt_element_vector, - int opt_element_index, - int match_start_point, - int max_return_elements, - CommandInterpreter *interpreter, - StringList &matches); - + HandleOptionArgumentCompletion (CommandInterpreter &interpreter, + Args &input, + int cursor_index, + int char_pos, + OptionElementVector &opt_element_vector, + int opt_element_index, + int match_start_point, + int max_return_elements, + StringList &matches); + protected: // This is a set of options expressed as indexes into the options table for this Option. typedef std::set OptionSet; Modified: lldb/trunk/include/lldb/Interpreter/ScriptInterpreter.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Interpreter/ScriptInterpreter.h?rev=106615&r1=106614&r2=106615&view=diff ============================================================================== --- lldb/trunk/include/lldb/Interpreter/ScriptInterpreter.h (original) +++ lldb/trunk/include/lldb/Interpreter/ScriptInterpreter.h Tue Jun 22 20:19:29 2010 @@ -43,10 +43,10 @@ virtual ~ScriptInterpreter (); virtual void - ExecuteOneLine (const std::string&, FILE *, FILE *) = 0; + ExecuteOneLine (CommandInterpreter &interpreter, const char *command) = 0; virtual void - ExecuteInterpreterLoop (FILE *, FILE *) = 0; + ExecuteInterpreterLoop (CommandInterpreter &interpreter) = 0; virtual bool ExecuteOneLineWithReturn (const char *in_string, ReturnType return_type, void *ret_value) Modified: lldb/trunk/include/lldb/Interpreter/ScriptInterpreterNone.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Interpreter/ScriptInterpreterNone.h?rev=106615&r1=106614&r2=106615&view=diff ============================================================================== --- lldb/trunk/include/lldb/Interpreter/ScriptInterpreterNone.h (original) +++ lldb/trunk/include/lldb/Interpreter/ScriptInterpreterNone.h Tue Jun 22 20:19:29 2010 @@ -18,15 +18,15 @@ { public: - ScriptInterpreterNone (); + ScriptInterpreterNone (CommandInterpreter &interpreter); ~ScriptInterpreterNone (); virtual void - ExecuteOneLine (const std::string &line, FILE *out, FILE *err); + ExecuteOneLine (CommandInterpreter &interpreter, const char *command); virtual void - ExecuteInterpreterLoop (FILE *out, FILE *err); + ExecuteInterpreterLoop (CommandInterpreter &interpreter); }; Modified: lldb/trunk/include/lldb/Interpreter/ScriptInterpreterPython.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Interpreter/ScriptInterpreterPython.h?rev=106615&r1=106614&r2=106615&view=diff ============================================================================== --- lldb/trunk/include/lldb/Interpreter/ScriptInterpreterPython.h (original) +++ lldb/trunk/include/lldb/Interpreter/ScriptInterpreterPython.h Tue Jun 22 20:19:29 2010 @@ -20,15 +20,15 @@ { public: - ScriptInterpreterPython (); + ScriptInterpreterPython (CommandInterpreter &interpreter); ~ScriptInterpreterPython (); void - ExecuteOneLine (const std::string &line, FILE *out, FILE *err); + ExecuteOneLine (CommandInterpreter &interpreter, const char *command); void - ExecuteInterpreterLoop (FILE *out, FILE *err); + ExecuteInterpreterLoop (CommandInterpreter &interpreter); bool ExecuteOneLineWithReturn (const char *in_string, @@ -46,7 +46,7 @@ static size_t GenerateBreakpointOptionsCommandCallback (void *baton, - InputReader *reader, + InputReader &reader, lldb::InputReaderAction notification, const char *bytes, size_t bytes_len); @@ -58,7 +58,8 @@ lldb::user_id_t break_loc_id); void - CollectDataForBreakpointCommandCallback (BreakpointOptions *bp_options, + CollectDataForBreakpointCommandCallback (CommandInterpreter &interpreter, + BreakpointOptions *bp_options, CommandReturnObject &result); StringList @@ -68,7 +69,7 @@ static size_t InputReaderCallback (void *baton, - InputReader *reader, + InputReader &reader, lldb::InputReaderAction notification, const char *bytes, size_t bytes_len); Modified: lldb/trunk/include/lldb/Target/Target.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/Target.h?rev=106615&r1=106614&r2=106615&view=diff ============================================================================== --- lldb/trunk/include/lldb/Target/Target.h (original) +++ lldb/trunk/include/lldb/Target/Target.h Tue Jun 22 20:19:29 2010 @@ -64,7 +64,7 @@ /// /// @see TargetList::CreateTarget(const FileSpec*, const ArchSpec*) //------------------------------------------------------------------ - Target(); + Target(Debugger &debugger); public: ~Target(); @@ -253,6 +253,12 @@ ArchSpec GetArchitecture () const; + Debugger & + GetDebugger () + { + return m_debugger; + } + bool GetTargetTriple (ConstString &target_triple); @@ -294,6 +300,7 @@ //------------------------------------------------------------------ // Member variables. //------------------------------------------------------------------ + Debugger & m_debugger; ModuleList m_images; ///< The list of images for this process (shared libraries and anything dynamically loaded). BreakpointList m_breakpoint_list; BreakpointList m_internal_breakpoint_list; Modified: lldb/trunk/include/lldb/Target/TargetList.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/TargetList.h?rev=106615&r1=106614&r2=106615&view=diff ============================================================================== --- lldb/trunk/include/lldb/Target/TargetList.h (original) +++ lldb/trunk/include/lldb/Target/TargetList.h Tue Jun 22 20:19:29 2010 @@ -79,7 +79,8 @@ /// A shared pointer to a target object. //------------------------------------------------------------------ Error - CreateTarget (const FileSpec& file_spec, + CreateTarget (Debugger &debugger, + const FileSpec& file_spec, const ArchSpec& arch, const UUID *uuid_ptr, bool get_dependent_files, Modified: lldb/trunk/include/lldb/lldb-forward-rtti.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/lldb-forward-rtti.h?rev=106615&r1=106614&r2=106615&view=diff ============================================================================== --- lldb/trunk/include/lldb/lldb-forward-rtti.h (original) +++ lldb/trunk/include/lldb/lldb-forward-rtti.h Tue Jun 22 20:19:29 2010 @@ -33,6 +33,7 @@ typedef SharedPtr::Type CommunicationSP; typedef SharedPtr::Type CompUnitSP; typedef SharedPtr::Type DataBufferSP; + typedef SharedPtr::Type DebuggerSP; typedef SharedPtr::Type DynamicLoaderSP; typedef SharedPtr::Type EventSP; typedef SharedPtr::Type FunctionSP; Modified: lldb/trunk/include/lldb/lldb-forward.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/lldb-forward.h?rev=106615&r1=106614&r2=106615&view=diff ============================================================================== --- lldb/trunk/include/lldb/lldb-forward.h (original) +++ lldb/trunk/include/lldb/lldb-forward.h Tue Jun 22 20:19:29 2010 @@ -42,7 +42,7 @@ class ClangExpression; class ClangExpressionDeclMap; class ClangExpressionVariableList; -class CommandContext; +class Debugger; class CommandInterpreter; class CommandObject; class CommandReturnObject; Modified: lldb/trunk/lldb.xcodeproj/project.pbxproj URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/lldb.xcodeproj/project.pbxproj?rev=106615&r1=106614&r2=106615&view=diff ============================================================================== --- lldb/trunk/lldb.xcodeproj/project.pbxproj (original) +++ lldb/trunk/lldb.xcodeproj/project.pbxproj Tue Jun 22 20:19:29 2010 @@ -160,7 +160,6 @@ 26D5B0C711B07550009A862E /* CFCMutableDictionary.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26BC7EF310F1B8AD00F91463 /* CFCMutableDictionary.cpp */; }; 26D5B0C811B07550009A862E /* CFCMutableSet.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26BC7EF510F1B8AD00F91463 /* CFCMutableSet.cpp */; }; 26D5B0C911B07550009A862E /* CFCString.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26BC7EF810F1B8AD00F91463 /* CFCString.cpp */; }; - 26D5B0CA11B07550009A862E /* CommandContext.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26BC7F0710F1B8DD00F91463 /* CommandContext.cpp */; }; 26D5B0CB11B07550009A862E /* CommandInterpreter.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26BC7F0810F1B8DD00F91463 /* CommandInterpreter.cpp */; }; 26D5B0CC11B07550009A862E /* CommandObject.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26BC7F0910F1B8DD00F91463 /* CommandObject.cpp */; }; 26D5B0CD11B07550009A862E /* CommandReturnObject.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26BC7F0A10F1B8DD00F91463 /* CommandReturnObject.cpp */; }; @@ -336,7 +335,6 @@ 4C08CDE811C81EF8001610A8 /* ThreadSpec.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4C08CDE711C81EF8001610A8 /* ThreadSpec.cpp */; }; 4C08CDEC11C81F1E001610A8 /* ThreadSpec.h in Headers */ = {isa = PBXBuildFile; fileRef = 4C08CDEB11C81F1E001610A8 /* ThreadSpec.h */; }; 4CA9637B11B6E99A00780E28 /* CommandObjectApropos.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4CA9637911B6E99A00780E28 /* CommandObjectApropos.cpp */; }; - 4CA9637C11B6E99A00780E28 /* CommandObjectApropos.h in Headers */ = {isa = PBXBuildFile; fileRef = 4CA9637A11B6E99A00780E28 /* CommandObjectApropos.h */; }; 9A19A6AF1163BBB200E0D453 /* SBValue.h in Headers */ = {isa = PBXBuildFile; fileRef = 9A19A6A51163BB7E00E0D453 /* SBValue.h */; settings = {ATTRIBUTES = (Public, ); }; }; 9A19A6B01163BBB300E0D453 /* SBValue.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9A19A6AD1163BB9800E0D453 /* SBValue.cpp */; }; 9A357583116CFDEE00E8ED2F /* SBValueList.h in Headers */ = {isa = PBXBuildFile; fileRef = 9A357582116CFDEE00E8ED2F /* SBValueList.h */; settings = {ATTRIBUTES = (Public, ); }; }; @@ -590,7 +588,6 @@ 26BC7CFA10F1B71400F91463 /* Stoppoint.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Stoppoint.h; path = include/lldb/Breakpoint/Stoppoint.h; sourceTree = ""; }; 26BC7CFB10F1B71400F91463 /* StoppointLocation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = StoppointLocation.h; path = include/lldb/Breakpoint/StoppointLocation.h; sourceTree = ""; }; 26BC7CFC10F1B71400F91463 /* WatchpointLocation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = WatchpointLocation.h; path = include/lldb/Breakpoint/WatchpointLocation.h; sourceTree = ""; }; - 26BC7D1010F1B76300F91463 /* CommandObjectAdd.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CommandObjectAdd.h; path = source/Commands/CommandObjectAdd.h; sourceTree = ""; }; 26BC7D1110F1B76300F91463 /* CommandObjectAlias.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CommandObjectAlias.h; path = source/Commands/CommandObjectAlias.h; sourceTree = ""; }; 26BC7D1210F1B76300F91463 /* CommandObjectAppend.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CommandObjectAppend.h; path = source/Commands/CommandObjectAppend.h; sourceTree = ""; }; 26BC7D1410F1B76300F91463 /* CommandObjectBreakpoint.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CommandObjectBreakpoint.h; path = source/Commands/CommandObjectBreakpoint.h; sourceTree = ""; }; @@ -605,7 +602,6 @@ 26BC7D1F10F1B76300F91463 /* CommandObjectProcess.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CommandObjectProcess.h; path = source/Commands/CommandObjectProcess.h; sourceTree = ""; }; 26BC7D2010F1B76300F91463 /* CommandObjectQuit.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CommandObjectQuit.h; path = source/Commands/CommandObjectQuit.h; sourceTree = ""; }; 26BC7D2210F1B76300F91463 /* CommandObjectRegister.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CommandObjectRegister.h; path = source/Commands/CommandObjectRegister.h; sourceTree = ""; }; - 26BC7D2310F1B76300F91463 /* CommandObjectRemove.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CommandObjectRemove.h; path = source/Commands/CommandObjectRemove.h; sourceTree = ""; }; 26BC7D2410F1B76300F91463 /* CommandObjectScript.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CommandObjectScript.h; path = source/Interpreter/CommandObjectScript.h; sourceTree = ""; }; 26BC7D2510F1B76300F91463 /* CommandObjectSelect.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CommandObjectSelect.h; path = source/Commands/CommandObjectSelect.h; sourceTree = ""; }; 26BC7D2610F1B76300F91463 /* CommandObjectSet.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CommandObjectSet.h; path = source/Commands/CommandObjectSet.h; sourceTree = ""; }; @@ -615,7 +611,6 @@ 26BC7D2A10F1B76300F91463 /* CommandObjectSourceFile.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CommandObjectSourceFile.h; path = source/Commands/CommandObjectSourceFile.h; sourceTree = ""; }; 26BC7D2C10F1B76300F91463 /* CommandObjectSyntax.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CommandObjectSyntax.h; path = source/Commands/CommandObjectSyntax.h; sourceTree = ""; }; 26BC7D2D10F1B76300F91463 /* CommandObjectThread.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CommandObjectThread.h; path = source/Commands/CommandObjectThread.h; sourceTree = ""; }; - 26BC7D2E10F1B76300F91463 /* CommandObjectTranslate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CommandObjectTranslate.h; path = source/Commands/CommandObjectTranslate.h; sourceTree = ""; }; 26BC7D2F10F1B76300F91463 /* CommandObjectVariable.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CommandObjectVariable.h; path = source/Commands/CommandObjectVariable.h; sourceTree = ""; }; 26BC7D5010F1B77400F91463 /* Address.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Address.h; path = include/lldb/Core/Address.h; sourceTree = ""; }; 26BC7D5110F1B77400F91463 /* AddressRange.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = AddressRange.h; path = include/lldb/Core/AddressRange.h; sourceTree = ""; }; @@ -677,7 +672,6 @@ 26BC7DD410F1B7D500F91463 /* Host.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Host.h; path = include/lldb/Host/Host.h; sourceTree = ""; }; 26BC7DD510F1B7D500F91463 /* Mutex.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Mutex.h; path = include/lldb/Host/Mutex.h; sourceTree = ""; }; 26BC7DD610F1B7D500F91463 /* Predicate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Predicate.h; path = include/lldb/Host/Predicate.h; sourceTree = ""; }; - 26BC7DE110F1B7F900F91463 /* CommandContext.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CommandContext.h; path = include/lldb/Interpreter/CommandContext.h; sourceTree = ""; }; 26BC7DE210F1B7F900F91463 /* CommandInterpreter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CommandInterpreter.h; path = include/lldb/Interpreter/CommandInterpreter.h; sourceTree = ""; }; 26BC7DE310F1B7F900F91463 /* CommandObject.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CommandObject.h; path = include/lldb/Interpreter/CommandObject.h; sourceTree = ""; }; 26BC7DE410F1B7F900F91463 /* CommandReturnObject.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CommandReturnObject.h; path = include/lldb/Interpreter/CommandReturnObject.h; sourceTree = ""; }; @@ -712,7 +706,6 @@ 26BC7E1610F1B83100F91463 /* Stoppoint.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = Stoppoint.cpp; path = source/Breakpoint/Stoppoint.cpp; sourceTree = ""; }; 26BC7E1710F1B83100F91463 /* StoppointLocation.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = StoppointLocation.cpp; path = source/Breakpoint/StoppointLocation.cpp; sourceTree = ""; }; 26BC7E1810F1B83100F91463 /* WatchpointLocation.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = WatchpointLocation.cpp; path = source/Breakpoint/WatchpointLocation.cpp; sourceTree = ""; }; - 26BC7E2910F1B84700F91463 /* CommandObjectAdd.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = CommandObjectAdd.cpp; path = source/Commands/CommandObjectAdd.cpp; sourceTree = ""; }; 26BC7E2A10F1B84700F91463 /* CommandObjectAlias.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = CommandObjectAlias.cpp; path = source/Commands/CommandObjectAlias.cpp; sourceTree = ""; }; 26BC7E2B10F1B84700F91463 /* CommandObjectAppend.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = CommandObjectAppend.cpp; path = source/Commands/CommandObjectAppend.cpp; sourceTree = ""; }; 26BC7E2D10F1B84700F91463 /* CommandObjectBreakpoint.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = CommandObjectBreakpoint.cpp; path = source/Commands/CommandObjectBreakpoint.cpp; sourceTree = ""; }; @@ -727,7 +720,6 @@ 26BC7E3810F1B84700F91463 /* CommandObjectProcess.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = CommandObjectProcess.cpp; path = source/Commands/CommandObjectProcess.cpp; sourceTree = ""; }; 26BC7E3910F1B84700F91463 /* CommandObjectQuit.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = CommandObjectQuit.cpp; path = source/Commands/CommandObjectQuit.cpp; sourceTree = ""; }; 26BC7E3B10F1B84700F91463 /* CommandObjectRegister.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = CommandObjectRegister.cpp; path = source/Commands/CommandObjectRegister.cpp; sourceTree = ""; }; - 26BC7E3C10F1B84700F91463 /* CommandObjectRemove.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = CommandObjectRemove.cpp; path = source/Commands/CommandObjectRemove.cpp; sourceTree = ""; }; 26BC7E3D10F1B84700F91463 /* CommandObjectScript.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = CommandObjectScript.cpp; path = source/Interpreter/CommandObjectScript.cpp; sourceTree = ""; }; 26BC7E3E10F1B84700F91463 /* CommandObjectSelect.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = CommandObjectSelect.cpp; path = source/Commands/CommandObjectSelect.cpp; sourceTree = ""; }; 26BC7E3F10F1B84700F91463 /* CommandObjectSet.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = CommandObjectSet.cpp; path = source/Commands/CommandObjectSet.cpp; sourceTree = ""; }; @@ -737,7 +729,6 @@ 26BC7E4310F1B84700F91463 /* CommandObjectSourceFile.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = CommandObjectSourceFile.cpp; path = source/Commands/CommandObjectSourceFile.cpp; sourceTree = ""; }; 26BC7E4510F1B84700F91463 /* CommandObjectSyntax.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = CommandObjectSyntax.cpp; path = source/Commands/CommandObjectSyntax.cpp; sourceTree = ""; }; 26BC7E4610F1B84700F91463 /* CommandObjectThread.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = CommandObjectThread.cpp; path = source/Commands/CommandObjectThread.cpp; sourceTree = ""; }; - 26BC7E4710F1B84700F91463 /* CommandObjectTranslate.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = CommandObjectTranslate.cpp; path = source/Commands/CommandObjectTranslate.cpp; sourceTree = ""; }; 26BC7E4810F1B84700F91463 /* CommandObjectVariable.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = CommandObjectVariable.cpp; path = source/Commands/CommandObjectVariable.cpp; sourceTree = ""; }; 26BC7E6910F1B85900F91463 /* Address.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = Address.cpp; path = source/Core/Address.cpp; sourceTree = ""; }; 26BC7E6A10F1B85900F91463 /* AddressRange.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = AddressRange.cpp; path = source/Core/AddressRange.cpp; sourceTree = ""; }; @@ -806,7 +797,6 @@ 26BC7EF710F1B8AD00F91463 /* CFCReleaser.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CFCReleaser.h; path = source/Host/macosx/cfcpp/CFCReleaser.h; sourceTree = ""; }; 26BC7EF810F1B8AD00F91463 /* CFCString.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = CFCString.cpp; path = source/Host/macosx/cfcpp/CFCString.cpp; sourceTree = ""; }; 26BC7EF910F1B8AD00F91463 /* CFCString.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CFCString.h; path = source/Host/macosx/cfcpp/CFCString.h; sourceTree = ""; }; - 26BC7F0710F1B8DD00F91463 /* CommandContext.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = CommandContext.cpp; path = source/Interpreter/CommandContext.cpp; sourceTree = ""; }; 26BC7F0810F1B8DD00F91463 /* CommandInterpreter.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = CommandInterpreter.cpp; path = source/Interpreter/CommandInterpreter.cpp; sourceTree = ""; }; 26BC7F0910F1B8DD00F91463 /* CommandObject.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = CommandObject.cpp; path = source/Interpreter/CommandObject.cpp; sourceTree = ""; }; 26BC7F0A10F1B8DD00F91463 /* CommandReturnObject.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = CommandReturnObject.cpp; path = source/Interpreter/CommandReturnObject.cpp; sourceTree = ""; }; @@ -1751,8 +1741,6 @@ 26BC7D0D10F1B71D00F91463 /* Commands */ = { isa = PBXGroup; children = ( - 26BC7D1010F1B76300F91463 /* CommandObjectAdd.h */, - 26BC7E2910F1B84700F91463 /* CommandObjectAdd.cpp */, 26BC7D1110F1B76300F91463 /* CommandObjectAlias.h */, 26BC7E2A10F1B84700F91463 /* CommandObjectAlias.cpp */, 26BC7D1210F1B76300F91463 /* CommandObjectAppend.h */, @@ -1793,8 +1781,6 @@ 26BC7E3910F1B84700F91463 /* CommandObjectQuit.cpp */, 26BC7D2210F1B76300F91463 /* CommandObjectRegister.h */, 26BC7E3B10F1B84700F91463 /* CommandObjectRegister.cpp */, - 26BC7D2310F1B76300F91463 /* CommandObjectRemove.h */, - 26BC7E3C10F1B84700F91463 /* CommandObjectRemove.cpp */, 26BC7D2410F1B76300F91463 /* CommandObjectScript.h */, 26BC7E3D10F1B84700F91463 /* CommandObjectScript.cpp */, 26BC7D2510F1B76300F91463 /* CommandObjectSelect.h */, @@ -1815,8 +1801,6 @@ 269416AD119A024800FF2715 /* CommandObjectTarget.cpp */, 26BC7D2D10F1B76300F91463 /* CommandObjectThread.h */, 26BC7E4610F1B84700F91463 /* CommandObjectThread.cpp */, - 26BC7D2E10F1B76300F91463 /* CommandObjectTranslate.h */, - 26BC7E4710F1B84700F91463 /* CommandObjectTranslate.cpp */, 9A8B4EA210FD515000C68FF2 /* CommandObjectUnalias.h */, 9A8B4EA310FD516400C68FF2 /* CommandObjectUnalias.cpp */, 26BC7D2F10F1B76300F91463 /* CommandObjectVariable.h */, @@ -1872,8 +1856,6 @@ 26A4EEB511682AAC007A372A /* LLDBWrapPython.cpp */, 4C09CB73116BD98B00C7A725 /* CommandCompletions.h */, 4C09CB74116BD98B00C7A725 /* CommandCompletions.cpp */, - 26BC7DE110F1B7F900F91463 /* CommandContext.h */, - 26BC7F0710F1B8DD00F91463 /* CommandContext.cpp */, 26BC7DE210F1B7F900F91463 /* CommandInterpreter.h */, 26BC7F0810F1B8DD00F91463 /* CommandInterpreter.cpp */, 26BC7DE310F1B7F900F91463 /* CommandObject.h */, @@ -2193,7 +2175,6 @@ 9AA69DAF118A023300D753A0 /* SBInputReader.h in Headers */, 49F1A74A11B338AE003ED505 /* ClangExpressionDeclMap.h in Headers */, 49D7072711B5AD03001AD875 /* ClangASTSource.h in Headers */, - 4CA9637C11B6E99A00780E28 /* CommandObjectApropos.h in Headers */, 261B5A5511C3F2AD00AABD0A /* SharingPtr.h in Headers */, 4C08CDEC11C81F1E001610A8 /* ThreadSpec.h in Headers */, ); @@ -2462,7 +2443,6 @@ 26D5B0C711B07550009A862E /* CFCMutableDictionary.cpp in Sources */, 26D5B0C811B07550009A862E /* CFCMutableSet.cpp in Sources */, 26D5B0C911B07550009A862E /* CFCString.cpp in Sources */, - 26D5B0CA11B07550009A862E /* CommandContext.cpp in Sources */, 26D5B0CB11B07550009A862E /* CommandInterpreter.cpp in Sources */, 26D5B0CC11B07550009A862E /* CommandObject.cpp in Sources */, 26D5B0CD11B07550009A862E /* CommandReturnObject.cpp in Sources */, Modified: lldb/trunk/source/API/SBAddress.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBAddress.cpp?rev=106615&r1=106614&r2=106615&view=diff ============================================================================== --- lldb/trunk/source/API/SBAddress.cpp (original) +++ lldb/trunk/source/API/SBAddress.cpp Tue Jun 22 20:19:29 2010 @@ -15,22 +15,22 @@ SBAddress::SBAddress () : - m_lldb_object_ap () + m_opaque_ap () { } SBAddress::SBAddress (const lldb_private::Address *lldb_object_ptr) : - m_lldb_object_ap () + m_opaque_ap () { if (lldb_object_ptr) - m_lldb_object_ap.reset (new lldb_private::Address(*lldb_object_ptr)); + m_opaque_ap.reset (new lldb_private::Address(*lldb_object_ptr)); } SBAddress::SBAddress (const SBAddress &rhs) : - m_lldb_object_ap () + m_opaque_ap () { if (rhs.IsValid()) - m_lldb_object_ap.reset (new lldb_private::Address(*rhs.m_lldb_object_ap.get())); + m_opaque_ap.reset (new lldb_private::Address(*rhs.m_opaque_ap.get())); } SBAddress::~SBAddress () @@ -43,7 +43,7 @@ if (this != &rhs) { if (rhs.IsValid()) - m_lldb_object_ap.reset (new lldb_private::Address(*rhs.m_lldb_object_ap.get())); + m_opaque_ap.reset (new lldb_private::Address(*rhs.m_opaque_ap.get())); } return *this; } @@ -51,7 +51,7 @@ bool SBAddress::IsValid () const { - return m_lldb_object_ap.get() != NULL && m_lldb_object_ap->IsValid(); + return m_opaque_ap.get() != NULL && m_opaque_ap->IsValid(); } void @@ -59,21 +59,21 @@ { if (lldb_object_ptr) { - if (m_lldb_object_ap.get()) - *m_lldb_object_ap = *lldb_object_ptr; + if (m_opaque_ap.get()) + *m_opaque_ap = *lldb_object_ptr; else - m_lldb_object_ap.reset (new lldb_private::Address(*lldb_object_ptr)); + m_opaque_ap.reset (new lldb_private::Address(*lldb_object_ptr)); return; } - if (m_lldb_object_ap.get()) - m_lldb_object_ap->Clear(); + if (m_opaque_ap.get()) + m_opaque_ap->Clear(); } lldb::addr_t SBAddress::GetFileAddress () const { - if (m_lldb_object_ap.get()) - return m_lldb_object_ap->GetFileAddress(); + if (m_opaque_ap.get()) + return m_opaque_ap->GetFileAddress(); else return LLDB_INVALID_ADDRESS; } @@ -81,8 +81,8 @@ lldb::addr_t SBAddress::GetLoadAddress (const SBProcess &process) const { - if (m_lldb_object_ap.get()) - return m_lldb_object_ap->GetLoadAddress(process.get()); + if (m_opaque_ap.get()) + return m_opaque_ap->GetLoadAddress(process.get()); else return LLDB_INVALID_ADDRESS; } @@ -90,12 +90,12 @@ bool SBAddress::OffsetAddress (addr_t offset) { - if (m_lldb_object_ap.get()) + if (m_opaque_ap.get()) { - addr_t addr_offset = m_lldb_object_ap->GetOffset(); + addr_t addr_offset = m_opaque_ap->GetOffset(); if (addr_offset != LLDB_INVALID_ADDRESS) { - m_lldb_object_ap->SetOffset(addr_offset + offset); + m_opaque_ap->SetOffset(addr_offset + offset); return true; } } @@ -106,13 +106,13 @@ const lldb_private::Address * SBAddress::operator->() const { - return m_lldb_object_ap.get(); + return m_opaque_ap.get(); } const lldb_private::Address & SBAddress::operator*() const { - return *m_lldb_object_ap; + return *m_opaque_ap; } Modified: lldb/trunk/source/API/SBBlock.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBBlock.cpp?rev=106615&r1=106614&r2=106615&view=diff ============================================================================== --- lldb/trunk/source/API/SBBlock.cpp (original) +++ lldb/trunk/source/API/SBBlock.cpp Tue Jun 22 20:19:29 2010 @@ -14,24 +14,24 @@ SBBlock::SBBlock () : - m_lldb_object_ptr (NULL) + m_opaque_ptr (NULL) { } SBBlock::SBBlock (lldb_private::Block *lldb_object_ptr) : - m_lldb_object_ptr (lldb_object_ptr) + m_opaque_ptr (lldb_object_ptr) { } SBBlock::~SBBlock () { - m_lldb_object_ptr = NULL; + m_opaque_ptr = NULL; } bool SBBlock::IsValid () const { - return m_lldb_object_ptr != NULL; + return m_opaque_ptr != NULL; } void @@ -39,7 +39,7 @@ { if (IsValid()) { - m_lldb_object_ptr->AppendVariables (can_create, get_parent_variables, var_list); + m_opaque_ptr->AppendVariables (can_create, get_parent_variables, var_list); } } Modified: lldb/trunk/source/API/SBBreakpoint.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBBreakpoint.cpp?rev=106615&r1=106614&r2=106615&view=diff ============================================================================== --- lldb/trunk/source/API/SBBreakpoint.cpp (original) +++ lldb/trunk/source/API/SBBreakpoint.cpp Tue Jun 22 20:19:29 2010 @@ -62,18 +62,18 @@ SBBreakpoint::SBBreakpoint () : - m_break_sp () + m_opaque_sp () { } SBBreakpoint::SBBreakpoint (const SBBreakpoint& rhs) : - m_break_sp (rhs.m_break_sp) + m_opaque_sp (rhs.m_opaque_sp) { } SBBreakpoint::SBBreakpoint (const lldb::BreakpointSP &bp_sp) : - m_break_sp (bp_sp) + m_opaque_sp (bp_sp) { } @@ -86,7 +86,7 @@ { if (this != &rhs) { - m_break_sp = rhs.m_break_sp; + m_opaque_sp = rhs.m_opaque_sp; } return *this; } @@ -94,8 +94,8 @@ break_id_t SBBreakpoint::GetID () const { - if (m_break_sp) - return m_break_sp->GetID(); + if (m_opaque_sp) + return m_opaque_sp->GetID(); return LLDB_INVALID_BREAK_ID; } @@ -103,28 +103,24 @@ bool SBBreakpoint::IsValid() const { - return m_break_sp; + return m_opaque_sp; } void SBBreakpoint::Dump (FILE *f) { - if (m_break_sp) + if (m_opaque_sp && f) { - if (f == NULL) - f = SBDebugger::GetOutputFileHandle(); - if (f == NULL) - return; lldb_private::StreamFile str (f); - m_break_sp->Dump (&str); + m_opaque_sp->Dump (&str); } } void SBBreakpoint::ClearAllBreakpointSites () { - if (m_break_sp) - m_break_sp->ClearAllBreakpointSites (); + if (m_opaque_sp) + m_opaque_sp->ClearAllBreakpointSites (); } SBBreakpointLocation @@ -132,18 +128,18 @@ { SBBreakpointLocation sb_bp_location; - if (m_break_sp) + if (m_opaque_sp) { if (vm_addr != LLDB_INVALID_ADDRESS) { Address address; - Process *sb_process = m_break_sp->GetTarget().GetProcessSP().get(); + Process *sb_process = m_opaque_sp->GetTarget().GetProcessSP().get(); if (sb_process == NULL || sb_process->ResolveLoadAddress (vm_addr, address) == false) { address.SetSection (NULL); address.SetOffset (vm_addr); } - sb_bp_location.SetLocation (m_break_sp->FindLocationByAddress (address)); + sb_bp_location.SetLocation (m_opaque_sp->FindLocationByAddress (address)); } } return sb_bp_location; @@ -154,18 +150,18 @@ { break_id_t lldb_id = (break_id_t) 0; - if (m_break_sp) + if (m_opaque_sp) { if (vm_addr != LLDB_INVALID_ADDRESS) { Address address; - Process *sb_process = m_break_sp->GetTarget().GetProcessSP().get(); + Process *sb_process = m_opaque_sp->GetTarget().GetProcessSP().get(); if (sb_process == NULL || sb_process->ResolveLoadAddress (vm_addr, address) == false) { address.SetSection (NULL); address.SetOffset (vm_addr); } - lldb_id = m_break_sp->FindLocationIDByAddress (address); + lldb_id = m_opaque_sp->FindLocationIDByAddress (address); } } @@ -177,8 +173,8 @@ { SBBreakpointLocation sb_bp_location; - if (m_break_sp) - sb_bp_location.SetLocation (m_break_sp->FindLocationByID (bp_loc_id)); + if (m_opaque_sp) + sb_bp_location.SetLocation (m_opaque_sp->FindLocationByID (bp_loc_id)); return sb_bp_location; } @@ -188,8 +184,8 @@ { SBBreakpointLocation sb_bp_location; - if (m_break_sp) - sb_bp_location.SetLocation (m_break_sp->GetLocationAtIndex (index)); + if (m_opaque_sp) + sb_bp_location.SetLocation (m_opaque_sp->GetLocationAtIndex (index)); return sb_bp_location; } @@ -197,13 +193,7 @@ void SBBreakpoint::ListLocations (FILE* f, const char *description_level) { - if (f == NULL) - f = SBDebugger::GetOutputFileHandle(); - - if (f == NULL) - return; - - if (m_break_sp) + if (m_opaque_sp && f) { DescriptionLevel level; if (strcmp (description_level, "brief") == 0) @@ -218,10 +208,10 @@ StreamFile str (f); str.IndentMore(); - int num_locs = m_break_sp->GetNumLocations(); + int num_locs = m_opaque_sp->GetNumLocations(); for (int i = 0; i < num_locs; ++i) { - BreakpointLocation *loc = m_break_sp->GetLocationAtIndex (i).get(); + BreakpointLocation *loc = m_opaque_sp->GetLocationAtIndex (i).get(); loc->GetDescription (&str, level); str.EOL(); } @@ -231,15 +221,15 @@ void SBBreakpoint::SetEnabled (bool enable) { - if (m_break_sp) - m_break_sp->SetEnabled (enable); + if (m_opaque_sp) + m_opaque_sp->SetEnabled (enable); } bool SBBreakpoint::IsEnabled () { - if (m_break_sp) - return m_break_sp->IsEnabled(); + if (m_opaque_sp) + return m_opaque_sp->IsEnabled(); else return false; } @@ -247,15 +237,15 @@ void SBBreakpoint::SetIgnoreCount (int32_t count) { - if (m_break_sp) - m_break_sp->SetIgnoreCount (count); + if (m_opaque_sp) + m_opaque_sp->SetIgnoreCount (count); } int32_t SBBreakpoint::GetIgnoreCount () const { - if (m_break_sp) - return m_break_sp->GetIgnoreCount(); + if (m_opaque_sp) + return m_opaque_sp->GetIgnoreCount(); else return 0; } @@ -263,16 +253,16 @@ void SBBreakpoint::SetThreadID (tid_t sb_thread_id) { - if (m_break_sp) - m_break_sp->SetThreadID (sb_thread_id); + if (m_opaque_sp) + m_opaque_sp->SetThreadID (sb_thread_id); } tid_t SBBreakpoint::GetThreadID () { tid_t lldb_thread_id = LLDB_INVALID_THREAD_ID; - if (m_break_sp) - lldb_thread_id = m_break_sp->GetThreadID(); + if (m_opaque_sp) + lldb_thread_id = m_opaque_sp->GetThreadID(); return lldb_thread_id; } @@ -280,16 +270,16 @@ void SBBreakpoint::SetThreadIndex (uint32_t index) { - if (m_break_sp) - m_break_sp->GetOptions()->GetThreadSpec()->SetIndex (index); + if (m_opaque_sp) + m_opaque_sp->GetOptions()->GetThreadSpec()->SetIndex (index); } uint32_t SBBreakpoint::GetThreadIndex() const { - if (m_break_sp) + if (m_opaque_sp) { - const ThreadSpec *thread_spec = m_break_sp->GetOptions()->GetThreadSpec(); + const ThreadSpec *thread_spec = m_opaque_sp->GetOptions()->GetThreadSpec(); if (thread_spec == NULL) return 0; else @@ -302,16 +292,16 @@ void SBBreakpoint::SetThreadName (const char *thread_name) { - if (m_break_sp) - m_break_sp->GetOptions()->GetThreadSpec()->SetName (thread_name); + if (m_opaque_sp) + m_opaque_sp->GetOptions()->GetThreadSpec()->SetName (thread_name); } const char * SBBreakpoint::GetThreadName () const { - if (m_break_sp) + if (m_opaque_sp) { - const ThreadSpec *thread_spec = m_break_sp->GetOptions()->GetThreadSpec(); + const ThreadSpec *thread_spec = m_opaque_sp->GetOptions()->GetThreadSpec(); if (thread_spec == NULL) return NULL; else @@ -323,16 +313,16 @@ void SBBreakpoint::SetQueueName (const char *queue_name) { - if (m_break_sp) - m_break_sp->GetOptions()->GetThreadSpec()->SetQueueName (queue_name); + if (m_opaque_sp) + m_opaque_sp->GetOptions()->GetThreadSpec()->SetQueueName (queue_name); } const char * SBBreakpoint::GetQueueName () const { - if (m_break_sp) + if (m_opaque_sp) { - const ThreadSpec *thread_spec = m_break_sp->GetOptions()->GetThreadSpec(); + const ThreadSpec *thread_spec = m_opaque_sp->GetOptions()->GetThreadSpec(); if (thread_spec == NULL) return NULL; else @@ -344,8 +334,8 @@ size_t SBBreakpoint::GetNumResolvedLocations() const { - if (m_break_sp) - return m_break_sp->GetNumResolvedLocations(); + if (m_opaque_sp) + return m_opaque_sp->GetNumResolvedLocations(); else return 0; } @@ -353,8 +343,8 @@ size_t SBBreakpoint::GetNumLocations() const { - if (m_break_sp) - return m_break_sp->GetNumLocations(); + if (m_opaque_sp) + return m_opaque_sp->GetNumLocations(); else return 0; } @@ -365,7 +355,7 @@ if (f == NULL) return; - if (m_break_sp) + if (m_opaque_sp) { DescriptionLevel level; if (strcmp (description_level, "brief") == 0) @@ -379,15 +369,15 @@ StreamFile str (f); - m_break_sp->GetDescription (&str, level); + m_opaque_sp->GetDescription (&str, level); str.EOL(); if (describe_locations) { //str.IndentMore(); - // int num_locs = m_break_sp->GetNumLocations(); + // int num_locs = m_opaque_sp->GetNumLocations(); // for (int i = 0; i < num_locs; ++i) // { - // BreakpointLocation *loc = m_break_sp->FindLocationByIndex (i); + // BreakpointLocation *loc = m_opaque_sp->FindLocationByIndex (i); // loc->GetDescription (&str, level); // str.EOL(); // } @@ -405,22 +395,22 @@ lldb::user_id_t break_loc_id ) { - BreakpointSP bp_sp(ctx->context.target->GetBreakpointList().FindBreakpointByID(break_id)); + BreakpointSP bp_sp(ctx->exe_ctx.target->GetBreakpointList().FindBreakpointByID(break_id)); if (baton && bp_sp) { CallbackData *data = (CallbackData *)baton; lldb_private::Breakpoint *bp = bp_sp.get(); if (bp && data->callback) { - if (ctx->context.process) + if (ctx->exe_ctx.process) { - SBProcess sb_process (ctx->context.process->GetSP()); + SBProcess sb_process (ctx->exe_ctx.process->GetSP()); SBThread sb_thread; SBBreakpointLocation sb_location; assert (bp_sp); sb_location.SetLocation (bp_sp->FindLocationByID (break_loc_id)); - if (ctx->context.thread) - sb_thread.SetThread(ctx->context.thread->GetSP()); + if (ctx->exe_ctx.thread) + sb_thread.SetThread(ctx->exe_ctx.thread->GetSP()); return data->callback (data->callback_baton, sb_process, @@ -435,10 +425,10 @@ void SBBreakpoint::SetCallback (BreakpointHitCallback callback, void *baton) { - if (m_break_sp.get()) + if (m_opaque_sp.get()) { BatonSP baton_sp(new SBBreakpointCallbackBaton (callback, baton)); - m_break_sp->SetCallback (SBBreakpoint::PrivateBreakpointHitCallback, baton_sp, false); + m_opaque_sp->SetCallback (SBBreakpoint::PrivateBreakpointHitCallback, baton_sp, false); } } @@ -446,24 +436,24 @@ lldb_private::Breakpoint * SBBreakpoint::operator->() const { - return m_break_sp.get(); + return m_opaque_sp.get(); } lldb_private::Breakpoint * SBBreakpoint::get() const { - return m_break_sp.get(); + return m_opaque_sp.get(); } lldb::BreakpointSP & SBBreakpoint::operator *() { - return m_break_sp; + return m_opaque_sp; } const lldb::BreakpointSP & SBBreakpoint::operator *() const { - return m_break_sp; + return m_opaque_sp; } Modified: lldb/trunk/source/API/SBBreakpointLocation.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBBreakpointLocation.cpp?rev=106615&r1=106614&r2=106615&view=diff ============================================================================== --- lldb/trunk/source/API/SBBreakpointLocation.cpp (original) +++ lldb/trunk/source/API/SBBreakpointLocation.cpp Tue Jun 22 20:19:29 2010 @@ -31,7 +31,7 @@ } SBBreakpointLocation::SBBreakpointLocation (const lldb::BreakpointLocationSP &break_loc_sp) : - m_break_loc_sp (break_loc_sp) + m_opaque_sp (break_loc_sp) { } @@ -42,7 +42,7 @@ bool SBBreakpointLocation::IsValid() const { - return m_break_loc_sp.get() != NULL; + return m_opaque_sp.get() != NULL; } addr_t @@ -50,9 +50,9 @@ { addr_t ret_addr = LLDB_INVALID_ADDRESS; - if (m_break_loc_sp) + if (m_opaque_sp) { - ret_addr = m_break_loc_sp->GetLoadAddress(); + ret_addr = m_opaque_sp->GetLoadAddress(); } return ret_addr; @@ -61,17 +61,17 @@ void SBBreakpointLocation::SetEnabled (bool enabled) { - if (m_break_loc_sp) + if (m_opaque_sp) { - m_break_loc_sp->SetEnabled (enabled); + m_opaque_sp->SetEnabled (enabled); } } bool SBBreakpointLocation::IsEnabled () { - if (m_break_loc_sp) - return m_break_loc_sp->IsEnabled(); + if (m_opaque_sp) + return m_opaque_sp->IsEnabled(); else return false; } @@ -79,8 +79,8 @@ int32_t SBBreakpointLocation::GetIgnoreCount () { - if (m_break_loc_sp) - return m_break_loc_sp->GetIgnoreCount(); + if (m_opaque_sp) + return m_opaque_sp->GetIgnoreCount(); else return 0; } @@ -88,40 +88,39 @@ void SBBreakpointLocation::SetIgnoreCount (int32_t n) { - if (m_break_loc_sp) - m_break_loc_sp->SetIgnoreCount (n); + if (m_opaque_sp) + m_opaque_sp->SetIgnoreCount (n); } void SBBreakpointLocation::SetThreadID (tid_t thread_id) { - if (m_break_loc_sp) - m_break_loc_sp->SetThreadID (thread_id); + if (m_opaque_sp) + m_opaque_sp->SetThreadID (thread_id); } tid_t SBBreakpointLocation::GetThreadID () { tid_t sb_thread_id = (lldb::tid_t) LLDB_INVALID_THREAD_ID; - if (m_break_loc_sp) - sb_thread_id = m_break_loc_sp->GetLocationOptions()->GetThreadSpecNoCreate()->GetTID(); - + if (m_opaque_sp) + sb_thread_id = m_opaque_sp->GetLocationOptions()->GetThreadSpecNoCreate()->GetTID(); return sb_thread_id; } void SBBreakpointLocation::SetThreadIndex (uint32_t index) { - if (m_break_loc_sp) - m_break_loc_sp->GetLocationOptions()->GetThreadSpec()->SetIndex (index); + if (m_opaque_sp) + m_opaque_sp->GetLocationOptions()->GetThreadSpec()->SetIndex (index); } uint32_t SBBreakpointLocation::GetThreadIndex() const { - if (m_break_loc_sp) + if (m_opaque_sp) { - const ThreadSpec *thread_spec = m_break_loc_sp->GetOptionsNoCreate()->GetThreadSpecNoCreate(); + const ThreadSpec *thread_spec = m_opaque_sp->GetOptionsNoCreate()->GetThreadSpecNoCreate(); if (thread_spec == NULL) return 0; else @@ -134,16 +133,16 @@ void SBBreakpointLocation::SetThreadName (const char *thread_name) { - if (m_break_loc_sp) - m_break_loc_sp->GetLocationOptions()->GetThreadSpec()->SetName (thread_name); + if (m_opaque_sp) + m_opaque_sp->GetLocationOptions()->GetThreadSpec()->SetName (thread_name); } const char * SBBreakpointLocation::GetThreadName () const { - if (m_break_loc_sp) + if (m_opaque_sp) { - const ThreadSpec *thread_spec = m_break_loc_sp->GetOptionsNoCreate()->GetThreadSpecNoCreate(); + const ThreadSpec *thread_spec = m_opaque_sp->GetOptionsNoCreate()->GetThreadSpecNoCreate(); if (thread_spec == NULL) return NULL; else @@ -155,16 +154,16 @@ void SBBreakpointLocation::SetQueueName (const char *queue_name) { - if (m_break_loc_sp) - m_break_loc_sp->GetLocationOptions()->GetThreadSpec()->SetQueueName (queue_name); + if (m_opaque_sp) + m_opaque_sp->GetLocationOptions()->GetThreadSpec()->SetQueueName (queue_name); } const char * SBBreakpointLocation::GetQueueName () const { - if (m_break_loc_sp) + if (m_opaque_sp) { - const ThreadSpec *thread_spec = m_break_loc_sp->GetOptionsNoCreate()->GetThreadSpecNoCreate(); + const ThreadSpec *thread_spec = m_opaque_sp->GetOptionsNoCreate()->GetThreadSpecNoCreate(); if (thread_spec == NULL) return NULL; else @@ -176,8 +175,8 @@ bool SBBreakpointLocation::IsResolved () { - if (m_break_loc_sp) - return m_break_loc_sp->IsResolved(); + if (m_opaque_sp) + return m_opaque_sp->IsResolved(); else return false; } @@ -185,11 +184,11 @@ void SBBreakpointLocation::SetLocation (const lldb::BreakpointLocationSP &break_loc_sp) { - if (m_break_loc_sp) + if (m_opaque_sp) { // Uninstall the callbacks? } - m_break_loc_sp = break_loc_sp; + m_opaque_sp = break_loc_sp; } void @@ -198,7 +197,7 @@ if (f == NULL) return; - if (m_break_loc_sp) + if (m_opaque_sp) { DescriptionLevel level; if (strcmp (description_level, "brief") == 0) @@ -212,7 +211,7 @@ StreamFile str (f); - m_break_loc_sp->GetDescription (&str, level); + m_opaque_sp->GetDescription (&str, level); str.EOL(); } } @@ -221,8 +220,8 @@ SBBreakpointLocation::GetBreakpoint () { SBBreakpoint sb_bp; - if (m_break_loc_sp) - *sb_bp = m_break_loc_sp->GetBreakpoint ().GetSP(); + if (m_opaque_sp) + *sb_bp = m_opaque_sp->GetBreakpoint ().GetSP(); return sb_bp; } Modified: lldb/trunk/source/API/SBBroadcaster.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBBroadcaster.cpp?rev=106615&r1=106614&r2=106615&view=diff ============================================================================== --- lldb/trunk/source/API/SBBroadcaster.cpp (original) +++ lldb/trunk/source/API/SBBroadcaster.cpp Tue Jun 22 20:19:29 2010 @@ -19,124 +19,124 @@ SBBroadcaster::SBBroadcaster () : - m_lldb_object (NULL), - m_lldb_object_owned (false) + m_opaque (NULL), + m_opaque_owned (false) { } SBBroadcaster::SBBroadcaster (const char *name) : - m_lldb_object (new Broadcaster (name)), - m_lldb_object_owned (true) + m_opaque (new Broadcaster (name)), + m_opaque_owned (true) { } SBBroadcaster::SBBroadcaster (lldb_private::Broadcaster *broadcaster, bool owns) : - m_lldb_object (broadcaster), - m_lldb_object_owned (owns) + m_opaque (broadcaster), + m_opaque_owned (owns) { } SBBroadcaster::~SBBroadcaster() { - SetLLDBObjectPtr (NULL, false); + reset (NULL, false); } void SBBroadcaster::BroadcastEventByType (uint32_t event_type, bool unique) { - if (m_lldb_object == NULL) + if (m_opaque == NULL) return; if (unique) - m_lldb_object->BroadcastEventIfUnique (event_type); + m_opaque->BroadcastEventIfUnique (event_type); else - m_lldb_object->BroadcastEvent (event_type); + m_opaque->BroadcastEvent (event_type); } void SBBroadcaster::BroadcastEvent (const SBEvent &event, bool unique) { - if (m_lldb_object == NULL) + if (m_opaque == NULL) return; - EventSP event_sp = event.GetSharedPtr (); + EventSP event_sp = event.GetSP (); if (unique) - m_lldb_object->BroadcastEventIfUnique (event_sp); + m_opaque->BroadcastEventIfUnique (event_sp); else - m_lldb_object->BroadcastEvent (event_sp); + m_opaque->BroadcastEvent (event_sp); } void SBBroadcaster::AddInitialEventsToListener (const SBListener &listener, uint32_t requested_events) { - if (m_lldb_object) - m_lldb_object->AddInitialEventsToListener (listener.get(), requested_events); + if (m_opaque) + m_opaque->AddInitialEventsToListener (listener.get(), requested_events); } uint32_t SBBroadcaster::AddListener (const SBListener &listener, uint32_t event_mask) { - if (m_lldb_object) - return m_lldb_object->AddListener (listener.get(), event_mask); + if (m_opaque) + return m_opaque->AddListener (listener.get(), event_mask); return 0; } const char * SBBroadcaster::GetName () { - if (m_lldb_object) - return m_lldb_object->GetBroadcasterName().AsCString(); + if (m_opaque) + return m_opaque->GetBroadcasterName().AsCString(); return NULL; } bool SBBroadcaster::EventTypeHasListeners (uint32_t event_type) { - if (m_lldb_object) - return m_lldb_object->EventTypeHasListeners (event_type); + if (m_opaque) + return m_opaque->EventTypeHasListeners (event_type); return false; } bool SBBroadcaster::RemoveListener (const SBListener &listener, uint32_t event_mask) { - if (m_lldb_object) - return m_lldb_object->RemoveListener (listener.get(), event_mask); + if (m_opaque) + return m_opaque->RemoveListener (listener.get(), event_mask); return false; } Broadcaster * -SBBroadcaster::GetLLDBObjectPtr () const +SBBroadcaster::get () const { - return m_lldb_object; + return m_opaque; } void -SBBroadcaster::SetLLDBObjectPtr (Broadcaster *broadcaster, bool owns) +SBBroadcaster::reset (Broadcaster *broadcaster, bool owns) { - if (m_lldb_object && m_lldb_object_owned) - delete m_lldb_object; - m_lldb_object = broadcaster; - m_lldb_object_owned = owns; + if (m_opaque && m_opaque_owned) + delete m_opaque; + m_opaque = broadcaster; + m_opaque_owned = owns; } bool SBBroadcaster::IsValid () const { - return m_lldb_object != NULL; + return m_opaque != NULL; } bool SBBroadcaster::operator == (const SBBroadcaster &rhs) const { - return m_lldb_object == rhs.m_lldb_object; + return m_opaque == rhs.m_opaque; } bool SBBroadcaster::operator != (const SBBroadcaster &rhs) const { - return m_lldb_object != rhs.m_lldb_object; + return m_opaque != rhs.m_opaque; } Modified: lldb/trunk/source/API/SBCommandContext.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBCommandContext.cpp?rev=106615&r1=106614&r2=106615&view=diff ============================================================================== --- lldb/trunk/source/API/SBCommandContext.cpp (original) +++ lldb/trunk/source/API/SBCommandContext.cpp Tue Jun 22 20:19:29 2010 @@ -7,7 +7,7 @@ // //===----------------------------------------------------------------------===// -#include "lldb/Interpreter/CommandContext.h" +#include "lldb/Core/Debugger.h" #include "lldb/Interpreter/CommandReturnObject.h" #include "lldb/API/SBCommandContext.h" @@ -17,8 +17,8 @@ using namespace lldb_private; -SBCommandContext::SBCommandContext (CommandContext *lldb_object) : - m_lldb_object (lldb_object) +SBCommandContext::SBCommandContext (Debugger *lldb_object) : + m_opaque (lldb_object) { } @@ -29,6 +29,6 @@ bool SBCommandContext::IsValid () const { - return m_lldb_object != NULL; + return m_opaque != NULL; } Modified: lldb/trunk/source/API/SBCommandInterpreter.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBCommandInterpreter.cpp?rev=106615&r1=106614&r2=106615&view=diff ============================================================================== --- lldb/trunk/source/API/SBCommandInterpreter.cpp (original) +++ lldb/trunk/source/API/SBCommandInterpreter.cpp Tue Jun 22 20:19:29 2010 @@ -30,8 +30,8 @@ using namespace lldb_private; -SBCommandInterpreter::SBCommandInterpreter (CommandInterpreter &interpreter) : - m_interpreter (interpreter) +SBCommandInterpreter::SBCommandInterpreter (CommandInterpreter *interpreter) : + m_opaque_ptr (interpreter) { } @@ -40,28 +40,49 @@ } bool +SBCommandInterpreter::IsValid() const +{ + return m_opaque_ptr != NULL; +} + + +bool SBCommandInterpreter::CommandExists (const char *cmd) { - return m_interpreter.CommandExists (cmd); + if (m_opaque_ptr) + return m_opaque_ptr->CommandExists (cmd); + return false; } bool SBCommandInterpreter::AliasExists (const char *cmd) { - return m_interpreter.AliasExists (cmd); + if (m_opaque_ptr) + return m_opaque_ptr->AliasExists (cmd); + return false; } bool SBCommandInterpreter::UserCommandExists (const char *cmd) { - return m_interpreter.UserCommandExists (cmd); + if (m_opaque_ptr) + return m_opaque_ptr->UserCommandExists (cmd); + return false; } lldb::ReturnStatus SBCommandInterpreter::HandleCommand (const char *command_line, SBCommandReturnObject &result, bool add_to_history) { result.Clear(); - m_interpreter.HandleCommand (command_line, add_to_history, result.GetLLDBObjectRef()); + if (m_opaque_ptr) + { + m_opaque_ptr->HandleCommand (command_line, add_to_history, result.ref()); + } + else + { + result->AppendError ("SBCommandInterpreter is not valid"); + result->SetStatus (eReturnStatusFailed); + } return result.GetStatus(); } @@ -73,64 +94,79 @@ int max_return_elements, SBStringList &matches) { - int num_completions; - lldb_private::StringList lldb_matches; - num_completions = m_interpreter.HandleCompletion (current_line, cursor, last_char, match_start_point, - max_return_elements, lldb_matches); - - SBStringList temp_list (&lldb_matches); - matches.AppendList (temp_list); + int num_completions = 0; + if (m_opaque_ptr) + { + lldb_private::StringList lldb_matches; + num_completions = m_opaque_ptr->HandleCompletion (current_line, cursor, last_char, match_start_point, + max_return_elements, lldb_matches); + SBStringList temp_list (&lldb_matches); + matches.AppendList (temp_list); + } return num_completions; } const char ** SBCommandInterpreter::GetEnvironmentVariables () { - const Args *env_vars = m_interpreter.GetEnvironmentVariables(); - if (env_vars) - return env_vars->GetConstArgumentVector (); + if (m_opaque_ptr) + { + const Args *env_vars = m_opaque_ptr->GetEnvironmentVariables(); + if (env_vars) + return env_vars->GetConstArgumentVector (); + } return NULL; } bool SBCommandInterpreter::HasCommands () { - return m_interpreter.HasCommands(); + if (m_opaque_ptr) + return m_opaque_ptr->HasCommands(); + return false; } bool SBCommandInterpreter::HasAliases () { - return m_interpreter.HasAliases(); + if (m_opaque_ptr) + return m_opaque_ptr->HasAliases(); + return false; } bool SBCommandInterpreter::HasUserCommands () { - return m_interpreter.HasUserCommands (); + if (m_opaque_ptr) + return m_opaque_ptr->HasUserCommands (); + return false; } bool SBCommandInterpreter::HasAliasOptions () { - return m_interpreter.HasAliasOptions (); + if (m_opaque_ptr) + return m_opaque_ptr->HasAliasOptions (); + return false; } bool SBCommandInterpreter::HasInterpreterVariables () { - return m_interpreter.HasInterpreterVariables (); + if (m_opaque_ptr) + return m_opaque_ptr->HasInterpreterVariables (); + return false; } SBProcess SBCommandInterpreter::GetProcess () { SBProcess process; - CommandContext *context = m_interpreter.Context(); - if (context) + if (m_opaque_ptr) { - Target *target = context->GetTarget(); + Debugger &debugger = m_opaque_ptr->GetDebugger(); + Target *target = debugger.GetCurrentTarget().get(); if (target) process.SetProcess(target->GetProcessSP()); } @@ -140,7 +176,7 @@ ssize_t SBCommandInterpreter::WriteToScriptInterpreter (const char *src) { - if (src) + if (m_opaque_ptr && src && src[0]) return WriteToScriptInterpreter (src, strlen(src)); return 0; } @@ -148,9 +184,9 @@ ssize_t SBCommandInterpreter::WriteToScriptInterpreter (const char *src, size_t src_len) { - if (src && src[0]) + if (m_opaque_ptr && src && src[0]) { - ScriptInterpreter *script_interpreter = m_interpreter.GetScriptInterpreter(); + ScriptInterpreter *script_interpreter = m_opaque_ptr->GetScriptInterpreter(); if (script_interpreter) return ::write (script_interpreter->GetMasterFileDescriptor(), src, src_len); } @@ -159,35 +195,58 @@ CommandInterpreter * -SBCommandInterpreter::GetLLDBObjectPtr () +SBCommandInterpreter::get () { - return &m_interpreter; + return m_opaque_ptr; } CommandInterpreter & -SBCommandInterpreter::GetLLDBObjectRef () +SBCommandInterpreter::ref () { - return m_interpreter; + assert (m_opaque_ptr); + return *m_opaque_ptr; +} + +void +SBCommandInterpreter::reset (lldb_private::CommandInterpreter *interpreter) +{ + m_opaque_ptr = interpreter; } void SBCommandInterpreter::SourceInitFileInHomeDirectory (SBCommandReturnObject &result) { result.Clear(); - m_interpreter.SourceInitFile (false, result.GetLLDBObjectRef()); + if (m_opaque_ptr) + { + m_opaque_ptr->SourceInitFile (false, result.ref()); + } + else + { + result->AppendError ("SBCommandInterpreter is not valid"); + result->SetStatus (eReturnStatusFailed); + } } void SBCommandInterpreter::SourceInitFileInCurrentWorkingDirectory (SBCommandReturnObject &result) { result.Clear(); - m_interpreter.SourceInitFile (true, result.GetLLDBObjectRef()); + if (m_opaque_ptr) + { + m_opaque_ptr->SourceInitFile (true, result.ref()); + } + else + { + result->AppendError ("SBCommandInterpreter is not valid"); + result->SetStatus (eReturnStatusFailed); + } } SBBroadcaster SBCommandInterpreter::GetBroadcaster () { - SBBroadcaster broadcaster (&m_interpreter, false); + SBBroadcaster broadcaster (m_opaque_ptr, false); return broadcaster; } Modified: lldb/trunk/source/API/SBCommandReturnObject.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBCommandReturnObject.cpp?rev=106615&r1=106614&r2=106615&view=diff ============================================================================== --- lldb/trunk/source/API/SBCommandReturnObject.cpp (original) +++ lldb/trunk/source/API/SBCommandReturnObject.cpp Tue Jun 22 20:19:29 2010 @@ -12,53 +12,54 @@ #include "lldb/API/SBCommandReturnObject.h" using namespace lldb; +using namespace lldb_private; SBCommandReturnObject::SBCommandReturnObject () : - m_return_object_ap (new lldb_private::CommandReturnObject ()) + m_opaque_ap (new CommandReturnObject ()) { } SBCommandReturnObject::~SBCommandReturnObject () { - // m_return_object_ap will automatically delete any pointer it owns + // m_opaque_ap will automatically delete any pointer it owns } bool SBCommandReturnObject::IsValid() const { - return m_return_object_ap.get() != NULL; + return m_opaque_ap.get() != NULL; } const char * SBCommandReturnObject::GetOutput () { - if (m_return_object_ap.get()) - return m_return_object_ap->GetOutputStream().GetData(); + if (m_opaque_ap.get()) + return m_opaque_ap->GetOutputStream().GetData(); return NULL; } const char * SBCommandReturnObject::GetError () { - if (m_return_object_ap.get()) - return m_return_object_ap->GetErrorStream().GetData(); + if (m_opaque_ap.get()) + return m_opaque_ap->GetErrorStream().GetData(); return NULL; } size_t SBCommandReturnObject::GetOutputSize () { - if (m_return_object_ap.get()) - return m_return_object_ap->GetOutputStream().GetSize(); + if (m_opaque_ap.get()) + return m_opaque_ap->GetOutputStream().GetSize(); return 0; } size_t SBCommandReturnObject::GetErrorSize () { - if (m_return_object_ap.get()) - return m_return_object_ap->GetErrorStream().GetSize(); + if (m_opaque_ap.get()) + return m_opaque_ap->GetErrorStream().GetSize(); return 0; } @@ -89,60 +90,73 @@ void SBCommandReturnObject::Clear() { - if (m_return_object_ap.get()) - m_return_object_ap->Clear(); + if (m_opaque_ap.get()) + m_opaque_ap->Clear(); } lldb::ReturnStatus SBCommandReturnObject::GetStatus() { - if (m_return_object_ap.get()) - return m_return_object_ap->GetStatus(); + if (m_opaque_ap.get()) + return m_opaque_ap->GetStatus(); return lldb::eReturnStatusInvalid; } bool SBCommandReturnObject::Succeeded () { - if (m_return_object_ap.get()) - return m_return_object_ap->Succeeded(); + if (m_opaque_ap.get()) + return m_opaque_ap->Succeeded(); return false; } bool SBCommandReturnObject::HasResult () { - if (m_return_object_ap.get()) - return m_return_object_ap->HasResult(); + if (m_opaque_ap.get()) + return m_opaque_ap->HasResult(); return false; } void SBCommandReturnObject::AppendMessage (const char *message) { - if (m_return_object_ap.get()) - m_return_object_ap->AppendMessage (message); + if (m_opaque_ap.get()) + m_opaque_ap->AppendMessage (message); } -lldb_private::CommandReturnObject * -SBCommandReturnObject::GetLLDBObjectPtr() +CommandReturnObject * +SBCommandReturnObject::operator ->() const { - return m_return_object_ap.get(); + return m_opaque_ap.get(); +} + +CommandReturnObject * +SBCommandReturnObject::get() const +{ + return m_opaque_ap.get(); +} + +CommandReturnObject & +SBCommandReturnObject::operator *() const +{ + assert(m_opaque_ap.get()); + return *(m_opaque_ap.get()); } -lldb_private::CommandReturnObject & -SBCommandReturnObject::GetLLDBObjectRef() +CommandReturnObject & +SBCommandReturnObject::ref() const { - assert(m_return_object_ap.get()); - return *(m_return_object_ap.get()); + assert(m_opaque_ap.get()); + return *(m_opaque_ap.get()); } void -SBCommandReturnObject::SetLLDBObjectPtr (lldb_private::CommandReturnObject *ptr) +SBCommandReturnObject::SetLLDBObjectPtr (CommandReturnObject *ptr) { - if (m_return_object_ap.get()) - m_return_object_ap.reset (ptr); + if (m_opaque_ap.get()) + m_opaque_ap.reset (ptr); } Modified: lldb/trunk/source/API/SBCommunication.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBCommunication.cpp?rev=106615&r1=106614&r2=106615&view=diff ============================================================================== --- lldb/trunk/source/API/SBCommunication.cpp (original) +++ lldb/trunk/source/API/SBCommunication.cpp Tue Jun 22 20:19:29 2010 @@ -18,57 +18,57 @@ SBCommunication::SBCommunication() : - m_lldb_object (NULL), - m_lldb_object_owned (false) + m_opaque (NULL), + m_opaque_owned (false) { } SBCommunication::SBCommunication(const char * broadcaster_name) : - m_lldb_object (new Communication (broadcaster_name)), - m_lldb_object_owned (true) + m_opaque (new Communication (broadcaster_name)), + m_opaque_owned (true) { } SBCommunication::~SBCommunication() { - if (m_lldb_object && m_lldb_object_owned) - delete m_lldb_object; - m_lldb_object = NULL; - m_lldb_object_owned = false; + if (m_opaque && m_opaque_owned) + delete m_opaque; + m_opaque = NULL; + m_opaque_owned = false; } ConnectionStatus SBCommunication::CheckIfBytesAvailable () { - if (m_lldb_object) - return m_lldb_object->BytesAvailable (0, NULL); + if (m_opaque) + return m_opaque->BytesAvailable (0, NULL); return eConnectionStatusNoConnection; } ConnectionStatus SBCommunication::WaitForBytesAvailableInfinite () { - if (m_lldb_object) - return m_lldb_object->BytesAvailable (UINT32_MAX, NULL); + if (m_opaque) + return m_opaque->BytesAvailable (UINT32_MAX, NULL); return eConnectionStatusNoConnection; } ConnectionStatus SBCommunication::WaitForBytesAvailableWithTimeout (uint32_t timeout_usec) { - if (m_lldb_object) - return m_lldb_object->BytesAvailable (timeout_usec, NULL); + if (m_opaque) + return m_opaque->BytesAvailable (timeout_usec, NULL); return eConnectionStatusNoConnection; } ConnectionStatus SBCommunication::Connect (const char *url) { - if (m_lldb_object) + if (m_opaque) { - if (!m_lldb_object->HasConnection ()) - m_lldb_object->SetConnection (new ConnectionFileDescriptor()); - return m_lldb_object->Connect (url, NULL); + if (!m_opaque->HasConnection ()) + m_opaque->SetConnection (new ConnectionFileDescriptor()); + return m_opaque->Connect (url, NULL); } return eConnectionStatusNoConnection; } @@ -76,15 +76,15 @@ ConnectionStatus SBCommunication::AdoptFileDesriptor (int fd, bool owns_fd) { - if (m_lldb_object) + if (m_opaque) { - if (m_lldb_object->HasConnection ()) + if (m_opaque->HasConnection ()) { - if (m_lldb_object->IsConnected()) - m_lldb_object->Disconnect (); + if (m_opaque->IsConnected()) + m_opaque->Disconnect (); } - m_lldb_object->SetConnection (new ConnectionFileDescriptor (fd, owns_fd)); - if (m_lldb_object->IsConnected()) + m_opaque->SetConnection (new ConnectionFileDescriptor (fd, owns_fd)); + if (m_opaque->IsConnected()) return eConnectionStatusSuccess; else return eConnectionStatusLostConnection; @@ -96,24 +96,24 @@ ConnectionStatus SBCommunication::Disconnect () { - if (m_lldb_object) - return m_lldb_object->Disconnect (); + if (m_opaque) + return m_opaque->Disconnect (); return eConnectionStatusNoConnection; } bool SBCommunication::IsConnected () const { - if (m_lldb_object) - return m_lldb_object->IsConnected (); + if (m_opaque) + return m_opaque->IsConnected (); return false; } size_t SBCommunication::Read (void *dst, size_t dst_len, uint32_t timeout_usec, ConnectionStatus &status) { - if (m_lldb_object) - return m_lldb_object->Read (dst, dst_len, timeout_usec, status, NULL); + if (m_opaque) + return m_opaque->Read (dst, dst_len, timeout_usec, status, NULL); status = eConnectionStatusNoConnection; return 0; } @@ -122,8 +122,8 @@ size_t SBCommunication::Write (const void *src, size_t src_len, ConnectionStatus &status) { - if (m_lldb_object) - return m_lldb_object->Write (src, src_len, status, NULL); + if (m_opaque) + return m_opaque->Write (src, src_len, status, NULL); status = eConnectionStatusNoConnection; return 0; } @@ -131,8 +131,8 @@ bool SBCommunication::ReadThreadStart () { - if (m_lldb_object) - return m_lldb_object->StartReadThread (); + if (m_opaque) + return m_opaque->StartReadThread (); return false; } @@ -140,16 +140,16 @@ bool SBCommunication::ReadThreadStop () { - if (m_lldb_object) - return m_lldb_object->StopReadThread (); + if (m_opaque) + return m_opaque->StopReadThread (); return false; } bool SBCommunication::ReadThreadIsRunning () { - if (m_lldb_object) - return m_lldb_object->ReadThreadIsRunning (); + if (m_opaque) + return m_opaque->ReadThreadIsRunning (); return false; } @@ -160,9 +160,9 @@ void *callback_baton ) { - if (m_lldb_object) + if (m_opaque) { - m_lldb_object->SetReadThreadBytesReceivedCallback (callback, callback_baton); + m_opaque->SetReadThreadBytesReceivedCallback (callback, callback_baton); return true; } return false; @@ -171,7 +171,7 @@ SBBroadcaster SBCommunication::GetBroadcaster () { - SBBroadcaster broadcaster (m_lldb_object, false); + SBBroadcaster broadcaster (m_opaque, false); return broadcaster; } @@ -180,15 +180,15 @@ //void //SBCommunication::CreateIfNeeded () //{ -// if (m_lldb_object == NULL) +// if (m_opaque == NULL) // { // static uint32_t g_broadcaster_num; // char broadcaster_name[256]; // ::snprintf (name, broadcaster_name, "%p SBCommunication", this); -// m_lldb_object = new Communication (broadcaster_name); -// m_lldb_object_owned = true; +// m_opaque = new Communication (broadcaster_name); +// m_opaque_owned = true; // } -// assert (m_lldb_object); +// assert (m_opaque); //} // // Modified: lldb/trunk/source/API/SBCompileUnit.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBCompileUnit.cpp?rev=106615&r1=106614&r2=106615&view=diff ============================================================================== --- lldb/trunk/source/API/SBCompileUnit.cpp (original) +++ lldb/trunk/source/API/SBCompileUnit.cpp Tue Jun 22 20:19:29 2010 @@ -18,35 +18,35 @@ SBCompileUnit::SBCompileUnit () : - m_lldb_object_ptr (NULL) + m_opaque_ptr (NULL) { } SBCompileUnit::SBCompileUnit (lldb_private::CompileUnit *lldb_object_ptr) : - m_lldb_object_ptr (lldb_object_ptr) + m_opaque_ptr (lldb_object_ptr) { } SBCompileUnit::~SBCompileUnit () { - m_lldb_object_ptr = NULL; + m_opaque_ptr = NULL; } SBFileSpec SBCompileUnit::GetFileSpec () const { SBFileSpec file_spec; - if (m_lldb_object_ptr) - file_spec.SetFileSpec(*m_lldb_object_ptr); + if (m_opaque_ptr) + file_spec.SetFileSpec(*m_opaque_ptr); return file_spec; } uint32_t SBCompileUnit::GetNumLineEntries () const { - if (m_lldb_object_ptr) + if (m_opaque_ptr) { - LineTable *line_table = m_lldb_object_ptr->GetLineTable (); + LineTable *line_table = m_opaque_ptr->GetLineTable (); if (line_table) return line_table->GetSize(); } @@ -57,9 +57,9 @@ SBCompileUnit::GetLineEntryAtIndex (uint32_t idx) const { SBLineEntry sb_line_entry; - if (m_lldb_object_ptr) + if (m_opaque_ptr) { - LineTable *line_table = m_lldb_object_ptr->GetLineTable (); + LineTable *line_table = m_opaque_ptr->GetLineTable (); if (line_table) { LineEntry line_entry; @@ -73,15 +73,15 @@ uint32_t SBCompileUnit::FindLineEntryIndex (uint32_t start_idx, uint32_t line, SBFileSpec *inline_file_spec) const { - if (m_lldb_object_ptr) + if (m_opaque_ptr) { FileSpec file_spec; if (inline_file_spec && inline_file_spec->IsValid()) file_spec = inline_file_spec->ref(); else - file_spec = *m_lldb_object_ptr; + file_spec = *m_opaque_ptr; - return m_lldb_object_ptr->FindLineEntry (start_idx, + return m_opaque_ptr->FindLineEntry (start_idx, line, inline_file_spec ? inline_file_spec->get() : NULL, NULL); @@ -92,29 +92,29 @@ bool SBCompileUnit::IsValid () const { - return m_lldb_object_ptr != NULL; + return m_opaque_ptr != NULL; } bool SBCompileUnit::operator == (const SBCompileUnit &rhs) const { - return m_lldb_object_ptr == rhs.m_lldb_object_ptr; + return m_opaque_ptr == rhs.m_opaque_ptr; } bool SBCompileUnit::operator != (const SBCompileUnit &rhs) const { - return m_lldb_object_ptr != rhs.m_lldb_object_ptr; + return m_opaque_ptr != rhs.m_opaque_ptr; } const lldb_private::CompileUnit * SBCompileUnit::operator->() const { - return m_lldb_object_ptr; + return m_opaque_ptr; } const lldb_private::CompileUnit & SBCompileUnit::operator*() const { - return *m_lldb_object_ptr; + return *m_opaque_ptr; } Modified: lldb/trunk/source/API/SBDebugger.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBDebugger.cpp?rev=106615&r1=106614&r2=106615&view=diff ============================================================================== --- lldb/trunk/source/API/SBDebugger.cpp (original) +++ lldb/trunk/source/API/SBDebugger.cpp Tue Jun 22 20:19:29 2010 @@ -43,112 +43,121 @@ Debugger::Terminate(); } -void -SBDebugger::SetAsync (bool b) +SBDebugger +SBDebugger::Create() { - static bool value_set_once = false; + SBDebugger debugger; + debugger.reset(Debugger::CreateInstance()); + return debugger; +} - if (!value_set_once) - { - value_set_once = true; - Debugger::GetSharedInstance().SetAsyncExecution(b); - } + +SBDebugger::SBDebugger () : + m_opaque_sp () +{ } -void -SBDebugger::SetInputFile (const char *tty_name) +SBDebugger::~SBDebugger () { - // DEPRECATED: will be removed in next submission - FILE *fh = ::fopen (tty_name, "r"); - SetInputFileHandle (fh, true); } -void -SBDebugger::SetOutputFile (const char *tty_name) +bool +SBDebugger::IsValid() const { - // DEPRECATED: will be removed in next submission - FILE *fh = ::fopen (tty_name, "w"); - SetOutputFileHandle (fh, true); - SetErrorFileHandle (fh, false); + return m_opaque_sp.get() != NULL; } + void -SBDebugger::SetErrorFile (const char *tty_name) +SBDebugger::SetAsync (bool b) { - // DEPRECATED: will be removed in next submission + if (m_opaque_sp) + m_opaque_sp->SetAsyncExecution(b); } - // Shouldn't really be settable after initialization as this could cause lots of problems; don't want users // trying to switch modes in the middle of a debugging session. void SBDebugger::SetInputFileHandle (FILE *fh, bool transfer_ownership) { - Debugger::GetSharedInstance().SetInputFileHandle (fh, transfer_ownership); + if (m_opaque_sp) + m_opaque_sp->SetInputFileHandle (fh, transfer_ownership); } void SBDebugger::SetOutputFileHandle (FILE *fh, bool transfer_ownership) { - Debugger::GetSharedInstance().SetOutputFileHandle (fh, transfer_ownership); + if (m_opaque_sp) + m_opaque_sp->SetOutputFileHandle (fh, transfer_ownership); } void SBDebugger::SetErrorFileHandle (FILE *fh, bool transfer_ownership) { - Debugger::GetSharedInstance().SetErrorFileHandle (fh, transfer_ownership); + if (m_opaque_sp) + m_opaque_sp->SetErrorFileHandle (fh, transfer_ownership); } FILE * SBDebugger::GetInputFileHandle () { - return Debugger::GetSharedInstance().GetInputFileHandle(); + if (m_opaque_sp) + return m_opaque_sp->GetInputFileHandle(); + return NULL; } FILE * SBDebugger::GetOutputFileHandle () { - return Debugger::GetSharedInstance().GetOutputFileHandle(); + if (m_opaque_sp) + return m_opaque_sp->GetOutputFileHandle(); + return NULL; } FILE * SBDebugger::GetErrorFileHandle () { - return Debugger::GetSharedInstance().GetErrorFileHandle(); + if (m_opaque_sp) + return m_opaque_sp->GetErrorFileHandle(); + return NULL; } SBCommandInterpreter SBDebugger::GetCommandInterpreter () { - SBCommandInterpreter sb_interpreter(Debugger::GetSharedInstance().GetCommandInterpreter()); + SBCommandInterpreter sb_interpreter; + if (m_opaque_sp) + sb_interpreter.reset (&m_opaque_sp->GetCommandInterpreter()); return sb_interpreter; } void SBDebugger::HandleCommand (const char *command) { - SBProcess process; - SBCommandInterpreter sb_interpreter(Debugger::GetSharedInstance().GetCommandInterpreter()); - SBCommandReturnObject result; - - sb_interpreter.HandleCommand (command, result, false); - - if (GetErrorFileHandle() != NULL) - result.PutError (GetErrorFileHandle()); - if (GetOutputFileHandle() != NULL) - result.PutOutput (GetOutputFileHandle()); - - if (Debugger::GetSharedInstance().GetAsyncExecution() == false) + if (m_opaque_sp) { - process = GetCommandInterpreter().GetProcess (); - if (process.IsValid()) + SBCommandInterpreter sb_interpreter(GetCommandInterpreter ()); + SBCommandReturnObject result; + + sb_interpreter.HandleCommand (command, result, false); + + if (GetErrorFileHandle() != NULL) + result.PutError (GetErrorFileHandle()); + if (GetOutputFileHandle() != NULL) + result.PutOutput (GetOutputFileHandle()); + + if (m_opaque_sp->GetAsyncExecution() == false) { - EventSP event_sp; - Listener &lldb_listener = Debugger::GetSharedInstance().GetListener(); - while (lldb_listener.GetNextEventForBroadcaster (process.get(), event_sp)) + SBProcess process(GetCommandInterpreter().GetProcess ()); + if (process.IsValid()) { - SBEvent event(event_sp); - HandleProcessEvent (process, event, GetOutputFileHandle(), GetErrorFileHandle()); + EventSP event_sp; + Listener &lldb_listener = m_opaque_sp->GetListener(); + while (lldb_listener.GetNextEventForBroadcaster (process.get(), event_sp)) + { + SBEvent event(event_sp); + HandleProcessEvent (process, event, GetOutputFileHandle(), GetErrorFileHandle()); + } } } } @@ -157,7 +166,9 @@ SBListener SBDebugger::GetListener () { - SBListener sb_listener(Debugger::GetSharedInstance().GetListener()); + SBListener sb_listener; + if (m_opaque_sp) + sb_listener.reset(&m_opaque_sp->GetListener(), false); return sb_listener; } @@ -271,53 +282,6 @@ } } -void -SBDebugger::ReportCurrentLocation (FILE *out, FILE *err) -{ - if ((out == NULL) || (err == NULL)) - return; - - SBTarget sb_target (GetCurrentTarget()); - if (!sb_target.IsValid()) - { - fprintf (out, "no target\n"); - return; - } - - SBProcess process = sb_target.GetProcess (); - if (process.IsValid()) - { - StateType state = process.GetState(); - - if (StateIsStoppedState (state)) - { - if (state == eStateExited) - { - int exit_status = process.GetExitStatus(); - const char *exit_description = process.GetExitDescription(); - ::fprintf (out, "Process %d exited with status = %i (0x%8.8x) %s\n", - process.GetProcessID(), - exit_status, - exit_status, - exit_description ? exit_description : ""); - } - else - { - fprintf (out, "Process %d %s\n", process.GetProcessID(), StateAsCString (state)); - SBThread current_thread = process.GetThreadAtIndex (0); - if (current_thread.IsValid()) - { - process.DisplayThreadsInfo (out, err, true); - } - else - fprintf (out, "No valid thread found in current process\n"); - } - } - else - fprintf (out, "No current location or status available\n"); - } -} - SBSourceManager & SBDebugger::GetSourceManager () { @@ -367,38 +331,6 @@ eScriptLanguageDefault, NULL); } -//pid_t -/* -SBDebugger::AttachByName (const char *process_name, const char *filename) -{ - SBTarget *temp_target = GetCurrentTarget(); - SBTarget sb_target; - pid_t return_pid = (pid_t) LLDB_INVALID_PROCESS_ID; - - if (temp_target == NULL) - { - if (filename != NULL) - { - sb_target = CreateWithFile (filename); - sb_target.SetArch (LLDB_ARCH_DEFAULT); - } - } - else - { - sb_target = *temp_target; - } - - if (sb_target.IsValid()) - { - SBProcess process = sb_target.GetProcess (); - if (process.IsValid()) - { - return_pid = process.AttachByName (process_name); - } - } - return return_pid; -} -*/ const char * SBDebugger::GetVersionString () @@ -429,34 +361,77 @@ SBDebugger::CreateTargetWithFileAndTargetTriple (const char *filename, const char *target_triple) { - ArchSpec arch; - FileSpec file_spec (filename); - arch.SetArchFromTargetTriple(target_triple); - TargetSP target_sp; - Error error (Debugger::GetSharedInstance().GetTargetList().CreateTarget (file_spec, arch, NULL, true, target_sp)); - SBTarget target(target_sp); + SBTarget target; + if (m_opaque_sp) + { + ArchSpec arch; + FileSpec file_spec (filename); + arch.SetArchFromTargetTriple(target_triple); + TargetSP target_sp; + Error error (m_opaque_sp->GetTargetList().CreateTarget (*m_opaque_sp, file_spec, arch, NULL, true, target_sp)); + target.reset (target_sp); + } return target; } SBTarget SBDebugger::CreateTargetWithFileAndArch (const char *filename, const char *archname) { - FileSpec file (filename); - ArchSpec arch = lldb_private::GetDefaultArchitecture(); - TargetSP target_sp; - Error error; - - if (archname != NULL) + SBTarget target; + if (m_opaque_sp) { - ArchSpec arch2 (archname); - error = Debugger::GetSharedInstance().GetTargetList().CreateTarget (file, arch2, NULL, true, target_sp); + FileSpec file (filename); + ArchSpec arch = lldb_private::GetDefaultArchitecture(); + TargetSP target_sp; + Error error; + + if (archname != NULL) + { + ArchSpec arch2 (archname); + error = m_opaque_sp->GetTargetList().CreateTarget (*m_opaque_sp, file, arch2, NULL, true, target_sp); + } + else + { + if (!arch.IsValid()) + arch = LLDB_ARCH_DEFAULT; + + error = m_opaque_sp->GetTargetList().CreateTarget (*m_opaque_sp, file, arch, NULL, true, target_sp); + + if (error.Fail()) + { + if (arch == LLDB_ARCH_DEFAULT_32BIT) + arch = LLDB_ARCH_DEFAULT_64BIT; + else + arch = LLDB_ARCH_DEFAULT_32BIT; + + error = m_opaque_sp->GetTargetList().CreateTarget (*m_opaque_sp, file, arch, NULL, true, target_sp); + } + } + + if (error.Success()) + { + m_opaque_sp->GetTargetList().SetCurrentTarget (target_sp.get()); + target.reset(target_sp); + } } - else + return target; +} + +SBTarget +SBDebugger::CreateTarget (const char *filename) +{ + SBTarget target; + if (m_opaque_sp) { + FileSpec file (filename); + ArchSpec arch = lldb_private::GetDefaultArchitecture(); + TargetSP target_sp; + Error error; + if (!arch.IsValid()) arch = LLDB_ARCH_DEFAULT; - error = Debugger::GetSharedInstance().GetTargetList().CreateTarget (file, arch, NULL, true, target_sp); + error = m_opaque_sp->GetTargetList().CreateTarget (*m_opaque_sp, file, arch, NULL, true, target_sp); if (error.Fail()) { @@ -465,77 +440,57 @@ else arch = LLDB_ARCH_DEFAULT_32BIT; - error = Debugger::GetSharedInstance().GetTargetList().CreateTarget (file, arch, NULL, true, target_sp); + error = m_opaque_sp->GetTargetList().CreateTarget (*m_opaque_sp, file, arch, NULL, true, target_sp); } - } - - if (error.Success()) - Debugger::GetSharedInstance().GetTargetList().SetCurrentTarget (target_sp.get()); - else - target_sp.reset(); - - SBTarget sb_target (target_sp); - return sb_target; -} - -SBTarget -SBDebugger::CreateTarget (const char *filename) -{ - FileSpec file (filename); - ArchSpec arch = lldb_private::GetDefaultArchitecture(); - TargetSP target_sp; - Error error; - - if (!arch.IsValid()) - arch = LLDB_ARCH_DEFAULT; - - error = Debugger::GetSharedInstance().GetTargetList().CreateTarget (file, arch, NULL, true, target_sp); - if (error.Fail()) - { - if (arch == LLDB_ARCH_DEFAULT_32BIT) - arch = LLDB_ARCH_DEFAULT_64BIT; - else - arch = LLDB_ARCH_DEFAULT_32BIT; - - error = Debugger::GetSharedInstance().GetTargetList().CreateTarget (file, arch, NULL, true, target_sp); + if (error.Success()) + { + m_opaque_sp->GetTargetList().SetCurrentTarget (target_sp.get()); + target.reset (target_sp); + } } - - if (!error.Fail()) - Debugger::GetSharedInstance().GetTargetList().SetCurrentTarget (target_sp.get()); - - SBTarget sb_target (target_sp); - return sb_target; + return target; } SBTarget SBDebugger::GetTargetAtIndex (uint32_t idx) { - SBTarget sb_target (Debugger::GetSharedInstance().GetTargetList().GetTargetAtIndex (idx)); + SBTarget sb_target; + if (m_opaque_sp) + sb_target.reset(m_opaque_sp->GetTargetList().GetTargetAtIndex (idx)); return sb_target; } SBTarget SBDebugger::FindTargetWithProcessID (pid_t pid) { - SBTarget sb_target(Debugger::GetSharedInstance().GetTargetList().FindTargetWithProcessID (pid)); + SBTarget sb_target; + if (m_opaque_sp) + sb_target.reset(m_opaque_sp->GetTargetList().FindTargetWithProcessID (pid)); return sb_target; } SBTarget SBDebugger::FindTargetWithFileAndArch (const char *filename, const char *arch_name) { - ArchSpec arch; - if (arch_name) - arch.SetArch(arch_name); - return SBTarget (Debugger::GetSharedInstance().GetTargetList().FindTargetWithExecutableAndArchitecture (FileSpec(filename), - arch_name ? &arch : NULL)); + SBTarget sb_target; + if (m_opaque_sp && filename && filename[0]) + { + ArchSpec arch; + if (arch_name) + arch.SetArch(arch_name); + TargetSP target_sp (m_opaque_sp->GetTargetList().FindTargetWithExecutableAndArchitecture (FileSpec(filename), arch_name ? &arch : NULL)); + sb_target.reset(target_sp); + } + return sb_target; } SBTarget SBDebugger::FindTargetWithLLDBProcess (const lldb::ProcessSP &process_sp) { - SBTarget sb_target(Debugger::GetSharedInstance().GetTargetList().FindTargetWithProcess (process_sp.get())); + SBTarget sb_target; + if (m_opaque_sp) + sb_target.reset(m_opaque_sp->GetTargetList().FindTargetWithProcess (process_sp.get())); return sb_target; } @@ -543,27 +498,54 @@ uint32_t SBDebugger::GetNumTargets () { - return Debugger::GetSharedInstance().GetTargetList().GetNumTargets ();} + if (m_opaque_sp) + return m_opaque_sp->GetTargetList().GetNumTargets (); + return 0; +} SBTarget SBDebugger::GetCurrentTarget () { - SBTarget sb_target(Debugger::GetSharedInstance().GetTargetList().GetCurrentTarget ()); + SBTarget sb_target; + if (m_opaque_sp) + sb_target.reset(m_opaque_sp->GetTargetList().GetCurrentTarget ()); return sb_target; } void SBDebugger::DispatchInput (void *baton, const void *data, size_t data_len) { - Debugger::GetSharedInstance().DispatchInput ((const char *) data, data_len); + if (m_opaque_sp) + m_opaque_sp->DispatchInput ((const char *) data, data_len); } void SBDebugger::PushInputReader (SBInputReader &reader) { - if (reader.IsValid()) + if (m_opaque_sp && reader.IsValid()) { InputReaderSP reader_sp(*reader); - Debugger::GetSharedInstance().PushInputReader (reader_sp); + m_opaque_sp->PushInputReader (reader_sp); } } + +void +SBDebugger::reset (const lldb::DebuggerSP &debugger_sp) +{ + m_opaque_sp = debugger_sp; +} + +Debugger * +SBDebugger::get () const +{ + return m_opaque_sp.get(); +} + +Debugger & +SBDebugger::ref () const +{ + assert (m_opaque_sp.get()); + return *m_opaque_sp; +} + + Modified: lldb/trunk/source/API/SBError.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBError.cpp?rev=106615&r1=106614&r2=106615&view=diff ============================================================================== --- lldb/trunk/source/API/SBError.cpp (original) +++ lldb/trunk/source/API/SBError.cpp Tue Jun 22 20:19:29 2010 @@ -16,15 +16,15 @@ SBError::SBError () : - m_lldb_object_ap () + m_opaque_ap () { } SBError::SBError (const SBError &rhs) : - m_lldb_object_ap () + m_opaque_ap () { if (rhs.IsValid()) - m_lldb_object_ap.reset (new Error(*rhs)); + m_opaque_ap.reset (new Error(*rhs)); } @@ -37,14 +37,14 @@ { if (rhs.IsValid()) { - if (m_lldb_object_ap.get()) - *m_lldb_object_ap = *rhs; + if (m_opaque_ap.get()) + *m_opaque_ap = *rhs; else - m_lldb_object_ap.reset (new Error(*rhs)); + m_opaque_ap.reset (new Error(*rhs)); } else { - m_lldb_object_ap.reset(); + m_opaque_ap.reset(); } return *this; } @@ -53,47 +53,47 @@ const char * SBError::GetCString () const { - if (m_lldb_object_ap.get()) - return m_lldb_object_ap->AsCString(); + if (m_opaque_ap.get()) + return m_opaque_ap->AsCString(); return NULL; } void SBError::Clear () { - if (m_lldb_object_ap.get()) - m_lldb_object_ap->Clear(); + if (m_opaque_ap.get()) + m_opaque_ap->Clear(); } bool SBError::Fail () const { - if (m_lldb_object_ap.get()) - return m_lldb_object_ap->Fail(); + if (m_opaque_ap.get()) + return m_opaque_ap->Fail(); return false; } bool SBError::Success () const { - if (m_lldb_object_ap.get()) - return m_lldb_object_ap->Success(); + if (m_opaque_ap.get()) + return m_opaque_ap->Success(); return false; } uint32_t SBError::GetError () const { - if (m_lldb_object_ap.get()) - return m_lldb_object_ap->GetError(); + if (m_opaque_ap.get()) + return m_opaque_ap->GetError(); return true; } ErrorType SBError::GetType () const { - if (m_lldb_object_ap.get()) - return m_lldb_object_ap->GetType(); + if (m_opaque_ap.get()) + return m_opaque_ap->GetType(); return eErrorTypeInvalid; } @@ -101,14 +101,14 @@ SBError::SetError (uint32_t err, ErrorType type) { CreateIfNeeded (); - m_lldb_object_ap->SetError (err, type); + m_opaque_ap->SetError (err, type); } void SBError::SetError (const Error &lldb_error) { CreateIfNeeded (); - *m_lldb_object_ap = lldb_error; + *m_opaque_ap = lldb_error; } @@ -116,21 +116,21 @@ SBError::SetErrorToErrno () { CreateIfNeeded (); - m_lldb_object_ap->SetErrorToErrno (); + m_opaque_ap->SetErrorToErrno (); } void SBError::SetErrorToGenericError () { CreateIfNeeded (); - m_lldb_object_ap->SetErrorToErrno (); + m_opaque_ap->SetErrorToErrno (); } void SBError::SetErrorString (const char *err_str) { CreateIfNeeded (); - m_lldb_object_ap->SetErrorString (err_str); + m_opaque_ap->SetErrorString (err_str); } int @@ -139,7 +139,7 @@ CreateIfNeeded (); va_list args; va_start (args, format); - int num_chars = m_lldb_object_ap->SetErrorStringWithVarArg (format, args); + int num_chars = m_opaque_ap->SetErrorStringWithVarArg (format, args); va_end (args); return num_chars; } @@ -147,27 +147,27 @@ bool SBError::IsValid () const { - return m_lldb_object_ap.get() != NULL; + return m_opaque_ap.get() != NULL; } void SBError::CreateIfNeeded () { - if (m_lldb_object_ap.get() == NULL) - m_lldb_object_ap.reset(new Error ()); + if (m_opaque_ap.get() == NULL) + m_opaque_ap.reset(new Error ()); } lldb_private::Error * SBError::operator->() { - return m_lldb_object_ap.get(); + return m_opaque_ap.get(); } lldb_private::Error * SBError::get() { - return m_lldb_object_ap.get(); + return m_opaque_ap.get(); } @@ -175,6 +175,6 @@ SBError::operator*() const { // Be sure to call "IsValid()" before calling this function or it will crash - return *m_lldb_object_ap; + return *m_opaque_ap; } Modified: lldb/trunk/source/API/SBEvent.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBEvent.cpp?rev=106615&r1=106614&r2=106615&view=diff ============================================================================== --- lldb/trunk/source/API/SBEvent.cpp (original) +++ lldb/trunk/source/API/SBEvent.cpp Tue Jun 22 20:19:29 2010 @@ -24,19 +24,19 @@ SBEvent::SBEvent () : m_event_sp (), - m_lldb_object (NULL) + m_opaque (NULL) { } SBEvent::SBEvent (uint32_t event_type, const char *cstr, uint32_t cstr_len) : m_event_sp (new Event (event_type, new EventDataBytes (cstr, cstr_len))), - m_lldb_object (m_event_sp.get()) + m_opaque (m_event_sp.get()) { } SBEvent::SBEvent (EventSP &event_sp) : m_event_sp (event_sp), - m_lldb_object (event_sp.get()) + m_opaque (event_sp.get()) { } @@ -47,7 +47,7 @@ void SBEvent::Dump (FILE *f) const { - const Event *lldb_event = GetLLDBObjectPtr(); + const Event *lldb_event = get(); if (lldb_event) { StreamFile str(f); @@ -58,7 +58,7 @@ const char * SBEvent::GetDataFlavor () { - Event *lldb_event = SBEvent::GetLLDBObjectPtr(); + Event *lldb_event = get(); if (lldb_event) return lldb_event->GetData()->GetFlavor().AsCString(); return NULL; @@ -67,7 +67,7 @@ uint32_t SBEvent::GetType () const { - const Event *lldb_event = SBEvent::GetLLDBObjectPtr(); + const Event *lldb_event = get(); if (lldb_event) return lldb_event->GetType(); return 0; @@ -77,9 +77,9 @@ SBEvent::GetBroadcaster () const { SBBroadcaster broadcaster; - const Event *lldb_event = SBEvent::GetLLDBObjectPtr(); + const Event *lldb_event = get(); if (lldb_event) - broadcaster.SetLLDBObjectPtr (lldb_event->GetBroadcaster(), false); + broadcaster.reset (lldb_event->GetBroadcaster(), false); return broadcaster; } @@ -88,9 +88,9 @@ { if (broadcaster) { - Event *lldb_event = SBEvent::GetLLDBObjectPtr(); + Event *lldb_event = get(); if (lldb_event) - return lldb_event->BroadcasterIs (broadcaster->GetLLDBObjectPtr ()); + return lldb_event->BroadcasterIs (broadcaster->get()); } return false; } @@ -98,79 +98,66 @@ bool SBEvent::BroadcasterMatchesRef (const SBBroadcaster &broadcaster) { - Event *lldb_event = SBEvent::GetLLDBObjectPtr(); + Event *lldb_event = get(); if (lldb_event) - return lldb_event->BroadcasterIs (broadcaster.GetLLDBObjectPtr ()); + return lldb_event->BroadcasterIs (broadcaster.get()); return false; } void SBEvent::Clear() { - Event *lldb_event = SBEvent::GetLLDBObjectPtr(); + Event *lldb_event = get(); if (lldb_event) lldb_event->Clear(); } EventSP & -SBEvent::GetSharedPtr () const +SBEvent::GetSP () const { return m_event_sp; } Event * -SBEvent::GetLLDBObjectPtr () +SBEvent::get() const { // There is a dangerous accessor call GetSharedPtr which can be used, so if // we have anything valid in m_event_sp, we must use that since if it gets // used by a function that puts something in there, then it won't update - // m_lldb_object... + // m_opaque... if (m_event_sp) - m_lldb_object = m_event_sp.get(); + m_opaque = m_event_sp.get(); - return m_lldb_object; -} - -const Event * -SBEvent::GetLLDBObjectPtr () const -{ - // There is a dangerous accessor call GetSharedPtr which can be used, so if - // we have anything valid in m_event_sp, we must use that since if it gets - // used by a function that puts something in there, then it won't update - // m_lldb_object... - if (m_event_sp) - m_lldb_object = m_event_sp.get(); - - return m_lldb_object; + return m_opaque; } void -SBEvent::SetEventSP (EventSP &event_sp) +SBEvent::reset (EventSP &event_sp) { m_event_sp = event_sp; - m_lldb_object = m_event_sp.get(); + m_opaque = m_event_sp.get(); } void -SBEvent::SetLLDBObjectPtr (Event* event_ptr) +SBEvent::reset (Event* event_ptr) { - m_lldb_object = event_ptr; + m_opaque = event_ptr; m_event_sp.reset(); } bool SBEvent::IsValid() const { - // Do NOT use m_lldb_object directly!!! Must use the SBEvent::GetLLDBObjectPtr() - // accessor. See comments in SBEvent::GetLLDBObjectPtr().... - return SBEvent::GetLLDBObjectPtr() != NULL; + // Do NOT use m_opaque directly!!! Must use the SBEvent::get() + // accessor. See comments in SBEvent::get().... + return SBEvent::get() != NULL; } const char * SBEvent::GetCStringFromEvent (const SBEvent &event) { - return reinterpret_cast(EventDataBytes::GetBytesFromEvent (event.GetLLDBObjectPtr())); + return reinterpret_cast(EventDataBytes::GetBytesFromEvent (event.get())); } Modified: lldb/trunk/source/API/SBFileSpec.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBFileSpec.cpp?rev=106615&r1=106614&r2=106615&view=diff ============================================================================== --- lldb/trunk/source/API/SBFileSpec.cpp (original) +++ lldb/trunk/source/API/SBFileSpec.cpp Tue Jun 22 20:19:29 2010 @@ -16,19 +16,19 @@ SBFileSpec::SBFileSpec () : - m_lldb_object_ap() + m_opaque_ap() { } SBFileSpec::SBFileSpec (const SBFileSpec &rhs) : - m_lldb_object_ap() + m_opaque_ap() { - if (rhs.m_lldb_object_ap.get()) - m_lldb_object_ap.reset (new FileSpec (*m_lldb_object_ap)); + if (rhs.m_opaque_ap.get()) + m_opaque_ap.reset (new FileSpec (*m_opaque_ap)); } SBFileSpec::SBFileSpec (const char *path) : - m_lldb_object_ap(new FileSpec (path)) + m_opaque_ap(new FileSpec (path)) { } @@ -42,7 +42,7 @@ if (this != &rhs) { if (rhs.IsValid()) - m_lldb_object_ap.reset (new lldb_private::FileSpec(*rhs.m_lldb_object_ap.get())); + m_opaque_ap.reset (new lldb_private::FileSpec(*rhs.m_opaque_ap.get())); } return *this; } @@ -50,14 +50,14 @@ bool SBFileSpec::IsValid() const { - return m_lldb_object_ap.get() != NULL; + return m_opaque_ap.get() != NULL; } bool SBFileSpec::Exists () const { - if (m_lldb_object_ap.get()) - return m_lldb_object_ap->Exists(); + if (m_opaque_ap.get()) + return m_opaque_ap->Exists(); return false; } @@ -71,24 +71,24 @@ const char * SBFileSpec::GetFileName() const { - if (m_lldb_object_ap.get()) - return m_lldb_object_ap->GetFilename().AsCString(); + if (m_opaque_ap.get()) + return m_opaque_ap->GetFilename().AsCString(); return NULL; } const char * SBFileSpec::GetDirectory() const { - if (m_lldb_object_ap.get()) - return m_lldb_object_ap->GetDirectory().AsCString(); + if (m_opaque_ap.get()) + return m_opaque_ap->GetDirectory().AsCString(); return NULL; } uint32_t SBFileSpec::GetPath (char *dst_path, size_t dst_len) const { - if (m_lldb_object_ap.get()) - return m_lldb_object_ap->GetPath (dst_path, dst_len); + if (m_opaque_ap.get()) + return m_opaque_ap->GetPath (dst_path, dst_len); if (dst_path && dst_len) *dst_path = '\0'; @@ -99,35 +99,35 @@ const lldb_private::FileSpec * SBFileSpec::operator->() const { - return m_lldb_object_ap.get(); + return m_opaque_ap.get(); } const lldb_private::FileSpec * SBFileSpec::get() const { - return m_lldb_object_ap.get(); + return m_opaque_ap.get(); } const lldb_private::FileSpec & SBFileSpec::operator*() const { - return *m_lldb_object_ap.get(); + return *m_opaque_ap.get(); } const lldb_private::FileSpec & SBFileSpec::ref() const { - return *m_lldb_object_ap.get(); + return *m_opaque_ap.get(); } void SBFileSpec::SetFileSpec (const lldb_private::FileSpec& fs) { - if (m_lldb_object_ap.get()) - *m_lldb_object_ap = fs; + if (m_opaque_ap.get()) + *m_opaque_ap = fs; else - m_lldb_object_ap.reset (new FileSpec (fs)); + m_opaque_ap.reset (new FileSpec (fs)); } Modified: lldb/trunk/source/API/SBFrame.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBFrame.cpp?rev=106615&r1=106614&r2=106615&view=diff ============================================================================== --- lldb/trunk/source/API/SBFrame.cpp (original) +++ lldb/trunk/source/API/SBFrame.cpp Tue Jun 22 20:19:29 2010 @@ -41,12 +41,12 @@ using namespace lldb_private; SBFrame::SBFrame () : - m_lldb_object_sp () + m_opaque_sp () { } SBFrame::SBFrame (const lldb::StackFrameSP &lldb_object_sp) : - m_lldb_object_sp (lldb_object_sp) + m_opaque_sp (lldb_object_sp) { } @@ -58,65 +58,65 @@ void SBFrame::SetFrame (const lldb::StackFrameSP &lldb_object_sp) { - m_lldb_object_sp = lldb_object_sp; + m_opaque_sp = lldb_object_sp; } bool SBFrame::IsValid() const { - return (m_lldb_object_sp.get() != NULL); + return (m_opaque_sp.get() != NULL); } SBSymbolContext SBFrame::GetSymbolContext (uint32_t resolve_scope) const { SBSymbolContext sb_sym_ctx; - if (m_lldb_object_sp) - sb_sym_ctx.SetSymbolContext(&m_lldb_object_sp->GetSymbolContext (resolve_scope)); + if (m_opaque_sp) + sb_sym_ctx.SetSymbolContext(&m_opaque_sp->GetSymbolContext (resolve_scope)); return sb_sym_ctx; } SBModule SBFrame::GetModule () const { - SBModule sb_module (m_lldb_object_sp->GetSymbolContext (eSymbolContextModule).module_sp); + SBModule sb_module (m_opaque_sp->GetSymbolContext (eSymbolContextModule).module_sp); return sb_module; } SBCompileUnit SBFrame::GetCompileUnit () const { - SBCompileUnit sb_comp_unit(m_lldb_object_sp->GetSymbolContext (eSymbolContextCompUnit).comp_unit); + SBCompileUnit sb_comp_unit(m_opaque_sp->GetSymbolContext (eSymbolContextCompUnit).comp_unit); return sb_comp_unit; } SBFunction SBFrame::GetFunction () const { - SBFunction sb_function(m_lldb_object_sp->GetSymbolContext (eSymbolContextFunction).function); + SBFunction sb_function(m_opaque_sp->GetSymbolContext (eSymbolContextFunction).function); return sb_function; } SBBlock SBFrame::GetBlock () const { - SBBlock sb_block(m_lldb_object_sp->GetSymbolContext (eSymbolContextBlock).block); + SBBlock sb_block(m_opaque_sp->GetSymbolContext (eSymbolContextBlock).block); return sb_block; } SBLineEntry SBFrame::GetLineEntry () const { - SBLineEntry sb_line_entry(&m_lldb_object_sp->GetSymbolContext (eSymbolContextLineEntry).line_entry); + SBLineEntry sb_line_entry(&m_opaque_sp->GetSymbolContext (eSymbolContextLineEntry).line_entry); return sb_line_entry; } uint32_t SBFrame::GetFrameID () const { - if (m_lldb_object_sp) - return m_lldb_object_sp->GetID(); + if (m_opaque_sp) + return m_opaque_sp->GetID(); else return UINT32_MAX; } @@ -125,24 +125,24 @@ lldb::addr_t SBFrame::GetPC () const { - if (m_lldb_object_sp) - return m_lldb_object_sp->GetPC().GetLoadAddress (&m_lldb_object_sp->GetThread().GetProcess()); + if (m_opaque_sp) + return m_opaque_sp->GetPC().GetLoadAddress (&m_opaque_sp->GetThread().GetProcess()); return LLDB_INVALID_ADDRESS; } bool SBFrame::SetPC (lldb::addr_t new_pc) { - if (m_lldb_object_sp) - return m_lldb_object_sp->GetRegisterContext()->SetPC (new_pc); + if (m_opaque_sp) + return m_opaque_sp->GetRegisterContext()->SetPC (new_pc); return false; } lldb::addr_t SBFrame::GetSP () const { - if (m_lldb_object_sp) - return m_lldb_object_sp->GetRegisterContext()->GetSP(); + if (m_opaque_sp) + return m_opaque_sp->GetRegisterContext()->GetSP(); return LLDB_INVALID_ADDRESS; } @@ -150,8 +150,8 @@ lldb::addr_t SBFrame::GetFP () const { - if (m_lldb_object_sp) - return m_lldb_object_sp->GetRegisterContext()->GetFP(); + if (m_opaque_sp) + return m_opaque_sp->GetRegisterContext()->GetFP(); return LLDB_INVALID_ADDRESS; } @@ -160,15 +160,15 @@ SBFrame::GetPCAddress () const { SBAddress sb_addr; - if (m_lldb_object_sp) - sb_addr.SetAddress (&m_lldb_object_sp->GetPC()); + if (m_opaque_sp) + sb_addr.SetAddress (&m_opaque_sp->GetPC()); return sb_addr; } void SBFrame::Clear() { - m_lldb_object_sp.reset(); + m_opaque_sp.reset(); } SBValue @@ -250,40 +250,40 @@ bool SBFrame::operator == (const SBFrame &rhs) const { - return m_lldb_object_sp.get() == rhs.m_lldb_object_sp.get(); + return m_opaque_sp.get() == rhs.m_opaque_sp.get(); } bool SBFrame::operator != (const SBFrame &rhs) const { - return m_lldb_object_sp.get() != rhs.m_lldb_object_sp.get(); + return m_opaque_sp.get() != rhs.m_opaque_sp.get(); } lldb_private::StackFrame * SBFrame::operator->() const { - return m_lldb_object_sp.get(); + return m_opaque_sp.get(); } lldb_private::StackFrame * SBFrame::get() const { - return m_lldb_object_sp.get(); + return m_opaque_sp.get(); } SBThread SBFrame::GetThread () const { - SBThread sb_thread (m_lldb_object_sp->GetThread().GetSP()); + SBThread sb_thread (m_opaque_sp->GetThread().GetSP()); return sb_thread; } const char * SBFrame::Disassemble () const { - if (m_lldb_object_sp) - return m_lldb_object_sp->Disassemble(); + if (m_opaque_sp) + return m_opaque_sp->Disassemble(); return NULL; } @@ -292,7 +292,7 @@ lldb_private::StackFrame * SBFrame::GetLLDBObjectPtr () { - return m_lldb_object_sp.get(); + return m_opaque_sp.get(); } SBValueList @@ -302,10 +302,10 @@ bool in_scope_only) { SBValueList value_list; - if (m_lldb_object_sp) + if (m_opaque_sp) { size_t i; - VariableList *variable_list = m_lldb_object_sp->GetVariableList(); + VariableList *variable_list = m_opaque_sp->GetVariableList(); if (variable_list) { const size_t num_variables = variable_list->GetSize(); @@ -334,7 +334,7 @@ } if (add_variable) { - if (in_scope_only && !variable_sp->IsInScope(m_lldb_object_sp.get())) + if (in_scope_only && !variable_sp->IsInScope(m_opaque_sp.get())) continue; value_list.Append(ValueObjectSP (new ValueObjectVariable (variable_sp))); @@ -346,7 +346,7 @@ if (statics) { - CompileUnit *frame_comp_unit = m_lldb_object_sp->GetSymbolContext (eSymbolContextCompUnit).comp_unit; + CompileUnit *frame_comp_unit = m_opaque_sp->GetSymbolContext (eSymbolContextCompUnit).comp_unit; if (frame_comp_unit) { @@ -377,9 +377,9 @@ SBFrame::GetRegisters () { SBValueList value_list; - if (m_lldb_object_sp) + if (m_opaque_sp) { - RegisterContext *reg_ctx = m_lldb_object_sp->GetRegisterContext(); + RegisterContext *reg_ctx = m_opaque_sp->GetRegisterContext(); if (reg_ctx) { const uint32_t num_sets = reg_ctx->GetRegisterSetCount(); Modified: lldb/trunk/source/API/SBFunction.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBFunction.cpp?rev=106615&r1=106614&r2=106615&view=diff ============================================================================== --- lldb/trunk/source/API/SBFunction.cpp (original) +++ lldb/trunk/source/API/SBFunction.cpp Tue Jun 22 20:19:29 2010 @@ -15,50 +15,50 @@ SBFunction::SBFunction () : - m_lldb_object_ptr (NULL) + m_opaque_ptr (NULL) { } SBFunction::SBFunction (lldb_private::Function *lldb_object_ptr) : - m_lldb_object_ptr (lldb_object_ptr) + m_opaque_ptr (lldb_object_ptr) { } SBFunction::~SBFunction () { - m_lldb_object_ptr = NULL; + m_opaque_ptr = NULL; } bool SBFunction::IsValid () const { - return m_lldb_object_ptr != NULL; + return m_opaque_ptr != NULL; } const char * SBFunction::GetName() const { - if (m_lldb_object_ptr) - return m_lldb_object_ptr->GetMangled().GetName().AsCString(); + if (m_opaque_ptr) + return m_opaque_ptr->GetMangled().GetName().AsCString(); return NULL; } const char * SBFunction::GetMangledName () const { - if (m_lldb_object_ptr) - return m_lldb_object_ptr->GetMangled().GetMangledName().AsCString(); + if (m_opaque_ptr) + return m_opaque_ptr->GetMangled().GetMangledName().AsCString(); return NULL; } bool SBFunction::operator == (const SBFunction &rhs) const { - return m_lldb_object_ptr == rhs.m_lldb_object_ptr; + return m_opaque_ptr == rhs.m_opaque_ptr; } bool SBFunction::operator != (const SBFunction &rhs) const { - return m_lldb_object_ptr != rhs.m_lldb_object_ptr; + return m_opaque_ptr != rhs.m_opaque_ptr; } Modified: lldb/trunk/source/API/SBInputReader.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBInputReader.cpp?rev=106615&r1=106614&r2=106615&view=diff ============================================================================== --- lldb/trunk/source/API/SBInputReader.cpp (original) +++ lldb/trunk/source/API/SBInputReader.cpp Tue Jun 22 20:19:29 2010 @@ -10,8 +10,9 @@ #include "lldb/lldb-enumerations.h" -#include "lldb/API/SBInputReader.h" +#include "lldb/API/SBDebugger.h" #include "lldb/API/SBError.h" +#include "lldb/API/SBInputReader.h" #include "lldb/API/SBStringList.h" #include "lldb/Core/InputReader.h" @@ -20,7 +21,7 @@ using namespace lldb_private; SBInputReader::SBInputReader () : - m_reader_sp (), + m_opaque_sp (), m_callback_function (NULL), m_callback_baton (NULL) @@ -28,12 +29,12 @@ } SBInputReader::SBInputReader (const lldb::InputReaderSP &reader_sp) : - m_reader_sp (reader_sp) + m_opaque_sp (reader_sp) { } SBInputReader::SBInputReader (const SBInputReader &rhs) : - m_reader_sp (rhs.m_reader_sp) + m_opaque_sp (rhs.m_opaque_sp) { } @@ -45,7 +46,7 @@ SBInputReader::PrivateCallback ( void *baton, - InputReader *reader, + InputReader &reader, lldb::InputReaderAction notification, const char *bytes, size_t bytes_len @@ -62,6 +63,7 @@ SBError SBInputReader::Initialize ( + SBDebugger &debugger, Callback callback_function, void *callback_baton, lldb::InputReaderGranularity granularity, @@ -71,14 +73,14 @@ ) { SBError sb_error; - m_reader_sp.reset (new InputReader ()); + m_opaque_sp.reset (new InputReader (debugger.ref())); m_callback_function = callback_function; m_callback_baton = callback_baton; - if (m_reader_sp) + if (m_opaque_sp) { - sb_error.SetError (m_reader_sp->Initialize (SBInputReader::PrivateCallback, + sb_error.SetError (m_opaque_sp->Initialize (SBInputReader::PrivateCallback, this, granularity, end_token, @@ -88,7 +90,7 @@ if (sb_error.Fail()) { - m_reader_sp.reset (); + m_opaque_sp.reset (); m_callback_function = NULL; m_callback_baton = NULL; } @@ -99,46 +101,53 @@ bool SBInputReader::IsValid () const { - return (m_reader_sp.get() != NULL); + return (m_opaque_sp.get() != NULL); } const SBInputReader & SBInputReader::operator = (const SBInputReader &rhs) { if (this != &rhs) - m_reader_sp = rhs.m_reader_sp; + m_opaque_sp = rhs.m_opaque_sp; return *this; } -lldb_private::InputReader * +InputReader * SBInputReader::operator->() const { - return m_reader_sp.get(); + return m_opaque_sp.get(); } lldb::InputReaderSP & SBInputReader::operator *() { - return m_reader_sp; + return m_opaque_sp; } const lldb::InputReaderSP & SBInputReader::operator *() const { - return m_reader_sp; + return m_opaque_sp; } -lldb_private::InputReader * +InputReader * SBInputReader::get() const { - return m_reader_sp.get(); + return m_opaque_sp.get(); +} + +InputReader & +SBInputReader::ref() const +{ + assert (m_opaque_sp.get()); + return *m_opaque_sp; } bool SBInputReader::IsDone () const { - if (m_reader_sp) - return m_reader_sp->IsDone(); + if (m_opaque_sp) + return m_opaque_sp->IsDone(); else return true; } @@ -146,15 +155,15 @@ void SBInputReader::SetIsDone (bool value) { - if (m_reader_sp) - m_reader_sp->SetIsDone (value); + if (m_opaque_sp) + m_opaque_sp->SetIsDone (value); } bool SBInputReader::IsActive () const { - if (m_reader_sp) - return m_reader_sp->IsActive(); + if (m_opaque_sp) + return m_opaque_sp->IsActive(); else return false; } @@ -162,8 +171,8 @@ InputReaderGranularity SBInputReader::GetGranularity () { - if (m_reader_sp) - return m_reader_sp->GetGranularity(); + if (m_opaque_sp) + return m_opaque_sp->GetGranularity(); else return eInputReaderGranularityInvalid; } Modified: lldb/trunk/source/API/SBInstruction.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBInstruction.cpp?rev=106615&r1=106614&r2=106615&view=diff ============================================================================== --- lldb/trunk/source/API/SBInstruction.cpp (original) +++ lldb/trunk/source/API/SBInstruction.cpp Tue Jun 22 20:19:29 2010 @@ -15,7 +15,7 @@ using namespace lldb_private; //SBInstruction::SBInstruction (lldb_private::Disassembler::Instruction *lldb_insn) : -// m_lldb_object_sp (lldb_insn); +// m_opaque_sp (lldb_insn); //{ //} @@ -30,7 +30,7 @@ //bool //SBInstruction::IsValid() //{ -// return (m_lldb_object_sp.get() != NULL); +// return (m_opaque_sp.get() != NULL); //} //size_t @@ -38,7 +38,7 @@ //{ // if (IsValid()) // { -// return m_lldb_object_sp->GetByteSize(); +// return m_opaque_sp->GetByteSize(); // } // return 0; //} @@ -48,7 +48,7 @@ //{ // if (IsValid ()) // { -// m_lldb_object_sp->SetByteSize (byte_size); +// m_opaque_sp->SetByteSize (byte_size); // } //} @@ -57,7 +57,7 @@ //{ // if (IsValid ()) // { -// return m_lldb_object_sp->DoesBranch (); +// return m_opaque_sp->DoesBranch (); // } // return false; //} @@ -70,5 +70,5 @@ //StreamFile out_strem (out); - //m_lldb_object_sp->Dump (out, LLDB_INVALID_ADDRESS, NULL, 0); + //m_opaque_sp->Dump (out, LLDB_INVALID_ADDRESS, NULL, 0); } Modified: lldb/trunk/source/API/SBLineEntry.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBLineEntry.cpp?rev=106615&r1=106614&r2=106615&view=diff ============================================================================== --- lldb/trunk/source/API/SBLineEntry.cpp (original) +++ lldb/trunk/source/API/SBLineEntry.cpp Tue Jun 22 20:19:29 2010 @@ -14,26 +14,26 @@ SBLineEntry::SBLineEntry () : - m_lldb_object_ap () + m_opaque_ap () { } SBLineEntry::SBLineEntry (const SBLineEntry &rhs) : - m_lldb_object_ap () + m_opaque_ap () { if (rhs.IsValid()) { - m_lldb_object_ap.reset (new lldb_private::LineEntry (*rhs)); + m_opaque_ap.reset (new lldb_private::LineEntry (*rhs)); } } SBLineEntry::SBLineEntry (const lldb_private::LineEntry *lldb_object_ptr) : - m_lldb_object_ap () + m_opaque_ap () { if (lldb_object_ptr) - m_lldb_object_ap.reset (new lldb_private::LineEntry(*lldb_object_ptr)); + m_opaque_ap.reset (new lldb_private::LineEntry(*lldb_object_ptr)); } const SBLineEntry & @@ -42,7 +42,7 @@ if (this != &rhs) { if (rhs.IsValid()) - m_lldb_object_ap.reset (new lldb_private::LineEntry(*rhs)); + m_opaque_ap.reset (new lldb_private::LineEntry(*rhs)); } return *this; } @@ -50,10 +50,10 @@ void SBLineEntry::SetLineEntry (const lldb_private::LineEntry &lldb_object_ref) { - if (m_lldb_object_ap.get()) - (*m_lldb_object_ap.get()) = lldb_object_ref; + if (m_opaque_ap.get()) + (*m_opaque_ap.get()) = lldb_object_ref; else - m_lldb_object_ap.reset (new lldb_private::LineEntry (lldb_object_ref)); + m_opaque_ap.reset (new lldb_private::LineEntry (lldb_object_ref)); } @@ -66,8 +66,8 @@ SBLineEntry::GetStartAddress () const { SBAddress sb_address; - if (m_lldb_object_ap.get()) - sb_address.SetAddress(&m_lldb_object_ap->range.GetBaseAddress()); + if (m_opaque_ap.get()) + sb_address.SetAddress(&m_opaque_ap->range.GetBaseAddress()); return sb_address; } @@ -75,10 +75,10 @@ SBLineEntry::GetEndAddress () const { SBAddress sb_address; - if (m_lldb_object_ap.get()) + if (m_opaque_ap.get()) { - sb_address.SetAddress(&m_lldb_object_ap->range.GetBaseAddress()); - sb_address.OffsetAddress(m_lldb_object_ap->range.GetByteSize()); + sb_address.SetAddress(&m_opaque_ap->range.GetBaseAddress()); + sb_address.OffsetAddress(m_opaque_ap->range.GetByteSize()); } return sb_address; } @@ -86,7 +86,7 @@ bool SBLineEntry::IsValid () const { - return m_lldb_object_ap.get() != NULL; + return m_opaque_ap.get() != NULL; } @@ -94,16 +94,16 @@ SBLineEntry::GetFileSpec () const { SBFileSpec sb_file_spec; - if (m_lldb_object_ap.get() && m_lldb_object_ap->file) - sb_file_spec.SetFileSpec(m_lldb_object_ap->file); + if (m_opaque_ap.get() && m_opaque_ap->file) + sb_file_spec.SetFileSpec(m_opaque_ap->file); return sb_file_spec; } uint32_t SBLineEntry::GetLine () const { - if (m_lldb_object_ap.get()) - return m_lldb_object_ap->line; + if (m_opaque_ap.get()) + return m_opaque_ap->line; return 0; } @@ -111,16 +111,16 @@ uint32_t SBLineEntry::GetColumn () const { - if (m_lldb_object_ap.get()) - return m_lldb_object_ap->column; + if (m_opaque_ap.get()) + return m_opaque_ap->column; return 0; } bool SBLineEntry::operator == (const SBLineEntry &rhs) const { - lldb_private::LineEntry *lhs_ptr = m_lldb_object_ap.get(); - lldb_private::LineEntry *rhs_ptr = rhs.m_lldb_object_ap.get(); + lldb_private::LineEntry *lhs_ptr = m_opaque_ap.get(); + lldb_private::LineEntry *rhs_ptr = rhs.m_opaque_ap.get(); if (lhs_ptr && rhs_ptr) return lldb_private::LineEntry::Compare (*lhs_ptr, *rhs_ptr) == 0; @@ -131,8 +131,8 @@ bool SBLineEntry::operator != (const SBLineEntry &rhs) const { - lldb_private::LineEntry *lhs_ptr = m_lldb_object_ap.get(); - lldb_private::LineEntry *rhs_ptr = rhs.m_lldb_object_ap.get(); + lldb_private::LineEntry *lhs_ptr = m_opaque_ap.get(); + lldb_private::LineEntry *rhs_ptr = rhs.m_opaque_ap.get(); if (lhs_ptr && rhs_ptr) return lldb_private::LineEntry::Compare (*lhs_ptr, *rhs_ptr) != 0; @@ -143,13 +143,13 @@ const lldb_private::LineEntry * SBLineEntry::operator->() const { - return m_lldb_object_ap.get(); + return m_opaque_ap.get(); } const lldb_private::LineEntry & SBLineEntry::operator*() const { - return *m_lldb_object_ap; + return *m_opaque_ap; } Modified: lldb/trunk/source/API/SBListener.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBListener.cpp?rev=106615&r1=106614&r2=106615&view=diff ============================================================================== --- lldb/trunk/source/API/SBListener.cpp (original) +++ lldb/trunk/source/API/SBListener.cpp Tue Jun 22 20:19:29 2010 @@ -19,30 +19,32 @@ using namespace lldb_private; -SBListener::SBListener () +SBListener::SBListener () : + m_opaque_ptr (NULL), + m_opaque_ptr_owned (false) { } SBListener::SBListener (const char *name) : - m_lldb_object_ptr (new Listener (name)), - m_lldb_object_ptr_owned (true) + m_opaque_ptr (new Listener (name)), + m_opaque_ptr_owned (true) { } SBListener::SBListener (Listener &listener) : - m_lldb_object_ptr (&listener), - m_lldb_object_ptr_owned (false) + m_opaque_ptr (&listener), + m_opaque_ptr_owned (false) { } SBListener::~SBListener () { - if (m_lldb_object_ptr_owned) + if (m_opaque_ptr_owned) { - if (m_lldb_object_ptr) + if (m_opaque_ptr) { - delete m_lldb_object_ptr; - m_lldb_object_ptr = NULL; + delete m_opaque_ptr; + m_opaque_ptr = NULL; } } } @@ -50,30 +52,30 @@ bool SBListener::IsValid() const { - return m_lldb_object_ptr != NULL; + return m_opaque_ptr != NULL; } void SBListener::AddEvent (const SBEvent &event) { - EventSP &event_sp = event.GetSharedPtr (); + EventSP &event_sp = event.GetSP (); if (event_sp) - m_lldb_object_ptr->AddEvent (event_sp); + m_opaque_ptr->AddEvent (event_sp); } void SBListener::Clear () { - if (IsValid()) - m_lldb_object_ptr->Clear (); + if (m_opaque_ptr) + m_opaque_ptr->Clear (); } uint32_t SBListener::StartListeningForEvents (const SBBroadcaster& broadcaster, uint32_t event_mask) { - if (IsValid() && broadcaster.IsValid()) + if (m_opaque_ptr && broadcaster.IsValid()) { - return m_lldb_object_ptr->StartListeningForEvents (broadcaster.GetLLDBObjectPtr (), event_mask); + return m_opaque_ptr->StartListeningForEvents (broadcaster.get(), event_mask); } return false; } @@ -81,9 +83,9 @@ bool SBListener::StopListeningForEvents (const SBBroadcaster& broadcaster, uint32_t event_mask) { - if (IsValid() && broadcaster.IsValid()) + if (m_opaque_ptr && broadcaster.IsValid()) { - return m_lldb_object_ptr->StopListeningForEvents (broadcaster.GetLLDBObjectPtr (), event_mask); + return m_opaque_ptr->StopListeningForEvents (broadcaster.get(), event_mask); } return false; } @@ -91,7 +93,7 @@ bool SBListener::WaitForEvent (uint32_t num_seconds, SBEvent &event) { - if (IsValid()) + if (m_opaque_ptr) { TimeValue time_value; if (num_seconds != UINT32_MAX) @@ -101,13 +103,13 @@ time_value.OffsetWithSeconds (num_seconds); } EventSP event_sp; - if (m_lldb_object_ptr->WaitForEvent (time_value.IsValid() ? &time_value : NULL, event_sp)) + if (m_opaque_ptr->WaitForEvent (time_value.IsValid() ? &time_value : NULL, event_sp)) { - event.SetEventSP (event_sp); + event.reset (event_sp); return true; } } - event.SetLLDBObjectPtr (NULL); + event.reset (NULL); return false; } @@ -119,7 +121,7 @@ SBEvent &event ) { - if (IsValid() && broadcaster.IsValid()) + if (m_opaque_ptr && broadcaster.IsValid()) { TimeValue time_value; if (num_seconds != UINT32_MAX) @@ -128,16 +130,16 @@ time_value.OffsetWithSeconds (num_seconds); } EventSP event_sp; - if (m_lldb_object_ptr->WaitForEventForBroadcaster (time_value.IsValid() ? &time_value : NULL, - broadcaster.GetLLDBObjectPtr (), + if (m_opaque_ptr->WaitForEventForBroadcaster (time_value.IsValid() ? &time_value : NULL, + broadcaster.get(), event_sp)) { - event.SetEventSP (event_sp); + event.reset (event_sp); return true; } } - event.SetLLDBObjectPtr (NULL); + event.reset (NULL); return false; } @@ -150,7 +152,7 @@ SBEvent &event ) { - if (IsValid() && broadcaster.IsValid()) + if (m_opaque_ptr && broadcaster.IsValid()) { TimeValue time_value; if (num_seconds != UINT32_MAX) @@ -159,40 +161,40 @@ time_value.OffsetWithSeconds (num_seconds); } EventSP event_sp; - if (m_lldb_object_ptr->WaitForEventForBroadcasterWithType (time_value.IsValid() ? &time_value : NULL, - broadcaster.GetLLDBObjectPtr (), - event_type_mask, - event_sp)) + if (m_opaque_ptr->WaitForEventForBroadcasterWithType (time_value.IsValid() ? &time_value : NULL, + broadcaster.get(), + event_type_mask, + event_sp)) { - event.SetEventSP (event_sp); + event.reset (event_sp); return true; } } - event.SetLLDBObjectPtr (NULL); + event.reset (NULL); return false; } bool SBListener::PeekAtNextEvent (SBEvent &event) { - if (m_lldb_object_ptr) + if (m_opaque_ptr) { - event.SetLLDBObjectPtr (m_lldb_object_ptr->PeekAtNextEvent ()); + event.reset (m_opaque_ptr->PeekAtNextEvent ()); return event.IsValid(); } - event.SetLLDBObjectPtr (NULL); + event.reset (NULL); return false; } bool SBListener::PeekAtNextEventForBroadcaster (const SBBroadcaster &broadcaster, SBEvent &event) { - if (IsValid() && broadcaster.IsValid()) + if (m_opaque_ptr && broadcaster.IsValid()) { - event.SetLLDBObjectPtr (m_lldb_object_ptr->PeekAtNextEventForBroadcaster (broadcaster.GetLLDBObjectPtr ())); + event.reset (m_opaque_ptr->PeekAtNextEventForBroadcaster (broadcaster.get())); return event.IsValid(); } - event.SetLLDBObjectPtr (NULL); + event.reset (NULL); return false; } @@ -200,44 +202,44 @@ SBListener::PeekAtNextEventForBroadcasterWithType (const SBBroadcaster &broadcaster, uint32_t event_type_mask, SBEvent &event) { - if (IsValid() && broadcaster.IsValid()) + if (m_opaque_ptr && broadcaster.IsValid()) { - event.SetLLDBObjectPtr(m_lldb_object_ptr->PeekAtNextEventForBroadcasterWithType (broadcaster.GetLLDBObjectPtr (), event_type_mask)); + event.reset(m_opaque_ptr->PeekAtNextEventForBroadcasterWithType (broadcaster.get(), event_type_mask)); return event.IsValid(); } - event.SetLLDBObjectPtr (NULL); + event.reset (NULL); return false; } bool SBListener::GetNextEvent (SBEvent &event) { - if (m_lldb_object_ptr) + if (m_opaque_ptr) { EventSP event_sp; - if (m_lldb_object_ptr->GetNextEvent (event_sp)) + if (m_opaque_ptr->GetNextEvent (event_sp)) { - event.SetEventSP (event_sp); + event.reset (event_sp); return true; } } - event.SetLLDBObjectPtr (NULL); + event.reset (NULL); return false; } bool SBListener::GetNextEventForBroadcaster (const SBBroadcaster &broadcaster, SBEvent &event) { - if (IsValid() && broadcaster.IsValid()) + if (m_opaque_ptr && broadcaster.IsValid()) { EventSP event_sp; - if (m_lldb_object_ptr->GetNextEventForBroadcaster (broadcaster.GetLLDBObjectPtr (), event_sp)) + if (m_opaque_ptr->GetNextEventForBroadcaster (broadcaster.get(), event_sp)) { - event.SetEventSP (event_sp); + event.reset (event_sp); return true; } } - event.SetLLDBObjectPtr (NULL); + event.reset (NULL); return false; } @@ -249,51 +251,61 @@ SBEvent &event ) { - if (IsValid() && broadcaster.IsValid()) + if (m_opaque_ptr && broadcaster.IsValid()) { EventSP event_sp; - if (m_lldb_object_ptr->GetNextEventForBroadcasterWithType (broadcaster.GetLLDBObjectPtr (), - event_type_mask, - event_sp)) + if (m_opaque_ptr->GetNextEventForBroadcasterWithType (broadcaster.get(), + event_type_mask, + event_sp)) { - event.SetEventSP (event_sp); + event.reset (event_sp); return true; } } - event.SetLLDBObjectPtr (NULL); + event.reset (NULL); return false; } bool SBListener::HandleBroadcastEvent (const SBEvent &event) { - if (m_lldb_object_ptr) - return m_lldb_object_ptr->HandleBroadcastEvent (event.GetSharedPtr()); + if (m_opaque_ptr) + return m_opaque_ptr->HandleBroadcastEvent (event.GetSP()); return false; } -lldb_private::Listener * +Listener * SBListener::operator->() const { - return m_lldb_object_ptr; + return m_opaque_ptr; } -lldb_private::Listener * +Listener * SBListener::get() const { - return m_lldb_object_ptr; + return m_opaque_ptr; } -lldb_private::Listener & +void +SBListener::reset(Listener *listener, bool transfer_ownership) +{ + if (m_opaque_ptr_owned && m_opaque_ptr) + delete m_opaque_ptr; + m_opaque_ptr_owned = transfer_ownership; + m_opaque_ptr = listener; +} + + +Listener & SBListener::operator *() { - return *m_lldb_object_ptr; + return *m_opaque_ptr; } -const lldb_private::Listener & +const Listener & SBListener::operator *() const { - return *m_lldb_object_ptr; + return *m_opaque_ptr; } Modified: lldb/trunk/source/API/SBModule.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBModule.cpp?rev=106615&r1=106614&r2=106615&view=diff ============================================================================== --- lldb/trunk/source/API/SBModule.cpp (original) +++ lldb/trunk/source/API/SBModule.cpp Tue Jun 22 20:19:29 2010 @@ -15,12 +15,12 @@ SBModule::SBModule () : - m_lldb_object_sp () + m_opaque_sp () { } SBModule::SBModule (const lldb::ModuleSP& module_sp) : - m_lldb_object_sp (module_sp) + m_opaque_sp (module_sp) { } @@ -31,23 +31,23 @@ bool SBModule::IsValid () const { - return m_lldb_object_sp.get() != NULL; + return m_opaque_sp.get() != NULL; } SBFileSpec SBModule::GetFileSpec () const { SBFileSpec file_spec; - if (m_lldb_object_sp) - file_spec.SetFileSpec(m_lldb_object_sp->GetFileSpec()); + if (m_opaque_sp) + file_spec.SetFileSpec(m_opaque_sp->GetFileSpec()); return file_spec; } const uint8_t * SBModule::GetUUIDBytes () const { - if (m_lldb_object_sp) - return (const uint8_t *)m_lldb_object_sp->GetUUID().GetBytes(); + if (m_opaque_sp) + return (const uint8_t *)m_opaque_sp->GetUUID().GetBytes(); return NULL; } @@ -55,53 +55,53 @@ bool SBModule::operator == (const SBModule &rhs) const { - if (m_lldb_object_sp) - return m_lldb_object_sp.get() == rhs.m_lldb_object_sp.get(); + if (m_opaque_sp) + return m_opaque_sp.get() == rhs.m_opaque_sp.get(); return false; } bool SBModule::operator != (const SBModule &rhs) const { - if (m_lldb_object_sp) - return m_lldb_object_sp.get() != rhs.m_lldb_object_sp.get(); + if (m_opaque_sp) + return m_opaque_sp.get() != rhs.m_opaque_sp.get(); return false; } lldb::ModuleSP & SBModule::operator *() { - return m_lldb_object_sp; + return m_opaque_sp; } lldb_private::Module * SBModule::operator ->() { - return m_lldb_object_sp.get(); + return m_opaque_sp.get(); } const lldb_private::Module * SBModule::operator ->() const { - return m_lldb_object_sp.get(); + return m_opaque_sp.get(); } lldb_private::Module * SBModule::get() { - return m_lldb_object_sp.get(); + return m_opaque_sp.get(); } const lldb_private::Module * SBModule::get() const { - return m_lldb_object_sp.get(); + return m_opaque_sp.get(); } void SBModule::SetModule (const lldb::ModuleSP& module_sp) { - m_lldb_object_sp = module_sp; + m_opaque_sp = module_sp; } Modified: lldb/trunk/source/API/SBProcess.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBProcess.cpp?rev=106615&r1=106614&r2=106615&view=diff ============================================================================== --- lldb/trunk/source/API/SBProcess.cpp (original) +++ lldb/trunk/source/API/SBProcess.cpp Tue Jun 22 20:19:29 2010 @@ -19,8 +19,9 @@ #include "lldb/Core/Stream.h" #include "lldb/Core/StreamFile.h" #include "lldb/Target/Process.h" -#include "lldb/Target/Thread.h" #include "lldb/Target/RegisterContext.h" +#include "lldb/Target/Target.h" +#include "lldb/Target/Thread.h" // Project includes @@ -37,7 +38,7 @@ SBProcess::SBProcess () : - m_lldb_object_sp() + m_opaque_sp() { } @@ -47,13 +48,13 @@ //---------------------------------------------------------------------- SBProcess::SBProcess (const SBProcess& rhs) : - m_lldb_object_sp (rhs.m_lldb_object_sp) + m_opaque_sp (rhs.m_opaque_sp) { } SBProcess::SBProcess (const lldb::ProcessSP &process_sp) : - m_lldb_object_sp (process_sp) + m_opaque_sp (process_sp) { } @@ -67,30 +68,30 @@ void SBProcess::SetProcess (const ProcessSP &process_sp) { - m_lldb_object_sp = process_sp; + m_opaque_sp = process_sp; } void SBProcess::Clear () { - m_lldb_object_sp.reset(); + m_opaque_sp.reset(); } bool SBProcess::IsValid() const { - return m_lldb_object_sp.get() != NULL; + return m_opaque_sp.get() != NULL; } uint32_t SBProcess::GetNumThreads () { - if (m_lldb_object_sp) + if (m_opaque_sp) { const bool can_update = true; - return m_lldb_object_sp->GetThreadList().GetSize(can_update); + return m_opaque_sp->GetThreadList().GetSize(can_update); } return 0; } @@ -99,8 +100,8 @@ SBProcess::GetCurrentThread () const { SBThread sb_thread; - if (m_lldb_object_sp) - sb_thread.SetThread (m_lldb_object_sp->GetThreadList().GetCurrentThread()); + if (m_opaque_sp) + sb_thread.SetThread (m_opaque_sp->GetThreadList().GetCurrentThread()); return sb_thread; } @@ -108,8 +109,8 @@ SBProcess::GetTarget() const { SBTarget sb_target; - if (m_lldb_object_sp) - sb_target = SBDebugger::FindTargetWithLLDBProcess (m_lldb_object_sp); + if (m_opaque_sp) + sb_target = m_opaque_sp->GetTarget().GetSP(); return sb_target; } @@ -117,10 +118,10 @@ size_t SBProcess::PutSTDIN (const char *src, size_t src_len) { - if (m_lldb_object_sp != NULL) + if (m_opaque_sp != NULL) { Error error; - return m_lldb_object_sp->PutSTDIN (src, src_len, error); + return m_opaque_sp->PutSTDIN (src, src_len, error); } else return 0; @@ -129,10 +130,10 @@ size_t SBProcess::GetSTDOUT (char *dst, size_t dst_len) const { - if (m_lldb_object_sp != NULL) + if (m_opaque_sp != NULL) { Error error; - return m_lldb_object_sp->GetSTDOUT (dst, dst_len, error); + return m_opaque_sp->GetSTDOUT (dst, dst_len, error); } else return 0; @@ -141,10 +142,10 @@ size_t SBProcess::GetSTDERR (char *dst, size_t dst_len) const { - if (m_lldb_object_sp != NULL) + if (m_opaque_sp != NULL) { Error error; - return m_lldb_object_sp->GetSTDERR (dst, dst_len, error); + return m_opaque_sp->GetSTDERR (dst, dst_len, error); } else return 0; @@ -156,14 +157,14 @@ if (out == NULL) return; - if (m_lldb_object_sp != NULL) + if (m_opaque_sp != NULL) { const StateType event_state = SBProcess::GetStateFromEvent (event); char message[1024]; int message_len = ::snprintf (message, sizeof (message), "Process %d %s\n", - m_lldb_object_sp->GetID(), + m_opaque_sp->GetID(), SBDebugger::StateAsCString (event_state)); if (message_len > 0) @@ -174,14 +175,14 @@ void SBProcess::AppendCurrentStateReport (const SBEvent &event, SBCommandReturnObject &result) { - if (m_lldb_object_sp != NULL) + if (m_opaque_sp != NULL) { const StateType event_state = SBProcess::GetStateFromEvent (event); char message[1024]; ::snprintf (message, sizeof (message), "Process %d %s\n", - m_lldb_object_sp->GetID(), + m_opaque_sp->GetID(), SBDebugger::StateAsCString (event_state)); result.AppendMessage (message); @@ -191,16 +192,16 @@ bool SBProcess::SetCurrentThread (const SBThread &thread) { - if (m_lldb_object_sp != NULL) - return m_lldb_object_sp->GetThreadList().SetCurrentThreadByID (thread.GetThreadID()); + if (m_opaque_sp != NULL) + return m_opaque_sp->GetThreadList().SetCurrentThreadByID (thread.GetThreadID()); return false; } bool SBProcess::SetCurrentThreadByID (uint32_t tid) { - if (m_lldb_object_sp != NULL) - return m_lldb_object_sp->GetThreadList().SetCurrentThreadByID (tid); + if (m_opaque_sp != NULL) + return m_opaque_sp->GetThreadList().SetCurrentThreadByID (tid); return false; } @@ -208,16 +209,16 @@ SBProcess::GetThreadAtIndex (size_t index) { SBThread thread; - if (m_lldb_object_sp) - thread.SetThread (m_lldb_object_sp->GetThreadList().GetThreadAtIndex(index)); + if (m_opaque_sp) + thread.SetThread (m_opaque_sp->GetThreadList().GetThreadAtIndex(index)); return thread; } StateType SBProcess::GetState () { - if (m_lldb_object_sp != NULL) - return m_lldb_object_sp->GetState(); + if (m_opaque_sp != NULL) + return m_opaque_sp->GetState(); else return eStateInvalid; } @@ -226,8 +227,8 @@ int SBProcess::GetExitStatus () { - if (m_lldb_object_sp != NULL) - return m_lldb_object_sp->GetExitStatus (); + if (m_opaque_sp != NULL) + return m_opaque_sp->GetExitStatus (); else return 0; } @@ -235,8 +236,8 @@ const char * SBProcess::GetExitDescription () { - if (m_lldb_object_sp != NULL) - return m_lldb_object_sp->GetExitDescription (); + if (m_opaque_sp != NULL) + return m_opaque_sp->GetExitDescription (); else return NULL; } @@ -244,8 +245,8 @@ lldb::pid_t SBProcess::GetProcessID () { - if (m_lldb_object_sp) - return m_lldb_object_sp->GetID(); + if (m_opaque_sp) + return m_opaque_sp->GetID(); else return LLDB_INVALID_PROCESS_ID; } @@ -253,85 +254,12 @@ uint32_t SBProcess::GetAddressByteSize () const { - if (m_lldb_object_sp) - return m_lldb_object_sp->GetAddressByteSize(); + if (m_opaque_sp) + return m_opaque_sp->GetAddressByteSize(); else return 0; } - -void -SBProcess::DisplayThreadsInfo (FILE *out, FILE *err, bool only_threads_with_stop_reason) -{ - if (m_lldb_object_sp != NULL) - { - size_t num_thread_infos_dumped = 0; - size_t num_threads = GetNumThreads(); - - if (out == NULL) - out = SBDebugger::GetOutputFileHandle(); - - if (err == NULL) - err = SBDebugger::GetErrorFileHandle(); - - if ((out == NULL) ||(err == NULL)) - return; - - if (num_threads > 0) - { - Thread::StopInfo thread_stop_info; - SBThread curr_thread (m_lldb_object_sp->GetThreadList().GetCurrentThread()); - for (int i = 0; i < num_threads; ++i) - { - SBThread thread (m_lldb_object_sp->GetThreadList().GetThreadAtIndex(i)); - if (thread.IsValid()) - { - bool is_current_thread = false; - StreamFile str (out); - if (thread == curr_thread) - is_current_thread = true; - StopReason thread_stop_reason = eStopReasonNone; - if (thread->GetStopInfo (&thread_stop_info)) - { - thread_stop_reason = thread_stop_info.GetStopReason(); - if (thread_stop_reason == eStopReasonNone) - { - if (only_threads_with_stop_reason && !is_current_thread) - continue; - } - } - ++num_thread_infos_dumped; - fprintf (out, " %c thread #%u: tid = 0x%4.4x, pc = 0x%16.16llx", - (is_current_thread ? '*' : ' '), - thread->GetIndexID(), thread->GetID(), thread->GetRegisterContext()->GetPC()); - - StackFrameSP frame_sp(thread->GetStackFrameAtIndex (0)); - if (frame_sp) - { - SymbolContext sc (frame_sp->GetSymbolContext (eSymbolContextEverything)); - fprintf (out, ", where = "); - sc.DumpStopContext (&str, m_lldb_object_sp.get(), frame_sp->GetPC ()); - } - - if (thread_stop_reason != eStopReasonNone) - { - fprintf (out, ", stop reason = "); - thread_stop_info.Dump (&str); - } - - const char *thread_name = thread->GetName(); - if (thread_name && thread_name[0]) - fprintf (out, ", thread_name = '%s'", thread_name); - - fprintf (out, "\n"); - - SBThread sb_thread (thread); - sb_thread.DisplayFramesForCurrentContext (out, err, 0, 1, false, 1); - } - } - } - } -} bool SBProcess::WaitUntilProcessHasStopped (SBCommandReturnObject &result) { @@ -340,11 +268,11 @@ if (IsValid()) { EventSP event_sp; - StateType state = m_lldb_object_sp->WaitForStateChangedEvents (NULL, event_sp); + StateType state = m_opaque_sp->WaitForStateChangedEvents (NULL, event_sp); while (StateIsStoppedState (state)) { - state = m_lldb_object_sp->WaitForStateChangedEvents (NULL, event_sp); + state = m_opaque_sp->WaitForStateChangedEvents (NULL, event_sp); SBEvent event (event_sp); AppendCurrentStateReport (event, result); state_changed = true; @@ -358,7 +286,7 @@ { SBError sb_error; if (IsValid()) - sb_error.SetError(m_lldb_object_sp->Resume()); + sb_error.SetError(m_opaque_sp->Resume()); else sb_error.SetErrorString ("SBProcess is invalid"); @@ -370,8 +298,8 @@ SBProcess::Destroy () { SBError sb_error; - if (m_lldb_object_sp) - sb_error.SetError(m_lldb_object_sp->Destroy()); + if (m_opaque_sp) + sb_error.SetError(m_opaque_sp->Destroy()); else sb_error.SetErrorString ("SBProcess is invalid"); @@ -384,7 +312,7 @@ { SBError sb_error; if (IsValid()) - sb_error.SetError (m_lldb_object_sp->Halt()); + sb_error.SetError (m_opaque_sp->Halt()); else sb_error.SetErrorString ("SBProcess is invalid"); return sb_error; @@ -394,8 +322,8 @@ SBProcess::Kill () { SBError sb_error; - if (m_lldb_object_sp) - sb_error.SetError (m_lldb_object_sp->Destroy()); + if (m_opaque_sp) + sb_error.SetError (m_opaque_sp->Destroy()); else sb_error.SetErrorString ("SBProcess is invalid"); return sb_error; @@ -406,8 +334,8 @@ SBProcess::AttachByName (const char *name, bool wait_for_launch) { SBError sb_error; - if (m_lldb_object_sp) - sb_error.SetError (m_lldb_object_sp->Attach (name, wait_for_launch)); + 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; @@ -425,8 +353,8 @@ SBProcess::Attach (lldb::pid_t attach_pid) { SBError sb_error; - if (m_lldb_object_sp) - sb_error.SetError (m_lldb_object_sp->Attach (attach_pid)); + if (m_opaque_sp) + sb_error.SetError (m_opaque_sp->Attach (attach_pid)); else sb_error.SetErrorString ("SBProcess is invalid"); return sb_error; @@ -436,8 +364,8 @@ SBProcess::Detach () { SBError sb_error; - if (m_lldb_object_sp) - sb_error.SetError (m_lldb_object_sp->Detach()); + if (m_opaque_sp) + sb_error.SetError (m_opaque_sp->Detach()); else sb_error.SetErrorString ("SBProcess is invalid"); @@ -448,102 +376,38 @@ SBProcess::Signal (int signal) { SBError sb_error; - if (m_lldb_object_sp) - sb_error.SetError (m_lldb_object_sp->Signal (signal)); + if (m_opaque_sp) + sb_error.SetError (m_opaque_sp->Signal (signal)); else sb_error.SetErrorString ("SBProcess is invalid"); return sb_error; } -void -SBProcess::ListThreads () -{ - FILE *out = SBDebugger::GetOutputFileHandle(); - if (out == NULL) - return; - - if (m_lldb_object_sp) - { - size_t num_threads = GetNumThreads (); - if (num_threads > 0) - { - Thread *cur_thread = m_lldb_object_sp->GetThreadList().GetCurrentThread().get(); - for (int i = 0; i < num_threads; ++i) - { - Thread *thread = m_lldb_object_sp->GetThreadList().GetThreadAtIndex(i).get(); - if (thread) - { - bool is_current_thread = false; - if (thread == cur_thread) - is_current_thread = true; - fprintf (out, " [%u] %c tid = 0x%4.4x, pc = 0x%16.16llx", - i, - (is_current_thread ? '*' : ' '), - thread->GetID(), - thread->GetRegisterContext()->GetPC()); - const char *thread_name = thread->GetName(); - if (thread_name && thread_name[0]) - fprintf (out, ", name = %s", thread_name); - const char *queue_name = thread->GetQueueName(); - if (queue_name && queue_name[0]) - fprintf (out, ", queue = %s", queue_name); - fprintf (out, "\n"); - } - } - } - } -} - SBThread SBProcess::GetThreadByID (tid_t sb_thread_id) { SBThread thread; - if (m_lldb_object_sp) - thread.SetThread (m_lldb_object_sp->GetThreadList().FindThreadByID ((tid_t) sb_thread_id)); + if (m_opaque_sp) + thread.SetThread (m_opaque_sp->GetThreadList().FindThreadByID ((tid_t) sb_thread_id)); return thread; } -void -SBProcess::Backtrace (bool all_threads, uint32_t num_frames) -{ - if (m_lldb_object_sp) - { - if (!all_threads) - { - SBDebugger::UpdateCurrentThread (*this); - SBThread cur_thread = GetCurrentThread(); - if (cur_thread.IsValid()) - cur_thread.Backtrace (num_frames); - } - else - { - int num_threads = GetNumThreads (); - for (int i = 0; i < num_threads; ++i) - { - SBThread sb_thread = GetThreadAtIndex (i); - sb_thread.Backtrace (num_frames); - } - } - } -} - StateType SBProcess::GetStateFromEvent (const SBEvent &event) { - return Process::ProcessEventData::GetStateFromEvent (event.GetLLDBObjectPtr()); + return Process::ProcessEventData::GetStateFromEvent (event.get()); } - bool SBProcess::GetRestartedFromEvent (const SBEvent &event) { - return Process::ProcessEventData::GetRestartedFromEvent (event.GetLLDBObjectPtr()); + return Process::ProcessEventData::GetRestartedFromEvent (event.get()); } SBProcess SBProcess::GetProcessFromEvent (const SBEvent &event) { - SBProcess process(Process::ProcessEventData::GetProcessFromEvent (event.GetLLDBObjectPtr())); + SBProcess process(Process::ProcessEventData::GetProcessFromEvent (event.get())); return process; } @@ -551,14 +415,14 @@ SBBroadcaster SBProcess::GetBroadcaster () const { - SBBroadcaster broadcaster(m_lldb_object_sp.get(), false); + SBBroadcaster broadcaster(m_opaque_sp.get(), false); return broadcaster; } lldb_private::Process * SBProcess::operator->() const { - return m_lldb_object_sp.get(); + return m_opaque_sp.get(); } size_t @@ -569,7 +433,7 @@ if (IsValid()) { Error error; - bytes_read = m_lldb_object_sp->ReadMemory (addr, dst, dst_len, error); + bytes_read = m_opaque_sp->ReadMemory (addr, dst, dst_len, error); sb_error.SetError (error); } else @@ -588,7 +452,7 @@ if (IsValid()) { Error error; - bytes_written = m_lldb_object_sp->WriteMemory (addr, src, src_len, error); + bytes_written = m_opaque_sp->WriteMemory (addr, src, src_len, error); sb_error.SetError (error); } @@ -599,6 +463,6 @@ lldb_private::Process * SBProcess::get() const { - return m_lldb_object_sp.get(); + return m_opaque_sp.get(); } Modified: lldb/trunk/source/API/SBSourceManager.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBSourceManager.cpp?rev=106615&r1=106614&r2=106615&view=diff ============================================================================== --- lldb/trunk/source/API/SBSourceManager.cpp (original) +++ lldb/trunk/source/API/SBSourceManager.cpp Tue Jun 22 20:19:29 2010 @@ -21,7 +21,7 @@ SBSourceManager::SBSourceManager (SourceManager& source_manager) : - m_source_manager (source_manager) + m_opaque_ref (source_manager) { } @@ -48,12 +48,12 @@ StreamFile str (f); - return m_source_manager.DisplaySourceLinesWithLineNumbers (*file, - line, - context_before, - context_after, - current_line_cstr, - &str); + return m_opaque_ref.DisplaySourceLinesWithLineNumbers (*file, + line, + context_before, + context_after, + current_line_cstr, + &str); } return 0; } @@ -61,5 +61,5 @@ SourceManager & SBSourceManager::GetLLDBManager () { - return m_source_manager; + return m_opaque_ref; } Modified: lldb/trunk/source/API/SBStringList.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBStringList.cpp?rev=106615&r1=106614&r2=106615&view=diff ============================================================================== --- lldb/trunk/source/API/SBStringList.cpp (original) +++ lldb/trunk/source/API/SBStringList.cpp Tue Jun 22 20:19:29 2010 @@ -15,22 +15,22 @@ using namespace lldb_private; SBStringList::SBStringList () : - m_lldb_object_ap () + m_opaque_ap () { } SBStringList::SBStringList (const lldb_private::StringList *lldb_strings_ptr) : - m_lldb_object_ap () + m_opaque_ap () { if (lldb_strings_ptr) - m_lldb_object_ap.reset (new lldb_private::StringList (*lldb_strings_ptr)); + m_opaque_ap.reset (new lldb_private::StringList (*lldb_strings_ptr)); } SBStringList::SBStringList (const SBStringList &rhs) : - m_lldb_object_ap () + m_opaque_ap () { if (rhs.IsValid()) - m_lldb_object_ap.reset (new lldb_private::StringList(*rhs)); + m_opaque_ap.reset (new lldb_private::StringList(*rhs)); } @@ -44,7 +44,7 @@ SBStringList::operator = (const SBStringList &rhs) { if (rhs.IsValid()) - m_lldb_object_ap.reset (new lldb_private::StringList(*rhs)); + m_opaque_ap.reset (new lldb_private::StringList(*rhs)); return *this; } @@ -52,19 +52,19 @@ const lldb_private::StringList * SBStringList::operator->() const { - return m_lldb_object_ap.get(); + return m_opaque_ap.get(); } const lldb_private::StringList & SBStringList::operator*() const { - return *m_lldb_object_ap; + return *m_opaque_ap; } bool SBStringList::IsValid() const { - return (m_lldb_object_ap.get() != NULL); + return (m_opaque_ap.get() != NULL); } void @@ -73,9 +73,9 @@ if (str != NULL) { if (IsValid()) - m_lldb_object_ap->AppendString (str); + m_opaque_ap->AppendString (str); else - m_lldb_object_ap.reset (new lldb_private::StringList (str)); + m_opaque_ap.reset (new lldb_private::StringList (str)); } } @@ -87,9 +87,9 @@ && (strc > 0)) { if (IsValid()) - m_lldb_object_ap->AppendList (strv, strc); + m_opaque_ap->AppendList (strv, strc); else - m_lldb_object_ap.reset (new lldb_private::StringList (strv, strc)); + m_opaque_ap.reset (new lldb_private::StringList (strv, strc)); } } @@ -99,8 +99,8 @@ if (strings.IsValid()) { if (! IsValid()) - m_lldb_object_ap.reset (new lldb_private::StringList()); - m_lldb_object_ap->AppendList (*(strings.m_lldb_object_ap)); + m_opaque_ap.reset (new lldb_private::StringList()); + m_opaque_ap->AppendList (*(strings.m_opaque_ap)); } } @@ -109,7 +109,7 @@ { if (IsValid()) { - return m_lldb_object_ap->GetSize(); + return m_opaque_ap->GetSize(); } return 0; } @@ -119,7 +119,7 @@ { if (IsValid()) { - return m_lldb_object_ap->GetStringAtIndex (idx); + return m_opaque_ap->GetStringAtIndex (idx); } return NULL; } @@ -129,6 +129,6 @@ { if (IsValid()) { - m_lldb_object_ap->Clear(); + m_opaque_ap->Clear(); } } Modified: lldb/trunk/source/API/SBSymbol.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBSymbol.cpp?rev=106615&r1=106614&r2=106615&view=diff ============================================================================== --- lldb/trunk/source/API/SBSymbol.cpp (original) +++ lldb/trunk/source/API/SBSymbol.cpp Tue Jun 22 20:19:29 2010 @@ -14,39 +14,39 @@ SBSymbol::SBSymbol () : - m_lldb_object_ptr (NULL) + m_opaque_ptr (NULL) { } SBSymbol::SBSymbol (lldb_private::Symbol *lldb_object_ptr) : - m_lldb_object_ptr (lldb_object_ptr) + m_opaque_ptr (lldb_object_ptr) { } SBSymbol::~SBSymbol () { - m_lldb_object_ptr = NULL; + m_opaque_ptr = NULL; } bool SBSymbol::IsValid () const { - return m_lldb_object_ptr != NULL; + return m_opaque_ptr != NULL; } const char * SBSymbol::GetName() const { - if (m_lldb_object_ptr) - return m_lldb_object_ptr->GetMangled().GetName().AsCString(); + if (m_opaque_ptr) + return m_opaque_ptr->GetMangled().GetName().AsCString(); return NULL; } const char * SBSymbol::GetMangledName () const { - if (m_lldb_object_ptr) - return m_lldb_object_ptr->GetMangled().GetMangledName().AsCString(); + if (m_opaque_ptr) + return m_opaque_ptr->GetMangled().GetMangledName().AsCString(); return NULL; } @@ -54,11 +54,11 @@ bool SBSymbol::operator == (const SBSymbol &rhs) const { - return m_lldb_object_ptr == rhs.m_lldb_object_ptr; + return m_opaque_ptr == rhs.m_opaque_ptr; } bool SBSymbol::operator != (const SBSymbol &rhs) const { - return m_lldb_object_ptr != rhs.m_lldb_object_ptr; + return m_opaque_ptr != rhs.m_opaque_ptr; } Modified: lldb/trunk/source/API/SBSymbolContext.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBSymbolContext.cpp?rev=106615&r1=106614&r2=106615&view=diff ============================================================================== --- lldb/trunk/source/API/SBSymbolContext.cpp (original) +++ lldb/trunk/source/API/SBSymbolContext.cpp Tue Jun 22 20:19:29 2010 @@ -16,22 +16,22 @@ SBSymbolContext::SBSymbolContext () : - m_lldb_object_ap () + m_opaque_ap () { } SBSymbolContext::SBSymbolContext (const SymbolContext *sc_ptr) : - m_lldb_object_ap () + m_opaque_ap () { if (sc_ptr) - m_lldb_object_ap.reset (new SymbolContext (*sc_ptr)); + m_opaque_ap.reset (new SymbolContext (*sc_ptr)); } SBSymbolContext::SBSymbolContext (const SBSymbolContext& rhs) : - m_lldb_object_ap () + m_opaque_ap () { if (rhs.IsValid()) - *m_lldb_object_ap = *rhs.m_lldb_object_ap; + *m_opaque_ap = *rhs.m_opaque_ap; } SBSymbolContext::~SBSymbolContext () @@ -44,7 +44,7 @@ if (this != &rhs) { if (rhs.IsValid()) - m_lldb_object_ap.reset (new lldb_private::SymbolContext(*rhs.m_lldb_object_ap.get())); + m_opaque_ap.reset (new lldb_private::SymbolContext(*rhs.m_opaque_ap.get())); } return *this; } @@ -54,22 +54,22 @@ { if (sc_ptr) { - if (m_lldb_object_ap.get()) - *m_lldb_object_ap = *sc_ptr; + if (m_opaque_ap.get()) + *m_opaque_ap = *sc_ptr; else - m_lldb_object_ap.reset (new SymbolContext (*sc_ptr)); + m_opaque_ap.reset (new SymbolContext (*sc_ptr)); } else { - if (m_lldb_object_ap.get()) - m_lldb_object_ap->Clear(); + if (m_opaque_ap.get()) + m_opaque_ap->Clear(); } } bool SBSymbolContext::IsValid () const { - return m_lldb_object_ap.get() != NULL; + return m_opaque_ap.get() != NULL; } @@ -78,35 +78,35 @@ SBSymbolContext::GetModule () { SBModule sb_module; - if (m_lldb_object_ap.get()) - sb_module.SetModule(m_lldb_object_ap->module_sp); + if (m_opaque_ap.get()) + sb_module.SetModule(m_opaque_ap->module_sp); return sb_module; } SBCompileUnit SBSymbolContext::GetCompileUnit () { - return SBCompileUnit (m_lldb_object_ap.get() ? m_lldb_object_ap->comp_unit : NULL); + return SBCompileUnit (m_opaque_ap.get() ? m_opaque_ap->comp_unit : NULL); } SBFunction SBSymbolContext::GetFunction () { - return SBFunction (m_lldb_object_ap.get() ? m_lldb_object_ap->function : NULL); + return SBFunction (m_opaque_ap.get() ? m_opaque_ap->function : NULL); } SBBlock SBSymbolContext::GetBlock () { - return SBBlock (m_lldb_object_ap.get() ? m_lldb_object_ap->block : NULL); + return SBBlock (m_opaque_ap.get() ? m_opaque_ap->block : NULL); } SBLineEntry SBSymbolContext::GetLineEntry () { SBLineEntry sb_line_entry; - if (m_lldb_object_ap.get()) - sb_line_entry.SetLineEntry (m_lldb_object_ap->line_entry); + if (m_opaque_ap.get()) + sb_line_entry.SetLineEntry (m_opaque_ap->line_entry); return sb_line_entry; } @@ -114,19 +114,19 @@ SBSymbol SBSymbolContext::GetSymbol () { - return SBSymbol (m_lldb_object_ap.get() ? m_lldb_object_ap->symbol : NULL); + return SBSymbol (m_opaque_ap.get() ? m_opaque_ap->symbol : NULL); } lldb_private::SymbolContext* SBSymbolContext::operator->() const { - return m_lldb_object_ap.get(); + return m_opaque_ap.get(); } lldb_private::SymbolContext * SBSymbolContext::GetLLDBObjectPtr() const { - return m_lldb_object_ap.get(); + return m_opaque_ap.get(); } Modified: lldb/trunk/source/API/SBTarget.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBTarget.cpp?rev=106615&r1=106614&r2=106615&view=diff ============================================================================== --- lldb/trunk/source/API/SBTarget.cpp (original) +++ lldb/trunk/source/API/SBTarget.cpp Tue Jun 22 20:19:29 2010 @@ -53,12 +53,12 @@ } SBTarget::SBTarget (const SBTarget& rhs) : - m_target_sp (rhs.m_target_sp) + m_opaque_sp (rhs.m_opaque_sp) { } SBTarget::SBTarget(const TargetSP& target_sp) : - m_target_sp (target_sp) + m_opaque_sp (target_sp) { } @@ -67,7 +67,7 @@ { if (this != &rhs) { - m_target_sp = rhs.m_target_sp; + m_opaque_sp = rhs.m_opaque_sp; } return *this; } @@ -83,28 +83,37 @@ bool SBTarget::IsValid () const { - return m_target_sp.get() != NULL; + return m_opaque_sp.get() != NULL; } SBProcess SBTarget::GetProcess () { SBProcess sb_process; - if (IsValid()) - sb_process.SetProcess (m_target_sp->GetProcessSP()); + if (m_opaque_sp) + sb_process.SetProcess (m_opaque_sp->GetProcessSP()); return sb_process; } +SBDebugger +SBTarget::GetDebugger () const +{ + SBDebugger debugger; + if (m_opaque_sp) + debugger.reset (m_opaque_sp->GetDebugger().GetSP()); + return debugger; +} + SBProcess SBTarget::CreateProcess () { SBProcess sb_process; - if (IsValid()) + if (m_opaque_sp) { - SBListener sb_listener = SBDebugger::GetListener(); + SBListener sb_listener (m_opaque_sp->GetDebugger().GetListener()); if (sb_listener.IsValid()) - sb_process.SetProcess (m_target_sp->CreateProcess (*sb_listener)); + sb_process.SetProcess (m_opaque_sp->CreateProcess (*sb_listener)); } return sb_process; } @@ -141,9 +150,9 @@ SBTarget::GetExecutable () { SBFileSpec exe_file_spec; - if (IsValid()) + if (m_opaque_sp) { - ModuleSP exe_module_sp (m_target_sp->GetExecutableModule ()); + ModuleSP exe_module_sp (m_opaque_sp->GetExecutableModule ()); if (exe_module_sp) exe_file_spec.SetFileSpec (exe_module_sp->GetFileSpec()); } @@ -154,8 +163,8 @@ bool SBTarget::DeleteTargetFromList (TargetList *list) { - if (IsValid()) - return list->DeleteTarget (m_target_sp); + if (m_opaque_sp) + return list->DeleteTarget (m_opaque_sp); else return false; } @@ -163,9 +172,9 @@ bool SBTarget::MakeCurrentTarget () { - if (IsValid()) + if (m_opaque_sp) { - Debugger::GetSharedInstance().GetTargetList().SetCurrentTarget (m_target_sp.get()); + m_opaque_sp->GetDebugger().GetTargetList().SetCurrentTarget (m_opaque_sp.get()); return true; } return false; @@ -174,24 +183,31 @@ bool SBTarget::operator == (const SBTarget &rhs) const { - return m_target_sp.get() == rhs.m_target_sp.get(); + return m_opaque_sp.get() == rhs.m_opaque_sp.get(); } bool SBTarget::operator != (const SBTarget &rhs) const { - return m_target_sp.get() != rhs.m_target_sp.get(); + return m_opaque_sp.get() != rhs.m_opaque_sp.get(); } lldb_private::Target * -SBTarget::GetLLDBObjectPtr() +SBTarget::operator ->() const { - return m_target_sp.get(); + return m_opaque_sp.get(); } -const lldb_private::Target * -SBTarget::GetLLDBObjectPtr() const + +lldb_private::Target * +SBTarget::get() const +{ + return m_opaque_sp.get(); +} + +void +SBTarget::reset (const lldb::TargetSP& target_sp) { - return m_target_sp.get(); + m_opaque_sp = target_sp; } SBBreakpoint @@ -207,8 +223,8 @@ SBTarget::BreakpointCreateByLocation (const SBFileSpec &sb_file_spec, uint32_t line) { SBBreakpoint sb_bp; - if (m_target_sp.get() && line != 0) - *sb_bp = m_target_sp->CreateBreakpoint (NULL, *sb_file_spec, line, true, false); + if (m_opaque_sp.get() && line != 0) + *sb_bp = m_opaque_sp->CreateBreakpoint (NULL, *sb_file_spec, line, true, false); return sb_bp; } @@ -216,16 +232,16 @@ SBTarget::BreakpointCreateByName (const char *symbol_name, const char *module_name) { SBBreakpoint sb_bp; - if (m_target_sp.get() && symbol_name && symbol_name[0]) + if (m_opaque_sp.get() && symbol_name && symbol_name[0]) { if (module_name && module_name[0]) { FileSpec module_file_spec(module_name); - *sb_bp = m_target_sp->CreateBreakpoint (&module_file_spec, symbol_name, false); + *sb_bp = m_opaque_sp->CreateBreakpoint (&module_file_spec, symbol_name, false); } else { - *sb_bp = m_target_sp->CreateBreakpoint (NULL, symbol_name, false); + *sb_bp = m_opaque_sp->CreateBreakpoint (NULL, symbol_name, false); } } return sb_bp; @@ -235,7 +251,7 @@ SBTarget::BreakpointCreateByRegex (const char *symbol_name_regex, const char *module_name) { SBBreakpoint sb_bp; - if (m_target_sp.get() && symbol_name_regex && symbol_name_regex[0]) + if (m_opaque_sp.get() && symbol_name_regex && symbol_name_regex[0]) { RegularExpression regexp(symbol_name_regex); @@ -243,11 +259,11 @@ { FileSpec module_file_spec(module_name); - *sb_bp = m_target_sp->CreateBreakpoint (&module_file_spec, regexp, false); + *sb_bp = m_opaque_sp->CreateBreakpoint (&module_file_spec, regexp, false); } else { - *sb_bp = m_target_sp->CreateBreakpoint (NULL, regexp, false); + *sb_bp = m_opaque_sp->CreateBreakpoint (NULL, regexp, false); } } return sb_bp; @@ -259,22 +275,22 @@ SBTarget::BreakpointCreateByAddress (addr_t address) { SBBreakpoint sb_bp; - if (m_target_sp.get()) - *sb_bp = m_target_sp->CreateBreakpoint (address, false); + if (m_opaque_sp.get()) + *sb_bp = m_opaque_sp->CreateBreakpoint (address, false); return sb_bp; } void SBTarget::ListAllBreakpoints () { - FILE *out_file = SBDebugger::GetOutputFileHandle(); + FILE *out_file = m_opaque_sp->GetDebugger().GetOutputFileHandle(); if (out_file == NULL) return; - if (IsValid()) + if (m_opaque_sp) { - const BreakpointList &bp_list = m_target_sp->GetBreakpointList(); + const BreakpointList &bp_list = m_opaque_sp->GetBreakpointList(); size_t num_bps = bp_list.GetSize(); for (int i = 0; i < num_bps; ++i) { @@ -288,8 +304,8 @@ SBTarget::FindBreakpointByID (break_id_t bp_id) { SBBreakpoint sb_breakpoint; - if (m_target_sp && bp_id != LLDB_INVALID_BREAK_ID) - *sb_breakpoint = m_target_sp->GetBreakpointByID (bp_id); + if (m_opaque_sp && bp_id != LLDB_INVALID_BREAK_ID) + *sb_breakpoint = m_opaque_sp->GetBreakpointByID (bp_id); return sb_breakpoint; } @@ -297,17 +313,17 @@ bool SBTarget::BreakpointDelete (break_id_t bp_id) { - if (m_target_sp) - return m_target_sp->RemoveBreakpointByID (bp_id); + if (m_opaque_sp) + return m_opaque_sp->RemoveBreakpointByID (bp_id); return false; } bool SBTarget::EnableAllBreakpoints () { - if (m_target_sp) + if (m_opaque_sp) { - m_target_sp->EnableAllBreakpoints (); + m_opaque_sp->EnableAllBreakpoints (); return true; } return false; @@ -316,9 +332,9 @@ bool SBTarget::DisableAllBreakpoints () { - if (m_target_sp) + if (m_opaque_sp) { - m_target_sp->DisableAllBreakpoints (); + m_opaque_sp->DisableAllBreakpoints (); return true; } return false; @@ -327,9 +343,9 @@ bool SBTarget::DeleteAllBreakpoints () { - if (m_target_sp) + if (m_opaque_sp) { - m_target_sp->RemoveAllBreakpoints (); + m_opaque_sp->RemoveAllBreakpoints (); return true; } return false; @@ -339,8 +355,8 @@ uint32_t SBTarget::GetNumModules () const { - if (m_target_sp) - return m_target_sp->GetImages().GetSize(); + if (m_opaque_sp) + return m_opaque_sp->GetImages().GetSize(); return 0; } @@ -348,8 +364,8 @@ SBTarget::FindModule (const SBFileSpec &sb_file_spec) { SBModule sb_module; - if (m_target_sp && sb_file_spec.IsValid()) - sb_module.SetModule (m_target_sp->GetImages().FindFirstModuleForFileSpec (*sb_file_spec, NULL)); + if (m_opaque_sp && sb_file_spec.IsValid()) + sb_module.SetModule (m_opaque_sp->GetImages().FindFirstModuleForFileSpec (*sb_file_spec, NULL)); return sb_module; } @@ -357,8 +373,8 @@ SBTarget::GetModuleAtIndex (uint32_t idx) { SBModule sb_module; - if (m_target_sp) - sb_module.SetModule(m_target_sp->GetImages().GetModuleAtIndex(idx)); + if (m_opaque_sp) + sb_module.SetModule(m_opaque_sp->GetImages().GetModuleAtIndex(idx)); return sb_module; } @@ -366,7 +382,7 @@ SBBroadcaster SBTarget::GetBroadcaster () const { - SBBroadcaster broadcaster(m_target_sp.get(), false); + SBBroadcaster broadcaster(m_opaque_sp.get(), false); return broadcaster; } @@ -376,11 +392,11 @@ if (file_address_start == LLDB_INVALID_ADDRESS) return; - FILE *out = SBDebugger::GetOutputFileHandle(); + FILE *out = m_opaque_sp->GetDebugger().GetOutputFileHandle(); if (out == NULL) return; - if (IsValid()) + if (m_opaque_sp) { SBModule module; if (module_name != NULL) @@ -388,7 +404,7 @@ SBFileSpec file_spec (module_name); module = FindModule (file_spec); } - ArchSpec arch (m_target_sp->GetArchitecture()); + ArchSpec arch (m_opaque_sp->GetArchitecture()); if (!arch.IsValid()) return; Disassembler *disassembler = Disassembler::FindPlugin (arch); @@ -446,11 +462,11 @@ if (function_name == NULL) return; - FILE *out = SBDebugger::GetOutputFileHandle(); + FILE *out = m_opaque_sp->GetDebugger().GetOutputFileHandle(); if (out == NULL) return; - if (IsValid()) + if (m_opaque_sp) { SBModule module; @@ -460,7 +476,7 @@ module = FindModule (file_spec); } - ArchSpec arch (m_target_sp->GetArchitecture()); + ArchSpec arch (m_opaque_sp->GetArchitecture()); if (!arch.IsValid()) return; @@ -486,7 +502,7 @@ if (module_name != NULL) containing_module = new FileSpec (module_name); - SearchFilterSP filter_sp (m_target_sp->GetSearchFilterForModule (containing_module)); + SearchFilterSP filter_sp (m_opaque_sp->GetSearchFilterForModule (containing_module)); AddressResolverSP resolver_sp (new AddressResolverName (function_name)); resolver_sp->ResolveAddress (*filter_sp); Modified: lldb/trunk/source/API/SBThread.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBThread.cpp?rev=106615&r1=106614&r2=106615&view=diff ============================================================================== --- lldb/trunk/source/API/SBThread.cpp (original) +++ lldb/trunk/source/API/SBThread.cpp Tue Jun 22 20:19:29 2010 @@ -11,8 +11,10 @@ #include "lldb/API/SBSymbolContext.h" #include "lldb/API/SBFileSpec.h" +#include "lldb/Core/Debugger.h" #include "lldb/Core/Stream.h" #include "lldb/Core/StreamFile.h" +#include "lldb/Interpreter/CommandInterpreter.h" #include "lldb/Target/Thread.h" #include "lldb/Target/Process.h" #include "lldb/Symbol/SymbolContext.h" @@ -35,7 +37,7 @@ using namespace lldb_private; SBThread::SBThread () : - m_lldb_object_sp () + m_opaque_sp () { } @@ -43,13 +45,13 @@ // Thread constructor //---------------------------------------------------------------------- SBThread::SBThread (const ThreadSP& lldb_object_sp) : - m_lldb_object_sp (lldb_object_sp) + m_opaque_sp (lldb_object_sp) { } SBThread::SBThread (const SBThread &rhs) { - m_lldb_object_sp = rhs.m_lldb_object_sp; + m_opaque_sp = rhs.m_opaque_sp; } //---------------------------------------------------------------------- @@ -62,16 +64,16 @@ bool SBThread::IsValid() const { - return m_lldb_object_sp != NULL; + return m_opaque_sp != NULL; } StopReason SBThread::GetStopReason() { - if (m_lldb_object_sp) + if (m_opaque_sp) { lldb_private::Thread::StopInfo thread_stop_info; - if (m_lldb_object_sp->GetStopInfo(&thread_stop_info)) + if (m_opaque_sp->GetStopInfo(&thread_stop_info)) return thread_stop_info.GetStopReason(); } return eStopReasonInvalid; @@ -80,10 +82,10 @@ size_t SBThread::GetStopDescription (char *dst, size_t dst_len) { - if (m_lldb_object_sp) + if (m_opaque_sp) { lldb_private::Thread::StopInfo thread_stop_info; - if (m_lldb_object_sp->GetStopInfo(&thread_stop_info)) + if (m_opaque_sp->GetStopInfo(&thread_stop_info)) { const char *stop_desc = thread_stop_info.GetStopDescription(); if (stop_desc) @@ -129,7 +131,7 @@ case eStopReasonSignal: { - stop_desc = m_lldb_object_sp->GetProcess().GetUnixSignals ().GetSignalAsCString (thread_stop_info.GetSignal()); + stop_desc = m_opaque_sp->GetProcess().GetUnixSignals ().GetSignalAsCString (thread_stop_info.GetSignal()); if (stop_desc == NULL || stop_desc[0] == '\0') { static char signal_desc[] = "signal"; @@ -169,15 +171,15 @@ void SBThread::SetThread (const ThreadSP& lldb_object_sp) { - m_lldb_object_sp = lldb_object_sp; + m_opaque_sp = lldb_object_sp; } lldb::tid_t SBThread::GetThreadID () const { - if (m_lldb_object_sp) - return m_lldb_object_sp->GetID(); + if (m_opaque_sp) + return m_opaque_sp->GetID(); else return LLDB_INVALID_THREAD_ID; } @@ -185,23 +187,23 @@ uint32_t SBThread::GetIndexID () const { - if (m_lldb_object_sp) - return m_lldb_object_sp->GetIndexID(); + if (m_opaque_sp) + return m_opaque_sp->GetIndexID(); return LLDB_INVALID_INDEX32; } const char * SBThread::GetName () const { - if (m_lldb_object_sp) - return m_lldb_object_sp->GetName(); + if (m_opaque_sp) + return m_opaque_sp->GetName(); return NULL; } const char * SBThread::GetQueueName () const { - if (m_lldb_object_sp) - return m_lldb_object_sp->GetQueueName(); + if (m_opaque_sp) + return m_opaque_sp->GetQueueName(); return NULL; } @@ -219,9 +221,9 @@ if ((out == NULL) || (err == NULL)) return; - if (m_lldb_object_sp) + if (m_opaque_sp) { - uint32_t num_stack_frames = m_lldb_object_sp->GetStackFrameCount (); + uint32_t num_stack_frames = m_opaque_sp->GetStackFrameCount (); StackFrameSP frame_sp; int frame_idx = 0; @@ -230,7 +232,7 @@ if (frame_idx >= num_stack_frames) break; - frame_sp = m_lldb_object_sp->GetStackFrameAtIndex (frame_idx); + frame_sp = m_opaque_sp->GetStackFrameAtIndex (frame_idx); if (!frame_sp) break; @@ -257,17 +259,16 @@ uint32_t source_lines_before) { bool success = false; - - if ((out == NULL) || (err == NULL)) + + if ((out == NULL) || (err == NULL)) return false; - - if (m_lldb_object_sp && frame.IsValid()) + + if (m_opaque_sp && frame.IsValid()) { - StreamFile str (out); - + SBSymbolContext sc(frame.GetSymbolContext(eSymbolContextEverything)); - + if (show_frame_info && sc.IsValid()) { user_id_t frame_idx = (user_id_t) frame.GetFrameID(); @@ -277,28 +278,28 @@ frame_idx, GetThreadID(), pc); - sc->DumpStopContext (&str, &m_lldb_object_sp->GetProcess(), *frame.GetPCAddress()); + sc->DumpStopContext (&str, &m_opaque_sp->GetProcess(), *frame.GetPCAddress()); fprintf (out, "\n"); success = true; } - + SBCompileUnit comp_unit(sc.GetCompileUnit()); if (show_source && comp_unit.IsValid()) { - success = false; + success = false; SBLineEntry line_entry; if (line_entry.IsValid()) { - SBSourceManager& source_manager = SBDebugger::GetSourceManager(); - SBFileSpec line_entry_file_spec = line_entry.GetFileSpec(); - + SourceManager& source_manager = m_opaque_sp->GetProcess().GetTarget().GetDebugger().GetSourceManager(); + SBFileSpec line_entry_file_spec (line_entry.GetFileSpec()); + if (line_entry_file_spec.IsValid()) { - source_manager.DisplaySourceLinesWithLineNumbers (line_entry_file_spec, + source_manager.DisplaySourceLinesWithLineNumbers (line_entry_file_spec.ref(), line_entry.GetLine(), source_lines_after, source_lines_before, "->", - out); + &str); success = true; } } @@ -310,17 +311,17 @@ void SBThread::StepOver (lldb::RunMode stop_other_threads) { - if (m_lldb_object_sp) + if (m_opaque_sp) { bool abort_other_plans = true; - StackFrameSP frame_sp(m_lldb_object_sp->GetStackFrameAtIndex (0)); + StackFrameSP frame_sp(m_opaque_sp->GetStackFrameAtIndex (0)); if (frame_sp) { if (frame_sp->HasDebugInformation ()) { SymbolContext sc(frame_sp->GetSymbolContext(eSymbolContextEverything)); - m_lldb_object_sp->QueueThreadPlanForStepRange (abort_other_plans, + m_opaque_sp->QueueThreadPlanForStepRange (abort_other_plans, eStepTypeOver, sc.line_entry.range, sc, @@ -330,15 +331,15 @@ } else { - m_lldb_object_sp->QueueThreadPlanForStepSingleInstruction (true, + m_opaque_sp->QueueThreadPlanForStepSingleInstruction (true, abort_other_plans, stop_other_threads); } } - Process &process = m_lldb_object_sp->GetProcess(); + Process &process = m_opaque_sp->GetProcess(); // Why do we need to set the current thread by ID here??? - process.GetThreadList().SetCurrentThreadByID (m_lldb_object_sp->GetID()); + process.GetThreadList().SetCurrentThreadByID (m_opaque_sp->GetID()); process.Resume(); } } @@ -346,17 +347,17 @@ void SBThread::StepInto (lldb::RunMode stop_other_threads) { - if (m_lldb_object_sp) + if (m_opaque_sp) { bool abort_other_plans = true; - StackFrameSP frame_sp(m_lldb_object_sp->GetStackFrameAtIndex (0)); + StackFrameSP frame_sp(m_opaque_sp->GetStackFrameAtIndex (0)); if (frame_sp && frame_sp->HasDebugInformation ()) { bool avoid_code_without_debug_info = true; SymbolContext sc(frame_sp->GetSymbolContext(eSymbolContextEverything)); - m_lldb_object_sp->QueueThreadPlanForStepRange (abort_other_plans, + m_opaque_sp->QueueThreadPlanForStepRange (abort_other_plans, eStepTypeInto, sc.line_entry.range, sc, @@ -365,14 +366,14 @@ } else { - m_lldb_object_sp->QueueThreadPlanForStepSingleInstruction (false, + m_opaque_sp->QueueThreadPlanForStepSingleInstruction (false, abort_other_plans, stop_other_threads); } - Process &process = m_lldb_object_sp->GetProcess(); + Process &process = m_opaque_sp->GetProcess(); // Why do we need to set the current thread by ID here??? - process.GetThreadList().SetCurrentThreadByID (m_lldb_object_sp->GetID()); + process.GetThreadList().SetCurrentThreadByID (m_opaque_sp->GetID()); process.Resume(); } @@ -381,15 +382,15 @@ void SBThread::StepOut () { - if (m_lldb_object_sp) + if (m_opaque_sp) { bool abort_other_plans = true; bool stop_other_threads = true; - m_lldb_object_sp->QueueThreadPlanForStepOut (abort_other_plans, NULL, false, stop_other_threads, eVoteYes, eVoteNoOpinion); + m_opaque_sp->QueueThreadPlanForStepOut (abort_other_plans, NULL, false, stop_other_threads, eVoteYes, eVoteNoOpinion); - Process &process = m_lldb_object_sp->GetProcess(); - process.GetThreadList().SetCurrentThreadByID (m_lldb_object_sp->GetID()); + Process &process = m_opaque_sp->GetProcess(); + process.GetThreadList().SetCurrentThreadByID (m_opaque_sp->GetID()); process.Resume(); } } @@ -397,11 +398,11 @@ void SBThread::StepInstruction (bool step_over) { - if (m_lldb_object_sp) + if (m_opaque_sp) { - m_lldb_object_sp->QueueThreadPlanForStepSingleInstruction (step_over, true, true); - Process &process = m_lldb_object_sp->GetProcess(); - process.GetThreadList().SetCurrentThreadByID (m_lldb_object_sp->GetID()); + m_opaque_sp->QueueThreadPlanForStepSingleInstruction (step_over, true, true); + Process &process = m_opaque_sp->GetProcess(); + process.GetThreadList().SetCurrentThreadByID (m_opaque_sp->GetID()); process.Resume(); } } @@ -409,67 +410,29 @@ void SBThread::RunToAddress (lldb::addr_t addr) { - if (m_lldb_object_sp) + if (m_opaque_sp) { bool abort_other_plans = true; bool stop_other_threads = true; Address target_addr (NULL, addr); - m_lldb_object_sp->QueueThreadPlanForRunToAddress (abort_other_plans, target_addr, stop_other_threads); - Process &process = m_lldb_object_sp->GetProcess(); - process.GetThreadList().SetCurrentThreadByID (m_lldb_object_sp->GetID()); + m_opaque_sp->QueueThreadPlanForRunToAddress (abort_other_plans, target_addr, stop_other_threads); + Process &process = m_opaque_sp->GetProcess(); + process.GetThreadList().SetCurrentThreadByID (m_opaque_sp->GetID()); process.Resume(); } } -void -SBThread::Backtrace (uint32_t num_frames) -{ - bool all_frames = false; - if (num_frames < 1) - all_frames = true; - - FILE *out = SBDebugger::GetOutputFileHandle(); - FILE *err = SBDebugger::GetErrorFileHandle(); - - if ((out == NULL) || (err == NULL)) - return; - - if (m_lldb_object_sp) - { - if (out && err) - { - int max_num_frames = m_lldb_object_sp->GetStackFrameCount(); - int last_frame = max_num_frames; - - if (!all_frames && (num_frames < last_frame)) - last_frame = num_frames; - - StackFrameSP frame_sp; - for (int i = 0; i < last_frame; ++i) - { - frame_sp = m_lldb_object_sp->GetStackFrameAtIndex (i); - if (!frame_sp) - break; - - SBFrame sb_frame (frame_sp); - if (DisplaySingleFrameForCurrentContext ((FILE *) out, (FILE *) err, sb_frame, true, false, 0, 0) == false) - break; - } - } - } -} - SBProcess SBThread::GetProcess () { SBProcess process; - if (m_lldb_object_sp) + if (m_opaque_sp) { // Have to go up to the target so we can get a shared pointer to our process... - process.SetProcess(m_lldb_object_sp->GetProcess().GetTarget().GetProcessSP()); + process.SetProcess(m_opaque_sp->GetProcess().GetTarget().GetProcessSP()); } return process; } @@ -477,8 +440,8 @@ uint32_t SBThread::GetNumFrames () { - if (m_lldb_object_sp) - return m_lldb_object_sp->GetStackFrameCount(); + if (m_opaque_sp) + return m_opaque_sp->GetStackFrameCount(); return 0; } @@ -486,56 +449,56 @@ SBThread::GetFrameAtIndex (uint32_t idx) { SBFrame sb_frame; - if (m_lldb_object_sp) - sb_frame.SetFrame (m_lldb_object_sp->GetStackFrameAtIndex (idx)); + if (m_opaque_sp) + sb_frame.SetFrame (m_opaque_sp->GetStackFrameAtIndex (idx)); return sb_frame; } const lldb::SBThread & SBThread::operator = (const lldb::SBThread &rhs) { - m_lldb_object_sp = rhs.m_lldb_object_sp; + m_opaque_sp = rhs.m_opaque_sp; return *this; } bool SBThread::operator == (const SBThread &rhs) const { - return m_lldb_object_sp.get() == rhs.m_lldb_object_sp.get(); + return m_opaque_sp.get() == rhs.m_opaque_sp.get(); } bool SBThread::operator != (const SBThread &rhs) const { - return m_lldb_object_sp.get() != rhs.m_lldb_object_sp.get(); + return m_opaque_sp.get() != rhs.m_opaque_sp.get(); } lldb_private::Thread * SBThread::GetLLDBObjectPtr () { - return m_lldb_object_sp.get(); + return m_opaque_sp.get(); } const lldb_private::Thread * SBThread::operator->() const { - return m_lldb_object_sp.get(); + return m_opaque_sp.get(); } const lldb_private::Thread & SBThread::operator*() const { - return *m_lldb_object_sp; + return *m_opaque_sp; } lldb_private::Thread * SBThread::operator->() { - return m_lldb_object_sp.get(); + return m_opaque_sp.get(); } lldb_private::Thread & SBThread::operator*() { - return *m_lldb_object_sp; + return *m_opaque_sp; } Modified: lldb/trunk/source/API/SBValue.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBValue.cpp?rev=106615&r1=106614&r2=106615&view=diff ============================================================================== --- lldb/trunk/source/API/SBValue.cpp (original) +++ lldb/trunk/source/API/SBValue.cpp Tue Jun 22 20:19:29 2010 @@ -33,12 +33,12 @@ using namespace lldb_private; SBValue::SBValue () : - m_lldb_object_sp () + m_opaque_sp () { } SBValue::SBValue (const lldb::ValueObjectSP &value_sp) : - m_lldb_object_sp (value_sp) + m_opaque_sp (value_sp) { } @@ -49,7 +49,7 @@ bool SBValue::IsValid () const { - return (m_lldb_object_sp.get() != NULL); + return (m_opaque_sp.get() != NULL); } void @@ -72,25 +72,25 @@ lldb_private::StreamFile out_stream (out_file); - out_stream.Printf ("%s ", m_lldb_object_sp->GetName().AsCString (NULL)); - if (! m_lldb_object_sp->IsInScope (lldb_frame)) + out_stream.Printf ("%s ", m_opaque_sp->GetName().AsCString (NULL)); + if (! m_opaque_sp->IsInScope (lldb_frame)) out_stream.Printf ("[out-of-scope] "); if (print_type) { - out_stream.Printf ("(%s) ", m_lldb_object_sp->GetTypeName().AsCString ("")); + out_stream.Printf ("(%s) ", m_opaque_sp->GetTypeName().AsCString ("")); } if (print_value) { ExecutionContextScope *exe_scope = frame->get(); - const char *val_cstr = m_lldb_object_sp->GetValueAsCString(exe_scope); - const char *err_cstr = m_lldb_object_sp->GetError().AsCString(); + const char *val_cstr = m_opaque_sp->GetValueAsCString(exe_scope); + const char *err_cstr = m_opaque_sp->GetError().AsCString(); if (!err_cstr) { - const char *sum_cstr = m_lldb_object_sp->GetSummaryAsCString(exe_scope); + const char *sum_cstr = m_opaque_sp->GetSummaryAsCString(exe_scope); const bool is_aggregate = - ClangASTContext::IsAggregateType (m_lldb_object_sp->GetOpaqueClangQualType()); + ClangASTContext::IsAggregateType (m_opaque_sp->GetOpaqueClangQualType()); if (val_cstr) out_stream.Printf ("= %s ", val_cstr); @@ -100,13 +100,13 @@ if (is_aggregate) { out_stream.PutChar ('{'); - const uint32_t num_children = m_lldb_object_sp->GetNumChildren(); + const uint32_t num_children = m_opaque_sp->GetNumChildren(); if (num_children) { out_stream.IndentMore(); for (uint32_t idx = 0; idx < num_children; ++idx) { - lldb::ValueObjectSP child_sp (m_lldb_object_sp->GetChildAtIndex (idx, true)); + lldb::ValueObjectSP child_sp (m_opaque_sp->GetChildAtIndex (idx, true)); if (child_sp.get()) { out_stream.EOL(); @@ -131,7 +131,7 @@ SBValue::GetName() { if (IsValid()) - return m_lldb_object_sp->GetName().AsCString(); + return m_opaque_sp->GetName().AsCString(); else return NULL; } @@ -140,7 +140,7 @@ SBValue::GetTypeName () { if (IsValid()) - return m_lldb_object_sp->GetTypeName().AsCString(); + return m_opaque_sp->GetTypeName().AsCString(); else return NULL; } @@ -151,7 +151,7 @@ size_t result = 0; if (IsValid()) - result = m_lldb_object_sp->GetByteSize(); + result = m_opaque_sp->GetByteSize(); return result; } @@ -162,7 +162,7 @@ bool result = false; if (IsValid()) - result = m_lldb_object_sp->IsInScope (frame.get()); + result = m_opaque_sp->IsInScope (frame.get()); return result; } @@ -171,8 +171,8 @@ SBValue::GetValue (const SBFrame &frame) { const char *value_string = NULL; - if ( m_lldb_object_sp) - value_string = m_lldb_object_sp->GetValueAsCString(frame.get()); + if ( m_opaque_sp) + value_string = m_opaque_sp->GetValueAsCString(frame.get()); return value_string; } @@ -180,7 +180,7 @@ SBValue::GetValueDidChange () { if (IsValid()) - return m_lldb_object_sp->GetValueDidChange(); + return m_opaque_sp->GetValueDidChange(); return false; } @@ -188,8 +188,8 @@ SBValue::GetSummary (const SBFrame &frame) { const char *value_string = NULL; - if ( m_lldb_object_sp) - value_string = m_lldb_object_sp->GetSummaryAsCString(frame.get()); + if ( m_opaque_sp) + value_string = m_opaque_sp->GetSummaryAsCString(frame.get()); return value_string; } @@ -198,7 +198,7 @@ { const char *value_string = NULL; if (IsValid()) - value_string = m_lldb_object_sp->GetLocationAsCString(frame.get()); + value_string = m_opaque_sp->GetLocationAsCString(frame.get()); return value_string; } @@ -207,7 +207,7 @@ { bool success = false; if (IsValid()) - success = m_lldb_object_sp->SetValueFromCString (frame.get(), value_str); + success = m_opaque_sp->SetValueFromCString (frame.get(), value_str); return success; } @@ -218,7 +218,7 @@ if (IsValid()) { - child_sp = m_lldb_object_sp->GetChildAtIndex (idx, true); + child_sp = m_opaque_sp->GetChildAtIndex (idx, true); } SBValue sb_value (child_sp); @@ -229,7 +229,7 @@ SBValue::GetIndexOfChildWithName (const char *name) { if (IsValid()) - return m_lldb_object_sp->GetIndexOfChildWithName (ConstString(name)); + return m_opaque_sp->GetIndexOfChildWithName (ConstString(name)); return UINT32_MAX; } @@ -241,7 +241,7 @@ if (IsValid()) { - child_sp = m_lldb_object_sp->GetChildMemberWithName (str_name, true); + child_sp = m_opaque_sp->GetChildMemberWithName (str_name, true); } SBValue sb_value (child_sp); @@ -256,7 +256,7 @@ if (IsValid()) { - num_children = m_lldb_object_sp->GetNumChildren(); + num_children = m_opaque_sp->GetNumChildren(); } return num_children; @@ -269,7 +269,7 @@ if (IsValid()) { - result = m_lldb_object_sp->GetValueIsValid(); + result = m_opaque_sp->GetValueIsValid(); } return result; @@ -281,7 +281,7 @@ { if (IsValid()) { - if (m_lldb_object_sp->IsPointerType()) + if (m_opaque_sp->IsPointerType()) { return GetChildAtIndex(0); } @@ -296,53 +296,53 @@ if (IsValid()) { - is_ptr_type = m_lldb_object_sp->IsPointerType(); + is_ptr_type = m_opaque_sp->IsPointerType(); } return is_ptr_type; } -lldb_private::ExecutionContext -SBValue::GetCurrentExecutionContext () -{ - lldb_private::Process *process = NULL; - lldb_private::Thread *thread = NULL; - lldb_private::StackFrame *frame = NULL; - - SBTarget sb_target = SBDebugger::GetCurrentTarget(); - if (sb_target.IsValid()) - { - SBProcess sb_process = sb_target.GetProcess(); - if (sb_process.IsValid()) - { - process = sb_process.get(); - SBThread sb_thread = sb_process.GetCurrentThread(); - if (sb_thread.IsValid()) - { - thread = sb_thread.GetLLDBObjectPtr(); - frame = thread->GetStackFrameAtIndex(0).get(); - lldb_private::ExecutionContext exe_context (process, thread, frame); - return exe_context; - } - else - { - lldb_private::ExecutionContext exe_context (process, NULL, NULL); - return exe_context; - } - } - } - - lldb_private::ExecutionContext exe_context (NULL, NULL, NULL); - return exe_context; -} - - +//lldb_private::ExecutionContext +//SBValue::GetCurrentExecutionContext () +//{ +// lldb_private::Process *process = NULL; +// lldb_private::Thread *thread = NULL; +// lldb_private::StackFrame *frame = NULL; +// +// SBTarget sb_target = SBDebugger::GetCurrentTarget(); +// if (sb_target.IsValid()) +// { +// SBProcess sb_process = sb_target.GetProcess(); +// if (sb_process.IsValid()) +// { +// process = sb_process.get(); +// SBThread sb_thread = sb_process.GetCurrentThread(); +// if (sb_thread.IsValid()) +// { +// thread = sb_thread.GetLLDBObjectPtr(); +// frame = thread->GetStackFrameAtIndex(0).get(); +// lldb_private::ExecutionContext exe_context (process, thread, frame); +// return exe_context; +// } +// else +// { +// lldb_private::ExecutionContext exe_context (process, NULL, NULL); +// return exe_context; +// } +// } +// } +// +// lldb_private::ExecutionContext exe_context (NULL, NULL, NULL); +// return exe_context; +//} +// +// void * SBValue::GetOpaqueType() { - if (m_lldb_object_sp) - return m_lldb_object_sp->GetOpaqueClangQualType(); + if (m_opaque_sp) + return m_opaque_sp->GetOpaqueClangQualType(); return NULL; } @@ -350,23 +350,23 @@ lldb_private::ValueObject * SBValue::get() const { - return m_lldb_object_sp.get(); + return m_opaque_sp.get(); } lldb_private::ValueObject * SBValue::operator->() const { - return m_lldb_object_sp.get(); + return m_opaque_sp.get(); } lldb::ValueObjectSP & SBValue::operator*() { - return m_lldb_object_sp; + return m_opaque_sp; } const lldb::ValueObjectSP & SBValue::operator*() const { - return m_lldb_object_sp; + return m_opaque_sp; } Modified: lldb/trunk/source/API/SBValueList.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBValueList.cpp?rev=106615&r1=106614&r2=106615&view=diff ============================================================================== --- lldb/trunk/source/API/SBValueList.cpp (original) +++ lldb/trunk/source/API/SBValueList.cpp Tue Jun 22 20:19:29 2010 @@ -17,22 +17,22 @@ using namespace lldb_private; SBValueList::SBValueList () : - m_lldb_object_ap () + m_opaque_ap () { } SBValueList::SBValueList (const SBValueList &rhs) : - m_lldb_object_ap () + m_opaque_ap () { if (rhs.IsValid()) - m_lldb_object_ap.reset (new lldb_private::ValueObjectList (*rhs)); + m_opaque_ap.reset (new lldb_private::ValueObjectList (*rhs)); } SBValueList::SBValueList (const lldb_private::ValueObjectList *lldb_object_ptr) : - m_lldb_object_ap () + m_opaque_ap () { if (lldb_object_ptr) - m_lldb_object_ap.reset (new lldb_private::ValueObjectList (*lldb_object_ptr)); + m_opaque_ap.reset (new lldb_private::ValueObjectList (*lldb_object_ptr)); } SBValueList::~SBValueList () @@ -42,7 +42,7 @@ bool SBValueList::IsValid () const { - return (m_lldb_object_ap.get() != NULL); + return (m_opaque_ap.get() != NULL); } const SBValueList & @@ -51,9 +51,9 @@ if (this != &rhs) { if (rhs.IsValid()) - m_lldb_object_ap.reset (new lldb_private::ValueObjectList (*rhs)); + m_opaque_ap.reset (new lldb_private::ValueObjectList (*rhs)); else - m_lldb_object_ap.reset (); + m_opaque_ap.reset (); } return *this; } @@ -61,25 +61,25 @@ lldb_private::ValueObjectList * SBValueList::operator->() { - return m_lldb_object_ap.get(); + return m_opaque_ap.get(); } lldb_private::ValueObjectList & SBValueList::operator*() { - return *m_lldb_object_ap; + return *m_opaque_ap; } const lldb_private::ValueObjectList * SBValueList::operator->() const { - return m_lldb_object_ap.get(); + return m_opaque_ap.get(); } const lldb_private::ValueObjectList & SBValueList::operator*() const { - return *m_lldb_object_ap; + return *m_opaque_ap; } void @@ -88,7 +88,7 @@ if (val_obj.get()) { CreateIfNeeded (); - m_lldb_object_ap->Append (*val_obj); + m_opaque_ap->Append (*val_obj); } } @@ -98,7 +98,7 @@ if (val_obj_sp) { CreateIfNeeded (); - m_lldb_object_ap->Append (val_obj_sp); + m_opaque_ap->Append (val_obj_sp); } } @@ -107,8 +107,8 @@ SBValueList::GetValueAtIndex (uint32_t idx) const { SBValue sb_value; - if (m_lldb_object_ap.get()) - *sb_value = m_lldb_object_ap->GetValueObjectAtIndex (idx); + if (m_opaque_ap.get()) + *sb_value = m_opaque_ap->GetValueObjectAtIndex (idx); return sb_value; } @@ -116,16 +116,16 @@ SBValueList::GetSize () const { uint32_t size = 0; - if (m_lldb_object_ap.get()) - size = m_lldb_object_ap->GetSize(); + if (m_opaque_ap.get()) + size = m_opaque_ap->GetSize(); return size; } void SBValueList::CreateIfNeeded () { - if (m_lldb_object_ap.get() == NULL) - m_lldb_object_ap.reset (new ValueObjectList()); + if (m_opaque_ap.get() == NULL) + m_opaque_ap.reset (new ValueObjectList()); } @@ -133,8 +133,8 @@ SBValueList::FindValueObjectByUID (lldb::user_id_t uid) { SBValue sb_value; - if ( m_lldb_object_ap.get()) - *sb_value = m_lldb_object_ap->FindValueObjectByUID (uid); + if ( m_opaque_ap.get()) + *sb_value = m_opaque_ap->FindValueObjectByUID (uid); return sb_value; } Modified: lldb/trunk/source/Breakpoint/StoppointCallbackContext.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Breakpoint/StoppointCallbackContext.cpp?rev=106615&r1=106614&r2=106615&view=diff ============================================================================== --- lldb/trunk/source/Breakpoint/StoppointCallbackContext.cpp (original) +++ lldb/trunk/source/Breakpoint/StoppointCallbackContext.cpp Tue Jun 22 20:19:29 2010 @@ -18,13 +18,13 @@ StoppointCallbackContext::StoppointCallbackContext() : event (NULL), - context() + exe_ctx() { } StoppointCallbackContext::StoppointCallbackContext(Event *e, Process* p, Thread *t, StackFrame *f, bool synchronously) : event (e), - context (p, t, f), + exe_ctx (p, t, f), is_synchronous(synchronously) { } @@ -33,6 +33,6 @@ StoppointCallbackContext::Clear() { event = NULL; - context.Clear(); + exe_ctx.Clear(); is_synchronous = false; } Modified: lldb/trunk/source/Commands/CommandCompletions.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandCompletions.cpp?rev=106615&r1=106614&r2=106615&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandCompletions.cpp (original) +++ lldb/trunk/source/Commands/CommandCompletions.cpp Tue Jun 22 20:19:29 2010 @@ -33,13 +33,16 @@ }; bool -CommandCompletions::InvokeCommonCompletionCallbacks (uint32_t completion_mask, - const char *completion_str, - int match_start_point, - int max_return_elements, - lldb_private::CommandInterpreter *interpreter, - SearchFilter *searcher, - lldb_private::StringList &matches) +CommandCompletions::InvokeCommonCompletionCallbacks +( + CommandInterpreter &interpreter, + uint32_t completion_mask, + const char *completion_str, + int match_start_point, + int max_return_elements, + SearchFilter *searcher, + StringList &matches +) { bool handled = false; @@ -54,10 +57,10 @@ && g_common_completions[i].callback != NULL) { handled = true; - g_common_completions[i].callback (completion_str, + g_common_completions[i].callback (interpreter, + completion_str, match_start_point, max_return_elements, - interpreter, searcher, matches); } @@ -66,20 +69,27 @@ } int -CommandCompletions::SourceFiles (const char *partial_file_name, - int match_start_point, - int max_return_elements, - lldb_private::CommandInterpreter *interpreter, - SearchFilter *searcher, - lldb_private::StringList &matches) +CommandCompletions::SourceFiles +( + CommandInterpreter &interpreter, + const char *partial_file_name, + int match_start_point, + int max_return_elements, + SearchFilter *searcher, + StringList &matches +) { // Find some way to switch "include support files..." - SourceFileCompleter completer (false, partial_file_name, match_start_point, max_return_elements, interpreter, + SourceFileCompleter completer (interpreter, + false, + partial_file_name, + match_start_point, + max_return_elements, matches); if (searcher == NULL) { - lldb::TargetSP target_sp = interpreter->Context()->GetTarget()->GetSP(); + lldb::TargetSP target_sp = interpreter.GetDebugger().GetCurrentTarget(); SearchFilter null_searcher (target_sp); completer.DoCompletion (&null_searcher); } @@ -91,18 +101,25 @@ } int -CommandCompletions::Modules (const char *partial_file_name, - int match_start_point, - int max_return_elements, - lldb_private::CommandInterpreter *interpreter, - SearchFilter *searcher, - lldb_private::StringList &matches) +CommandCompletions::Modules +( + CommandInterpreter &interpreter, + const char *partial_file_name, + int match_start_point, + int max_return_elements, + SearchFilter *searcher, + StringList &matches +) { - ModuleCompleter completer(partial_file_name, match_start_point, max_return_elements, interpreter, matches); - + ModuleCompleter completer (interpreter, + partial_file_name, + match_start_point, + max_return_elements, + matches); + if (searcher == NULL) { - lldb::TargetSP target_sp = interpreter->Context()->GetTarget()->GetSP(); + lldb::TargetSP target_sp = interpreter.GetDebugger().GetCurrentTarget(); SearchFilter null_searcher (target_sp); completer.DoCompletion (&null_searcher); } @@ -114,18 +131,24 @@ } int -CommandCompletions::Symbols (const char *partial_file_name, - int match_start_point, - int max_return_elements, - lldb_private::CommandInterpreter *interpreter, - SearchFilter *searcher, - lldb_private::StringList &matches) +CommandCompletions::Symbols +( + CommandInterpreter &interpreter, + const char *partial_file_name, + int match_start_point, + int max_return_elements, + SearchFilter *searcher, + StringList &matches) { - SymbolCompleter completer(partial_file_name, match_start_point, max_return_elements, interpreter, matches); + SymbolCompleter completer (interpreter, + partial_file_name, + match_start_point, + max_return_elements, + matches); if (searcher == NULL) { - lldb::TargetSP target_sp = interpreter->Context()->GetTarget()->GetSP(); + lldb::TargetSP target_sp = interpreter.GetDebugger().GetCurrentTarget(); SearchFilter null_searcher (target_sp); completer.DoCompletion (&null_searcher); } @@ -136,17 +159,18 @@ return matches.GetSize(); } -CommandCompletions::Completer::Completer ( +CommandCompletions::Completer::Completer +( + CommandInterpreter &interpreter, const char *completion_str, int match_start_point, int max_return_elements, - CommandInterpreter *interpreter, StringList &matches ) : + m_interpreter (interpreter), m_completion_str (completion_str), m_match_start_point (match_start_point), m_max_return_elements (max_return_elements), - m_interpreter (interpreter), m_matches (matches) { } @@ -160,15 +184,16 @@ // SourceFileCompleter //---------------------------------------------------------------------- -CommandCompletions::SourceFileCompleter::SourceFileCompleter ( +CommandCompletions::SourceFileCompleter::SourceFileCompleter +( + CommandInterpreter &interpreter, bool include_support_files, const char *completion_str, int match_start_point, int max_return_elements, - CommandInterpreter *interpreter, StringList &matches ) : - CommandCompletions::Completer (completion_str, match_start_point, max_return_elements, interpreter, matches), + CommandCompletions::Completer (interpreter, completion_str, match_start_point, max_return_elements, matches), m_include_support_files (include_support_files), m_matching_files() { @@ -264,14 +289,15 @@ else return false; } -CommandCompletions::SymbolCompleter::SymbolCompleter ( +CommandCompletions::SymbolCompleter::SymbolCompleter +( + CommandInterpreter &interpreter, const char *completion_str, int match_start_point, int max_return_elements, - CommandInterpreter *interpreter, StringList &matches ) : - CommandCompletions::Completer (completion_str, match_start_point, max_return_elements, interpreter, matches) + CommandCompletions::Completer (interpreter, completion_str, match_start_point, max_return_elements, matches) { std::string regex_str ("^"); regex_str.append(completion_str); @@ -353,14 +379,15 @@ //---------------------------------------------------------------------- // ModuleCompleter //---------------------------------------------------------------------- -CommandCompletions::ModuleCompleter::ModuleCompleter ( +CommandCompletions::ModuleCompleter::ModuleCompleter +( + CommandInterpreter &interpreter, const char *completion_str, int match_start_point, int max_return_elements, - CommandInterpreter *interpreter, StringList &matches ) : - CommandCompletions::Completer (completion_str, match_start_point, max_return_elements, interpreter, matches) + CommandCompletions::Completer (interpreter, completion_str, match_start_point, max_return_elements, matches) { FileSpec partial_spec (m_completion_str.c_str()); m_file_name = partial_spec.GetFilename().GetCString(); Removed: lldb/trunk/source/Commands/CommandObjectAdd.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectAdd.cpp?rev=106614&view=auto ============================================================================== --- lldb/trunk/source/Commands/CommandObjectAdd.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectAdd.cpp (removed) @@ -1,51 +0,0 @@ -//===-- CommandObjectAdd.cpp ------------------------------------*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -#include "CommandObjectAdd.h" - -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes -#include "lldb/Interpreter/CommandInterpreter.h" -#include "lldb/Interpreter/Options.h" -#include "lldb/Interpreter/CommandReturnObject.h" - -using namespace lldb; -using namespace lldb_private; - -//------------------------------------------------------------------------- -// CommandObjectAdd -//------------------------------------------------------------------------- - -CommandObjectAdd::CommandObjectAdd () : - CommandObject ("add", - "Allows the user to add a new command/function pair to the debugger's dictionary.", - "add ") -{ -} - -CommandObjectAdd::~CommandObjectAdd() -{ -} - - -bool -CommandObjectAdd::Execute -( - Args& command, - CommandContext *context, - CommandInterpreter *interpreter, - CommandReturnObject &result -) -{ - result.AppendMessage ("This function has not been implemented yet."); - result.SetStatus (eReturnStatusSuccessFinishNoResult); - return result.Succeeded(); -} Removed: lldb/trunk/source/Commands/CommandObjectAdd.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectAdd.h?rev=106614&view=auto ============================================================================== --- lldb/trunk/source/Commands/CommandObjectAdd.h (original) +++ lldb/trunk/source/Commands/CommandObjectAdd.h (removed) @@ -1,43 +0,0 @@ -//===-- CommandObjectAdd.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_CommandObjectAdd_h_ -#define liblldb_CommandObjectAdd_h_ - -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes -#include "lldb/Interpreter/CommandObject.h" - -namespace lldb_private { -//------------------------------------------------------------------------- -// CommandObjectAdd -//------------------------------------------------------------------------- - -class CommandObjectAdd : public CommandObject -{ -public: - - CommandObjectAdd (); - - virtual - ~CommandObjectAdd (); - - virtual bool - Execute (Args& command, - CommandContext *context, - CommandInterpreter *interpreter, - CommandReturnObject &result); - -}; - -} // namespace lldb_private - -#endif // liblldb_CommandObjectAdd_h_ Modified: lldb/trunk/source/Commands/CommandObjectAlias.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectAlias.cpp?rev=106615&r1=106614&r2=106615&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectAlias.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectAlias.cpp Tue Jun 22 20:19:29 2010 @@ -89,8 +89,12 @@ bool -CommandObjectAlias::Execute (Args& args, CommandContext *context, CommandInterpreter *interpreter, - CommandReturnObject &result) +CommandObjectAlias::Execute +( + CommandInterpreter &interpreter, + Args& args, + CommandReturnObject &result +) { const int argc = args.GetArgumentCount(); @@ -109,7 +113,7 @@ // Verify that the command is alias'able, and get the appropriate command object. - if (interpreter->CommandExists (alias_command.c_str())) + if (interpreter.CommandExists (alias_command.c_str())) { result.AppendErrorWithFormat ("'%s' is a permanent debugger command and cannot be redefined.\n", alias_command.c_str()); @@ -117,7 +121,7 @@ } else { - CommandObjectSP command_obj_sp(interpreter->GetCommandSP (actual_command.c_str())); + CommandObjectSP command_obj_sp(interpreter.GetCommandSP (actual_command.c_str())); CommandObjectSP subcommand_obj_sp; bool use_subcommand = false; if (command_obj_sp.get()) @@ -193,24 +197,24 @@ // Create the alias. - if (interpreter->AliasExists (alias_command.c_str()) - || interpreter->UserCommandExists (alias_command.c_str())) + if (interpreter.AliasExists (alias_command.c_str()) + || interpreter.UserCommandExists (alias_command.c_str())) { - OptionArgVectorSP tmp_option_arg_sp (interpreter->GetAliasOptions (alias_command.c_str())); + OptionArgVectorSP tmp_option_arg_sp (interpreter.GetAliasOptions (alias_command.c_str())); if (tmp_option_arg_sp.get()) { if (option_arg_vector->size() == 0) - interpreter->RemoveAliasOptions (alias_command.c_str()); + interpreter.RemoveAliasOptions (alias_command.c_str()); } result.AppendWarningWithFormat ("Overwriting existing definition for '%s'.\n", alias_command.c_str()); } if (use_subcommand) - interpreter->AddAlias (alias_command.c_str(), subcommand_obj_sp); + interpreter.AddAlias (alias_command.c_str(), subcommand_obj_sp); else - interpreter->AddAlias (alias_command.c_str(), command_obj_sp); + interpreter.AddAlias (alias_command.c_str(), command_obj_sp); if (option_arg_vector->size() > 0) - interpreter->AddOrReplaceAliasOptions (alias_command.c_str(), option_arg_vector_sp); + interpreter.AddOrReplaceAliasOptions (alias_command.c_str(), option_arg_vector_sp); result.SetStatus (eReturnStatusSuccessFinishNoResult); } else Modified: lldb/trunk/source/Commands/CommandObjectAlias.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectAlias.h?rev=106615&r1=106614&r2=106615&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectAlias.h (original) +++ lldb/trunk/source/Commands/CommandObjectAlias.h Tue Jun 22 20:19:29 2010 @@ -32,9 +32,8 @@ ~CommandObjectAlias (); virtual bool - Execute (Args& command, - CommandContext *context, - CommandInterpreter *interpreter, + Execute (CommandInterpreter &interpreter, + Args& command, CommandReturnObject &result); }; Modified: lldb/trunk/source/Commands/CommandObjectAppend.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectAppend.cpp?rev=106615&r1=106614&r2=106615&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectAppend.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectAppend.cpp Tue Jun 22 20:19:29 2010 @@ -37,9 +37,8 @@ bool CommandObjectAppend::Execute ( + CommandInterpreter &interpreter, Args& command, - CommandContext *context, - CommandInterpreter *interpreter, CommandReturnObject &result ) { @@ -64,7 +63,7 @@ } else { - StateVariable *var = interpreter->GetStateVariable(var_name); + StateVariable *var = interpreter.GetStateVariable(var_name); if (var == NULL) { result.AppendErrorWithFormat ("'%s' is not a settable internal variable.\n", var_name); Modified: lldb/trunk/source/Commands/CommandObjectAppend.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectAppend.h?rev=106615&r1=106614&r2=106615&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectAppend.h (original) +++ lldb/trunk/source/Commands/CommandObjectAppend.h Tue Jun 22 20:19:29 2010 @@ -30,9 +30,8 @@ ~CommandObjectAppend (); virtual bool - Execute (Args& command, - CommandContext *context, - CommandInterpreter *interpreter, + Execute (CommandInterpreter &interpreter, + Args& command, CommandReturnObject &result); Modified: lldb/trunk/source/Commands/CommandObjectApropos.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectApropos.cpp?rev=106615&r1=106614&r2=106615&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectApropos.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectApropos.cpp Tue Jun 22 20:19:29 2010 @@ -40,14 +40,18 @@ bool -CommandObjectApropos::Execute (Args &command, CommandContext *context, CommandInterpreter *interpreter, - CommandReturnObject &result) +CommandObjectApropos::Execute +( + CommandInterpreter &interpreter, + Args& args, + CommandReturnObject &result +) { - const int argc = command.GetArgumentCount (); + const int argc = args.GetArgumentCount (); if (argc == 1) { - const char *search_word = command.GetArgumentAtIndex(0); + const char *search_word = args.GetArgumentAtIndex(0); if ((search_word != NULL) && (strlen (search_word) > 0)) { @@ -55,7 +59,7 @@ // is private. StringList commands_found; StringList commands_help; - interpreter->FindCommandsForApropos (search_word, commands_found, commands_help); + interpreter.FindCommandsForApropos (search_word, commands_found, commands_help); if (commands_found.GetSize() == 0) { result.AppendMessageWithFormat ("No commands found pertaining to '%s'.", search_word); @@ -74,8 +78,11 @@ } for (int i = 0; i < commands_found.GetSize(); ++i) - interpreter->OutputFormattedHelpText (result.GetOutputStream(), commands_found.GetStringAtIndex(i), - "--", commands_help.GetStringAtIndex(i), max_len); + interpreter.OutputFormattedHelpText (result.GetOutputStream(), + commands_found.GetStringAtIndex(i), + "--", commands_help. + GetStringAtIndex(i), + max_len); } result.SetStatus (eReturnStatusSuccessFinishNoResult); Modified: lldb/trunk/source/Commands/CommandObjectApropos.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectApropos.h?rev=106615&r1=106614&r2=106615&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectApropos.h (original) +++ lldb/trunk/source/Commands/CommandObjectApropos.h Tue Jun 22 20:19:29 2010 @@ -32,9 +32,8 @@ ~CommandObjectApropos (); virtual bool - Execute (Args& command, - CommandContext *context, - CommandInterpreter *interpreter, + Execute (CommandInterpreter &interpreter, + Args& command, CommandReturnObject &result); Modified: lldb/trunk/source/Commands/CommandObjectArgs.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectArgs.cpp?rev=106615&r1=106614&r2=106615&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectArgs.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectArgs.cpp Tue Jun 22 20:19:29 2010 @@ -20,7 +20,7 @@ #include "lldb/Expression/ClangFunction.h" #include "lldb/Host/Host.h" #include "lldb/Interpreter/CommandInterpreter.h" -#include "lldb/Interpreter/CommandContext.h" +#include "lldb/Core/Debugger.h" #include "lldb/Interpreter/CommandReturnObject.h" #include "lldb/Symbol/ObjectFile.h" #include "lldb/Symbol/Variable.h" @@ -95,14 +95,17 @@ } bool -CommandObjectArgs::Execute(Args &command, - CommandContext *context, - CommandInterpreter *interpreter, - CommandReturnObject &result) +CommandObjectArgs::Execute +( + CommandInterpreter &interpreter, + Args& args, + CommandReturnObject &result +) { ConstString target_triple; - Process *process = context->GetExecutionContext().process; + + Process *process = interpreter.GetDebugger().GetExecutionContext().process; if (!process) { result.AppendError ("Args found no process."); @@ -118,7 +121,7 @@ return false; } - int num_args = command.GetArgumentCount (); + int num_args = args.GetArgumentCount (); int arg_index; if (!num_args) @@ -128,7 +131,7 @@ return false; } - Thread *thread = context->GetExecutionContext ().thread; + Thread *thread = interpreter.GetDebugger().GetExecutionContext ().thread; if (!thread) { @@ -167,7 +170,7 @@ for (arg_index = 0; arg_index < num_args; ++arg_index) { - const char *arg_type_cstr = command.GetArgumentAtIndex(arg_index); + const char *arg_type_cstr = args.GetArgumentAtIndex(arg_index); Value value; value.SetValueType(Value::eValueTypeScalar); void *type; @@ -262,7 +265,7 @@ for (arg_index = 0; arg_index < num_args; ++arg_index) { - result.GetOutputStream ().Printf ("%d (%s): ", arg_index, command.GetArgumentAtIndex (arg_index)); + result.GetOutputStream ().Printf ("%d (%s): ", arg_index, args.GetArgumentAtIndex (arg_index)); value_list.GetValueAtIndex (arg_index)->Dump (&result.GetOutputStream ()); result.GetOutputStream ().Printf("\n"); } Modified: lldb/trunk/source/Commands/CommandObjectArgs.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectArgs.h?rev=106615&r1=106614&r2=106615&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectArgs.h (original) +++ lldb/trunk/source/Commands/CommandObjectArgs.h Tue Jun 22 20:19:29 2010 @@ -58,9 +58,8 @@ virtual bool - Execute (Args& command, - CommandContext *context, - CommandInterpreter *interpreter, + Execute (CommandInterpreter &interpreter, + Args& command, CommandReturnObject &result); virtual bool Modified: lldb/trunk/source/Commands/CommandObjectBreakpoint.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectBreakpoint.cpp?rev=106615&r1=106614&r2=106615&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectBreakpoint.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectBreakpoint.cpp Tue Jun 22 20:19:29 2010 @@ -32,7 +32,7 @@ using namespace lldb_private; static void -AddBreakpointDescription (CommandContext *context, StreamString *s, Breakpoint *bp, lldb::DescriptionLevel level) +AddBreakpointDescription (StreamString *s, Breakpoint *bp, lldb::DescriptionLevel level) { s->IndentMore(); bp->GetDescription (s, level, true); @@ -240,13 +240,12 @@ bool CommandObjectBreakpointSet::Execute ( + CommandInterpreter &interpreter, Args& command, - CommandContext *context, - CommandInterpreter *interpreter, CommandReturnObject &result ) { - Target *target = context->GetTarget(); + Target *target = interpreter.GetDebugger().GetCurrentTarget().get(); if (target == NULL) { result.AppendError ("Invalid target, set executable file using 'file' command."); @@ -287,7 +286,7 @@ FileSpec file; if (m_options.m_filename.empty()) { - StackFrame *cur_frame = context->GetExecutionContext().frame; + StackFrame *cur_frame = interpreter.GetDebugger().GetExecutionContext().frame; if (cur_frame == NULL) { result.AppendError ("Attempting to set breakpoint by line number alone with no selected frame."); @@ -458,7 +457,7 @@ //------------------------------------------------------------------------- #pragma mark MultiwordBreakpoint -CommandObjectMultiwordBreakpoint::CommandObjectMultiwordBreakpoint (CommandInterpreter *interpreter) : +CommandObjectMultiwordBreakpoint::CommandObjectMultiwordBreakpoint (CommandInterpreter &interpreter) : CommandObjectMultiword ("breakpoint", "A set of commands for operating on breakpoints.", "breakpoint []") @@ -480,13 +479,13 @@ modify_command_object->SetCommandName ("breakpoint modify"); set_command_object->SetCommandName("breakpoint set"); - status = LoadSubCommand (list_command_object, "list", interpreter); - status = LoadSubCommand (enable_command_object, "enable", interpreter); - status = LoadSubCommand (disable_command_object, "disable", interpreter); - status = LoadSubCommand (delete_command_object, "delete", interpreter); - status = LoadSubCommand (set_command_object, "set", interpreter); - status = LoadSubCommand (command_command_object, "command", interpreter); - status = LoadSubCommand (modify_command_object, "modify", interpreter); + status = LoadSubCommand (interpreter, "list", list_command_object); + status = LoadSubCommand (interpreter, "enable", enable_command_object); + status = LoadSubCommand (interpreter, "disable", disable_command_object); + status = LoadSubCommand (interpreter, "delete", delete_command_object); + status = LoadSubCommand (interpreter, "set", set_command_object); + status = LoadSubCommand (interpreter, "command", command_command_object); + status = LoadSubCommand (interpreter, "modify", modify_command_object); } CommandObjectMultiwordBreakpoint::~CommandObjectMultiwordBreakpoint () @@ -653,13 +652,12 @@ bool CommandObjectBreakpointList::Execute ( + CommandInterpreter &interpreter, Args& args, - CommandContext *context, - CommandInterpreter *interpreter, CommandReturnObject &result ) { - Target *target = context->GetTarget(); + Target *target = interpreter.GetDebugger().GetCurrentTarget().get(); if (target == NULL) { result.AppendError ("Invalid target, set executable file using 'file' command."); @@ -689,7 +687,7 @@ for (int i = 0; i < num_breakpoints; ++i) { Breakpoint *breakpoint = breakpoints.GetBreakpointByIndex (i).get(); - AddBreakpointDescription (context, &output_stream, breakpoint, m_options.m_level); + AddBreakpointDescription (&output_stream, breakpoint, m_options.m_level); } result.SetStatus (eReturnStatusSuccessFinishNoResult); } @@ -705,7 +703,7 @@ { BreakpointID cur_bp_id = valid_bp_ids.GetBreakpointIDAtIndex (i); Breakpoint *breakpoint = target->GetBreakpointByID (cur_bp_id.GetBreakpointID()).get(); - AddBreakpointDescription (context, &output_stream, breakpoint, m_options.m_level); + AddBreakpointDescription (&output_stream, breakpoint, m_options.m_level); } result.SetStatus (eReturnStatusSuccessFinishNoResult); } @@ -743,10 +741,14 @@ bool -CommandObjectBreakpointEnable::Execute (Args& args, CommandContext *context, - CommandInterpreter *interpreter, CommandReturnObject &result) +CommandObjectBreakpointEnable::Execute +( + CommandInterpreter &interpreter, + Args& args, + CommandReturnObject &result +) { - Target *target = context->GetTarget(); + Target *target = interpreter.GetDebugger().GetCurrentTarget().get(); if (target == NULL) { result.AppendError ("Invalid target, set executable file using 'file' command."); @@ -838,10 +840,14 @@ } bool -CommandObjectBreakpointDisable::Execute (Args& args, CommandContext *context, - CommandInterpreter *interpreter, CommandReturnObject &result) +CommandObjectBreakpointDisable::Execute +( + CommandInterpreter &interpreter, + Args& args, + CommandReturnObject &result +) { - Target *target = context->GetTarget(); + Target *target = interpreter.GetDebugger().GetCurrentTarget().get(); if (target == NULL) { result.AppendError ("Invalid target, set executable file using 'file' command."); @@ -929,10 +935,14 @@ } bool -CommandObjectBreakpointDelete::Execute (Args& args, CommandContext *context, - CommandInterpreter *interpreter, CommandReturnObject &result) +CommandObjectBreakpointDelete::Execute +( + CommandInterpreter &interpreter, + Args& args, + CommandReturnObject &result +) { - Target *target = context->GetTarget(); + Target *target = interpreter.GetDebugger().GetCurrentTarget().get(); if (target == NULL) { result.AppendError ("Invalid target, set executable file using 'file' command."); @@ -1163,9 +1173,8 @@ bool CommandObjectBreakpointModify::Execute ( + CommandInterpreter &interpreter, Args& command, - CommandContext *context, - CommandInterpreter *interpreter, CommandReturnObject &result ) { @@ -1176,7 +1185,7 @@ return false; } - Target *target = context->GetTarget(); + Target *target = interpreter.GetDebugger().GetCurrentTarget().get(); if (target == NULL) { result.AppendError ("Invalid target, set executable file using 'file' command."); Modified: lldb/trunk/source/Commands/CommandObjectBreakpoint.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectBreakpoint.h?rev=106615&r1=106614&r2=106615&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectBreakpoint.h (original) +++ lldb/trunk/source/Commands/CommandObjectBreakpoint.h Tue Jun 22 20:19:29 2010 @@ -32,7 +32,7 @@ class CommandObjectMultiwordBreakpoint : public CommandObjectMultiword { public: - CommandObjectMultiwordBreakpoint (CommandInterpreter *interpreter); + CommandObjectMultiwordBreakpoint (CommandInterpreter &interpreter); virtual ~CommandObjectMultiwordBreakpoint (); @@ -66,9 +66,8 @@ ~CommandObjectBreakpointSet (); virtual bool - Execute (Args& command, - CommandContext *context, - CommandInterpreter *interpreter, + Execute (CommandInterpreter &interpreter, + Args& command, CommandReturnObject &result); virtual Options * @@ -133,9 +132,8 @@ ~CommandObjectBreakpointModify (); virtual bool - Execute (Args& command, - CommandContext *context, - CommandInterpreter *interpreter, + Execute (CommandInterpreter &interpreter, + Args& command, CommandReturnObject &result); virtual Options * @@ -194,9 +192,8 @@ ~CommandObjectBreakpointEnable (); virtual bool - Execute (Args& command, - CommandContext *context, - CommandInterpreter *interpreter, + Execute (CommandInterpreter &interpreter, + Args& command, CommandReturnObject &result); private: @@ -215,9 +212,8 @@ ~CommandObjectBreakpointDisable (); virtual bool - Execute (Args& command, - CommandContext *context, - CommandInterpreter *interpreter, + Execute (CommandInterpreter &interpreter, + Args& command, CommandReturnObject &result); private: @@ -236,9 +232,8 @@ ~CommandObjectBreakpointList (); virtual bool - Execute (Args& command, - CommandContext *context, - CommandInterpreter *interpreter, + Execute (CommandInterpreter &interpreter, + Args& command, CommandReturnObject &result); virtual Options * @@ -290,9 +285,8 @@ ~CommandObjectBreakpointDelete (); virtual bool - Execute (Args& command, - CommandContext *context, - CommandInterpreter *interpreter, + Execute (CommandInterpreter &interpreter, + Args& command, CommandReturnObject &result); private: Modified: lldb/trunk/source/Commands/CommandObjectBreakpointCommand.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectBreakpointCommand.cpp?rev=106615&r1=106614&r2=106615&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectBreakpointCommand.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectBreakpointCommand.cpp Tue Jun 22 20:19:29 2010 @@ -208,13 +208,12 @@ bool CommandObjectBreakpointCommandAdd::Execute ( + CommandInterpreter &interpreter, Args& command, - CommandContext *context, - CommandInterpreter *interpreter, CommandReturnObject &result ) { - Target *target = context->GetTarget(); + Target *target = interpreter.GetDebugger().GetCurrentTarget().get(); if (target == NULL) { @@ -258,12 +257,12 @@ { if (m_options.m_use_script_language) { - interpreter->GetScriptInterpreter()->CollectDataForBreakpointCommandCallback (bp_loc_sp->GetLocationOptions(), + interpreter.GetScriptInterpreter()->CollectDataForBreakpointCommandCallback (bp_loc_sp->GetLocationOptions(), result); } else { - CollectDataForBreakpointCommandCallback (bp_loc_sp->GetLocationOptions(), result); + CollectDataForBreakpointCommandCallback (interpreter, bp_loc_sp->GetLocationOptions(), result); } } } @@ -271,12 +270,12 @@ { if (m_options.m_use_script_language) { - interpreter->GetScriptInterpreter()->CollectDataForBreakpointCommandCallback (bp->GetOptions(), + interpreter.GetScriptInterpreter()->CollectDataForBreakpointCommandCallback (bp->GetOptions(), result); } else { - CollectDataForBreakpointCommandCallback (bp->GetOptions(), result); + CollectDataForBreakpointCommandCallback (interpreter, bp->GetOptions(), result); } } } @@ -297,11 +296,12 @@ void CommandObjectBreakpointCommandAdd::CollectDataForBreakpointCommandCallback ( + CommandInterpreter &interpreter, BreakpointOptions *bp_options, CommandReturnObject &result ) { - InputReaderSP reader_sp (new InputReader()); + InputReaderSP reader_sp (new InputReader(interpreter.GetDebugger())); std::auto_ptr data_ap(new BreakpointOptions::CommandData()); if (reader_sp && data_ap.get()) { @@ -316,7 +316,7 @@ true)); // echo input if (err.Success()) { - Debugger::GetSharedInstance().PushInputReader (reader_sp); + interpreter.GetDebugger().PushInputReader (reader_sp); result.SetStatus (eReturnStatusSuccessFinishNoResult); } else @@ -337,13 +337,13 @@ CommandObjectBreakpointCommandAdd::GenerateBreakpointCommandCallback ( void *baton, - InputReader *reader, + InputReader &reader, lldb::InputReaderAction notification, const char *bytes, size_t bytes_len ) { - FILE *out_fh = Debugger::GetSharedInstance().GetOutputFileHandle(); + FILE *out_fh = reader.GetDebugger().GetOutputFileHandle(); switch (notification) { @@ -351,8 +351,8 @@ if (out_fh) { ::fprintf (out_fh, "%s\n", g_reader_instructions); - if (reader->GetPrompt()) - ::fprintf (out_fh, "%s", reader->GetPrompt()); + if (reader.GetPrompt()) + ::fprintf (out_fh, "%s", reader.GetPrompt()); } break; @@ -360,8 +360,8 @@ break; case eInputReaderReactivate: - if (out_fh && reader->GetPrompt()) - ::fprintf (out_fh, "%s", reader->GetPrompt()); + if (out_fh && reader.GetPrompt()) + ::fprintf (out_fh, "%s", reader.GetPrompt()); break; case eInputReaderGotToken: @@ -375,8 +375,8 @@ ((BreakpointOptions::CommandData *)bp_options_baton->m_data)->user_source.AppendString (bytes, bytes_len); } } - if (out_fh && !reader->IsDone() && reader->GetPrompt()) - ::fprintf (out_fh, "%s", reader->GetPrompt()); + if (out_fh && !reader.IsDone() && reader.GetPrompt()) + ::fprintf (out_fh, "%s", reader.GetPrompt()); break; case eInputReaderDone: @@ -403,12 +403,14 @@ } bool -CommandObjectBreakpointCommandRemove::Execute (Args& command, - CommandContext *context, - CommandInterpreter *interpreter, - CommandReturnObject &result) +CommandObjectBreakpointCommandRemove::Execute +( + CommandInterpreter &interpreter, + Args& command, + CommandReturnObject &result +) { - Target *target = context->GetTarget(); + Target *target = interpreter.GetDebugger().GetCurrentTarget().get(); if (target == NULL) { @@ -486,12 +488,14 @@ } bool -CommandObjectBreakpointCommandList::Execute (Args& command, - CommandContext *context, - CommandInterpreter *interpreter, - CommandReturnObject &result) +CommandObjectBreakpointCommandList::Execute +( + CommandInterpreter &interpreter, + Args& command, + CommandReturnObject &result +) { - Target *target = context->GetTarget(); + Target *target = interpreter.GetDebugger().GetCurrentTarget().get(); if (target == NULL) { @@ -587,7 +591,7 @@ // CommandObjectBreakpointCommand //------------------------------------------------------------------------- -CommandObjectBreakpointCommand::CommandObjectBreakpointCommand (CommandInterpreter *interpreter) : +CommandObjectBreakpointCommand::CommandObjectBreakpointCommand (CommandInterpreter &interpreter) : CommandObjectMultiword ("command", "A set of commands for adding, removing and examining bits of code to be executed when the breakpoint is hit (breakpoint 'commmands').", "command [] ") @@ -601,9 +605,9 @@ remove_command_object->SetCommandName ("breakpoint command remove"); list_command_object->SetCommandName ("breakpoint command list"); - status = LoadSubCommand (add_command_object, "add", interpreter); - status = LoadSubCommand (remove_command_object, "remove", interpreter); - status = LoadSubCommand (list_command_object, "list", interpreter); + status = LoadSubCommand (interpreter, "add", add_command_object); + status = LoadSubCommand (interpreter, "remove", remove_command_object); + status = LoadSubCommand (interpreter, "list", list_command_object); } @@ -631,63 +635,61 @@ if (commands.GetSize() > 0) { uint32_t num_commands = commands.GetSize(); - CommandInterpreter &interpreter = Debugger::GetSharedInstance().GetCommandInterpreter(); CommandReturnObject result; - ExecutionContext exe_ctx = context->context; - - FILE *out_fh = Debugger::GetSharedInstance().GetOutputFileHandle(); - FILE *err_fh = Debugger::GetSharedInstance().GetErrorFileHandle(); - - - uint32_t i; - for (i = 0; i < num_commands; ++i) + if (context->exe_ctx.target) { - - // First time through we use the context from the stoppoint, after that we use whatever - // has been set by the previous command. - - if (!interpreter.HandleCommand (commands.GetStringAtIndex(i), false, result, &exe_ctx)) - break; + + Debugger &debugger = context->exe_ctx.target->GetDebugger(); + CommandInterpreter &interpreter = debugger.GetCommandInterpreter(); + + FILE *out_fh = debugger.GetOutputFileHandle(); + FILE *err_fh = debugger.GetErrorFileHandle(); - // FIXME: This isn't really the right way to do this. We should be able to peek at the public - // to see if there is any new events, but that is racey, since the internal process thread has to run and - // deliver the event to the public queue before a run will show up. So for now we check - // the internal thread state. - - lldb::StateType internal_state = exe_ctx.process->GetPrivateState(); - if (internal_state != eStateStopped) + uint32_t i; + for (i = 0; i < num_commands; ++i) { - if (i < num_commands - 1) + + // First time through we use the context from the stoppoint, after that we use whatever + // has been set by the previous command. + + if (!interpreter.HandleCommand (commands.GetStringAtIndex(i), false, result, &context->exe_ctx)) + break; + + // FIXME: This isn't really the right way to do this. We should be able to peek at the public + // to see if there is any new events, but that is racey, since the internal process thread has to run and + // deliver the event to the public queue before a run will show up. So for now we check + // the internal thread state. + + lldb::StateType internal_state = context->exe_ctx.process->GetPrivateState(); + if (internal_state != eStateStopped) { - if (out_fh) - ::fprintf (out_fh, "Short-circuiting command execution because target state changed to %s." - " last command: \"%s\"\n", StateAsCString(internal_state), - commands.GetStringAtIndex(i)); + if (i < num_commands - 1) + { + if (out_fh) + ::fprintf (out_fh, "Short-circuiting command execution because target state changed to %s." + " last command: \"%s\"\n", StateAsCString(internal_state), + commands.GetStringAtIndex(i)); + } + break; } - break; + + if (out_fh) + ::fprintf (out_fh, "%s", result.GetErrorStream().GetData()); + if (err_fh) + ::fprintf (err_fh, "%s", result.GetOutputStream().GetData()); + result.Clear(); + result.SetStatus (eReturnStatusSuccessFinishNoResult); } - - // First time through we use the context from the stoppoint, after that we use whatever - // has been set by the previous command. - exe_ctx = Debugger::GetSharedInstance().GetCurrentExecutionContext(); - + if (err_fh && !result.Succeeded() && i < num_commands) + ::fprintf (err_fh, "Attempt to execute '%s' failed.\n", commands.GetStringAtIndex(i)); + if (out_fh) ::fprintf (out_fh, "%s", result.GetErrorStream().GetData()); + if (err_fh) - ::fprintf (err_fh, "%s", result.GetOutputStream().GetData()); - result.Clear(); - result.SetStatus (eReturnStatusSuccessFinishNoResult); + ::fprintf (err_fh, "%s", result.GetOutputStream().GetData()); } - - if (err_fh && !result.Succeeded() && i < num_commands) - ::fprintf (err_fh, "Attempt to execute '%s' failed.\n", commands.GetStringAtIndex(i)); - - if (out_fh) - ::fprintf (out_fh, "%s", result.GetErrorStream().GetData()); - - if (err_fh) - ::fprintf (err_fh, "%s", result.GetOutputStream().GetData()); } return ret_value; } Modified: lldb/trunk/source/Commands/CommandObjectBreakpointCommand.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectBreakpointCommand.h?rev=106615&r1=106614&r2=106615&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectBreakpointCommand.h (original) +++ lldb/trunk/source/Commands/CommandObjectBreakpointCommand.h Tue Jun 22 20:19:29 2010 @@ -34,7 +34,7 @@ class CommandObjectBreakpointCommand : public CommandObjectMultiword { public: - CommandObjectBreakpointCommand (CommandInterpreter *interpreter); + CommandObjectBreakpointCommand (CommandInterpreter &interpreter); virtual ~CommandObjectBreakpointCommand (); @@ -62,21 +62,21 @@ ~CommandObjectBreakpointCommandAdd (); virtual bool - Execute (Args& command, - CommandContext *context, - CommandInterpreter *interpreter, + Execute (CommandInterpreter &interpreter, + Args& command, CommandReturnObject &result); virtual Options * GetOptions (); void - CollectDataForBreakpointCommandCallback (BreakpointOptions *bp_options, + CollectDataForBreakpointCommandCallback (CommandInterpreter &interpreter, + BreakpointOptions *bp_options, CommandReturnObject &result); static size_t GenerateBreakpointCommandCallback (void *baton, - InputReader *reader, + InputReader &reader, lldb::InputReaderAction notification, const char *bytes, size_t bytes_len); @@ -134,9 +134,8 @@ ~CommandObjectBreakpointCommandRemove (); virtual bool - Execute (Args& command, - CommandContext *context, - CommandInterpreter *interpreter, + Execute (CommandInterpreter &interpreter, + Args& command, CommandReturnObject &result); private: @@ -155,9 +154,8 @@ ~CommandObjectBreakpointCommandList (); virtual bool - Execute (Args& command, - CommandContext *context, - CommandInterpreter *interpreter, + Execute (CommandInterpreter &interpreter, + Args& command, CommandReturnObject &result); private: Modified: lldb/trunk/source/Commands/CommandObjectCall.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectCall.cpp?rev=106615&r1=106614&r2=106615&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectCall.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectCall.cpp Tue Jun 22 20:19:29 2010 @@ -20,7 +20,7 @@ #include "lldb/Expression/ClangFunction.h" #include "lldb/Host/Host.h" #include "lldb/Interpreter/CommandInterpreter.h" -#include "lldb/Interpreter/CommandContext.h" +#include "lldb/Core/Debugger.h" #include "lldb/Interpreter/CommandReturnObject.h" #include "lldb/Symbol/ObjectFile.h" #include "lldb/Symbol/Variable.h" @@ -128,23 +128,21 @@ bool CommandObjectCall::Execute ( + CommandInterpreter &interpreter, Args &command, - CommandContext *context, - CommandInterpreter *interpreter, CommandReturnObject &result ) { ConstString target_triple; int num_args = command.GetArgumentCount(); - Target *target = context->GetTarget (); - if (target) - target->GetTargetTriple(target_triple); + ExecutionContext exe_ctx(interpreter.GetDebugger().GetExecutionContext()); + if (exe_ctx.target) + exe_ctx.target->GetTargetTriple(target_triple); if (!target_triple) target_triple = Host::GetTargetTriple (); - ExecutionContext exe_ctx(context->GetExecutionContext()); if (exe_ctx.thread == NULL || exe_ctx.frame == NULL) { result.AppendError ("No currently selected thread and frame."); @@ -215,7 +213,7 @@ val.SetValueType (Value::eValueTypeHostAddress); - void *cstr_type = target->GetScratchClangASTContext()->GetCStringType(true); + void *cstr_type = exe_ctx.target->GetScratchClangASTContext()->GetCStringType(true); val.SetContext (Value::eContextTypeOpaqueClangQualType, cstr_type); value_list.PushValue(val); @@ -233,7 +231,7 @@ // run it: StreamString errors; - ClangFunction clang_fun (target_triple.GetCString(), *target_fn, target->GetScratchClangASTContext(), value_list); + ClangFunction clang_fun (target_triple.GetCString(), *target_fn, exe_ctx.target->GetScratchClangASTContext(), value_list); if (m_options.noexecute) { // Now write down the argument values for this call. Modified: lldb/trunk/source/Commands/CommandObjectCall.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectCall.h?rev=106615&r1=106614&r2=106615&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectCall.h (original) +++ lldb/trunk/source/Commands/CommandObjectCall.h Tue Jun 22 20:19:29 2010 @@ -66,9 +66,8 @@ virtual bool - Execute (Args& command, - CommandContext *context, - CommandInterpreter *interpreter, + Execute (CommandInterpreter &interpreter, + Args& command, CommandReturnObject &result); virtual bool Modified: lldb/trunk/source/Commands/CommandObjectCrossref.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectCrossref.cpp?rev=106615&r1=106614&r2=106615&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectCrossref.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectCrossref.cpp Tue Jun 22 20:19:29 2010 @@ -40,9 +40,8 @@ bool CommandObjectCrossref::Execute ( + CommandInterpreter &interpreter, Args& command, - CommandContext *context, - CommandInterpreter *interpreter, CommandReturnObject &result ) { Modified: lldb/trunk/source/Commands/CommandObjectDisassemble.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectDisassemble.cpp?rev=106615&r1=106614&r2=106615&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectDisassemble.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectDisassemble.cpp Tue Jun 22 20:19:29 2010 @@ -155,8 +155,7 @@ void CommandObjectDisassemble::Disassemble ( - CommandContext *context, - CommandInterpreter *interpreter, + CommandInterpreter &interpreter, CommandReturnObject &result, Disassembler *disassembler, const SymbolContextList &sc_list @@ -171,11 +170,11 @@ break; if (sc.GetAddressRange(eSymbolContextFunction | eSymbolContextSymbol, range)) { - lldb::addr_t addr = range.GetBaseAddress().GetLoadAddress(context->GetExecutionContext().process); + lldb::addr_t addr = range.GetBaseAddress().GetLoadAddress(interpreter.GetDebugger().GetExecutionContext().process); if (addr != LLDB_INVALID_ADDRESS) { lldb::addr_t end_addr = addr + range.GetByteSize(); - Disassemble (context, interpreter, result, disassembler, addr, end_addr); + Disassemble (interpreter, result, disassembler, addr, end_addr); } } } @@ -184,8 +183,7 @@ void CommandObjectDisassemble::Disassemble ( - CommandContext *context, - CommandInterpreter *interpreter, + CommandInterpreter &interpreter, CommandReturnObject &result, Disassembler *disassembler, lldb::addr_t addr, @@ -198,7 +196,7 @@ if (end_addr == LLDB_INVALID_ADDRESS || addr >= end_addr) end_addr = addr + DEFAULT_DISASM_BYTE_SIZE; - ExecutionContext exe_ctx (context->GetExecutionContext()); + ExecutionContext exe_ctx (interpreter.GetDebugger().GetExecutionContext()); DataExtractor data; size_t bytes_disassembled = disassembler->ParseInstructions (&exe_ctx, eAddressTypeLoad, addr, end_addr - addr, data); if (bytes_disassembled == 0) @@ -225,7 +223,7 @@ lldb::addr_t curr_addr = addr + offset; if (m_options.show_mixed) { - Process *process = context->GetExecutionContext().process; + Process *process = interpreter.GetDebugger().GetExecutionContext().process; if (!sc_range.ContainsLoadAddress (curr_addr, process)) { prev_sc = sc; @@ -248,7 +246,7 @@ output_stream.EOL(); if (sc.comp_unit && sc.line_entry.IsValid()) { - interpreter->GetSourceManager().DisplaySourceLinesWithLineNumbers ( + interpreter.GetDebugger().GetSourceManager().DisplaySourceLinesWithLineNumbers ( sc.line_entry.file, sc.line_entry.line, m_options.num_lines_context, @@ -286,13 +284,12 @@ bool CommandObjectDisassemble::Execute ( + CommandInterpreter &interpreter, Args& command, - CommandContext *context, - CommandInterpreter *interpreter, CommandReturnObject &result ) { - Target *target = context->GetTarget(); + Target *target = interpreter.GetDebugger().GetCurrentTarget().get(); if (target == NULL) { result.AppendError ("invalid target, set executable file using 'file' command"); @@ -353,7 +350,7 @@ } else { - ExecutionContext exe_ctx(context->GetExecutionContext()); + ExecutionContext exe_ctx(interpreter.GetDebugger().GetExecutionContext()); if (exe_ctx.frame) { SymbolContext sc(exe_ctx.frame->GetSymbolContext(eSymbolContextFunction | eSymbolContextSymbol)); @@ -394,11 +391,11 @@ if (target->GetImages().FindFunctions(name, sc_list)) { - Disassemble (context, interpreter, result, disassembler, sc_list); + Disassemble (interpreter, result, disassembler, sc_list); } else if (target->GetImages().FindSymbolsWithNameAndType(name, eSymbolTypeCode, sc_list)) { - Disassemble (context, interpreter, result, disassembler, sc_list); + Disassemble (interpreter, result, disassembler, sc_list); } else { @@ -409,7 +406,7 @@ } else { - Disassemble (context, interpreter, result, disassembler, addr, end_addr); + Disassemble (interpreter, result, disassembler, addr, end_addr); } return result.Succeeded(); Modified: lldb/trunk/source/Commands/CommandObjectDisassemble.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectDisassemble.h?rev=106615&r1=106614&r2=106615&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectDisassemble.h (original) +++ lldb/trunk/source/Commands/CommandObjectDisassemble.h Tue Jun 22 20:19:29 2010 @@ -67,25 +67,22 @@ } virtual bool - Execute (Args& command, - CommandContext *context, - CommandInterpreter *interpreter, + Execute (CommandInterpreter &interpreter, + Args& command, CommandReturnObject &result); protected: CommandOptions m_options; void - Disassemble (CommandContext *context, - CommandInterpreter *interpreter, + Disassemble (CommandInterpreter &interpreter, CommandReturnObject &result, Disassembler *disassembler, lldb::addr_t addr, lldb::addr_t end_addr); void - Disassemble (CommandContext *context, - CommandInterpreter *interpreter, + Disassemble (CommandInterpreter &interpreter, CommandReturnObject &result, Disassembler *disassembler, const SymbolContextList &sc_list); Modified: lldb/trunk/source/Commands/CommandObjectExpression.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectExpression.cpp?rev=106615&r1=106614&r2=106615&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectExpression.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectExpression.cpp Tue Jun 22 20:19:29 2010 @@ -21,7 +21,8 @@ #include "lldb/Expression/ClangExpressionVariable.h" #include "lldb/Expression/DWARFExpression.h" #include "lldb/Host/Host.h" -#include "lldb/Interpreter/CommandContext.h" +#include "lldb/Core/Debugger.h" +#include "lldb/Interpreter/CommandInterpreter.h" #include "lldb/Interpreter/CommandReturnObject.h" #include "lldb/Symbol/ObjectFile.h" #include "lldb/Symbol/Variable.h" @@ -124,9 +125,8 @@ bool CommandObjectExpression::Execute ( + CommandInterpreter &interpreter, Args& command, - CommandContext *context, - CommandInterpreter *interpreter, CommandReturnObject &result ) { @@ -138,24 +138,22 @@ CommandObjectExpression::MultiLineExpressionCallback ( void *baton, - InputReader *reader, + InputReader &reader, lldb::InputReaderAction notification, const char *bytes, size_t bytes_len ) { - FILE *out_fh = Debugger::GetSharedInstance().GetOutputFileHandle(); CommandObjectExpression *cmd_object_expr = (CommandObjectExpression *) baton; switch (notification) { case eInputReaderActivate: - if (out_fh) - ::fprintf (out_fh, "%s\n", "Enter expressions, then terminate with an empty line to evaluate:"); + reader.GetDebugger().GetOutputStream().Printf("%s\n", "Enter expressions, then terminate with an empty line to evaluate:"); // Fall through case eInputReaderReactivate: //if (out_fh) - // ::fprintf (out_fh, "%3u: ", cmd_object_expr->m_expr_line_count); + // reader.GetDebugger().GetOutputStream().Printf ("%3u: ", cmd_object_expr->m_expr_line_count); break; case eInputReaderDeactivate: @@ -169,20 +167,18 @@ } if (bytes_len == 0) - reader->SetIsDone(true); + reader.SetIsDone(true); //else if (out_fh && !reader->IsDone()) // ::fprintf (out_fh, "%3u: ", cmd_object_expr->m_expr_line_count); break; case eInputReaderDone: { - StreamFile out_stream(Debugger::GetSharedInstance().GetOutputFileHandle()); - StreamFile err_stream(Debugger::GetSharedInstance().GetErrorFileHandle()); bool bare = false; cmd_object_expr->EvaluateExpression (cmd_object_expr->m_expr_lines.c_str(), bare, - out_stream, - err_stream); + reader.GetDebugger().GetOutputStream(), + reader.GetDebugger().GetErrorStream()); } break; } @@ -329,21 +325,20 @@ bool CommandObjectExpression::ExecuteRawCommandString ( + CommandInterpreter &interpreter, const char *command, - CommandContext *context, - CommandInterpreter *interpreter, CommandReturnObject &result ) { ConstString target_triple; - Target *target = context->GetTarget (); + Target *target = interpreter.GetDebugger().GetCurrentTarget().get(); if (target) target->GetTargetTriple(target_triple); if (!target_triple) target_triple = Host::GetTargetTriple (); - ExecutionContext exe_ctx(context->GetExecutionContext()); + ExecutionContext exe_ctx(interpreter.GetDebugger().GetExecutionContext()); Stream &output_stream = result.GetOutputStream(); @@ -356,18 +351,18 @@ m_expr_lines.clear(); m_expr_line_count = 0; - InputReaderSP reader_sp (new InputReader()); + InputReaderSP reader_sp (new InputReader(interpreter.GetDebugger())); if (reader_sp) { Error err (reader_sp->Initialize (CommandObjectExpression::MultiLineExpressionCallback, this, // baton eInputReaderGranularityLine, // token size, to pass to callback function - NULL, // end token + NULL, // end token NULL, // prompt true)); // echo input if (err.Success()) { - Debugger::GetSharedInstance().PushInputReader (reader_sp); + interpreter.GetDebugger().PushInputReader (reader_sp); result.SetStatus (eReturnStatusSuccessFinishNoResult); } else @@ -408,8 +403,8 @@ if (end_options) { - Args args(command, end_options - command); - if (!ParseOptions(args, interpreter, result)) + Args args (command, end_options - command); + if (!ParseOptions (interpreter, args, result)) return false; } } Modified: lldb/trunk/source/Commands/CommandObjectExpression.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectExpression.h?rev=106615&r1=106614&r2=106615&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectExpression.h (original) +++ lldb/trunk/source/Commands/CommandObjectExpression.h Tue Jun 22 20:19:29 2010 @@ -65,25 +65,23 @@ virtual bool - Execute (Args& command, - CommandContext *context, - CommandInterpreter *interpreter, + Execute (CommandInterpreter &interpreter, + Args& command, CommandReturnObject &result); virtual bool WantsRawCommandString() { return true; } virtual bool - ExecuteRawCommandString (const char *command, - CommandContext *context, - CommandInterpreter *interpreter, + ExecuteRawCommandString (CommandInterpreter &interpreter, + const char *command, CommandReturnObject &result); protected: static size_t MultiLineExpressionCallback (void *baton, - InputReader *reader, + InputReader &reader, lldb::InputReaderAction notification, const char *bytes, size_t bytes_len); Modified: lldb/trunk/source/Commands/CommandObjectFile.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectFile.cpp?rev=106615&r1=106614&r2=106615&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectFile.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectFile.cpp Tue Jun 22 20:19:29 2010 @@ -16,7 +16,7 @@ #include "lldb/Interpreter/Args.h" #include "lldb/Core/Debugger.h" #include "lldb/Core/Timer.h" -#include "lldb/Interpreter/CommandContext.h" +#include "lldb/Core/Debugger.h" #include "lldb/Interpreter/CommandInterpreter.h" #include "lldb/Interpreter/CommandReturnObject.h" #include "lldb/Target/Process.h" @@ -104,9 +104,8 @@ bool CommandObjectFile::Execute ( + CommandInterpreter &interpreter, Args& command, - CommandContext *context, - CommandInterpreter *interpreter, CommandReturnObject &result ) { @@ -135,8 +134,8 @@ if (!arch.IsValid()) arch = LLDB_ARCH_DEFAULT; } - - Error error = Debugger::GetSharedInstance().GetTargetList().CreateTarget (file_spec, arch, NULL, true, target_sp); + Debugger &debugger = interpreter.GetDebugger(); + Error error = debugger.GetTargetList().CreateTarget (debugger, file_spec, arch, NULL, true, target_sp); if (error.Fail() && !m_options.m_arch.IsValid()) { @@ -144,12 +143,12 @@ arch = LLDB_ARCH_DEFAULT_64BIT; else arch = LLDB_ARCH_DEFAULT_32BIT; - error = Debugger::GetSharedInstance().GetTargetList().CreateTarget (file_spec, arch, NULL, true, target_sp); + error = debugger.GetTargetList().CreateTarget (debugger, file_spec, arch, NULL, true, target_sp); } if (target_sp) { - Debugger::GetSharedInstance().GetTargetList().SetCurrentTarget(target_sp.get()); + debugger.GetTargetList().SetCurrentTarget(target_sp.get()); result.AppendMessageWithFormat ("Current executable set to '%s' (%s).\n", file_path, arch.AsCString()); result.SetStatus (eReturnStatusSuccessFinishNoResult); } Modified: lldb/trunk/source/Commands/CommandObjectFile.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectFile.h?rev=106615&r1=106614&r2=106615&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectFile.h (original) +++ lldb/trunk/source/Commands/CommandObjectFile.h Tue Jun 22 20:19:29 2010 @@ -34,9 +34,8 @@ ~CommandObjectFile (); virtual bool - Execute (Args& command, - CommandContext *context, - CommandInterpreter *interpreter, + Execute (CommandInterpreter &interpreter, + Args& command, CommandReturnObject &result); virtual Options * Modified: lldb/trunk/source/Commands/CommandObjectFrame.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectFrame.cpp?rev=106615&r1=106614&r2=106615&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectFrame.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectFrame.cpp Tue Jun 22 20:19:29 2010 @@ -16,7 +16,7 @@ #include "lldb/Interpreter/Args.h" #include "lldb/Core/Debugger.h" #include "lldb/Core/Timer.h" -#include "lldb/Interpreter/CommandContext.h" +#include "lldb/Core/Debugger.h" #include "lldb/Interpreter/CommandInterpreter.h" #include "lldb/Interpreter/CommandReturnObject.h" #include "lldb/Target/Process.h" @@ -51,12 +51,11 @@ } bool - Execute (Args& command, - CommandContext *context, - CommandInterpreter *interpreter, + Execute (CommandInterpreter &interpreter, + Args& command, CommandReturnObject &result) { - ExecutionContext exe_ctx(context->GetExecutionContext()); + ExecutionContext exe_ctx(interpreter.GetDebugger().GetExecutionContext()); if (exe_ctx.frame) { exe_ctx.frame->Dump (&result.GetOutputStream(), true); @@ -95,12 +94,11 @@ } bool - Execute (Args& command, - CommandContext *context, - CommandInterpreter *interpreter, + Execute (CommandInterpreter &interpreter, + Args& command, CommandReturnObject &result) { - ExecutionContext exe_ctx (context->GetExecutionContext()); + ExecutionContext exe_ctx (interpreter.GetDebugger().GetExecutionContext()); if (exe_ctx.thread) { if (command.GetArgumentCount() == 1) @@ -156,13 +154,13 @@ // CommandObjectMultiwordFrame //------------------------------------------------------------------------- -CommandObjectMultiwordFrame::CommandObjectMultiwordFrame (CommandInterpreter *interpreter) : +CommandObjectMultiwordFrame::CommandObjectMultiwordFrame (CommandInterpreter &interpreter) : CommandObjectMultiword ("frame", "A set of commands for operating on the current thread's frames.", "frame []") { - LoadSubCommand (CommandObjectSP (new CommandObjectFrameInfo ()), "info", interpreter); - LoadSubCommand (CommandObjectSP (new CommandObjectFrameSelect ()), "select", interpreter); + LoadSubCommand (interpreter, "info", CommandObjectSP (new CommandObjectFrameInfo ())); + LoadSubCommand (interpreter, "select", CommandObjectSP (new CommandObjectFrameSelect ())); } CommandObjectMultiwordFrame::~CommandObjectMultiwordFrame () Modified: lldb/trunk/source/Commands/CommandObjectFrame.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectFrame.h?rev=106615&r1=106614&r2=106615&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectFrame.h (original) +++ lldb/trunk/source/Commands/CommandObjectFrame.h Tue Jun 22 20:19:29 2010 @@ -28,7 +28,7 @@ { public: - CommandObjectMultiwordFrame (CommandInterpreter *interpreter); + CommandObjectMultiwordFrame (CommandInterpreter &interpreter); virtual ~CommandObjectMultiwordFrame (); Modified: lldb/trunk/source/Commands/CommandObjectHelp.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectHelp.cpp?rev=106615&r1=106614&r2=106615&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectHelp.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectHelp.cpp Tue Jun 22 20:19:29 2010 @@ -38,133 +38,29 @@ bool -CommandObjectHelp::OldExecute -( - Args& command, - CommandContext *context, - CommandInterpreter *interpreter, - CommandReturnObject &result -) -{ - CommandObject::CommandMap::iterator pos; - CommandObject *cmd_obj; - - const int argc = command.GetArgumentCount(); - if (argc > 0) - { - cmd_obj = interpreter->GetCommandObject (command.GetArgumentAtIndex(0), false, false); - if (cmd_obj == NULL) - { - cmd_obj = interpreter->GetCommandObject (command.GetArgumentAtIndex(0), true, false); - if (cmd_obj != NULL) - { - StreamString alias_help_str; - interpreter->GetAliasHelp (command.GetArgumentAtIndex(0), cmd_obj->GetCommandName(), alias_help_str); - result.AppendMessageWithFormat ("'%s' is an alias for %s.\n", command.GetArgumentAtIndex (0), - alias_help_str.GetData()); - } - } - - if (cmd_obj) - { - Stream &output_strm = result.GetOutputStream(); - if (cmd_obj->GetOptions() != NULL) - { - const char * long_help = cmd_obj->GetHelpLong(); - if ((long_help!= NULL) - && strlen (long_help) > 0) - output_strm.Printf ("\n%s", cmd_obj->GetHelpLong()); - else - output_strm.Printf ("\n%s\n", cmd_obj->GetHelp()); - output_strm.Printf ("\nSyntax: %s\n", cmd_obj->GetSyntax()); - cmd_obj->GetOptions()->GenerateOptionUsage (output_strm, cmd_obj); - } - else if (cmd_obj->IsMultiwordObject()) - { - bool done = false; - if (argc > 1) - { - CommandObject::CommandMap::iterator pos; - std::string sub_command = command.GetArgumentAtIndex(1); - pos = ((CommandObjectMultiword *) cmd_obj)->m_subcommand_dict.find(sub_command); - if (pos != ((CommandObjectMultiword *) cmd_obj)->m_subcommand_dict.end()) - { - CommandObject *sub_cmd_obj = pos->second.get(); - if (sub_cmd_obj->GetOptions() != NULL) - { - output_strm.Printf ("\n%s\n", sub_cmd_obj->GetHelp()); - output_strm.Printf ("\nSyntax: %s\n", sub_cmd_obj->GetSyntax()); - sub_cmd_obj->GetOptions()->GenerateOptionUsage (output_strm, sub_cmd_obj); - done = true; - } - else - { - output_strm.Printf ("\n%s\n", sub_cmd_obj->GetHelp()); - output_strm.Printf ("\nSyntax: %s\n", sub_cmd_obj->GetSyntax()); - done = true; - } - } - } - if (!done) - { - output_strm.Printf ("%s\n", cmd_obj->GetHelp()); - ((CommandObjectMultiword *) cmd_obj)->GenerateHelpText (result, interpreter); - } - } - else - { - const char *long_help = cmd_obj->GetHelpLong(); - if ((long_help != NULL) - && (strlen (long_help) > 0)) - output_strm.Printf ("\n%s", cmd_obj->GetHelpLong()); - else - output_strm.Printf ("\n%s\n", cmd_obj->GetHelp()); - output_strm.Printf ("\nSyntax: %s\n", cmd_obj->GetSyntax()); - } - result.SetStatus (eReturnStatusSuccessFinishNoResult); - } - else - { - result.AppendErrorWithFormat - ("'%s' is not a known command.\nTry 'help' to see a current list of commands.\n", - command.GetArgumentAtIndex(0)); - result.SetStatus (eReturnStatusFailed); - } - } - else - { - result.SetStatus (eReturnStatusSuccessFinishNoResult); - interpreter->GetHelp(result); - } - return result.Succeeded(); -} - -bool -CommandObjectHelp::Execute (Args &command, CommandContext *context, CommandInterpreter *interpreter, - CommandReturnObject &result) +CommandObjectHelp::Execute (CommandInterpreter &interpreter, Args& command, CommandReturnObject &result) { CommandObject::CommandMap::iterator pos; CommandObject *cmd_obj; const int argc = command.GetArgumentCount (); - + // 'help' doesn't take any options or arguments, other than command names. If argc is 0, we show the user // all commands and aliases. Otherwise every argument must be the name of a command or a sub-command. - if (argc == 0) { result.SetStatus (eReturnStatusSuccessFinishNoResult); - interpreter->GetHelp (result); // General help, for ALL commands. + interpreter.GetHelp (result); // General help, for ALL commands. } else { // Get command object for the first command argument. Only search built-in command dictionary. - cmd_obj = interpreter->GetCommandObject (command.GetArgumentAtIndex (0), false, false); + cmd_obj = interpreter.GetCommandObject (command.GetArgumentAtIndex (0), false, false); if (cmd_obj == NULL) - { + { // That failed, so now search in the aliases dictionary, too. - cmd_obj = interpreter->GetCommandObject (command.GetArgumentAtIndex (0), true, false); - } - + cmd_obj = interpreter.GetCommandObject (command.GetArgumentAtIndex (0), true, false); + } + if (cmd_obj != NULL) { bool all_okay = true; @@ -182,19 +78,19 @@ { pos = ((CommandObjectMultiword *) sub_cmd_obj)->m_subcommand_dict.find (sub_command); if (pos != ((CommandObjectMultiword *) sub_cmd_obj)->m_subcommand_dict.end()) - sub_cmd_obj = pos->second.get(); + sub_cmd_obj = pos->second.get(); else - all_okay = false; + all_okay = false; } } - + if (!all_okay || (sub_cmd_obj == NULL)) { std::string cmd_string; command.GetCommandString (cmd_string); result.AppendErrorWithFormat - ("'%s' is not a known command.\nTry 'help' to see a current list of commands.\n", - cmd_string.c_str()); + ("'%s' is not a known command.\nTry 'help' to see a current list of commands.\n", + cmd_string.c_str()); result.SetStatus (eReturnStatusFailed); } else @@ -208,59 +104,59 @@ const char *long_help = sub_cmd_obj->GetHelpLong(); if ((long_help != NULL) && (strlen (long_help) > 0)) - output_strm.Printf ("\n%s", long_help); + output_strm.Printf ("\n%s", long_help); } else if (sub_cmd_obj->IsMultiwordObject()) { output_strm.Printf ("%s\n", sub_cmd_obj->GetHelp()); - ((CommandObjectMultiword *) sub_cmd_obj)->GenerateHelpText (result, interpreter); + ((CommandObjectMultiword *) sub_cmd_obj)->GenerateHelpText (interpreter, result); } else { - const char *long_help = sub_cmd_obj->GetHelpLong(); - if ((long_help != NULL) - && (strlen (long_help) > 0)) - output_strm.Printf ("%s", long_help); - else - output_strm.Printf ("%s\n", sub_cmd_obj->GetHelp()); - output_strm.Printf ("\nSyntax: %s\n", sub_cmd_obj->GetSyntax()); + const char *long_help = sub_cmd_obj->GetHelpLong(); + if ((long_help != NULL) + && (strlen (long_help) > 0)) + output_strm.Printf ("%s", long_help); + else + output_strm.Printf ("%s\n", sub_cmd_obj->GetHelp()); + output_strm.Printf ("\nSyntax: %s\n", sub_cmd_obj->GetSyntax()); } } } else { result.AppendErrorWithFormat - ("'%s' is not a known command.\nTry 'help' to see a current list of commands.\n", - command.GetArgumentAtIndex(0)); + ("'%s' is not a known command.\nTry 'help' to see a current list of commands.\n", + command.GetArgumentAtIndex(0)); result.SetStatus (eReturnStatusFailed); } } - + return result.Succeeded(); } int CommandObjectHelp::HandleCompletion ( + CommandInterpreter &interpreter, Args &input, int &cursor_index, int &cursor_char_position, int match_start_point, int max_return_elements, - CommandInterpreter *interpreter, StringList &matches ) { // Return the completions of the commands in the help system: if (cursor_index == 0) { - return interpreter->HandleCompletionMatches(input, cursor_index, cursor_char_position, match_start_point, max_return_elements, matches); + return interpreter.HandleCompletionMatches(input, cursor_index, cursor_char_position, match_start_point, max_return_elements, matches); } else { - CommandObject *cmd_obj = interpreter->GetCommandObject (input.GetArgumentAtIndex(0), true, false); + CommandObject *cmd_obj = interpreter.GetCommandObject (input.GetArgumentAtIndex(0), true, false); input.Shift(); cursor_index--; - return cmd_obj->HandleCompletion (input, cursor_index, cursor_char_position, match_start_point, max_return_elements, interpreter, matches); + return cmd_obj->HandleCompletion (interpreter, input, cursor_index, cursor_char_position, match_start_point, max_return_elements, matches); } } Modified: lldb/trunk/source/Commands/CommandObjectHelp.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectHelp.h?rev=106615&r1=106614&r2=106615&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectHelp.h (original) +++ lldb/trunk/source/Commands/CommandObjectHelp.h Tue Jun 22 20:19:29 2010 @@ -31,25 +31,18 @@ virtual ~CommandObjectHelp (); - bool - OldExecute (Args& command, - CommandContext *context, - CommandInterpreter *interpreter, - CommandReturnObject &result); - virtual bool - Execute (Args& command, - CommandContext *context, - CommandInterpreter *interpreter, + Execute (CommandInterpreter &interpreter, + Args& command, CommandReturnObject &result); virtual int - HandleCompletion (Args &input, + HandleCompletion (CommandInterpreter &interpreter, + Args &input, int &cursor_index, int &cursor_char_position, int match_start_point, int max_return_elements, - CommandInterpreter *interpreter, StringList &matches); }; Modified: lldb/trunk/source/Commands/CommandObjectImage.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectImage.cpp?rev=106615&r1=106614&r2=106615&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectImage.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectImage.cpp Tue Jun 22 20:19:29 2010 @@ -13,21 +13,22 @@ // C++ Includes // Other libraries and framework includes // Project includes +#include "lldb/Core/Debugger.h" +#include "lldb/Core/FileSpec.h" +#include "lldb/Core/Module.h" +#include "lldb/Core/RegularExpression.h" +#include "lldb/Core/Stream.h" #include "lldb/Interpreter/Args.h" -#include "lldb/Interpreter/CommandContext.h" #include "lldb/Interpreter/Options.h" +#include "lldb/Interpreter/CommandCompletions.h" +#include "lldb/Interpreter/CommandInterpreter.h" #include "lldb/Interpreter/CommandReturnObject.h" -#include "lldb/Core/FileSpec.h" #include "lldb/Symbol/LineTable.h" #include "lldb/Symbol/ObjectFile.h" -#include "lldb/Core/RegularExpression.h" -#include "lldb/Core/Stream.h" #include "lldb/Symbol/SymbolFile.h" #include "lldb/Symbol/SymbolVendor.h" -#include "lldb/Core/Module.h" #include "lldb/Target/Process.h" #include "lldb/Target/Target.h" -#include "lldb/Interpreter/CommandCompletions.h" using namespace lldb; using namespace lldb_private; @@ -56,7 +57,7 @@ static uint32_t DumpCompileUnitLineTable ( - CommandContext *context, + CommandInterpreter &interpreter, Stream &strm, Module *module, const FileSpec &file_spec, @@ -85,7 +86,9 @@ << module->GetFileSpec().GetFilename() << "\n"; LineTable *line_table = sc.comp_unit->GetLineTable(); if (line_table) - line_table->GetDescription (&strm, context->GetExecutionContext().process, lldb::eDescriptionLevelBrief); + line_table->GetDescription (&strm, + interpreter.GetDebugger().GetExecutionContext().process, + lldb::eDescriptionLevelBrief); else strm << "No line table"; } @@ -153,7 +156,7 @@ static void -DumpModuleSymtab (CommandContext *context, Stream &strm, Module *module) +DumpModuleSymtab (CommandInterpreter &interpreter, Stream &strm, Module *module) { if (module) { @@ -162,13 +165,13 @@ { Symtab *symtab = objfile->GetSymtab(); if (symtab) - symtab->Dump(&strm, context->GetExecutionContext().process); + symtab->Dump(&strm, interpreter.GetDebugger().GetExecutionContext().process); } } } static void -DumpModuleSections (CommandContext *context, Stream &strm, Module *module) +DumpModuleSections (CommandInterpreter &interpreter, Stream &strm, Module *module) { if (module) { @@ -177,7 +180,7 @@ { SectionList *section_list = objfile->GetSectionList(); if (section_list) - section_list->Dump(&strm, context->GetExecutionContext().process, true); + section_list->Dump(&strm, interpreter.GetDebugger().GetExecutionContext().process, true); } } } @@ -198,14 +201,14 @@ } static bool -LookupAddressInModule (CommandContext *context, Stream &strm, Module *module, uint32_t resolve_mask, lldb::addr_t raw_addr, lldb::addr_t offset) +LookupAddressInModule (CommandInterpreter &interpreter, Stream &strm, Module *module, uint32_t resolve_mask, lldb::addr_t raw_addr, lldb::addr_t offset) { if (module) { lldb::addr_t addr = raw_addr - offset; Address so_addr; SymbolContext sc; - Process *process = context->GetExecutionContext().process; + Process *process = interpreter.GetDebugger().GetExecutionContext().process; if (process && process->IsAlive()) { if (!process->ResolveLoadAddress (addr, so_addr)) @@ -223,7 +226,7 @@ if (offset) strm.Printf("0x%llx: ", addr); - ExecutionContextScope *exe_scope = context->GetExecutionContext().GetBestExecutionContextScope(); + ExecutionContextScope *exe_scope = interpreter.GetDebugger().GetExecutionContext().GetBestExecutionContextScope(); if (so_addr.Dump (&strm, exe_scope, Address::DumpStyleSectionNameOffset)) strm.PutCString(": "); so_addr.Dump (&strm, exe_scope, Address::DumpStyleResolvedDescription); @@ -234,7 +237,7 @@ } static uint32_t -LookupSymbolInModule (CommandContext *context, Stream &strm, Module *module, const char *name, bool name_is_regex) +LookupSymbolInModule (CommandInterpreter &interpreter, Stream &strm, Module *module, const char *name, bool name_is_regex) { if (module) { @@ -275,7 +278,7 @@ { Symbol *symbol = symtab->SymbolAtIndex(match_indexes[i]); strm.Indent (); - symbol->Dump (&strm, context->GetExecutionContext().process, i); + symbol->Dump (&strm, interpreter.GetDebugger().GetExecutionContext().process, i); } strm.IndentLess (); return num_matches; @@ -288,7 +291,7 @@ static void -DumpSymbolContextList (CommandContext *context, Stream &strm, SymbolContextList &sc_list, bool prepend_addr) +DumpSymbolContextList (CommandInterpreter &interpreter, Stream &strm, SymbolContextList &sc_list, bool prepend_addr) { strm.IndentMore (); uint32_t i; @@ -305,9 +308,9 @@ if (sc.line_entry.range.GetBaseAddress().IsValid()) { lldb::addr_t vm_addr = - sc.line_entry.range.GetBaseAddress().GetLoadAddress(context->GetExecutionContext().process); + sc.line_entry.range.GetBaseAddress().GetLoadAddress(interpreter.GetDebugger().GetExecutionContext().process); int addr_size = sizeof (addr_t); - Process *process = context->GetExecutionContext().process; + Process *process = interpreter.GetDebugger().GetExecutionContext().process; if (process) addr_size = process->GetAddressByteSize(); if (vm_addr != LLDB_INVALID_ADDRESS) @@ -318,14 +321,14 @@ strm.PutCString(" in "); } } - sc.DumpStopContext(&strm, context->GetExecutionContext().process, sc.line_entry.range.GetBaseAddress()); + sc.DumpStopContext(&strm, interpreter.GetDebugger().GetExecutionContext().process, sc.line_entry.range.GetBaseAddress()); } } strm.IndentLess (); } static uint32_t -LookupFunctionInModule (CommandContext *context, Stream &strm, Module *module, const char *name, bool name_is_regex) +LookupFunctionInModule (CommandInterpreter &interpreter, Stream &strm, Module *module, const char *name, bool name_is_regex) { if (module && name && name[0]) { @@ -353,7 +356,7 @@ strm.Printf("%u match%s found in ", num_matches, num_matches > 1 ? "es" : ""); DumpFullpath (strm, &module->GetFileSpec(), 0); strm.PutCString(":\n"); - DumpSymbolContextList (context, strm, sc_list, true); + DumpSymbolContextList (interpreter, strm, sc_list, true); } return num_matches; } @@ -362,7 +365,7 @@ } static uint32_t -LookupFileAndLineInModule (CommandContext *context, Stream &strm, Module *module, const FileSpec &file_spec, uint32_t line, bool check_inlines) +LookupFileAndLineInModule (CommandInterpreter &interpreter, Stream &strm, Module *module, const FileSpec &file_spec, uint32_t line, bool check_inlines) { if (module && file_spec) { @@ -379,7 +382,7 @@ strm << " in "; DumpFullpath (strm, &module->GetFileSpec(), 0); strm.PutCString(":\n"); - DumpSymbolContextList (context, strm, sc_list, true); + DumpSymbolContextList (interpreter, strm, sc_list, true); return num_matches; } } @@ -397,8 +400,8 @@ public: CommandObjectImageDumpModuleList (const char *name, - const char *help, - const char *syntax) : + const char *help, + const char *syntax) : CommandObject (name, help, syntax) { } @@ -409,26 +412,26 @@ } virtual int - HandleArgumentCompletion (Args &input, - int &cursor_index, - int &cursor_char_position, - OptionElementVector &opt_element_vector, - int match_start_point, - int max_return_elements, - CommandInterpreter *interpreter, - StringList &matches) + HandleArgumentCompletion (CommandInterpreter &interpreter, + Args &input, + int &cursor_index, + int &cursor_char_position, + OptionElementVector &opt_element_vector, + int match_start_point, + int max_return_elements, + StringList &matches) { // Arguments are the standard module completer. std::string completion_str (input.GetArgumentAtIndex(cursor_index)); completion_str.erase (cursor_char_position); - CommandCompletions::InvokeCommonCompletionCallbacks (CommandCompletions::eModuleCompletion, - completion_str.c_str(), - match_start_point, - max_return_elements, - interpreter, - NULL, - matches); + CommandCompletions::InvokeCommonCompletionCallbacks (interpreter, + CommandCompletions::eModuleCompletion, + completion_str.c_str(), + match_start_point, + max_return_elements, + NULL, + matches); return matches.GetSize(); } }; @@ -438,8 +441,8 @@ public: CommandObjectImageDumpSourceFileList (const char *name, - const char *help, - const char *syntax) : + const char *help, + const char *syntax) : CommandObject (name, help, syntax) { } @@ -450,26 +453,26 @@ } virtual int - HandleArgumentCompletion (Args &input, - int &cursor_index, - int &cursor_char_position, - OptionElementVector &opt_element_vector, - int match_start_point, - int max_return_elements, - CommandInterpreter *interpreter, - StringList &matches) + HandleArgumentCompletion (CommandInterpreter &interpreter, + Args &input, + int &cursor_index, + int &cursor_char_position, + OptionElementVector &opt_element_vector, + int match_start_point, + int max_return_elements, + StringList &matches) { // Arguments are the standard source file completer. std::string completion_str (input.GetArgumentAtIndex(cursor_index)); completion_str.erase (cursor_char_position); - CommandCompletions::InvokeCommonCompletionCallbacks (CommandCompletions::eSourceFileCompletion, - completion_str.c_str(), - match_start_point, - max_return_elements, - interpreter, - NULL, - matches); + CommandCompletions::InvokeCommonCompletionCallbacks (interpreter, + CommandCompletions::eSourceFileCompletion, + completion_str.c_str(), + match_start_point, + max_return_elements, + NULL, + matches); return matches.GetSize(); } }; @@ -491,12 +494,11 @@ } virtual bool - Execute (Args& command, - CommandContext *context, - CommandInterpreter *interpreter, + Execute (CommandInterpreter &interpreter, + Args& command, CommandReturnObject &result) { - Target *target = context->GetTarget(); + Target *target = interpreter.GetDebugger().GetCurrentTarget().get(); if (target == NULL) { result.AppendError ("invalid target, set executable file using 'file' command"); @@ -521,7 +523,7 @@ for (uint32_t image_idx = 0; image_idxGetImages().GetModulePointerAtIndex(image_idx)); + DumpModuleSymtab (interpreter, result.GetOutputStream(), target->GetImages().GetModulePointerAtIndex(image_idx)); } } else @@ -549,7 +551,7 @@ if (image_module) { num_dumped++; - DumpModuleSymtab (context, result.GetOutputStream(), image_module); + DumpModuleSymtab (interpreter, result.GetOutputStream(), image_module); } } } @@ -578,10 +580,9 @@ { public: CommandObjectImageDumpSections () : - CommandObjectImageDumpModuleList ( - "image dump sections", - "Dump the sections from one or more executable images.", - "image dump sections [ ...]") + CommandObjectImageDumpModuleList ("image dump sections", + "Dump the sections from one or more executable images.", + "image dump sections [ ...]") { } @@ -591,12 +592,11 @@ } virtual bool - Execute (Args& command, - CommandContext *context, - CommandInterpreter *interpreter, + Execute (CommandInterpreter &interpreter, + Args& command, CommandReturnObject &result) { - Target *target = context->GetTarget(); + Target *target = interpreter.GetDebugger().GetCurrentTarget().get(); if (target == NULL) { result.AppendError ("invalid target, set executable file using 'file' command"); @@ -621,7 +621,7 @@ for (uint32_t image_idx = 0; image_idxGetImages().GetModulePointerAtIndex(image_idx)); + DumpModuleSections (interpreter, result.GetOutputStream(), target->GetImages().GetModulePointerAtIndex(image_idx)); } } else @@ -649,7 +649,7 @@ if (image_module) { num_dumped++; - DumpModuleSections (context, result.GetOutputStream(), image_module); + DumpModuleSections (interpreter, result.GetOutputStream(), image_module); } } } @@ -689,12 +689,11 @@ } virtual bool - Execute (Args& command, - CommandContext *context, - CommandInterpreter *interpreter, + Execute (CommandInterpreter &interpreter, + Args& command, CommandReturnObject &result) { - Target *target = context->GetTarget(); + Target *target = interpreter.GetDebugger().GetCurrentTarget().get(); if (target == NULL) { result.AppendError ("invalid target, set executable file using 'file' command"); @@ -787,12 +786,11 @@ } virtual bool - Execute (Args& command, - CommandContext *context, - CommandInterpreter *interpreter, + Execute (CommandInterpreter &interpreter, + Args& command, CommandReturnObject &result) { - Target *target = context->GetTarget(); + Target *target = interpreter.GetDebugger().GetCurrentTarget().get(); if (target == NULL) { result.AppendError ("invalid target, set executable file using 'file' command"); @@ -801,7 +799,7 @@ } else { - ExecutionContext exe_ctx(context->GetExecutionContext()); + ExecutionContext exe_ctx(interpreter.GetDebugger().GetExecutionContext()); uint32_t total_num_dumped = 0; uint32_t addr_byte_size = target->GetArchitecture().GetAddressByteSize(); @@ -826,7 +824,7 @@ uint32_t num_dumped = 0; for (uint32_t i = 0; iGetImages().GetModulePointerAtIndex(i), file_spec, @@ -863,15 +861,15 @@ //------------------------------------------------------------------ // Constructors and Destructors //------------------------------------------------------------------ - CommandObjectImageDump(CommandInterpreter *interpreter) : + CommandObjectImageDump(CommandInterpreter &interpreter) : CommandObjectMultiword ("image dump", - "Dumps information in one or more executable images; 'line-table' expects a source file name", - "image dump [symtab|sections|symfile|line-table] [ ...]") + "Dumps information in one or more executable images; 'line-table' expects a source file name", + "image dump [symtab|sections|symfile|line-table] [ ...]") { - LoadSubCommand (CommandObjectSP (new CommandObjectImageDumpSymtab ()), "symtab", interpreter); - LoadSubCommand (CommandObjectSP (new CommandObjectImageDumpSections ()), "sections", interpreter); - LoadSubCommand (CommandObjectSP (new CommandObjectImageDumpSymfile ()), "symfile", interpreter); - LoadSubCommand (CommandObjectSP (new CommandObjectImageDumpLineTable ()), "line-table", interpreter); + LoadSubCommand (interpreter, "symtab", CommandObjectSP (new CommandObjectImageDumpSymtab ())); + LoadSubCommand (interpreter, "sections", CommandObjectSP (new CommandObjectImageDumpSections ())); + LoadSubCommand (interpreter, "symfile", CommandObjectSP (new CommandObjectImageDumpSymfile ())); + LoadSubCommand (interpreter, "line-table", CommandObjectSP (new CommandObjectImageDumpLineTable ())); } virtual @@ -957,12 +955,11 @@ } virtual bool - Execute (Args& command, - CommandContext *context, - CommandInterpreter *interpreter, + Execute (CommandInterpreter &interpreter, + Args& command, CommandReturnObject &result) { - Target *target = context->GetTarget(); + Target *target = interpreter.GetDebugger().GetCurrentTarget().get(); if (target == NULL) { result.AppendError ("invalid target, set executable file using 'file' command"); @@ -1223,14 +1220,14 @@ bool - LookupInModule (CommandContext *context, Module *module, CommandReturnObject &result, bool &syntax_error) + LookupInModule (CommandInterpreter &interpreter, Module *module, CommandReturnObject &result, bool &syntax_error) { switch (m_options.m_type) { case eLookupTypeAddress: if (m_options.m_addr != LLDB_INVALID_ADDRESS) { - if (LookupAddressInModule (context, result.GetOutputStream(), module, eSymbolContextEverything, m_options.m_addr, m_options.m_offset)) + if (LookupAddressInModule (interpreter, result.GetOutputStream(), module, eSymbolContextEverything, m_options.m_addr, m_options.m_offset)) { result.SetStatus(eReturnStatusSuccessFinishResult); return true; @@ -1241,7 +1238,7 @@ case eLookupTypeSymbol: if (!m_options.m_str.empty()) { - if (LookupSymbolInModule (context, result.GetOutputStream(), module, m_options.m_str.c_str(), m_options.m_use_regex)) + if (LookupSymbolInModule (interpreter, result.GetOutputStream(), module, m_options.m_str.c_str(), m_options.m_use_regex)) { result.SetStatus(eReturnStatusSuccessFinishResult); return true; @@ -1253,7 +1250,7 @@ if (m_options.m_file) { - if (LookupFileAndLineInModule (context, + if (LookupFileAndLineInModule (interpreter, result.GetOutputStream(), module, m_options.m_file, @@ -1269,7 +1266,7 @@ case eLookupTypeFunction: if (!m_options.m_str.empty()) { - if (LookupFunctionInModule (context, + if (LookupFunctionInModule (interpreter, result.GetOutputStream(), module, m_options.m_str.c_str(), @@ -1292,12 +1289,11 @@ } virtual bool - Execute (Args& command, - CommandContext *context, - CommandInterpreter *interpreter, + Execute (CommandInterpreter &interpreter, + Args& command, CommandReturnObject &result) { - Target *target = context->GetTarget(); + Target *target = interpreter.GetDebugger().GetCurrentTarget().get(); if (target == NULL) { result.AppendError ("invalid target, set executable file using 'file' command"); @@ -1322,7 +1318,7 @@ { for (i = 0; iGetImages().GetModulePointerAtIndex(i), result, syntax_error)) + if (LookupInModule (interpreter, target->GetImages().GetModulePointerAtIndex(i), result, syntax_error)) { result.GetOutputStream().EOL(); num_successful_lookups++; @@ -1353,7 +1349,7 @@ Module * image_module = matching_modules.GetModulePointerAtIndex(i); if (image_module) { - if (LookupInModule (context, image_module, result, syntax_error)) + if (LookupInModule (interpreter, image_module, result, syntax_error)) { result.GetOutputStream().EOL(); num_successful_lookups++; @@ -1399,14 +1395,14 @@ //---------------------------------------------------------------------- // CommandObjectImage constructor //---------------------------------------------------------------------- -CommandObjectImage::CommandObjectImage(CommandInterpreter *interpreter) : +CommandObjectImage::CommandObjectImage(CommandInterpreter &interpreter) : CommandObjectMultiword ("image", - "Access information for one or more executable images.", - "image [dump|list] ...") + "Access information for one or more executable images.", + "image [dump|list] ...") { - LoadSubCommand (CommandObjectSP (new CommandObjectImageDump (interpreter)), "dump", interpreter); - LoadSubCommand (CommandObjectSP (new CommandObjectImageList ()), "list", interpreter); - LoadSubCommand (CommandObjectSP (new CommandObjectImageLookup ()), "lookup", interpreter); + LoadSubCommand (interpreter, "dump", CommandObjectSP (new CommandObjectImageDump (interpreter))); + LoadSubCommand (interpreter, "list", CommandObjectSP (new CommandObjectImageList ())); + LoadSubCommand (interpreter, "lookup", CommandObjectSP (new CommandObjectImageLookup ())); } //---------------------------------------------------------------------- Modified: lldb/trunk/source/Commands/CommandObjectImage.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectImage.h?rev=106615&r1=106614&r2=106615&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectImage.h (original) +++ lldb/trunk/source/Commands/CommandObjectImage.h Tue Jun 22 20:19:29 2010 @@ -28,7 +28,8 @@ //------------------------------------------------------------------ // Constructors and Destructors //------------------------------------------------------------------ - CommandObjectImage(CommandInterpreter *interpreter); + CommandObjectImage(CommandInterpreter &interpreter); + virtual ~CommandObjectImage(); Modified: lldb/trunk/source/Commands/CommandObjectLog.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectLog.cpp?rev=106615&r1=106614&r2=106615&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectLog.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectLog.cpp Tue Jun 22 20:19:29 2010 @@ -26,7 +26,7 @@ #include "lldb/Core/StreamFile.h" #include "lldb/Core/Timer.h" -#include "lldb/Interpreter/CommandContext.h" +#include "lldb/Core/Debugger.h" #include "lldb/Interpreter/CommandReturnObject.h" #include "lldb/Symbol/LineTable.h" @@ -76,9 +76,8 @@ } virtual bool - Execute (Args& args, - CommandContext *context, - CommandInterpreter *interpreter, + Execute (CommandInterpreter &interpreter, + Args& args, CommandReturnObject &result) { if (args.GetArgumentCount() < 1) @@ -256,9 +255,8 @@ } virtual bool - Execute (Args& args, - CommandContext *context, - CommandInterpreter *interpreter, + Execute (CommandInterpreter &interpreter, + Args& args, CommandReturnObject &result) { const size_t argc = args.GetArgumentCount(); @@ -318,9 +316,8 @@ } virtual bool - Execute (Args& args, - CommandContext *context, - CommandInterpreter *interpreter, + Execute (CommandInterpreter &interpreter, + Args& args, CommandReturnObject &result) { const size_t argc = args.GetArgumentCount(); @@ -382,9 +379,8 @@ } virtual bool - Execute (Args& args, - CommandContext *context, - CommandInterpreter *interpreter, + Execute (CommandInterpreter &interpreter, + Args& args, CommandReturnObject &result) { const size_t argc = args.GetArgumentCount(); @@ -429,15 +425,15 @@ //---------------------------------------------------------------------- // CommandObjectLog constructor //---------------------------------------------------------------------- -CommandObjectLog::CommandObjectLog(CommandInterpreter *interpreter) : +CommandObjectLog::CommandObjectLog(CommandInterpreter &interpreter) : CommandObjectMultiword ("log", "A set of commands for operating on logs.", "log []") { - LoadSubCommand (CommandObjectSP (new CommandObjectLogEnable), "enable", interpreter); - LoadSubCommand (CommandObjectSP (new CommandObjectLogDisable), "disable", interpreter); - LoadSubCommand (CommandObjectSP (new CommandObjectLogList), "list", interpreter); - LoadSubCommand (CommandObjectSP (new CommandObjectLogTimer), "timers", interpreter); + LoadSubCommand (interpreter, "enable", CommandObjectSP (new CommandObjectLogEnable)); + LoadSubCommand (interpreter, "disable", CommandObjectSP (new CommandObjectLogDisable)); + LoadSubCommand (interpreter, "list", CommandObjectSP (new CommandObjectLogList)); + LoadSubCommand (interpreter, "timers", CommandObjectSP (new CommandObjectLogTimer)); } //---------------------------------------------------------------------- Modified: lldb/trunk/source/Commands/CommandObjectLog.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectLog.h?rev=106615&r1=106614&r2=106615&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectLog.h (original) +++ lldb/trunk/source/Commands/CommandObjectLog.h Tue Jun 22 20:19:29 2010 @@ -31,7 +31,7 @@ //------------------------------------------------------------------ // Constructors and Destructors //------------------------------------------------------------------ - CommandObjectLog(CommandInterpreter *interpreter); + CommandObjectLog(CommandInterpreter &interpreter); virtual ~CommandObjectLog(); Modified: lldb/trunk/source/Commands/CommandObjectMemory.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectMemory.cpp?rev=106615&r1=106614&r2=106615&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectMemory.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectMemory.cpp Tue Jun 22 20:19:29 2010 @@ -13,13 +13,14 @@ // C++ Includes // Other libraries and framework includes // Project includes -#include "lldb/Interpreter/Args.h" #include "lldb/Core/DataBufferHeap.h" #include "lldb/Core/DataExtractor.h" -#include "lldb/Interpreter/Options.h" +#include "lldb/Core/Debugger.h" #include "lldb/Core/StreamString.h" +#include "lldb/Interpreter/Args.h" #include "lldb/Interpreter/CommandReturnObject.h" -#include "lldb/Interpreter/CommandContext.h" +#include "lldb/Interpreter/CommandInterpreter.h" +#include "lldb/Interpreter/Options.h" #include "lldb/Target/Process.h" using namespace lldb; @@ -195,12 +196,11 @@ } virtual bool - Execute (Args& command, - CommandContext *context, - CommandInterpreter *interpreter, + Execute (CommandInterpreter &interpreter, + Args& command, CommandReturnObject &result) { - Process *process = context->GetExecutionContext().process; + Process *process = interpreter.GetDebugger().GetExecutionContext().process; if (process == NULL) { result.AppendError("need a process to read memory"); @@ -441,12 +441,11 @@ } virtual bool - Execute (Args& command, - CommandContext *context, - CommandInterpreter *interpreter, + Execute (CommandInterpreter &interpreter, + Args& command, CommandReturnObject &result) { - Process *process = context->GetExecutionContext().process; + Process *process = interpreter.GetDebugger().GetExecutionContext().process; if (process == NULL) { result.AppendError("need a process to read memory"); @@ -666,13 +665,13 @@ // CommandObjectMemory //------------------------------------------------------------------------- -CommandObjectMemory::CommandObjectMemory (CommandInterpreter *interpreter) : +CommandObjectMemory::CommandObjectMemory (CommandInterpreter &interpreter) : CommandObjectMultiword ("memory", "A set of commands for operating on a memory.", "memory []") { - LoadSubCommand (CommandObjectSP (new CommandObjectMemoryRead ()), "read", interpreter); - LoadSubCommand (CommandObjectSP (new CommandObjectMemoryWrite ()), "write", interpreter); + LoadSubCommand (interpreter, "read", CommandObjectSP (new CommandObjectMemoryRead ())); + LoadSubCommand (interpreter, "write", CommandObjectSP (new CommandObjectMemoryWrite ())); } CommandObjectMemory::~CommandObjectMemory () Modified: lldb/trunk/source/Commands/CommandObjectMemory.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectMemory.h?rev=106615&r1=106614&r2=106615&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectMemory.h (original) +++ lldb/trunk/source/Commands/CommandObjectMemory.h Tue Jun 22 20:19:29 2010 @@ -21,7 +21,7 @@ class CommandObjectMemory : public CommandObjectMultiword { public: - CommandObjectMemory (CommandInterpreter *interpreter); + CommandObjectMemory (CommandInterpreter &interpreter); virtual ~CommandObjectMemory (); Modified: lldb/trunk/source/Commands/CommandObjectMultiword.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectMultiword.cpp?rev=106615&r1=106614&r2=106615&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectMultiword.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectMultiword.cpp Tue Jun 22 20:19:29 2010 @@ -12,7 +12,7 @@ // C++ Includes // Other libraries and framework includes // Project includes -#include "lldb/Interpreter/CommandContext.h" +#include "lldb/Core/Debugger.h" #include "lldb/Interpreter/CommandInterpreter.h" #include "lldb/Interpreter/Options.h" #include "lldb/Interpreter/CommandReturnObject.h" @@ -80,8 +80,12 @@ } bool -CommandObjectMultiword::LoadSubCommand (CommandObjectSP cmd_obj, const char *name, - CommandInterpreter *interpreter) +CommandObjectMultiword::LoadSubCommand +( + CommandInterpreter &interpreter, + const char *name, + const CommandObjectSP& cmd_obj +) { CommandMap::iterator pos; bool success = true; @@ -90,7 +94,7 @@ if (pos == m_subcommand_dict.end()) { m_subcommand_dict[name] = cmd_obj; - interpreter->CrossRegisterCommand (name, GetCommandName()); + interpreter.CrossRegisterCommand (name, GetCommandName()); } else success = false; @@ -101,16 +105,15 @@ bool CommandObjectMultiword::Execute ( + CommandInterpreter &interpreter, Args& args, - CommandContext *context, - CommandInterpreter *interpreter, CommandReturnObject &result ) { const size_t argc = args.GetArgumentCount(); if (argc == 0) { - GenerateHelpText (result, interpreter); + GenerateHelpText (interpreter, result); } else { @@ -120,7 +123,7 @@ { if (::strcasecmp (sub_command, "help") == 0) { - GenerateHelpText (result, interpreter); + GenerateHelpText (interpreter, result); } else if (!m_subcommand_dict.empty()) { @@ -133,7 +136,7 @@ args.Shift(); - sub_cmd_obj->ExecuteWithOptions (args, context, interpreter, result); + sub_cmd_obj->ExecuteWithOptions (interpreter, args, result); } else { @@ -176,7 +179,7 @@ } void -CommandObjectMultiword::GenerateHelpText (CommandReturnObject &result, CommandInterpreter *interpreter) +CommandObjectMultiword::GenerateHelpText (CommandInterpreter &interpreter, CommandReturnObject &result) { // First time through here, generate the help text for the object and // push it to the return result object as well @@ -185,7 +188,7 @@ output_stream.PutCString ("The following subcommands are supported:\n\n"); CommandMap::iterator pos; - std::string longest_word = interpreter->FindLongestCommandWord (m_subcommand_dict); + std::string longest_word = interpreter.FindLongestCommandWord (m_subcommand_dict); uint32_t max_len = 0; if (! longest_word.empty()) @@ -195,8 +198,11 @@ { std::string indented_command (" "); indented_command.append (pos->first); - interpreter->OutputFormattedHelpText (result.GetOutputStream(), indented_command.c_str(), "--", - pos->second->GetHelp(), max_len); + interpreter.OutputFormattedHelpText (result.GetOutputStream(), + indented_command.c_str(), + "--", + pos->second->GetHelp(), + max_len); } output_stream.PutCString ("\nFor more help on any particular subcommand, type 'help '.\n"); @@ -207,33 +213,40 @@ int CommandObjectMultiword::HandleCompletion ( + CommandInterpreter &interpreter, Args &input, int &cursor_index, int &cursor_char_position, int match_start_point, int max_return_elements, - CommandInterpreter *interpreter, StringList &matches ) { if (cursor_index == 0) { - CommandObject::AddNamesMatchingPartialString (m_subcommand_dict, input.GetArgumentAtIndex(0), matches); + CommandObject::AddNamesMatchingPartialString (m_subcommand_dict, + input.GetArgumentAtIndex(0), + matches); if (matches.GetSize() == 1 && matches.GetStringAtIndex(0) != NULL && strcmp (input.GetArgumentAtIndex(0), matches.GetStringAtIndex(0)) == 0) { StringList temp_matches; - CommandObject *cmd_obj = GetSubcommandObject (input.GetArgumentAtIndex(0), &temp_matches); + CommandObject *cmd_obj = GetSubcommandObject (input.GetArgumentAtIndex(0), + &temp_matches); if (cmd_obj != NULL) { matches.DeleteStringAtIndex (0); input.Shift(); cursor_char_position = 0; input.AppendArgument (""); - return cmd_obj->HandleCompletion (input, cursor_index, cursor_char_position, match_start_point, - max_return_elements, interpreter, matches); + return cmd_obj->HandleCompletion (interpreter, + input, cursor_index, + cursor_char_position, + match_start_point, + max_return_elements, + matches); } else return matches.GetSize(); @@ -243,7 +256,8 @@ } else { - CommandObject *sub_command_object = GetSubcommandObject (input.GetArgumentAtIndex(0), &matches); + CommandObject *sub_command_object = GetSubcommandObject (input.GetArgumentAtIndex(0), + &matches); if (sub_command_object == NULL) { return matches.GetSize(); @@ -254,8 +268,13 @@ matches.DeleteStringAtIndex(0); input.Shift(); cursor_index--; - return sub_command_object->HandleCompletion (input, cursor_index, cursor_char_position, match_start_point, - max_return_elements, interpreter, matches); + return sub_command_object->HandleCompletion (interpreter, + input, + cursor_index, + cursor_char_position, + match_start_point, + max_return_elements, + matches); } } Modified: lldb/trunk/source/Commands/CommandObjectProcess.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectProcess.cpp?rev=106615&r1=106614&r2=106615&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectProcess.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectProcess.cpp Tue Jun 22 20:19:29 2010 @@ -120,13 +120,12 @@ } bool - Execute (Args& launch_args, - CommandContext *context, - CommandInterpreter *interpreter, + Execute (CommandInterpreter &interpreter, + Args& launch_args, CommandReturnObject &result) { - Target *target = context->GetTarget(); - bool synchronous_execution = interpreter->GetSynchronous (); + Target *target = interpreter.GetDebugger().GetCurrentTarget().get(); + bool synchronous_execution = interpreter.GetSynchronous (); // bool launched = false; // bool stopped_after_launch = false; @@ -138,19 +137,11 @@ } // If our listener is NULL, users aren't allows to launch - Listener *listener = interpreter->GetListener(); - if (listener == NULL) - { - result.AppendError ("operation not allowed through the command interpreter"); - result.SetStatus (eReturnStatusFailed); - return false; - } - char filename[PATH_MAX]; Module *exe_module = target->GetExecutableModule().get(); exe_module->GetFileSpec().GetPath(filename, sizeof(filename)); - Process *process = context->GetExecutionContext().process; + Process *process = interpreter.GetDebugger().GetExecutionContext().process; if (process) { if (process->IsAlive()) @@ -168,10 +159,10 @@ else plugin_name = NULL; - process = target->CreateProcess (*listener, plugin_name).get(); + process = target->CreateProcess (interpreter.GetDebugger().GetListener(), plugin_name).get(); - const Args *environment = interpreter->GetEnvironmentVariables(); - const Args *run_args = interpreter->GetProgramArguments(); + const Args *environment = interpreter.GetEnvironmentVariables(); + const Args *run_args = interpreter.GetProgramArguments(); // There are two possible sources of args to be passed to the process upon launching: Those the user // typed at the run command (launch_args); or those the user pre-set in the run-args variable (run_args). @@ -185,7 +176,7 @@ else { // launch-args was not empty; use that, AND re-set run-args to contains launch-args values. - StateVariable *run_args_var = interpreter->GetStateVariable ("run-args"); + StateVariable *run_args_var = interpreter.GetStateVariable ("run-args"); if (run_args_var != NULL) { run_args_var->ArrayClearValues(); @@ -229,7 +220,7 @@ { // Call continue_command. CommandReturnObject continue_result; - interpreter->HandleCommand("process continue", false, continue_result); + interpreter.HandleCommand("process continue", false, continue_result); } if (synchronous_execution) @@ -296,12 +287,11 @@ } bool - Execute (Args& command, - CommandContext *context, - CommandInterpreter *interpreter, + Execute (CommandInterpreter &interpreter, + Args& command, CommandReturnObject &result) { - Target *target = context->GetTarget(); + Target *target = interpreter.GetDebugger().GetCurrentTarget().get(); if (target == NULL) { result.AppendError ("invalid target, set executable file using 'file' command"); @@ -310,14 +300,8 @@ } // If our listener is NULL, users aren't allows to launch - Listener *listener = interpreter->GetListener(); - if (listener == NULL) - { - result.AppendError ("operation not allowed through the command interpreter"); - result.SetStatus (eReturnStatusFailed); - return false; - } - Process *process = context->GetExecutionContext().process; + + Process *process = interpreter.GetDebugger().GetExecutionContext().process; if (process) { if (process->IsAlive()) @@ -340,7 +324,7 @@ if (!m_options.plugin_name.empty()) plugin_name = m_options.plugin_name.c_str(); - process = target->CreateProcess (*listener, plugin_name).get(); + process = target->CreateProcess (interpreter.GetDebugger().GetListener(), plugin_name).get(); if (process) { @@ -508,13 +492,12 @@ } bool - Execute (Args& command, - CommandContext *context, - CommandInterpreter *interpreter, + Execute (CommandInterpreter &interpreter, + Args& command, CommandReturnObject &result) { - Process *process = context->GetExecutionContext().process; - bool synchronous_execution = interpreter->GetSynchronous (); + Process *process = interpreter.GetDebugger().GetExecutionContext().process; + bool synchronous_execution = interpreter.GetSynchronous (); if (process == NULL) { @@ -595,12 +578,11 @@ } bool - Execute (Args& command, - CommandContext *context, - CommandInterpreter *interpreter, + Execute (CommandInterpreter &interpreter, + Args& command, CommandReturnObject &result) { - Process *process = context->GetExecutionContext().process; + Process *process = interpreter.GetDebugger().GetExecutionContext().process; if (process == NULL) { result.AppendError ("must have a valid process in order to detach"); @@ -643,12 +625,11 @@ } bool - Execute (Args& command, - CommandContext *context, - CommandInterpreter *interpreter, + Execute (CommandInterpreter &interpreter, + Args& command, CommandReturnObject &result) { - Process *process = context->GetExecutionContext().process; + Process *process = interpreter.GetDebugger().GetExecutionContext().process; if (process == NULL) { result.AppendError ("no process to signal"); @@ -711,12 +692,11 @@ } bool - Execute (Args& command, - CommandContext *context, - CommandInterpreter *interpreter, + Execute (CommandInterpreter &interpreter, + Args& command, CommandReturnObject &result) { - Process *process = context->GetExecutionContext().process; + Process *process = interpreter.GetDebugger().GetExecutionContext().process; if (process == NULL) { result.AppendError ("no process to halt"); @@ -773,12 +753,11 @@ } bool - Execute (Args& command, - CommandContext *context, - CommandInterpreter *interpreter, + Execute (CommandInterpreter &interpreter, + Args& command, CommandReturnObject &result) { - Process *process = context->GetExecutionContext().process; + Process *process = interpreter.GetDebugger().GetExecutionContext().process; if (process == NULL) { result.AppendError ("no process to kill"); @@ -832,15 +811,14 @@ bool Execute ( + CommandInterpreter &interpreter, Args& command, - CommandContext *context, - CommandInterpreter *interpreter, CommandReturnObject &result ) { StreamString &output_stream = result.GetOutputStream(); result.SetStatus (eReturnStatusSuccessFinishNoResult); - ExecutionContext exe_ctx(context->GetExecutionContext()); + ExecutionContext exe_ctx(interpreter.GetDebugger().GetExecutionContext()); if (exe_ctx.process) { const StateType state = exe_ctx.process->GetState(); @@ -891,19 +869,19 @@ // CommandObjectMultiwordProcess //------------------------------------------------------------------------- -CommandObjectMultiwordProcess::CommandObjectMultiwordProcess (CommandInterpreter *interpreter) : +CommandObjectMultiwordProcess::CommandObjectMultiwordProcess (CommandInterpreter &interpreter) : CommandObjectMultiword ("process", "A set of commands for operating on a process.", "process []") { - LoadSubCommand (CommandObjectSP (new CommandObjectProcessAttach ()), "attach", interpreter); - LoadSubCommand (CommandObjectSP (new CommandObjectProcessLaunch ()), "launch", interpreter); - LoadSubCommand (CommandObjectSP (new CommandObjectProcessContinue ()), "continue", interpreter); - LoadSubCommand (CommandObjectSP (new CommandObjectProcessDetach ()), "detach", interpreter); - LoadSubCommand (CommandObjectSP (new CommandObjectProcessSignal ()), "signal", interpreter); - LoadSubCommand (CommandObjectSP (new CommandObjectProcessStatus ()), "status", interpreter); - LoadSubCommand (CommandObjectSP (new CommandObjectProcessInterrupt ()), "interrupt", interpreter); - LoadSubCommand (CommandObjectSP (new CommandObjectProcessKill ()), "kill", interpreter); + LoadSubCommand (interpreter, "attach", CommandObjectSP (new CommandObjectProcessAttach ())); + LoadSubCommand (interpreter, "launch", CommandObjectSP (new CommandObjectProcessLaunch ())); + LoadSubCommand (interpreter, "continue", CommandObjectSP (new CommandObjectProcessContinue ())); + LoadSubCommand (interpreter, "detach", CommandObjectSP (new CommandObjectProcessDetach ())); + LoadSubCommand (interpreter, "signal", CommandObjectSP (new CommandObjectProcessSignal ())); + LoadSubCommand (interpreter, "status", CommandObjectSP (new CommandObjectProcessStatus ())); + LoadSubCommand (interpreter, "interrupt", CommandObjectSP (new CommandObjectProcessInterrupt ())); + LoadSubCommand (interpreter, "kill", CommandObjectSP (new CommandObjectProcessKill ())); } CommandObjectMultiwordProcess::~CommandObjectMultiwordProcess () Modified: lldb/trunk/source/Commands/CommandObjectProcess.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectProcess.h?rev=106615&r1=106614&r2=106615&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectProcess.h (original) +++ lldb/trunk/source/Commands/CommandObjectProcess.h Tue Jun 22 20:19:29 2010 @@ -25,7 +25,7 @@ class CommandObjectMultiwordProcess : public CommandObjectMultiword { public: - CommandObjectMultiwordProcess (CommandInterpreter *interpreter); + CommandObjectMultiwordProcess (CommandInterpreter &interpreter); virtual ~CommandObjectMultiwordProcess (); Modified: lldb/trunk/source/Commands/CommandObjectQuit.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectQuit.cpp?rev=106615&r1=106614&r2=106615&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectQuit.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectQuit.cpp Tue Jun 22 20:19:29 2010 @@ -35,13 +35,12 @@ bool CommandObjectQuit::Execute ( - Args& command, - CommandContext *context, - CommandInterpreter *interpreter, + CommandInterpreter &interpreter, + Args& args, CommandReturnObject &result ) { - interpreter->BroadcastEvent (CommandInterpreter::eBroadcastBitQuitCommandReceived); + interpreter.BroadcastEvent (CommandInterpreter::eBroadcastBitQuitCommandReceived); result.SetStatus (eReturnStatusQuit); return true; } Modified: lldb/trunk/source/Commands/CommandObjectQuit.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectQuit.h?rev=106615&r1=106614&r2=106615&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectQuit.h (original) +++ lldb/trunk/source/Commands/CommandObjectQuit.h Tue Jun 22 20:19:29 2010 @@ -39,9 +39,8 @@ ~CommandObjectQuit (); virtual bool - Execute (Args& command, - CommandContext *context, - CommandInterpreter *interpreter, + Execute (CommandInterpreter &interpreter, + Args& args, CommandReturnObject &result); }; Modified: lldb/trunk/source/Commands/CommandObjectRegister.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectRegister.cpp?rev=106615&r1=106614&r2=106615&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectRegister.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectRegister.cpp Tue Jun 22 20:19:29 2010 @@ -13,10 +13,11 @@ // C++ Includes // Other libraries and framework includes // Project includes -#include "lldb/Interpreter/Args.h" #include "lldb/Core/DataExtractor.h" #include "lldb/Core/Scalar.h" -#include "lldb/Interpreter/CommandContext.h" +#include "lldb/Core/Debugger.h" +#include "lldb/Interpreter/Args.h" +#include "lldb/Interpreter/CommandInterpreter.h" #include "lldb/Interpreter/CommandReturnObject.h" #include "lldb/Target/ExecutionContext.h" #include "lldb/Target/RegisterContext.h" @@ -44,14 +45,16 @@ } virtual bool - Execute (Args& command, - CommandContext *context, - CommandInterpreter *interpreter, - CommandReturnObject &result) + Execute + ( + CommandInterpreter &interpreter, + Args& command, + CommandReturnObject &result + ) { StreamString &output_stream = result.GetOutputStream(); DataExtractor reg_data; - ExecutionContext exe_ctx(context->GetExecutionContext()); + ExecutionContext exe_ctx(interpreter.GetDebugger().GetExecutionContext()); RegisterContext *reg_context = exe_ctx.GetRegisterContext (); if (reg_context) @@ -150,13 +153,15 @@ } virtual bool - Execute (Args& command, - CommandContext *context, - CommandInterpreter *interpreter, - CommandReturnObject &result) + Execute + ( + CommandInterpreter &interpreter, + Args& command, + CommandReturnObject &result + ) { DataExtractor reg_data; - ExecutionContext exe_ctx(context->GetExecutionContext()); + ExecutionContext exe_ctx(interpreter.GetDebugger().GetExecutionContext()); RegisterContext *reg_context = exe_ctx.GetRegisterContext (); if (reg_context) @@ -213,13 +218,13 @@ //---------------------------------------------------------------------- // CommandObjectRegister constructor //---------------------------------------------------------------------- -CommandObjectRegister::CommandObjectRegister(CommandInterpreter *interpreter) : +CommandObjectRegister::CommandObjectRegister(CommandInterpreter &interpreter) : CommandObjectMultiword ("register", "Access thread registers.", "register [read|write] ...") { - LoadSubCommand (CommandObjectSP (new CommandObjectRegisterRead ()), "read", interpreter); - LoadSubCommand (CommandObjectSP (new CommandObjectRegisterWrite ()), "write", interpreter); + LoadSubCommand (interpreter, "read", CommandObjectSP (new CommandObjectRegisterRead ())); + LoadSubCommand (interpreter, "write", CommandObjectSP (new CommandObjectRegisterWrite ())); } Modified: lldb/trunk/source/Commands/CommandObjectRegister.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectRegister.h?rev=106615&r1=106614&r2=106615&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectRegister.h (original) +++ lldb/trunk/source/Commands/CommandObjectRegister.h Tue Jun 22 20:19:29 2010 @@ -28,7 +28,8 @@ //------------------------------------------------------------------ // Constructors and Destructors //------------------------------------------------------------------ - CommandObjectRegister(CommandInterpreter *interpreter); + CommandObjectRegister(CommandInterpreter &interpreter); + virtual ~CommandObjectRegister(); Removed: lldb/trunk/source/Commands/CommandObjectRemove.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectRemove.cpp?rev=106614&view=auto ============================================================================== --- lldb/trunk/source/Commands/CommandObjectRemove.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectRemove.cpp (removed) @@ -1,89 +0,0 @@ -//===-- CommandObjectRemove.cpp ---------------------------------*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -#include "CommandObjectRemove.h" - -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes -#include "lldb/Interpreter/CommandInterpreter.h" -#include "lldb/Interpreter/CommandReturnObject.h" - -using namespace lldb; -using namespace lldb_private; - -//------------------------------------------------------------------------- -// CommandObjectRemove -//------------------------------------------------------------------------- - -CommandObjectRemove::CommandObjectRemove () : - CommandObject ("remove", - "Allows the user to remove/delete user-defined command functions (script functions).", - "remove ") -{ -} - -CommandObjectRemove::~CommandObjectRemove() -{ -} - - -bool -CommandObjectRemove::Execute (Args& args, CommandContext *context, CommandInterpreter *interpreter, - CommandReturnObject &result) -{ - CommandObject::CommandMap::iterator pos; - CommandObject *cmd_obj; - - if (args.GetArgumentCount() != 0) - { - const char *command_name = args.GetArgumentAtIndex(0); - cmd_obj = interpreter->GetCommandObject(command_name); - if (cmd_obj) - { - if (interpreter->CommandExists (command_name)) - { - result.AppendErrorWithFormat ("'%s' is a permanent debugger command and cannot be removed.\n", - command_name); - result.SetStatus (eReturnStatusFailed); - } - else - { - - if (interpreter->RemoveUser (command_name) == false) - { - if (interpreter->UserCommandExists (command_name)) - result.AppendErrorWithFormat ("Unknown error occurred; unable to remove command '%s'.\n", - command_name); - else - result.AppendErrorWithFormat ("'%s' is not a user-defined command/function name.\n", - command_name); - result.SetStatus (eReturnStatusFailed); - } - else - result.SetStatus (eReturnStatusSuccessFinishNoResult); - } - } - else - { - result.AppendErrorWithFormat ("'%s' is not a known command.\nTry 'help' to see a current list of commands.\n", - command_name); - result.SetStatus (eReturnStatusFailed); - } - } - else - { - result.AppendError ("must call remove with a valid command"); - result.SetStatus (eReturnStatusFailed); - } - - return result.Succeeded(); -} - Removed: lldb/trunk/source/Commands/CommandObjectRemove.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectRemove.h?rev=106614&view=auto ============================================================================== --- lldb/trunk/source/Commands/CommandObjectRemove.h (original) +++ lldb/trunk/source/Commands/CommandObjectRemove.h (removed) @@ -1,44 +0,0 @@ -//===-- CommandObjectRemove.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_CommandObjectRemove_h_ -#define liblldb_CommandObjectRemove_h_ - -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes -#include "lldb/Interpreter/CommandObject.h" - -namespace lldb_private { - -//------------------------------------------------------------------------- -// CommandObjectRemove -//------------------------------------------------------------------------- - -class CommandObjectRemove : public CommandObject -{ -public: - - CommandObjectRemove (); - - virtual - ~CommandObjectRemove (); - - virtual bool - Execute (Args& command, - CommandContext *context, - CommandInterpreter *interpreter, - CommandReturnObject &result); - -}; - -} // namespace lldb_private - -#endif // liblldb_CommandObjectRemove_h_ Modified: lldb/trunk/source/Commands/CommandObjectSet.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectSet.cpp?rev=106615&r1=106614&r2=106615&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectSet.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectSet.cpp Tue Jun 22 20:19:29 2010 @@ -38,9 +38,8 @@ bool CommandObjectSet::Execute ( + CommandInterpreter &interpreter, Args& command, - CommandContext *context, - CommandInterpreter *interpreter, CommandReturnObject &result ) { @@ -66,7 +65,7 @@ else if (var_value == NULL || var_value[0] == '\0') { // No value given: Check to see if we're trying to clear an array. - StateVariable *var = interpreter->GetStateVariable (var_name); + StateVariable *var = interpreter.GetStateVariable (var_name); if (var != NULL && var->GetType() == StateVariable::eTypeStringArray) { @@ -81,7 +80,7 @@ } else { - StateVariable *var = interpreter->GetStateVariable(var_name); + StateVariable *var = interpreter.GetStateVariable(var_name); if (var == NULL) { result.AppendErrorWithFormat ("'%s' is not a settable internal variable.\n", var_name); @@ -98,7 +97,7 @@ if (success) { result.SetStatus(eReturnStatusSuccessFinishResult); - if (!var->HasVerifyFunction() || var->VerifyValue (interpreter, (void *) &new_value, result)) + if (!var->HasVerifyFunction() || var->VerifyValue (&interpreter, (void *) &new_value, result)) var->SetBoolValue (new_value); } else @@ -115,7 +114,7 @@ if (success) { result.SetStatus(eReturnStatusSuccessFinishResult); - if (!var->HasVerifyFunction() || var->VerifyValue (interpreter, (void *) &new_value, result)) + if (!var->HasVerifyFunction() || var->VerifyValue (&interpreter, (void *) &new_value, result)) var->SetIntValue (new_value); } else @@ -126,7 +125,7 @@ } else if (var->GetType() == StateVariable::eTypeString) { - if (!var->HasVerifyFunction() || var->VerifyValue (interpreter, (void *) var_value, result)) + if (!var->HasVerifyFunction() || var->VerifyValue (&interpreter, (void *) var_value, result)) var->SetStringValue (var_value); } else if (var->GetType() == StateVariable::eTypeStringArray) Modified: lldb/trunk/source/Commands/CommandObjectSet.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectSet.h?rev=106615&r1=106614&r2=106615&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectSet.h (original) +++ lldb/trunk/source/Commands/CommandObjectSet.h Tue Jun 22 20:19:29 2010 @@ -32,9 +32,8 @@ ~CommandObjectSet (); virtual bool - Execute (Args& command, - CommandContext *context, - CommandInterpreter *interpreter, + Execute (CommandInterpreter &interpreter, + Args& command, CommandReturnObject &result); }; Modified: lldb/trunk/source/Commands/CommandObjectSettings.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectSettings.cpp?rev=106615&r1=106614&r2=106615&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectSettings.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectSettings.cpp Tue Jun 22 20:19:29 2010 @@ -38,9 +38,8 @@ bool CommandObjectSettings::Execute ( + CommandInterpreter &interpreter, Args& command, - CommandContext *context, - CommandInterpreter *interpreter, CommandReturnObject &result ) { @@ -53,7 +52,7 @@ } else { - interpreter->ShowVariableHelp (result); + interpreter.ShowVariableHelp (result); result.SetStatus (eReturnStatusSuccessFinishNoResult); } Modified: lldb/trunk/source/Commands/CommandObjectSettings.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectSettings.h?rev=106615&r1=106614&r2=106615&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectSettings.h (original) +++ lldb/trunk/source/Commands/CommandObjectSettings.h Tue Jun 22 20:19:29 2010 @@ -32,9 +32,8 @@ ~CommandObjectSettings (); virtual bool - Execute (Args& command, - CommandContext *context, - CommandInterpreter *interpreter, + Execute (CommandInterpreter &interpreter, + Args& command, CommandReturnObject &result); }; Modified: lldb/trunk/source/Commands/CommandObjectShow.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectShow.cpp?rev=106615&r1=106614&r2=106615&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectShow.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectShow.cpp Tue Jun 22 20:19:29 2010 @@ -38,9 +38,8 @@ bool CommandObjectShow::Execute ( + CommandInterpreter &interpreter, Args& command, - CommandContext *context, - CommandInterpreter *interpreter, CommandReturnObject &result ) { @@ -51,7 +50,7 @@ // The user requested to see the value of a particular variable. const char *var_name = command.GetArgumentAtIndex(0); - StateVariable *var = interpreter->GetStateVariable(var_name); + StateVariable *var = interpreter.GetStateVariable(var_name); if (var) { var->AppendVariableInformation (result); @@ -66,7 +65,7 @@ else { // The user didn't specify a particular variable, so show the values of all of them. - interpreter->ShowVariableValues(result); + interpreter.ShowVariableValues(result); result.SetStatus (eReturnStatusSuccessFinishNoResult); } Modified: lldb/trunk/source/Commands/CommandObjectShow.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectShow.h?rev=106615&r1=106614&r2=106615&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectShow.h (original) +++ lldb/trunk/source/Commands/CommandObjectShow.h Tue Jun 22 20:19:29 2010 @@ -32,9 +32,8 @@ ~CommandObjectShow (); virtual bool - Execute (Args& command, - CommandContext *context, - CommandInterpreter *interpreter, + Execute (CommandInterpreter &interpreter, + Args& command, CommandReturnObject &result); }; Modified: lldb/trunk/source/Commands/CommandObjectSource.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectSource.cpp?rev=106615&r1=106614&r2=106615&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectSource.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectSource.cpp Tue Jun 22 20:19:29 2010 @@ -14,7 +14,7 @@ // Other libraries and framework includes // Project includes #include "lldb/Interpreter/Args.h" -#include "lldb/Interpreter/CommandContext.h" +#include "lldb/Core/Debugger.h" #include "lldb/Interpreter/CommandInterpreter.h" #include "lldb/Interpreter/CommandReturnObject.h" #include "lldb/Target/Process.h" @@ -43,9 +43,8 @@ bool CommandObjectSource::Execute ( + CommandInterpreter &interpreter, Args& args, - CommandContext *context, - CommandInterpreter *interpreter, CommandReturnObject &result ) { @@ -88,8 +87,8 @@ size_t i; for (i = 0; iGetPrompt(), commands[i].c_str()); - if (!interpreter->HandleCommand(commands[i].c_str(), false, result)) + result.GetOutputStream().Printf("%s %s\n", interpreter.GetPrompt(), commands[i].c_str()); + if (!interpreter.HandleCommand(commands[i].c_str(), false, result)) break; } Modified: lldb/trunk/source/Commands/CommandObjectSource.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectSource.h?rev=106615&r1=106614&r2=106615&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectSource.h (original) +++ lldb/trunk/source/Commands/CommandObjectSource.h Tue Jun 22 20:19:29 2010 @@ -36,9 +36,8 @@ GetCommands (); virtual bool - Execute (Args& command, - CommandContext *context, - CommandInterpreter *interpreter, + Execute (CommandInterpreter &interpreter, + Args& command, CommandReturnObject &result); }; Modified: lldb/trunk/source/Commands/CommandObjectSourceFile.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectSourceFile.cpp?rev=106615&r1=106614&r2=106615&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectSourceFile.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectSourceFile.cpp Tue Jun 22 20:19:29 2010 @@ -14,7 +14,7 @@ // Other libraries and framework includes // Project includes #include "lldb/Interpreter/Args.h" -#include "lldb/Interpreter/CommandContext.h" +#include "lldb/Core/Debugger.h" #include "lldb/Interpreter/CommandInterpreter.h" #include "lldb/Interpreter/CommandReturnObject.h" #include "lldb/Target/Process.h" @@ -119,9 +119,8 @@ bool CommandObjectSourceFile::Execute ( + CommandInterpreter &interpreter, Args& args, - CommandContext *context, - CommandInterpreter *interpreter, CommandReturnObject &result ) { @@ -133,7 +132,7 @@ result.SetStatus (eReturnStatusFailed); } - ExecutionContext exe_ctx(context->GetExecutionContext()); + ExecutionContext exe_ctx(interpreter.GetDebugger().GetExecutionContext()); if (m_options.file_name.empty()) { // Last valid source manager context, or the current frame if no @@ -142,14 +141,14 @@ // more likely because you typed it once, then typed it again if (m_options.start_line == 0) { - if (interpreter->GetSourceManager().DisplayMoreWithLineNumbers (&result.GetOutputStream())) + if (interpreter.GetDebugger().GetSourceManager().DisplayMoreWithLineNumbers (&result.GetOutputStream())) { result.SetStatus (eReturnStatusSuccessFinishResult); } } else { - if (interpreter->GetSourceManager().DisplaySourceLinesWithLineNumbersUsingLastFile( + if (interpreter.GetDebugger().GetSourceManager().DisplaySourceLinesWithLineNumbersUsingLastFile( m_options.start_line, // Line to display 0, // Lines before line to display m_options.num_lines, // Lines after line to display @@ -164,7 +163,7 @@ else { const char *filename = m_options.file_name.c_str(); - Target *target = context->GetTarget(); + Target *target = interpreter.GetDebugger().GetCurrentTarget().get(); if (target == NULL) { result.AppendError ("invalid target, set executable file using 'file' command"); @@ -187,13 +186,13 @@ { if (sc.comp_unit) { - interpreter->GetSourceManager ().DisplaySourceLinesWithLineNumbers (sc.comp_unit, - m_options.start_line, // Line to display - 0, // Lines before line to display - m_options.num_lines, // Lines after line to display - "", // Don't mark "line" - &result.GetOutputStream()); - + interpreter.GetDebugger().GetSourceManager ().DisplaySourceLinesWithLineNumbers (sc.comp_unit, + m_options.start_line, // Line to display + 0, // Lines before line to display + m_options.num_lines, // Lines after line to display + "", // Don't mark "line" + &result.GetOutputStream()); + result.SetStatus (eReturnStatusSuccessFinishResult); } Modified: lldb/trunk/source/Commands/CommandObjectSourceFile.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectSourceFile.h?rev=106615&r1=106614&r2=106615&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectSourceFile.h (original) +++ lldb/trunk/source/Commands/CommandObjectSourceFile.h Tue Jun 22 20:19:29 2010 @@ -62,9 +62,8 @@ ~CommandObjectSourceFile (); virtual bool - Execute (Args& command, - CommandContext *context, - CommandInterpreter *interpreter, + Execute (CommandInterpreter &interpreter, + Args& command, CommandReturnObject &result); virtual Modified: lldb/trunk/source/Commands/CommandObjectSyntax.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectSyntax.cpp?rev=106615&r1=106614&r2=106615&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectSyntax.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectSyntax.cpp Tue Jun 22 20:19:29 2010 @@ -43,7 +43,7 @@ CommandObjectSyntax::OldExecute ( Args& command, - CommandContext *context, + Debugger *context, CommandInterpreter *interpreter, CommandReturnObject &result ) @@ -86,7 +86,7 @@ } bool -CommandObjectSyntax::Execute (Args &command, CommandContext *context, CommandInterpreter *interpreter, +CommandObjectSyntax::Execute (Args &command, Debugger *context, CommandInterpreter *interpreter, CommandReturnObject &result) { CommandObject::CommandMap::iterator pos; Modified: lldb/trunk/source/Commands/CommandObjectSyntax.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectSyntax.h?rev=106615&r1=106614&r2=106615&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectSyntax.h (original) +++ lldb/trunk/source/Commands/CommandObjectSyntax.h Tue Jun 22 20:19:29 2010 @@ -33,13 +33,13 @@ bool OldExecute (Args& command, - CommandContext *context, + Debugger *context, CommandInterpreter *interpreter, CommandReturnObject &result); virtual bool Execute (Args& command, - CommandContext *context, + Debugger *context, CommandInterpreter *interpreter, CommandReturnObject &result); Modified: lldb/trunk/source/Commands/CommandObjectTarget.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectTarget.cpp?rev=106615&r1=106614&r2=106615&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectTarget.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectTarget.cpp Tue Jun 22 20:19:29 2010 @@ -18,7 +18,7 @@ #include "lldb/Interpreter/Args.h" #include "lldb/Core/Debugger.h" #include "lldb/Core/Timer.h" -#include "lldb/Interpreter/CommandContext.h" +#include "lldb/Core/Debugger.h" #include "lldb/Interpreter/CommandInterpreter.h" #include "lldb/Interpreter/CommandReturnObject.h" #include "lldb/Target/Process.h" @@ -46,12 +46,11 @@ } bool - Execute (Args& command, - CommandContext *context, - CommandInterpreter *interpreter, + Execute (CommandInterpreter &interpreter, + Args& command, CommandReturnObject &result) { - Target * target = context->GetTarget(); + Target *target = interpreter.GetDebugger().GetCurrentTarget().get(); if (target) { uint32_t argc = command.GetArgumentCount(); @@ -70,9 +69,9 @@ if (from[0] && to[0]) { bool last_pair = ((argc - i) == 2); - target->GetImageSearchPathList().Append(ConstString(from), - ConstString(to), - last_pair); // Notify if this is the last pair + target->GetImageSearchPathList().Append (ConstString(from), + ConstString(to), + last_pair); // Notify if this is the last pair } else { @@ -110,12 +109,11 @@ } bool - Execute (Args& command, - CommandContext *context, - CommandInterpreter *interpreter, + Execute (CommandInterpreter &interpreter, + Args& command, CommandReturnObject &result) { - Target * target = context->GetTarget(); + Target *target = interpreter.GetDebugger().GetCurrentTarget().get(); if (target) { bool notify = true; @@ -146,12 +144,11 @@ } bool - Execute (Args& command, - CommandContext *context, - CommandInterpreter *interpreter, + Execute (CommandInterpreter &interpreter, + Args& command, CommandReturnObject &result) { - Target * target = context->GetTarget(); + Target *target = interpreter.GetDebugger().GetCurrentTarget().get(); if (target) { uint32_t argc = command.GetArgumentCount(); @@ -230,12 +227,11 @@ } bool - Execute (Args& command, - CommandContext *context, - CommandInterpreter *interpreter, + Execute (CommandInterpreter &interpreter, + Args& command, CommandReturnObject &result) { - Target * target = context->GetTarget(); + Target *target = interpreter.GetDebugger().GetCurrentTarget().get(); if (target) { if (command.GetArgumentCount() != 0) @@ -272,12 +268,11 @@ } bool - Execute (Args& command, - CommandContext *context, - CommandInterpreter *interpreter, + Execute (CommandInterpreter &interpreter, + Args& command, CommandReturnObject &result) { - Target * target = context->GetTarget(); + Target *target = interpreter.GetDebugger().GetCurrentTarget().get(); if (target) { if (command.GetArgumentCount() != 1) @@ -327,8 +322,8 @@ // // bool // Execute (Args& command, -// CommandContext *context, -// CommandInterpreter *interpreter, +// Debugger *context, +// CommandInterpreter &interpreter, // CommandReturnObject &result) // { // ExecutionContext exe_ctx (context->GetExecutionContext()); @@ -392,16 +387,16 @@ { public: - CommandObjectMultiwordImageSearchPaths (CommandInterpreter *interpreter) : + CommandObjectMultiwordImageSearchPaths (CommandInterpreter &interpreter) : CommandObjectMultiword ("target image-search-paths", "A set of commands for operating on debugger target image search paths.", "target image-search-paths []") { - LoadSubCommand (CommandObjectSP (new CommandObjectTargetImageSearchPathsAdd ()), "add", interpreter); - LoadSubCommand (CommandObjectSP (new CommandObjectTargetImageSearchPathsClear ()), "clear", interpreter); - LoadSubCommand (CommandObjectSP (new CommandObjectTargetImageSearchPathsInsert ()), "insert", interpreter); - LoadSubCommand (CommandObjectSP (new CommandObjectTargetImageSearchPathsList ()), "list", interpreter); - LoadSubCommand (CommandObjectSP (new CommandObjectTargetImageSearchPathsQuery ()), "query", interpreter); + LoadSubCommand (interpreter, "add", CommandObjectSP (new CommandObjectTargetImageSearchPathsAdd ())); + LoadSubCommand (interpreter, "clear", CommandObjectSP (new CommandObjectTargetImageSearchPathsClear ())); + LoadSubCommand (interpreter, "insert", CommandObjectSP (new CommandObjectTargetImageSearchPathsInsert ())); + LoadSubCommand (interpreter, "list", CommandObjectSP (new CommandObjectTargetImageSearchPathsList ())); + LoadSubCommand (interpreter, "query", CommandObjectSP (new CommandObjectTargetImageSearchPathsQuery ())); } ~CommandObjectMultiwordImageSearchPaths() @@ -416,12 +411,12 @@ // CommandObjectMultiwordTarget //------------------------------------------------------------------------- -CommandObjectMultiwordTarget::CommandObjectMultiwordTarget (CommandInterpreter *interpreter) : +CommandObjectMultiwordTarget::CommandObjectMultiwordTarget (CommandInterpreter &interpreter) : CommandObjectMultiword ("target", "A set of commands for operating on debugger targets.", "target []") { - LoadSubCommand (CommandObjectSP (new CommandObjectMultiwordImageSearchPaths (interpreter)), "image-search-paths", interpreter); + LoadSubCommand (interpreter, "image-search-paths", CommandObjectSP (new CommandObjectMultiwordImageSearchPaths (interpreter))); } CommandObjectMultiwordTarget::~CommandObjectMultiwordTarget () Modified: lldb/trunk/source/Commands/CommandObjectTarget.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectTarget.h?rev=106615&r1=106614&r2=106615&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectTarget.h (original) +++ lldb/trunk/source/Commands/CommandObjectTarget.h Tue Jun 22 20:19:29 2010 @@ -28,7 +28,7 @@ { public: - CommandObjectMultiwordTarget (CommandInterpreter *interpreter); + CommandObjectMultiwordTarget (CommandInterpreter &interpreter); virtual ~CommandObjectMultiwordTarget (); Modified: lldb/trunk/source/Commands/CommandObjectThread.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectThread.cpp?rev=106615&r1=106614&r2=106615&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectThread.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectThread.cpp Tue Jun 22 20:19:29 2010 @@ -39,7 +39,7 @@ bool lldb_private::DisplayThreadInfo ( - CommandInterpreter *interpreter, + CommandInterpreter &interpreter, Stream &strm, Thread *thread, bool only_threads_with_stop_reason, @@ -96,7 +96,7 @@ size_t lldb_private::DisplayThreadsInfo ( - CommandInterpreter *interpreter, + CommandInterpreter &interpreter, ExecutionContext *exe_ctx, CommandReturnObject &result, bool only_threads_with_stop_reason, @@ -145,7 +145,7 @@ lldb_private::DisplayFramesForExecutionContext ( Thread *thread, - CommandInterpreter *interpreter, + CommandInterpreter &interpreter, Stream& strm, bool ascending, uint32_t first_frame, @@ -226,7 +226,7 @@ ( Thread *thread, StackFrame *frame, - CommandInterpreter *interpreter, + CommandInterpreter &interpreter, Stream& strm, bool show_frame_info, bool show_source, @@ -248,7 +248,7 @@ if (show_source && sc.comp_unit && sc.line_entry.IsValid()) { - interpreter->GetSourceManager().DisplaySourceLinesWithLineNumbers ( + interpreter.GetDebugger().GetSourceManager().DisplaySourceLinesWithLineNumbers ( sc.line_entry.file, sc.line_entry.line, 3, @@ -285,18 +285,17 @@ } - bool + virtual bool Execute ( + CommandInterpreter &interpreter, Args& command, - CommandContext *context, - CommandInterpreter *interpreter, CommandReturnObject &result ) { if (command.GetArgumentCount() == 0) { - ExecutionContext exe_ctx(context->GetExecutionContext()); + ExecutionContext exe_ctx(interpreter.GetDebugger().GetExecutionContext()); if (exe_ctx.thread) { bool show_frame_info = true; @@ -441,13 +440,15 @@ } virtual bool - Execute (Args& command, - CommandContext *context, - CommandInterpreter *interpreter, - CommandReturnObject &result) + Execute + ( + CommandInterpreter &interpreter, + Args& command, + CommandReturnObject &result + ) { - Process *process = context->GetExecutionContext().process; - bool synchronous_execution = interpreter->GetSynchronous(); + Process *process = interpreter.GetDebugger().GetExecutionContext().process; + bool synchronous_execution = interpreter.GetSynchronous(); if (process == NULL) { @@ -647,21 +648,23 @@ } virtual bool - Execute (Args& command, - CommandContext *context, - CommandInterpreter *interpreter, - CommandReturnObject &result) + Execute + ( + CommandInterpreter &interpreter, + Args& command, + CommandReturnObject &result + ) { - bool synchronous_execution = interpreter->GetSynchronous (); + bool synchronous_execution = interpreter.GetSynchronous (); - if (!context->GetTarget()) + if (!interpreter.GetDebugger().GetCurrentTarget().get()) { result.AppendError ("invalid target, set executable file using 'file' command"); result.SetStatus (eReturnStatusFailed); return false; } - Process *process = context->GetExecutionContext().process; + Process *process = interpreter.GetDebugger().GetExecutionContext().process; if (process == NULL) { result.AppendError ("no process exists. Cannot continue"); @@ -897,21 +900,23 @@ } virtual bool - Execute (Args& command, - CommandContext *context, - CommandInterpreter *interpreter, - CommandReturnObject &result) + Execute + ( + CommandInterpreter &interpreter, + Args& command, + CommandReturnObject &result + ) { - bool synchronous_execution = interpreter->GetSynchronous (); + bool synchronous_execution = interpreter.GetSynchronous (); - if (!context->GetTarget()) + if (!interpreter.GetDebugger().GetCurrentTarget().get()) { result.AppendError ("invalid target, set executable file using 'file' command"); result.SetStatus (eReturnStatusFailed); return false; } - Process *process = context->GetExecutionContext().process; + Process *process = interpreter.GetDebugger().GetExecutionContext().process; if (process == NULL) { result.AppendError ("need a valid process to step"); @@ -1085,12 +1090,14 @@ } virtual bool - Execute (Args& command, - CommandContext *context, - CommandInterpreter *interpreter, - CommandReturnObject &result) + Execute + ( + CommandInterpreter &interpreter, + Args& command, + CommandReturnObject &result + ) { - Process *process = context->GetExecutionContext().process; + Process *process = interpreter.GetDebugger().GetExecutionContext().process; if (process == NULL) { result.AppendError ("no process"); @@ -1132,128 +1139,130 @@ // CommandObjectThreadList //------------------------------------------------------------------------- -CommandObjectThreadList::CommandObjectThreadList (): - CommandObject ("thread list", - "Shows a summary of all current threads in a process.", - "thread list", - eFlagProcessMustBeLaunched | eFlagProcessMustBePaused) +class CommandObjectThreadList : public CommandObject { -} +public: -CommandObjectThreadList::~CommandObjectThreadList() -{ -} -bool -CommandObjectThreadList::Execute -( - Args& command, - CommandContext *context, - CommandInterpreter *interpreter, - CommandReturnObject &result -) -{ - StreamString &strm = result.GetOutputStream(); - result.SetStatus (eReturnStatusSuccessFinishNoResult); - ExecutionContext exe_ctx(context->GetExecutionContext()); - if (exe_ctx.process) - { - const StateType state = exe_ctx.process->GetState(); - - if (StateIsStoppedState(state)) - { - if (state == eStateExited) - { - int exit_status = exe_ctx.process->GetExitStatus(); - const char *exit_description = exe_ctx.process->GetExitDescription(); - strm.Printf ("Process %d exited with status = %i (0x%8.8x) %s\n", - exe_ctx.process->GetID(), - exit_status, - exit_status, - exit_description ? exit_description : ""); - } - else + CommandObjectThreadList (): + CommandObject ("thread list", + "Shows a summary of all current threads in a process.", + "thread list", + eFlagProcessMustBeLaunched | eFlagProcessMustBePaused) + { + } + + ~CommandObjectThreadList() + { + } + + bool + Execute + ( + CommandInterpreter &interpreter, + Args& command, + CommandReturnObject &result + ) + { + StreamString &strm = result.GetOutputStream(); + result.SetStatus (eReturnStatusSuccessFinishNoResult); + ExecutionContext exe_ctx(interpreter.GetDebugger().GetExecutionContext()); + if (exe_ctx.process) + { + const StateType state = exe_ctx.process->GetState(); + + if (StateIsStoppedState(state)) { - strm.Printf ("Process %d state is %s\n", exe_ctx.process->GetID(), StateAsCString (state)); - if (exe_ctx.thread == NULL) - exe_ctx.thread = exe_ctx.process->GetThreadList().GetThreadAtIndex(0).get(); - if (exe_ctx.thread != NULL) + if (state == eStateExited) { - DisplayThreadsInfo (interpreter, &exe_ctx, result, false, false); + int exit_status = exe_ctx.process->GetExitStatus(); + const char *exit_description = exe_ctx.process->GetExitDescription(); + strm.Printf ("Process %d exited with status = %i (0x%8.8x) %s\n", + exe_ctx.process->GetID(), + exit_status, + exit_status, + exit_description ? exit_description : ""); } else { - result.AppendError ("no valid thread found in current process"); - result.SetStatus (eReturnStatusFailed); + strm.Printf ("Process %d state is %s\n", exe_ctx.process->GetID(), StateAsCString (state)); + if (exe_ctx.thread == NULL) + exe_ctx.thread = exe_ctx.process->GetThreadList().GetThreadAtIndex(0).get(); + if (exe_ctx.thread != NULL) + { + DisplayThreadsInfo (interpreter, &exe_ctx, result, false, false); + } + else + { + result.AppendError ("no valid thread found in current process"); + result.SetStatus (eReturnStatusFailed); + } } } + else + { + result.AppendError ("process is currently running"); + result.SetStatus (eReturnStatusFailed); + } } else { - result.AppendError ("process is currently running"); + result.AppendError ("no current location or status available"); result.SetStatus (eReturnStatusFailed); } + return result.Succeeded(); } - else - { - result.AppendError ("no current location or status available"); - result.SetStatus (eReturnStatusFailed); - } - return result.Succeeded(); -} +}; //------------------------------------------------------------------------- // CommandObjectMultiwordThread //------------------------------------------------------------------------- -CommandObjectMultiwordThread::CommandObjectMultiwordThread (CommandInterpreter *interpreter) : +CommandObjectMultiwordThread::CommandObjectMultiwordThread (CommandInterpreter &interpreter) : CommandObjectMultiword ("thread", "A set of commands for operating on one or more thread within a running process.", "thread []") { - LoadSubCommand (CommandObjectSP (new CommandObjectThreadBacktrace ()), "backtrace", interpreter); - LoadSubCommand (CommandObjectSP (new CommandObjectThreadContinue ()), "continue", interpreter); - LoadSubCommand (CommandObjectSP (new CommandObjectThreadList ()), "list", interpreter); - LoadSubCommand (CommandObjectSP (new CommandObjectThreadSelect ()), "select", interpreter); - LoadSubCommand (CommandObjectSP (new CommandObjectThreadUntil ()), "until", interpreter); - LoadSubCommand (CommandObjectSP (new CommandObjectThreadStepWithTypeAndScope ("thread step-in", - "Source level single step in in specified thread (current thread, if none specified).", - "thread step-in []", - eFlagProcessMustBeLaunched | eFlagProcessMustBePaused, - eStepTypeInto, - eStepScopeSource)), - "step-in", interpreter); - - LoadSubCommand (CommandObjectSP (new CommandObjectThreadStepWithTypeAndScope ("thread step-out", + LoadSubCommand (interpreter, "backtrace", CommandObjectSP (new CommandObjectThreadBacktrace ())); + LoadSubCommand (interpreter, "continue", CommandObjectSP (new CommandObjectThreadContinue ())); + LoadSubCommand (interpreter, "list", CommandObjectSP (new CommandObjectThreadList ())); + LoadSubCommand (interpreter, "select", CommandObjectSP (new CommandObjectThreadSelect ())); + LoadSubCommand (interpreter, "until", CommandObjectSP (new CommandObjectThreadUntil ())); + LoadSubCommand (interpreter, "step-in", CommandObjectSP (new CommandObjectThreadStepWithTypeAndScope ( + "thread step-in", + "Source level single step in in specified thread (current thread, if none specified).", + "thread step-in []", + eFlagProcessMustBeLaunched | eFlagProcessMustBePaused, + eStepTypeInto, + eStepScopeSource))); + + LoadSubCommand (interpreter, "step-out", CommandObjectSP (new CommandObjectThreadStepWithTypeAndScope ("thread step-out", "Source level single step out in specified thread (current thread, if none specified).", "thread step-out []", eFlagProcessMustBeLaunched | eFlagProcessMustBePaused, eStepTypeOut, - eStepScopeSource)), - "step-out", interpreter); + eStepScopeSource))); - LoadSubCommand (CommandObjectSP (new CommandObjectThreadStepWithTypeAndScope ("thread step-over", + LoadSubCommand (interpreter, "step-over", CommandObjectSP (new CommandObjectThreadStepWithTypeAndScope ("thread step-over", "Source level single step over in specified thread (current thread, if none specified).", "thread step-over []", eFlagProcessMustBeLaunched | eFlagProcessMustBePaused, eStepTypeOver, - eStepScopeSource)), - "step-over", interpreter); + eStepScopeSource))); - LoadSubCommand (CommandObjectSP (new CommandObjectThreadStepWithTypeAndScope ("thread step-inst", + LoadSubCommand (interpreter, "step-inst", CommandObjectSP (new CommandObjectThreadStepWithTypeAndScope ("thread step-inst", "Single step one instruction in specified thread (current thread, if none specified).", "thread step-inst []", eFlagProcessMustBeLaunched | eFlagProcessMustBePaused, eStepTypeTrace, - eStepScopeInstruction)), - "step-inst", interpreter); - LoadSubCommand (CommandObjectSP (new CommandObjectThreadStepWithTypeAndScope ("thread step-inst-over", + eStepScopeInstruction))); + + LoadSubCommand (interpreter, "step-inst-over", CommandObjectSP (new CommandObjectThreadStepWithTypeAndScope ("thread step-inst-over", "Single step one instruction in specified thread (current thread, if none specified), stepping over calls.", "thread step-inst-over []", eFlagProcessMustBeLaunched | eFlagProcessMustBePaused, eStepTypeTraceOver, - eStepScopeInstruction)), - "step-inst-over", interpreter); + eStepScopeInstruction))); } CommandObjectMultiwordThread::~CommandObjectMultiwordThread () Modified: lldb/trunk/source/Commands/CommandObjectThread.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectThread.h?rev=106615&r1=106614&r2=106615&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectThread.h (original) +++ lldb/trunk/source/Commands/CommandObjectThread.h Tue Jun 22 20:19:29 2010 @@ -18,27 +18,11 @@ namespace lldb_private { -class CommandObjectThreadList : public CommandObject -{ -public: - - CommandObjectThreadList (); - - ~CommandObjectThreadList (); - - virtual bool - Execute (Args& command, - CommandContext *context, - CommandInterpreter *interpreter, - CommandReturnObject &result); -}; - - class CommandObjectMultiwordThread : public CommandObjectMultiword { public: - CommandObjectMultiwordThread (CommandInterpreter *interpreter); + CommandObjectMultiwordThread (CommandInterpreter &interpreter); virtual ~CommandObjectMultiwordThread (); @@ -47,14 +31,14 @@ bool -DisplayThreadInfo (CommandInterpreter *interpreter, +DisplayThreadInfo (CommandInterpreter &interpreter, Stream &strm, Thread *thread, bool only_threads_with_stop_reason, bool show_source); size_t -DisplayThreadsInfo (CommandInterpreter *interpreter, +DisplayThreadsInfo (CommandInterpreter &interpreter, ExecutionContext *exe_ctx, CommandReturnObject &result, bool only_threads_with_stop_reason, @@ -62,7 +46,7 @@ size_t DisplayFramesForExecutionContext (Thread *thread, - CommandInterpreter *interpreter, + CommandInterpreter &interpreter, Stream& strm, bool ascending, uint32_t first_frame, @@ -75,7 +59,7 @@ bool DisplayFrameForExecutionContext (Thread *thread, StackFrame *frame, - CommandInterpreter *interpreter, + CommandInterpreter &interpreter, Stream& strm, bool show_frame_info, bool show_source, Removed: lldb/trunk/source/Commands/CommandObjectTranslate.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectTranslate.cpp?rev=106614&view=auto ============================================================================== --- lldb/trunk/source/Commands/CommandObjectTranslate.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectTranslate.cpp (removed) @@ -1,75 +0,0 @@ -//===-- CommandObjectTranslate.cpp ------------------------------*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -#include "CommandObjectTranslate.h" - -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes -#include "lldb/Interpreter/Args.h" -#include "lldb/Interpreter/Options.h" - -#include "lldb/Interpreter/CommandInterpreter.h" -#include "lldb/Interpreter/CommandReturnObject.h" - -using namespace lldb; -using namespace lldb_private; - -//------------------------------------------------------------------------- -// CommandObjectTranslate -//------------------------------------------------------------------------- - -CommandObjectTranslate::CommandObjectTranslate () : - CommandObject ("translate", - "Shows the actual function called for a given debugger command.", - "translate ") -{ -} - -CommandObjectTranslate::~CommandObjectTranslate() -{ -} - - -bool -CommandObjectTranslate::Execute -( - Args& command, - CommandContext *context, - CommandInterpreter *interpreter, - CommandReturnObject &result -) -{ - CommandObject *cmd_obj; - - if (command.GetArgumentCount() != 0) - { - cmd_obj = interpreter->GetCommandObject(command.GetArgumentAtIndex(0)); - if (cmd_obj) - { - result.SetStatus (eReturnStatusSuccessFinishNoResult); - result.AppendMessageWithFormat ("%s\n", cmd_obj->Translate()); - } - else - { - result.AppendErrorWithFormat - ("'%s' is not a known command.\nTry 'help' to see a current list of commands.\n", - command.GetArgumentAtIndex(0)); - result.SetStatus (eReturnStatusFailed); - } - } - else - { - result.AppendError ("must call translate with a valid command"); - result.SetStatus (eReturnStatusFailed); - } - - return result.Succeeded(); -} Removed: lldb/trunk/source/Commands/CommandObjectTranslate.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectTranslate.h?rev=106614&view=auto ============================================================================== --- lldb/trunk/source/Commands/CommandObjectTranslate.h (original) +++ lldb/trunk/source/Commands/CommandObjectTranslate.h (removed) @@ -1,44 +0,0 @@ -//===-- CommandObjectTranslate.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_CommandObjectTranslate_h_ -#define liblldb_CommandObjectTranslate_h_ - -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes -#include "lldb/Interpreter/CommandObject.h" - -namespace lldb_private { - -//------------------------------------------------------------------------- -// CommandObjectTranslate -//------------------------------------------------------------------------- - -class CommandObjectTranslate : public CommandObject -{ -public: - - CommandObjectTranslate (); - - virtual - ~CommandObjectTranslate (); - - virtual bool - Execute (Args& command, - CommandContext *context, - CommandInterpreter *interpreter, - CommandReturnObject &result); - -}; - -} // namespace lldb_private - -#endif // liblldb_CommandObjectTranslate_h_ Modified: lldb/trunk/source/Commands/CommandObjectUnalias.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectUnalias.cpp?rev=106615&r1=106614&r2=106615&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectUnalias.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectUnalias.cpp Tue Jun 22 20:19:29 2010 @@ -25,8 +25,8 @@ CommandObjectUnalias::CommandObjectUnalias () : CommandObject ("unalias", - "Allows the user to remove/delete a user-defined command abbreviation.", - "unalias ") + "Allows the user to remove/delete a user-defined command abbreviation.", + "unalias ") { } @@ -36,8 +36,12 @@ bool -CommandObjectUnalias::Execute (Args& args, CommandContext *context, CommandInterpreter *interpreter, - CommandReturnObject &result) +CommandObjectUnalias::Execute +( + CommandInterpreter &interpreter, + Args& args, + CommandReturnObject &result +) { CommandObject::CommandMap::iterator pos; CommandObject *cmd_obj; @@ -45,10 +49,10 @@ if (args.GetArgumentCount() != 0) { const char *command_name = args.GetArgumentAtIndex(0); - cmd_obj = interpreter->GetCommandObject(command_name); + cmd_obj = interpreter.GetCommandObject(command_name); if (cmd_obj) { - if (interpreter->CommandExists (command_name)) + if (interpreter.CommandExists (command_name)) { result.AppendErrorWithFormat ("'%s' is a permanent debugger command and cannot be removed.\n", command_name); @@ -57,9 +61,9 @@ else { - if (interpreter->RemoveAlias (command_name) == false) + if (interpreter.RemoveAlias (command_name) == false) { - if (interpreter->AliasExists (command_name)) + if (interpreter.AliasExists (command_name)) result.AppendErrorWithFormat ("Error occurred while attempting to unalias '%s'.\n", command_name); else result.AppendErrorWithFormat ("'%s' is not an existing alias.\n", command_name); Modified: lldb/trunk/source/Commands/CommandObjectUnalias.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectUnalias.h?rev=106615&r1=106614&r2=106615&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectUnalias.h (original) +++ lldb/trunk/source/Commands/CommandObjectUnalias.h Tue Jun 22 20:19:29 2010 @@ -32,9 +32,8 @@ ~CommandObjectUnalias (); virtual bool - Execute (Args& args, - CommandContext *context, - CommandInterpreter *interpreter, + Execute (CommandInterpreter &interpreter, + Args& args, CommandReturnObject &result); }; Modified: lldb/trunk/source/Commands/CommandObjectVariable.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectVariable.cpp?rev=106615&r1=106614&r2=106615&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectVariable.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectVariable.cpp Tue Jun 22 20:19:29 2010 @@ -465,12 +465,14 @@ } virtual bool - Execute (Args& command, - CommandContext *context, - CommandInterpreter *interpreter, - CommandReturnObject &result) + Execute + ( + CommandInterpreter &interpreter, + Args& command, + CommandReturnObject &result + ) { - ExecutionContext exe_ctx(context->GetExecutionContext()); + ExecutionContext exe_ctx(interpreter.GetDebugger().GetExecutionContext()); if (exe_ctx.frame == NULL) { result.AppendError ("invalid frame"); @@ -492,14 +494,13 @@ if (!m_options.globals.empty()) { uint32_t fail_count = 0; - Target *target = context->GetTarget(); - if (target) + if (exe_ctx.target) { const size_t num_globals = m_options.globals.size(); for (idx = 0; idx < num_globals; ++idx) { VariableList global_var_list; - const uint32_t num_matching_globals = target->GetImages().FindGlobalVariables (m_options.globals[idx], true, UINT32_MAX, global_var_list); + const uint32_t num_matching_globals = exe_ctx.target->GetImages().FindGlobalVariables (m_options.globals[idx], true, UINT32_MAX, global_var_list); if (num_matching_globals == 0) { @@ -781,12 +782,12 @@ //---------------------------------------------------------------------- // CommandObjectVariable constructor //---------------------------------------------------------------------- -CommandObjectVariable::CommandObjectVariable(CommandInterpreter *interpreter) : +CommandObjectVariable::CommandObjectVariable(CommandInterpreter &interpreter) : CommandObjectMultiword ("variable", - "Access program arguments, locals, static and global variables.", - "variable [list] ...") + "Access program arguments, locals, static and global variables.", + "variable [list] ...") { - LoadSubCommand (CommandObjectSP (new CommandObjectVariableList ()), "list", interpreter); + LoadSubCommand (interpreter, "list", CommandObjectSP (new CommandObjectVariableList ())); } //---------------------------------------------------------------------- Modified: lldb/trunk/source/Commands/CommandObjectVariable.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectVariable.h?rev=106615&r1=106614&r2=106615&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectVariable.h (original) +++ lldb/trunk/source/Commands/CommandObjectVariable.h Tue Jun 22 20:19:29 2010 @@ -26,7 +26,7 @@ { public: - CommandObjectVariable (CommandInterpreter *iterpreter); + CommandObjectVariable (CommandInterpreter &interpreter); virtual ~CommandObjectVariable (); Modified: lldb/trunk/source/Core/Debugger.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/Debugger.cpp?rev=106615&r1=106614&r2=106615&view=diff ============================================================================== --- lldb/trunk/source/Core/Debugger.cpp (original) +++ lldb/trunk/source/Core/Debugger.cpp Tue Jun 22 20:19:29 2010 @@ -13,7 +13,7 @@ #include "lldb/Core/InputReader.h" #include "lldb/Core/State.h" #include "lldb/Core/Timer.h" - +#include "lldb/Interpreter/CommandInterpreter.h" #include "lldb/Target/TargetList.h" #include "lldb/Target/Process.h" #include "lldb/Target/Thread.h" @@ -22,115 +22,137 @@ using namespace lldb; using namespace lldb_private; -int Debugger::g_shared_debugger_refcount = 0; -bool Debugger::g_in_terminate = false; - -Debugger::DebuggerSP & -Debugger::GetDebuggerSP () -{ - static DebuggerSP g_shared_debugger_sp; - return g_shared_debugger_sp; -} +static uint32_t g_shared_debugger_refcount = 0; void Debugger::Initialize () { - g_shared_debugger_refcount++; - if (GetDebuggerSP().get() == NULL) - { - GetDebuggerSP().reset (new Debugger()); + if (g_shared_debugger_refcount == 0) lldb_private::Initialize(); - GetDebuggerSP()->GetCommandInterpreter().Initialize(); - } + g_shared_debugger_refcount++; } void Debugger::Terminate () { - g_shared_debugger_refcount--; - if (g_shared_debugger_refcount == 0) + if (g_shared_debugger_refcount > 0) { - // Because Terminate is called also in the destructor, we need to make sure - // that none of the calls to GetSharedInstance leads to a call to Initialize, - // thus bumping the refcount back to 1 & causing Debugger::~Debugger to try to - // re-terminate. So we use g_in_terminate to indicate this condition. - // When we can require at least Initialize to be called, we won't have to do - // this since then the GetSharedInstance won't have to auto-call Initialize... - - g_in_terminate = true; - int num_targets = GetDebuggerSP()->GetTargetList().GetNumTargets(); - for (int i = 0; i < num_targets; i++) + g_shared_debugger_refcount--; + if (g_shared_debugger_refcount == 0) { - ProcessSP process_sp(GetDebuggerSP()->GetTargetList().GetTargetAtIndex (i)->GetProcessSP()); - if (process_sp) - process_sp->Destroy(); + lldb_private::WillTerminate(); + lldb_private::Terminate(); } - GetDebuggerSP()->DisconnectInput(); - lldb_private::WillTerminate(); - GetDebuggerSP().reset(); } } -Debugger & -Debugger::GetSharedInstance() +typedef std::vector DebuggerList; + +static Mutex & +GetDebuggerListMutex () +{ + static Mutex g_mutex(Mutex::eMutexTypeRecursive); + return g_mutex; +} + +static DebuggerList & +GetDebuggerList() +{ + // hide the static debugger list inside a singleton accessor to avoid + // global init contructors + static DebuggerList g_list; + return g_list; +} + + +DebuggerSP +Debugger::CreateInstance () +{ + DebuggerSP debugger_sp (new Debugger); + // Scope for locker + { + Mutex::Locker locker (GetDebuggerListMutex ()); + GetDebuggerList().push_back(debugger_sp); + } + return debugger_sp; +} + +lldb::DebuggerSP +Debugger::GetSP () { - // Don't worry about thread race conditions with the code below as - // lldb_private::Initialize(); does this in a thread safe way. I just - // want to avoid having to lock and unlock a mutex in - // lldb_private::Initialize(); every time we want to access the - // Debugger shared instance. + lldb::DebuggerSP debugger_sp; - // FIXME: We intend to require clients to call Initialize by hand (since they - // will also have to call Terminate by hand.) But for now it is not clear where - // we can reliably call these in JH. So the present version initializes on first use - // here, and terminates in the destructor. - if (g_shared_debugger_refcount == 0 && !g_in_terminate) - Initialize(); - - assert(GetDebuggerSP().get()!= NULL); - return *(GetDebuggerSP().get()); + Mutex::Locker locker (GetDebuggerListMutex ()); + DebuggerList &debugger_list = GetDebuggerList(); + DebuggerList::iterator pos, end = debugger_list.end(); + for (pos = debugger_list.begin(); pos != end; ++pos) + { + if ((*pos).get() == this) + { + debugger_sp = *pos; + break; + } + } + return debugger_sp; } + +TargetSP +Debugger::FindTargetWithProcessID (lldb::pid_t pid) +{ + lldb::TargetSP target_sp; + Mutex::Locker locker (GetDebuggerListMutex ()); + DebuggerList &debugger_list = GetDebuggerList(); + DebuggerList::iterator pos, end = debugger_list.end(); + for (pos = debugger_list.begin(); pos != end; ++pos) + { + target_sp = (*pos)->GetTargetList().FindTargetWithProcessID (pid); + if (target_sp) + break; + } + return target_sp; +} + + Debugger::Debugger () : m_input_comm("debugger.input"), m_input_file (), m_output_file (), m_error_file (), - m_async_execution (true), m_target_list (), m_listener ("lldb.Debugger"), m_source_manager (), - m_command_interpreter (eScriptLanguageDefault, false, &m_listener, m_source_manager), + m_command_interpreter_ap (new CommandInterpreter (*this, eScriptLanguageDefault, false)), + m_exe_ctx (), m_input_readers (), m_input_reader_data () { + m_command_interpreter_ap->Initialize (); } Debugger::~Debugger () { - // FIXME: - // Remove this once this version of lldb has made its way through a build. - Terminate(); + int num_targets = m_target_list.GetNumTargets(); + for (int i = 0; i < num_targets; i++) + { + ProcessSP process_sp (m_target_list.GetTargetAtIndex (i)->GetProcessSP()); + if (process_sp) + process_sp->Destroy(); + } + DisconnectInput(); } bool Debugger::GetAsyncExecution () { - return m_async_execution; + return !m_command_interpreter_ap->GetSynchronous(); } void Debugger::SetAsyncExecution (bool async_execution) { - static bool value_has_been_set = false; - - if (!value_has_been_set) - { - value_has_been_set = true; - m_async_execution = async_execution; - m_command_interpreter.SetSynchronous (!async_execution); - } + m_command_interpreter_ap->SetSynchronous (!async_execution); } void @@ -203,7 +225,8 @@ CommandInterpreter & Debugger::GetCommandInterpreter () { - return m_command_interpreter; + assert (m_command_interpreter_ap.get()); + return *m_command_interpreter_ap; } Listener & @@ -432,3 +455,39 @@ } } } + +void +Debugger::UpdateExecutionContext (ExecutionContext *override_context) +{ + m_exe_ctx.Clear(); + + if (override_context != NULL) + { + m_exe_ctx.target = override_context->target; + m_exe_ctx.process = override_context->process; + m_exe_ctx.thread = override_context->thread; + m_exe_ctx.frame = override_context->frame; + } + else + { + TargetSP target_sp (GetCurrentTarget()); + if (target_sp) + { + m_exe_ctx.target = target_sp.get(); + m_exe_ctx.process = target_sp->GetProcessSP().get(); + if (m_exe_ctx.process && m_exe_ctx.process->IsRunning() == false) + { + m_exe_ctx.thread = m_exe_ctx.process->GetThreadList().GetCurrentThread().get(); + if (m_exe_ctx.thread == NULL) + m_exe_ctx.thread = m_exe_ctx.process->GetThreadList().GetThreadAtIndex(0).get(); + if (m_exe_ctx.thread) + { + m_exe_ctx.frame = m_exe_ctx.thread->GetCurrentFrame().get(); + if (m_exe_ctx.frame == NULL) + m_exe_ctx.frame = m_exe_ctx.thread->GetStackFrameAtIndex (0).get(); + } + } + } + } +} + Modified: lldb/trunk/source/Core/Disassembler.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/Disassembler.cpp?rev=106615&r1=106614&r2=106615&view=diff ============================================================================== --- lldb/trunk/source/Core/Disassembler.cpp (original) +++ lldb/trunk/source/Core/Disassembler.cpp Tue Jun 22 20:19:29 2010 @@ -55,6 +55,7 @@ bool Disassembler::Disassemble ( + Debugger &debugger, const ArchSpec &arch, const ExecutionContext &exe_ctx, uint32_t mixed_context_lines, @@ -144,7 +145,7 @@ if (sc.comp_unit && sc.line_entry.IsValid()) { - Debugger::GetSharedInstance().GetSourceManager().DisplaySourceLinesWithLineNumbers ( + debugger.GetSourceManager().DisplaySourceLinesWithLineNumbers ( sc.line_entry.file, sc.line_entry.line, mixed_context_lines, Modified: lldb/trunk/source/Core/InputReader.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/InputReader.cpp?rev=106615&r1=106614&r2=106615&view=diff ============================================================================== --- lldb/trunk/source/Core/InputReader.cpp (original) +++ lldb/trunk/source/Core/InputReader.cpp Tue Jun 22 20:19:29 2010 @@ -15,7 +15,8 @@ using namespace lldb; using namespace lldb_private; -InputReader::InputReader () : +InputReader::InputReader (Debugger &debugger) : + m_debugger (debugger), m_callback (NULL), m_callback_baton (NULL), m_end_token (), @@ -126,7 +127,7 @@ break; } - if (m_callback (m_callback_baton, this, eInputReaderGotToken, p, 1) == 0) + if (m_callback (m_callback_baton, *this, eInputReaderGotToken, p, 1) == 0) break; ++p; if (IsDone()) @@ -175,7 +176,7 @@ { const size_t word_len = p - word_start; size_t bytes_handled = m_callback (m_callback_baton, - this, + *this, eInputReaderGotToken, word_start, word_len); @@ -212,7 +213,7 @@ { SetIsDone(true); m_callback (m_callback_baton, - this, + *this, eInputReaderGotToken, line_start, end_token - line_start); @@ -221,7 +222,7 @@ } size_t bytes_handled = m_callback (m_callback_baton, - this, + *this, eInputReaderGotToken, line_start, line_length); @@ -259,7 +260,7 @@ { size_t length = end_token - bytes; size_t bytes_handled = m_callback (m_callback_baton, - this, + *this, eInputReaderGotToken, bytes, length); @@ -287,19 +288,6 @@ return 0; } - -FILE * -InputReader::GetInputFileHandle () -{ - return Debugger::GetSharedInstance().GetInputFileHandle (); -} - -FILE * -InputReader::GetOutputFileHandle () -{ - return Debugger::GetSharedInstance().GetOutputFileHandle (); -} - const char * InputReader::GetPrompt () const { @@ -314,7 +302,7 @@ { if (!m_prompt.empty()) { - FILE *out_fh = GetOutputFileHandle(); + FILE *out_fh = m_debugger.GetOutputFileHandle(); if (out_fh) ::fprintf (out_fh, "%s", m_prompt.c_str()); } @@ -339,5 +327,5 @@ return; // We don't notify the tokens here, it is done in HandleRawBytes } if (m_callback) - m_callback (m_callback_baton, this, notification, NULL, 0); + m_callback (m_callback_baton, *this, notification, NULL, 0); } Modified: lldb/trunk/source/Core/Log.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/Log.cpp?rev=106615&r1=106614&r2=106615&view=diff ============================================================================== --- lldb/trunk/source/Core/Log.cpp (original) +++ lldb/trunk/source/Core/Log.cpp Tue Jun 22 20:19:29 2010 @@ -43,18 +43,8 @@ if (set) g_stream_sp = stream_sp; else - { - if (g_stream_sp) - stream_sp = g_stream_sp; - else - { - FILE *out_fh = Debugger::GetSharedInstance().GetOutputFileHandle(); - if (out_fh) - stream_sp.reset(new StreamFile(out_fh)); - else - stream_sp.reset(); - } - } + stream_sp = g_stream_sp; + return stream_sp.get(); } @@ -91,7 +81,7 @@ // Since we are in a shared library and we can't have global // constructors, we need to control access to this static variable // through an accessor function to get and set the value. - static StreamSP g_stream_sp(new StreamFile(Debugger::GetSharedInstance().GetErrorFileHandle())); + static StreamSP g_stream_sp; if (set) g_stream_sp = stream_sp; Removed: lldb/trunk/source/Interpreter/CommandContext.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Interpreter/CommandContext.cpp?rev=106614&view=auto ============================================================================== --- lldb/trunk/source/Interpreter/CommandContext.cpp (original) +++ lldb/trunk/source/Interpreter/CommandContext.cpp (removed) @@ -1,77 +0,0 @@ -//===-- CommandContext.cpp --------------------------------------*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -#include "lldb/Interpreter/CommandContext.h" - -#include "lldb/Core/Debugger.h" -#include "lldb/Core/StreamString.h" -#include "lldb/Interpreter/CommandObject.h" -#include "lldb/Interpreter/CommandReturnObject.h" -#include "lldb/Target/Process.h" -#include "lldb/Target/Target.h" -#include "lldb/Target/Thread.h" - -using namespace lldb; -using namespace lldb_private; - -CommandContext::CommandContext () : - m_exe_ctx () -{ -} - -CommandContext::~CommandContext () -{ -} - -Target * -CommandContext::GetTarget() -{ - return Debugger::GetSharedInstance().GetCurrentTarget().get(); -} - - -ExecutionContext & -CommandContext::GetExecutionContext() -{ - return m_exe_ctx; -} - -void -CommandContext::Update (ExecutionContext *override_context) -{ - m_exe_ctx.Clear(); - - if (override_context != NULL) - { - m_exe_ctx.target = override_context->target; - m_exe_ctx.process = override_context->process; - m_exe_ctx.thread = override_context->thread; - m_exe_ctx.frame = override_context->frame; - } - else - { - TargetSP target_sp (Debugger::GetSharedInstance().GetCurrentTarget()); - if (target_sp) - { - m_exe_ctx.process = target_sp->GetProcessSP().get(); - if (m_exe_ctx.process && m_exe_ctx.process->IsRunning() == false) - { - m_exe_ctx.thread = m_exe_ctx.process->GetThreadList().GetCurrentThread().get(); - if (m_exe_ctx.thread == NULL) - m_exe_ctx.thread = m_exe_ctx.process->GetThreadList().GetThreadAtIndex(0).get(); - if (m_exe_ctx.thread) - { - m_exe_ctx.frame = m_exe_ctx.thread->GetCurrentFrame().get(); - if (m_exe_ctx.frame == NULL) - m_exe_ctx.frame = m_exe_ctx.thread->GetStackFrameAtIndex (0).get(); - } - } - } - } -} Modified: lldb/trunk/source/Interpreter/CommandInterpreter.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Interpreter/CommandInterpreter.cpp?rev=106615&r1=106614&r2=106615&view=diff ============================================================================== --- lldb/trunk/source/Interpreter/CommandInterpreter.cpp (original) +++ lldb/trunk/source/Interpreter/CommandInterpreter.cpp Tue Jun 22 20:19:29 2010 @@ -12,7 +12,6 @@ #include #include -#include "../Commands/CommandObjectAdd.h" #include "../Commands/CommandObjectAlias.h" #include "../Commands/CommandObjectAppend.h" #include "../Commands/CommandObjectApropos.h" @@ -33,7 +32,6 @@ #include "../Commands/CommandObjectQuit.h" #include "lldb/Interpreter/CommandObjectRegexCommand.h" #include "../Commands/CommandObjectRegister.h" -#include "../Commands/CommandObjectRemove.h" #include "CommandObjectScript.h" #include "../Commands/CommandObjectSelect.h" #include "../Commands/CommandObjectSet.h" @@ -44,7 +42,6 @@ #include "../Commands/CommandObjectSyntax.h" #include "../Commands/CommandObjectTarget.h" #include "../Commands/CommandObjectThread.h" -#include "../Commands/CommandObjectTranslate.h" #include "../Commands/CommandObjectUnalias.h" #include "../Commands/CommandObjectVariable.h" @@ -64,16 +61,14 @@ CommandInterpreter::CommandInterpreter ( + Debugger &debugger, ScriptLanguage script_language, - bool synchronous_execution, - Listener *listener, - SourceManager& source_manager + bool synchronous_execution ) : Broadcaster ("CommandInterpreter"), + m_debugger (debugger), m_script_language (script_language), - m_synchronous_execution (synchronous_execution), - m_listener (listener), - m_source_manager (source_manager) + m_synchronous_execution (synchronous_execution) { } @@ -204,43 +199,38 @@ // the crossref object exists and is ready to take the cross reference. Put the cross referencing command // objects into the CommandDictionary now, so they are ready for use when the other commands get created. - m_command_dict["select"] = CommandObjectSP (new CommandObjectSelect ()); - m_command_dict["info"] = CommandObjectSP (new CommandObjectInfo ()); - m_command_dict["delete"] = CommandObjectSP (new CommandObjectDelete ()); + m_command_dict["select"] = CommandObjectSP (new CommandObjectSelect ()); + m_command_dict["info"] = CommandObjectSP (new CommandObjectInfo ()); + m_command_dict["delete"] = CommandObjectSP (new CommandObjectDelete ()); // Non-CommandObjectCrossref commands can now be created. - //m_command_dict["add"] = CommandObjectSP (new CommandObjectAdd ()); m_command_dict["alias"] = CommandObjectSP (new CommandObjectAlias ()); m_command_dict["append"] = CommandObjectSP (new CommandObjectAppend ()); m_command_dict["apropos"] = CommandObjectSP (new CommandObjectApropos ()); - //m_command_dict["args"] = CommandObjectSP (new CommandObjectArgs ()); - m_command_dict["breakpoint"]= CommandObjectSP (new CommandObjectMultiwordBreakpoint (this)); + m_command_dict["breakpoint"]= CommandObjectSP (new CommandObjectMultiwordBreakpoint (*this)); m_command_dict["call"] = CommandObjectSP (new CommandObjectCall ()); m_command_dict["disassemble"] = CommandObjectSP (new CommandObjectDisassemble ()); m_command_dict["expression"]= CommandObjectSP (new CommandObjectExpression ()); m_command_dict["file"] = CommandObjectSP (new CommandObjectFile ()); - m_command_dict["frame"] = CommandObjectSP (new CommandObjectMultiwordFrame (this)); + m_command_dict["frame"] = CommandObjectSP (new CommandObjectMultiwordFrame (*this)); m_command_dict["help"] = CommandObjectSP (new CommandObjectHelp ()); - m_command_dict["image"] = CommandObjectSP (new CommandObjectImage (this)); - m_command_dict["log"] = CommandObjectSP (new CommandObjectLog (this)); - m_command_dict["memory"] = CommandObjectSP (new CommandObjectMemory (this)); - m_command_dict["process"] = CommandObjectSP (new CommandObjectMultiwordProcess (this)); + m_command_dict["image"] = CommandObjectSP (new CommandObjectImage (*this)); + m_command_dict["log"] = CommandObjectSP (new CommandObjectLog (*this)); + m_command_dict["memory"] = CommandObjectSP (new CommandObjectMemory (*this)); + m_command_dict["process"] = CommandObjectSP (new CommandObjectMultiwordProcess (*this)); m_command_dict["quit"] = CommandObjectSP (new CommandObjectQuit ()); - m_command_dict["register"] = CommandObjectSP (new CommandObjectRegister (this)); - //m_command_dict["remove"] = CommandObjectSP (new CommandObjectRemove ()); + m_command_dict["register"] = CommandObjectSP (new CommandObjectRegister (*this)); m_command_dict["script"] = CommandObjectSP (new CommandObjectScript (m_script_language)); m_command_dict["set"] = CommandObjectSP (new CommandObjectSet ()); m_command_dict["settings"] = CommandObjectSP (new CommandObjectSettings ()); m_command_dict["show"] = CommandObjectSP (new CommandObjectShow ()); m_command_dict["source"] = CommandObjectSP (new CommandObjectSource ()); m_command_dict["source-file"] = CommandObjectSP (new CommandObjectSourceFile ()); - //m_command_dict["syntax"] = CommandObjectSP (new CommandObjectSyntax ()); - m_command_dict["target"] = CommandObjectSP (new CommandObjectMultiwordTarget (this)); - m_command_dict["thread"] = CommandObjectSP (new CommandObjectMultiwordThread (this)); - //m_command_dict["translate"] = CommandObjectSP (new CommandObjectTranslate ()); + m_command_dict["target"] = CommandObjectSP (new CommandObjectMultiwordTarget (*this)); + m_command_dict["thread"] = CommandObjectSP (new CommandObjectMultiwordThread (*this)); m_command_dict["unalias"] = CommandObjectSP (new CommandObjectUnalias ()); - m_command_dict["variable"] = CommandObjectSP (new CommandObjectVariable (this)); + m_command_dict["variable"] = CommandObjectSP (new CommandObjectVariable (*this)); std::auto_ptr break_regex_cmd_ap(new CommandObjectRegexCommand ("regexp-break", @@ -568,8 +558,13 @@ // parses the line and takes the appropriate actions. bool -CommandInterpreter::HandleCommand (const char *command_line, bool add_to_history, CommandReturnObject &result, - ExecutionContext *override_context) +CommandInterpreter::HandleCommand +( + const char *command_line, + bool add_to_history, + CommandReturnObject &result, + ExecutionContext *override_context +) { // FIXME: there should probably be a mutex to make sure only one thread can // run the interpreter at a time. @@ -580,7 +575,7 @@ // result.AppendMessageWithFormat ("Processing command: %s\n", command_line); // } - m_current_context.Update (override_context); + m_debugger.UpdateExecutionContext (override_context); if (command_line == NULL || command_line[0] == '\0') { @@ -639,7 +634,7 @@ stripped_command += strlen(command_cstr); while (isspace(*stripped_command)) ++stripped_command; - command_obj->ExecuteRawCommandString(stripped_command, Context(), this, result); + command_obj->ExecuteRawCommandString (*this, stripped_command, result); } } else @@ -649,7 +644,7 @@ // Remove the command from the args. command_args.Shift(); - command_obj->ExecuteWithOptions (command_args, Context(), this, result); + command_obj->ExecuteWithOptions (*this, command_args, result); } } else @@ -658,9 +653,12 @@ int num_matches; int cursor_index = command_args.GetArgumentCount() - 1; int cursor_char_position = strlen (command_args.GetArgumentAtIndex(command_args.GetArgumentCount() - 1)); - num_matches = HandleCompletionMatches (command_args, cursor_index, - cursor_char_position, - 0, -1, matches); + num_matches = HandleCompletionMatches (command_args, + cursor_index, + cursor_char_position, + 0, + -1, + matches); if (num_matches > 0) { @@ -740,8 +738,12 @@ { parsed_line.Shift(); cursor_index--; - num_command_matches = command_object->HandleCompletion (parsed_line, cursor_index, cursor_char_position, - match_start_point, max_return_elements, this, + num_command_matches = command_object->HandleCompletion (*this, + parsed_line, + cursor_index, + cursor_char_position, + match_start_point, + max_return_elements, matches); } } @@ -779,8 +781,12 @@ // Only max_return_elements == -1 is supported at present: assert (max_return_elements == -1); - num_command_matches = HandleCompletionMatches (parsed_line, cursor_index, cursor_char_position, match_start_point, - max_return_elements, matches); + num_command_matches = HandleCompletionMatches (parsed_line, + cursor_index, + cursor_char_position, + match_start_point, + max_return_elements, + matches); if (num_command_matches <= 0) return num_command_matches; @@ -817,12 +823,6 @@ return num_command_matches; } -CommandContext * -CommandInterpreter::Context () -{ - return &m_current_context; -} - const Args * CommandInterpreter::GetProgramArguments () { @@ -916,20 +916,6 @@ m_script_language = lang; } -Listener * -CommandInterpreter::GetListener () -{ - return m_listener; -} - -SourceManager & -CommandInterpreter::GetSourceManager () -{ - return m_source_manager; -} - - - OptionArgVectorSP CommandInterpreter::GetAliasOptions (const char *alias_name) { @@ -1132,16 +1118,15 @@ ScriptInterpreter * CommandInterpreter::GetScriptInterpreter () { - CommandObject::CommandMap::iterator pos; - - pos = m_command_dict.find ("script"); - if (pos != m_command_dict.end()) + CommandObject::CommandMap::iterator pos; + + pos = m_command_dict.find ("script"); + if (pos != m_command_dict.end()) { - CommandObject *script_cmd_obj = pos->second.get(); - return ((CommandObjectScript *) script_cmd_obj)->GetInterpreter (); + CommandObject *script_cmd_obj = pos->second.get(); + return ((CommandObjectScript *) script_cmd_obj)->GetInterpreter (*this); } - else - return NULL; + return NULL; } Modified: lldb/trunk/source/Interpreter/CommandObject.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Interpreter/CommandObject.cpp?rev=106615&r1=106614&r2=106615&view=diff ============================================================================== --- lldb/trunk/source/Interpreter/CommandObject.cpp (original) +++ lldb/trunk/source/Interpreter/CommandObject.cpp Tue Jun 22 20:19:29 2010 @@ -133,21 +133,20 @@ bool CommandObject::ExecuteCommandString ( + CommandInterpreter &interpreter, const char *command_line, - CommandContext *context, - CommandInterpreter *interpreter, CommandReturnObject &result ) { Args command_args(command_line); - return ExecuteWithOptions (command_args, context, interpreter, result); + return ExecuteWithOptions (interpreter, command_args, result); } bool CommandObject::ParseOptions ( + CommandInterpreter &interpreter, Args& args, - CommandInterpreter *interpreter, CommandReturnObject &result ) { @@ -189,9 +188,8 @@ bool CommandObject::ExecuteWithOptions ( + CommandInterpreter &interpreter, Args& args, - CommandContext *context, - CommandInterpreter *interpreter, CommandReturnObject &result ) { @@ -199,10 +197,10 @@ { const char *tmp_str = args.GetArgumentAtIndex (i); if (tmp_str[0] == '`') // back-quote - args.ReplaceArgumentAtIndex (i, interpreter->ProcessEmbeddedScriptCommands (tmp_str)); + args.ReplaceArgumentAtIndex (i, interpreter.ProcessEmbeddedScriptCommands (tmp_str)); } - Process *process = context->GetExecutionContext().process; + Process *process = interpreter.GetDebugger().GetExecutionContext().process; if (process == NULL) { if (GetFlags().IsSet(CommandObject::eFlagProcessMustBeLaunched | CommandObject::eFlagProcessMustBePaused)) @@ -248,11 +246,11 @@ } } - if (!ParseOptions (args, interpreter, result)) + if (!ParseOptions (interpreter, args, result)) return false; // Call the command-specific version of 'Execute', passing it the already processed arguments. - return Execute (args, context, interpreter, result); + return Execute (interpreter, args, result); } class CommandDictCommandPartialMatch @@ -300,12 +298,12 @@ int CommandObject::HandleCompletion ( + CommandInterpreter &interpreter, Args &input, int &cursor_index, int &cursor_char_position, int match_start_point, int max_return_elements, - CommandInterpreter *interpreter, StringList &matches ) { @@ -340,46 +338,30 @@ input.DeleteArgumentAtIndex(input.GetArgumentCount() - 1); bool handled_by_options; - handled_by_options = cur_options->HandleOptionCompletion(input, - opt_element_vector, - cursor_index, - cursor_char_position, - match_start_point, - max_return_elements, - interpreter, - matches); + handled_by_options = cur_options->HandleOptionCompletion (interpreter, + input, + opt_element_vector, + cursor_index, + cursor_char_position, + match_start_point, + max_return_elements, + matches); if (handled_by_options) return matches.GetSize(); } // If we got here, the last word is not an option or an option argument. - return HandleArgumentCompletion(input, - cursor_index, - cursor_char_position, - opt_element_vector, - match_start_point, - max_return_elements, - interpreter, - matches); + return HandleArgumentCompletion (interpreter, + input, + cursor_index, + cursor_char_position, + opt_element_vector, + match_start_point, + max_return_elements, + matches); } } -int -CommandObject::HandleArgumentCompletion -( - Args &input, - int &cursor_index, - int &cursor_char_position, - OptionElementVector &opt_element_vector, - int match_start_point, - int max_return_elements, - CommandInterpreter *interpreter, - StringList &matches -) -{ - return 0; -} - // Case insensitive version of ::strstr() // Returns true if s2 is contained within s1. Modified: lldb/trunk/source/Interpreter/CommandObjectRegexCommand.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Interpreter/CommandObjectRegexCommand.cpp?rev=106615&r1=106614&r2=106615&view=diff ============================================================================== --- lldb/trunk/source/Interpreter/CommandObjectRegexCommand.cpp (original) +++ lldb/trunk/source/Interpreter/CommandObjectRegexCommand.cpp Tue Jun 22 20:19:29 2010 @@ -46,9 +46,8 @@ bool CommandObjectRegexCommand::Execute ( + CommandInterpreter &interpreter, Args& command, - CommandContext *context, - CommandInterpreter *interpreter, CommandReturnObject &result ) { @@ -59,9 +58,8 @@ bool CommandObjectRegexCommand::ExecuteRawCommandString ( + CommandInterpreter &interpreter, const char *command, - CommandContext *context, - CommandInterpreter *interpreter, CommandReturnObject &result ) { @@ -92,7 +90,7 @@ // Interpret the new command and return this as the result! // if (m_options.verbose) // result.GetOutputStream().Printf("%s\n", new_command.c_str()); - return interpreter->HandleCommand(new_command.c_str(), true, result); + return interpreter.HandleCommand(new_command.c_str(), true, result); } } result.SetStatus(eReturnStatusFailed); Modified: lldb/trunk/source/Interpreter/CommandObjectScript.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Interpreter/CommandObjectScript.cpp?rev=106615&r1=106614&r2=106615&view=diff ============================================================================== --- lldb/trunk/source/Interpreter/CommandObjectScript.cpp (original) +++ lldb/trunk/source/Interpreter/CommandObjectScript.cpp Tue Jun 22 20:19:29 2010 @@ -43,15 +43,12 @@ bool CommandObjectScript::ExecuteRawCommandString ( + CommandInterpreter &interpreter, const char *command, - CommandContext *context, - CommandInterpreter *interpreter, CommandReturnObject &result ) { - std::string arg_str (command); - - ScriptInterpreter *script_interpreter = GetInterpreter (); + ScriptInterpreter *script_interpreter = GetInterpreter (interpreter); if (script_interpreter == NULL) { @@ -59,23 +56,11 @@ result.SetStatus (eReturnStatusFailed); } - FILE *out_fh = Debugger::GetSharedInstance().GetOutputFileHandle(); - FILE *err_fh = Debugger::GetSharedInstance().GetOutputFileHandle(); - if (out_fh && err_fh) - { - if (arg_str.empty()) - script_interpreter->ExecuteInterpreterLoop (out_fh, err_fh); - else - script_interpreter->ExecuteOneLine (arg_str, out_fh, err_fh); - result.SetStatus (eReturnStatusSuccessFinishNoResult); - } + if (command == NULL || command[0] == '\0') + script_interpreter->ExecuteInterpreterLoop (interpreter); else - { - if (out_fh == NULL) - result.AppendError("invalid output file handle"); - else - result.AppendError("invalid error file handle"); - } + script_interpreter->ExecuteOneLine (interpreter, command); + result.SetStatus (eReturnStatusSuccessFinishNoResult); return result.Succeeded(); } @@ -88,60 +73,29 @@ bool CommandObjectScript::Execute ( + CommandInterpreter &interpreter, Args& command, - CommandContext *context, - CommandInterpreter *interpreter, CommandReturnObject &result ) { - std::string arg_str; - ScriptInterpreter *script_interpreter = GetInterpreter (); - - if (script_interpreter == NULL) - { - result.AppendError("no script interpeter"); - result.SetStatus (eReturnStatusFailed); - } - - const int argc = command.GetArgumentCount(); - for (int i = 0; i < argc; ++i) - arg_str.append(command.GetArgumentAtIndex(i)); - - - FILE *out_fh = Debugger::GetSharedInstance().GetOutputFileHandle(); - FILE *err_fh = Debugger::GetSharedInstance().GetOutputFileHandle(); - if (out_fh && err_fh) - { - if (arg_str.empty()) - script_interpreter->ExecuteInterpreterLoop (out_fh, err_fh); - else - script_interpreter->ExecuteOneLine (arg_str, out_fh, err_fh); - result.SetStatus (eReturnStatusSuccessFinishNoResult); - } - else - { - if (out_fh == NULL) - result.AppendError("invalid output file handle"); - else - result.AppendError("invalid error file handle"); - } - return result.Succeeded(); + // everything should be handled in ExecuteRawCommandString + return false; } ScriptInterpreter * -CommandObjectScript::GetInterpreter () +CommandObjectScript::GetInterpreter (CommandInterpreter &interpreter) { if (m_interpreter_ap.get() == NULL) { switch (m_script_lang) { case eScriptLanguagePython: - m_interpreter_ap.reset (new ScriptInterpreterPython ()); + m_interpreter_ap.reset (new ScriptInterpreterPython (interpreter)); break; case eScriptLanguageNone: - m_interpreter_ap.reset (new ScriptInterpreterNone ()); + m_interpreter_ap.reset (new ScriptInterpreterNone (interpreter)); break; } } Modified: lldb/trunk/source/Interpreter/CommandObjectScript.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Interpreter/CommandObjectScript.h?rev=106615&r1=106614&r2=106615&view=diff ============================================================================== --- lldb/trunk/source/Interpreter/CommandObjectScript.h (original) +++ lldb/trunk/source/Interpreter/CommandObjectScript.h Tue Jun 22 20:19:29 2010 @@ -34,19 +34,17 @@ bool WantsRawCommandString(); virtual bool - ExecuteRawCommandString (const char *command, - CommandContext *context, - CommandInterpreter *interpreter, - CommandReturnObject &result); + ExecuteRawCommandString (CommandInterpreter &interpreter, + const char *command, + CommandReturnObject &result); virtual bool - Execute (Args& command, - CommandContext *context, - CommandInterpreter *interpreter, + Execute (CommandInterpreter &interpreter, + Args& command, CommandReturnObject &result); ScriptInterpreter * - GetInterpreter (); + GetInterpreter (CommandInterpreter &interpreter); private: lldb::ScriptLanguage m_script_lang; Modified: lldb/trunk/source/Interpreter/Options.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Interpreter/Options.cpp?rev=106615&r1=106614&r2=106615&view=diff ============================================================================== --- lldb/trunk/source/Interpreter/Options.cpp (original) +++ lldb/trunk/source/Interpreter/Options.cpp Tue Jun 22 20:19:29 2010 @@ -532,13 +532,13 @@ bool Options::HandleOptionCompletion ( + CommandInterpreter &interpreter, Args &input, OptionElementVector &opt_element_vector, int cursor_index, int char_pos, int match_start_point, int max_return_elements, - lldb_private::CommandInterpreter *interpreter, lldb_private::StringList &matches ) { @@ -625,15 +625,15 @@ if (opt_defs_index != -1) { - HandleOptionArgumentCompletion (input, - cursor_index, - strlen (input.GetArgumentAtIndex(cursor_index)), - opt_element_vector, - i, - match_start_point, - max_return_elements, - interpreter, - matches); + HandleOptionArgumentCompletion (interpreter, + input, + cursor_index, + strlen (input.GetArgumentAtIndex(cursor_index)), + opt_element_vector, + i, + match_start_point, + max_return_elements, + matches); return true; } else @@ -655,6 +655,7 @@ bool Options::HandleOptionArgumentCompletion ( + CommandInterpreter &interpreter, Args &input, int cursor_index, int char_pos, @@ -662,7 +663,6 @@ int opt_element_index, int match_start_point, int max_return_elements, - lldb_private::CommandInterpreter *interpreter, lldb_private::StringList &matches ) { @@ -713,7 +713,7 @@ if (module_name) { FileSpec module_spec(module_name); - lldb::TargetSP target_sp = interpreter->Context()->GetTarget()->GetSP(); + lldb::TargetSP target_sp = interpreter.GetDebugger().GetCurrentTarget(); // Search filters require a target... if (target_sp != NULL) filter_ap.reset (new SearchFilterByModule (target_sp, module_spec)); @@ -723,12 +723,12 @@ } } - return CommandCompletions::InvokeCommonCompletionCallbacks (completion_mask, - input.GetArgumentAtIndex (opt_arg_pos), - match_start_point, - max_return_elements, - interpreter, - filter_ap.get(), - matches); - + return CommandCompletions::InvokeCommonCompletionCallbacks (interpreter, + completion_mask, + input.GetArgumentAtIndex (opt_arg_pos), + match_start_point, + max_return_elements, + filter_ap.get(), + matches); + } Modified: lldb/trunk/source/Interpreter/ScriptInterpreterNone.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Interpreter/ScriptInterpreterNone.cpp?rev=106615&r1=106614&r2=106615&view=diff ============================================================================== --- lldb/trunk/source/Interpreter/ScriptInterpreterNone.cpp (original) +++ lldb/trunk/source/Interpreter/ScriptInterpreterNone.cpp Tue Jun 22 20:19:29 2010 @@ -10,11 +10,13 @@ #include "lldb/Interpreter/ScriptInterpreterNone.h" #include "lldb/Core/Stream.h" #include "lldb/Core/StringList.h" +#include "lldb/Core/Debugger.h" +#include "lldb/Interpreter/CommandInterpreter.h" using namespace lldb; using namespace lldb_private; -ScriptInterpreterNone::ScriptInterpreterNone () : +ScriptInterpreterNone::ScriptInterpreterNone (CommandInterpreter &interpreter) : ScriptInterpreter (eScriptLanguageNone) { } @@ -24,15 +26,15 @@ } void -ScriptInterpreterNone::ExecuteOneLine (const std::string &line, FILE *out, FILE *err) +ScriptInterpreterNone::ExecuteOneLine (CommandInterpreter &interpreter, const char *command) { - ::fprintf (err, "error: there is no embedded script interpreter in this mode.\n"); + interpreter.GetDebugger().GetErrorStream().PutCString ("error: there is no embedded script interpreter in this mode.\n"); } void -ScriptInterpreterNone::ExecuteInterpreterLoop (FILE *out, FILE *err) +ScriptInterpreterNone::ExecuteInterpreterLoop (CommandInterpreter &interpreter) { - fprintf (err, "error: there is no embedded script interpreter in this mode.\n"); + interpreter.GetDebugger().GetErrorStream().PutCString ("error: there is no embedded script interpreter in this mode.\n"); } Modified: lldb/trunk/source/Interpreter/ScriptInterpreterPython.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Interpreter/ScriptInterpreterPython.cpp?rev=106615&r1=106614&r2=106615&view=diff ============================================================================== --- lldb/trunk/source/Interpreter/ScriptInterpreterPython.cpp (original) +++ lldb/trunk/source/Interpreter/ScriptInterpreterPython.cpp Tue Jun 22 20:19:29 2010 @@ -24,6 +24,7 @@ #include "lldb/Breakpoint/Breakpoint.h" #include "lldb/Breakpoint/BreakpointLocation.h" +#include "lldb/Breakpoint/StoppointCallbackContext.h" #include "lldb/Core/Debugger.h" #include "lldb/Core/FileSpec.h" #include "lldb/Core/InputReader.h" @@ -33,6 +34,7 @@ #include "lldb/Host/Host.h" #include "lldb/Interpreter/CommandInterpreter.h" #include "lldb/Interpreter/CommandReturnObject.h" +#include "lldb/Core/Debugger.h" #include "lldb/Target/Process.h" extern "C" void init_lldb (void); @@ -139,7 +141,7 @@ return fflush (stream) || prev_fail ? EOF : 0; } -ScriptInterpreterPython::ScriptInterpreterPython () : +ScriptInterpreterPython::ScriptInterpreterPython (CommandInterpreter &interpreter) : ScriptInterpreter (eScriptLanguagePython), m_compiled_module (NULL), m_termios_valid (false) @@ -194,7 +196,7 @@ } const char *pty_slave_name = GetScriptInterpreterPtyName (); - FILE *out_fh = Debugger::GetSharedInstance().GetOutputFileHandle(); + FILE *out_fh = interpreter.GetDebugger().GetOutputFileHandle(); PyObject *pmod = PyImport_ExecCodeModule( const_cast("embedded_interpreter"), @@ -249,14 +251,15 @@ } void -ScriptInterpreterPython::ExecuteOneLine (const std::string& line, FILE *out, FILE *err) +ScriptInterpreterPython::ExecuteOneLine (CommandInterpreter &interpreter, const char *command) { - int success; - - success = PyRun_SimpleString (line.c_str()); - if (success != 0) + if (command) { - fprintf (err, "error: python failed attempting to evaluate '%s'\n", line.c_str()); + int success; + + success = PyRun_SimpleString (command); + if (success != 0) + interpreter.GetDebugger().GetErrorStream().Printf ("error: python failed attempting to evaluate '%s'\n", command); } } @@ -266,7 +269,7 @@ ScriptInterpreterPython::InputReaderCallback ( void *baton, - InputReader *reader, + InputReader &reader, lldb::InputReaderAction notification, const char *bytes, size_t bytes_len @@ -275,19 +278,20 @@ if (baton == NULL) return 0; - ScriptInterpreterPython *interpreter = (ScriptInterpreterPython *) baton; + ScriptInterpreterPython *script_interpreter = (ScriptInterpreterPython *) baton; switch (notification) { case eInputReaderActivate: { // Save terminal settings if we can - interpreter->m_termios_valid = ::tcgetattr (::fileno (reader->GetInputFileHandle()), - &interpreter->m_termios) == 0; + FILE *input_fh = reader.GetDebugger().GetInputFileHandle(); + int input_fd = ::fileno (input_fh); + script_interpreter->m_termios_valid = ::tcgetattr (input_fd, &script_interpreter->m_termios) == 0; struct termios tmp_termios; - if (::tcgetattr (::fileno (reader->GetInputFileHandle()), &tmp_termios) == 0) + if (::tcgetattr (input_fd, &tmp_termios) == 0) { tmp_termios.c_cc[VEOF] = _POSIX_VDISABLE; - ::tcsetattr (::fileno (reader->GetInputFileHandle()), TCSANOW, &tmp_termios); + ::tcsetattr (input_fd, TCSANOW, &tmp_termios); } } break; @@ -302,11 +306,11 @@ if (bytes && bytes_len) { if ((int) bytes[0] == 4) - ::write (interpreter->GetMasterFileDescriptor(), "quit()", 6); + ::write (script_interpreter->GetMasterFileDescriptor(), "quit()", 6); else - ::write (interpreter->GetMasterFileDescriptor(), bytes, bytes_len); + ::write (script_interpreter->GetMasterFileDescriptor(), bytes, bytes_len); } - ::write (interpreter->GetMasterFileDescriptor(), "\n", 1); + ::write (script_interpreter->GetMasterFileDescriptor(), "\n", 1); break; case eInputReaderDone: @@ -315,11 +319,11 @@ // Write a newline out to the reader output //::fwrite ("\n", 1, 1, out_fh); // Restore terminal settings if they were validly saved - if (interpreter->m_termios_valid) + if (script_interpreter->m_termios_valid) { - ::tcsetattr (::fileno (reader->GetInputFileHandle()), + ::tcsetattr (::fileno (reader.GetDebugger().GetInputFileHandle()), TCSANOW, - &interpreter->m_termios); + &script_interpreter->m_termios); } break; } @@ -329,11 +333,12 @@ void -ScriptInterpreterPython::ExecuteInterpreterLoop (FILE *out, FILE *err) +ScriptInterpreterPython::ExecuteInterpreterLoop (CommandInterpreter &interpreter) { Timer scoped_timer (__PRETTY_FUNCTION__, __PRETTY_FUNCTION__); - InputReaderSP reader_sp (new InputReader()); + Debugger &debugger = interpreter.GetDebugger(); + InputReaderSP reader_sp (new InputReader(debugger)); if (reader_sp) { Error error (reader_sp->Initialize (ScriptInterpreterPython::InputReaderCallback, @@ -345,9 +350,9 @@ if (error.Success()) { - Debugger::GetSharedInstance().PushInputReader (reader_sp); - ExecuteOneLine ("run_python_interpreter(ConsoleDict)", out, err); - Debugger::GetSharedInstance().PopInputReader (reader_sp); + debugger.PushInputReader (reader_sp); + ExecuteOneLine (interpreter, "run_python_interpreter(ConsoleDict)"); + debugger.PopInputReader (reader_sp); } } } @@ -528,7 +533,7 @@ ScriptInterpreterPython::GenerateBreakpointOptionsCommandCallback ( void *baton, - InputReader *reader, + InputReader &reader, lldb::InputReaderAction notification, const char *bytes, size_t bytes_len @@ -536,7 +541,7 @@ { static StringList commands_in_progress; - FILE *out_fh = reader->GetOutputFileHandle(); + FILE *out_fh = reader.GetDebugger().GetOutputFileHandle(); switch (notification) { case eInputReaderActivate: @@ -545,8 +550,8 @@ if (out_fh) { ::fprintf (out_fh, "%s\n", g_reader_instructions); - if (reader->GetPrompt()) - ::fprintf (out_fh, "%s", reader->GetPrompt()); + if (reader.GetPrompt()) + ::fprintf (out_fh, "%s", reader.GetPrompt()); } } break; @@ -555,16 +560,16 @@ break; case eInputReaderReactivate: - if (reader->GetPrompt() && out_fh) - ::fprintf (out_fh, "%s", reader->GetPrompt()); + if (reader.GetPrompt() && out_fh) + ::fprintf (out_fh, "%s", reader.GetPrompt()); break; case eInputReaderGotToken: { std::string temp_string (bytes, bytes_len); commands_in_progress.AppendString (temp_string.c_str()); - if (out_fh && !reader->IsDone() && reader->GetPrompt()) - ::fprintf (out_fh, "%s", reader->GetPrompt()); + if (out_fh && !reader.IsDone() && reader.GetPrompt()) + ::fprintf (out_fh, "%s", reader.GetPrompt()); } break; @@ -575,7 +580,7 @@ data_ap->user_source.AppendList (commands_in_progress); if (data_ap.get()) { - ScriptInterpreter *interpreter = Debugger::GetSharedInstance().GetCommandInterpreter().GetScriptInterpreter(); + ScriptInterpreter *interpreter = reader.GetDebugger().GetCommandInterpreter().GetScriptInterpreter(); if (interpreter) { if (interpreter->GenerateBreakpointCommandCallbackData (data_ap->user_source, @@ -602,10 +607,12 @@ } void -ScriptInterpreterPython::CollectDataForBreakpointCommandCallback (BreakpointOptions *bp_options, +ScriptInterpreterPython::CollectDataForBreakpointCommandCallback (CommandInterpreter &interpreter, + BreakpointOptions *bp_options, CommandReturnObject &result) { - InputReaderSP reader_sp (new InputReader ()); + Debugger &debugger = interpreter.GetDebugger(); + InputReaderSP reader_sp (new InputReader (debugger)); if (reader_sp) { @@ -618,7 +625,7 @@ true); // echo input if (err.Success()) - Debugger::GetSharedInstance().PushInputReader (reader_sp); + debugger.PushInputReader (reader_sp); else { result.AppendError (err.AsCString()); @@ -819,11 +826,11 @@ if (python_string != NULL) { - bool success = - Debugger::GetSharedInstance().GetCommandInterpreter().GetScriptInterpreter()->ExecuteOneLineWithReturn - (python_string, - ScriptInterpreter::eBool, - (void *) &temp_bool); + bool success = context->exe_ctx.target->GetDebugger(). + GetCommandInterpreter(). + GetScriptInterpreter()->ExecuteOneLineWithReturn (python_string, + ScriptInterpreter::eBool, + (void *) &temp_bool); if (success) ret_value = temp_bool; } Modified: lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp?rev=106615&r1=106614&r2=106615&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp (original) +++ lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp Tue Jun 22 20:19:29 2010 @@ -1922,7 +1922,7 @@ // debugserver that we are tracking... lldb::pid_t gdb_remote_pid = (lldb::pid_t)(intptr_t)callback_baton; - TargetSP target_sp(Debugger::GetSharedInstance().GetTargetList().FindTargetWithProcessID (gdb_remote_pid)); + TargetSP target_sp(Debugger::FindTargetWithProcessID (gdb_remote_pid)); if (target_sp) { ProcessSP process_sp (target_sp->GetProcessSP()); Modified: lldb/trunk/source/Target/Process.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/Process.cpp?rev=106615&r1=106614&r2=106615&view=diff ============================================================================== --- lldb/trunk/source/Target/Process.cpp (original) +++ lldb/trunk/source/Target/Process.cpp Tue Jun 22 20:19:29 2010 @@ -347,7 +347,7 @@ { if (signo == 0 || exit_status) { - TargetSP target_sp(Debugger::GetSharedInstance().GetTargetList().FindTargetWithProcessID (pid)); + TargetSP target_sp(Debugger::FindTargetWithProcessID (pid)); if (target_sp) { ProcessSP process_sp (target_sp->GetProcessSP()); Modified: lldb/trunk/source/Target/StackFrame.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/StackFrame.cpp?rev=106615&r1=106614&r2=106615&view=diff ============================================================================== --- lldb/trunk/source/Target/StackFrame.cpp (original) +++ lldb/trunk/source/Target/StackFrame.cpp Tue Jun 22 20:19:29 2010 @@ -176,7 +176,9 @@ { ExecutionContext exe_ctx; Calculate(exe_ctx); - Disassembler::Disassemble (m_thread.GetProcess().GetTarget().GetArchitecture(), + Target &target = m_thread.GetProcess().GetTarget(); + Disassembler::Disassemble (target.GetDebugger(), + target.GetArchitecture(), exe_ctx, 0, m_disassembly); Modified: lldb/trunk/source/Target/Target.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/Target.cpp?rev=106615&r1=106614&r2=106615&view=diff ============================================================================== --- lldb/trunk/source/Target/Target.cpp (original) +++ lldb/trunk/source/Target/Target.cpp Tue Jun 22 20:19:29 2010 @@ -33,8 +33,9 @@ //---------------------------------------------------------------------- // Target constructor //---------------------------------------------------------------------- -Target::Target() : +Target::Target(Debugger &debugger) : Broadcaster("Target"), + m_debugger (debugger), m_images(), m_breakpoint_list (false), m_internal_breakpoint_list (true), @@ -111,7 +112,7 @@ lldb::TargetSP Target::GetSP() { - return Debugger::GetSharedInstance().GetTargetList().GetTargetSP(this); + return m_debugger.GetTargetList().GetTargetSP(this); } BreakpointList & Modified: lldb/trunk/source/Target/TargetList.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/TargetList.cpp?rev=106615&r1=106614&r2=106615&view=diff ============================================================================== --- lldb/trunk/source/Target/TargetList.cpp (original) +++ lldb/trunk/source/Target/TargetList.cpp Tue Jun 22 20:19:29 2010 @@ -46,6 +46,7 @@ Error TargetList::CreateTarget ( + Debugger &debugger, const FileSpec& file, const ArchSpec& arch, const UUID *uuid_ptr, @@ -74,7 +75,7 @@ NULL); if (exe_module_sp) { - target_sp.reset(new Target); + target_sp.reset(new Target(debugger)); target_sp->SetExecutableModule (exe_module_sp, get_dependent_files); if (target_sp.get()) Modified: lldb/trunk/tools/driver/Driver.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/driver/Driver.cpp?rev=106615&r1=106614&r2=106615&view=diff ============================================================================== --- lldb/trunk/tools/driver/Driver.cpp (original) +++ lldb/trunk/tools/driver/Driver.cpp Tue Jun 22 20:19:29 2010 @@ -79,6 +79,7 @@ Driver::Driver () : SBBroadcaster ("Driver"), + m_debugger (SBDebugger::Create()), m_editline_pty (), m_editline_slave_fh (NULL), m_editline_reader (), @@ -323,9 +324,93 @@ } +Driver::OptionData::OptionData () : + m_filename(), + m_script_lang (lldb::eScriptLanguageDefault), + m_source_command_files (), + m_debug_mode (false), + m_print_help (false), + m_print_version (false) + +{ +} + +Driver::OptionData::~OptionData () +{ +} + +void +Driver::OptionData::Clear () +{ + m_filename.clear (); + m_script_lang = lldb::eScriptLanguageDefault; + m_source_command_files.clear (); + m_debug_mode = false; + m_print_help = false; + m_print_version = false; +} + +void +Driver::ResetOptionValues () +{ + m_option_data.Clear (); +} + +const char * +Driver::GetFilename() const +{ + if (m_option_data.m_filename.empty()) + return NULL; + return m_option_data.m_filename.c_str(); +} + +const char * +Driver::GetCrashLogFilename() const +{ + if (m_option_data.m_crash_log.empty()) + return NULL; + return m_option_data.m_crash_log.c_str(); +} + +lldb::ScriptLanguage +Driver::GetScriptLanguage() const +{ + return m_option_data.m_script_lang; +} + +size_t +Driver::GetNumSourceCommandFiles () const +{ + return m_option_data.m_source_command_files.size(); +} + +const char * +Driver::GetSourceCommandFileAtIndex (uint32_t idx) const +{ + if (idx < m_option_data.m_source_command_files.size()) + return m_option_data.m_source_command_files[idx].c_str(); + return NULL; +} + +bool +Driver::GetDebugMode() const +{ + return m_option_data.m_debug_mode; +} + + +// Check the arguments that were passed to this program to make sure they are valid and to get their +// argument values (if any). Return a boolean value indicating whether or not to start up the full +// debugger (i.e. the Command Interpreter) or not. Return FALSE if the arguments were invalid OR +// if the user only wanted help or version information. + SBError -ParseOptions (Driver::OptionData &data, int argc, const char **argv) +Driver::ParseArgs (int argc, const char *argv[], FILE *out_fh, bool &exit) { + ResetOptionValues (); + + SBCommandReturnObject result; + SBError error; std::string option_string; struct option *long_options = NULL; @@ -389,7 +474,7 @@ break; else if (val == '?') { - data.m_print_help = true; + m_option_data.m_print_help = true; error.SetErrorStringWithFormat ("unknown or ambiguous option"); break; } @@ -397,7 +482,7 @@ continue; else { - data.m_seen_options.insert ((char) val); + m_option_data.m_seen_options.insert ((char) val); if (long_options_index == -1) { for (int i = 0; @@ -414,180 +499,68 @@ if (long_options_index >= 0) { - error = Driver::SetOptionValue (long_options_index, - long_options[long_options_index].has_arg == no_argument ? NULL : optarg, - data); - } - else - { - error.SetErrorStringWithFormat ("invalid option with value %i", val); - } - if (error.Fail()) - break; - } - } - - return error; -} + const char short_option = (char) g_options[long_options_index].short_option; -Driver::OptionData::OptionData () : - m_filename(), - m_script_lang (lldb::eScriptLanguageDefault), - m_source_command_files (), - m_debug_mode (false), - m_print_help (false), - m_print_version (false) + switch (short_option) + { + case 'h': + m_option_data.m_print_help = true; + break; -{ -} + case 'v': + m_option_data.m_print_version = true; + break; -Driver::OptionData::~OptionData () -{ -} + case 'c': + m_option_data.m_crash_log = optarg; + break; -void -Driver::OptionData::Clear () -{ - m_filename.clear (); - m_script_lang = lldb::eScriptLanguageDefault; - m_source_command_files.clear (); - m_debug_mode = false; - m_print_help = false; - m_print_version = false; -} + case 'f': + { + SBFileSpec file(optarg); + if (file.Exists()) + m_option_data.m_filename = optarg; + else + error.SetErrorStringWithFormat("file specified in --file (-f) option doesn't exist: '%s'", optarg); + } + break; -SBError -Driver::SetOptionValue (int option_idx, const char *option_arg, Driver::OptionData &option_data) -{ - SBError error; - const char short_option = (char) g_options[option_idx].short_option; + case 'a': + if (!m_debugger.SetDefaultArchitecture (optarg)) + error.SetErrorStringWithFormat("invalid architecture in the -a or --arch option: '%s'", optarg); + break; - switch (short_option) - { - case 'h': - option_data.m_print_help = true; - break; + case 'l': + m_option_data.m_script_lang = m_debugger.GetScriptingLanguage (optarg); + break; - case 'v': - option_data.m_print_version = true; - break; + case 'd': + m_option_data.m_debug_mode = true; + break; - case 'c': - option_data.m_crash_log = option_arg; - break; + case 's': + { + SBFileSpec file(optarg); + if (file.Exists()) + m_option_data.m_source_command_files.push_back (optarg); + else + error.SetErrorStringWithFormat("file specified in --source (-s) option doesn't exist: '%s'", optarg); + } + break; - case 'f': - { - SBFileSpec file(option_arg); - if (file.Exists()) - option_data.m_filename = option_arg; - else - error.SetErrorStringWithFormat("file specified in --file (-f) option doesn't exist: '%s'", option_arg); + default: + m_option_data.m_print_help = true; + error.SetErrorStringWithFormat ("unrecognized option %c", short_option); + break; + } } - break; - - case 'a': - if (!SBDebugger::SetDefaultArchitecture (option_arg)) - error.SetErrorStringWithFormat("invalid architecture in the -a or --arch option: '%s'", option_arg); - break; - - case 'l': - option_data.m_script_lang = SBDebugger::GetScriptingLanguage (option_arg); - break; - - case 'd': - option_data.m_debug_mode = true; - break; - - case 's': + else { - SBFileSpec file(option_arg); - if (file.Exists()) - option_data.m_source_command_files.push_back (option_arg); - else - error.SetErrorStringWithFormat("file specified in --source (-s) option doesn't exist: '%s'", option_arg); + error.SetErrorStringWithFormat ("invalid option with value %i", val); } - break; - - default: - option_data.m_print_help = true; - error.SetErrorStringWithFormat ("unrecognized option %c", short_option); - break; - } - - return error; -} - -void -Driver::ResetOptionValues () -{ - m_option_data.Clear (); -} - -const char * -Driver::GetFilename() const -{ - if (m_option_data.m_filename.empty()) - return NULL; - return m_option_data.m_filename.c_str(); -} - -const char * -Driver::GetCrashLogFilename() const -{ - if (m_option_data.m_crash_log.empty()) - return NULL; - return m_option_data.m_crash_log.c_str(); -} - -lldb::ScriptLanguage -Driver::GetScriptLanguage() const -{ - return m_option_data.m_script_lang; -} - -size_t -Driver::GetNumSourceCommandFiles () const -{ - return m_option_data.m_source_command_files.size(); -} - -const char * -Driver::GetSourceCommandFileAtIndex (uint32_t idx) const -{ - if (idx < m_option_data.m_source_command_files.size()) - return m_option_data.m_source_command_files[idx].c_str(); - return NULL; -} - -bool -Driver::GetDebugMode() const -{ - return m_option_data.m_debug_mode; -} - - -// Check the arguments that were passed to this program to make sure they are valid and to get their -// argument values (if any). Return a boolean value indicating whether or not to start up the full -// debugger (i.e. the Command Interpreter) or not. Return FALSE if the arguments were invalid OR -// if the user only wanted help or version information. - -bool -Driver::ParseArgs (int argc, const char *argv[], FILE *out_fh, FILE *err_fh) -{ - bool valid = true; - - ResetOptionValues (); - - SBCommandReturnObject result; - - SBError error = ParseOptions (m_option_data, argc, argv); - if (error.Fail()) - { - const char *error_cstr = error.GetCString (); - if (error_cstr) - ::fprintf (err_fh, "error: %s\n", error_cstr); - valid = false; + if (error.Fail()) + return error; + } } // If there is a trailing argument, it is the filename. @@ -599,28 +572,24 @@ } else { - ::fprintf (err_fh, "error: don't provide a file both on in the -f option and as an argument."); - valid = false; + error.SetErrorStringWithFormat ("error: don't provide a file both on in the -f option and as an argument."); } } else if (optind < argc - 1) { // Trailing extra arguments... - ::fprintf (err_fh, "error: trailing extra arguments - only one the filename is allowed."); - valid = false; - + error.SetErrorStringWithFormat ("error: trailing extra arguments - only one the filename is allowed."); } - if (!valid || m_option_data.m_print_help) + if (error.Fail() || m_option_data.m_print_help) { ShowUsage (out_fh, g_options, m_option_data); - valid = false; } else if (m_option_data.m_print_version) { - ::fprintf (out_fh, "%s\n", SBDebugger::GetVersionString()); - valid = false; + ::fprintf (out_fh, "%s\n", m_debugger.GetVersionString()); + exit = true; } else if (! m_option_data.m_crash_log.empty()) { @@ -631,7 +600,7 @@ // All other combinations are valid; do nothing more here. } - return valid; + return error; } void @@ -640,7 +609,7 @@ // The process has stuff waiting for stdout; get it and write it out to the appropriate place. char stdio_buffer[1024]; size_t len; - while ((len = SBDebugger::GetCurrentTarget().GetProcess().GetSTDOUT (stdio_buffer, sizeof (stdio_buffer))) > 0) + while ((len = m_debugger.GetCurrentTarget().GetProcess().GetSTDOUT (stdio_buffer, sizeof (stdio_buffer))) > 0) m_io_channel_ap->OutWrite (stdio_buffer, len); } @@ -650,7 +619,7 @@ // The process has stuff waiting for stderr; get it and write it out to the appropriate place. char stdio_buffer[1024]; size_t len; - while ((len = SBDebugger::GetCurrentTarget().GetProcess().GetSTDERR (stdio_buffer, sizeof (stdio_buffer))) > 0) + while ((len = m_debugger.GetCurrentTarget().GetProcess().GetSTDERR (stdio_buffer, sizeof (stdio_buffer))) > 0) m_io_channel_ap->ErrWrite (stdio_buffer, len); } @@ -658,7 +627,7 @@ Driver::UpdateCurrentThread () { using namespace lldb; - SBProcess process(SBDebugger::GetCurrentTarget().GetProcess()); + SBProcess process(m_debugger.GetCurrentTarget().GetProcess()); if (process.IsValid()) { SBThread curr_thread (process.GetCurrentThread()); @@ -765,7 +734,7 @@ { char message[1024]; int message_len = ::snprintf (message, sizeof(message), "Process %d %s\n", process.GetProcessID(), - SBDebugger::StateAsCString (event_state)); + m_debugger.StateAsCString (event_state)); m_io_channel_ap->OutWrite(message, message_len); } break; @@ -775,7 +744,7 @@ break; case eStateExited: - SBDebugger::HandleCommand("process status"); + m_debugger.HandleCommand("process status"); m_io_channel_ap->RefreshPrompt(); break; @@ -794,7 +763,7 @@ else { UpdateCurrentThread (); - SBDebugger::HandleCommand("process status"); + m_debugger.HandleCommand("process status"); m_io_channel_ap->RefreshPrompt(); } break; @@ -820,7 +789,7 @@ if (command_string == NULL) command_string == ""; SBCommandReturnObject result; - if (SBDebugger::GetCommandInterpreter().HandleCommand (command_string, result, true) != lldb::eReturnStatusQuit) + if (m_debugger.GetCommandInterpreter().HandleCommand (command_string, result, true) != lldb::eReturnStatusQuit) { m_io_channel_ap->ErrWrite (result.GetError(), result.GetErrorSize()); m_io_channel_ap->OutWrite (result.GetOutput(), result.GetOutputSize()); @@ -971,7 +940,7 @@ // // if (crash_infos.size()) // { -// SBTarget target (SBDebugger::CreateTarget (crash_infos.front().path.c_str(), +// SBTarget target (m_debugger.CreateTarget (crash_infos.front().path.c_str(), // lldb::GetDefaultArchitecture().AsCString (), // false)); // if (target.IsValid()) @@ -995,7 +964,7 @@ { // Echo the characters back to the Debugger's stdout, that way if you // type characters while a command is running, you'll see what you've typed. - FILE *out_fh = SBDebugger::GetOutputFileHandle(); + FILE *out_fh = m_debugger.GetOutputFileHandle(); if (out_fh) ::fwrite (src, 1, src_len, out_fh); } @@ -1076,9 +1045,9 @@ ::setbuf (stdin, NULL); ::setbuf (stdout, NULL); - SBDebugger::SetErrorFileHandle (stderr, false); - SBDebugger::SetOutputFileHandle (stdout, false); - SBDebugger::SetInputFileHandle (stdin, true); + m_debugger.SetErrorFileHandle (stderr, false); + m_debugger.SetOutputFileHandle (stdout, false); + m_debugger.SetInputFileHandle (stdin, true); // You have to drain anything that comes to the master side of the PTY. master_out_comm is // for that purpose. The reason you need to do this is a curious reason... editline will echo @@ -1104,7 +1073,7 @@ // ParseCrashLog (crash_log); // } // - SBCommandInterpreter sb_interpreter = SBDebugger::GetCommandInterpreter(); + SBCommandInterpreter sb_interpreter = m_debugger.GetCommandInterpreter(); m_io_channel_ap.reset (new IOChannel(m_editline_slave_fh, stdout, stderr, this)); @@ -1115,13 +1084,14 @@ char buffer[25]; sprintf (buffer, "set term-width %d", window_size.ws_col); - SBDebugger::HandleCommand ((const char *) buffer); + m_debugger.HandleCommand ((const char *) buffer); } // Since input can be redirected by the debugger, we must insert our editline // input reader in the queue so we know when our reader should be active // and so we can receive bytes only when we are supposed to. - SBError err (m_editline_reader.Initialize (Driver::EditLineInputReaderCallback, // callback + SBError err (m_editline_reader.Initialize (m_debugger, + Driver::EditLineInputReaderCallback, // callback this, // baton eInputReaderGranularityByte, // token_size NULL, // end token - NULL means never done @@ -1135,9 +1105,9 @@ exit (6); } - SBDebugger::PushInputReader (m_editline_reader); + m_debugger.PushInputReader (m_editline_reader); - SBListener listener(SBDebugger::GetListener()); + SBListener listener(m_debugger.GetListener()); if (listener.IsValid()) { @@ -1161,8 +1131,8 @@ sb_interpreter.SourceInitFileInHomeDirectory(result); if (GetDebugMode()) { - result.PutError (SBDebugger::GetErrorFileHandle()); - result.PutOutput (SBDebugger::GetOutputFileHandle()); + result.PutError (m_debugger.GetErrorFileHandle()); + result.PutOutput (m_debugger.GetOutputFileHandle()); } // Now we handle options we got from the command line @@ -1174,11 +1144,11 @@ { const char *command_file = GetSourceCommandFileAtIndex(i); ::snprintf (command_string, sizeof(command_string), "source '%s'", command_file); - SBDebugger::GetCommandInterpreter().HandleCommand (command_string, result, false); + m_debugger.GetCommandInterpreter().HandleCommand (command_string, result, false); if (GetDebugMode()) { - result.PutError (SBDebugger::GetErrorFileHandle()); - result.PutOutput (SBDebugger::GetOutputFileHandle()); + result.PutError (m_debugger.GetErrorFileHandle()); + result.PutOutput (m_debugger.GetOutputFileHandle()); } } } @@ -1186,13 +1156,13 @@ if (!m_option_data.m_filename.empty()) { char arch_name[64]; - if (SBDebugger::GetDefaultArchitecture (arch_name, sizeof (arch_name))) + if (m_debugger.GetDefaultArchitecture (arch_name, sizeof (arch_name))) ::snprintf (command_string, sizeof (command_string), "file --arch=%s '%s'", arch_name, m_option_data.m_filename.c_str()); else ::snprintf (command_string, sizeof(command_string), "file '%s'", m_option_data.m_filename.c_str()); - SBDebugger::HandleCommand (command_string); + m_debugger.HandleCommand (command_string); } // Now that all option parsing is done, we try and parse the .lldbinit @@ -1200,8 +1170,8 @@ sb_interpreter.SourceInitFileInCurrentWorkingDirectory (result); if (GetDebugMode()) { - result.PutError(SBDebugger::GetErrorFileHandle()); - result.PutOutput(SBDebugger::GetOutputFileHandle()); + result.PutError(m_debugger.GetErrorFileHandle()); + result.PutOutput(m_debugger.GetOutputFileHandle()); } SBEvent event; @@ -1237,7 +1207,7 @@ else done = HandleIOEvent (event); } - else if (event.BroadcasterMatchesRef (SBDebugger::GetCurrentTarget().GetProcess().GetBroadcaster())) + else if (event.BroadcasterMatchesRef (m_debugger.GetCurrentTarget().GetProcess().GetBroadcaster())) { HandleProcessEvent (event); } @@ -1267,7 +1237,7 @@ } } - SBProcess process = SBDebugger::GetCurrentTarget().GetProcess(); + SBProcess process = m_debugger.GetCurrentTarget().GetProcess(); if (process.IsValid()) process.Destroy(); } @@ -1289,19 +1259,27 @@ int main (int argc, char const *argv[]) { - SBDebugger::Initialize(); SBHostOS::ThreadCreated ("[main]"); - // Do a little setup on the debugger before we get going - SBDebugger::SetAsync(true); - Driver driver; - - bool valid_args = driver.ParseArgs (argc, argv, stdout, stderr); - if (valid_args) + // Create a scope for driver so that the driver object will destroy itself + // before SBDebugger::Terminate() is called. { - driver.MainLoop (); + Driver driver; + + bool exit = false; + SBError error (driver.ParseArgs (argc, argv, stdout, exit)); + if (error.Fail()) + { + const char *error_cstr = error.GetCString (); + if (error_cstr) + ::fprintf (stderr, "error: %s\n", error_cstr); + } + else if (!exit) + { + driver.MainLoop (); + } } SBDebugger::Terminate(); Modified: lldb/trunk/tools/driver/Driver.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/driver/Driver.h?rev=106615&r1=106614&r2=106615&view=diff ============================================================================== --- lldb/trunk/tools/driver/Driver.h (original) +++ lldb/trunk/tools/driver/Driver.h Tue Jun 22 20:19:29 2010 @@ -19,6 +19,7 @@ #include "lldb/API/SBDefines.h" #include "lldb/API/SBBroadcaster.h" +#include "lldb/API/SBDebugger.h" #include "lldb/API/SBError.h" #include "lldb/API/SBInputReader.h" @@ -59,8 +60,8 @@ void HandleProcessEvent (const lldb::SBEvent &event); - bool - ParseArgs (int argc, const char *argv[], FILE *out_fh, FILE *err_fh); + lldb::SBError + ParseArgs (int argc, const char *argv[], FILE *out_fh, bool &do_exit); const char * GetFilename() const; @@ -113,7 +114,14 @@ Driver::OptionData &data); + lldb::SBDebugger & + GetDebugger() + { + return m_debugger; + } + private: + lldb::SBDebugger m_debugger; lldb_utility::PseudoTerminal m_editline_pty; FILE *m_editline_slave_fh; lldb::SBInputReader m_editline_reader; Modified: lldb/trunk/tools/driver/IOChannel.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/driver/IOChannel.cpp?rev=106615&r1=106614&r2=106615&view=diff ============================================================================== --- lldb/trunk/tools/driver/IOChannel.cpp (original) +++ lldb/trunk/tools/driver/IOChannel.cpp Tue Jun 22 20:19:29 2010 @@ -70,13 +70,12 @@ SBStringList completions; size_t page_size = 40; - int num_completions - = SBDebugger::GetCommandInterpreter().HandleCompletion (line_info->buffer, - line_info->cursor, - line_info->lastchar, - 0, - -1, - completions); + int num_completions = m_driver->GetDebugger().GetCommandInterpreter().HandleCompletion (line_info->buffer, + line_info->cursor, + line_info->lastchar, + 0, + -1, + completions); if (num_completions == -1) { @@ -269,7 +268,7 @@ SBListener listener("IOChannel::Run"); std::string new_line; - SBBroadcaster interpreter_broadcaster (SBDebugger::GetCommandInterpreter().GetBroadcaster()); + SBBroadcaster interpreter_broadcaster (m_driver->GetDebugger().GetCommandInterpreter().GetBroadcaster()); listener.StartListeningForEvents (interpreter_broadcaster, SBCommandInterpreter::eBroadcastBitResetPrompt | SBCommandInterpreter::eBroadcastBitThreadShouldExit | From scallanan at apple.com Wed Jun 23 13:58:10 2010 From: scallanan at apple.com (Sean Callanan) Date: Wed, 23 Jun 2010 18:58:10 -0000 Subject: [Lldb-commits] [lldb] r106665 - /lldb/trunk/source/Expression/ClangASTSource.cpp Message-ID: <20100623185811.076B92A6C12C@llvm.org> Author: spyffe Date: Wed Jun 23 13:58:10 2010 New Revision: 106665 URL: http://llvm.org/viewvc/llvm-project?rev=106665&view=rev Log: Fixes for array handling and dynamic type casting errors pointed out by John McCall. Modified: lldb/trunk/source/Expression/ClangASTSource.cpp Modified: lldb/trunk/source/Expression/ClangASTSource.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/ClangASTSource.cpp?rev=106665&r1=106664&r2=106665&view=diff ============================================================================== --- lldb/trunk/source/Expression/ClangASTSource.cpp (original) +++ lldb/trunk/source/Expression/ClangASTSource.cpp Wed Jun 23 13:58:10 2010 @@ -112,15 +112,14 @@ QualType QT = QualType::getFromOpaquePtr(type); clang::Type *T = QT.getTypePtr(); + const FunctionProtoType *FPT = T->getAs(); - if (T->isFunctionProtoType()) - { - FunctionProtoType *FPT = dyn_cast(T); - + if (FPT) + { unsigned NumArgs = FPT->getNumArgs(); unsigned ArgIndex; - ParmVarDecl *ParmVarDecls[NumArgs]; + ParmVarDecl **ParmVarDecls = new ParmVarDecl*[NumArgs]; for (ArgIndex = 0; ArgIndex < NumArgs; ++ArgIndex) { @@ -138,6 +137,8 @@ } Decl->setParams(ParmVarDecls, NumArgs); + + delete [] ParmVarDecls; } Decls.push_back(Decl); From scallanan at apple.com Wed Jun 23 16:28:25 2010 From: scallanan at apple.com (Sean Callanan) Date: Wed, 23 Jun 2010 21:28:25 -0000 Subject: [Lldb-commits] [lldb] r106682 - in /lldb/trunk: include/lldb/Core/Log.h source/Commands/CommandObjectLog.cpp source/Core/Log.cpp Message-ID: <20100623212825.669652A6C12C@llvm.org> Author: spyffe Date: Wed Jun 23 16:28:25 2010 New Revision: 106682 URL: http://llvm.org/viewvc/llvm-project?rev=106682&view=rev Log: Fixed the log streams for logs that output to standard output, resolving a crasher. Modified: lldb/trunk/include/lldb/Core/Log.h lldb/trunk/source/Commands/CommandObjectLog.cpp lldb/trunk/source/Core/Log.cpp Modified: lldb/trunk/include/lldb/Core/Log.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/Log.h?rev=106682&r1=106681&r2=106682&view=diff ============================================================================== --- lldb/trunk/include/lldb/Core/Log.h (original) +++ lldb/trunk/include/lldb/Core/Log.h Wed Jun 23 16:28:25 2010 @@ -101,30 +101,6 @@ ListAllLogChannels (Stream *strm); //------------------------------------------------------------------ - // Static accessors to STDOUT logging facilities. - //------------------------------------------------------------------ - static void - STDOUT (const char *format, ...); - - static lldb::StreamSP - GetStreamForSTDOUT (); - - static void - SetStreamForSTDOUT (lldb::StreamSP &stream_sp); - - //------------------------------------------------------------------ - // Static accessors to STDERR logging facilities. - //------------------------------------------------------------------ - static void - STDERR (const char *format, ...); - - static lldb::StreamSP - GetStreamForSTDERR (); - - static void - SetStreamForSTDERR (lldb::StreamSP &stream_sp); - - //------------------------------------------------------------------ // Member functions //------------------------------------------------------------------ Log (); Modified: lldb/trunk/source/Commands/CommandObjectLog.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectLog.cpp?rev=106682&r1=106681&r2=106682&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectLog.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectLog.cpp Wed Jun 23 16:28:25 2010 @@ -27,6 +27,7 @@ #include "lldb/Core/Timer.h" #include "lldb/Core/Debugger.h" +#include "lldb/Interpreter/CommandInterpreter.h" #include "lldb/Interpreter/CommandReturnObject.h" #include "lldb/Symbol/LineTable.h" @@ -94,16 +95,7 @@ if (m_options.log_file.empty()) { - std::string log_file(""); - LogStreamMap::iterator pos = m_log_streams.find(log_file); - if (pos == m_log_streams.end()) - { - log_stream_sp = Log::GetStreamForSTDOUT (); - if (log_stream_sp) - m_log_streams[log_file] = log_stream_sp; - } - else - log_stream_sp = pos->second; + log_stream_sp.reset(new StreamFile(interpreter.GetDebugger().GetOutputFileHandle())); } else { Modified: lldb/trunk/source/Core/Log.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/Log.cpp?rev=106682&r1=106681&r2=106682&view=diff ============================================================================== --- lldb/trunk/source/Core/Log.cpp (original) +++ lldb/trunk/source/Core/Log.cpp Wed Jun 23 16:28:25 2010 @@ -32,91 +32,6 @@ using namespace lldb; using namespace lldb_private; -static Stream * -StreamForSTDOUTAccess (bool set, StreamSP &stream_sp) -{ - // Since we are in a shared library and we can't have global - // constructors, we need to control access to this static variable - // through an accessor function to get and set the value. - static StreamSP g_stream_sp; - - if (set) - g_stream_sp = stream_sp; - else - stream_sp = g_stream_sp; - - return stream_sp.get(); -} - -StreamSP -Log::GetStreamForSTDOUT () -{ - StreamSP stream_sp; - StreamForSTDOUTAccess (false, stream_sp); - return stream_sp; -} - -void -Log::SetStreamForSTDOUT (StreamSP &stream_sp) -{ - StreamForSTDOUTAccess (true, stream_sp); -} - -void -Log::STDOUT (const char *format, ...) -{ - StreamSP stream_sp; - if (StreamForSTDOUTAccess(false, stream_sp)) - { - va_list args; - va_start (args, format); - stream_sp->PrintfVarArg(format, args); - va_end (args); - } -} - -static Stream * -StreamForSTDERRAccess (bool set, StreamSP &stream_sp) -{ - // Since we are in a shared library and we can't have global - // constructors, we need to control access to this static variable - // through an accessor function to get and set the value. - static StreamSP g_stream_sp; - - if (set) - g_stream_sp = stream_sp; - else - stream_sp = g_stream_sp; - return stream_sp.get(); -} - -StreamSP -Log::GetStreamForSTDERR () -{ - StreamSP stream_sp; - StreamForSTDERRAccess (false, stream_sp); - return stream_sp; -} - -void -Log::SetStreamForSTDERR (StreamSP &stream_sp) -{ - StreamForSTDERRAccess (true, stream_sp); -} - -void -Log::STDERR (const char *format, ...) -{ - StreamSP stream_sp; - if (StreamForSTDERRAccess(false, stream_sp)) - { - va_list args; - va_start (args, format); - stream_sp->PrintfVarArg(format, args); - va_end (args); - } -} - Log::Log () : m_stream_sp(), m_options(0), From scallanan at apple.com Wed Jun 23 18:18:05 2010 From: scallanan at apple.com (Sean Callanan) Date: Wed, 23 Jun 2010 23:18:05 -0000 Subject: [Lldb-commits] [lldb] r106695 - in /lldb/trunk: include/lldb/Expression/ClangExpression.h source/Commands/CommandObjectExpression.cpp source/Commands/CommandObjectExpression.h source/Expression/ClangExpression.cpp Message-ID: <20100623231805.342122A6C12C@llvm.org> Author: spyffe Date: Wed Jun 23 18:18:04 2010 New Revision: 106695 URL: http://llvm.org/viewvc/llvm-project?rev=106695&view=rev Log: Added the temporary -i option to expr, which switches the expression parsing over to use the LLVM IR as opposed to Clang ASTs. Right now, that functionality only logs. Modified: lldb/trunk/include/lldb/Expression/ClangExpression.h lldb/trunk/source/Commands/CommandObjectExpression.cpp lldb/trunk/source/Commands/CommandObjectExpression.h lldb/trunk/source/Expression/ClangExpression.cpp Modified: lldb/trunk/include/lldb/Expression/ClangExpression.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Expression/ClangExpression.h?rev=106695&r1=106694&r2=106695&view=diff ============================================================================== --- lldb/trunk/include/lldb/Expression/ClangExpression.h (original) +++ lldb/trunk/include/lldb/Expression/ClangExpression.h Wed Jun 23 18:18:04 2010 @@ -57,6 +57,10 @@ unsigned ConvertExpressionToDWARF (ClangExpressionVariableList &expr_local_variable_list, StreamString &dwarf_opcode_strm); + + unsigned + ConvertIRToDWARF (ClangExpressionVariableList &excpr_local_variable_list, + StreamString &dwarf_opcode_strm); bool JITFunction (const ExecutionContext &exc_context, const char *func_name); Modified: lldb/trunk/source/Commands/CommandObjectExpression.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectExpression.cpp?rev=106695&r1=106694&r2=106695&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectExpression.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectExpression.cpp Wed Jun 23 18:18:04 2010 @@ -69,6 +69,10 @@ case 'f': error = Args::StringToFormat(option_arg, format); break; + + case 'i': + use_ir = true; + break; default: error.SetErrorStringWithFormat("Invalid short option character '%c'.\n", short_option); @@ -87,6 +91,7 @@ format = eFormatDefault; show_types = true; show_summary = true; + use_ir = false; } const lldb::OptionDefinition* @@ -198,7 +203,6 @@ if (!target_triple) target_triple = Host::GetTargetTriple (); - if (target_triple) { const bool show_types = m_options.show_types; @@ -221,9 +225,19 @@ dwarf_opcodes.SetByteOrder(eByteOrderHost); dwarf_opcodes.GetFlags().Set(Stream::eBinary); ClangExpressionVariableList expr_local_vars; - clang_expr.ConvertExpressionToDWARF (expr_local_vars, dwarf_opcodes); - - success = true; + + bool success; + + if (m_options.use_ir) + success = (clang_expr.ConvertIRToDWARF (expr_local_vars, dwarf_opcodes) == 0); + else + success = (clang_expr.ConvertExpressionToDWARF (expr_local_vars, dwarf_opcodes) == 0); + + if (!success) + { + output_stream << "Expression couldn't be translated to DWARF\n"; + return false; + } DataExtractor dwarf_opcodes_data(dwarf_opcodes.GetData(), dwarf_opcodes.GetSize(), eByteOrderHost, 8); DWARFExpression expr(dwarf_opcodes_data, 0, dwarf_opcodes_data.GetByteSize(), NULL); @@ -431,7 +445,14 @@ dwarf_opcodes.SetByteOrder(eByteOrderHost); dwarf_opcodes.GetFlags().Set(Stream::eBinary); ClangExpressionVariableList expr_local_vars; - clang_expr.ConvertExpressionToDWARF (expr_local_vars, dwarf_opcodes); + + bool success = true; + + if (m_options.use_ir) + success = (clang_expr.ConvertIRToDWARF (expr_local_vars, dwarf_opcodes) == 0); + else + success = (clang_expr.ConvertExpressionToDWARF (expr_local_vars, dwarf_opcodes) == 0); + result.SetStatus (eReturnStatusSuccessFinishResult); @@ -439,6 +460,7 @@ DWARFExpression expr(dwarf_opcodes_data, 0, dwarf_opcodes_data.GetByteSize(), NULL); expr.SetExpressionLocalVariableList(&expr_local_vars); expr.SetExpressionDeclMap(&expr_decl_map); + if (debug) { output_stream << "Expression parsed ok, dwarf opcodes:"; @@ -541,9 +563,10 @@ lldb::OptionDefinition CommandObjectExpression::CommandOptions::g_option_table[] = { -{ LLDB_OPT_SET_1, true, "language", 'l', required_argument, NULL, 0, "[c|c++|objc|objc++]", "Sets the language to use when parsing the expression."}, -{ LLDB_OPT_SET_2, false, "format", 'f', required_argument, NULL, 0, "[ [bool|b] | [bin] | [char|c] | [oct|o] | [dec|i|d|u] | [hex|x] | [float|f] | [cstr|s] ]", "Specify the format that the expression output should use."}, -{ LLDB_OPT_SET_3, false, "debug", 'g', no_argument, NULL, 0, NULL, "Enable verbose debug logging of the expression parsing and evaluation."}, +{ LLDB_OPT_SET_ALL, true, "language", 'l', required_argument, NULL, 0, "[c|c++|objc|objc++]", "Sets the language to use when parsing the expression."}, +{ LLDB_OPT_SET_ALL, false, "format", 'f', required_argument, NULL, 0, "[ [bool|b] | [bin] | [char|c] | [oct|o] | [dec|i|d|u] | [hex|x] | [float|f] | [cstr|s] ]", "Specify the format that the expression output should use."}, +{ LLDB_OPT_SET_ALL, false, "debug", 'g', no_argument, NULL, 0, NULL, "Enable verbose debug logging of the expression parsing and evaluation."}, +{ LLDB_OPT_SET_ALL, false, "use-ir", 'i', no_argument, NULL, 0, NULL, "[Temporary] Instructs the expression evaluator to use IR instead of ASTs."}, { 0, false, NULL, 0, 0, NULL, NULL, NULL, NULL } }; Modified: lldb/trunk/source/Commands/CommandObjectExpression.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectExpression.h?rev=106695&r1=106694&r2=106695&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectExpression.h (original) +++ lldb/trunk/source/Commands/CommandObjectExpression.h Wed Jun 23 18:18:04 2010 @@ -52,6 +52,7 @@ bool debug; bool show_types; bool show_summary; + bool use_ir; }; CommandObjectExpression (); Modified: lldb/trunk/source/Expression/ClangExpression.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/ClangExpression.cpp?rev=106695&r1=106694&r2=106695&view=diff ============================================================================== --- lldb/trunk/source/Expression/ClangExpression.cpp (original) +++ lldb/trunk/source/Expression/ClangExpression.cpp Wed Jun 23 18:18:04 2010 @@ -50,6 +50,7 @@ #include "llvm/Target/TargetSelect.h" // Project includes +#include "lldb/Core/Log.h" #include "lldb/Expression/ClangExpression.h" #include "lldb/Expression/ClangASTSource.h" #include "lldb/Expression/ClangStmtVisitor.h" @@ -354,7 +355,7 @@ // - Call clang::ParseAST (in lib/Sema/ParseAST.cpp) to parse the buffer. The CodeGenerator will generate code for __dbg_expr. // - Once ParseAST completes, you can grab the llvm::Module from the CodeGenerator, which will have an llvm::Function you can hand off to the JIT. ParseAST(m_clang_ap->getPreprocessor(), m_code_generator_ptr, m_clang_ap->getASTContext()); - + text_diagnostic_buffer.EndSourceFile(); //compiler_instance->getASTContext().getTranslationUnitDecl()->dump(); @@ -454,6 +455,58 @@ return 0; } +unsigned +ClangExpression::ConvertIRToDWARF (ClangExpressionVariableList &excpr_local_variable_list, + StreamString &dwarf_opcode_strm) +{ + Log *log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS); + + llvm::Module *module = m_code_generator_ptr->GetModule(); + + if (!module) + { + if (log) + log->Printf("IR doesn't contain a module"); + + return 1; + } + + llvm::Module::iterator fi; + + for (fi = module->begin(); + fi != module->end(); + ++fi) + { + llvm::Function &function = *fi; + + if (log) + log->Printf("IR for %s:", function.getName().str().c_str()); + + llvm::Function::iterator bbi; + + for (bbi = function.begin(); + bbi != function.end(); + ++bbi) + { + llvm::BasicBlock &bb = *bbi; + + llvm::BasicBlock::iterator ii; + + for (ii = bb.begin(); + ii != bb.end(); + ++ii) + { + llvm::Instruction &inst = *ii; + + if (log) + log->Printf(" %s", inst.getOpcodeName()); + } + } + } + + return 0; +} + bool ClangExpression::JITFunction (const ExecutionContext &exc_context, const char *name) { From scallanan at apple.com Wed Jun 23 19:16:27 2010 From: scallanan at apple.com (Sean Callanan) Date: Thu, 24 Jun 2010 00:16:27 -0000 Subject: [Lldb-commits] [lldb] r106703 - /lldb/trunk/source/Commands/CommandObjectExpression.cpp Message-ID: <20100624001627.2BCCC2A6C12C@llvm.org> Author: spyffe Date: Wed Jun 23 19:16:27 2010 New Revision: 106703 URL: http://llvm.org/viewvc/llvm-project?rev=106703&view=rev Log: Extensive code cleanup of the expression command. - Rationalized EvaluateExpression to remove a lot of nesting; also added comments to make it easy to find what's happening where - Made ExecuteRawCommandString subcontract out to EvaluateExpression - Minor logging improvements Modified: lldb/trunk/source/Commands/CommandObjectExpression.cpp Modified: lldb/trunk/source/Commands/CommandObjectExpression.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectExpression.cpp?rev=106703&r1=106702&r2=106703&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectExpression.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectExpression.cpp Wed Jun 23 19:16:27 2010 @@ -194,146 +194,180 @@ bool CommandObjectExpression::EvaluateExpression (const char *expr, bool bare, Stream &output_stream, Stream &error_stream) { - bool success = false; - ConstString target_triple; + Log *log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS); + + //////////////////////////////////// + // Set up the target and compiler + // + Target *target = m_exe_ctx.target; - if (target) - target->GetTargetTriple(target_triple); + + if (!target) + { + error_stream.PutCString ("error: invalid target\n"); + return false; + } + + ConstString target_triple; + + target->GetTargetTriple (target_triple); if (!target_triple) target_triple = Host::GetTargetTriple (); + + if (!target_triple) + { + error_stream.PutCString ("error: invalid target triple\n"); + return false; + } + + ClangExpressionDeclMap expr_decl_map (&m_exe_ctx); + ClangExpression clang_expr (target_triple.AsCString (), &expr_decl_map); + + ////////////////////////// + // Parse the expression + // + + unsigned num_errors; + + if (bare) + num_errors = clang_expr.ParseBareExpression (llvm::StringRef (expr), error_stream); + else + num_errors = clang_expr.ParseExpression (expr, error_stream); - if (target_triple) + if (num_errors) { - const bool show_types = m_options.show_types; - const bool show_summary = m_options.show_summary; - const bool debug = m_options.debug; + error_stream.Printf ("error: %d errors parsing expression\n", num_errors); + return false; + } + + /////////////////////////////////////////////// + // Convert the output of the parser to DWARF + // + + StreamString dwarf_opcodes; + dwarf_opcodes.SetByteOrder (eByteOrderHost); + dwarf_opcodes.GetFlags ().Set (Stream::eBinary); + + ClangExpressionVariableList expr_local_vars; + + bool success; + + if (m_options.use_ir) + success = (clang_expr.ConvertIRToDWARF (expr_local_vars, dwarf_opcodes) == 0); + else + success = (clang_expr.ConvertExpressionToDWARF (expr_local_vars, dwarf_opcodes) == 0); + + if (!success) + { + error_stream.PutCString ("error: expression couldn't be translated to DWARF\n"); + return false; + } + + ////////////////////////////////////////// + // Evaluate the generated DWARF opcodes + // + + DataExtractor dwarf_opcodes_data (dwarf_opcodes.GetData (), dwarf_opcodes.GetSize (), eByteOrderHost, 8); + DWARFExpression dwarf_expr (dwarf_opcodes_data, 0, dwarf_opcodes_data.GetByteSize (), NULL); + + dwarf_expr.SetExpressionLocalVariableList(&expr_local_vars); + + if (log) + { + StreamString stream_string; - ClangExpressionDeclMap expr_decl_map(&m_exe_ctx); - ClangExpression clang_expr(target_triple.AsCString(), &expr_decl_map); + log->PutCString ("Expression parsed ok, dwarf opcodes:"); - unsigned num_errors = 0; + stream_string.PutCString ("\n"); + stream_string.IndentMore (); + dwarf_expr.GetDescription (&stream_string, lldb::eDescriptionLevelVerbose); + stream_string.IndentLess (); + stream_string.EOL (); - if (bare) - num_errors = clang_expr.ParseBareExpression (llvm::StringRef(expr), error_stream); - else - num_errors = clang_expr.ParseExpression (expr, error_stream); - - if (num_errors == 0) - { - StreamString dwarf_opcodes; - dwarf_opcodes.SetByteOrder(eByteOrderHost); - dwarf_opcodes.GetFlags().Set(Stream::eBinary); - ClangExpressionVariableList expr_local_vars; - - bool success; - - if (m_options.use_ir) - success = (clang_expr.ConvertIRToDWARF (expr_local_vars, dwarf_opcodes) == 0); - else - success = (clang_expr.ConvertExpressionToDWARF (expr_local_vars, dwarf_opcodes) == 0); - - if (!success) - { - output_stream << "Expression couldn't be translated to DWARF\n"; - return false; - } + log->PutCString (stream_string.GetString ().c_str ()); + } - DataExtractor dwarf_opcodes_data(dwarf_opcodes.GetData(), dwarf_opcodes.GetSize(), eByteOrderHost, 8); - DWARFExpression expr(dwarf_opcodes_data, 0, dwarf_opcodes_data.GetByteSize(), NULL); - expr.SetExpressionLocalVariableList(&expr_local_vars); - if (debug) - { - output_stream << "Expression parsed ok, dwarf opcodes:"; - output_stream.IndentMore(); - expr.GetDescription(&output_stream, lldb::eDescriptionLevelVerbose); - output_stream.IndentLess(); - output_stream.EOL(); - } + clang::ASTContext *ast_context = clang_expr.GetASTContext (); + Value expr_result; + Error expr_error; + success = dwarf_expr.Evaluate (&m_exe_ctx, ast_context, NULL, expr_result, &expr_error); + + if (!success) + { + error_stream.Printf ("error: couldn't evaluate DWARF expression: %s\n", expr_error.AsCString ()); + return false; + } + + /////////////////////////////////////// + // Interpret the result and print it + // + + lldb::Format format = m_options.format; + + // Resolve any values that are possible + expr_result.ResolveValue (&m_exe_ctx, ast_context); + + if (expr_result.GetContextType () == Value::eContextTypeInvalid && + expr_result.GetValueType () == Value::eValueTypeScalar && + format == eFormatDefault) + { + // The expression result is just a scalar with no special formatting + expr_result.GetScalar ().GetValue (&output_stream, m_options.show_types); + output_stream.EOL (); + return true; + } + + // The expression result is more complext and requires special handling + DataExtractor data; + expr_error = expr_result.GetValueAsData (&m_exe_ctx, ast_context, data, 0); + + if (!expr_error.Success ()) + { + error_stream.Printf ("error: couldn't resolve result value: %s\n", expr_error.AsCString ()); + return false; + } - clang::ASTContext *ast_context = clang_expr.GetASTContext(); - Value expr_result; - Error expr_error; - bool expr_success = expr.Evaluate (&m_exe_ctx, ast_context, NULL, expr_result, &expr_error); - if (expr_success) - { - lldb::Format format = m_options.format; + if (format == eFormatDefault) + format = expr_result.GetValueDefaultFormat (); - // Resolve any values that are possible - expr_result.ResolveValue(&m_exe_ctx, ast_context); + void *clang_type = expr_result.GetValueOpaqueClangQualType (); + + if (clang_type) + { + if (m_options.show_types) + Type::DumpClangTypeName (&output_stream, clang_type); - if (expr_result.GetContextType() == Value::eContextTypeInvalid && - expr_result.GetValueType() == Value::eValueTypeScalar && - format == eFormatDefault) - { - // The expression result is just a scalar with no special formatting - expr_result.GetScalar().GetValue (&output_stream, show_types); - output_stream.EOL(); - } - else - { - DataExtractor data; - expr_error = expr_result.GetValueAsData (&m_exe_ctx, ast_context, data, 0); - if (expr_error.Success()) - { - if (format == eFormatDefault) - format = expr_result.GetValueDefaultFormat (); - - void *clang_type = expr_result.GetValueOpaqueClangQualType(); - if (clang_type) - { - if (show_types) - Type::DumpClangTypeName(&output_stream, clang_type); - - Type::DumpValue ( - &m_exe_ctx, // The execution context for memory and variable access - ast_context, // The ASTContext that the clang type belongs to - clang_type, // The opaque clang type we want to dump that value of - &output_stream, // Stream to dump to - format, // Format to use when dumping - data, // A buffer containing the bytes for the clang type - 0, // Byte offset within "data" where value is - data.GetByteSize(), // Size in bytes of the value we are dumping - 0, // Bitfield bit size - 0, // Bitfield bit offset - show_types, // Show types? - show_summary, // Show summary? - debug, // Debug logging output? - UINT32_MAX); // Depth to dump in case this is an aggregate type - } - else - { - data.Dump(&output_stream, // Stream to dump to - 0, // Byte offset within "data" - format, // Format to use when dumping - data.GetByteSize(), // Size in bytes of each item we are dumping - 1, // Number of items to dump - UINT32_MAX, // Number of items per line - LLDB_INVALID_ADDRESS, // Invalid address, don't show any offset/address context - 0, // Bitfield bit size - 0); // Bitfield bit offset - } - output_stream.EOL(); - } - else - { - error_stream.Printf ("error: %s\n", expr_error.AsCString()); - success = false; - } - } - } - else - { - error_stream.Printf ("error: %s\n", expr_error.AsCString()); - } - } + Type::DumpValue (&m_exe_ctx, // The execution context for memory and variable access + ast_context, // The ASTContext that the clang type belongs to + clang_type, // The opaque clang type we want to dump that value of + &output_stream, // Stream to dump to + format, // Format to use when dumping + data, // A buffer containing the bytes for the clang type + 0, // Byte offset within "data" where value is + data.GetByteSize (), // Size in bytes of the value we are dumping + 0, // Bitfield bit size + 0, // Bitfield bit offset + m_options.show_types, // Show types? + m_options.show_summary, // Show summary? + m_options.debug, // Debug logging output? + UINT32_MAX); // Depth to dump in case this is an aggregate type } else { - error_stream.PutCString ("error: invalid target triple\n"); + data.Dump (&output_stream, // Stream to dump to + 0, // Byte offset within "data" + format, // Format to use when dumping + data.GetByteSize (), // Size in bytes of each item we are dumping + 1, // Number of items to dump + UINT32_MAX, // Number of items per line + LLDB_INVALID_ADDRESS, // Invalid address, don't show any offset/address context + 0, // Bitfield bit size + 0); // Bitfield bit offset } - - return success; + output_stream.EOL(); + + return true; } bool @@ -344,17 +378,7 @@ CommandReturnObject &result ) { - ConstString target_triple; - Target *target = interpreter.GetDebugger().GetCurrentTarget().get(); - if (target) - target->GetTargetTriple(target_triple); - - if (!target_triple) - target_triple = Host::GetTargetTriple (); - - ExecutionContext exe_ctx(interpreter.GetDebugger().GetExecutionContext()); - - Stream &output_stream = result.GetOutputStream(); + m_exe_ctx = interpreter.GetDebugger().GetExecutionContext(); m_options.ResetOptionValues(); @@ -423,141 +447,10 @@ } } - const bool show_types = m_options.show_types; - const bool show_summary = m_options.show_summary; - const bool debug = m_options.debug; - - if (expr == NULL) expr = command; - - if (target_triple) - { - ClangExpressionDeclMap expr_decl_map(&exe_ctx); - - ClangExpression clang_expr(target_triple.AsCString(), &expr_decl_map); - - unsigned num_errors = clang_expr.ParseExpression (expr, result.GetErrorStream()); - - if (num_errors == 0) - { - StreamString dwarf_opcodes; - dwarf_opcodes.SetByteOrder(eByteOrderHost); - dwarf_opcodes.GetFlags().Set(Stream::eBinary); - ClangExpressionVariableList expr_local_vars; - - bool success = true; - - if (m_options.use_ir) - success = (clang_expr.ConvertIRToDWARF (expr_local_vars, dwarf_opcodes) == 0); - else - success = (clang_expr.ConvertExpressionToDWARF (expr_local_vars, dwarf_opcodes) == 0); - - - result.SetStatus (eReturnStatusSuccessFinishResult); - - DataExtractor dwarf_opcodes_data(dwarf_opcodes.GetData(), dwarf_opcodes.GetSize(), eByteOrderHost, 8); - DWARFExpression expr(dwarf_opcodes_data, 0, dwarf_opcodes_data.GetByteSize(), NULL); - expr.SetExpressionLocalVariableList(&expr_local_vars); - expr.SetExpressionDeclMap(&expr_decl_map); - - if (debug) - { - output_stream << "Expression parsed ok, dwarf opcodes:"; - output_stream.IndentMore(); - expr.GetDescription(&output_stream, lldb::eDescriptionLevelVerbose); - output_stream.IndentLess(); - output_stream.EOL(); - } - - clang::ASTContext *ast_context = clang_expr.GetASTContext(); - Value expr_result; - Error expr_error; - bool expr_success = expr.Evaluate (&exe_ctx, ast_context, NULL, expr_result, &expr_error); - if (expr_success) - { - lldb::Format format = m_options.format; - - // Resolve any values that are possible - expr_result.ResolveValue(&exe_ctx, ast_context); - - if (expr_result.GetContextType() == Value::eContextTypeInvalid && - expr_result.GetValueType() == Value::eValueTypeScalar && - format == eFormatDefault) - { - // The expression result is just a scalar with no special formatting - expr_result.GetScalar().GetValue (&output_stream, show_types); - output_stream.EOL(); - } - else - { - DataExtractor data; - expr_error = expr_result.GetValueAsData (&exe_ctx, ast_context, data, 0); - if (expr_error.Success()) - { - if (format == eFormatDefault) - format = expr_result.GetValueDefaultFormat (); - - void *clang_type = expr_result.GetValueOpaqueClangQualType(); - if (clang_type) - { - if (show_types) - Type::DumpClangTypeName(&output_stream, clang_type); - - Type::DumpValue ( - &exe_ctx, // The execution context for memory and variable access - ast_context, // The ASTContext that the clang type belongs to - clang_type, // The opaque clang type we want to dump that value of - &output_stream, // Stream to dump to - format, // Format to use when dumping - data, // A buffer containing the bytes for the clang type - 0, // Byte offset within "data" where value is - data.GetByteSize(), // Size in bytes of the value we are dumping - 0, // Bitfield bit size - 0, // Bitfield bit offset - show_types, // Show types? - show_summary, // Show summary? - debug, // Debug logging output? - UINT32_MAX); // Depth to dump in case this is an aggregate type - } - else - { - data.Dump(&output_stream, // Stream to dump to - 0, // Byte offset within "data" - format, // Format to use when dumping - data.GetByteSize(), // Size in bytes of each item we are dumping - 1, // Number of items to dump - UINT32_MAX, // Number of items per line - LLDB_INVALID_ADDRESS, // Invalid address, don't show any offset/address context - 0, // Bitfield bit size - 0); // Bitfield bit offset - } - output_stream.EOL(); - } - else - { - result.AppendError(expr_error.AsCString()); - result.SetStatus (eReturnStatusFailed); - } - } - } - else - { - result.AppendError (expr_error.AsCString()); - result.SetStatus (eReturnStatusFailed); - } - } - else - { - result.SetStatus (eReturnStatusFailed); - } - } - else - { - result.AppendError ("invalid target triple"); - result.SetStatus (eReturnStatusFailed); - } - return result.Succeeded(); + + return EvaluateExpression (expr, false, result.GetOutputStream(), result.GetErrorStream()); } lldb::OptionDefinition From scallanan at apple.com Wed Jun 23 19:47:05 2010 From: scallanan at apple.com (Sean Callanan) Date: Thu, 24 Jun 2010 00:47:05 -0000 Subject: [Lldb-commits] [lldb] r106708 - /lldb/trunk/source/Expression/ClangExpression.cpp Message-ID: <20100624004705.C9CF72A6C12C@llvm.org> Author: spyffe Date: Wed Jun 23 19:47:05 2010 New Revision: 106708 URL: http://llvm.org/viewvc/llvm-project?rev=106708&view=rev Log: Improved printing of LLVM IR. We now print complete instructions rather than simply their opcodes. Modified: lldb/trunk/source/Expression/ClangExpression.cpp Modified: lldb/trunk/source/Expression/ClangExpression.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/ClangExpression.cpp?rev=106708&r1=106707&r2=106708&view=diff ============================================================================== --- lldb/trunk/source/Expression/ClangExpression.cpp (original) +++ lldb/trunk/source/Expression/ClangExpression.cpp Wed Jun 23 19:47:05 2010 @@ -498,11 +498,16 @@ { llvm::Instruction &inst = *ii; + std::string s; + llvm::raw_string_ostream os(s); + + inst.print(os); + if (log) - log->Printf(" %s", inst.getOpcodeName()); + log->Printf(" %s", s.c_str()); } } - } + } return 0; } From jingham at apple.com Thu Jun 24 15:28:42 2010 From: jingham at apple.com (Jim Ingham) Date: Thu, 24 Jun 2010 20:28:42 -0000 Subject: [Lldb-commits] [lldb] r106782 - /lldb/trunk/source/Interpreter/CommandInterpreter.cpp Message-ID: <20100624202842.C24532A6C12C@llvm.org> Author: jingham Date: Thu Jun 24 15:28:42 2010 New Revision: 106782 URL: http://llvm.org/viewvc/llvm-project?rev=106782&view=rev Log: Fix a bug in handling command resolution for non-exact matches. Now we will correctly give help options when there are both aliases & real commands matching the current input string. Modified: lldb/trunk/source/Interpreter/CommandInterpreter.cpp Modified: lldb/trunk/source/Interpreter/CommandInterpreter.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Interpreter/CommandInterpreter.cpp?rev=106782&r1=106781&r2=106782&view=diff ============================================================================== --- lldb/trunk/source/Interpreter/CommandInterpreter.cpp (original) +++ lldb/trunk/source/Interpreter/CommandInterpreter.cpp Thu Jun 24 15:28:42 2010 @@ -316,13 +316,13 @@ ret_val = pos->second; } - if (num_cmd_matches != 1 && include_aliases && HasAliases()) + if (include_aliases && HasAliases()) { num_alias_matches = CommandObject::AddNamesMatchingPartialString (m_alias_dict, cmd_cstr, *matches); } - if (num_alias_matches == 1) + if (num_alias_matches == 1 && num_cmd_matches == 0) { cmd.assign(matches->GetStringAtIndex (num_cmd_matches)); pos = m_alias_dict.find(cmd); @@ -335,12 +335,12 @@ } } - if (num_cmd_matches != 1 && num_alias_matches != 1 && HasUserCommands()) + if (HasUserCommands()) { num_user_matches = CommandObject::AddNamesMatchingPartialString (m_user_dict, cmd_cstr, *matches); } - if (num_user_matches == 1) + if (num_user_matches == 1 && num_alias_matches == 0 && num_cmd_matches == 0) { cmd.assign (matches->GetStringAtIndex (num_cmd_matches + num_alias_matches)); From jingham at apple.com Thu Jun 24 15:30:15 2010 From: jingham at apple.com (Jim Ingham) Date: Thu, 24 Jun 2010 20:30:15 -0000 Subject: [Lldb-commits] [lldb] r106783 - in /lldb/trunk: include/lldb/Interpreter/Options.h source/Interpreter/Options.cpp Message-ID: <20100624203015.D99E62A6C12C@llvm.org> Author: jingham Date: Thu Jun 24 15:30:15 2010 New Revision: 106783 URL: http://llvm.org/viewvc/llvm-project?rev=106783&view=rev Log: Convert direct access to the required & optional option sets to an accessor so we can lazily run BuildValidOptionSet, but make sure it is done before access. Modified: lldb/trunk/include/lldb/Interpreter/Options.h lldb/trunk/source/Interpreter/Options.cpp Modified: lldb/trunk/include/lldb/Interpreter/Options.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Interpreter/Options.h?rev=106783&r1=106782&r2=106783&view=diff ============================================================================== --- lldb/trunk/include/lldb/Interpreter/Options.h (original) +++ lldb/trunk/include/lldb/Interpreter/Options.h Thu Jun 24 15:30:15 2010 @@ -276,13 +276,24 @@ protected: // This is a set of options expressed as indexes into the options table for this Option. typedef std::set OptionSet; + typedef std::vector OptionSetVector; std::vector m_getopt_table; OptionSet m_seen_options; - std::vector m_required_options; - std::vector m_optional_options; - + OptionSetVector m_required_options; + OptionSetVector m_optional_options; + OptionSetVector &GetRequiredOptions () + { + BuildValidOptionSets(); + return m_required_options; + } + + OptionSetVector &GetOptionalOptions () + { + BuildValidOptionSets(); + return m_optional_options; + } bool IsASubset (const OptionSet& set_a, const OptionSet& set_b); Modified: lldb/trunk/source/Interpreter/Options.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Interpreter/Options.cpp?rev=106783&r1=106782&r2=106783&view=diff ============================================================================== --- lldb/trunk/source/Interpreter/Options.cpp (original) +++ lldb/trunk/source/Interpreter/Options.cpp Thu Jun 24 15:30:15 2010 @@ -121,7 +121,7 @@ { bool options_are_valid = false; - int num_levels = m_required_options.size(); + int num_levels = GetRequiredOptions().size(); if (num_levels) { for (int i = 0; i < num_levels && !options_are_valid; ++i) @@ -132,13 +132,13 @@ // m_seen_options are in the set of optional options at this level. // Check to see if all of m_required_options[i] are a subset of m_seen_options - if (IsASubset (m_required_options[i], m_seen_options)) + if (IsASubset (GetRequiredOptions()[i], m_seen_options)) { // Construct the set difference: remaining_options = {m_seen_options} - {m_required_options[i]} OptionSet remaining_options; - OptionsSetDiff (m_seen_options, m_required_options[i], remaining_options); + OptionsSetDiff (m_seen_options, GetRequiredOptions()[i], remaining_options); // Check to see if remaining_options is a subset of m_optional_options[i] - if (IsASubset (remaining_options, m_optional_options[i])) + if (IsASubset (remaining_options, GetOptionalOptions()[i])) options_are_valid = true; } } @@ -196,7 +196,7 @@ { for (int j = 0; j < LLDB_MAX_NUM_OPTION_SETS; j++) { - if (this_usage_mask & 1 << j) + if (this_usage_mask & (1 << j)) { if (num_option_sets <= j) num_option_sets = j + 1; @@ -383,8 +383,7 @@ if (num_options == 0) return; - BuildValidOptionSets (); - int num_option_sets = m_required_options.size(); + int num_option_sets = GetRequiredOptions().size(); uint32_t i; @@ -511,7 +510,7 @@ { bool options_are_valid = false; - int num_levels = m_required_options.size(); + int num_levels = GetRequiredOptions().size(); if (num_levels) { for (int i = 0; i < num_levels && !options_are_valid; ++i) @@ -520,7 +519,7 @@ // Therefore a set of options is correct if m_seen_options is a subset of the // union of m_required_options and m_optional_options. OptionSet union_set; - OptionsSetUnion (m_required_options[i], m_optional_options[i], union_set); + OptionsSetUnion (GetRequiredOptions()[i], GetOptionalOptions()[i], union_set); if (IsASubset (m_seen_options, union_set)) options_are_valid = true; } @@ -560,7 +559,33 @@ if (opt_pos == cursor_index) { // We're completing the option itself. - if (opt_defs_index != -1) + + if (opt_defs_index == OptionArgElement::eBareDash) + { + // We're completing a bare dash. That means all options are open. + // FIXME: We should scan the other options provided and only complete options + // within the option group they belong to. + char opt_str[3] = {'-', 'a', '\0'}; + + for (int i = 0 ; opt_defs[i].short_option != 0 ; i++) + { + opt_str[1] = opt_defs[i].short_option; + matches.AppendString (opt_str); + } + return true; + } + else if (opt_defs_index == OptionArgElement::eBareDoubleDash) + { + std::string full_name ("--"); + for (int i = 0 ; opt_defs[i].short_option != 0 ; i++) + { + full_name.erase(full_name.begin() + 2, full_name.end()); + full_name.append (opt_defs[i].long_option); + matches.AppendString (full_name.c_str()); + } + return true; + } + else if (opt_defs_index != OptionArgElement::eUnrecognizedArg) { // We recognized it, if it an incomplete long option, complete it anyway (getopt_long is // happy with shortest unique string, but it's still a nice thing to do.) Otherwise return From jingham at apple.com Thu Jun 24 15:31:04 2010 From: jingham at apple.com (Jim Ingham) Date: Thu, 24 Jun 2010 20:31:04 -0000 Subject: [Lldb-commits] [lldb] r106784 - in /lldb/trunk: include/lldb/Interpreter/Args.h source/Interpreter/Args.cpp source/Interpreter/CommandObject.cpp Message-ID: <20100624203104.996F72A6C12C@llvm.org> Author: jingham Date: Thu Jun 24 15:31:04 2010 New Revision: 106784 URL: http://llvm.org/viewvc/llvm-project?rev=106784&view=rev Log: Handle completing "-" and "--". Modified: lldb/trunk/include/lldb/Interpreter/Args.h lldb/trunk/source/Interpreter/Args.cpp lldb/trunk/source/Interpreter/CommandObject.cpp Modified: lldb/trunk/include/lldb/Interpreter/Args.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Interpreter/Args.h?rev=106784&r1=106783&r2=106784&view=diff ============================================================================== --- lldb/trunk/include/lldb/Interpreter/Args.h (original) +++ lldb/trunk/include/lldb/Interpreter/Args.h Thu Jun 24 15:31:04 2010 @@ -33,6 +33,12 @@ struct OptionArgElement { + enum { + eUnrecognizedArg = -1, + eBareDash = -2, + eBareDoubleDash = -3 + }; + OptionArgElement (int defs_index, int pos, int arg_pos) : opt_defs_index(defs_index), opt_pos (pos), @@ -303,7 +309,7 @@ ParseAliasOptions (Options &options, CommandReturnObject &result, OptionArgVector *option_arg_vector); void - ParseArgsForCompletion (Options &options, OptionElementVector &option_element_vector); + ParseArgsForCompletion (Options &options, OptionElementVector &option_element_vector, uint32_t cursor_index); //------------------------------------------------------------------ // Clear the arguments. Modified: lldb/trunk/source/Interpreter/Args.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Interpreter/Args.cpp?rev=106784&r1=106783&r2=106784&view=diff ============================================================================== --- lldb/trunk/source/Interpreter/Args.cpp (original) +++ lldb/trunk/source/Interpreter/Args.cpp Thu Jun 24 15:31:04 2010 @@ -945,7 +945,8 @@ Args::ParseArgsForCompletion ( Options &options, - OptionElementVector &option_element_vector + OptionElementVector &option_element_vector, + uint32_t cursor_index ) { StreamString sstr; @@ -993,26 +994,61 @@ int val; const OptionDefinition *opt_defs = options.GetDefinitions(); - // Fooey... getopt_long permutes the GetArgumentVector for no apparent reason. + // Fooey... getopt_long permutes the GetArgumentVector to move the options to the front. // So we have to build another Arg and pass that to getopt_long so it doesn't - // screw up the one we have. + // change the one we have. std::vector dummy_vec(GetArgumentVector(), GetArgumentVector() + GetArgumentCount() + 1); + bool failed_once = false; + uint32_t dash_dash_pos = -1; + while (1) { bool missing_argument = false; int parse_start = optind; int long_options_index = -1; + val = ::getopt_long (dummy_vec.size() - 1,(char *const *) dummy_vec.data(), sstr.GetData(), long_options, &long_options_index); if (val == -1) - break; + { + // When we're completing a "--" which is the last option on line, + if (failed_once) + break; + + failed_once = true; + + // If this is a bare "--" we mark it as such so we can complete it successfully later. + // Handling the "--" is a little tricky, since that may mean end of options or arguments, or the + // user might want to complete options by long name. I make this work by checking whether the + // cursor is in the "--" argument, and if so I assume we're completing the long option, otherwise + // I let it pass to getopt_long which will terminate the option parsing. + // Note, in either case we continue parsing the line so we can figure out what other options + // were passed. This will be useful when we come to restricting completions based on what other + // options we've seen on the line. + if (optind < dummy_vec.size() - 1 + && (strcmp (dummy_vec[optind-1], "--") == 0)) + { + dash_dash_pos = optind - 1; + if (optind - 1 == cursor_index) + { + option_element_vector.push_back (OptionArgElement (OptionArgElement::eBareDoubleDash, optind - 1, + OptionArgElement::eBareDoubleDash)); + continue; + } + else + break; + } + else + break; + } else if (val == '?') { - option_element_vector.push_back (OptionArgElement (-1, parse_start, -1)); + option_element_vector.push_back (OptionArgElement (OptionArgElement::eUnrecognizedArg, optind - 1, + OptionArgElement::eUnrecognizedArg)); continue; } else if (val == 0) @@ -1070,34 +1106,48 @@ if (missing_argument) arg_index = -1; else - arg_index = parse_start + 1; + arg_index = optind - 1; - option_element_vector.push_back (OptionArgElement (opt_defs_index, parse_start, arg_index)); + option_element_vector.push_back (OptionArgElement (opt_defs_index, optind - 2, arg_index)); } else { - option_element_vector.push_back (OptionArgElement (opt_defs_index, parse_start, -1)); + option_element_vector.push_back (OptionArgElement (opt_defs_index, optind - 1, -1)); } break; case optional_argument: if (optarg != NULL) { - option_element_vector.push_back (OptionArgElement (opt_defs_index, parse_start, 0)); + option_element_vector.push_back (OptionArgElement (opt_defs_index, optind - 2, optind - 1)); } else { - option_element_vector.push_back (OptionArgElement (opt_defs_index, parse_start, parse_start + 1)); + option_element_vector.push_back (OptionArgElement (opt_defs_index, optind - 2, optind - 1)); } break; default: // The options table is messed up. Here we'll just continue - option_element_vector.push_back (OptionArgElement (-1, parse_start, -1)); + option_element_vector.push_back (OptionArgElement (OptionArgElement::eUnrecognizedArg, optind - 1, + OptionArgElement::eUnrecognizedArg)); break; } } else { - option_element_vector.push_back (OptionArgElement (-1, parse_start, -1)); + option_element_vector.push_back (OptionArgElement (OptionArgElement::eUnrecognizedArg, optind - 1, + OptionArgElement::eUnrecognizedArg)); } } + + // Finally we have to handle the case where the cursor index points at a single "-". We want to mark that in + // the option_element_vector, but only if it is not after the "--". But it turns out that getopt_long just ignores + // an isolated "-". So we have to look it up by hand here. We only care if it is AT the cursor position. + + if ((dash_dash_pos == -1 || cursor_index < dash_dash_pos) + && strcmp (GetArgumentAtIndex(cursor_index), "-") == 0) + { + option_element_vector.push_back (OptionArgElement (OptionArgElement::eBareDash, cursor_index, + OptionArgElement::eBareDash)); + + } } Modified: lldb/trunk/source/Interpreter/CommandObject.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Interpreter/CommandObject.cpp?rev=106784&r1=106783&r2=106784&view=diff ============================================================================== --- lldb/trunk/source/Interpreter/CommandObject.cpp (original) +++ lldb/trunk/source/Interpreter/CommandObject.cpp Thu Jun 24 15:31:04 2010 @@ -333,7 +333,7 @@ input.AppendArgument (""); - input.ParseArgsForCompletion (*cur_options, opt_element_vector); + input.ParseArgsForCompletion (*cur_options, opt_element_vector, cursor_index); input.DeleteArgumentAtIndex(input.GetArgumentCount() - 1); From jingham at apple.com Thu Jun 24 19:34:36 2010 From: jingham at apple.com (Jim Ingham) Date: Fri, 25 Jun 2010 00:34:36 -0000 Subject: [Lldb-commits] [lldb] r106814 - /lldb/trunk/docs/code-signing.txt Message-ID: <20100625003436.23CE32A6C12C@llvm.org> Author: jingham Date: Thu Jun 24 19:34:35 2010 New Revision: 106814 URL: http://llvm.org/viewvc/llvm-project?rev=106814&view=rev Log: Remove a reference to Leopard. Modified: lldb/trunk/docs/code-signing.txt Modified: lldb/trunk/docs/code-signing.txt URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/docs/code-signing.txt?rev=106814&r1=106813&r2=106814&view=diff ============================================================================== --- lldb/trunk/docs/code-signing.txt (original) +++ lldb/trunk/docs/code-signing.txt Thu Jun 24 19:34:35 2010 @@ -31,8 +31,7 @@ - Enter your login password to confirm and make it trusted The next steps are necessary on SnowLeopard, but are probably because of a bug -how Keychain Access makes certificates (the steps above used to be enougn -in Leopard.) +how Keychain Access makes certificates. - Option-drag the new lldb_codesign certificate from the login keychain to the System keychain in the Keychains pane of the main Keychain Access window From johnny.chen at apple.com Fri Jun 25 16:14:08 2010 From: johnny.chen at apple.com (Johnny Chen) Date: Fri, 25 Jun 2010 21:14:08 -0000 Subject: [Lldb-commits] [lldb] r106890 - in /lldb/trunk/test: dotest.py example/ example/TestSequenceFunctions.py Message-ID: <20100625211408.4ECAE2A6C12C@llvm.org> Author: johnny Date: Fri Jun 25 16:14:08 2010 New Revision: 106890 URL: http://llvm.org/viewvc/llvm-project?rev=106890&view=rev Log: A simple testing framework for lldb using python's unit testing framework. Tests for lldb are written as python scripts which take advantage of the script bridging provided by LLDB.framework to interact with lldb core. A specific naming pattern is followed by the .py script to be recognized as a module which implements a test scenario, namely, Test*.py. To specify the directories where "Test*.py" python test scripts are located, you need to pass in a list of directory names. By default, the current working directory is searched if nothing is specified on the command line. An example: [14:10:20] johnny:/Volumes/data/lldb/svn/trunk/test $ ./dotest.py -v example test_choice (TestSequenceFunctions.TestSequenceFunctions) ... ok test_sample (TestSequenceFunctions.TestSequenceFunctions) ... ok test_shuffle (TestSequenceFunctions.TestSequenceFunctions) ... ok ---------------------------------------------------------------------- Ran 3 tests in 0.000s OK Added: lldb/trunk/test/dotest.py (with props) lldb/trunk/test/example/ lldb/trunk/test/example/TestSequenceFunctions.py Added: lldb/trunk/test/dotest.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/dotest.py?rev=106890&view=auto ============================================================================== --- lldb/trunk/test/dotest.py (added) +++ lldb/trunk/test/dotest.py Fri Jun 25 16:14:08 2010 @@ -0,0 +1,136 @@ +#!/usr/bin/env python + +""" +A simple testing framework for lldb using python's unit testing framework. + +Tests for lldb are written as python scripts which take advantage of the script +bridging provided by LLDB.framework to interact with lldb core. + +A specific naming pattern is followed by the .py script to be recognized as +a module which implements a test scenario, namely, Test*.py. + +To specify the directories where "Test*.py" python test scripts are located, +you need to pass in a list of directory names. By default, the current +working directory is searched if nothing is specified on the command line. +""" + +import os +import sys +import unittest + +# +# Global variables: +# + +# The test suite. +suite = unittest.TestSuite() + +# Default verbosity is 0. +verbose = 0 + +# By default, search from the current working directory. +testdirs = [ os.getcwd() ] + + +def usage(): + print """ +Usage: dotest.py [option] [args] +where options: +-h : print this help message and exit (also --help) +-v : do verbose mode of unittest framework + +and: +args : specify a list of directory names to search for python Test*.py scripts + if empty, search from the curret working directory, instead +""" + + +def setupSysPath(): + """Add LLDB.framework/Resources/Python to the search paths for modules.""" + + # Get the directory containing the current script. + testPath = sys.path[0] + if not testPath.endswith('test'): + print "This script expects to reside in lldb's test directory." + sys.exit(-1) + + base = os.path.abspath(os.path.join(testPath, os.pardir)) + dbgPath = os.path.join(base, 'build', 'Debug', 'LLDB.framework', + 'Resources', 'Python') + relPath = os.path.join(base, 'build', 'Release', 'LLDB.framework', + 'Resources', 'Python') + + lldbPath = None + if os.path.isfile(os.path.join(dbgPath, 'lldb.py')): + lldbPath = dbgPath + elif os.path.isfile(os.path.join(relPath, 'lldb.py')): + lldbPath = relPath + + if not lldbPath: + print 'This script requires lldb.py to be in either ' + dbgPath, + print ' or' + relPath + sys.exit(-1) + + sys.path.append(lldbPath) + #print 'sys.path =', sys.path + + +def initTestdirs(): + """Initialize the list of directories containing our unittest scripts. + + '-h/--help as the first option prints out usage info and exit the program. + """ + + global verbose + global testdirs + + if len(sys.argv) == 1: + pass + elif sys.argv[1].find('-h') != -1: + # Print usage info and exit. + usage() + sys.exit(0) + else: + # Process possible verbose flag. + index = 1 + if sys.argv[1].find('-v') != -1: + verbose = 2 + index += 1 + + # Gather all the dirs passed on the command line. + if len(sys.argv) > index: + testdirs = map(os.path.abspath, sys.argv[index:]) + + #print "testdirs =", testdirs + + +def visit(prefix, dir, names): + """Visitor function for os.path.walk(path, visit, arg).""" + + global suite + + for name in names: + if os.path.isdir(os.path.join(dir, name)): + continue + + if '.py' == os.path.splitext(name)[1] and name.startswith(prefix): + # We found a pattern match for our test case. Add it to the suite. + sys.path.append(dir) + base = os.path.splitext(name)[0] + suite.addTests(unittest.defaultTestLoader.loadTestsFromName(base)) + + +# +# Start the actions by first setting up the module search path for lldb, +# followed by initializing the test directories, and then walking the directory +# trees, while collecting the tests into our test suite. +# +setupSysPath() +initTestdirs() +for testdir in testdirs: + os.path.walk(testdir, visit, 'Test') + +# Now that we have loaded all the test cases, run the whole test suite. +#print "test suite =", suite +#print "verbose =", verbose +unittest.TextTestRunner(verbosity=verbose).run(suite) Propchange: lldb/trunk/test/dotest.py ------------------------------------------------------------------------------ svn:executable = * Added: lldb/trunk/test/example/TestSequenceFunctions.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/example/TestSequenceFunctions.py?rev=106890&view=auto ============================================================================== --- lldb/trunk/test/example/TestSequenceFunctions.py (added) +++ lldb/trunk/test/example/TestSequenceFunctions.py Fri Jun 25 16:14:08 2010 @@ -0,0 +1,34 @@ +"""An example unittest copied from python tutorial.""" + +import random +import unittest +import traceback + +class TestSequenceFunctions(unittest.TestCase): + + def setUp(self): + #traceback.print_stack() + self.seq = range(10) + + def tearDown(self): + #traceback.print_stack() + pass + + def test_shuffle(self): + # make sure the shuffled sequence does not lose any elements + random.shuffle(self.seq) + self.seq.sort() + self.assertEqual(self.seq, range(10)) + + def test_choice(self): + element = random.choice(self.seq) + self.assertTrue(element in self.seq) + + def test_sample(self): + self.assertRaises(ValueError, random.sample, self.seq, 20) + for element in random.sample(self.seq, 5): + self.assertTrue(element in self.seq) + + +if __name__ == '__main__': + unittest.main() From johnny.chen at apple.com Fri Jun 25 18:15:47 2010 From: johnny.chen at apple.com (Johnny Chen) Date: Fri, 25 Jun 2010 23:15:47 -0000 Subject: [Lldb-commits] [lldb] r106909 - in /lldb/trunk/test: help/ help/TestHelp.py tester.py Message-ID: <20100625231547.4E68F2A6C12C@llvm.org> Author: johnny Date: Fri Jun 25 18:15:47 2010 New Revision: 106909 URL: http://llvm.org/viewvc/llvm-project?rev=106909&view=rev Log: A simple test of 'help' command and its output. Added: lldb/trunk/test/help/ lldb/trunk/test/help/TestHelp.py Modified: lldb/trunk/test/tester.py Added: lldb/trunk/test/help/TestHelp.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/help/TestHelp.py?rev=106909&view=auto ============================================================================== --- lldb/trunk/test/help/TestHelp.py (added) +++ lldb/trunk/test/help/TestHelp.py Fri Jun 25 18:15:47 2010 @@ -0,0 +1,29 @@ +"""Test lldb help command.""" + +import lldb +import unittest + +class TestHelpCommand(unittest.TestCase): + + def setUp(self): + self.debugger = lldb.SBDebugger.Create() + self.debugger.SetAsync(True) + self.ci = self.debugger.GetCommandInterpreter() + if not self.ci: + raise Exception('Could not get the command interpreter') + + def tearDown(self): + pass + + def test_simplehelp(self): + """A simple test of 'help' command and its output.""" + res = lldb.SBCommandReturnObject() + self.ci.HandleCommand("help", res, False) + self.assertTrue(res.Succeeded()) + self.assertTrue(res.GetOutput().startswith( + 'The following is a list of built-in, permanent debugger commands')) + #print res.GetOutput() + + +if __name__ == '__main__': + unittest.main() Modified: lldb/trunk/test/tester.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/tester.py?rev=106909&r1=106908&r2=106909&view=diff ============================================================================== --- lldb/trunk/test/tester.py (original) +++ lldb/trunk/test/tester.py Fri Jun 25 18:15:47 2010 @@ -101,6 +101,7 @@ class SanityCheckTestCase(LLDBTestCase): def runTest(self): ret = self.runCommand("show arch", "show-arch") + print ret suite = unittest.TestLoader().loadTestsFromTestCase(SanityCheckTestCase) unittest.TextTestRunner(verbosity=2).run(suite) From johnny.chen at apple.com Fri Jun 25 18:22:48 2010 From: johnny.chen at apple.com (Johnny Chen) Date: Fri, 25 Jun 2010 23:22:48 -0000 Subject: [Lldb-commits] [lldb] r106910 - /lldb/trunk/test/tester.py Message-ID: <20100625232248.9C2B52A6C12C@llvm.org> Author: johnny Date: Fri Jun 25 18:22:48 2010 New Revision: 106910 URL: http://llvm.org/viewvc/llvm-project?rev=106910&view=rev Log: Use lldb.SBDebugger.Create() factory method to create an instance first. Modified: lldb/trunk/test/tester.py Modified: lldb/trunk/test/tester.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/tester.py?rev=106910&r1=106909&r2=106910&view=diff ============================================================================== --- lldb/trunk/test/tester.py (original) +++ lldb/trunk/test/tester.py Fri Jun 25 18:22:48 2010 @@ -82,8 +82,9 @@ class LLDBTestCase(unittest.TestCase): def setUp(self): - lldb.SBDebugger.SetAsync(True) - self.m_commandInterpreter = lldb.SBDebugger.GetCommandInterpreter() + debugger = lldb.SBDebugger.Create() + debugger.SetAsync(True) + self.m_commandInterpreter = debugger.GetCommandInterpreter() if not self.m_commandInterpreter: print "Couldn't get the command interpreter" sys.exit(-1) @@ -101,7 +102,7 @@ class SanityCheckTestCase(LLDBTestCase): def runTest(self): ret = self.runCommand("show arch", "show-arch") - print ret + #print ret suite = unittest.TestLoader().loadTestsFromTestCase(SanityCheckTestCase) unittest.TextTestRunner(verbosity=2).run(suite) From johnny.chen at apple.com Fri Jun 25 18:34:17 2010 From: johnny.chen at apple.com (Johnny Chen) Date: Fri, 25 Jun 2010 23:34:17 -0000 Subject: [Lldb-commits] [lldb] r106913 - /lldb/trunk/test/dotest.py Message-ID: <20100625233417.8E79B2A6C12C@llvm.org> Author: johnny Date: Fri Jun 25 18:34:17 2010 New Revision: 106913 URL: http://llvm.org/viewvc/llvm-project?rev=106913&view=rev Log: Removed debug print statements. Modified: lldb/trunk/test/dotest.py Modified: lldb/trunk/test/dotest.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/dotest.py?rev=106913&r1=106912&r2=106913&view=diff ============================================================================== --- lldb/trunk/test/dotest.py (original) +++ lldb/trunk/test/dotest.py Fri Jun 25 18:34:17 2010 @@ -72,7 +72,6 @@ sys.exit(-1) sys.path.append(lldbPath) - #print 'sys.path =', sys.path def initTestdirs(): @@ -101,8 +100,6 @@ if len(sys.argv) > index: testdirs = map(os.path.abspath, sys.argv[index:]) - #print "testdirs =", testdirs - def visit(prefix, dir, names): """Visitor function for os.path.walk(path, visit, arg).""" @@ -131,6 +128,4 @@ os.path.walk(testdir, visit, 'Test') # Now that we have loaded all the test cases, run the whole test suite. -#print "test suite =", suite -#print "verbose =", verbose unittest.TextTestRunner(verbosity=verbose).run(suite) From johnny.chen at apple.com Fri Jun 25 19:19:32 2010 From: johnny.chen at apple.com (Johnny Chen) Date: Sat, 26 Jun 2010 00:19:32 -0000 Subject: [Lldb-commits] [lldb] r106929 - /lldb/trunk/test/dotest.py Message-ID: <20100626001932.D0BE12A6C12C@llvm.org> Author: johnny Date: Fri Jun 25 19:19:32 2010 New Revision: 106929 URL: http://llvm.org/viewvc/llvm-project?rev=106929&view=rev Log: No need to add the test script containing directory to sys.path more than once. Modified: lldb/trunk/test/dotest.py Modified: lldb/trunk/test/dotest.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/dotest.py?rev=106929&r1=106928&r2=106929&view=diff ============================================================================== --- lldb/trunk/test/dotest.py (original) +++ lldb/trunk/test/dotest.py Fri Jun 25 19:19:32 2010 @@ -112,7 +112,8 @@ if '.py' == os.path.splitext(name)[1] and name.startswith(prefix): # We found a pattern match for our test case. Add it to the suite. - sys.path.append(dir) + if not sys.path.count(dir): + sys.path.append(dir) base = os.path.splitext(name)[0] suite.addTests(unittest.defaultTestLoader.loadTestsFromName(base))