From wilsons at start.ca Mon Jul 19 19:57:42 2010 From: wilsons at start.ca (Stephen Wilson) Date: Mon, 19 Jul 2010 20:57:42 -0400 Subject: [Lldb-commits] [PATCH] Fix assertion conditions and missing header. Message-ID: An embedded and charset-unspecified text was scrubbed... Name: proc.patch Url: http://lists.cs.uiuc.edu/pipermail/lldb-commits/attachments/20100719/0548bce1/attachment.pl -------------- next part -------------- An embedded and charset-unspecified text was scrubbed... Name: objfile.patch Url: http://lists.cs.uiuc.edu/pipermail/lldb-commits/attachments/20100719/0548bce1/attachment-0001.pl From benny.kra at googlemail.com Tue Jul 20 09:37:45 2010 From: benny.kra at googlemail.com (Benjamin Kramer) Date: Tue, 20 Jul 2010 14:37:45 -0000 Subject: [Lldb-commits] [lldb] r108840 - in /lldb/trunk/source: Interpreter/CommandObjectRegexCommand.cpp Plugins/DynamicLoader/MacOSX-DYLD/ThreadPlanStepThroughObjCTrampoline.cpp Symbol/TypeList.cpp Message-ID: <20100720143745.6A2FF2A6C12C@llvm.org> Author: d0k Date: Tue Jul 20 09:37:45 2010 New Revision: 108840 URL: http://llvm.org/viewvc/llvm-project?rev=108840&view=rev Log: More constructor warning fixes from William Lynch. Modified: lldb/trunk/source/Interpreter/CommandObjectRegexCommand.cpp lldb/trunk/source/Plugins/DynamicLoader/MacOSX-DYLD/ThreadPlanStepThroughObjCTrampoline.cpp lldb/trunk/source/Symbol/TypeList.cpp Modified: lldb/trunk/source/Interpreter/CommandObjectRegexCommand.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Interpreter/CommandObjectRegexCommand.cpp?rev=108840&r1=108839&r2=108840&view=diff ============================================================================== --- lldb/trunk/source/Interpreter/CommandObjectRegexCommand.cpp (original) +++ lldb/trunk/source/Interpreter/CommandObjectRegexCommand.cpp Tue Jul 20 09:37:45 2010 @@ -30,8 +30,8 @@ uint32_t max_matches ) : CommandObject (name, help, syntax), - m_entries(), - m_max_matches (max_matches) + m_max_matches (max_matches), + m_entries () { } Modified: lldb/trunk/source/Plugins/DynamicLoader/MacOSX-DYLD/ThreadPlanStepThroughObjCTrampoline.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/DynamicLoader/MacOSX-DYLD/ThreadPlanStepThroughObjCTrampoline.cpp?rev=108840&r1=108839&r2=108840&view=diff ============================================================================== --- lldb/trunk/source/Plugins/DynamicLoader/MacOSX-DYLD/ThreadPlanStepThroughObjCTrampoline.cpp (original) +++ lldb/trunk/source/Plugins/DynamicLoader/MacOSX-DYLD/ThreadPlanStepThroughObjCTrampoline.cpp Tue Jul 20 09:37:45 2010 @@ -34,13 +34,13 @@ lldb::addr_t sel_ptr, bool stop_others) : ThreadPlan (ThreadPlan::eKindGeneric, "MacOSX Step through ObjC Trampoline", thread, eVoteNoOpinion, eVoteNoOpinion), + m_args_addr (args_addr), + m_stop_others (stop_others), m_objc_trampoline_handler (trampoline_handler), m_impl_function (trampoline_handler->GetLookupImplementationWrapperFunction()), - m_args_addr (args_addr), m_object_ptr (object_ptr), m_class_ptr (class_ptr), - m_sel_ptr (sel_ptr), - m_stop_others (stop_others) + m_sel_ptr (sel_ptr) { } Modified: lldb/trunk/source/Symbol/TypeList.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/TypeList.cpp?rev=108840&r1=108839&r2=108840&view=diff ============================================================================== --- lldb/trunk/source/Symbol/TypeList.cpp (original) +++ lldb/trunk/source/Symbol/TypeList.cpp Tue Jul 20 09:37:45 2010 @@ -40,8 +40,8 @@ using namespace clang; TypeList::TypeList(const char *target_triple) : - m_types(), - m_ast(target_triple) + m_ast (target_triple), + m_types () { } From gclayton at apple.com Tue Jul 20 12:17:40 2010 From: gclayton at apple.com (Greg Clayton) Date: Tue, 20 Jul 2010 10:17:40 -0700 Subject: [Lldb-commits] [PATCH] Fix assertion conditions and missing header. In-Reply-To: References: Message-ID: <13AD00D3-F8F3-47AA-86B2-4C902AE19748@apple.com> Looks good, go ahead and submit. Greg Clayton On Jul 19, 2010, at 5:57 PM, Stephen Wilson wrote: > > Two trivial patches. Fix a thinko in assertion conditions and add a > missing header. > > OK to apply? > > Thanks! > Steve > > _______________________________________________ > lldb-commits mailing list > lldb-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/lldb-commits From gclayton at apple.com Tue Jul 20 13:30:17 2010 From: gclayton at apple.com (Greg Clayton) Date: Tue, 20 Jul 2010 18:30:17 -0000 Subject: [Lldb-commits] [lldb] r108871 - /lldb/trunk/source/Symbol/Symtab.cpp Message-ID: <20100720183017.8E5E42A6C12C@llvm.org> Author: gclayton Date: Tue Jul 20 13:30:17 2010 New Revision: 108871 URL: http://llvm.org/viewvc/llvm-project?rev=108871&view=rev Log: Logic fix to properly determine when a symbol is not from the current symbol table (from William Lynch). Modified: lldb/trunk/source/Symbol/Symtab.cpp Modified: lldb/trunk/source/Symbol/Symtab.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/Symtab.cpp?rev=108871&r1=108870&r2=108871&view=diff ============================================================================== --- lldb/trunk/source/Symbol/Symtab.cpp (original) +++ lldb/trunk/source/Symbol/Symtab.cpp Tue Jul 20 13:30:17 2010 @@ -504,7 +504,7 @@ Symtab::CalculateSymbolSize (Symbol *symbol) { // Make sure this symbol is from this symbol table... - if (symbol < m_symbols.data() && symbol >= m_symbols.data() + m_symbols.size()) + if (symbol < m_symbols.data() || symbol >= m_symbols.data() + m_symbols.size()) return 0; // See if this symbol already has a byte size? From wilsons at start.ca Tue Jul 20 13:40:23 2010 From: wilsons at start.ca (Stephen Wilson) Date: Tue, 20 Jul 2010 18:40:23 -0000 Subject: [Lldb-commits] [lldb] r108878 - /lldb/trunk/include/lldb/Symbol/ObjectFile.h Message-ID: <20100720184023.2DD1F2A6C12C@llvm.org> Author: wilsons Date: Tue Jul 20 13:40:23 2010 New Revision: 108878 URL: http://llvm.org/viewvc/llvm-project?rev=108878&view=rev Log: Add missing include. Modified: lldb/trunk/include/lldb/Symbol/ObjectFile.h Modified: lldb/trunk/include/lldb/Symbol/ObjectFile.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Symbol/ObjectFile.h?rev=108878&r1=108877&r2=108878&view=diff ============================================================================== --- lldb/trunk/include/lldb/Symbol/ObjectFile.h (original) +++ lldb/trunk/include/lldb/Symbol/ObjectFile.h Tue Jul 20 13:40:23 2010 @@ -12,6 +12,7 @@ #include "lldb/lldb-private.h" #include "lldb/Core/DataExtractor.h" +#include "lldb/Core/FileSpec.h" #include "lldb/Core/ModuleChild.h" #include "lldb/Core/PluginInterface.h" #include "lldb/Symbol/Symtab.h" From wilsons at start.ca Tue Jul 20 13:41:11 2010 From: wilsons at start.ca (Stephen Wilson) Date: Tue, 20 Jul 2010 18:41:11 -0000 Subject: [Lldb-commits] [lldb] r108879 - /lldb/trunk/source/Target/Process.cpp Message-ID: <20100720184111.8B58A2A6C12C@llvm.org> Author: wilsons Date: Tue Jul 20 13:41:11 2010 New Revision: 108879 URL: http://llvm.org/viewvc/llvm-project?rev=108879&view=rev Log: Fix assertion conditions. Modified: lldb/trunk/source/Target/Process.cpp Modified: lldb/trunk/source/Target/Process.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/Process.cpp?rev=108879&r1=108878&r2=108879&view=diff ============================================================================== --- lldb/trunk/source/Target/Process.cpp (original) +++ lldb/trunk/source/Target/Process.cpp Tue Jul 20 13:41:11 2010 @@ -699,7 +699,7 @@ { // Clear a software breakoint instruction uint8_t curr_break_op[8]; - assert (sizeof(curr_break_op) < break_op_size); + assert (break_op_size <= sizeof(curr_break_op)); bool break_op_found = false; // Read the breakpoint opcode @@ -729,7 +729,7 @@ if (verify) { uint8_t verify_opcode[8]; - assert (sizeof(verify_opcode) < break_op_size); + assert (break_op_size < sizeof(verify_opcode)); // Verify that our original opcode made it back to the inferior if (DoReadMemory (bp_addr, verify_opcode, break_op_size, error) == break_op_size) { From gclayton at apple.com Tue Jul 20 17:52:08 2010 From: gclayton at apple.com (Greg Clayton) Date: Tue, 20 Jul 2010 22:52:08 -0000 Subject: [Lldb-commits] [lldb] r108957 - in /lldb/trunk: include/lldb/Core/ source/Commands/ source/Core/ source/Expression/ source/Interpreter/ source/Plugins/Process/MacOSX-User/source/ source/Plugins/Process/gdb-remote/ source/Plugins/SymbolFile/DWARF/ source/Symbol/ source/Target/ Message-ID: <20100720225209.9461D2A6C12C@llvm.org> Author: gclayton Date: Tue Jul 20 17:52:08 2010 New Revision: 108957 URL: http://llvm.org/viewvc/llvm-project?rev=108957&view=rev Log: Remove use of STL collection class use of the "data()" method since it isn't part of C++'98. Most of these were "std::vector::data()" and "std::string::data()". Modified: lldb/trunk/include/lldb/Core/UniqueCStringMap.h lldb/trunk/source/Commands/CommandObjectMemory.cpp lldb/trunk/source/Commands/CommandObjectThread.cpp lldb/trunk/source/Core/Address.cpp lldb/trunk/source/Core/Communication.cpp lldb/trunk/source/Core/Debugger.cpp lldb/trunk/source/Core/Event.cpp lldb/trunk/source/Core/RegularExpression.cpp lldb/trunk/source/Core/ValueObject.cpp lldb/trunk/source/Core/ValueObjectChild.cpp lldb/trunk/source/Expression/ClangFunction.cpp lldb/trunk/source/Interpreter/Args.cpp lldb/trunk/source/Interpreter/Options.cpp lldb/trunk/source/Plugins/Process/MacOSX-User/source/ProcessMacOSX.cpp lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.cpp lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp lldb/trunk/source/Symbol/ClangASTContext.cpp lldb/trunk/source/Symbol/Symtab.cpp lldb/trunk/source/Symbol/Type.cpp lldb/trunk/source/Target/ObjCObjectPrinter.cpp lldb/trunk/source/Target/Process.cpp Modified: lldb/trunk/include/lldb/Core/UniqueCStringMap.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/UniqueCStringMap.h?rev=108957&r1=108956&r2=108957&view=diff ============================================================================== --- lldb/trunk/include/lldb/Core/UniqueCStringMap.h (original) +++ lldb/trunk/include/lldb/Core/UniqueCStringMap.h Tue Jul 20 17:52:08 2010 @@ -157,13 +157,16 @@ const Entry * FindNextValueForName (const char *unique_cstr, const Entry *entry_ptr) const { - const Entry *first_entry = m_map.data(); - const Entry *after_last_entry = first_entry + m_map.size(); - const Entry *next_entry = entry_ptr + 1; - if (first_entry <= next_entry && next_entry < after_last_entry) + if (!m_map.empty()) { - if (next_entry->cstring == unique_cstr) - return next_entry; + const Entry *first_entry = &m_map[0]; + const Entry *after_last_entry = first_entry + m_map.size(); + const Entry *next_entry = entry_ptr + 1; + if (first_entry <= next_entry && next_entry < after_last_entry) + { + if (next_entry->cstring == unique_cstr) + return next_entry; + } } return NULL; } Modified: lldb/trunk/source/Commands/CommandObjectMemory.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectMemory.cpp?rev=108957&r1=108956&r2=108957&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectMemory.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectMemory.cpp Tue Jul 20 17:52:08 2010 @@ -647,7 +647,7 @@ if (!buffer.GetString().empty()) { Error error; - if (process->WriteMemory (addr, buffer.GetString().data(), buffer.GetString().size(), error) == buffer.GetString().size()) + if (process->WriteMemory (addr, buffer.GetString().c_str(), buffer.GetString().size(), error) == buffer.GetString().size()) return true; else { Modified: lldb/trunk/source/Commands/CommandObjectThread.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectThread.cpp?rev=108957&r1=108956&r2=108957&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectThread.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectThread.cpp Tue Jul 20 17:52:08 2010 @@ -1028,7 +1028,7 @@ index_ptr++; } - new_plan = thread->QueueThreadPlanForStepUntil (abort_other_plans, address_list.data(), address_list.size(), m_options.m_stop_others); + new_plan = thread->QueueThreadPlanForStepUntil (abort_other_plans, &address_list.front(), address_list.size(), m_options.m_stop_others); new_plan->SetOkayToDiscard(false); } else Modified: lldb/trunk/source/Core/Address.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/Address.cpp?rev=108957&r1=108956&r2=108957&view=diff ============================================================================== --- lldb/trunk/source/Core/Address.cpp (original) +++ lldb/trunk/source/Core/Address.cpp Tue Jul 20 17:52:08 2010 @@ -167,7 +167,7 @@ static bool DumpUInt (ExecutionContextScope *exe_scope, const Address &address, uint32_t byte_size, Stream* strm) { - if (exe_scope == NULL) + if (exe_scope == NULL || byte_size == 0) return 0; std::vector buf(byte_size, 0); @@ -177,7 +177,7 @@ uint32_t addr_size = 0; if (GetByteOrderAndAddressSize (exe_scope, address, byte_order, addr_size)) { - DataExtractor data (buf.data(), buf.size(), byte_order, addr_size); + DataExtractor data (&buf.front(), buf.size(), byte_order, addr_size); data.Dump (strm, 0, // Start offset in "data" Modified: lldb/trunk/source/Core/Communication.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/Communication.cpp?rev=108957&r1=108956&r2=108957&view=diff ============================================================================== --- lldb/trunk/source/Core/Communication.cpp (original) +++ lldb/trunk/source/Core/Communication.cpp Tue Jul 20 17:52:08 2010 @@ -248,7 +248,7 @@ const size_t len = std::min(dst_len, m_bytes.size()); - ::memcpy (dst, m_bytes.data(), len); + ::memcpy (dst, m_bytes.c_str(), len); m_bytes.erase(m_bytes.begin(), m_bytes.begin() + len); return len; Modified: lldb/trunk/source/Core/Debugger.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/Debugger.cpp?rev=108957&r1=108956&r2=108957&view=diff ============================================================================== --- lldb/trunk/source/Core/Debugger.cpp (original) +++ lldb/trunk/source/Core/Debugger.cpp Tue Jul 20 17:52:08 2010 @@ -337,7 +337,7 @@ if (!reader_sp) break; - size_t bytes_handled = reader_sp->HandleRawBytes (m_input_reader_data.data(), + size_t bytes_handled = reader_sp->HandleRawBytes (m_input_reader_data.c_str(), m_input_reader_data.size()); if (bytes_handled) { Modified: lldb/trunk/source/Core/Event.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/Event.cpp?rev=108957&r1=108956&r2=108957&view=diff ============================================================================== --- lldb/trunk/source/Core/Event.cpp (original) +++ lldb/trunk/source/Core/Event.cpp Tue Jul 20 17:52:08 2010 @@ -169,10 +169,10 @@ { s->Printf("\"%s\"", m_bytes.c_str()); } - else + else if (m_bytes.size() > 0) { DataExtractor data; - data.SetData(m_bytes.data(), m_bytes.size(), eByteOrderHost); + data.SetData(&m_bytes[0], m_bytes.size(), eByteOrderHost); data.Dump(s, 0, eFormatBytes, 1, m_bytes.size(), 32, LLDB_INVALID_ADDRESS, 0, 0); } } @@ -182,7 +182,7 @@ { if (m_bytes.empty()) return NULL; - return m_bytes.data(); + return &m_bytes[0]; } size_t Modified: lldb/trunk/source/Core/RegularExpression.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/RegularExpression.cpp?rev=108957&r1=108956&r2=108957&view=diff ============================================================================== --- lldb/trunk/source/Core/RegularExpression.cpp (original) +++ lldb/trunk/source/Core/RegularExpression.cpp Tue Jul 20 17:52:08 2010 @@ -100,7 +100,7 @@ match_result = ::regexec (&m_preg, s, m_matches.size(), - const_cast(m_matches.data()), + &m_matches.front(), execute_flags); } return match_result == 0; Modified: lldb/trunk/source/Core/ValueObject.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/ValueObject.cpp?rev=108957&r1=108956&r2=108957&view=diff ============================================================================== --- lldb/trunk/source/Core/ValueObject.cpp (original) +++ lldb/trunk/source/Core/ValueObject.cpp Tue Jul 20 17:52:08 2010 @@ -395,8 +395,8 @@ // Resize the formatted buffer in case every character // uses the "\xXX" format and one extra byte for a NULL cstr_buffer.resize(data_buffer.size() * 4 + 1); - data.SetData (data_buffer.data(), data_buffer.size(), eByteOrderHost); - bytes_read = process->ReadMemory (cstr_address, data_buffer.data(), fixed_length, error); + data.SetData (&data_buffer.front(), data_buffer.size(), eByteOrderHost); + bytes_read = process->ReadMemory (cstr_address, &data_buffer.front(), fixed_length, error); if (bytes_read > 0) { sstr << '"'; @@ -423,11 +423,11 @@ // "\xXX" format and one extra byte for a NULL cstr_buffer.resize (k_max_buf_size * 4 + 1); - data.SetData (data_buffer.data(), data_buffer.size(), eByteOrderHost); + data.SetData (&data_buffer.front(), data_buffer.size(), eByteOrderHost); size_t total_cstr_len = 0; - while ((bytes_read = process->ReadMemory (cstr_address, data_buffer.data(), k_max_buf_size, error)) > 0) + while ((bytes_read = process->ReadMemory (cstr_address, &data_buffer.front(), k_max_buf_size, error)) > 0) { - size_t len = strlen(data_buffer.data()); + size_t len = strlen(&data_buffer.front()); if (len == 0) break; if (len > bytes_read) Modified: lldb/trunk/source/Core/ValueObjectChild.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/ValueObjectChild.cpp?rev=108957&r1=108956&r2=108957&view=diff ============================================================================== --- lldb/trunk/source/Core/ValueObjectChild.cpp (original) +++ lldb/trunk/source/Core/ValueObjectChild.cpp Tue Jul 20 17:52:08 2010 @@ -112,8 +112,8 @@ if (clang_type_name) { std::vector bitfield_type_name (strlen(clang_type_name) + 32, 0); - ::snprintf (bitfield_type_name.data(), bitfield_type_name.size(), "%s:%u", clang_type_name, m_bitfield_bit_size); - m_type_name.SetCString(bitfield_type_name.data()); + ::snprintf (&bitfield_type_name.front(), bitfield_type_name.size(), "%s:%u", clang_type_name, m_bitfield_bit_size); + m_type_name.SetCString(&bitfield_type_name.front()); } } } Modified: lldb/trunk/source/Expression/ClangFunction.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/ClangFunction.cpp?rev=108957&r1=108956&r2=108957&view=diff ============================================================================== --- lldb/trunk/source/Expression/ClangFunction.cpp (original) +++ lldb/trunk/source/Expression/ClangFunction.cpp Tue Jul 20 17:52:08 2010 @@ -358,8 +358,8 @@ buffer.resize(byte_size); DataExtractor value_data; arg_scalar.GetData (value_data); - value_data.ExtractBytes(0, byte_size, process->GetByteOrder(), buffer.data()); - process->WriteMemory(args_addr_ref + offset, buffer.data(), byte_size, error); + value_data.ExtractBytes(0, byte_size, process->GetByteOrder(), &buffer.front()); + process->WriteMemory(args_addr_ref + offset, &buffer.front(), byte_size, error); } return true; @@ -417,7 +417,7 @@ data_buffer.resize(m_return_size); Process *process = exc_context.process; Error error; - size_t bytes_read = process->ReadMemory(args_addr + m_return_offset/8, data_buffer.data(), m_return_size, error); + size_t bytes_read = process->ReadMemory(args_addr + m_return_offset/8, &data_buffer.front(), m_return_size, error); if (bytes_read == 0) { @@ -427,7 +427,7 @@ if (bytes_read < m_return_size) return false; - DataExtractor data(data_buffer.data(), m_return_size, process->GetByteOrder(), process->GetAddressByteSize()); + DataExtractor data(&data_buffer.front(), m_return_size, process->GetByteOrder(), process->GetAddressByteSize()); // FIXME: Assuming an integer scalar for now: uint32_t offset = 0; Modified: lldb/trunk/source/Interpreter/Args.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Interpreter/Args.cpp?rev=108957&r1=108956&r2=108957&view=diff ============================================================================== --- lldb/trunk/source/Interpreter/Args.cpp (original) +++ lldb/trunk/source/Interpreter/Args.cpp Tue Jul 20 17:52:08 2010 @@ -1008,7 +1008,7 @@ int long_options_index = -1; val = ::getopt_long (dummy_vec.size() - 1, - (char *const *) dummy_vec.data(), + (char *const *) &dummy_vec.front(), sstr.GetData(), long_options, &long_options_index); Modified: lldb/trunk/source/Interpreter/Options.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Interpreter/Options.cpp?rev=108957&r1=108956&r2=108957&view=diff ============================================================================== --- lldb/trunk/source/Interpreter/Options.cpp (original) +++ lldb/trunk/source/Interpreter/Options.cpp Tue Jul 20 17:52:08 2010 @@ -285,7 +285,10 @@ m_getopt_table[j].val = 0; } - return m_getopt_table.data(); + if (m_getopt_table.empty()) + return NULL; + + return &m_getopt_table.front(); } Modified: lldb/trunk/source/Plugins/Process/MacOSX-User/source/ProcessMacOSX.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/MacOSX-User/source/ProcessMacOSX.cpp?rev=108957&r1=108956&r2=108957&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Process/MacOSX-User/source/ProcessMacOSX.cpp (original) +++ lldb/trunk/source/Plugins/Process/MacOSX-User/source/ProcessMacOSX.cpp Tue Jul 20 17:52:08 2010 @@ -943,13 +943,13 @@ ProcessMacOSXLog::LogIf (PD_LOG_PROCESS, "ProcessMacOSX::%s (&%p[%u]) ...", __FUNCTION__, buf, buf_size); if (bytes_available > buf_size) { - memcpy(buf, m_stdout_data.data(), buf_size); + memcpy(buf, m_stdout_data.c_str(), buf_size); m_stdout_data.erase(0, buf_size); bytes_available = buf_size; } else { - memcpy(buf, m_stdout_data.data(), bytes_available); + memcpy(buf, m_stdout_data.c_str(), bytes_available); m_stdout_data.clear(); //ResetEventBits(eBroadcastBitSTDOUT); Modified: lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp?rev=108957&r1=108956&r2=108957&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp (original) +++ lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp Tue Jul 20 17:52:08 2010 @@ -267,7 +267,7 @@ m_async_response.Clear(); if (!m_async_packet.empty()) { - SendPacketAndWaitForResponse (m_async_packet.data(), + SendPacketAndWaitForResponse (&m_async_packet[0], m_async_packet.size(), m_async_response, m_async_timeout, @@ -483,7 +483,7 @@ if (m_send_acks) { char packet_checksum = strtol (&packet_data[packet_size-2], NULL, 16); - char actual_checksum = CalculcateChecksum (response_str.data(), response_str.size()); + char actual_checksum = CalculcateChecksum (&response_str[0], response_str.size()); checksum_error = packet_checksum != actual_checksum; // Send the ack or nack if needed if (checksum_error) 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=108957&r1=108956&r2=108957&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.cpp (original) +++ lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.cpp Tue Jul 20 17:52:08 2010 @@ -379,7 +379,7 @@ return false; response.GetStringRef().insert(0, 1, 'G'); - data_sp.reset (new DataBufferHeap(response.GetStringRef().data(), + data_sp.reset (new DataBufferHeap(response.GetStringRef().c_str(), response.GetStringRef().size())); return true; } 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=108957&r1=108956&r2=108957&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp (original) +++ lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp Tue Jul 20 17:52:08 2010 @@ -1313,13 +1313,13 @@ ProcessGDBRemoteLog::LogIf (GDBR_LOG_PROCESS, "ProcessGDBRemote::%s (&%p[%u]) ...", __FUNCTION__, buf, buf_size); if (bytes_available > buf_size) { - memcpy(buf, m_stdout_data.data(), buf_size); + memcpy(buf, m_stdout_data.c_str(), buf_size); m_stdout_data.erase(0, buf_size); bytes_available = buf_size; } else { - memcpy(buf, m_stdout_data.data(), bytes_available); + memcpy(buf, m_stdout_data.c_str(), bytes_available); m_stdout_data.clear(); //ResetEventBits(eBroadcastBitSTDOUT); Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp?rev=108957&r1=108956&r2=108957&view=diff ============================================================================== --- lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp (original) +++ lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp Tue Jul 20 17:52:08 2010 @@ -2878,17 +2878,18 @@ { // This is a class and all members that didn't have // their access specified are private. - type_list->GetClangASTContext().SetDefaultAccessForRecordFields (clang_type, clang::AS_private, member_accessibilities.data(), member_accessibilities.size()); + type_list->GetClangASTContext().SetDefaultAccessForRecordFields (clang_type, clang::AS_private, &member_accessibilities.front(), member_accessibilities.size()); } if (!base_classes.empty()) { - type_list->GetClangASTContext().SetBaseClassesForClassType (clang_type, base_classes.data(), base_classes.size()); + type_list->GetClangASTContext().SetBaseClassesForClassType (clang_type, &base_classes.front(), base_classes.size()); + + // Clang will copy each CXXBaseSpecifier in "base_classes" + // so we have to free them all. + ClangASTContext::DeleteBaseClassSpecifiers (&base_classes.front(), base_classes.size()); } - // Clang will copy each CXXBaseSpecifier in "base_classes" - // so we have to free them all. - ClangASTContext::DeleteBaseClassSpecifiers (base_classes.data(), base_classes.size()); } type_list->GetClangASTContext().CompleteTagDeclarationDefinition (clang_type); } @@ -3069,7 +3070,7 @@ assert (function_decl); m_die_to_decl_ctx[die] = function_decl; if (!function_param_decls.empty()) - type_list->GetClangASTContext().SetFunctionParameters (function_decl, function_param_decls.data(), function_param_decls.size()); + type_list->GetClangASTContext().SetFunctionParameters (function_decl, &function_param_decls.front(), function_param_decls.size()); } type_sp.reset( new Type(die->GetOffset(), this, type_name_dbstr, 0, NULL, LLDB_INVALID_UID, Type::eIsTypeWithUID, &decl, clang_type)); Modified: lldb/trunk/source/Symbol/ClangASTContext.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/ClangASTContext.cpp?rev=108957&r1=108956&r2=108957&view=diff ============================================================================== --- lldb/trunk/source/Symbol/ClangASTContext.cpp (original) +++ lldb/trunk/source/Symbol/ClangASTContext.cpp Tue Jul 20 17:52:08 2010 @@ -1944,7 +1944,7 @@ // TODO: Detect calling convention in DWARF? return ast_context->getFunctionType(QualType::getFromOpaquePtr(result_type), - qual_type_args.data(), + qual_type_args.empty() ? NULL : &qual_type_args.front(), qual_type_args.size(), isVariadic, TypeQuals, Modified: lldb/trunk/source/Symbol/Symtab.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/Symtab.cpp?rev=108957&r1=108956&r2=108957&view=diff ============================================================================== --- lldb/trunk/source/Symbol/Symtab.cpp (original) +++ lldb/trunk/source/Symbol/Symtab.cpp Tue Jul 20 17:52:08 2010 @@ -503,8 +503,11 @@ size_t Symtab::CalculateSymbolSize (Symbol *symbol) { + if (m_symbols.empty()) + return 0; + // Make sure this symbol is from this symbol table... - if (symbol < m_symbols.data() || symbol >= m_symbols.data() + m_symbols.size()) + if (symbol < &m_symbols.front() || symbol > &m_symbols.back()) return 0; // See if this symbol already has a byte size? @@ -523,7 +526,7 @@ if (m_addr_indexes.empty()) InitAddressIndexes(); const size_t num_addr_indexes = m_addr_indexes.size(); - SymbolSearchInfo info = FindIndexPtrForSymbolContainingAddress(this, symbol->GetAddressRangePtr()->GetBaseAddress().GetFileAddress(), m_addr_indexes.data(), num_addr_indexes); + SymbolSearchInfo info = FindIndexPtrForSymbolContainingAddress(this, symbol->GetAddressRangePtr()->GetBaseAddress().GetFileAddress(), &m_addr_indexes.front(), num_addr_indexes); if (info.match_index_ptr != NULL) { const lldb::addr_t curr_file_addr = symbol->GetAddressRangePtr()->GetBaseAddress().GetFileAddress(); @@ -531,7 +534,7 @@ // last one by taking the delta between the current symbol and // the next symbol - for (uint32_t addr_index = info.match_index_ptr - m_addr_indexes.data() + 1; + for (uint32_t addr_index = info.match_index_ptr - &m_addr_indexes.front() + 1; addr_index < num_addr_indexes; ++addr_index) { Modified: lldb/trunk/source/Symbol/Type.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/Type.cpp?rev=108957&r1=108956&r2=108957&view=diff ============================================================================== --- lldb/trunk/source/Symbol/Type.cpp (original) +++ lldb/trunk/source/Symbol/Type.cpp Tue Jul 20 17:52:08 2010 @@ -399,14 +399,14 @@ else buf.resize (256); - lldb_private::DataExtractor cstr_data(buf.data(), buf.size(), exe_ctx->process->GetByteOrder(), 4); + lldb_private::DataExtractor cstr_data(&buf.front(), buf.size(), exe_ctx->process->GetByteOrder(), 4); buf.back() = '\0'; size_t bytes_read; size_t total_cstr_len = 0; Error error; - while ((bytes_read = exe_ctx->process->ReadMemory (pointer_addresss, buf.data(), buf.size(), error)) > 0) + while ((bytes_read = exe_ctx->process->ReadMemory (pointer_addresss, &buf.front(), buf.size(), error)) > 0) { - const size_t len = strlen((const char *)buf.data()); + const size_t len = strlen((const char *)&buf.front()); if (len == 0) break; if (total_cstr_len == 0) Modified: lldb/trunk/source/Target/ObjCObjectPrinter.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/ObjCObjectPrinter.cpp?rev=108957&r1=108956&r2=108957&view=diff ============================================================================== --- lldb/trunk/source/Target/ObjCObjectPrinter.cpp (original) +++ lldb/trunk/source/Target/ObjCObjectPrinter.cpp Tue Jul 20 17:52:08 2010 @@ -86,7 +86,7 @@ if (!desc.empty()) { - str.SetCString(desc.data()); + str.SetCString(&desc.front()); return true; } return false; Modified: lldb/trunk/source/Target/Process.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/Process.cpp?rev=108957&r1=108956&r2=108957&view=diff ============================================================================== --- lldb/trunk/source/Target/Process.cpp (original) +++ lldb/trunk/source/Target/Process.cpp Tue Jul 20 17:52:08 2010 @@ -989,7 +989,12 @@ exec_path_plus_argv.push_back(NULL); // Now launch using these arguments. - error = DoLaunch (exe_module, exec_path_plus_argv.data(), envp, stdin_path, stdout_path, stderr_path); + error = DoLaunch (exe_module, + exec_path_plus_argv.empty() ? NULL : &exec_path_plus_argv.front(), + envp, + stdin_path, + stdout_path, + stderr_path); if (error.Fail()) { From gclayton at apple.com Tue Jul 20 17:54:09 2010 From: gclayton at apple.com (Greg Clayton) Date: Tue, 20 Jul 2010 22:54:09 -0000 Subject: [Lldb-commits] [lldb] r108958 - /lldb/trunk/source/Commands/CommandObjectMultiword.cpp Message-ID: <20100720225409.ABF202A6C12C@llvm.org> Author: gclayton Date: Tue Jul 20 17:54:09 2010 New Revision: 108958 URL: http://llvm.org/viewvc/llvm-project?rev=108958&view=rev Log: Fixing a crashing bug in multiword commands from William Lynch. Modified: lldb/trunk/source/Commands/CommandObjectMultiword.cpp Modified: lldb/trunk/source/Commands/CommandObjectMultiword.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectMultiword.cpp?rev=108958&r1=108957&r2=108958&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectMultiword.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectMultiword.cpp Tue Jul 20 17:54:09 2010 @@ -290,13 +290,12 @@ const char * CommandObjectMultiword::GetRepeatCommand (Args ¤t_command_args, uint32_t index) { - if (current_command_args.GetArgumentCount() == 0) - return NULL; index++; + if (current_command_args.GetArgumentCount() <= index) + return NULL; CommandObject *sub_command_object = GetSubcommandObject (current_command_args.GetArgumentAtIndex(index)); if (sub_command_object == NULL) return NULL; - else return sub_command_object->GetRepeatCommand(current_command_args, index); } From scallanan at apple.com Tue Jul 20 18:31:16 2010 From: scallanan at apple.com (Sean Callanan) Date: Tue, 20 Jul 2010 23:31:16 -0000 Subject: [Lldb-commits] [lldb] r108965 - in /lldb/trunk: include/lldb/Expression/ClangExpressionDeclMap.h include/lldb/Symbol/ASTType.h include/lldb/Symbol/ClangASTContext.h lldb.xcodeproj/project.pbxproj source/Commands/CommandObjectExpression.cpp source/Expression/ClangExpressionDeclMap.cpp source/Expression/IRForTarget.cpp source/Symbol/ASTType.cpp Message-ID: <20100720233116.8F4512A6C12C@llvm.org> Author: spyffe Date: Tue Jul 20 18:31:16 2010 New Revision: 108965 URL: http://llvm.org/viewvc/llvm-project?rev=108965&view=rev Log: Added functionality to dematerialize values that were used by the JIT compiled expression, including the result of the expression. Also added a new class, ASTType, which encapsulates an opaque Clang type and its associated AST context. Refactored ClangExpressionDeclMap to use ASTTypes, significantly reducing the possibility of mixups of types from different AST contexts. Added: lldb/trunk/include/lldb/Symbol/ASTType.h lldb/trunk/source/Symbol/ASTType.cpp Modified: lldb/trunk/include/lldb/Expression/ClangExpressionDeclMap.h lldb/trunk/include/lldb/Symbol/ClangASTContext.h lldb/trunk/lldb.xcodeproj/project.pbxproj lldb/trunk/source/Commands/CommandObjectExpression.cpp lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp lldb/trunk/source/Expression/IRForTarget.cpp Modified: lldb/trunk/include/lldb/Expression/ClangExpressionDeclMap.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Expression/ClangExpressionDeclMap.h?rev=108965&r1=108964&r2=108965&view=diff ============================================================================== --- lldb/trunk/include/lldb/Expression/ClangExpressionDeclMap.h (original) +++ lldb/trunk/include/lldb/Expression/ClangExpressionDeclMap.h Tue Jul 20 18:31:16 2010 @@ -21,6 +21,7 @@ // Project includes #include "lldb/Core/ClangForward.h" #include "lldb/Core/Value.h" +#include "lldb/Symbol/ASTType.h" namespace clang { class DeclarationName; @@ -54,6 +55,7 @@ const clang::NamedDecl *decl, std::string &name, void *type, + clang::ASTContext *ast_context, size_t size, off_t alignment); bool DoStructLayout (); @@ -69,20 +71,27 @@ Value *GetValueForIndex (uint32_t index); // Interface for CommandObjectExpression - lldb::addr_t Materialize(ExecutionContext *exe_ctx, - Error &error); + bool Materialize(ExecutionContext *exe_ctx, + lldb::addr_t &struct_address, + Error &error); + + bool Dematerialize(ExecutionContext *exe_ctx, + lldb_private::Value &result_value, + Error &error); // Interface for ClangASTSource void GetDecls (NameSearchContext &context, const char *name); -protected: private: + typedef TaggedASTType<0> TypeFromParser; + typedef TaggedASTType<1> TypeFromUser; + struct Tuple { const clang::NamedDecl *m_decl; - clang::ASTContext *m_ast_context; - void *m_orig_type; - Value *m_value; /* owned by ClangExpressionDeclMap */ + TypeFromParser m_parser_type; + TypeFromUser m_user_type; + lldb_private::Value *m_value; /* owned by ClangExpressionDeclMap */ }; struct StructMember @@ -90,7 +99,7 @@ const clang::NamedDecl *m_decl; llvm::Value *m_value; std::string m_name; - void *m_type; + TypeFromParser m_parser_type; off_t m_offset; size_t m_size; off_t m_alignment; @@ -109,29 +118,35 @@ off_t m_struct_alignment; size_t m_struct_size; bool m_struct_laid_out; + lldb::addr_t m_allocated_area; lldb::addr_t m_materialized_location; Variable *FindVariableInScope(const SymbolContext &sym_ctx, const char *name, - void *type = NULL, - clang::ASTContext *ast_context = NULL); + TypeFromUser *type = NULL); Value *GetVariableValue(ExecutionContext &exe_ctx, Variable *var, - clang::ASTContext *target_ast_context = NULL, - void **opaque_type = NULL, - clang::ASTContext **found_ast_context = NULL); + clang::ASTContext *parser_ast_context, + TypeFromUser *found_type = NULL, + TypeFromParser *parser_type = NULL); void AddOneVariable(NameSearchContext &context, Variable *var); void AddOneFunction(NameSearchContext &context, Function *fun); - bool MaterializeOneVariable(ExecutionContext &exe_ctx, - const SymbolContext &sym_ctx, - const char *name, - void *type, - clang::ASTContext *ast_context, - lldb::addr_t addr, - Error &err); + // Set D to dematerialize instead + bool DoMaterialize (bool dematerialize, + ExecutionContext *exe_ctx, + lldb_private::Value *result_value, /* must be non-NULL if D is set */ + Error &err); + + bool DoMaterializeOneVariable(bool dematerialize, + ExecutionContext &exe_ctx, + const SymbolContext &sym_ctx, + const char *name, + TypeFromUser type, + lldb::addr_t addr, + Error &err); }; } // namespace lldb_private Added: lldb/trunk/include/lldb/Symbol/ASTType.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Symbol/ASTType.h?rev=108965&view=auto ============================================================================== --- lldb/trunk/include/lldb/Symbol/ASTType.h (added) +++ lldb/trunk/include/lldb/Symbol/ASTType.h Tue Jul 20 18:31:16 2010 @@ -0,0 +1,108 @@ +//===-- ASTType.h -----------------------------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +namespace clang +{ + class ASTContext; +} + +namespace lldb_private +{ + +class ASTTypeBase +{ +protected: + ASTTypeBase (void *type, clang::ASTContext *ast_context) : + m_type(type), + m_ast_context(ast_context) + { + } + + ASTTypeBase (const ASTTypeBase &tw) : + m_type(tw.m_type), + m_ast_context(tw.m_ast_context) + { + } + + ASTTypeBase () : + m_type(0), + m_ast_context(0) + { + } + + ~ASTTypeBase(); + + ASTTypeBase &operator= (const ASTTypeBase &atb) + { + m_type = atb.m_type; + m_ast_context = atb.m_ast_context; + return *this; + } + +public: + void *GetType() const + { + return m_type; + } + + clang::ASTContext *GetASTContext() const + { + return m_ast_context; + } + +private: + void *m_type; + clang::ASTContext *m_ast_context; +}; + +class ASTType : public ASTTypeBase +{ +public: + ASTType (void *type, clang::ASTContext *ast_context) : + ASTTypeBase(type, ast_context) { } + + ASTType (const ASTType &at) : + ASTTypeBase(at) { } + + ASTType () : + ASTTypeBase() { } + + ~ASTType(); + + ASTType &operator= (const ASTType &at) + { + ASTTypeBase::operator= (at); + return *this; + } +}; + +// For cases in which there are multiple classes of types that are not +// interchangeable, to allow static type checking. +template class TaggedASTType : public ASTTypeBase +{ +public: + TaggedASTType (void *type, clang::ASTContext *ast_context) : + ASTTypeBase(type, ast_context) { } + + TaggedASTType (const TaggedASTType &tw) : + ASTTypeBase(tw) { } + + TaggedASTType () : + ASTTypeBase() { } + + ~TaggedASTType() { } + + TaggedASTType &operator= (const TaggedASTType &tw) + { + ASTTypeBase::operator= (tw); + return *this; + } +}; + +} Modified: lldb/trunk/include/lldb/Symbol/ClangASTContext.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Symbol/ClangASTContext.h?rev=108965&r1=108964&r2=108965&view=diff ============================================================================== --- lldb/trunk/include/lldb/Symbol/ClangASTContext.h (original) +++ lldb/trunk/include/lldb/Symbol/ClangASTContext.h Tue Jul 20 18:31:16 2010 @@ -21,7 +21,7 @@ // Project includes #include "lldb/lldb-enumerations.h" #include "lldb/Core/ClangForward.h" - +#include "lldb/Symbol/ASTType.h" namespace lldb_private { Modified: lldb/trunk/lldb.xcodeproj/project.pbxproj URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/lldb.xcodeproj/project.pbxproj?rev=108965&r1=108964&r2=108965&view=diff ============================================================================== --- lldb/trunk/lldb.xcodeproj/project.pbxproj (original) +++ lldb/trunk/lldb.xcodeproj/project.pbxproj Tue Jul 20 18:31:16 2010 @@ -335,6 +335,8 @@ 49D7072911B5AD11001AD875 /* ClangASTSource.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 49D7072811B5AD11001AD875 /* ClangASTSource.cpp */; settings = {COMPILER_FLAGS = "-fno-rtti"; }; }; 49DA743011DE6A5A006AEF7E /* IRToDWARF.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 49DA742F11DE6A5A006AEF7E /* IRToDWARF.cpp */; }; 49DA743511DE6BB2006AEF7E /* IRToDWARF.h in Headers */ = {isa = PBXBuildFile; fileRef = 49DA743411DE6BB2006AEF7E /* IRToDWARF.h */; }; + 49E45FAA11F660DC008F7B28 /* ASTType.h in Headers */ = {isa = PBXBuildFile; fileRef = 49E45FA911F660DC008F7B28 /* ASTType.h */; }; + 49E45FAF11F660FE008F7B28 /* ASTType.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 49E45FAD11F660FE008F7B28 /* ASTType.cpp */; }; 49F1A74611B3388F003ED505 /* ClangExpressionDeclMap.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 49F1A74511B3388F003ED505 /* ClangExpressionDeclMap.cpp */; }; 49F1A74A11B338AE003ED505 /* ClangExpressionDeclMap.h in Headers */ = {isa = PBXBuildFile; fileRef = 49F1A74911B338AE003ED505 /* ClangExpressionDeclMap.h */; }; 4C08CDE811C81EF8001610A8 /* ThreadSpec.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4C08CDE711C81EF8001610A8 /* ThreadSpec.cpp */; }; @@ -910,6 +912,8 @@ 49D7072811B5AD11001AD875 /* ClangASTSource.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = ClangASTSource.cpp; path = source/Expression/ClangASTSource.cpp; sourceTree = ""; }; 49DA742F11DE6A5A006AEF7E /* IRToDWARF.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = IRToDWARF.cpp; path = source/Expression/IRToDWARF.cpp; sourceTree = ""; }; 49DA743411DE6BB2006AEF7E /* IRToDWARF.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = IRToDWARF.h; path = include/lldb/Expression/IRToDWARF.h; sourceTree = ""; }; + 49E45FA911F660DC008F7B28 /* ASTType.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ASTType.h; path = include/lldb/Symbol/ASTType.h; sourceTree = ""; }; + 49E45FAD11F660FE008F7B28 /* ASTType.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = ASTType.cpp; path = source/Symbol/ASTType.cpp; sourceTree = ""; }; 49EC3E98118F90AC00B1265E /* ThreadPlanCallFunction.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = ThreadPlanCallFunction.cpp; path = source/Target/ThreadPlanCallFunction.cpp; sourceTree = ""; }; 49EC3E9C118F90D400B1265E /* ThreadPlanCallFunction.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ThreadPlanCallFunction.h; path = include/lldb/Target/ThreadPlanCallFunction.h; sourceTree = ""; }; 49F1A74511B3388F003ED505 /* ClangExpressionDeclMap.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = ClangExpressionDeclMap.cpp; path = source/Expression/ClangExpressionDeclMap.cpp; sourceTree = ""; }; @@ -1665,6 +1669,8 @@ isa = PBXGroup; children = ( AF94005711C03F6500085DB9 /* SymbolVendor.cpp */, + 49E45FA911F660DC008F7B28 /* ASTType.h */, + 49E45FAD11F660FE008F7B28 /* ASTType.cpp */, 26BC7C5510F1B6E900F91463 /* Block.h */, 26BC7F1310F1B8EC00F91463 /* Block.cpp */, 26BC7C5610F1B6E900F91463 /* ClangASTContext.h */, @@ -2195,6 +2201,7 @@ 49307AB211DEA4F20081F992 /* IRForTarget.h in Headers */, 4C5DBBC911E3FEC60035160F /* CommandObjectCommands.h in Headers */, 26D27CA011ED3A4E0024D721 /* ELFHeader.h in Headers */, + 49E45FAA11F660DC008F7B28 /* ASTType.h in Headers */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -2648,6 +2655,7 @@ 49307AAE11DEA4D90081F992 /* IRForTarget.cpp in Sources */, 4C5DBBC811E3FEC60035160F /* CommandObjectCommands.cpp in Sources */, 26D27C9F11ED3A4E0024D721 /* ELFHeader.cpp in Sources */, + 49E45FAF11F660FE008F7B28 /* ASTType.cpp in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; Modified: lldb/trunk/source/Commands/CommandObjectExpression.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectExpression.cpp?rev=108965&r1=108964&r2=108965&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectExpression.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectExpression.cpp Tue Jul 20 18:31:16 2010 @@ -305,10 +305,9 @@ } Error err; - - lldb::addr_t struct_address = expr_decl_map.Materialize(&m_exe_ctx, err); + lldb::addr_t struct_address; - if (struct_address == LLDB_INVALID_ADDRESS) + if (!expr_decl_map.Materialize(&m_exe_ctx, struct_address, err)) { error_stream.Printf ("Couldn't materialize struct: %s\n", err.AsCString("unknown error")); return false; Modified: lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp?rev=108965&r1=108964&r2=108965&view=diff ============================================================================== --- lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp (original) +++ lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp Tue Jul 20 18:31:16 2010 @@ -28,9 +28,10 @@ #include "lldb/Symbol/TypeList.h" #include "lldb/Symbol/Variable.h" #include "lldb/Symbol/VariableList.h" +#include "lldb/Target/ExecutionContext.h" #include "lldb/Target/Process.h" #include "lldb/Target/StackFrame.h" -#include "lldb/Target/ExecutionContext.h" +#include "lldb/Target/Target.h" using namespace lldb_private; using namespace clang; @@ -83,7 +84,8 @@ ClangExpressionDeclMap::AddValueToStruct (llvm::Value *value, const clang::NamedDecl *decl, std::string &name, - void *type, + void *parser_type, + clang::ASTContext *parser_ast_context, size_t size, off_t alignment) { @@ -101,13 +103,13 @@ StructMember member; - member.m_value = value; - member.m_decl = decl; - member.m_name = name; - member.m_type = type; - member.m_offset = 0; - member.m_size = size; - member.m_alignment = alignment; + member.m_value = value; + member.m_decl = decl; + member.m_name = name; + member.m_parser_type = TypeFromParser(parser_type, parser_ast_context); + member.m_offset = 0; + member.m_size = size; + member.m_alignment = alignment; m_members.push_back(member); @@ -181,7 +183,7 @@ } // Interface for DwarfExpression -Value +lldb_private::Value *ClangExpressionDeclMap::GetValueForIndex (uint32_t index) { if (index >= m_tuples.size ()) @@ -191,8 +193,33 @@ } // Interface for CommandObjectExpression -lldb::addr_t -ClangExpressionDeclMap::Materialize (ExecutionContext *exe_ctx, Error &err) + +bool +ClangExpressionDeclMap::Materialize (ExecutionContext *exe_ctx, + lldb::addr_t &struct_address, + Error &err) +{ + bool result = DoMaterialize(false, exe_ctx, NULL, err); + + if (result) + struct_address = m_materialized_location; + + return result; +} + +bool +ClangExpressionDeclMap::Dematerialize (ExecutionContext *exe_ctx, + lldb_private::Value &result_value, + Error &err) +{ + return DoMaterialize(true, exe_ctx, &result_value, err); +} + +bool +ClangExpressionDeclMap::DoMaterialize (bool dematerialize, + ExecutionContext *exe_ctx, + lldb_private::Value *result_value, + Error &err) { Log *log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS); @@ -202,12 +229,6 @@ return LLDB_INVALID_ADDRESS; } - if (m_materialized_location) - { - exe_ctx->process->DeallocateMemory(m_materialized_location); - m_materialized_location = 0; - } - if (!exe_ctx) { err.SetErrorString("Received null execution context"); @@ -216,23 +237,32 @@ const SymbolContext &sym_ctx(exe_ctx->frame->GetSymbolContext(lldb::eSymbolContextEverything)); - StructMemberIterator iter; + if (!dematerialize) + { + if (m_materialized_location) + { + exe_ctx->process->DeallocateMemory(m_materialized_location); + m_materialized_location = 0; + } - lldb::addr_t mem = exe_ctx->process->AllocateMemory(m_struct_alignment + m_struct_size, - lldb::ePermissionsReadable | lldb::ePermissionsWritable, - err); - - if (mem == LLDB_INVALID_ADDRESS) - return LLDB_INVALID_ADDRESS; - - m_materialized_location = mem; + lldb::addr_t mem = exe_ctx->process->AllocateMemory(m_struct_alignment + m_struct_size, + lldb::ePermissionsReadable | lldb::ePermissionsWritable, + err); + + if (mem == LLDB_INVALID_ADDRESS) + return false; + + m_allocated_area = mem; + } - lldb::addr_t aligned_mem = mem; + m_materialized_location = m_allocated_area; - if (aligned_mem % m_struct_alignment) + if (m_materialized_location % m_struct_alignment) { - aligned_mem += (m_struct_alignment - (aligned_mem % m_struct_alignment)); + m_materialized_location += (m_struct_alignment - (m_materialized_location % m_struct_alignment)); } + + StructMemberIterator iter; for (iter = m_members.begin(); iter != m_members.end(); @@ -251,23 +281,122 @@ if (log) log->Printf("Found special result variable %s", iter->m_name.c_str()); + if (dematerialize) + { + clang::ASTContext *context(exe_ctx->target->GetScratchClangASTContext()->getASTContext()); + + if (!context) + { + err.SetErrorString("Couldn't find a scratch AST context to put the result type into"); + } + + TypeFromUser copied_type(ClangASTContext::CopyType(context, + iter->m_parser_type.GetASTContext(), + iter->m_parser_type.GetType()), + context); + + result_value->SetContext(Value::eContextTypeOpaqueClangQualType, copied_type.GetType()); + } + continue; } Tuple &tuple(m_tuples[tuple_index]); - if (!MaterializeOneVariable(*exe_ctx, sym_ctx, iter->m_name.c_str(), tuple.m_orig_type, tuple.m_ast_context, aligned_mem + iter->m_offset, err)) + if (!DoMaterializeOneVariable(dematerialize, *exe_ctx, sym_ctx, iter->m_name.c_str(), tuple.m_user_type, m_materialized_location + iter->m_offset, err)) return false; } - return aligned_mem; + return true; +} + +bool +ClangExpressionDeclMap::DoMaterializeOneVariable(bool dematerialize, + ExecutionContext &exe_ctx, + const SymbolContext &sym_ctx, + const char *name, + TypeFromUser type, + lldb::addr_t addr, + Error &err) +{ + Log *log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS); + + Variable *var = FindVariableInScope(sym_ctx, name, &type); + + if (!var) + { + err.SetErrorStringWithFormat("Couldn't find %s with appropriate type", name); + return false; + } + + log->Printf("%s %s with type %p", (dematerialize ? "Dematerializing" : "Materializing"), name, type.GetType()); + + std::auto_ptr location_value(GetVariableValue(exe_ctx, + var, + type.GetASTContext())); + + if (!location_value.get()) + { + err.SetErrorStringWithFormat("Couldn't get value for %s", name); + return false; + } + + if (location_value->GetValueType() == Value::eValueTypeLoadAddress) + { + lldb::addr_t value_addr = location_value->GetScalar().ULongLong(); + + size_t bit_size = ClangASTContext::GetTypeBitSize(type.GetASTContext(), type.GetType()); + size_t byte_size = bit_size % 8 ? ((bit_size + 8) / 8) : (bit_size / 8); + + DataBufferHeap data; + data.SetByteSize(byte_size); + + lldb::addr_t src_addr; + lldb::addr_t dest_addr; + + if (dematerialize) + { + src_addr = addr; + dest_addr = value_addr; + } + else + { + src_addr = value_addr; + dest_addr = addr; + } + + Error error; + if (exe_ctx.process->ReadMemory (src_addr, data.GetBytes(), byte_size, error) != byte_size) + { + err.SetErrorStringWithFormat ("Couldn't read a composite type from the target: %s", error.AsCString()); + return false; + } + + if (exe_ctx.process->WriteMemory (dest_addr, data.GetBytes(), byte_size, error) != byte_size) + { + err.SetErrorStringWithFormat ("Couldn't write a composite type to the target: %s", error.AsCString()); + return false; + } + + if (log) + log->Printf("Copied from 0x%llx to 0x%llx", (uint64_t)src_addr, (uint64_t)addr); + } + else + { + StreamString ss; + + location_value->Dump(&ss); + + err.SetErrorStringWithFormat("%s has a value of unhandled type: %s", name, ss.GetString().c_str()); + } + + return true; } Variable* ClangExpressionDeclMap::FindVariableInScope(const SymbolContext &sym_ctx, const char *name, - void *type, - clang::ASTContext *ast_context) + TypeFromUser *type) { Log *log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS); @@ -319,9 +448,9 @@ if (!type) return var.get(); - if (ast_context == var->GetType()->GetClangAST()) + if (type->GetASTContext() == var->GetType()->GetClangAST()) { - if (!ClangASTContext::AreTypesSame(ast_context, type, var->GetType()->GetOpaqueClangQualType())) + if (!ClangASTContext::AreTypesSame(type->GetASTContext(), type, var->GetType()->GetOpaqueClangQualType())) continue; } else @@ -357,9 +486,9 @@ if (!type) return var.get(); - if (ast_context == var->GetType()->GetClangAST()) + if (type->GetASTContext() == var->GetType()->GetClangAST()) { - if (!ClangASTContext::AreTypesSame(ast_context, type, var->GetType()->GetOpaqueClangQualType())) + if (!ClangASTContext::AreTypesSame(type->GetASTContext(), type->GetType(), var->GetType()->GetOpaqueClangQualType())) return NULL; } else @@ -375,75 +504,6 @@ return NULL; } -bool -ClangExpressionDeclMap::MaterializeOneVariable(ExecutionContext &exe_ctx, - const SymbolContext &sym_ctx, - const char *name, - void *type, - clang::ASTContext *ast_context, - lldb::addr_t addr, - Error &err) -{ - Log *log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS); - - Variable *var = FindVariableInScope(sym_ctx, name, type, ast_context); - - if (!var) - { - err.SetErrorStringWithFormat("Couldn't find %s with appropriate type", name); - return false; - } - - log->Printf("Materializing %s with type %p", name, type); - - std::auto_ptr location_value(GetVariableValue(exe_ctx, - var, - ast_context)); - - if (!location_value.get()) - { - err.SetErrorStringWithFormat("Couldn't get value for %s", name); - return false; - } - - if (location_value->GetValueType() == Value::eValueTypeLoadAddress) - { - lldb::addr_t src_addr = location_value->GetScalar().ULongLong(); - - size_t bit_size = ClangASTContext::GetTypeBitSize(ast_context, type); - size_t byte_size = bit_size % 8 ? ((bit_size + 8) / 8) : (bit_size / 8); - - DataBufferHeap data; - data.SetByteSize(byte_size); - - Error error; - if (exe_ctx.process->ReadMemory (src_addr, data.GetBytes(), byte_size, error) != byte_size) - { - err.SetErrorStringWithFormat ("Couldn't read a composite type from the target: %s", error.AsCString()); - return false; - } - - if (exe_ctx.process->WriteMemory (addr, data.GetBytes(), byte_size, error) != byte_size) - { - err.SetErrorStringWithFormat ("Couldn't write a composite type to the target: %s", error.AsCString()); - return false; - } - - if (log) - log->Printf("Copied from 0x%llx to 0x%llx", (uint64_t)src_addr, (uint64_t)addr); - } - else - { - StreamString ss; - - location_value->Dump(&ss); - - err.SetErrorStringWithFormat("%s has a value of unhandled type: %s", name, ss.GetString().c_str()); - } - - return true; -} - // Interface for ClangASTSource void ClangExpressionDeclMap::GetDecls(NameSearchContext &context, @@ -483,9 +543,9 @@ Value * ClangExpressionDeclMap::GetVariableValue(ExecutionContext &exe_ctx, Variable *var, - clang::ASTContext *target_ast_context, - void **opaque_type, - clang::ASTContext **found_ast_context) + clang::ASTContext *parser_ast_context, + TypeFromUser *user_type, + TypeFromParser *parser_type) { Log *log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS); @@ -542,8 +602,13 @@ void *type_to_use; - if (target_ast_context) - type_to_use = ClangASTContext::CopyType(target_ast_context, var_ast_context, var_opaque_type); + if (parser_ast_context) + { + type_to_use = ClangASTContext::CopyType(parser_ast_context, var_ast_context, var_opaque_type); + + if (parser_type) + *parser_type = TypeFromParser(type_to_use, parser_ast_context); + } else type_to_use = var_opaque_type; @@ -571,11 +636,8 @@ var_location->SetValueType(Value::eValueTypeLoadAddress); } - if (opaque_type) - *opaque_type = var_opaque_type; - - if (found_ast_context) - *found_ast_context = var_ast_context; + if (user_type) + *user_type = TypeFromUser(var_opaque_type, var_ast_context); return var_location.release(); } @@ -586,23 +648,23 @@ { Log *log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS); - void *var_opaque_type = NULL; - clang::ASTContext *var_ast_context = NULL; + TypeFromUser ut; + TypeFromParser pt; Value *var_location = GetVariableValue(*m_exe_ctx, var, context.GetASTContext(), - &var_opaque_type, - &var_ast_context); + &ut, + &pt); - NamedDecl *var_decl = context.AddVarDecl(var_opaque_type); + NamedDecl *var_decl = context.AddVarDecl(pt.GetType()); Tuple tuple; tuple.m_decl = var_decl; tuple.m_value = var_location; - tuple.m_orig_type = var_opaque_type; - tuple.m_ast_context = var_ast_context; + tuple.m_user_type = ut; + tuple.m_parser_type = pt; m_tuples.push_back(tuple); @@ -651,8 +713,7 @@ tuple.m_decl = fun_decl; tuple.m_value = fun_location.release(); - tuple.m_orig_type = fun_opaque_type; - tuple.m_ast_context = fun_ast_context; + tuple.m_user_type = TypeFromUser(fun_opaque_type, fun_ast_context); m_tuples.push_back(tuple); Modified: lldb/trunk/source/Expression/IRForTarget.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/IRForTarget.cpp?rev=108965&r1=108964&r2=108965&view=diff ============================================================================== --- lldb/trunk/source/Expression/IRForTarget.cpp (original) +++ lldb/trunk/source/Expression/IRForTarget.cpp Tue Jul 20 18:31:16 2010 @@ -93,12 +93,18 @@ std::string name = named_decl->getName().str(); void *qual_type = NULL; + clang::ASTContext *ast_context = NULL; if (clang::ValueDecl *value_decl = dyn_cast(named_decl)) + { qual_type = value_decl->getType().getAsOpaquePtr(); + ast_context = &value_decl->getASTContext(); + } else + { return false; - + } + const llvm::Type *value_type = global_variable->getType(); size_t value_size = m_target_data->getTypeStoreSize(value_type); @@ -108,6 +114,7 @@ named_decl, name, qual_type, + ast_context, value_size, value_alignment)) return false; Added: lldb/trunk/source/Symbol/ASTType.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/ASTType.cpp?rev=108965&view=auto ============================================================================== --- lldb/trunk/source/Symbol/ASTType.cpp (added) +++ lldb/trunk/source/Symbol/ASTType.cpp Tue Jul 20 18:31:16 2010 @@ -0,0 +1,20 @@ +//===-- ASTType.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/Symbol/ASTType.h" + +using namespace lldb_private; + +ASTTypeBase::~ASTTypeBase() +{ +} + +ASTType::~ASTType() +{ +} \ No newline at end of file From scallanan at apple.com Tue Jul 20 18:53:01 2010 From: scallanan at apple.com (Sean Callanan) Date: Tue, 20 Jul 2010 23:53:01 -0000 Subject: [Lldb-commits] [lldb] r108970 - /lldb/trunk/include/lldb/Symbol/ASTType.h Message-ID: <20100720235301.34A762A6C12D@llvm.org> Author: spyffe Date: Tue Jul 20 18:53:01 2010 New Revision: 108970 URL: http://llvm.org/viewvc/llvm-project?rev=108970&view=rev Log: Whoops, forgot to guard ASTType.h. Fixed. Modified: lldb/trunk/include/lldb/Symbol/ASTType.h Modified: lldb/trunk/include/lldb/Symbol/ASTType.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Symbol/ASTType.h?rev=108970&r1=108969&r2=108970&view=diff ============================================================================== --- lldb/trunk/include/lldb/Symbol/ASTType.h (original) +++ lldb/trunk/include/lldb/Symbol/ASTType.h Tue Jul 20 18:53:01 2010 @@ -7,6 +7,9 @@ // //===----------------------------------------------------------------------===// +#ifndef liblldb_ASTType_h_ +#define liblldb_ASTType_h_ + namespace clang { class ASTContext; @@ -106,3 +109,5 @@ }; } + +#endif From gclayton at apple.com Tue Jul 20 20:08:41 2010 From: gclayton at apple.com (Greg Clayton) Date: Wed, 21 Jul 2010 01:08:41 -0000 Subject: [Lldb-commits] [lldb] r108976 - /lldb/trunk/source/Core/DataExtractor.cpp Message-ID: <20100721010841.CC7662A6C12C@llvm.org> Author: gclayton Date: Tue Jul 20 20:08:41 2010 New Revision: 108976 URL: http://llvm.org/viewvc/llvm-project?rev=108976&view=rev Log: Avoid std::bitset<64>::to_string() since it is missing in earlier C++ libraries (from William Lynch). Modified: lldb/trunk/source/Core/DataExtractor.cpp Modified: lldb/trunk/source/Core/DataExtractor.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/DataExtractor.cpp?rev=108976&r1=108975&r2=108976&view=diff ============================================================================== --- lldb/trunk/source/Core/DataExtractor.cpp (original) +++ lldb/trunk/source/Core/DataExtractor.cpp Tue Jul 20 20:08:41 2010 @@ -1197,7 +1197,13 @@ case eFormatBinary: { uint64_t uval64 = GetMaxU64Bitfield(&offset, item_byte_size, item_bit_size, item_bit_offset); - std::string binary_value(std::bitset<64>(uval64).to_string()); + // Avoid std::bitset<64>::to_string() since it is missing in + // earlier C++ libraries + std::string binary_value(64, '0'); + std::bitset<64> bits(uval64); + for (size_t i = 0; i < 64; ++i) + if (bits[i]) + binary_value[64 - 1 - i] = '1'; if (item_bit_size > 0) s->Printf("0b%s", binary_value.c_str() + 64 - item_bit_size); else if (item_byte_size > 0 && item_byte_size <= 8) From gclayton at apple.com Wed Jul 21 11:57:26 2010 From: gclayton at apple.com (Greg Clayton) Date: Wed, 21 Jul 2010 16:57:26 -0000 Subject: [Lldb-commits] [lldb] r109016 - in /lldb/trunk: lldb.xcodeproj/project.pbxproj llvm.zip scripts/build-llvm.pl source/Plugins/Disassembler/llvm/DisassemblerLLVM.h Message-ID: <20100721165726.CD5492A6C12C@llvm.org> Author: gclayton Date: Wed Jul 21 11:57:26 2010 New Revision: 109016 URL: http://llvm.org/viewvc/llvm-project?rev=109016&view=rev Log: Updated LLVM and Clang to July 20 at 16:00. Modified: lldb/trunk/lldb.xcodeproj/project.pbxproj lldb/trunk/llvm.zip lldb/trunk/scripts/build-llvm.pl lldb/trunk/source/Plugins/Disassembler/llvm/DisassemblerLLVM.h Modified: lldb/trunk/lldb.xcodeproj/project.pbxproj URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/lldb.xcodeproj/project.pbxproj?rev=109016&r1=109015&r2=109016&view=diff ============================================================================== --- lldb/trunk/lldb.xcodeproj/project.pbxproj (original) +++ lldb/trunk/lldb.xcodeproj/project.pbxproj Wed Jul 21 11:57:26 2010 @@ -2764,7 +2764,7 @@ "$(LLVM_BUILD_DIR)", ); LLVM_BUILD_DIR = "$(SRCROOT)/llvm"; - LLVM_CONFIGURATION = "Release+Asserts"; + LLVM_CONFIGURATION = Release; OTHER_CFLAGS = ( "-DFOR_DYLD=0", "-DSUPPORT_REMOTE_UNWINDING", @@ -2817,7 +2817,7 @@ "$(LLVM_BUILD_DIR)", ); LLVM_BUILD_DIR = "$(SRCROOT)/llvm"; - LLVM_CONFIGURATION = "Release+Asserts"; + LLVM_CONFIGURATION = Release; OTHER_CFLAGS = ( "-DFOR_DYLD=0", "-DSUPPORT_REMOTE_UNWINDING", @@ -2927,7 +2927,7 @@ "$(LLVM_BUILD_DIR)", ); LLVM_BUILD_DIR = "$(DERIVED_FILE_DIR)/llvm.build"; - LLVM_CONFIGURATION = "Release+Asserts"; + LLVM_CONFIGURATION = Release; OTHER_CFLAGS = ( "-DFOR_DYLD=0", "-DSUPPORT_REMOTE_UNWINDING", Modified: lldb/trunk/llvm.zip URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/llvm.zip?rev=109016&r1=109015&r2=109016&view=diff ============================================================================== Binary files - no diff available. Modified: lldb/trunk/scripts/build-llvm.pl URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/scripts/build-llvm.pl?rev=109016&r1=109015&r2=109016&view=diff ============================================================================== --- lldb/trunk/scripts/build-llvm.pl (original) +++ lldb/trunk/scripts/build-llvm.pl Wed Jul 21 11:57:26 2010 @@ -25,7 +25,7 @@ our $llvm_configuration = $ENV{LLVM_CONFIGURATION}; -our $llvm_revision = "'{2010-07-13T13:00}'"; +our $llvm_revision = "'{2010-07-20T16:00}'"; our $llvm_source_dir = "$ENV{SRCROOT}"; our $cc = "$ENV{DEVELOPER_BIN_DIR}/gcc-4.2"; our $cxx = "$ENV{DEVELOPER_BIN_DIR}/g++-4.2"; @@ -70,6 +70,7 @@ "$llvm_configuration/lib/libLLVMLinker.a", "$llvm_configuration/lib/libLLVMMC.a", "$llvm_configuration/lib/libLLVMMCParser.a", + "$llvm_configuration/lib/libLLVMMCDisassembler.a", "$llvm_configuration/lib/libLLVMScalarOpts.a", "$llvm_configuration/lib/libLLVMSelectionDAG.a", "$llvm_configuration/lib/libLLVMSupport.a", @@ -200,6 +201,10 @@ if (!-e $llvm_dstroot_arch_archive) { $do_make = 1; + } + else + { + print "LLVM architecture archive for ${arch} is '$llvm_dstroot_arch_archive'\n"; } } else Modified: lldb/trunk/source/Plugins/Disassembler/llvm/DisassemblerLLVM.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Disassembler/llvm/DisassemblerLLVM.h?rev=109016&r1=109015&r2=109016&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Disassembler/llvm/DisassemblerLLVM.h (original) +++ lldb/trunk/source/Plugins/Disassembler/llvm/DisassemblerLLVM.h Wed Jul 21 11:57:26 2010 @@ -10,14 +10,11 @@ #ifndef liblldb_DisassemblerLLVM_h_ #define liblldb_DisassemblerLLVM_h_ -#include "lldb/Core/Disassembler.h" -#include "lldb/Host/Mutex.h" -struct EDDisassembler; -typedef EDDisassembler *EDDisassemblerRef; +#include "llvm-c/EnhancedDisassembly.h" -struct EDInst; -typedef EDInst *EDInstRef; +#include "lldb/Core/Disassembler.h" +#include "lldb/Host/Mutex.h" class DisassemblerLLVM : public lldb_private::Disassembler { From gclayton at apple.com Wed Jul 21 16:49:46 2010 From: gclayton at apple.com (Greg Clayton) Date: Wed, 21 Jul 2010 21:49:46 -0000 Subject: [Lldb-commits] [lldb] r109040 - in /lldb/trunk: include/lldb/Core/Section.h source/Core/Address.cpp source/Core/Section.cpp Message-ID: <20100721214946.4A3B42A6C12C@llvm.org> Author: gclayton Date: Wed Jul 21 16:49:46 2010 New Revision: 109040 URL: http://llvm.org/viewvc/llvm-project?rev=109040&view=rev Log: Allow searching for a section by SectionType. Modified: lldb/trunk/include/lldb/Core/Section.h lldb/trunk/source/Core/Address.cpp lldb/trunk/source/Core/Section.cpp Modified: lldb/trunk/include/lldb/Core/Section.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/Section.h?rev=109040&r1=109039&r2=109040&view=diff ============================================================================== --- lldb/trunk/include/lldb/Core/Section.h (original) +++ lldb/trunk/include/lldb/Core/Section.h Wed Jul 21 16:49:46 2010 @@ -55,6 +55,9 @@ FindSectionByID (lldb::user_id_t sect_id) const; lldb::SectionSP + FindSectionByType (lldb::SectionType sect_type, uint32_t start_idx = 0) const; + + lldb::SectionSP GetSharedPointer (const Section *section, bool check_children) const; lldb::SectionSP @@ -254,7 +257,7 @@ GetLinkedFileAddress () const; lldb::SectionType - GetSectionType () const + GetType () const { return m_type; } Modified: lldb/trunk/source/Core/Address.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/Address.cpp?rev=109040&r1=109039&r2=109040&view=diff ============================================================================== --- lldb/trunk/source/Core/Address.cpp (original) +++ lldb/trunk/source/Core/Address.cpp Wed Jul 21 16:49:46 2010 @@ -508,7 +508,7 @@ const Section *section = GetSection(); if (section) { - SectionType sect_type = section->GetSectionType(); + SectionType sect_type = section->GetType(); switch (sect_type) { case eSectionTypeDataCString: Modified: lldb/trunk/source/Core/Section.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/Section.cpp?rev=109040&r1=109039&r2=109040&view=diff ============================================================================== --- lldb/trunk/source/Core/Section.cpp (original) +++ lldb/trunk/source/Core/Section.cpp Wed Jul 21 16:49:46 2010 @@ -566,6 +566,23 @@ return sect_sp; } + +SectionSP +SectionList::FindSectionByType (lldb::SectionType sect_type, uint32_t start_idx) const +{ + SectionSP sect_sp; + uint32_t num_sections = m_sections.size(); + for (uint32_t idx = start_idx; idx < num_sections; ++idx) + { + if (m_sections[idx]->GetType() == sect_type) + { + sect_sp = m_sections[idx]; + break; + } + } + return sect_sp; +} + SectionSP SectionList::GetSharedPointer (const Section *section, bool check_children) const { From gclayton at apple.com Wed Jul 21 16:51:37 2010 From: gclayton at apple.com (Greg Clayton) Date: Wed, 21 Jul 2010 21:51:37 -0000 Subject: [Lldb-commits] [lldb] r109041 - /lldb/trunk/include/lldb/lldb-enumerations.h Message-ID: <20100721215137.509462A6C12C@llvm.org> Author: gclayton Date: Wed Jul 21 16:51:36 2010 New Revision: 109041 URL: http://llvm.org/viewvc/llvm-project?rev=109041&view=rev Log: Add new SectionType enumerations for all DWARF sections. ObjectFile parsers should start properly setting the section types for DWARF sections, then we can move the DWARF SymbolFile parser over to finding the sections by the appropriate SectionType. Modified: lldb/trunk/include/lldb/lldb-enumerations.h Modified: lldb/trunk/include/lldb/lldb-enumerations.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/lldb-enumerations.h?rev=109041&r1=109040&r2=109041&view=diff ============================================================================== --- lldb/trunk/include/lldb/lldb-enumerations.h (original) +++ lldb/trunk/include/lldb/lldb-enumerations.h Wed Jul 21 16:51:36 2010 @@ -367,6 +367,17 @@ eSectionTypeZeroFill, eSectionTypeDataObjCMessageRefs, // Pointer to function pointer + selector eSectionTypeDataObjCCFStrings, // Objective C const CFString/NSString objects + eSectionTypeDWARFDebugAbbrev, + eSectionTypeDWARFDebugAranges, + eSectionTypeDWARFDebugFrame, + eSectionTypeDWARFDebugInfo, + eSectionTypeDWARFDebugLine, + eSectionTypeDWARFDebugLoc, + eSectionTypeDWARFDebugMacInfo, + eSectionTypeDWARFDebugPubnames, + eSectionTypeDWARFDebugPubtypes, + eSectionTypeDWARFDebugRanges, + eSectionTypeDWARFDebugStr, eSectionTypeOther } SectionType; From gclayton at apple.com Wed Jul 21 17:54:27 2010 From: gclayton at apple.com (Greg Clayton) Date: Wed, 21 Jul 2010 22:54:27 -0000 Subject: [Lldb-commits] [lldb] r109054 - in /lldb/trunk: include/lldb/Core/Section.h include/lldb/lldb-enumerations.h source/Core/Section.cpp source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h Message-ID: <20100721225427.50D132A6C12C@llvm.org> Author: gclayton Date: Wed Jul 21 17:54:26 2010 New Revision: 109054 URL: http://llvm.org/viewvc/llvm-project?rev=109054&view=rev Log: Modified both the ObjectFileMachO and ObjectFileELF to correctly set the SectionType for Section objects for DWARF. Modified the DWARF plug-in to get the DWARF sections by SectionType so we can safely abstract the LLDB core from section names for the various object file formats. Modified the SectionType definitions for .debug_pubnames and .debug_pubtypes to use the correct case. Modified: lldb/trunk/include/lldb/Core/Section.h lldb/trunk/include/lldb/lldb-enumerations.h lldb/trunk/source/Core/Section.cpp lldb/trunk/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h Modified: lldb/trunk/include/lldb/Core/Section.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/Section.h?rev=109054&r1=109053&r2=109054&view=diff ============================================================================== --- lldb/trunk/include/lldb/Core/Section.h (original) +++ lldb/trunk/include/lldb/Core/Section.h Wed Jul 21 17:54:26 2010 @@ -55,7 +55,7 @@ FindSectionByID (lldb::user_id_t sect_id) const; lldb::SectionSP - FindSectionByType (lldb::SectionType sect_type, uint32_t start_idx = 0) const; + FindSectionByType (lldb::SectionType sect_type, bool check_children, uint32_t start_idx = 0) const; lldb::SectionSP GetSharedPointer (const Section *section, bool check_children) const; Modified: lldb/trunk/include/lldb/lldb-enumerations.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/lldb-enumerations.h?rev=109054&r1=109053&r2=109054&view=diff ============================================================================== --- lldb/trunk/include/lldb/lldb-enumerations.h (original) +++ lldb/trunk/include/lldb/lldb-enumerations.h Wed Jul 21 17:54:26 2010 @@ -374,10 +374,11 @@ eSectionTypeDWARFDebugLine, eSectionTypeDWARFDebugLoc, eSectionTypeDWARFDebugMacInfo, - eSectionTypeDWARFDebugPubnames, - eSectionTypeDWARFDebugPubtypes, + eSectionTypeDWARFDebugPubNames, + eSectionTypeDWARFDebugPubTypes, eSectionTypeDWARFDebugRanges, eSectionTypeDWARFDebugStr, + eSectionTypeEHFrame, eSectionTypeOther } SectionType; Modified: lldb/trunk/source/Core/Section.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/Section.cpp?rev=109054&r1=109053&r2=109054&view=diff ============================================================================== --- lldb/trunk/source/Core/Section.cpp (original) +++ lldb/trunk/source/Core/Section.cpp Wed Jul 21 17:54:26 2010 @@ -568,7 +568,7 @@ SectionSP -SectionList::FindSectionByType (lldb::SectionType sect_type, uint32_t start_idx) const +SectionList::FindSectionByType (lldb::SectionType sect_type, bool check_children, uint32_t start_idx) const { SectionSP sect_sp; uint32_t num_sections = m_sections.size(); @@ -579,6 +579,12 @@ sect_sp = m_sections[idx]; break; } + else if (check_children) + { + sect_sp = m_sections[idx]->GetChildren().FindSectionByType (sect_type, check_children, 0); + if (sect_sp) + break; + } } return sect_sp; } Modified: lldb/trunk/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp?rev=109054&r1=109053&r2=109054&view=diff ============================================================================== --- lldb/trunk/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp (original) +++ lldb/trunk/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp Wed Jul 21 17:54:26 2010 @@ -421,17 +421,52 @@ ConstString name(m_shstr_data.PeekCStr(header.sh_name)); uint64_t size = header.sh_type == SHT_NOBITS ? 0 : header.sh_size; + static ConstString g_sect_name_text (".text"); + static ConstString g_sect_name_data (".data"); + static ConstString g_sect_name_bss (".bss"); + static ConstString g_sect_name_dwarf_debug_abbrev (".debug_abbrev"); + static ConstString g_sect_name_dwarf_debug_aranges (".debug_aranges"); + static ConstString g_sect_name_dwarf_debug_frame (".debug_frame"); + static ConstString g_sect_name_dwarf_debug_info (".debug_info"); + static ConstString g_sect_name_dwarf_debug_line (".debug_line"); + static ConstString g_sect_name_dwarf_debug_loc (".debug_loc"); + static ConstString g_sect_name_dwarf_debug_macinfo (".debug_macinfo"); + static ConstString g_sect_name_dwarf_debug_pubnames (".debug_pubnames"); + static ConstString g_sect_name_dwarf_debug_pubtypes (".debug_pubtypes"); + static ConstString g_sect_name_dwarf_debug_ranges (".debug_ranges"); + static ConstString g_sect_name_dwarf_debug_str (".debug_str"); + static ConstString g_sect_name_eh_frame (".eh_frame"); + + SectionType sect_type = eSectionTypeOther; + + if (name == g_sect_name_text) sect_type = eSectionTypeCode; + else if (name == g_sect_name_data) sect_type = eSectionTypeData; + else if (name == g_sect_name_bss) sect_type = eSectionTypeZeroFill; + else if (name == g_sect_name_dwarf_debug_abbrev) sect_type = eSectionTypeDWARFDebugAbbrev; + else if (name == g_sect_name_dwarf_debug_aranges) sect_type = eSectionTypeDWARFDebugAranges; + else if (name == g_sect_name_dwarf_debug_frame) sect_type = eSectionTypeDWARFDebugFrame; + else if (name == g_sect_name_dwarf_debug_info) sect_type = eSectionTypeDWARFDebugInfo; + else if (name == g_sect_name_dwarf_debug_line) sect_type = eSectionTypeDWARFDebugLine; + else if (name == g_sect_name_dwarf_debug_loc) sect_type = eSectionTypeDWARFDebugLoc; + else if (name == g_sect_name_dwarf_debug_macinfo) sect_type = eSectionTypeDWARFDebugMacInfo; + else if (name == g_sect_name_dwarf_debug_pubnames) sect_type = eSectionTypeDWARFDebugPubNames; + else if (name == g_sect_name_dwarf_debug_pubtypes) sect_type = eSectionTypeDWARFDebugPubTypes; + else if (name == g_sect_name_dwarf_debug_ranges) sect_type = eSectionTypeDWARFDebugRanges; + else if (name == g_sect_name_dwarf_debug_str) sect_type = eSectionTypeDWARFDebugStr; + else if (name == g_sect_name_eh_frame) sect_type = eSectionTypeEHFrame; + + SectionSP section(new Section( - 0, // Parent section. - GetModule(), // Module to which this section belongs. - SectionIndex(I), // Section ID. - name, // Section name. - eSectionTypeOther, // FIXME: Fill in as appropriate. - header.sh_addr, // VM address. - header.sh_size, // VM size in bytes of this section. - header.sh_offset, // Offset of this section in the file. - size, // Size of the section as found in the file. - header.sh_flags)); // Flags for this section. + 0, // Parent section. + GetModule(), // Module to which this section belongs. + SectionIndex(I), // Section ID. + name, // Section name. + sect_type, // Section type. + header.sh_addr, // VM address. + header.sh_size, // VM size in bytes of this section. + header.sh_offset, // Offset of this section in the file. + size, // Size of the section as found in the file. + header.sh_flags)); // Flags for this section. m_sections_ap->AddSection(section); } Modified: lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp?rev=109054&r1=109053&r2=109054&view=diff ============================================================================== --- lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp (original) +++ lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp Wed Jul 21 17:54:26 2010 @@ -373,16 +373,53 @@ static ConstString g_sect_name_objc_const ("__objc_const"); static ConstString g_sect_name_objc_classlist ("__objc_classlist"); static ConstString g_sect_name_cfstring ("__cfstring"); + + static ConstString g_sect_name_dwarf_debug_abbrev ("__debug_abbrev"); + static ConstString g_sect_name_dwarf_debug_aranges ("__debug_aranges"); + static ConstString g_sect_name_dwarf_debug_frame ("__debug_frame"); + static ConstString g_sect_name_dwarf_debug_info ("__debug_info"); + static ConstString g_sect_name_dwarf_debug_line ("__debug_line"); + static ConstString g_sect_name_dwarf_debug_loc ("__debug_loc"); + static ConstString g_sect_name_dwarf_debug_macinfo ("__debug_macinfo"); + static ConstString g_sect_name_dwarf_debug_pubnames ("__debug_pubnames"); + static ConstString g_sect_name_dwarf_debug_pubtypes ("__debug_pubtypes"); + static ConstString g_sect_name_dwarf_debug_ranges ("__debug_ranges"); + static ConstString g_sect_name_dwarf_debug_str ("__debug_str"); + static ConstString g_sect_name_eh_frame ("__eh_frame"); + SectionType sect_type = eSectionTypeOther; - if (section_name == g_sect_name_objc_selrefs) - { + + if (section_name == g_sect_name_dwarf_debug_abbrev) + sect_type = eSectionTypeDWARFDebugAbbrev; + else if (section_name == g_sect_name_dwarf_debug_aranges) + sect_type = eSectionTypeDWARFDebugAranges; + else if (section_name == g_sect_name_dwarf_debug_frame) + sect_type = eSectionTypeDWARFDebugFrame; + else if (section_name == g_sect_name_dwarf_debug_info) + sect_type = eSectionTypeDWARFDebugInfo; + else if (section_name == g_sect_name_dwarf_debug_line) + sect_type = eSectionTypeDWARFDebugLine; + else if (section_name == g_sect_name_dwarf_debug_loc) + sect_type = eSectionTypeDWARFDebugLoc; + else if (section_name == g_sect_name_dwarf_debug_macinfo) + sect_type = eSectionTypeDWARFDebugMacInfo; + else if (section_name == g_sect_name_dwarf_debug_pubnames) + sect_type = eSectionTypeDWARFDebugPubNames; + else if (section_name == g_sect_name_dwarf_debug_pubtypes) + sect_type = eSectionTypeDWARFDebugPubTypes; + else if (section_name == g_sect_name_dwarf_debug_ranges) + sect_type = eSectionTypeDWARFDebugRanges; + else if (section_name == g_sect_name_dwarf_debug_str) + sect_type = eSectionTypeDWARFDebugStr; + else if (section_name == g_sect_name_objc_selrefs) sect_type = eSectionTypeDataCStringPointers; - } else if (section_name == g_sect_name_objc_msgrefs) - { sect_type = eSectionTypeDataObjCMessageRefs; - } + else if (section_name == g_sect_name_eh_frame) + sect_type = eSectionTypeEHFrame; + else if (section_name == g_sect_name_cfstring) + sect_type = eSectionTypeDataObjCCFStrings; else if (section_name == g_sect_name_objc_data || section_name == g_sect_name_objc_classrefs || section_name == g_sect_name_objc_superrefs || @@ -391,10 +428,6 @@ { sect_type = eSectionTypeDataPointers; } - else if (section_name == g_sect_name_cfstring) - { - sect_type = eSectionTypeDataObjCCFStrings; - } if (sect_type == eSectionTypeOther) { Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp?rev=109054&r1=109053&r2=109054&view=diff ============================================================================== --- lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp (original) +++ lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp Wed Jul 21 17:54:26 2010 @@ -57,83 +57,6 @@ using namespace lldb_private; -static const ConstString& -GetSectionNameDebugInfo() -{ - static const ConstString g_sect_name("__debug_info"); - return g_sect_name; -} - -static const ConstString& -GetSectionNameDebugAbbrev() -{ - static const ConstString g_sect_name ("__debug_abbrev"); - return g_sect_name; -} - -static const ConstString& -GetSectionNameDebugAranges() -{ - static const ConstString g_sect_name ("__debug_aranges"); - return g_sect_name; -} - -static const ConstString& -GetSectionNameDebugFrame() -{ - static const ConstString g_sect_name ("__debug_frame"); - return g_sect_name; -} - -static const ConstString& -GetSectionNameDebugLine() -{ - static const ConstString g_sect_name ("__debug_line"); - return g_sect_name; -} - -static const ConstString& -GetSectionNameDebugLoc() -{ - static const ConstString g_sect_name ("__debug_loc"); - return g_sect_name; -} - -static const ConstString& -GetSectionNameDebugMacInfo() -{ - static const ConstString g_sect_name ("__debug_macinfo"); - return g_sect_name; -} - -static const ConstString& -GetSectionNameDebugPubNames() -{ - static const ConstString g_sect_name ("__debug_pubnames"); - return g_sect_name; -} - -static const ConstString& -GetSectionNameDebugPubTypes() -{ - static const ConstString g_sect_name ("__debug_pubtypes"); - return g_sect_name; -} - -static const ConstString& -GetSectionNameDebugRanges() -{ - static const ConstString g_sect_name ("__debug_ranges"); - return g_sect_name; -} - -static const ConstString& -GetSectionNameDebugStr() -{ - static const ConstString g_sect_name ("__debug_str"); - return g_sect_name; -} - static uint32_t DwarfToClangAccessibility (uint32_t dwarf_accessibility) { @@ -283,68 +206,71 @@ section = section_list->FindSectionByName(g_dwarf_section_name).get(); if (section) + { section->MemoryMapSectionDataFromObjectFile(m_obj_file, m_dwarf_data); + section_list = §ion->GetChildren (); + } - section = section_list->FindSectionByName (GetSectionNameDebugInfo()).get(); + section = section_list->FindSectionByType (eSectionTypeDWARFDebugInfo, true).get(); if (section != NULL) { debug_info_file_size = section->GetByteSize(); - section = section_list->FindSectionByName (GetSectionNameDebugAbbrev()).get(); + section = section_list->FindSectionByType (eSectionTypeDWARFDebugAbbrev, true).get(); if (section) debug_abbrev_file_size = section->GetByteSize(); else m_flags.Set (flagsGotDebugAbbrevData); - section = section_list->FindSectionByName (GetSectionNameDebugAranges()).get(); + section = section_list->FindSectionByType (eSectionTypeDWARFDebugAranges, true).get(); if (section) debug_aranges_file_size = section->GetByteSize(); else m_flags.Set (flagsGotDebugArangesData); - section = section_list->FindSectionByName (GetSectionNameDebugFrame()).get(); + section = section_list->FindSectionByType (eSectionTypeDWARFDebugFrame, true).get(); if (section) debug_frame_file_size = section->GetByteSize(); else m_flags.Set (flagsGotDebugFrameData); - section = section_list->FindSectionByName (GetSectionNameDebugLine()).get(); + section = section_list->FindSectionByType (eSectionTypeDWARFDebugLine, true).get(); if (section) debug_line_file_size = section->GetByteSize(); else m_flags.Set (flagsGotDebugLineData); - section = section_list->FindSectionByName (GetSectionNameDebugLoc()).get(); + section = section_list->FindSectionByType (eSectionTypeDWARFDebugLoc, true).get(); if (section) debug_loc_file_size = section->GetByteSize(); else m_flags.Set (flagsGotDebugLocData); - section = section_list->FindSectionByName (GetSectionNameDebugMacInfo()).get(); + section = section_list->FindSectionByType (eSectionTypeDWARFDebugMacInfo, true).get(); if (section) debug_macinfo_file_size = section->GetByteSize(); else m_flags.Set (flagsGotDebugMacInfoData); - section = section_list->FindSectionByName (GetSectionNameDebugPubNames()).get(); + section = section_list->FindSectionByType (eSectionTypeDWARFDebugPubNames, true).get(); if (section) debug_pubnames_file_size = section->GetByteSize(); else m_flags.Set (flagsGotDebugPubNamesData); - section = section_list->FindSectionByName (GetSectionNameDebugPubTypes()).get(); + section = section_list->FindSectionByType (eSectionTypeDWARFDebugPubTypes, true).get(); if (section) debug_pubtypes_file_size = section->GetByteSize(); else m_flags.Set (flagsGotDebugPubTypesData); - section = section_list->FindSectionByName (GetSectionNameDebugRanges()).get(); + section = section_list->FindSectionByType (eSectionTypeDWARFDebugRanges, true).get(); if (section) debug_ranges_file_size = section->GetByteSize(); else m_flags.Set (flagsGotDebugRangesData); - section = section_list->FindSectionByName (GetSectionNameDebugStr()).get(); + section = section_list->FindSectionByType (eSectionTypeDWARFDebugStr, true).get(); if (section) debug_str_file_size = section->GetByteSize(); else @@ -376,7 +302,7 @@ } const DataExtractor& -SymbolFileDWARF::GetCachedSectionData (uint32_t got_flag, const ConstString §ion_name, DataExtractor &data) +SymbolFileDWARF::GetCachedSectionData (uint32_t got_flag, SectionType sect_type, DataExtractor &data) { if (m_flags.IsClear (got_flag)) { @@ -384,8 +310,8 @@ const SectionList *section_list = m_obj_file->GetSectionList(); if (section_list) { - Section *section = section_list->FindSectionByName (section_name).get(); - if (section ) + Section *section = section_list->FindSectionByType(sect_type, true).get(); + if (section) { // See if we memory mapped the DWARF segment? if (m_dwarf_data.GetByteSize()) @@ -406,67 +332,67 @@ const DataExtractor& SymbolFileDWARF::get_debug_abbrev_data() { - return GetCachedSectionData (flagsGotDebugAbbrevData, GetSectionNameDebugAbbrev(), m_data_debug_abbrev); + return GetCachedSectionData (flagsGotDebugAbbrevData, eSectionTypeDWARFDebugAbbrev, m_data_debug_abbrev); } const DataExtractor& SymbolFileDWARF::get_debug_aranges_data() { - return GetCachedSectionData (flagsGotDebugArangesData, GetSectionNameDebugAranges(), m_data_debug_aranges); + return GetCachedSectionData (flagsGotDebugArangesData, eSectionTypeDWARFDebugAranges, m_data_debug_aranges); } const DataExtractor& SymbolFileDWARF::get_debug_frame_data() { - return GetCachedSectionData (flagsGotDebugFrameData, GetSectionNameDebugFrame(), m_data_debug_frame); + return GetCachedSectionData (flagsGotDebugFrameData, eSectionTypeDWARFDebugFrame, m_data_debug_frame); } const DataExtractor& SymbolFileDWARF::get_debug_info_data() { - return GetCachedSectionData (flagsGotDebugInfoData, GetSectionNameDebugInfo(), m_data_debug_info); + return GetCachedSectionData (flagsGotDebugInfoData, eSectionTypeDWARFDebugInfo, m_data_debug_info); } const DataExtractor& SymbolFileDWARF::get_debug_line_data() { - return GetCachedSectionData (flagsGotDebugLineData, GetSectionNameDebugLine(), m_data_debug_line); + return GetCachedSectionData (flagsGotDebugLineData, eSectionTypeDWARFDebugLine, m_data_debug_line); } const DataExtractor& SymbolFileDWARF::get_debug_loc_data() { - return GetCachedSectionData (flagsGotDebugLocData, GetSectionNameDebugLoc(), m_data_debug_loc); + return GetCachedSectionData (flagsGotDebugLocData, eSectionTypeDWARFDebugLoc, m_data_debug_loc); } const DataExtractor& SymbolFileDWARF::get_debug_macinfo_data() { - return GetCachedSectionData (flagsGotDebugMacInfoData, GetSectionNameDebugMacInfo(), m_data_debug_macinfo); + return GetCachedSectionData (flagsGotDebugMacInfoData, eSectionTypeDWARFDebugMacInfo, m_data_debug_macinfo); } const DataExtractor& SymbolFileDWARF::get_debug_pubnames_data() { - return GetCachedSectionData (flagsGotDebugPubNamesData, GetSectionNameDebugPubNames(), m_data_debug_pubnames); + return GetCachedSectionData (flagsGotDebugPubNamesData, eSectionTypeDWARFDebugPubNames, m_data_debug_pubnames); } const DataExtractor& SymbolFileDWARF::get_debug_pubtypes_data() { - return GetCachedSectionData (flagsGotDebugPubTypesData, GetSectionNameDebugPubTypes(), m_data_debug_pubtypes); + return GetCachedSectionData (flagsGotDebugPubTypesData, eSectionTypeDWARFDebugPubTypes, m_data_debug_pubtypes); } const DataExtractor& SymbolFileDWARF::get_debug_ranges_data() { - return GetCachedSectionData (flagsGotDebugRangesData, GetSectionNameDebugRanges(), m_data_debug_ranges); + return GetCachedSectionData (flagsGotDebugRangesData, eSectionTypeDWARFDebugRanges, m_data_debug_ranges); } const DataExtractor& SymbolFileDWARF::get_debug_str_data() { - return GetCachedSectionData (flagsGotDebugStrData, GetSectionNameDebugStr(), m_data_debug_str); + return GetCachedSectionData (flagsGotDebugStrData, eSectionTypeDWARFDebugStr, m_data_debug_str); } Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h?rev=109054&r1=109053&r2=109054&view=diff ============================================================================== --- lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h (original) +++ lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h Wed Jul 21 17:54:26 2010 @@ -170,9 +170,10 @@ const DWARFDebugRanges* DebugRanges() const; const lldb_private::DataExtractor& - GetCachedSectionData (uint32_t got_flag, const lldb_private::ConstString §ion_name, lldb_private::DataExtractor &data); + GetCachedSectionData (uint32_t got_flag, lldb::SectionType sect_type, lldb_private::DataExtractor &data); - static bool SupportedVersion(uint16_t version); + static bool + SupportedVersion(uint16_t version); clang::DeclContext * GetClangDeclContextForDIE (const DWARFCompileUnit *cu, const DWARFDebugInfoEntry *die); From gclayton at apple.com Wed Jul 21 17:12:05 2010 From: gclayton at apple.com (Greg Clayton) Date: Wed, 21 Jul 2010 22:12:05 -0000 Subject: [Lldb-commits] [lldb] r109046 - in /lldb/trunk: include/lldb/Core/ include/lldb/Expression/ include/lldb/Symbol/ lldb.xcodeproj/ source/Commands/ source/Core/ source/Expression/ source/Host/macosx/ source/Plugins/DynamicLoader/MacOSX-DYLD/ source/Plugins/ObjectContainer/Universal-Mach-O/ source/Plugins/ObjectFile/Mach-O/ source/Plugins/Process/gdb-remote/ source/Plugins/SymbolVendor/MacOSX/ source/Symbol/ Message-ID: <20100721221205.CAE382A6C12C@llvm.org> Author: gclayton Date: Wed Jul 21 17:12:05 2010 New Revision: 109046 URL: http://llvm.org/viewvc/llvm-project?rev=109046&view=rev Log: Change over to using the definitions for mach-o types and defines to the defines that are in "llvm/Support/MachO.h". This should allow ObjectFileMachO and ObjectContainerUniversalMachO to be able to be cross compiled in Linux. Also did some cleanup on the ASTType by renaming it to ClangASTType and renaming the header file. Moved a lot of "AST * + opaque clang type *" functionality from lldb_private::Type over into ClangASTType. Added: lldb/trunk/include/lldb/Symbol/ClangASTType.h - copied, changed from r109016, lldb/trunk/include/lldb/Symbol/ASTType.h lldb/trunk/source/Symbol/ClangASTType.cpp - copied, changed from r109016, lldb/trunk/source/Symbol/ASTType.cpp Removed: lldb/trunk/include/lldb/Symbol/ASTType.h lldb/trunk/source/Symbol/ASTType.cpp Modified: lldb/trunk/include/lldb/Core/ClangForward.h lldb/trunk/include/lldb/Expression/ClangExpressionDeclMap.h lldb/trunk/include/lldb/Expression/ClangFunction.h lldb/trunk/include/lldb/Expression/ClangResultSynthesizer.h lldb/trunk/include/lldb/Symbol/ClangASTContext.h lldb/trunk/include/lldb/Symbol/Type.h lldb/trunk/lldb.xcodeproj/project.pbxproj lldb/trunk/source/Commands/CommandObjectExpression.cpp lldb/trunk/source/Commands/CommandObjectVariable.cpp lldb/trunk/source/Core/Value.cpp lldb/trunk/source/Core/ValueObject.cpp lldb/trunk/source/Core/ValueObjectChild.cpp lldb/trunk/source/Core/ValueObjectRegister.cpp lldb/trunk/source/Expression/ClangExpression.cpp lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp lldb/trunk/source/Expression/DWARFExpression.cpp lldb/trunk/source/Host/macosx/Symbols.cpp lldb/trunk/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.cpp lldb/trunk/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.h lldb/trunk/source/Plugins/ObjectContainer/Universal-Mach-O/ObjectContainerUniversalMachO.cpp lldb/trunk/source/Plugins/ObjectContainer/Universal-Mach-O/ObjectContainerUniversalMachO.h lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.h lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp lldb/trunk/source/Plugins/SymbolVendor/MacOSX/SymbolVendorMacOSX.cpp lldb/trunk/source/Symbol/ClangASTContext.cpp lldb/trunk/source/Symbol/Function.cpp lldb/trunk/source/Symbol/Type.cpp Modified: lldb/trunk/include/lldb/Core/ClangForward.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/ClangForward.h?rev=109046&r1=109045&r2=109046&view=diff ============================================================================== --- lldb/trunk/include/lldb/Core/ClangForward.h (original) +++ lldb/trunk/include/lldb/Core/ClangForward.h Wed Jul 21 17:12:05 2010 @@ -24,9 +24,13 @@ class Context; } + class Action; class ASTContext; + class ASTRecordLayout; class AddrLabelExpr; + class AnalyzerOptions; class BinaryOperator; + class CodeGenOptions; class CodeGenerator; class CompilerInstance; class CXXBaseSpecifier; @@ -38,18 +42,23 @@ class CharacterLiteral; class CompoundAssignOperator; class Decl; + class DeclarationName; class DeclaratorDecl; class DeclContext; class DeclRefExpr; class DeclStmt; + class DependencyOutputOptions; class Diagnostic; + class DiagnosticOptions; class EnumDecl; class Expr; class ExtVectorElementExpr; class FieldDecl; class FloatingLiteral; + class FrontendOptions; class FunctionDecl; class GotoStmt; + class HeaderSearchOptions; class IdentifierTable; class IntegerLiteral; class LabelStmt; @@ -72,6 +81,8 @@ class ParenExpr; class ParmVarDecl; class PredefinedExpr; + class PreprocessorOptions; + class PreprocessorOutputOptions; class QualType; class QualifiedNameType; class RecordDecl; Modified: lldb/trunk/include/lldb/Expression/ClangExpressionDeclMap.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Expression/ClangExpressionDeclMap.h?rev=109046&r1=109045&r2=109046&view=diff ============================================================================== --- lldb/trunk/include/lldb/Expression/ClangExpressionDeclMap.h (original) +++ lldb/trunk/include/lldb/Expression/ClangExpressionDeclMap.h Wed Jul 21 17:12:05 2010 @@ -21,13 +21,7 @@ // Project includes #include "lldb/Core/ClangForward.h" #include "lldb/Core/Value.h" -#include "lldb/Symbol/ASTType.h" - -namespace clang { - class DeclarationName; - class DeclContext; - class QualType; -} +#include "lldb/Symbol/ClangASTType.h" namespace llvm { class Value; @@ -35,6 +29,33 @@ namespace lldb_private { +//---------------------------------------------------------------------- +// For cases in which there are multiple classes of types that are not +// interchangeable, to allow static type checking. +//---------------------------------------------------------------------- +template class TaggedClangASTType : public ClangASTType +{ +public: + TaggedClangASTType (void *type, clang::ASTContext *ast_context) : + ClangASTType(type, ast_context) { } + + TaggedClangASTType (const TaggedClangASTType &tw) : + ClangASTType(tw) { } + + TaggedClangASTType () : + ClangASTType() { } + + ~TaggedClangASTType() { } + + const TaggedClangASTType & + operator= (const TaggedClangASTType &tw) + { + ClangASTType::operator= (tw); + return *this; + } +}; + + class Error; class Function; class NameSearchContext; @@ -83,8 +104,8 @@ void GetDecls (NameSearchContext &context, const char *name); private: - typedef TaggedASTType<0> TypeFromParser; - typedef TaggedASTType<1> TypeFromUser; + typedef TaggedClangASTType<0> TypeFromParser; + typedef TaggedClangASTType<1> TypeFromUser; struct Tuple { Modified: lldb/trunk/include/lldb/Expression/ClangFunction.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Expression/ClangFunction.h?rev=109046&r1=109045&r2=109046&view=diff ============================================================================== --- lldb/trunk/include/lldb/Expression/ClangFunction.h (original) +++ lldb/trunk/include/lldb/Expression/ClangFunction.h Wed Jul 21 17:12:05 2010 @@ -26,11 +26,6 @@ // Right now, this is just a toy. It calls a set function, with fixed // values. -namespace clang -{ - class ASTRecordLayout; -} - namespace lldb_private { Modified: lldb/trunk/include/lldb/Expression/ClangResultSynthesizer.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Expression/ClangResultSynthesizer.h?rev=109046&r1=109045&r2=109046&view=diff ============================================================================== --- lldb/trunk/include/lldb/Expression/ClangResultSynthesizer.h (original) +++ lldb/trunk/include/lldb/Expression/ClangResultSynthesizer.h Wed Jul 21 17:12:05 2010 @@ -11,10 +11,7 @@ #define liblldb_ClangResultSynthesizer_h_ #include "clang/Sema/SemaConsumer.h" - -namespace clang { - class Action; -} +#include "lldb/Core/ClangForward.h" namespace lldb_private { Removed: lldb/trunk/include/lldb/Symbol/ASTType.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Symbol/ASTType.h?rev=109045&view=auto ============================================================================== --- lldb/trunk/include/lldb/Symbol/ASTType.h (original) +++ lldb/trunk/include/lldb/Symbol/ASTType.h (removed) @@ -1,113 +0,0 @@ -//===-- ASTType.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_ASTType_h_ -#define liblldb_ASTType_h_ - -namespace clang -{ - class ASTContext; -} - -namespace lldb_private -{ - -class ASTTypeBase -{ -protected: - ASTTypeBase (void *type, clang::ASTContext *ast_context) : - m_type(type), - m_ast_context(ast_context) - { - } - - ASTTypeBase (const ASTTypeBase &tw) : - m_type(tw.m_type), - m_ast_context(tw.m_ast_context) - { - } - - ASTTypeBase () : - m_type(0), - m_ast_context(0) - { - } - - ~ASTTypeBase(); - - ASTTypeBase &operator= (const ASTTypeBase &atb) - { - m_type = atb.m_type; - m_ast_context = atb.m_ast_context; - return *this; - } - -public: - void *GetType() const - { - return m_type; - } - - clang::ASTContext *GetASTContext() const - { - return m_ast_context; - } - -private: - void *m_type; - clang::ASTContext *m_ast_context; -}; - -class ASTType : public ASTTypeBase -{ -public: - ASTType (void *type, clang::ASTContext *ast_context) : - ASTTypeBase(type, ast_context) { } - - ASTType (const ASTType &at) : - ASTTypeBase(at) { } - - ASTType () : - ASTTypeBase() { } - - ~ASTType(); - - ASTType &operator= (const ASTType &at) - { - ASTTypeBase::operator= (at); - return *this; - } -}; - -// For cases in which there are multiple classes of types that are not -// interchangeable, to allow static type checking. -template class TaggedASTType : public ASTTypeBase -{ -public: - TaggedASTType (void *type, clang::ASTContext *ast_context) : - ASTTypeBase(type, ast_context) { } - - TaggedASTType (const TaggedASTType &tw) : - ASTTypeBase(tw) { } - - TaggedASTType () : - ASTTypeBase() { } - - ~TaggedASTType() { } - - TaggedASTType &operator= (const TaggedASTType &tw) - { - ASTTypeBase::operator= (tw); - return *this; - } -}; - -} - -#endif Modified: lldb/trunk/include/lldb/Symbol/ClangASTContext.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Symbol/ClangASTContext.h?rev=109046&r1=109045&r2=109046&view=diff ============================================================================== --- lldb/trunk/include/lldb/Symbol/ClangASTContext.h (original) +++ lldb/trunk/include/lldb/Symbol/ClangASTContext.h Wed Jul 21 17:12:05 2010 @@ -21,7 +21,7 @@ // Project includes #include "lldb/lldb-enumerations.h" #include "lldb/Core/ClangForward.h" -#include "lldb/Symbol/ASTType.h" +#include "lldb/Symbol/ClangASTType.h" namespace lldb_private { Copied: lldb/trunk/include/lldb/Symbol/ClangASTType.h (from r109016, lldb/trunk/include/lldb/Symbol/ASTType.h) URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Symbol/ClangASTType.h?p2=lldb/trunk/include/lldb/Symbol/ClangASTType.h&p1=lldb/trunk/include/lldb/Symbol/ASTType.h&r1=109016&r2=109046&rev=109046&view=diff ============================================================================== --- lldb/trunk/include/lldb/Symbol/ASTType.h (original) +++ lldb/trunk/include/lldb/Symbol/ClangASTType.h Wed Jul 21 17:12:05 2010 @@ -1,4 +1,4 @@ -//===-- ASTType.h -----------------------------------------------*- C++ -*-===// +//===-- ClangASTType.h ------------------------------------------*- C++ -*-===// // // The LLVM Compiler Infrastructure // @@ -7,107 +7,213 @@ // //===----------------------------------------------------------------------===// -#ifndef liblldb_ASTType_h_ -#define liblldb_ASTType_h_ +#ifndef liblldb_ClangASTType_h_ +#define liblldb_ClangASTType_h_ -namespace clang -{ - class ASTContext; -} +#include "lldb/lldb-include.h" +#include "lldb/Core/ClangForward.h" -namespace lldb_private -{ - -class ASTTypeBase +namespace lldb_private { + +//---------------------------------------------------------------------- +// A class that can carry around a clang ASTContext and a opaque clang +// QualType. A clang::QualType can be easily reconstructed from an +// opaque clang type and often the ASTContext is needed when doing +// various type related tasks, so this class allows both items to travel +// in a single very lightweight class that can be used. There are many +// static equivalents of the member functions that allow the ASTContext +// and the opaque clang QualType to be specified for ease of use and +// to avoid code duplication. +//---------------------------------------------------------------------- +class ClangASTType { protected: - ASTTypeBase (void *type, clang::ASTContext *ast_context) : - m_type(type), - m_ast_context(ast_context) + ClangASTType (void *type, clang::ASTContext *ast_context) : + m_type (type), + m_ast (ast_context) { } - ASTTypeBase (const ASTTypeBase &tw) : - m_type(tw.m_type), - m_ast_context(tw.m_ast_context) + ClangASTType (const ClangASTType &tw) : + m_type (tw.m_type), + m_ast (tw.m_ast) { } - ASTTypeBase () : - m_type(0), - m_ast_context(0) + ClangASTType () : + m_type (0), + m_ast (0) { } - ~ASTTypeBase(); + ~ClangASTType(); - ASTTypeBase &operator= (const ASTTypeBase &atb) + const ClangASTType & + operator= (const ClangASTType &atb) { m_type = atb.m_type; - m_ast_context = atb.m_ast_context; + m_ast = atb.m_ast; return *this; } public: - void *GetType() const + void * + GetOpaqueQualType() const { return m_type; } - clang::ASTContext *GetASTContext() const + clang::ASTContext * + GetASTContext() const { - return m_ast_context; + return m_ast; } - + + ConstString + GetClangTypeName (); + + static ConstString + GetClangTypeName (void *clang_type); + + void + DumpValue (ExecutionContext *exe_ctx, + Stream *s, + lldb::Format format, + const DataExtractor &data, + uint32_t data_offset, + size_t data_byte_size, + uint32_t bitfield_bit_size, + uint32_t bitfield_bit_offset, + bool show_types, + bool show_summary, + bool verbose, + uint32_t depth); + + static void + DumpValue (clang::ASTContext *ast_context, + void *opaque_clang_qual_type, + ExecutionContext *exe_ctx, + Stream *s, + lldb::Format format, + const DataExtractor &data, + uint32_t data_offset, + size_t data_byte_size, + uint32_t bitfield_bit_size, + uint32_t bitfield_bit_offset, + bool show_types, + bool show_summary, + bool verbose, + uint32_t depth); + + bool + DumpTypeValue (Stream *s, + lldb::Format format, + const DataExtractor &data, + uint32_t data_offset, + size_t data_byte_size, + uint32_t bitfield_bit_size, + uint32_t bitfield_bit_offset); + + + static bool + DumpTypeValue (clang::ASTContext *ast_context, + void *opaque_clang_qual_type, + Stream *s, + lldb::Format format, + const DataExtractor &data, + uint32_t data_offset, + size_t data_byte_size, + uint32_t bitfield_bit_size, + uint32_t bitfield_bit_offset); + + void + DumpSummary (ExecutionContext *exe_ctx, + Stream *s, + const DataExtractor &data, + uint32_t data_offset, + size_t data_byte_size); + + + static void + DumpSummary (clang::ASTContext *ast_context, + void *opaque_clang_qual_type, + ExecutionContext *exe_ctx, + Stream *s, + const DataExtractor &data, + uint32_t data_offset, + size_t data_byte_size); + + + lldb::Encoding + GetEncoding (uint32_t &count); + + static lldb::Encoding + GetEncoding (void *opaque_clang_qual_type, uint32_t &count); + + lldb::Format + GetFormat (); + + static lldb::Format + GetFormat (void *opaque_clang_qual_type); + + bool + GetValueAsScalar (const DataExtractor &data, + uint32_t data_offset, + size_t data_byte_size, + Scalar &value); + + static bool + GetValueAsScalar (clang::ASTContext *ast_context, + void *opaque_clang_qual_type, + const DataExtractor &data, + uint32_t data_offset, + size_t data_byte_size, + Scalar &value); + + bool + SetValueFromScalar (const Scalar &value, + Stream &strm); + + static bool + SetValueFromScalar (clang::ASTContext *ast_context, + void *opaque_clang_qual_type, + const Scalar &value, + Stream &strm); + + bool + ReadFromMemory (ExecutionContext *exe_ctx, + lldb::addr_t addr, + lldb::AddressType address_type, + DataExtractor &data); + + static bool + ReadFromMemory (clang::ASTContext *ast_context, + void *opaque_clang_qual_type, + ExecutionContext *exe_ctx, + lldb::addr_t addr, + lldb::AddressType address_type, + DataExtractor &data); + + bool + WriteToMemory (ExecutionContext *exe_ctx, + lldb::addr_t addr, + lldb::AddressType address_type, + StreamString &new_value); + + static bool + WriteToMemory (clang::ASTContext *ast_context, + void *opaque_clang_qual_type, + ExecutionContext *exe_ctx, + lldb::addr_t addr, + lldb::AddressType address_type, + StreamString &new_value); + private: void *m_type; - clang::ASTContext *m_ast_context; -}; - -class ASTType : public ASTTypeBase -{ -public: - ASTType (void *type, clang::ASTContext *ast_context) : - ASTTypeBase(type, ast_context) { } - - ASTType (const ASTType &at) : - ASTTypeBase(at) { } - - ASTType () : - ASTTypeBase() { } - - ~ASTType(); - - ASTType &operator= (const ASTType &at) - { - ASTTypeBase::operator= (at); - return *this; - } + clang::ASTContext *m_ast; }; - -// For cases in which there are multiple classes of types that are not -// interchangeable, to allow static type checking. -template class TaggedASTType : public ASTTypeBase -{ -public: - TaggedASTType (void *type, clang::ASTContext *ast_context) : - ASTTypeBase(type, ast_context) { } - - TaggedASTType (const TaggedASTType &tw) : - ASTTypeBase(tw) { } - - TaggedASTType () : - ASTTypeBase() { } - ~TaggedASTType() { } - - TaggedASTType &operator= (const TaggedASTType &tw) - { - ASTTypeBase::operator= (tw); - return *this; - } -}; -} +} // namespace lldb_private -#endif +#endif // #ifndef liblldb_ClangASTType_h_ Modified: lldb/trunk/include/lldb/Symbol/Type.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Symbol/Type.h?rev=109046&r1=109045&r2=109046&view=diff ============================================================================== --- lldb/trunk/include/lldb/Symbol/Type.h (original) +++ lldb/trunk/include/lldb/Symbol/Type.h Wed Jul 21 17:12:05 2010 @@ -103,35 +103,6 @@ return m_name; } - static ConstString - GetClangTypeName (void *clang_qual_type); - - static void - DumpValue(ExecutionContext *exe_ctx, - clang::ASTContext *ast_context, - void *clang_qual_type, - Stream *s, - lldb::Format format, - const DataExtractor &data, - uint32_t data_offset, - size_t data_byte_size, - uint32_t bitfield_bit_size, - uint32_t bitfield_bit_offset, - bool show_types, - bool show_summary, - bool verbose, - uint32_t depth); - - static void - DumpSummary (ExecutionContext *exe_ctx, - clang::ASTContext *ast_context, - void *clang_qual_type, - Stream *s, - const DataExtractor &data, - uint32_t data_offset, - size_t data_byte_size); - - void DumpValue(ExecutionContext *exe_ctx, Stream *s, @@ -151,31 +122,6 @@ bool show_summary, bool verbose); - static bool - DumpTypeValue ( Stream *s, - clang::ASTContext *ast_context, - void *clang_qual_type, - lldb::Format format, - const DataExtractor &data, - uint32_t data_offset, - size_t data_byte_size, - uint32_t bitfield_bit_size, - uint32_t bitfield_bit_offset); - - static bool - GetValueAsScalar (clang::ASTContext *ast_context, - void *clang_qual_type, - const DataExtractor &data, - uint32_t data_offset, - size_t data_byte_size, - Scalar &value); - - static bool - SetValueFromScalar (clang::ASTContext *ast_context, - void *clang_qual_type, - const Scalar &value, - Stream &strm); - bool ReadFromMemory (ExecutionContext *exe_ctx, lldb::addr_t address, @@ -188,23 +134,6 @@ lldb::AddressType address_type, DataExtractor &data); - - static bool - ReadFromMemory (ExecutionContext *exe_ctx, - clang::ASTContext *ast_context, - void *clang_qual_type, - lldb::addr_t addr, - lldb::AddressType address_type, - DataExtractor &data); - - static bool - WriteToMemory (ExecutionContext *exe_ctx, - clang::ASTContext *ast_context, - void *clang_qual_type, - lldb::addr_t addr, - lldb::AddressType address_type, - StreamString &new_value); - bool GetIsDeclaration() const; @@ -223,9 +152,6 @@ lldb::Encoding GetEncoding (uint32_t &count); - static lldb::Encoding - GetEncoding (void *clang_qual_type, uint32_t &count); - SymbolContextScope * GetSymbolContextScope() { @@ -265,12 +191,6 @@ static int Compare(const Type &a, const Type &b); - static lldb::Format - GetFormat (void *clang_qual_type); - - static int - DumpClangTypeName(Stream *s, void *clang_qual_type); - protected: ConstString m_name; uint64_t m_byte_size; Modified: lldb/trunk/lldb.xcodeproj/project.pbxproj URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/lldb.xcodeproj/project.pbxproj?rev=109046&r1=109045&r2=109046&view=diff ============================================================================== --- lldb/trunk/lldb.xcodeproj/project.pbxproj (original) +++ lldb/trunk/lldb.xcodeproj/project.pbxproj Wed Jul 21 17:12:05 2010 @@ -335,8 +335,8 @@ 49D7072911B5AD11001AD875 /* ClangASTSource.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 49D7072811B5AD11001AD875 /* ClangASTSource.cpp */; settings = {COMPILER_FLAGS = "-fno-rtti"; }; }; 49DA743011DE6A5A006AEF7E /* IRToDWARF.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 49DA742F11DE6A5A006AEF7E /* IRToDWARF.cpp */; }; 49DA743511DE6BB2006AEF7E /* IRToDWARF.h in Headers */ = {isa = PBXBuildFile; fileRef = 49DA743411DE6BB2006AEF7E /* IRToDWARF.h */; }; - 49E45FAA11F660DC008F7B28 /* ASTType.h in Headers */ = {isa = PBXBuildFile; fileRef = 49E45FA911F660DC008F7B28 /* ASTType.h */; }; - 49E45FAF11F660FE008F7B28 /* ASTType.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 49E45FAD11F660FE008F7B28 /* ASTType.cpp */; }; + 49E45FAA11F660DC008F7B28 /* ClangASTType.h in Headers */ = {isa = PBXBuildFile; fileRef = 49E45FA911F660DC008F7B28 /* ClangASTType.h */; }; + 49E45FAF11F660FE008F7B28 /* ClangASTType.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 49E45FAD11F660FE008F7B28 /* ClangASTType.cpp */; }; 49F1A74611B3388F003ED505 /* ClangExpressionDeclMap.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 49F1A74511B3388F003ED505 /* ClangExpressionDeclMap.cpp */; }; 49F1A74A11B338AE003ED505 /* ClangExpressionDeclMap.h in Headers */ = {isa = PBXBuildFile; fileRef = 49F1A74911B338AE003ED505 /* ClangExpressionDeclMap.h */; }; 4C08CDE811C81EF8001610A8 /* ThreadSpec.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4C08CDE711C81EF8001610A8 /* ThreadSpec.cpp */; }; @@ -912,8 +912,8 @@ 49D7072811B5AD11001AD875 /* ClangASTSource.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = ClangASTSource.cpp; path = source/Expression/ClangASTSource.cpp; sourceTree = ""; }; 49DA742F11DE6A5A006AEF7E /* IRToDWARF.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = IRToDWARF.cpp; path = source/Expression/IRToDWARF.cpp; sourceTree = ""; }; 49DA743411DE6BB2006AEF7E /* IRToDWARF.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = IRToDWARF.h; path = include/lldb/Expression/IRToDWARF.h; sourceTree = ""; }; - 49E45FA911F660DC008F7B28 /* ASTType.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ASTType.h; path = include/lldb/Symbol/ASTType.h; sourceTree = ""; }; - 49E45FAD11F660FE008F7B28 /* ASTType.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = ASTType.cpp; path = source/Symbol/ASTType.cpp; sourceTree = ""; }; + 49E45FA911F660DC008F7B28 /* ClangASTType.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ClangASTType.h; path = include/lldb/Symbol/ClangASTType.h; sourceTree = ""; }; + 49E45FAD11F660FE008F7B28 /* ClangASTType.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = ClangASTType.cpp; path = source/Symbol/ClangASTType.cpp; sourceTree = ""; }; 49EC3E98118F90AC00B1265E /* ThreadPlanCallFunction.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = ThreadPlanCallFunction.cpp; path = source/Target/ThreadPlanCallFunction.cpp; sourceTree = ""; }; 49EC3E9C118F90D400B1265E /* ThreadPlanCallFunction.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ThreadPlanCallFunction.h; path = include/lldb/Target/ThreadPlanCallFunction.h; sourceTree = ""; }; 49F1A74511B3388F003ED505 /* ClangExpressionDeclMap.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = ClangExpressionDeclMap.cpp; path = source/Expression/ClangExpressionDeclMap.cpp; sourceTree = ""; }; @@ -1669,12 +1669,12 @@ isa = PBXGroup; children = ( AF94005711C03F6500085DB9 /* SymbolVendor.cpp */, - 49E45FA911F660DC008F7B28 /* ASTType.h */, - 49E45FAD11F660FE008F7B28 /* ASTType.cpp */, 26BC7C5510F1B6E900F91463 /* Block.h */, 26BC7F1310F1B8EC00F91463 /* Block.cpp */, 26BC7C5610F1B6E900F91463 /* ClangASTContext.h */, 26BC7F1410F1B8EC00F91463 /* ClangASTContext.cpp */, + 49E45FA911F660DC008F7B28 /* ClangASTType.h */, + 49E45FAD11F660FE008F7B28 /* ClangASTType.cpp */, 26BC7C5710F1B6E900F91463 /* CompileUnit.h */, 26BC7F1510F1B8EC00F91463 /* CompileUnit.cpp */, 26BC7C5810F1B6E900F91463 /* Declaration.h */, @@ -2201,7 +2201,7 @@ 49307AB211DEA4F20081F992 /* IRForTarget.h in Headers */, 4C5DBBC911E3FEC60035160F /* CommandObjectCommands.h in Headers */, 26D27CA011ED3A4E0024D721 /* ELFHeader.h in Headers */, - 49E45FAA11F660DC008F7B28 /* ASTType.h in Headers */, + 49E45FAA11F660DC008F7B28 /* ClangASTType.h in Headers */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -2655,7 +2655,7 @@ 49307AAE11DEA4D90081F992 /* IRForTarget.cpp in Sources */, 4C5DBBC811E3FEC60035160F /* CommandObjectCommands.cpp in Sources */, 26D27C9F11ED3A4E0024D721 /* ELFHeader.cpp in Sources */, - 49E45FAF11F660FE008F7B28 /* ASTType.cpp in Sources */, + 49E45FAF11F660FE008F7B28 /* ClangASTType.cpp in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; Modified: lldb/trunk/source/Commands/CommandObjectExpression.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectExpression.cpp?rev=109046&r1=109045&r2=109046&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectExpression.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectExpression.cpp Wed Jul 21 17:12:05 2010 @@ -12,8 +12,10 @@ // C Includes // C++ Includes // Other libraries and framework includes +#include "llvm/ADT/StringRef.h" + // Project includes -#include "lldb/Interpreter/Args.h" +#include "lldb/Core/Debugger.h" #include "lldb/Core/Value.h" #include "lldb/Core/InputReader.h" #include "lldb/Expression/ClangExpression.h" @@ -21,15 +23,15 @@ #include "lldb/Expression/ClangExpressionVariable.h" #include "lldb/Expression/DWARFExpression.h" #include "lldb/Host/Host.h" -#include "lldb/Core/Debugger.h" +#include "lldb/Interpreter/Args.h" #include "lldb/Interpreter/CommandInterpreter.h" #include "lldb/Interpreter/CommandReturnObject.h" +#include "lldb/Symbol/ClangASTType.h" #include "lldb/Symbol/ObjectFile.h" #include "lldb/Symbol/Variable.h" #include "lldb/Target/Process.h" #include "lldb/Target/StackFrame.h" #include "lldb/Target/Target.h" -#include "llvm/ADT/StringRef.h" using namespace lldb; using namespace lldb_private; @@ -402,22 +404,26 @@ if (clang_type) { if (m_options.show_types) - Type::DumpClangTypeName (&output_stream, clang_type); + { + ConstString type_name(ClangASTType::GetClangTypeName (clang_type)); + if (type_name) + output_stream.Printf("(%s) ", type_name.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 + ClangASTType::DumpValue (ast_context, // The ASTContext that the clang type belongs to + clang_type, // The opaque clang type we want to dump that value of + &m_exe_ctx, // The execution context for memory and variable access + &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 { Modified: lldb/trunk/source/Commands/CommandObjectVariable.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectVariable.cpp?rev=109046&r1=109045&r2=109046&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectVariable.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectVariable.cpp Wed Jul 21 17:12:05 2010 @@ -23,6 +23,7 @@ #include "lldb/Interpreter/CommandInterpreter.h" #include "lldb/Interpreter/CommandReturnObject.h" +#include "lldb/Symbol/ClangASTType.h" #include "lldb/Symbol/ClangASTContext.h" #include "lldb/Symbol/ObjectFile.h" #include "lldb/Symbol/SymbolContext.h" @@ -386,12 +387,12 @@ Scalar scalar; - if (!Type::GetValueAsScalar (valobj->GetClangAST(), - valobj->GetOpaqueClangQualType(), - valobj->GetDataExtractor(), - 0, - valobj->GetByteSize(), - scalar)) + if (!ClangASTType::GetValueAsScalar (valobj->GetClangAST(), + valobj->GetOpaqueClangQualType(), + valobj->GetDataExtractor(), + 0, + valobj->GetByteSize(), + scalar)) return; ConstString po_output; Modified: lldb/trunk/source/Core/Value.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/Value.cpp?rev=109046&r1=109045&r2=109046&view=diff ============================================================================== --- lldb/trunk/source/Core/Value.cpp (original) +++ lldb/trunk/source/Core/Value.cpp Wed Jul 21 17:12:05 2010 @@ -17,6 +17,7 @@ #include "lldb/Core/DataBufferHeap.h" #include "lldb/Core/Module.h" #include "lldb/Core/Stream.h" +#include "lldb/Symbol/ClangASTType.h" #include "lldb/Symbol/ClangASTContext.h" #include "lldb/Symbol/ObjectFile.h" #include "lldb/Symbol/SymbolContext.h" @@ -472,7 +473,7 @@ break; case eContextTypeOpaqueClangQualType: - return Type::GetFormat (m_context); + return ClangASTType::GetFormat (m_context); case eContextTypeDCRegisterInfo: if (GetRegisterInfo()) @@ -692,9 +693,9 @@ lldb::AddressType address_type = m_value_type == eValueTypeLoadAddress ? eAddressTypeLoad : eAddressTypeHost; lldb::addr_t addr = m_value.ULongLong(LLDB_INVALID_ADDRESS); DataExtractor data; - if (Type::ReadFromMemory (exe_ctx, ast_context, opaque_clang_qual_type, addr, address_type, data)) + if (ClangASTType::ReadFromMemory (ast_context, opaque_clang_qual_type, exe_ctx, addr, address_type, data)) { - if (Type::GetValueAsScalar (ast_context, opaque_clang_qual_type, data, 0, data.GetByteSize(), scalar)) + if (ClangASTType::GetValueAsScalar (ast_context, opaque_clang_qual_type, data, 0, data.GetByteSize(), scalar)) { m_value = scalar; m_value_type = eValueTypeScalar; Modified: lldb/trunk/source/Core/ValueObject.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/ValueObject.cpp?rev=109046&r1=109045&r2=109046&view=diff ============================================================================== --- lldb/trunk/source/Core/ValueObject.cpp (original) +++ lldb/trunk/source/Core/ValueObject.cpp Wed Jul 21 17:12:05 2010 @@ -20,6 +20,7 @@ #include "lldb/Core/ValueObjectChild.h" #include "lldb/Core/ValueObjectList.h" +#include "lldb/Symbol/ClangASTType.h" #include "lldb/Symbol/ClangASTContext.h" #include "lldb/Symbol/Type.h" @@ -488,16 +489,16 @@ if (clang_type) { StreamString sstr; - lldb::Format format = Type::GetFormat(clang_type); - if (Type::DumpTypeValue(&sstr, - GetClangAST(), // The clang AST - clang_type, // The clang type to display - format, // Format to display this type with - m_data, // Data to extract from - 0, // Byte offset into "m_data" - GetByteSize(), // Byte size of item in "m_data" - GetBitfieldBitSize(), // Bitfield bit size - GetBitfieldBitOffset())) // Bitfield bit offset + lldb::Format format = ClangASTType::GetFormat(clang_type); + if (ClangASTType::DumpTypeValue(GetClangAST(), // The clang AST + clang_type, // The clang type to display + &sstr, + format, // Format to display this type with + m_data, // Data to extract from + 0, // Byte offset into "m_data" + GetByteSize(), // Byte size of item in "m_data" + GetBitfieldBitSize(), // Bitfield bit size + GetBitfieldBitOffset())) // Bitfield bit offset m_value_str.swap(sstr.GetString()); else m_value_str.clear(); @@ -537,7 +538,7 @@ return false; uint32_t count = 0; - lldb::Encoding encoding = Type::GetEncoding (GetOpaqueClangQualType(), count); + lldb::Encoding encoding = ClangASTType::GetEncoding (GetOpaqueClangQualType(), count); char *end = NULL; const size_t byte_size = GetByteSize(); Modified: lldb/trunk/source/Core/ValueObjectChild.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/ValueObjectChild.cpp?rev=109046&r1=109045&r2=109046&view=diff ============================================================================== --- lldb/trunk/source/Core/ValueObjectChild.cpp (original) +++ lldb/trunk/source/Core/ValueObjectChild.cpp Wed Jul 21 17:12:05 2010 @@ -12,6 +12,7 @@ #include "lldb/Core/Module.h" #include "lldb/Core/ValueObjectList.h" +#include "lldb/Symbol/ClangASTType.h" #include "lldb/Symbol/ObjectFile.h" #include "lldb/Symbol/SymbolContext.h" #include "lldb/Symbol/Type.h" @@ -103,7 +104,7 @@ { if (m_type_name.IsEmpty()) { - m_type_name = Type::GetClangTypeName (GetOpaqueClangQualType()); + m_type_name = ClangASTType::GetClangTypeName (GetOpaqueClangQualType()); if (m_type_name) { if (m_bitfield_bit_size > 0) Modified: lldb/trunk/source/Core/ValueObjectRegister.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/ValueObjectRegister.cpp?rev=109046&r1=109045&r2=109046&view=diff ============================================================================== --- lldb/trunk/source/Core/ValueObjectRegister.cpp (original) +++ lldb/trunk/source/Core/ValueObjectRegister.cpp Wed Jul 21 17:12:05 2010 @@ -15,6 +15,7 @@ // Other libraries and framework includes // Project includes #include "lldb/Core/Module.h" +#include "lldb/Symbol/ClangASTType.h" #include "lldb/Symbol/ClangASTContext.h" #include "lldb/Symbol/TypeList.h" #include "lldb/Target/ExecutionContext.h" @@ -250,7 +251,7 @@ ValueObjectRegister::GetTypeName() { if (m_type_name.IsEmpty()) - m_type_name = Type::GetClangTypeName (GetOpaqueClangQualType()); + m_type_name = ClangASTType::GetClangTypeName (GetOpaqueClangQualType()); return m_type_name; } Modified: lldb/trunk/source/Expression/ClangExpression.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/ClangExpression.cpp?rev=109046&r1=109045&r2=109046&view=diff ============================================================================== --- lldb/trunk/source/Expression/ClangExpression.cpp (original) +++ lldb/trunk/source/Expression/ClangExpression.cpp Wed Jul 21 17:12:05 2010 @@ -55,6 +55,7 @@ // Project includes #include "lldb/Core/Log.h" +#include "lldb/Core/ClangForward.h" #include "lldb/Expression/ClangExpression.h" #include "lldb/Expression/ClangASTSource.h" #include "lldb/Expression/ClangResultSynthesizer.h" @@ -74,23 +75,6 @@ using namespace clang; using namespace llvm; -namespace clang { - -class AnalyzerOptions; -class CodeGenOptions; -class DependencyOutputOptions; -class DiagnosticOptions; -class FrontendOptions; -class HeaderSearchOptions; -class LangOptions; -class PreprocessorOptions; -class PreprocessorOutputOptions; -class TargetInfo; -class TargetOptions; - -} // end namespace clang - - //===----------------------------------------------------------------------===// // Utility Methods Modified: lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp?rev=109046&r1=109045&r2=109046&view=diff ============================================================================== --- lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp (original) +++ lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp Wed Jul 21 17:12:05 2010 @@ -292,10 +292,11 @@ TypeFromUser copied_type(ClangASTContext::CopyType(context, iter->m_parser_type.GetASTContext(), - iter->m_parser_type.GetType()), + iter->m_parser_type.GetOpaqueQualType()), context); - result_value->SetContext(Value::eContextTypeOpaqueClangQualType, copied_type.GetType()); + result_value->SetContext(Value::eContextTypeOpaqueClangQualType, + copied_type.GetOpaqueQualType()); } continue; @@ -329,7 +330,10 @@ return false; } - log->Printf("%s %s with type %p", (dematerialize ? "Dematerializing" : "Materializing"), name, type.GetType()); + log->Printf("%s %s with type %p", + (dematerialize ? "Dematerializing" : "Materializing"), + name, + type.GetOpaqueQualType()); std::auto_ptr location_value(GetVariableValue(exe_ctx, var, @@ -345,7 +349,8 @@ { lldb::addr_t value_addr = location_value->GetScalar().ULongLong(); - size_t bit_size = ClangASTContext::GetTypeBitSize(type.GetASTContext(), type.GetType()); + size_t bit_size = ClangASTContext::GetTypeBitSize (type.GetASTContext(), + type.GetOpaqueQualType()); size_t byte_size = bit_size % 8 ? ((bit_size + 8) / 8) : (bit_size / 8); DataBufferHeap data; @@ -488,7 +493,9 @@ if (type->GetASTContext() == var->GetType()->GetClangAST()) { - if (!ClangASTContext::AreTypesSame(type->GetASTContext(), type->GetType(), var->GetType()->GetOpaqueClangQualType())) + if (!ClangASTContext::AreTypesSame(type->GetASTContext(), + type->GetOpaqueQualType(), + var->GetType()->GetOpaqueClangQualType())) return NULL; } else @@ -657,7 +664,7 @@ &ut, &pt); - NamedDecl *var_decl = context.AddVarDecl(pt.GetType()); + NamedDecl *var_decl = context.AddVarDecl(pt.GetOpaqueQualType()); Tuple tuple; Modified: lldb/trunk/source/Expression/DWARFExpression.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/DWARFExpression.cpp?rev=109046&r1=109045&r2=109046&view=diff ============================================================================== --- lldb/trunk/source/Expression/DWARFExpression.cpp (original) +++ lldb/trunk/source/Expression/DWARFExpression.cpp Wed Jul 21 17:12:05 2010 @@ -24,6 +24,7 @@ #include "lldb/lldb-private-log.h" +#include "lldb/Symbol/ClangASTType.h" #include "lldb/Symbol/ClangASTContext.h" #include "lldb/Symbol/Type.h" @@ -2273,10 +2274,10 @@ } else { - if (!Type::SetValueFromScalar(ast_context, - clang_type, - tmp.ResolveValue(exe_ctx, ast_context), - new_value)) + if (!ClangASTType::SetValueFromScalar (ast_context, + clang_type, + tmp.ResolveValue(exe_ctx, ast_context), + new_value)) { if (error_ptr) error_ptr->SetErrorStringWithFormat ("Couldn't extract a value from an integral type.\n"); @@ -2292,12 +2293,12 @@ { lldb::AddressType address_type = (value_type == Value::eValueTypeLoadAddress ? eAddressTypeLoad : eAddressTypeHost); lldb::addr_t addr = stack.back().GetScalar().ULongLong(LLDB_INVALID_ADDRESS); - if (!Type::WriteToMemory (exe_ctx, - ast_context, - clang_type, - addr, - address_type, - new_value)) + if (!ClangASTType::WriteToMemory (ast_context, + clang_type, + exe_ctx, + addr, + address_type, + new_value)) { if (error_ptr) error_ptr->SetErrorStringWithFormat ("Failed to write value to memory at 0x%llx.\n", addr); Modified: lldb/trunk/source/Host/macosx/Symbols.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/macosx/Symbols.cpp?rev=109046&r1=109045&r2=109046&view=diff ============================================================================== --- lldb/trunk/source/Host/macosx/Symbols.cpp (original) +++ lldb/trunk/source/Host/macosx/Symbols.cpp Wed Jul 21 17:12:05 2010 @@ -11,8 +11,7 @@ // C Includes #include -#include -#include +#include "llvm/Support/MachO.h" // C++ Includes // Other libraries and framework includes @@ -29,6 +28,7 @@ using namespace lldb; using namespace lldb_private; +using namespace llvm::MachO; extern "C" { @@ -49,8 +49,8 @@ const uint32_t magic ) { - assert(magic == MH_CIGAM || magic == MH_MAGIC || magic == MH_CIGAM_64 || magic == MH_MAGIC_64); - if (magic == MH_MAGIC || magic == MH_MAGIC_64) + assert(magic == HeaderMagic32 || magic == HeaderMagic32Swapped || magic == HeaderMagic64 || magic == HeaderMagic64Swapped); + if (magic == HeaderMagic32 || magic == HeaderMagic64) data.SetByteOrder (eByteOrderHost); else if (eByteOrderHost == eByteOrderBig) data.SetByteOrder (eByteOrderLittle); @@ -80,11 +80,11 @@ if (uuid == NULL) return true; - if (magic == MH_CIGAM_64 || magic == MH_MAGIC_64) + if (magic == HeaderMagic64Swapped || magic == HeaderMagic64) data_offset += 4; // Skip reserved field for in mach_header_64 // Make sure we have enough data for all the load commands - if (magic == MH_CIGAM_64 || magic == MH_MAGIC_64) + if (magic == HeaderMagic64Swapped || magic == HeaderMagic64) { if (data.GetByteSize() < sizeof(struct mach_header_64) + sizeofcmds) { @@ -106,7 +106,7 @@ const uint32_t cmd_offset = data_offset; // Save this data_offset in case parsing of the segment goes awry! uint32_t cmd = data.GetU32(&data_offset); uint32_t cmd_size = data.GetU32(&data_offset); - if (cmd == LC_UUID) + if (cmd == LoadCommandUUID) { UUID file_uuid (data.GetData(&data_offset, 16), 16); return file_uuid == *uuid; @@ -128,7 +128,7 @@ const uint32_t magic ) { - assert(magic == FAT_CIGAM || magic == FAT_MAGIC); + assert(magic == UniversalMagic || magic == UniversalMagicSwapped); // Universal mach-o files always have their headers encoded as BIG endian data.SetByteOrder(eByteOrderBig); @@ -167,10 +167,10 @@ switch (arch_magic) { - case MH_CIGAM: // 32 bit mach-o file - case MH_MAGIC: // 32 bit mach-o file - case MH_CIGAM_64: // 64 bit mach-o file - case MH_MAGIC_64: // 64 bit mach-o file + case HeaderMagic32: + case HeaderMagic32Swapped: + case HeaderMagic64: + case HeaderMagic64Swapped: if (SkinnyMachOFileContainsArchAndUUID (file_spec, arch, uuid, file_offset + arch_offset, arch_data, arch_data_offset, arch_magic)) return true; break; @@ -201,15 +201,15 @@ switch (magic) { // 32 bit mach-o file - case MH_CIGAM: - case MH_MAGIC: - case MH_CIGAM_64: - case MH_MAGIC_64: + case HeaderMagic32: + case HeaderMagic32Swapped: + case HeaderMagic64: + case HeaderMagic64Swapped: return SkinnyMachOFileContainsArchAndUUID (file_spec, arch, uuid, file_offset, data, data_offset, magic); // fat mach-o file - case FAT_CIGAM: - case FAT_MAGIC: + case UniversalMagic: + case UniversalMagicSwapped: return UniversalMachOFileContainsArchAndUUID (file_spec, arch, uuid, file_offset, data, data_offset, magic); default: Modified: lldb/trunk/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.cpp?rev=109046&r1=109045&r2=109046&view=diff ============================================================================== --- lldb/trunk/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.cpp (original) +++ lldb/trunk/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.cpp Wed Jul 21 17:12:05 2010 @@ -34,7 +34,7 @@ using namespace lldb; using namespace lldb_private; - +using namespace llvm::MachO; /// FIXME - The ObjC Runtime trampoline handler doesn't really belong here. /// I am putting it here so I can invoke it in the Trampoline code here, but @@ -191,7 +191,7 @@ DataExtractor data; // Load command data if (ReadMachHeader (addr, &m_dyld.header, &data)) { - if (m_dyld.header.filetype == MH_DYLINKER) + if (m_dyld.header.filetype == HeaderFileTypeDynamicLinkEditor) { m_dyld.address = addr; ModuleSP dyld_module_sp; @@ -670,15 +670,15 @@ // Returns true if we succeed, false if we fail for any reason. //---------------------------------------------------------------------- bool -DynamicLoaderMacOSXDYLD::ReadMachHeader (lldb::addr_t addr, struct mach_header *header, DataExtractor *load_command_data) +DynamicLoaderMacOSXDYLD::ReadMachHeader (lldb::addr_t addr, mach_header *header, DataExtractor *load_command_data) { - DataBufferHeap header_bytes(sizeof(struct mach_header), 0); + DataBufferHeap header_bytes(sizeof(mach_header), 0); Error error; size_t bytes_read = m_process->ReadMemory (addr, header_bytes.GetBytes(), header_bytes.GetByteSize(), error); - if (bytes_read == sizeof(struct mach_header)) + if (bytes_read == sizeof(mach_header)) { uint32_t offset = 0; ::memset (header, 0, sizeof(header)); @@ -690,16 +690,16 @@ data.SetByteOrder(DynamicLoaderMacOSXDYLD::GetByteOrderFromMagic(header->magic)); switch (header->magic) { - case MH_MAGIC: - case MH_CIGAM: + case llvm::MachO::HeaderMagic32: + case llvm::MachO::HeaderMagic32Swapped: data.SetAddressByteSize(4); - load_cmd_addr += sizeof(struct mach_header); + load_cmd_addr += sizeof(mach_header); break; - case MH_MAGIC_64: - case MH_CIGAM_64: + case llvm::MachO::HeaderMagic64: + case llvm::MachO::HeaderMagic64Swapped: data.SetAddressByteSize(8); - load_cmd_addr += sizeof(struct mach_header_64); + load_cmd_addr += sizeof(mach_header_64); break; default: @@ -707,7 +707,7 @@ } // Read the rest of dyld's mach header - if (data.GetU32(&offset, &header->cputype, (sizeof(struct mach_header)/sizeof(uint32_t)) - 1)) + if (data.GetU32(&offset, &header->cputype, (sizeof(mach_header)/sizeof(uint32_t)) - 1)) { if (load_command_data == NULL) return true; // We were able to read the mach_header and weren't asked to read the load command bytes @@ -752,15 +752,15 @@ // Clear out any load command specific data from DYLIB_INFO since // we are about to read it. - if (data.ValidOffsetForDataOfSize (offset, sizeof(struct load_command))) + if (data.ValidOffsetForDataOfSize (offset, sizeof(load_command))) { - struct load_command load_cmd; + load_command load_cmd; uint32_t load_cmd_offset = offset; load_cmd.cmd = data.GetU32 (&offset); load_cmd.cmdsize = data.GetU32 (&offset); switch (load_cmd.cmd) { - case LC_SEGMENT: + case LoadCommandSegment32: { segment.name.SetTrimmedCStringWithLength ((const char *)data.GetData(&offset, 16), 16); segment.addr = data.GetU32 (&offset); @@ -769,7 +769,7 @@ } break; - case LC_SEGMENT_64: + case LoadCommandSegment64: { segment.name.SetTrimmedCStringWithLength ((const char *)data.GetData(&offset, 16), 16); segment.addr = data.GetU64 (&offset); @@ -778,7 +778,7 @@ } break; - case LC_ID_DYLINKER: + case LoadCommandDynamicLinkerIdent: if (lc_id_dylinker) { uint32_t name_offset = load_cmd_offset + data.GetU32 (&offset); @@ -787,7 +787,7 @@ } break; - case LC_UUID: + case LoadCommandUUID: dylib_info.uuid.SetBytes(data.GetData (&offset, 16)); break; @@ -820,7 +820,7 @@ ParseLoadCommands (data, m_dyld_image_infos[i], NULL); - if (m_dyld_image_infos[i].header.filetype == MH_EXECUTE) + if (m_dyld_image_infos[i].header.filetype == HeaderFileTypeExecutable) exe_idx = i; } } Modified: lldb/trunk/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.h?rev=109046&r1=109045&r2=109046&view=diff ============================================================================== --- lldb/trunk/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.h (original) +++ lldb/trunk/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.h Wed Jul 21 17:12:05 2010 @@ -11,19 +11,20 @@ #define liblldb_DynamicLoaderMacOSXDYLD_h_ // C Includes -#include - // C++ Includes #include #include #include // Other libraries and framework includes +#include "llvm/Support/MachO.h" + #include "lldb/Target/DynamicLoader.h" #include "lldb/Core/FileSpec.h" #include "lldb/Core/UUID.h" #include "lldb/Host/Mutex.h" #include "lldb/Target/Process.h" + #include "ObjCTrampolineHandler.h" class DynamicLoaderMacOSXDYLD : public lldb_private::DynamicLoader @@ -144,12 +145,12 @@ { switch (m_dyld.header.magic) { - case MH_MAGIC: - case MH_CIGAM: + case llvm::MachO::HeaderMagic32: + case llvm::MachO::HeaderMagic32Swapped: return 4; - case MH_MAGIC_64: - case MH_CIGAM_64: + case llvm::MachO::HeaderMagic64: + case llvm::MachO::HeaderMagic64Swapped: return 8; default: @@ -163,12 +164,12 @@ { switch (magic) { - case MH_MAGIC: - case MH_MAGIC_64: + case llvm::MachO::HeaderMagic32: + case llvm::MachO::HeaderMagic64: return lldb::eByteOrderHost; - case MH_CIGAM: - case MH_CIGAM_64: + case llvm::MachO::HeaderMagic32Swapped: + case llvm::MachO::HeaderMagic64Swapped: if (lldb::eByteOrderHost == lldb::eByteOrderBig) return lldb::eByteOrderLittle; else @@ -182,7 +183,7 @@ bool ReadMachHeader (lldb::addr_t addr, - struct mach_header *header, + llvm::MachO::mach_header *header, lldb_private::DataExtractor *load_command_data); class Segment { @@ -218,7 +219,7 @@ lldb::addr_t mod_date; // Modification date for this dylib lldb_private::FileSpec file_spec; // Resolved path for this dylib lldb_private::UUID uuid; // UUID for this dylib if it has one, else all zeros - struct mach_header header; // The mach header for this image + llvm::MachO::mach_header header; // The mach header for this image std::vector segments; // All segment vmaddr and vmsize pairs for this executable (from memory of inferior) DYLDImageInfo() : Modified: lldb/trunk/source/Plugins/ObjectContainer/Universal-Mach-O/ObjectContainerUniversalMachO.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ObjectContainer/Universal-Mach-O/ObjectContainerUniversalMachO.cpp?rev=109046&r1=109045&r2=109046&view=diff ============================================================================== --- lldb/trunk/source/Plugins/ObjectContainer/Universal-Mach-O/ObjectContainerUniversalMachO.cpp (original) +++ lldb/trunk/source/Plugins/ObjectContainer/Universal-Mach-O/ObjectContainerUniversalMachO.cpp Wed Jul 21 17:12:05 2010 @@ -16,7 +16,7 @@ using namespace lldb; using namespace lldb_private; - +using namespace llvm::MachO; void ObjectContainerUniversalMachO::Initialize() @@ -75,7 +75,7 @@ DataExtractor data(dataSP, eByteOrderHost, 4); uint32_t offset = 0; uint32_t magic = data.GetU32(&offset); - return magic == FAT_MAGIC || magic == FAT_CIGAM; + return magic == UniversalMagic || magic == UniversalMagicSwapped; } ObjectContainerUniversalMachO::ObjectContainerUniversalMachO @@ -108,20 +108,20 @@ m_data.SetByteOrder (eByteOrderBig); m_header.magic = m_data.GetU32(&offset); - if (m_header.magic == FAT_MAGIC) + if (m_header.magic == UniversalMagic) { m_data.SetAddressByteSize(4); m_header.nfat_arch = m_data.GetU32(&offset); - const size_t nfat_arch_size = sizeof(fat_arch_t) * m_header.nfat_arch; + const size_t nfat_arch_size = sizeof(fat_arch) * m_header.nfat_arch; // See if the current data we have is enough for all of the fat headers? if (!m_data.ValidOffsetForDataOfSize(offset, nfat_arch_size)) { // The fat headers are larger than the number of bytes we have been // given when this class was constructed. We will read the exact number // of bytes that we need. - DataBufferSP data_sp(m_file.ReadFileContents(m_offset, nfat_arch_size + sizeof(fat_header_t))); + DataBufferSP data_sp(m_file.ReadFileContents(m_offset, nfat_arch_size + sizeof(fat_header))); m_data.SetData (data_sp); } @@ -130,10 +130,10 @@ uint32_t arch_idx = 0; for (arch_idx = 0; arch_idx < m_header.nfat_arch; ++arch_idx) { - if (m_data.ValidOffsetForDataOfSize(offset, sizeof(fat_arch_t))) + if (m_data.ValidOffsetForDataOfSize(offset, sizeof(fat_arch))) { - fat_arch_t arch; - if (m_data.GetU32(&offset, &arch, sizeof(fat_arch_t)/sizeof(uint32_t))) + fat_arch arch; + if (m_data.GetU32(&offset, &arch, sizeof(fat_arch)/sizeof(uint32_t))) { m_fat_archs.push_back(arch); } Modified: lldb/trunk/source/Plugins/ObjectContainer/Universal-Mach-O/ObjectContainerUniversalMachO.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ObjectContainer/Universal-Mach-O/ObjectContainerUniversalMachO.h?rev=109046&r1=109045&r2=109046&view=diff ============================================================================== --- lldb/trunk/source/Plugins/ObjectContainer/Universal-Mach-O/ObjectContainerUniversalMachO.h (original) +++ lldb/trunk/source/Plugins/ObjectContainer/Universal-Mach-O/ObjectContainerUniversalMachO.h Wed Jul 21 17:12:05 2010 @@ -10,11 +10,11 @@ #ifndef liblldb_ObjectContainerUniversalMachO_h_ #define liblldb_ObjectContainerUniversalMachO_h_ -#include - #include "lldb/Symbol/ObjectContainer.h" #include "lldb/Core/FileSpec.h" +#include "llvm/Support/MachO.h" + class ObjectContainerUniversalMachO : public lldb_private::ObjectContainer { @@ -94,10 +94,8 @@ protected: - typedef struct fat_header fat_header_t; - typedef struct fat_arch fat_arch_t; - fat_header_t m_header; - std::vector m_fat_archs; + llvm::MachO::fat_header m_header; + std::vector m_fat_archs; }; #endif // liblldb_ObjectContainerUniversalMachO_h_ Modified: lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp?rev=109046&r1=109045&r2=109046&view=diff ============================================================================== --- lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp (original) +++ lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp Wed Jul 21 17:12:05 2010 @@ -9,9 +9,6 @@ #include "ObjectFileMachO.h" -#include -#include - #include "lldb/Core/ArchSpec.h" #include "lldb/Core/DataBuffer.h" #include "lldb/Core/FileSpec.h" @@ -25,18 +22,10 @@ #include "lldb/Core/UUID.h" #include "lldb/Symbol/ObjectFile.h" -#ifndef S_DTRACE_DOF -// section contains DTrace Object Format -#define S_DTRACE_DOF 0xf -#endif - -#ifndef S_LAZY_DYLIB_SYMBOL_POINTERS -// section with only lazy symbol pointers to lazy loaded dylibs -#define S_LAZY_DYLIB_SYMBOL_POINTERS 0x10 -#endif using namespace lldb; using namespace lldb_private; +using namespace llvm::MachO; void @@ -85,12 +74,12 @@ { switch (magic) { - case MH_MAGIC: - case MH_CIGAM: + case HeaderMagic32: + case HeaderMagic32Swapped: return sizeof(struct mach_header); - case MH_MAGIC_64: - case MH_CIGAM_64: + case HeaderMagic64: + case HeaderMagic64Swapped: return sizeof(struct mach_header_64); break; @@ -139,25 +128,25 @@ m_header.magic = m_data.GetU32(&offset); switch (m_header.magic) { - case MH_MAGIC: + case HeaderMagic32: m_data.SetByteOrder (eByteOrderHost); m_data.SetAddressByteSize(4); can_parse = true; break; - case MH_MAGIC_64: + case HeaderMagic64: m_data.SetByteOrder (eByteOrderHost); m_data.SetAddressByteSize(8); can_parse = true; break; - case MH_CIGAM: + case HeaderMagic32Swapped: m_data.SetByteOrder(eByteOrderHost == eByteOrderBig ? eByteOrderLittle : eByteOrderBig); m_data.SetAddressByteSize(4); can_parse = true; break; - case MH_CIGAM_64: + case HeaderMagic64Swapped: m_data.SetByteOrder(eByteOrderHost == eByteOrderBig ? eByteOrderLittle : eByteOrderBig); m_data.SetAddressByteSize(8); can_parse = true; @@ -245,7 +234,7 @@ if (m_data.GetU32(&offset, &load_cmd, 2) == NULL) break; - if (load_cmd.cmd == LC_SEGMENT || load_cmd.cmd == LC_SEGMENT_64) + if (load_cmd.cmd == LoadCommandSegment32 || load_cmd.cmd == LoadCommandSegment64) { if (m_data.GetU8(&offset, (uint8_t*)load_cmd.segname, 16)) { @@ -282,13 +271,13 @@ struct section_64 sect64; ::bzero (§64, sizeof(sect64)); // Push a section into our mach sections for the section at - // index zero (NO_SECT) + // index zero (NListSectionNoSection) m_mach_sections.push_back(sect64); uint32_t segment_sect_idx; const lldb::user_id_t first_segment_sectID = sectID + 1; - const uint32_t num_u32s = load_cmd.cmd == LC_SEGMENT ? 7 : 8; + const uint32_t num_u32s = load_cmd.cmd == LoadCommandSegment32 ? 7 : 8; for (segment_sect_idx=0; segment_sect_idxFindSectionByName (g_section_name_eh_frame); - uint8_t TEXT_eh_frame_sectID = eh_frame_section_sp.get() ? eh_frame_section_sp->GetID() : NO_SECT; + uint8_t TEXT_eh_frame_sectID = eh_frame_section_sp.get() ? eh_frame_section_sp->GetID() : NListSectionNoSection; //uint32_t symtab_offset = 0; const uint8_t* nlist_data = symtab_data_sp->GetBytes(); assert (symtab_data_sp->GetByteSize()/nlist_size >= symtab_load_command.nsyms); @@ -635,7 +621,7 @@ if (bit_width_32) { struct nlist* nlist32_ptr = (struct nlist*)(nlist_data + (nlist_idx * nlist_size)); - nlist.n_un.n_strx = nlist32_ptr->n_un.n_strx; + nlist.n_strx = nlist32_ptr->n_strx; nlist.n_type = nlist32_ptr->n_type; nlist.n_sect = nlist32_ptr->n_sect; nlist.n_desc = nlist32_ptr->n_desc; @@ -647,12 +633,12 @@ } SymbolType type = eSymbolTypeInvalid; - const char* symbol_name = &strtab_data[nlist.n_un.n_strx]; + const char* symbol_name = &strtab_data[nlist.n_strx]; if (symbol_name[0] == '\0') symbol_name = NULL; Section* symbol_section = NULL; bool add_nlist = true; - bool is_debug = ((nlist.n_type & N_STAB) != 0); + bool is_debug = ((nlist.n_type & NlistMaskStab) != 0); assert (sym_idx < num_syms); @@ -662,18 +648,21 @@ { switch (nlist.n_type) { - case N_GSYM: // global symbol: name,,NO_SECT,type,0 + case StabGlobalSymbol: + // N_GSYM -- global symbol: name,,NO_SECT,type,0 // Sometimes the N_GSYM value contains the address. if (nlist.n_value != 0) symbol_section = section_info.GetSection (nlist.n_sect, nlist.n_value); type = eSymbolTypeGlobal; break; - case N_FNAME: // procedure name (f77 kludge): name,,NO_SECT,0,0 + case StabFunctionName: + // N_FNAME -- procedure name (f77 kludge): name,,NO_SECT,0,0 type = eSymbolTypeFunction; break; - case N_FUN: // procedure: name,,n_sect,linenumber,address + case StabFunction: + // N_FUN -- procedure: name,,n_sect,linenumber,address if (symbol_name) { type = eSymbolTypeFunction; @@ -701,17 +690,20 @@ } break; - case N_STSYM: // static symbol: name,,n_sect,type,address + case StabStaticSymbol: + // N_STSYM -- static symbol: name,,n_sect,type,address symbol_section = section_info.GetSection (nlist.n_sect, nlist.n_value); type = eSymbolTypeStatic; break; - case N_LCSYM: // .lcomm symbol: name,,n_sect,type,address + case StabLocalCommon: + // N_LCSYM -- .lcomm symbol: name,,n_sect,type,address symbol_section = section_info.GetSection (nlist.n_sect, nlist.n_value); type = eSymbolTypeCommonBlock; break; - case N_BNSYM: + case StabBeginSymbol: + // N_BNSYM // We use the current number of symbols in the symbol table in lieu of // using nlist_idx in case we ever start trimming entries out if (minimize) @@ -727,7 +719,8 @@ } break; - case N_ENSYM: + case StabEndSymbol: + // N_ENSYM // Set the size of the N_BNSYM to the terminating index of this N_ENSYM // so that we can always skip the entire symbol if we need to navigate // more quickly at the source level when parsing STABS @@ -750,24 +743,29 @@ break; - case N_OPT: // emitted with gcc2_compiled and in gcc source + case StabSourceFileOptions: + // N_OPT - emitted with gcc2_compiled and in gcc source type = eSymbolTypeCompiler; break; - case N_RSYM: // register sym: name,,NO_SECT,type,register + case StabRegisterSymbol: + // N_RSYM - register sym: name,,NO_SECT,type,register type = eSymbolTypeVariable; break; - case N_SLINE: // src line: 0,,n_sect,linenumber,address + case StabSourceLine: + // N_SLINE - src line: 0,,n_sect,linenumber,address symbol_section = section_info.GetSection (nlist.n_sect, nlist.n_value); type = eSymbolTypeLineEntry; break; - case N_SSYM: // structure elt: name,,NO_SECT,type,struct_offset + case StabStructureType: + // N_SSYM - structure elt: name,,NO_SECT,type,struct_offset type = eSymbolTypeVariableType; break; - case N_SO: + case StabSourceFileName: + // N_SO - source file name type = eSymbolTypeSourceFile; if (symbol_name == NULL) { @@ -802,25 +800,29 @@ } break; - case N_OSO: // object file name: name,,0,0,st_mtime + case StabObjectFileName: + // N_OSO - object file name: name,,0,0,st_mtime type = eSymbolTypeObjectFile; break; - case N_LSYM: // local sym: name,,NO_SECT,type,offset + case StabLocalSymbol: + // N_LSYM - local sym: name,,NO_SECT,type,offset type = eSymbolTypeLocal; break; //---------------------------------------------------------------------- // INCL scopes //---------------------------------------------------------------------- - case N_BINCL: // include file beginning: name,,NO_SECT,0,sum + case StabBeginIncludeFileName: + // N_BINCL - include file beginning: name,,NO_SECT,0,sum // We use the current number of symbols in the symbol table in lieu of // using nlist_idx in case we ever start trimming entries out N_INCL_indexes.push_back(sym_idx); type = eSymbolTypeScopeBegin; break; - case N_EINCL: // include file end: name,,NO_SECT,0,0 + case StabEndIncludeFile: + // N_EINCL - include file end: name,,NO_SECT,0,0 // Set the size of the N_BINCL to the terminating index of this N_EINCL // so that we can always skip the entire symbol if we need to navigate // more quickly at the source level when parsing STABS @@ -834,27 +836,33 @@ type = eSymbolTypeScopeEnd; break; - case N_SOL: // #included file name: name,,n_sect,0,address + case StabIncludeFileName: + // N_SOL - #included file name: name,,n_sect,0,address type = eSymbolTypeHeaderFile; break; - case N_PARAMS: // compiler parameters: name,,NO_SECT,0,0 + case StabCompilerParameters: + // N_PARAMS - compiler parameters: name,,NO_SECT,0,0 type = eSymbolTypeCompiler; break; - case N_VERSION: // compiler version: name,,NO_SECT,0,0 + case StabCompilerVersion: + // N_VERSION - compiler version: name,,NO_SECT,0,0 type = eSymbolTypeCompiler; break; - case N_OLEVEL: // compiler -O level: name,,NO_SECT,0,0 + case StabCompilerOptLevel: + // N_OLEVEL - compiler -O level: name,,NO_SECT,0,0 type = eSymbolTypeCompiler; break; - case N_PSYM: // parameter: name,,NO_SECT,type,offset + case StabParameter: + // N_PSYM - parameter: name,,NO_SECT,type,offset type = eSymbolTypeVariable; break; - case N_ENTRY: // alternate entry: name,,n_sect,linenumber,address + case StabAlternateEntry: + // N_ENTRY - alternate entry: name,,n_sect,linenumber,address symbol_section = section_info.GetSection (nlist.n_sect, nlist.n_value); type = eSymbolTypeLineEntry; break; @@ -862,7 +870,8 @@ //---------------------------------------------------------------------- // Left and Right Braces //---------------------------------------------------------------------- - case N_LBRAC: // left bracket: 0,,NO_SECT,nesting level,address + case StabLeftBracket: + // N_LBRAC - left bracket: 0,,NO_SECT,nesting level,address // We use the current number of symbols in the symbol table in lieu of // using nlist_idx in case we ever start trimming entries out symbol_section = section_info.GetSection (nlist.n_sect, nlist.n_value); @@ -870,7 +879,8 @@ type = eSymbolTypeScopeBegin; break; - case N_RBRAC: // right bracket: 0,,NO_SECT,nesting level,address + case StabRightBracket: + // N_RBRAC - right bracket: 0,,NO_SECT,nesting level,address // Set the size of the N_LBRAC to the terminating index of this N_RBRAC // so that we can always skip the entire symbol if we need to navigate // more quickly at the source level when parsing STABS @@ -885,25 +895,29 @@ type = eSymbolTypeScopeEnd; break; - case N_EXCL: // deleted include file: name,,NO_SECT,0,sum + case StabDeletedIncludeFile: + // N_EXCL - deleted include file: name,,NO_SECT,0,sum type = eSymbolTypeHeaderFile; break; //---------------------------------------------------------------------- // COMM scopes //---------------------------------------------------------------------- - case N_BCOMM: // begin common: name,,NO_SECT,0,0 + case StabBeginCommon: + // N_BCOMM - begin common: name,,NO_SECT,0,0 // We use the current number of symbols in the symbol table in lieu of // using nlist_idx in case we ever start trimming entries out type = eSymbolTypeScopeBegin; N_COMM_indexes.push_back(sym_idx); break; - case N_ECOML: // end common (local name): 0,,n_sect,0,address + case StabEndCommonLocal: + // N_ECOML - end common (local name): 0,,n_sect,0,address symbol_section = section_info.GetSection (nlist.n_sect, nlist.n_value); // Fall through - case N_ECOMM: // end common: name,,n_sect,0,0 + case StabEndCommon: + // N_ECOMM - end common: name,,n_sect,0,0 // Set the size of the N_BCOMM to the terminating index of this N_ECOMM/N_ECOML // so that we can always skip the entire symbol if we need to navigate // more quickly at the source level when parsing STABS @@ -917,7 +931,8 @@ type = eSymbolTypeScopeEnd; break; - case N_LENG: // second stab entry with length information + case StabLength: + // N_LENG - second stab entry with length information type = eSymbolTypeAdditional; break; @@ -926,9 +941,9 @@ } else { - //uint8_t n_pext = N_PEXT & nlist.n_type; - uint8_t n_type = N_TYPE & nlist.n_type; - sym[sym_idx].SetExternal((N_EXT & nlist.n_type) != 0); + //uint8_t n_pext = NlistMaskPrivateExternal & nlist.n_type; + uint8_t n_type = NlistMaskType & nlist.n_type; + sym[sym_idx].SetExternal((NlistMaskExternal & nlist.n_type) != 0); if (symbol_name && ::strstr (symbol_name, ".objc") == symbol_name) { @@ -938,17 +953,17 @@ { switch (n_type) { - case N_INDR: // Fall through - case N_PBUD: // Fall through - case N_UNDF: + case NListTypeIndirect: // N_INDR - Fall through + case NListTypePreboundUndefined:// N_PBUD - Fall through + case NListTypeUndefined: // N_UNDF type = eSymbolTypeExtern; break; - case N_ABS: + case NListTypeAbsolute: // N_ABS type = eSymbolTypeAbsolute; break; - case N_SECT: + case NListTypeSection: // N_SECT symbol_section = section_info.GetSection (nlist.n_sect, nlist.n_value); assert(symbol_section != NULL); @@ -958,27 +973,27 @@ } else { - uint32_t section_type = symbol_section->GetAllFlagBits() & SECTION_TYPE; + uint32_t section_type = symbol_section->GetAllFlagBits() & SectionFlagMaskSectionType; switch (section_type) { - case S_REGULAR: break; // regular section - //case S_ZEROFILL: type = eSymbolTypeData; break; // zero fill on demand section - case S_CSTRING_LITERALS: type = eSymbolTypeData; break; // section with only literal C strings - case S_4BYTE_LITERALS: type = eSymbolTypeData; break; // section with only 4 byte literals - case S_8BYTE_LITERALS: type = eSymbolTypeData; break; // section with only 8 byte literals - case S_LITERAL_POINTERS: type = eSymbolTypeTrampoline; break; // section with only pointers to literals - case S_NON_LAZY_SYMBOL_POINTERS: type = eSymbolTypeTrampoline; break; // section with only non-lazy symbol pointers - case S_LAZY_SYMBOL_POINTERS: type = eSymbolTypeTrampoline; break; // section with only lazy symbol pointers - case S_SYMBOL_STUBS: type = eSymbolTypeTrampoline; break; // section with only symbol stubs, byte size of stub in the reserved2 field - case S_MOD_INIT_FUNC_POINTERS: type = eSymbolTypeCode; break; // section with only function pointers for initialization - case S_MOD_TERM_FUNC_POINTERS: type = eSymbolTypeCode; break; // section with only function pointers for termination - //case S_COALESCED: type = eSymbolType; break; // section contains symbols that are to be coalesced - //case S_GB_ZEROFILL: type = eSymbolTypeData; break; // zero fill on demand section (that can be larger than 4 gigabytes) - case S_INTERPOSING: type = eSymbolTypeTrampoline; break; // section with only pairs of function pointers for interposing - case S_16BYTE_LITERALS: type = eSymbolTypeData; break; // section with only 16 byte literals - case S_DTRACE_DOF: type = eSymbolTypeInstrumentation; break; - case S_LAZY_DYLIB_SYMBOL_POINTERS: type = eSymbolTypeTrampoline; break; + case SectionTypeRegular: break; // regular section + //case SectionTypeZeroFill: type = eSymbolTypeData; break; // zero fill on demand section + case SectionTypeCStringLiterals: type = eSymbolTypeData; break; // section with only literal C strings + case SectionType4ByteLiterals: type = eSymbolTypeData; break; // section with only 4 byte literals + case SectionType8ByteLiterals: type = eSymbolTypeData; break; // section with only 8 byte literals + case SectionTypeLiteralPointers: type = eSymbolTypeTrampoline; break; // section with only pointers to literals + case SectionTypeNonLazySymbolPointers: type = eSymbolTypeTrampoline; break; // section with only non-lazy symbol pointers + case SectionTypeLazySymbolPointers: type = eSymbolTypeTrampoline; break; // section with only lazy symbol pointers + case SectionTypeSymbolStubs: type = eSymbolTypeTrampoline; break; // section with only symbol stubs, byte size of stub in the reserved2 field + case SectionTypeModuleInitFunctionPointers: type = eSymbolTypeCode; break; // section with only function pointers for initialization + case SectionTypeModuleTermFunctionPointers: type = eSymbolTypeCode; break; // section with only function pointers for termination + //case SectionTypeCoalesced: type = eSymbolType; break; // section contains symbols that are to be coalesced + //case SectionTypeZeroFillLarge: type = eSymbolTypeData; break; // zero fill on demand section (that can be larger than 4 gigabytes) + case SectionTypeInterposing: type = eSymbolTypeTrampoline; break; // section with only pairs of function pointers for interposing + case SectionType16ByteLiterals: type = eSymbolTypeData; break; // section with only 16 byte literals + case SectionTypeDTraceObjectFormat: type = eSymbolTypeInstrumentation; break; + case SectionTypeLazyDylibSymbolPointers: type = eSymbolTypeTrampoline; break; default: break; } @@ -987,7 +1002,9 @@ const char *symbol_sect_name = symbol_section->GetName().AsCString(); if (symbol_section->IsDescendant (text_section_sp.get())) { - if (symbol_section->IsClear(S_ATTR_PURE_INSTRUCTIONS | S_ATTR_SELF_MODIFYING_CODE | S_ATTR_SOME_INSTRUCTIONS)) + if (symbol_section->IsClear(SectionAttrUserPureInstructions | + SectionAttrUserSelfModifyingCode | + SectionAttrSytemSomeInstructions)) type = eSymbolTypeData; else type = eSymbolTypeCode; @@ -1097,7 +1114,7 @@ for (uint32_t sect_idx = 1; sect_idx < m_mach_sections.size(); ++sect_idx) { - if ((m_mach_sections[sect_idx].flags & SECTION_TYPE) == S_SYMBOL_STUBS) + if ((m_mach_sections[sect_idx].flags & SectionFlagMaskSectionType) == SectionTypeSymbolStubs) { uint32_t symbol_stub_byte_size = m_mach_sections[sect_idx].reserved2; if (symbol_stub_byte_size == 0) @@ -1177,7 +1194,7 @@ lldb_private::Mutex::Locker locker(m_mutex); s->Printf("%.*p: ", (int)sizeof(void*) * 2, this); s->Indent(); - if (m_header.magic == MH_MAGIC_64 || m_header.magic == MH_CIGAM_64) + if (m_header.magic == HeaderMagic64 || m_header.magic == HeaderMagic64Swapped) s->PutCString("ObjectFileMachO64"); else s->PutCString("ObjectFileMachO32"); @@ -1207,7 +1224,7 @@ if (m_data.GetU32(&offset, &load_cmd, 2) == NULL) break; - if (load_cmd.cmd == LC_UUID) + if (load_cmd.cmd == LoadCommandUUID) { const uint8_t *uuid_bytes = m_data.PeekData(offset, 16); if (uuid_bytes) @@ -1239,11 +1256,11 @@ switch (load_cmd.cmd) { - case LC_LOAD_DYLIB: - case LC_LOAD_WEAK_DYLIB: - case LC_REEXPORT_DYLIB: - case LC_LOAD_DYLINKER: - case LC_LOADFVMLIB: + case LoadCommandDylibLoad: + case LoadCommandDylibLoadWeak: + case LoadCommandDylibReexport: + case LoadCommandDynamicLinkerLoad: + case LoadCommandFixedVMShlibLoad: { uint32_t name_offset = cmd_offset + m_data.GetU32(&offset); const char *path = m_data.PeekCStr(name_offset); Modified: lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.h?rev=109046&r1=109045&r2=109046&view=diff ============================================================================== --- lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.h (original) +++ lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.h Wed Jul 21 17:12:05 2010 @@ -10,7 +10,8 @@ #ifndef liblldb_ObjectFileMachO_h_ #define liblldb_ObjectFileMachO_h_ -#include +#include "llvm/Support/MachO.h" + #include "lldb/Core/FileSpec.h" #include "lldb/Host/Mutex.h" #include "lldb/Symbol/ObjectFile.h" @@ -112,13 +113,13 @@ protected: mutable lldb_private::Mutex m_mutex; - struct mach_header m_header; + llvm::MachO::mach_header m_header; mutable std::auto_ptr m_sections_ap; mutable std::auto_ptr m_symtab_ap; - struct dysymtab_command m_dysymtab; - std::vector m_mach_segments; - std::vector m_mach_sections; + llvm::MachO::dysymtab_command m_dysymtab; + std::vector m_mach_segments; + std::vector m_mach_sections; size_t ParseSections (); 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=109046&r1=109045&r2=109046&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp (original) +++ lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp Wed Jul 21 17:12:05 2010 @@ -9,15 +9,9 @@ // C Includes #include -#include -#include #include -#include #include -#include #include -#include -#include // C++ Includes #include Modified: lldb/trunk/source/Plugins/SymbolVendor/MacOSX/SymbolVendorMacOSX.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolVendor/MacOSX/SymbolVendorMacOSX.cpp?rev=109046&r1=109045&r2=109046&view=diff ============================================================================== --- lldb/trunk/source/Plugins/SymbolVendor/MacOSX/SymbolVendorMacOSX.cpp (original) +++ lldb/trunk/source/Plugins/SymbolVendor/MacOSX/SymbolVendorMacOSX.cpp Wed Jul 21 17:12:05 2010 @@ -9,8 +9,6 @@ #include "SymbolVendorMacOSX.h" -#include // DebugSymbols needs this on Leopard... - #include #include "lldb/Core/Module.h" Removed: lldb/trunk/source/Symbol/ASTType.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/ASTType.cpp?rev=109045&view=auto ============================================================================== --- lldb/trunk/source/Symbol/ASTType.cpp (original) +++ lldb/trunk/source/Symbol/ASTType.cpp (removed) @@ -1,20 +0,0 @@ -//===-- ASTType.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/Symbol/ASTType.h" - -using namespace lldb_private; - -ASTTypeBase::~ASTTypeBase() -{ -} - -ASTType::~ASTType() -{ -} \ No newline at end of file Modified: lldb/trunk/source/Symbol/ClangASTContext.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/ClangASTContext.cpp?rev=109046&r1=109045&r2=109046&view=diff ============================================================================== --- lldb/trunk/source/Symbol/ClangASTContext.cpp (original) +++ lldb/trunk/source/Symbol/ClangASTContext.cpp Wed Jul 21 17:12:05 2010 @@ -316,11 +316,11 @@ return m_selector_table_ap.get(); } -SourceManager * +clang::SourceManager * ClangASTContext::getSourceManager() { if (m_source_manager_ap.get() == NULL) - m_source_manager_ap.reset(new SourceManager(*getDiagnostic())); + m_source_manager_ap.reset(new clang::SourceManager(*getDiagnostic())); return m_source_manager_ap.get(); } @@ -758,7 +758,7 @@ QualType record_qual_type(QualType::getFromOpaquePtr(record_clang_type)); - Type *clang_type = record_qual_type.getTypePtr(); + clang::Type *clang_type = record_qual_type.getTypePtr(); if (clang_type) { const RecordType *record_type = dyn_cast(clang_type); @@ -863,7 +863,7 @@ if (clang_qual_type) { QualType qual_type(QualType::getFromOpaquePtr(clang_qual_type)); - Type *clang_type = qual_type.getTypePtr(); + clang::Type *clang_type = qual_type.getTypePtr(); if (clang_type) { RecordType *record_type = dyn_cast(clang_type); @@ -913,7 +913,7 @@ { if (class_clang_type) { - Type *clang_type = QualType::getFromOpaquePtr(class_clang_type).getTypePtr(); + clang::Type *clang_type = QualType::getFromOpaquePtr(class_clang_type).getTypePtr(); if (clang_type) { RecordType *record_type = dyn_cast(clang_type); @@ -948,15 +948,15 @@ switch (qual_type->getTypeClass()) { - case Type::IncompleteArray: - case Type::VariableArray: - case Type::ConstantArray: - case Type::ExtVector: - case Type::Vector: - case Type::Record: + case clang::Type::IncompleteArray: + case clang::Type::VariableArray: + case clang::Type::ConstantArray: + case clang::Type::ExtVector: + case clang::Type::Vector: + case clang::Type::Record: return true; - case Type::Typedef: + case clang::Type::Typedef: return ClangASTContext::IsAggregateType (cast(qual_type)->LookThroughTypedefs().getAsOpaquePtr()); default: @@ -976,7 +976,7 @@ QualType qual_type(QualType::getFromOpaquePtr(clang_qual_type)); switch (qual_type->getTypeClass()) { - case Type::Record: + case clang::Type::Record: { const RecordType *record_type = cast(qual_type.getTypePtr()); const RecordDecl *record_decl = record_type->getDecl(); @@ -1017,11 +1017,11 @@ } break; - case Type::ConstantArray: + case clang::Type::ConstantArray: num_children = cast(qual_type.getTypePtr())->getSize().getLimitedValue(); break; - case Type::Pointer: + case clang::Type::Pointer: { PointerType *pointer_type = cast(qual_type.getTypePtr()); QualType pointee_type = pointer_type->getPointeeType(); @@ -1034,7 +1034,7 @@ } break; - case Type::Typedef: + case clang::Type::Typedef: num_children = ClangASTContext::GetNumChildren (cast(qual_type)->LookThroughTypedefs().getAsOpaquePtr(), omit_empty_base_classes); break; @@ -1103,7 +1103,7 @@ QualType parent_qual_type(QualType::getFromOpaquePtr(parent_clang_type)); switch (parent_qual_type->getTypeClass()) { - case Type::Record: + case clang::Type::Record: { const RecordType *record_type = cast(parent_qual_type.getTypePtr()); const RecordDecl *record_decl = record_type->getDecl(); @@ -1190,7 +1190,7 @@ } break; - case Type::ConstantArray: + case clang::Type::ConstantArray: { const ConstantArrayType *array = cast(parent_qual_type.getTypePtr()); const uint64_t element_count = array->getSize().getLimitedValue(); @@ -1211,7 +1211,7 @@ } break; - case Type::Pointer: + case clang::Type::Pointer: { PointerType *pointer_type = cast(parent_qual_type.getTypePtr()); QualType pointee_type = pointer_type->getPointeeType(); @@ -1251,7 +1251,7 @@ } break; - case Type::Typedef: + case clang::Type::Typedef: return GetChildClangTypeAtIndex (ast_context, parent_name, cast(parent_qual_type)->LookThroughTypedefs().getAsOpaquePtr(), @@ -1461,7 +1461,7 @@ QualType qual_type(QualType::getFromOpaquePtr(clang_type)); switch (qual_type->getTypeClass()) { - case Type::Record: + case clang::Type::Record: { const RecordType *record_type = cast(qual_type.getTypePtr()); const RecordDecl *record_decl = record_type->getDecl(); @@ -1548,7 +1548,7 @@ } break; - case Type::ConstantArray: + case clang::Type::ConstantArray: { // const ConstantArrayType *array = cast(parent_qual_type.getTypePtr()); // const uint64_t element_count = array->getSize().getLimitedValue(); @@ -1569,7 +1569,7 @@ } break; -// case Type::MemberPointerType: +// case clang::Type::MemberPointerType: // { // MemberPointerType *mem_ptr_type = cast(qual_type.getTypePtr()); // QualType pointee_type = mem_ptr_type->getPointeeType(); @@ -1583,8 +1583,8 @@ // } // break; // - case Type::LValueReference: - case Type::RValueReference: + case clang::Type::LValueReference: + case clang::Type::RValueReference: { ReferenceType *reference_type = cast(qual_type.getTypePtr()); QualType pointee_type = reference_type->getPointeeType(); @@ -1600,7 +1600,7 @@ } break; - case Type::Pointer: + case clang::Type::Pointer: { PointerType *pointer_type = cast(qual_type.getTypePtr()); QualType pointee_type = pointer_type->getPointeeType(); @@ -1634,7 +1634,7 @@ } break; - case Type::Typedef: + case clang::Type::Typedef: return GetIndexOfChildMemberWithName (ast_context, cast(qual_type)->LookThroughTypedefs().getAsOpaquePtr(), name, @@ -1667,7 +1667,7 @@ QualType qual_type(QualType::getFromOpaquePtr(clang_type)); switch (qual_type->getTypeClass()) { - case Type::Record: + case clang::Type::Record: { const RecordType *record_type = cast(qual_type.getTypePtr()); const RecordDecl *record_decl = record_type->getDecl(); @@ -1709,7 +1709,7 @@ } break; - case Type::ConstantArray: + case clang::Type::ConstantArray: { // const ConstantArrayType *array = cast(parent_qual_type.getTypePtr()); // const uint64_t element_count = array->getSize().getLimitedValue(); @@ -1730,7 +1730,7 @@ } break; -// case Type::MemberPointerType: +// case clang::Type::MemberPointerType: // { // MemberPointerType *mem_ptr_type = cast(qual_type.getTypePtr()); // QualType pointee_type = mem_ptr_type->getPointeeType(); @@ -1744,8 +1744,8 @@ // } // break; // - case Type::LValueReference: - case Type::RValueReference: + case clang::Type::LValueReference: + case clang::Type::RValueReference: { ReferenceType *reference_type = cast(qual_type.getTypePtr()); QualType pointee_type = reference_type->getPointeeType(); @@ -1760,7 +1760,7 @@ } break; - case Type::Pointer: + case clang::Type::Pointer: { PointerType *pointer_type = cast(qual_type.getTypePtr()); QualType pointee_type = pointer_type->getPointeeType(); @@ -1793,7 +1793,7 @@ } break; - case Type::Typedef: + case clang::Type::Typedef: return GetIndexOfChildWithName (ast_context, cast(qual_type)->LookThroughTypedefs().getAsOpaquePtr(), name, @@ -1814,7 +1814,7 @@ if (tag_clang_type) { QualType tag_qual_type(QualType::getFromOpaquePtr(tag_clang_type)); - Type *clang_type = tag_qual_type.getTypePtr(); + clang::Type *clang_type = tag_qual_type.getTypePtr(); if (clang_type) { TagType *tag_type = dyn_cast(clang_type); @@ -1844,34 +1844,34 @@ QualType qual_type(QualType::getFromOpaquePtr(clang_type)); switch (qual_type->getTypeClass()) { - case Type::FunctionNoProto: break; - case Type::FunctionProto: break; - case Type::IncompleteArray: break; - case Type::VariableArray: break; - case Type::ConstantArray: break; - case Type::ExtVector: break; - case Type::Vector: break; - case Type::Builtin: break; - case Type::ObjCObjectPointer: break; - case Type::BlockPointer: break; - case Type::Pointer: break; - case Type::LValueReference: break; - case Type::RValueReference: break; - case Type::MemberPointer: break; - case Type::Complex: break; - case Type::ObjCInterface: break; - case Type::Record: + case clang::Type::FunctionNoProto: break; + case clang::Type::FunctionProto: break; + case clang::Type::IncompleteArray: break; + case clang::Type::VariableArray: break; + case clang::Type::ConstantArray: break; + case clang::Type::ExtVector: break; + case clang::Type::Vector: break; + case clang::Type::Builtin: break; + case clang::Type::ObjCObjectPointer: break; + case clang::Type::BlockPointer: break; + case clang::Type::Pointer: break; + case clang::Type::LValueReference: break; + case clang::Type::RValueReference: break; + case clang::Type::MemberPointer: break; + case clang::Type::Complex: break; + case clang::Type::ObjCInterface: break; + case clang::Type::Record: return cast(qual_type)->getDecl(); - case Type::Enum: + case clang::Type::Enum: return cast(qual_type)->getDecl(); - case Type::Typedef: + case clang::Type::Typedef: return ClangASTContext::GetDeclContextForType (cast(qual_type)->LookThroughTypedefs().getAsOpaquePtr()); - case Type::TypeOfExpr: break; - case Type::TypeOf: break; - case Type::Decltype: break; - //case Type::QualifiedName: break; - case Type::TemplateSpecialization: break; + case clang::Type::TypeOfExpr: break; + case clang::Type::TypeOf: break; + case clang::Type::Decltype: break; + //case clang::Type::QualifiedName: break; + case clang::Type::TemplateSpecialization: break; } // No DeclContext in this type... return NULL; @@ -2006,7 +2006,7 @@ if (clang_type) { QualType qual_type (QualType::getFromOpaquePtr(clang_type)); - Type *t = qual_type.getTypePtr(); + clang::Type *t = qual_type.getTypePtr(); if (t) { TagType *tag_type = dyn_cast(t); @@ -2030,7 +2030,7 @@ if (clang_type) { QualType qual_type (QualType::getFromOpaquePtr(clang_type)); - Type *t = qual_type.getTypePtr(); + clang::Type *t = qual_type.getTypePtr(); if (t) { TagType *tag_type = dyn_cast(t); @@ -2091,7 +2091,7 @@ assert (identifier_table != NULL); QualType enum_qual_type (QualType::getFromOpaquePtr(enum_clang_type)); - Type *clang_type = enum_qual_type.getTypePtr(); + clang::Type *clang_type = enum_qual_type.getTypePtr(); if (clang_type) { const EnumType *enum_type = dyn_cast(clang_type); @@ -2171,31 +2171,31 @@ QualType qual_type (QualType::getFromOpaquePtr(clang_type)); switch (qual_type->getTypeClass()) { - case Type::ObjCObjectPointer: + case clang::Type::ObjCObjectPointer: if (target_type) *target_type = cast(qual_type)->getPointeeType().getAsOpaquePtr(); return true; - case Type::BlockPointer: + case clang::Type::BlockPointer: if (target_type) *target_type = cast(qual_type)->getPointeeType().getAsOpaquePtr(); return true; - case Type::Pointer: + case clang::Type::Pointer: if (target_type) *target_type = cast(qual_type)->getPointeeType().getAsOpaquePtr(); return true; - case Type::MemberPointer: + case clang::Type::MemberPointer: if (target_type) *target_type = cast(qual_type)->getPointeeType().getAsOpaquePtr(); return true; - case Type::LValueReference: + case clang::Type::LValueReference: if (target_type) *target_type = cast(qual_type)->desugar().getAsOpaquePtr(); return true; - case Type::RValueReference: + case clang::Type::RValueReference: if (target_type) *target_type = cast(qual_type)->desugar().getAsOpaquePtr(); return true; - case Type::Typedef: + case clang::Type::Typedef: return ClangASTContext::IsPointerOrReferenceType (cast(qual_type)->LookThroughTypedefs().getAsOpaquePtr()); default: break; @@ -2247,23 +2247,23 @@ QualType qual_type (QualType::getFromOpaquePtr(clang_type)); switch (qual_type->getTypeClass()) { - case Type::ObjCObjectPointer: + case clang::Type::ObjCObjectPointer: if (target_type) *target_type = cast(qual_type)->getPointeeType().getAsOpaquePtr(); return true; - case Type::BlockPointer: + case clang::Type::BlockPointer: if (target_type) *target_type = cast(qual_type)->getPointeeType().getAsOpaquePtr(); return true; - case Type::Pointer: + case clang::Type::Pointer: if (target_type) *target_type = cast(qual_type)->getPointeeType().getAsOpaquePtr(); return true; - case Type::MemberPointer: + case clang::Type::MemberPointer: if (target_type) *target_type = cast(qual_type)->getPointeeType().getAsOpaquePtr(); return true; - case Type::Typedef: + case clang::Type::Typedef: return ClangASTContext::IsPointerOrReferenceType (cast(qual_type)->LookThroughTypedefs().getAsOpaquePtr(), target_type); default: break; @@ -2320,11 +2320,11 @@ QualType qual_type (QualType::getFromOpaquePtr(clang_type)); switch (qual_type->getTypeClass()) { - case Type::ConstantArray: + case clang::Type::ConstantArray: { ConstantArrayType *array = cast(qual_type.getTypePtr()); QualType element_qual_type = array->getElementType(); - Type *canonical_type = element_qual_type->getCanonicalTypeInternal().getTypePtr(); + clang::Type *canonical_type = element_qual_type->getCanonicalTypeInternal().getTypePtr(); if (canonical_type && canonical_type->isCharType()) { // We know the size of the array and it could be a C string @@ -2335,13 +2335,13 @@ } break; - case Type::Pointer: + case clang::Type::Pointer: { PointerType *pointer_type = cast(qual_type.getTypePtr()); - Type *pointee_type_ptr = pointer_type->getPointeeType().getTypePtr(); + clang::Type *pointee_type_ptr = pointer_type->getPointeeType().getTypePtr(); if (pointee_type_ptr) { - Type *canonical_type_ptr = pointee_type_ptr->getCanonicalTypeInternal().getTypePtr(); + clang::Type *canonical_type_ptr = pointee_type_ptr->getCanonicalTypeInternal().getTypePtr(); length = 0; // No length info, read until a NULL terminator is received if (canonical_type_ptr) return canonical_type_ptr->isCharType(); @@ -2351,17 +2351,17 @@ } break; - case Type::Typedef: + case clang::Type::Typedef: return ClangASTContext::IsCStringType (cast(qual_type)->LookThroughTypedefs().getAsOpaquePtr(), length); - case Type::LValueReference: - case Type::RValueReference: + case clang::Type::LValueReference: + case clang::Type::RValueReference: { ReferenceType *reference_type = cast(qual_type.getTypePtr()); - Type *pointee_type_ptr = reference_type->getPointeeType().getTypePtr(); + clang::Type *pointee_type_ptr = reference_type->getPointeeType().getTypePtr(); if (pointee_type_ptr) { - Type *canonical_type_ptr = pointee_type_ptr->getCanonicalTypeInternal().getTypePtr(); + clang::Type *canonical_type_ptr = pointee_type_ptr->getCanonicalTypeInternal().getTypePtr(); length = 0; // No length info, read until a NULL terminator is received if (canonical_type_ptr) return canonical_type_ptr->isCharType(); @@ -2385,24 +2385,24 @@ switch (qual_type->getTypeClass()) { - case Type::ConstantArray: + case clang::Type::ConstantArray: if (member_type) *member_type = cast(qual_type)->getElementType().getAsOpaquePtr(); if (size) *size = cast(qual_type)->getSize().getLimitedValue(ULONG_LONG_MAX); return true; - case Type::IncompleteArray: + case clang::Type::IncompleteArray: if (member_type) *member_type = cast(qual_type)->getElementType().getAsOpaquePtr(); if (size) *size = 0; return true; - case Type::VariableArray: + case clang::Type::VariableArray: if (member_type) *member_type = cast(qual_type)->getElementType().getAsOpaquePtr(); if (size) *size = 0; - case Type::DependentSizedArray: + case clang::Type::DependentSizedArray: if (member_type) *member_type = cast(qual_type)->getElementType().getAsOpaquePtr(); if (size) Copied: lldb/trunk/source/Symbol/ClangASTType.cpp (from r109016, lldb/trunk/source/Symbol/ASTType.cpp) URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/ClangASTType.cpp?p2=lldb/trunk/source/Symbol/ClangASTType.cpp&p1=lldb/trunk/source/Symbol/ASTType.cpp&r1=109016&r2=109046&rev=109046&view=diff ============================================================================== --- lldb/trunk/source/Symbol/ASTType.cpp (original) +++ lldb/trunk/source/Symbol/ClangASTType.cpp Wed Jul 21 17:12:05 2010 @@ -1,4 +1,4 @@ -//===-- ASTType.cpp ---------------------------------------------*- C++ -*-===// +//===-- ClangASTType.cpp ---------------------------------------------*- C++ -*-===// // // The LLVM Compiler Infrastructure // @@ -7,14 +7,1108 @@ // //===----------------------------------------------------------------------===// -#include "lldb/Symbol/ASTType.h" +#include "lldb/Symbol/ClangASTType.h" + +#include "clang/AST/ASTConsumer.h" +#include "clang/AST/ASTContext.h" +#include "clang/AST/Decl.h" +#include "clang/AST/DeclCXX.h" +#include "clang/AST/DeclGroup.h" +#include "clang/AST/RecordLayout.h" + +#include "clang/Basic/Builtins.h" +#include "clang/Basic/IdentifierTable.h" +#include "clang/Basic/LangOptions.h" +#include "clang/Basic/SourceManager.h" +#include "clang/Basic/TargetInfo.h" + +#include "llvm/Support/FormattedStream.h" +#include "llvm/Support/raw_ostream.h" + +#include "lldb/Core/ConstString.h" +#include "lldb/Core/DataBufferHeap.h" +#include "lldb/Core/DataExtractor.h" +#include "lldb/Core/Scalar.h" +#include "lldb/Core/Stream.h" +#include "lldb/Core/StreamString.h" +#include "lldb/Symbol/ClangASTContext.h" +#include "lldb/Target/ExecutionContext.h" +#include "lldb/Target/Process.h" using namespace lldb_private; -ASTTypeBase::~ASTTypeBase() +ClangASTType::~ClangASTType() +{ +} + +ConstString +ClangASTType::GetClangTypeName () +{ + return GetClangTypeName (m_type); +} + +ConstString +ClangASTType::GetClangTypeName (void *opaque_clang_qual_type) +{ + ConstString clang_type_name; + if (opaque_clang_qual_type) + { + clang::QualType qual_type(clang::QualType::getFromOpaquePtr(opaque_clang_qual_type)); + + const clang::TypedefType *typedef_type = qual_type->getAs(); + if (typedef_type) + { + const clang::TypedefDecl *typedef_decl = typedef_type->getDecl(); + std::string clang_typedef_name (typedef_decl->getQualifiedNameAsString()); + if (!clang_typedef_name.empty()) + clang_type_name.SetCString (clang_typedef_name.c_str()); + } + else + { + std::string type_name(qual_type.getAsString()); + if (!type_name.empty()) + clang_type_name.SetCString (type_name.c_str()); + } + } + else + { + clang_type_name.SetCString (""); + } + + return clang_type_name; +} + +lldb::Encoding +ClangASTType::GetEncoding (uint32_t &count) +{ + return GetEncoding(m_type, count); +} + + +lldb::Encoding +ClangASTType::GetEncoding (void *opaque_clang_qual_type, uint32_t &count) +{ + count = 1; + clang::QualType qual_type(clang::QualType::getFromOpaquePtr(opaque_clang_qual_type)); + + switch (qual_type->getTypeClass()) + { + case clang::Type::FunctionNoProto: + case clang::Type::FunctionProto: + break; + + case clang::Type::IncompleteArray: + case clang::Type::VariableArray: + break; + + case clang::Type::ConstantArray: + break; + + case clang::Type::ExtVector: + case clang::Type::Vector: + // TODO: Set this to more than one??? + break; + + case clang::Type::Builtin: + switch (cast(qual_type)->getKind()) + { + default: assert(0 && "Unknown builtin type!"); + case clang::BuiltinType::Void: + break; + + case clang::BuiltinType::Bool: + case clang::BuiltinType::Char_S: + case clang::BuiltinType::SChar: + case clang::BuiltinType::WChar: + case clang::BuiltinType::Char16: + case clang::BuiltinType::Char32: + case clang::BuiltinType::Short: + case clang::BuiltinType::Int: + case clang::BuiltinType::Long: + case clang::BuiltinType::LongLong: + case clang::BuiltinType::Int128: return lldb::eEncodingSint; + + case clang::BuiltinType::Char_U: + case clang::BuiltinType::UChar: + case clang::BuiltinType::UShort: + case clang::BuiltinType::UInt: + case clang::BuiltinType::ULong: + case clang::BuiltinType::ULongLong: + case clang::BuiltinType::UInt128: return lldb::eEncodingUint; + + case clang::BuiltinType::Float: + case clang::BuiltinType::Double: + case clang::BuiltinType::LongDouble: return lldb::eEncodingIEEE754; + + case clang::BuiltinType::NullPtr: return lldb::eEncodingUint; + } + break; + // All pointer types are represented as unsigned integer encodings. + // We may nee to add a eEncodingPointer if we ever need to know the + // difference + case clang::Type::ObjCObjectPointer: + case clang::Type::BlockPointer: + case clang::Type::Pointer: + case clang::Type::LValueReference: + case clang::Type::RValueReference: + case clang::Type::MemberPointer: return lldb::eEncodingUint; + // Complex numbers are made up of floats + case clang::Type::Complex: + count = 2; + return lldb::eEncodingIEEE754; + + case clang::Type::ObjCInterface: break; + case clang::Type::Record: break; + case clang::Type::Enum: return lldb::eEncodingSint; + case clang::Type::Typedef: + return GetEncoding(cast(qual_type)->LookThroughTypedefs().getAsOpaquePtr(), count); + break; + + case clang::Type::TypeOfExpr: + case clang::Type::TypeOf: + case clang::Type::Decltype: +// case clang::Type::QualifiedName: + case clang::Type::TemplateSpecialization: break; + } + count = 0; + return lldb::eEncodingInvalid; +} + +lldb::Format +ClangASTType::GetFormat () { + return GetFormat (m_type); } -ASTType::~ASTType() +lldb::Format +ClangASTType::GetFormat (void *opaque_clang_qual_type) { -} \ No newline at end of file + clang::QualType qual_type(clang::QualType::getFromOpaquePtr(opaque_clang_qual_type)); + + switch (qual_type->getTypeClass()) + { + case clang::Type::FunctionNoProto: + case clang::Type::FunctionProto: + break; + + case clang::Type::IncompleteArray: + case clang::Type::VariableArray: + break; + + case clang::Type::ConstantArray: + break; + + case clang::Type::ExtVector: + case clang::Type::Vector: + break; + + case clang::Type::Builtin: + switch (cast(qual_type)->getKind()) + { + default: assert(0 && "Unknown builtin type!"); + case clang::BuiltinType::Void: + break; + + case clang::BuiltinType::Bool: return lldb::eFormatBoolean; + case clang::BuiltinType::Char_S: + case clang::BuiltinType::SChar: + case clang::BuiltinType::Char_U: + case clang::BuiltinType::UChar: + case clang::BuiltinType::WChar: return lldb::eFormatChar; + case clang::BuiltinType::Char16: return lldb::eFormatUnicode16; + case clang::BuiltinType::Char32: return lldb::eFormatUnicode32; + case clang::BuiltinType::UShort: return lldb::eFormatHex; + case clang::BuiltinType::Short: return lldb::eFormatDecimal; + case clang::BuiltinType::UInt: return lldb::eFormatHex; + case clang::BuiltinType::Int: return lldb::eFormatDecimal; + case clang::BuiltinType::ULong: return lldb::eFormatHex; + case clang::BuiltinType::Long: return lldb::eFormatDecimal; + case clang::BuiltinType::ULongLong: return lldb::eFormatHex; + case clang::BuiltinType::LongLong: return lldb::eFormatDecimal; + case clang::BuiltinType::UInt128: return lldb::eFormatHex; + case clang::BuiltinType::Int128: return lldb::eFormatDecimal; + case clang::BuiltinType::Float: return lldb::eFormatFloat; + case clang::BuiltinType::Double: return lldb::eFormatFloat; + case clang::BuiltinType::LongDouble: return lldb::eFormatFloat; + case clang::BuiltinType::NullPtr: return lldb::eFormatHex; + } + break; + case clang::Type::ObjCObjectPointer: return lldb::eFormatHex; + case clang::Type::BlockPointer: return lldb::eFormatHex; + case clang::Type::Pointer: return lldb::eFormatHex; + case clang::Type::LValueReference: + case clang::Type::RValueReference: return lldb::eFormatHex; + case clang::Type::MemberPointer: break; + case clang::Type::Complex: return lldb::eFormatComplex; + case clang::Type::ObjCInterface: break; + case clang::Type::Record: break; + case clang::Type::Enum: return lldb::eFormatEnum; + case clang::Type::Typedef: + return ClangASTType::GetFormat(cast(qual_type)->LookThroughTypedefs().getAsOpaquePtr()); + + case clang::Type::TypeOfExpr: + case clang::Type::TypeOf: + case clang::Type::Decltype: +// case clang::Type::QualifiedName: + case clang::Type::TemplateSpecialization: break; + } + // We don't know hot to display this type... + return lldb::eFormatBytes; +} + + +void +ClangASTType::DumpValue +( + ExecutionContext *exe_ctx, + Stream *s, + lldb::Format format, + const lldb_private::DataExtractor &data, + uint32_t data_byte_offset, + size_t data_byte_size, + uint32_t bitfield_bit_size, + uint32_t bitfield_bit_offset, + bool show_types, + bool show_summary, + bool verbose, + uint32_t depth +) +{ + return DumpValue (m_ast, + m_type, + exe_ctx, + s, + format, + data, + data_byte_offset, + data_byte_size, + bitfield_bit_size, + bitfield_bit_offset, + show_types, + show_summary, + verbose, + depth); +} + +#define DEPTH_INCREMENT 2 +void +ClangASTType::DumpValue +( + clang::ASTContext *ast_context, + void *opaque_clang_qual_type, + ExecutionContext *exe_ctx, + Stream *s, + lldb::Format format, + const lldb_private::DataExtractor &data, + uint32_t data_byte_offset, + size_t data_byte_size, + uint32_t bitfield_bit_size, + uint32_t bitfield_bit_offset, + bool show_types, + bool show_summary, + bool verbose, + uint32_t depth +) +{ + clang::QualType qual_type(clang::QualType::getFromOpaquePtr(opaque_clang_qual_type)); + switch (qual_type->getTypeClass()) + { + case clang::Type::Record: + { + const clang::RecordType *record_type = cast(qual_type.getTypePtr()); + const clang::RecordDecl *record_decl = record_type->getDecl(); + assert(record_decl); + uint32_t field_bit_offset = 0; + uint32_t field_byte_offset = 0; + const clang::ASTRecordLayout &record_layout = ast_context->getASTRecordLayout(record_decl); + uint32_t child_idx = 0; + + + const clang::CXXRecordDecl *cxx_record_decl = dyn_cast(record_decl); + if (cxx_record_decl) + { + // We might have base classes to print out first + clang::CXXRecordDecl::base_class_const_iterator base_class, base_class_end; + for (base_class = cxx_record_decl->bases_begin(), base_class_end = cxx_record_decl->bases_end(); + base_class != base_class_end; + ++base_class) + { + const clang::CXXRecordDecl *base_class_decl = cast(base_class->getType()->getAs()->getDecl()); + + // Skip empty base classes + if (verbose == false && ClangASTContext::RecordHasFields(base_class_decl) == false) + continue; + + if (base_class->isVirtual()) + field_bit_offset = record_layout.getVBaseClassOffset(base_class_decl); + else + field_bit_offset = record_layout.getBaseClassOffset(base_class_decl); + field_byte_offset = field_bit_offset / 8; + assert (field_bit_offset % 8 == 0); + if (child_idx == 0) + s->PutChar('{'); + else + s->PutChar(','); + + clang::QualType base_class_qual_type = base_class->getType(); + std::string base_class_type_name(base_class_qual_type.getAsString()); + + // Indent and print the base class type name + s->Printf("\n%*s%s ", depth + DEPTH_INCREMENT, "", base_class_type_name.c_str()); + + std::pair base_class_type_info = ast_context->getTypeInfo(base_class_qual_type); + + // Dump the value of the member + DumpValue (ast_context, // The clang AST context for this type + base_class_qual_type.getAsOpaquePtr(),// The clang type we want to dump + exe_ctx, + s, // Stream to dump to + ClangASTType::GetFormat(base_class_qual_type.getAsOpaquePtr()), // The format with which to display the member + data, // Data buffer containing all bytes for this type + data_byte_offset + field_byte_offset,// Offset into "data" where to grab value from + base_class_type_info.first / 8, // Size of this type in bytes + 0, // Bitfield bit size + 0, // Bitfield bit offset + show_types, // Boolean indicating if we should show the variable types + show_summary, // Boolean indicating if we should show a summary for the current type + verbose, // Verbose output? + depth + DEPTH_INCREMENT); // Scope depth for any types that have children + + ++child_idx; + } + } + uint32_t field_idx = 0; + clang::RecordDecl::field_iterator field, field_end; + for (field = record_decl->field_begin(), field_end = record_decl->field_end(); field != field_end; ++field, ++field_idx, ++child_idx) + { + // Print the starting squiggly bracket (if this is the + // first member) or comman (for member 2 and beyong) for + // the struct/union/class member. + if (child_idx == 0) + s->PutChar('{'); + else + s->PutChar(','); + + // Indent + s->Printf("\n%*s", depth + DEPTH_INCREMENT, ""); + + clang::QualType field_type = field->getType(); + // Print the member type if requested + // Figure out the type byte size (field_type_info.first) and + // alignment (field_type_info.second) from the AST context. + std::pair field_type_info = ast_context->getTypeInfo(field_type); + assert(field_idx < record_layout.getFieldCount()); + // Figure out the field offset within the current struct/union/class type + field_bit_offset = record_layout.getFieldOffset (field_idx); + field_byte_offset = field_bit_offset / 8; + uint32_t field_bitfield_bit_size = 0; + uint32_t field_bitfield_bit_offset = 0; + if (ClangASTContext::FieldIsBitfield (ast_context, *field, field_bitfield_bit_size)) + field_bitfield_bit_offset = field_bit_offset % 8; + + if (show_types) + { + std::string field_type_name(field_type.getAsString()); + if (field_bitfield_bit_size > 0) + s->Printf("(%s:%u) ", field_type_name.c_str(), field_bitfield_bit_size); + else + s->Printf("(%s) ", field_type_name.c_str()); + } + // Print the member name and equal sign + s->Printf("%s = ", field->getNameAsString().c_str()); + + + // Dump the value of the member + DumpValue (ast_context, // The clang AST context for this type + field_type.getAsOpaquePtr(), // The clang type we want to dump + exe_ctx, + s, // Stream to dump to + ClangASTType::GetFormat(field_type.getAsOpaquePtr()), // The format with which to display the member + data, // Data buffer containing all bytes for this type + data_byte_offset + field_byte_offset,// Offset into "data" where to grab value from + field_type_info.first / 8, // Size of this type in bytes + field_bitfield_bit_size, // Bitfield bit size + field_bitfield_bit_offset, // Bitfield bit offset + show_types, // Boolean indicating if we should show the variable types + show_summary, // Boolean indicating if we should show a summary for the current type + verbose, // Verbose output? + depth + DEPTH_INCREMENT); // Scope depth for any types that have children + } + + // Indent the trailing squiggly bracket + if (child_idx > 0) + s->Printf("\n%*s}", depth, ""); + } + return; + + case clang::Type::Enum: + { + const clang::EnumType *enum_type = cast(qual_type.getTypePtr()); + const clang::EnumDecl *enum_decl = enum_type->getDecl(); + assert(enum_decl); + clang::EnumDecl::enumerator_iterator enum_pos, enum_end_pos; + uint32_t offset = data_byte_offset; + const int64_t enum_value = data.GetMaxU64Bitfield(&offset, data_byte_size, bitfield_bit_size, bitfield_bit_offset); + for (enum_pos = enum_decl->enumerator_begin(), enum_end_pos = enum_decl->enumerator_end(); enum_pos != enum_end_pos; ++enum_pos) + { + if (enum_pos->getInitVal() == enum_value) + { + s->Printf("%s", enum_pos->getNameAsCString()); + return; + } + } + // If we have gotten here we didn't get find the enumerator in the + // enum decl, so just print the integer. + s->Printf("%lli", enum_value); + } + return; + + case clang::Type::ConstantArray: + { + const clang::ConstantArrayType *array = cast(qual_type.getTypePtr()); + bool is_array_of_characters = false; + clang::QualType element_qual_type = array->getElementType(); + + clang::Type *canonical_type = element_qual_type->getCanonicalTypeInternal().getTypePtr(); + if (canonical_type) + is_array_of_characters = canonical_type->isCharType(); + + const uint64_t element_count = array->getSize().getLimitedValue(); + + std::pair field_type_info = ast_context->getTypeInfo(element_qual_type); + + uint32_t element_idx = 0; + uint32_t element_offset = 0; + uint64_t element_byte_size = field_type_info.first / 8; + uint32_t element_stride = element_byte_size; + + if (is_array_of_characters) + { + s->PutChar('"'); + data.Dump(s, data_byte_offset, lldb::eFormatChar, element_byte_size, element_count, UINT32_MAX, LLDB_INVALID_ADDRESS, 0, 0); + s->PutChar('"'); + return; + } + else + { + lldb::Format element_format = ClangASTType::GetFormat(element_qual_type.getAsOpaquePtr()); + + for (element_idx = 0; element_idx < element_count; ++element_idx) + { + // Print the starting squiggly bracket (if this is the + // first member) or comman (for member 2 and beyong) for + // the struct/union/class member. + if (element_idx == 0) + s->PutChar('{'); + else + s->PutChar(','); + + // Indent and print the index + s->Printf("\n%*s[%u] ", depth + DEPTH_INCREMENT, "", element_idx); + + // Figure out the field offset within the current struct/union/class type + element_offset = element_idx * element_stride; + + // Dump the value of the member + DumpValue (ast_context, // The clang AST context for this type + element_qual_type.getAsOpaquePtr(), // The clang type we want to dump + exe_ctx, + s, // Stream to dump to + element_format, // The format with which to display the element + data, // Data buffer containing all bytes for this type + data_byte_offset + element_offset,// Offset into "data" where to grab value from + element_byte_size, // Size of this type in bytes + 0, // Bitfield bit size + 0, // Bitfield bit offset + show_types, // Boolean indicating if we should show the variable types + show_summary, // Boolean indicating if we should show a summary for the current type + verbose, // Verbose output? + depth + DEPTH_INCREMENT); // Scope depth for any types that have children + } + + // Indent the trailing squiggly bracket + if (element_idx > 0) + s->Printf("\n%*s}", depth, ""); + } + } + return; + + case clang::Type::Typedef: + { + clang::QualType typedef_qual_type = cast(qual_type)->LookThroughTypedefs(); + lldb::Format typedef_format = ClangASTType::GetFormat(typedef_qual_type.getAsOpaquePtr()); + std::pair typedef_type_info = ast_context->getTypeInfo(typedef_qual_type); + uint64_t typedef_byte_size = typedef_type_info.first / 8; + + return DumpValue (ast_context, // The clang AST context for this type + typedef_qual_type.getAsOpaquePtr(), // The clang type we want to dump + exe_ctx, + s, // Stream to dump to + typedef_format, // The format with which to display the element + data, // Data buffer containing all bytes for this type + data_byte_offset, // Offset into "data" where to grab value from + typedef_byte_size, // Size of this type in bytes + bitfield_bit_size, // Bitfield bit size + bitfield_bit_offset,// Bitfield bit offset + show_types, // Boolean indicating if we should show the variable types + show_summary, // Boolean indicating if we should show a summary for the current type + verbose, // Verbose output? + depth); // Scope depth for any types that have children + } + break; + + default: + // We are down the a scalar type that we just need to display. + data.Dump(s, data_byte_offset, format, data_byte_size, 1, UINT32_MAX, LLDB_INVALID_ADDRESS, bitfield_bit_size, bitfield_bit_offset); + + if (show_summary) + DumpSummary (ast_context, opaque_clang_qual_type, exe_ctx, s, data, data_byte_offset, data_byte_size); + break; + } +} + + + +bool +ClangASTType::DumpTypeValue +( + Stream *s, + lldb::Format format, + const lldb_private::DataExtractor &data, + uint32_t byte_offset, + size_t byte_size, + uint32_t bitfield_bit_size, + uint32_t bitfield_bit_offset +) +{ + return DumpTypeValue (m_ast, + m_type, + s, + format, + data, + byte_offset, + byte_size, + bitfield_bit_size, + bitfield_bit_offset); +} + + +bool +ClangASTType::DumpTypeValue +( + clang::ASTContext *ast_context, + void *opaque_clang_qual_type, + Stream *s, + lldb::Format format, + const lldb_private::DataExtractor &data, + uint32_t byte_offset, + size_t byte_size, + uint32_t bitfield_bit_size, + uint32_t bitfield_bit_offset +) +{ + clang::QualType qual_type(clang::QualType::getFromOpaquePtr(opaque_clang_qual_type)); + if (ClangASTContext::IsAggregateType (opaque_clang_qual_type)) + { + return 0; + } + else + { + switch (qual_type->getTypeClass()) + { + case clang::Type::Enum: + { + const clang::EnumType *enum_type = cast(qual_type.getTypePtr()); + const clang::EnumDecl *enum_decl = enum_type->getDecl(); + assert(enum_decl); + clang::EnumDecl::enumerator_iterator enum_pos, enum_end_pos; + uint32_t offset = byte_offset; + const int64_t enum_value = data.GetMaxU64Bitfield (&offset, byte_size, bitfield_bit_size, bitfield_bit_offset); + for (enum_pos = enum_decl->enumerator_begin(), enum_end_pos = enum_decl->enumerator_end(); enum_pos != enum_end_pos; ++enum_pos) + { + if (enum_pos->getInitVal() == enum_value) + { + s->PutCString (enum_pos->getNameAsCString()); + return true; + } + } + // If we have gotten here we didn't get find the enumerator in the + // enum decl, so just print the integer. + + s->Printf("%lli", enum_value); + return true; + } + break; + + case clang::Type::Typedef: + { + clang::QualType typedef_qual_type = cast(qual_type)->LookThroughTypedefs(); + lldb::Format typedef_format = ClangASTType::GetFormat(typedef_qual_type.getAsOpaquePtr()); + std::pair typedef_type_info = ast_context->getTypeInfo(typedef_qual_type); + uint64_t typedef_byte_size = typedef_type_info.first / 8; + + return ClangASTType::DumpTypeValue( + ast_context, // The clang AST context for this type + typedef_qual_type.getAsOpaquePtr(), // The clang type we want to dump + s, + typedef_format, // The format with which to display the element + data, // Data buffer containing all bytes for this type + byte_offset, // Offset into "data" where to grab value from + typedef_byte_size, // Size of this type in bytes + bitfield_bit_size, // Size in bits of a bitfield value, if zero don't treat as a bitfield + bitfield_bit_offset); // Offset in bits of a bitfield value if bitfield_bit_size != 0 + } + break; + + default: + // We are down the a scalar type that we just need to display. + return data.Dump(s, + byte_offset, + format, + byte_size, + 1, + UINT32_MAX, + LLDB_INVALID_ADDRESS, + bitfield_bit_size, + bitfield_bit_offset); + break; + } + } + return 0; +} + + + +void +ClangASTType::DumpSummary +( + ExecutionContext *exe_ctx, + Stream *s, + const lldb_private::DataExtractor &data, + uint32_t data_byte_offset, + size_t data_byte_size +) +{ + return DumpSummary (m_ast, + m_type, + exe_ctx, + s, + data, + data_byte_offset, + data_byte_size); +} + +void +ClangASTType::DumpSummary +( + clang::ASTContext *ast_context, + void *opaque_clang_qual_type, + ExecutionContext *exe_ctx, + Stream *s, + const lldb_private::DataExtractor &data, + uint32_t data_byte_offset, + size_t data_byte_size +) +{ + uint32_t length = 0; + clang::QualType qual_type(clang::QualType::getFromOpaquePtr(opaque_clang_qual_type)); + if (ClangASTContext::IsCStringType (opaque_clang_qual_type, length)) + { + + if (exe_ctx && exe_ctx->process) + { + uint32_t offset = data_byte_offset; + lldb::addr_t pointer_addresss = data.GetMaxU64(&offset, data_byte_size); + std::vector buf; + if (length > 0) + buf.resize (length); + else + buf.resize (256); + + lldb_private::DataExtractor cstr_data(&buf.front(), buf.size(), exe_ctx->process->GetByteOrder(), 4); + buf.back() = '\0'; + size_t bytes_read; + size_t total_cstr_len = 0; + Error error; + while ((bytes_read = exe_ctx->process->ReadMemory (pointer_addresss, &buf.front(), buf.size(), error)) > 0) + { + const size_t len = strlen((const char *)&buf.front()); + if (len == 0) + break; + if (total_cstr_len == 0) + s->PutCString (" \""); + cstr_data.Dump(s, 0, lldb::eFormatChar, 1, len, UINT32_MAX, LLDB_INVALID_ADDRESS, 0, 0); + total_cstr_len += len; + if (len < buf.size()) + break; + pointer_addresss += total_cstr_len; + } + if (total_cstr_len > 0) + s->PutChar ('"'); + } + } +} + +bool +ClangASTType::GetValueAsScalar +( + const lldb_private::DataExtractor &data, + uint32_t data_byte_offset, + size_t data_byte_size, + Scalar &value +) +{ + return GetValueAsScalar (m_ast, + m_type, + data, + data_byte_offset, + data_byte_size, + value); +} + +bool +ClangASTType::GetValueAsScalar +( + clang::ASTContext *ast_context, + void *opaque_clang_qual_type, + const lldb_private::DataExtractor &data, + uint32_t data_byte_offset, + size_t data_byte_size, + Scalar &value +) +{ + clang::QualType qual_type(clang::QualType::getFromOpaquePtr(opaque_clang_qual_type)); + + if (ClangASTContext::IsAggregateType (opaque_clang_qual_type)) + { + return false; // Aggregate types don't have scalar values + } + else + { + uint32_t count = 0; + lldb::Encoding encoding = GetEncoding (opaque_clang_qual_type, count); + + if (encoding == lldb::eEncodingInvalid || count != 1) + return false; + + uint64_t bit_width = ast_context->getTypeSize(qual_type); + uint32_t byte_size = (bit_width + 7 ) / 8; + uint32_t offset = data_byte_offset; + switch (encoding) + { + case lldb::eEncodingUint: + if (byte_size <= sizeof(unsigned long long)) + { + uint64_t uval64 = data.GetMaxU64 (&offset, byte_size); + if (byte_size <= sizeof(unsigned int)) + { + value = (unsigned int)uval64; + return true; + } + else if (byte_size <= sizeof(unsigned long)) + { + value = (unsigned long)uval64; + return true; + } + else if (byte_size <= sizeof(unsigned long long)) + { + value = (unsigned long long )uval64; + return true; + } + else + value.Clear(); + } + break; + + case lldb::eEncodingSint: + if (byte_size <= sizeof(long long)) + { + int64_t sval64 = (int64_t)data.GetMaxU64 (&offset, byte_size); + if (byte_size <= sizeof(int)) + { + value = (int)sval64; + return true; + } + else if (byte_size <= sizeof(long)) + { + value = (long)sval64; + return true; + } + else if (byte_size <= sizeof(long long)) + { + value = (long long )sval64; + return true; + } + else + value.Clear(); + } + break; + + case lldb::eEncodingIEEE754: + if (byte_size <= sizeof(long double)) + { + uint32_t u32; + uint64_t u64; + if (byte_size == sizeof(float)) + { + if (sizeof(float) == sizeof(uint32_t)) + { + u32 = data.GetU32(&offset); + value = *((float *)&u32); + return true; + } + else if (sizeof(float) == sizeof(uint64_t)) + { + u64 = data.GetU64(&offset); + value = *((float *)&u64); + return true; + } + } + else + if (byte_size == sizeof(double)) + { + if (sizeof(double) == sizeof(uint32_t)) + { + u32 = data.GetU32(&offset); + value = *((double *)&u32); + return true; + } + else if (sizeof(double) == sizeof(uint64_t)) + { + u64 = data.GetU64(&offset); + value = *((double *)&u64); + return true; + } + } + else + if (byte_size == sizeof(long double)) + { + if (sizeof(long double) == sizeof(uint32_t)) + { + u32 = data.GetU32(&offset); + value = *((long double *)&u32); + return true; + } + else if (sizeof(long double) == sizeof(uint64_t)) + { + u64 = data.GetU64(&offset); + value = *((long double *)&u64); + return true; + } + } + } + break; + } + } + return false; +} + +bool +ClangASTType::SetValueFromScalar (const Scalar &value, Stream &strm) +{ + return SetValueFromScalar (m_ast, m_type, value, strm); +} + +bool +ClangASTType::SetValueFromScalar +( + clang::ASTContext *ast_context, + void *opaque_clang_qual_type, + const Scalar &value, + Stream &strm +) +{ + clang::QualType qual_type(clang::QualType::getFromOpaquePtr(opaque_clang_qual_type)); + + // Aggregate types don't have scalar values + if (!ClangASTContext::IsAggregateType (opaque_clang_qual_type)) + { + strm.GetFlags().Set(Stream::eBinary); + uint32_t count = 0; + lldb::Encoding encoding = GetEncoding (opaque_clang_qual_type, count); + + if (encoding == lldb::eEncodingInvalid || count != 1) + return false; + + uint64_t bit_width = ast_context->getTypeSize(qual_type); + // This function doesn't currently handle non-byte aligned assignments + if ((bit_width % 8) != 0) + return false; + + uint32_t byte_size = (bit_width + 7 ) / 8; + switch (encoding) + { + case lldb::eEncodingUint: + switch (byte_size) + { + case 1: strm.PutHex8(value.UInt()); return true; + case 2: strm.PutHex16(value.UInt()); return true; + case 4: strm.PutHex32(value.UInt()); return true; + case 8: strm.PutHex64(value.ULongLong()); return true; + default: + break; + } + break; + + case lldb::eEncodingSint: + switch (byte_size) + { + case 1: strm.PutHex8(value.SInt()); return true; + case 2: strm.PutHex16(value.SInt()); return true; + case 4: strm.PutHex32(value.SInt()); return true; + case 8: strm.PutHex64(value.SLongLong()); return true; + default: + break; + } + break; + + case lldb::eEncodingIEEE754: + if (byte_size <= sizeof(long double)) + { + if (byte_size == sizeof(float)) + { + strm.PutFloat(value.Float()); + return true; + } + else + if (byte_size == sizeof(double)) + { + strm.PutDouble(value.Double()); + return true; + } + else + if (byte_size == sizeof(long double)) + { + strm.PutDouble(value.LongDouble()); + return true; + } + } + break; + } + } + return false; +} + +bool +ClangASTType::ReadFromMemory +( + lldb_private::ExecutionContext *exe_ctx, + lldb::addr_t addr, + lldb::AddressType address_type, + lldb_private::DataExtractor &data +) +{ + return ReadFromMemory (m_ast, + m_type, + exe_ctx, + addr, + address_type, + data); +} + + +bool +ClangASTType::ReadFromMemory +( + clang::ASTContext *ast_context, + void *opaque_clang_qual_type, + lldb_private::ExecutionContext *exe_ctx, + lldb::addr_t addr, + lldb::AddressType address_type, + lldb_private::DataExtractor &data +) +{ + if (address_type == lldb::eAddressTypeFile) + { + // Can't convert a file address to anything valid without more + // context (which Module it came from) + return false; + } + clang::QualType qual_type(clang::QualType::getFromOpaquePtr(opaque_clang_qual_type)); + + const uint32_t byte_size = (ast_context->getTypeSize (qual_type) + 7) / 8; + if (data.GetByteSize() < byte_size) + { + lldb::DataBufferSP data_sp(new DataBufferHeap (byte_size, '\0')); + data.SetData(data_sp); + } + + uint8_t* dst = (uint8_t*)data.PeekData(0, byte_size); + if (dst != NULL) + { + if (address_type == lldb::eAddressTypeHost) + { + // The address is an address in this process, so just copy it + memcpy (dst, (uint8_t*)NULL + addr, byte_size); + return true; + } + else + { + if (exe_ctx && exe_ctx->process) + { + Error error; + return exe_ctx->process->ReadMemory(addr, dst, byte_size, error) == byte_size; + } + } + } + return false; +} + +bool +ClangASTType::WriteToMemory +( + lldb_private::ExecutionContext *exe_ctx, + lldb::addr_t addr, + lldb::AddressType address_type, + StreamString &new_value +) +{ + return WriteToMemory (m_ast, + m_type, + exe_ctx, + addr, + address_type, + new_value); +} + +bool +ClangASTType::WriteToMemory +( + clang::ASTContext *ast_context, + void *opaque_clang_qual_type, + lldb_private::ExecutionContext *exe_ctx, + lldb::addr_t addr, + lldb::AddressType address_type, + StreamString &new_value +) +{ + if (address_type == lldb::eAddressTypeFile) + { + // Can't convert a file address to anything valid without more + // context (which Module it came from) + return false; + } + clang::QualType qual_type(clang::QualType::getFromOpaquePtr(opaque_clang_qual_type)); + const uint32_t byte_size = (ast_context->getTypeSize (qual_type) + 7) / 8; + + if (byte_size > 0) + { + if (address_type == lldb::eAddressTypeHost) + { + // The address is an address in this process, so just copy it + memcpy ((void *)addr, new_value.GetData(), byte_size); + return true; + } + else + { + if (exe_ctx && exe_ctx->process) + { + Error error; + return exe_ctx->process->WriteMemory(addr, new_value.GetData(), byte_size, error) == byte_size; + } + } + } + return false; +} + + Modified: lldb/trunk/source/Symbol/Function.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/Function.cpp?rev=109046&r1=109045&r2=109046&view=diff ============================================================================== --- lldb/trunk/source/Symbol/Function.cpp (original) +++ lldb/trunk/source/Symbol/Function.cpp Wed Jul 21 17:12:05 2010 @@ -10,10 +10,11 @@ #include "lldb/Symbol/Function.h" #include "lldb/Core/Module.h" #include "lldb/Core/Section.h" +#include "lldb/Symbol/ClangASTType.h" +#include "lldb/Symbol/ClangASTContext.h" #include "lldb/Symbol/CompileUnit.h" #include "lldb/Symbol/LineTable.h" #include "lldb/Symbol/SymbolVendor.h" -#include "lldb/Symbol/ClangASTContext.h" #include "clang/AST/Type.h" #include "clang/AST/CanonicalType.h" @@ -339,7 +340,7 @@ clang::FunctionType *function_type = dyn_cast (clang_type); clang::QualType fun_return_qualtype = function_type->getResultType(); - const ConstString fun_return_name(Type::GetClangTypeName(fun_return_qualtype.getAsOpaquePtr())); + const ConstString fun_return_name(ClangASTType::GetClangTypeName(fun_return_qualtype.getAsOpaquePtr())); SymbolContext sc; CalculateSymbolContext (&sc); @@ -381,7 +382,7 @@ return Type(); clang::QualType arg_qualtype = (function_proto_type->arg_type_begin())[idx]; - const ConstString arg_return_name(Type::GetClangTypeName(arg_qualtype.getAsOpaquePtr())); + const ConstString arg_return_name(ClangASTType::GetClangTypeName(arg_qualtype.getAsOpaquePtr())); SymbolContext sc; CalculateSymbolContext (&sc); // Null out everything below the CompUnit 'cause we don't actually know these. Modified: lldb/trunk/source/Symbol/Type.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/Type.cpp?rev=109046&r1=109045&r2=109046&view=diff ============================================================================== --- lldb/trunk/source/Symbol/Type.cpp (original) +++ lldb/trunk/source/Symbol/Type.cpp Wed Jul 21 17:12:05 2010 @@ -30,6 +30,7 @@ #include "lldb/Core/Scalar.h" #include "lldb/Core/StreamString.h" +#include "lldb/Symbol/ClangASTType.h" #include "lldb/Symbol/ClangASTContext.h" #include "lldb/Symbol/ObjectFile.h" #include "lldb/Symbol/SymbolContextScope.h" @@ -270,59 +271,6 @@ return m_name; } -int -lldb_private::Type::DumpClangTypeName(Stream *s, void *clang_type) -{ - clang::QualType qual_type(clang::QualType::getFromOpaquePtr(clang_type)); - std::string type_name; - const clang::TypedefType *typedef_type = qual_type->getAs(); - if (typedef_type) - { - const clang::TypedefDecl *typedef_decl = typedef_type->getDecl(); - type_name = typedef_decl->getQualifiedNameAsString(); - } - else - { - type_name = qual_type.getAsString(); - } - if (!type_name.empty()) - return s->Printf("(%s) ", type_name.c_str()); - return 0; -} - -lldb_private::ConstString -lldb_private::Type::GetClangTypeName (void *clang_type) -{ - ConstString clang_type_name; - if (clang_type) - { - clang::QualType qual_type(clang::QualType::getFromOpaquePtr(clang_type)); - - const clang::TypedefType *typedef_type = qual_type->getAs(); - if (typedef_type) - { - const clang::TypedefDecl *typedef_decl = typedef_type->getDecl(); - std::string clang_typedef_name (typedef_decl->getQualifiedNameAsString()); - if (!clang_typedef_name.empty()) - clang_type_name.SetCString (clang_typedef_name.c_str()); - } - else - { - std::string type_name(qual_type.getAsString()); - if (!type_name.empty()) - clang_type_name.SetCString (type_name.c_str()); - } - } - else - { - clang_type_name.SetCString (""); - } - - return clang_type_name; -} - - - void lldb_private::Type::DumpTypeName(Stream *s) { @@ -354,658 +302,23 @@ s->PutCString(") "); } - lldb_private::Type::DumpValue (exe_ctx, - GetClangAST (), - m_clang_qual_type, - s, - format == lldb::eFormatDefault ? GetFormat() : format, - data, - data_byte_offset, - GetByteSize(), - 0, // Bitfield bit size - 0, // Bitfield bit offset - show_types, - show_summary, - verbose, - 0); - } -} - - -void -lldb_private::Type::DumpSummary -( - ExecutionContext *exe_ctx, - clang::ASTContext *ast_context, - void *clang_type, - Stream *s, - const lldb_private::DataExtractor &data, - uint32_t data_byte_offset, - size_t data_byte_size -) -{ - uint32_t length = 0; - clang::QualType qual_type(clang::QualType::getFromOpaquePtr(clang_type)); - if (ClangASTContext::IsCStringType (clang_type, length)) - { - - if (exe_ctx && exe_ctx->process) - { - uint32_t offset = data_byte_offset; - lldb::addr_t pointer_addresss = data.GetMaxU64(&offset, data_byte_size); - std::vector buf; - if (length > 0) - buf.resize (length); - else - buf.resize (256); - - lldb_private::DataExtractor cstr_data(&buf.front(), buf.size(), exe_ctx->process->GetByteOrder(), 4); - buf.back() = '\0'; - size_t bytes_read; - size_t total_cstr_len = 0; - Error error; - while ((bytes_read = exe_ctx->process->ReadMemory (pointer_addresss, &buf.front(), buf.size(), error)) > 0) - { - const size_t len = strlen((const char *)&buf.front()); - if (len == 0) - break; - if (total_cstr_len == 0) - s->PutCString (" \""); - cstr_data.Dump(s, 0, lldb::eFormatChar, 1, len, UINT32_MAX, LLDB_INVALID_ADDRESS, 0, 0); - total_cstr_len += len; - if (len < buf.size()) - break; - pointer_addresss += total_cstr_len; - } - if (total_cstr_len > 0) - s->PutChar ('"'); - } - } -} - -#define DEPTH_INCREMENT 2 -void -lldb_private::Type::DumpValue -( - ExecutionContext *exe_ctx, - clang::ASTContext *ast_context, - void *clang_type, - Stream *s, - lldb::Format format, - const lldb_private::DataExtractor &data, - uint32_t data_byte_offset, - size_t data_byte_size, - uint32_t bitfield_bit_size, - uint32_t bitfield_bit_offset, - bool show_types, - bool show_summary, - bool verbose, - uint32_t depth -) -{ - clang::QualType qual_type(clang::QualType::getFromOpaquePtr(clang_type)); - switch (qual_type->getTypeClass()) - { - case clang::Type::Record: - { - const clang::RecordType *record_type = cast(qual_type.getTypePtr()); - const clang::RecordDecl *record_decl = record_type->getDecl(); - assert(record_decl); - uint32_t field_bit_offset = 0; - uint32_t field_byte_offset = 0; - const clang::ASTRecordLayout &record_layout = ast_context->getASTRecordLayout(record_decl); - uint32_t child_idx = 0; - - - const clang::CXXRecordDecl *cxx_record_decl = dyn_cast(record_decl); - if (cxx_record_decl) - { - // We might have base classes to print out first - clang::CXXRecordDecl::base_class_const_iterator base_class, base_class_end; - for (base_class = cxx_record_decl->bases_begin(), base_class_end = cxx_record_decl->bases_end(); - base_class != base_class_end; - ++base_class) - { - const clang::CXXRecordDecl *base_class_decl = cast(base_class->getType()->getAs()->getDecl()); - - // Skip empty base classes - if (verbose == false && ClangASTContext::RecordHasFields(base_class_decl) == false) - continue; - - if (base_class->isVirtual()) - field_bit_offset = record_layout.getVBaseClassOffset(base_class_decl); - else - field_bit_offset = record_layout.getBaseClassOffset(base_class_decl); - field_byte_offset = field_bit_offset / 8; - assert (field_bit_offset % 8 == 0); - if (child_idx == 0) - s->PutChar('{'); - else - s->PutChar(','); - - clang::QualType base_class_qual_type = base_class->getType(); - std::string base_class_type_name(base_class_qual_type.getAsString()); - - // Indent and print the base class type name - s->Printf("\n%*s%s ", depth + DEPTH_INCREMENT, "", base_class_type_name.c_str()); - - std::pair base_class_type_info = ast_context->getTypeInfo(base_class_qual_type); - - // Dump the value of the member - Type::DumpValue ( - exe_ctx, - ast_context, // The clang AST context for this type - base_class_qual_type.getAsOpaquePtr(),// The clang type we want to dump - s, // Stream to dump to - Type::GetFormat(base_class_qual_type.getAsOpaquePtr()), // The format with which to display the member - data, // Data buffer containing all bytes for this type - data_byte_offset + field_byte_offset,// Offset into "data" where to grab value from - base_class_type_info.first / 8, // Size of this type in bytes - 0, // Bitfield bit size - 0, // Bitfield bit offset - show_types, // Boolean indicating if we should show the variable types - show_summary, // Boolean indicating if we should show a summary for the current type - verbose, // Verbose output? - depth + DEPTH_INCREMENT); // Scope depth for any types that have children - - ++child_idx; - } - } - uint32_t field_idx = 0; - clang::RecordDecl::field_iterator field, field_end; - for (field = record_decl->field_begin(), field_end = record_decl->field_end(); field != field_end; ++field, ++field_idx, ++child_idx) - { - // Print the starting squiggly bracket (if this is the - // first member) or comman (for member 2 and beyong) for - // the struct/union/class member. - if (child_idx == 0) - s->PutChar('{'); - else - s->PutChar(','); - - // Indent - s->Printf("\n%*s", depth + DEPTH_INCREMENT, ""); - - clang::QualType field_type = field->getType(); - // Print the member type if requested - // Figure out the type byte size (field_type_info.first) and - // alignment (field_type_info.second) from the AST context. - std::pair field_type_info = ast_context->getTypeInfo(field_type); - assert(field_idx < record_layout.getFieldCount()); - // Figure out the field offset within the current struct/union/class type - field_bit_offset = record_layout.getFieldOffset (field_idx); - field_byte_offset = field_bit_offset / 8; - uint32_t field_bitfield_bit_size = 0; - uint32_t field_bitfield_bit_offset = 0; - if (ClangASTContext::FieldIsBitfield (ast_context, *field, field_bitfield_bit_size)) - field_bitfield_bit_offset = field_bit_offset % 8; - - if (show_types) - { - std::string field_type_name(field_type.getAsString()); - if (field_bitfield_bit_size > 0) - s->Printf("(%s:%u) ", field_type_name.c_str(), field_bitfield_bit_size); - else - s->Printf("(%s) ", field_type_name.c_str()); - } - // Print the member name and equal sign - s->Printf("%s = ", field->getNameAsString().c_str()); - - - // Dump the value of the member - Type::DumpValue ( - exe_ctx, - ast_context, // The clang AST context for this type - field_type.getAsOpaquePtr(), // The clang type we want to dump - s, // Stream to dump to - Type::GetFormat(field_type.getAsOpaquePtr()), // The format with which to display the member - data, // Data buffer containing all bytes for this type - data_byte_offset + field_byte_offset,// Offset into "data" where to grab value from - field_type_info.first / 8, // Size of this type in bytes - field_bitfield_bit_size, // Bitfield bit size - field_bitfield_bit_offset, // Bitfield bit offset - show_types, // Boolean indicating if we should show the variable types - show_summary, // Boolean indicating if we should show a summary for the current type - verbose, // Verbose output? - depth + DEPTH_INCREMENT); // Scope depth for any types that have children - } - - // Indent the trailing squiggly bracket - if (child_idx > 0) - s->Printf("\n%*s}", depth, ""); - } - return; - - case clang::Type::Enum: - { - const clang::EnumType *enum_type = cast(qual_type.getTypePtr()); - const clang::EnumDecl *enum_decl = enum_type->getDecl(); - assert(enum_decl); - clang::EnumDecl::enumerator_iterator enum_pos, enum_end_pos; - uint32_t offset = data_byte_offset; - const int64_t enum_value = data.GetMaxU64Bitfield(&offset, data_byte_size, bitfield_bit_size, bitfield_bit_offset); - for (enum_pos = enum_decl->enumerator_begin(), enum_end_pos = enum_decl->enumerator_end(); enum_pos != enum_end_pos; ++enum_pos) - { - if (enum_pos->getInitVal() == enum_value) - { - s->Printf("%s", enum_pos->getNameAsCString()); - return; - } - } - // If we have gotten here we didn't get find the enumerator in the - // enum decl, so just print the integer. - s->Printf("%lli", enum_value); - } - return; - - case clang::Type::ConstantArray: - { - const clang::ConstantArrayType *array = cast(qual_type.getTypePtr()); - bool is_array_of_characters = false; - clang::QualType element_qual_type = array->getElementType(); - - clang::Type *canonical_type = element_qual_type->getCanonicalTypeInternal().getTypePtr(); - if (canonical_type) - is_array_of_characters = canonical_type->isCharType(); - - const uint64_t element_count = array->getSize().getLimitedValue(); - - std::pair field_type_info = ast_context->getTypeInfo(element_qual_type); - - uint32_t element_idx = 0; - uint32_t element_offset = 0; - uint64_t element_byte_size = field_type_info.first / 8; - uint32_t element_stride = element_byte_size; - - if (is_array_of_characters) - { - s->PutChar('"'); - data.Dump(s, data_byte_offset, lldb::eFormatChar, element_byte_size, element_count, UINT32_MAX, LLDB_INVALID_ADDRESS, 0, 0); - s->PutChar('"'); - return; - } - else - { - lldb::Format element_format = Type::GetFormat(element_qual_type.getAsOpaquePtr()); - - for (element_idx = 0; element_idx < element_count; ++element_idx) - { - // Print the starting squiggly bracket (if this is the - // first member) or comman (for member 2 and beyong) for - // the struct/union/class member. - if (element_idx == 0) - s->PutChar('{'); - else - s->PutChar(','); - - // Indent and print the index - s->Printf("\n%*s[%u] ", depth + DEPTH_INCREMENT, "", element_idx); - - // Figure out the field offset within the current struct/union/class type - element_offset = element_idx * element_stride; - - // Dump the value of the member - Type::DumpValue ( - exe_ctx, - ast_context, // The clang AST context for this type - element_qual_type.getAsOpaquePtr(), // The clang type we want to dump - s, // Stream to dump to - element_format, // The format with which to display the element - data, // Data buffer containing all bytes for this type - data_byte_offset + element_offset,// Offset into "data" where to grab value from - element_byte_size, // Size of this type in bytes - 0, // Bitfield bit size - 0, // Bitfield bit offset - show_types, // Boolean indicating if we should show the variable types - show_summary, // Boolean indicating if we should show a summary for the current type - verbose, // Verbose output? - depth + DEPTH_INCREMENT); // Scope depth for any types that have children - } - - // Indent the trailing squiggly bracket - if (element_idx > 0) - s->Printf("\n%*s}", depth, ""); - } - } - return; - - case clang::Type::Typedef: - { - clang::QualType typedef_qual_type = cast(qual_type)->LookThroughTypedefs(); - lldb::Format typedef_format = lldb_private::Type::GetFormat(typedef_qual_type.getAsOpaquePtr()); - std::pair typedef_type_info = ast_context->getTypeInfo(typedef_qual_type); - uint64_t typedef_byte_size = typedef_type_info.first / 8; - - return Type::DumpValue( - exe_ctx, - ast_context, // The clang AST context for this type - typedef_qual_type.getAsOpaquePtr(), // The clang type we want to dump - s, // Stream to dump to - typedef_format, // The format with which to display the element - data, // Data buffer containing all bytes for this type - data_byte_offset, // Offset into "data" where to grab value from - typedef_byte_size, // Size of this type in bytes - bitfield_bit_size, // Bitfield bit size - bitfield_bit_offset,// Bitfield bit offset - show_types, // Boolean indicating if we should show the variable types - show_summary, // Boolean indicating if we should show a summary for the current type - verbose, // Verbose output? - depth); // Scope depth for any types that have children - } - break; - - default: - // We are down the a scalar type that we just need to display. - data.Dump(s, data_byte_offset, format, data_byte_size, 1, UINT32_MAX, LLDB_INVALID_ADDRESS, bitfield_bit_size, bitfield_bit_offset); - - if (show_summary) - Type::DumpSummary (exe_ctx, ast_context, clang_type, s, data, data_byte_offset, data_byte_size); - break; - } -} - -bool -lldb_private::Type::DumpTypeValue -( - Stream *s, - clang::ASTContext *ast_context, - void *clang_type, - lldb::Format format, - const lldb_private::DataExtractor &data, - uint32_t byte_offset, - size_t byte_size, - uint32_t bitfield_bit_size, - uint32_t bitfield_bit_offset -) -{ - clang::QualType qual_type(clang::QualType::getFromOpaquePtr(clang_type)); - if (ClangASTContext::IsAggregateType (clang_type)) - { - return 0; - } - else - { - switch (qual_type->getTypeClass()) - { - case clang::Type::Enum: - { - const clang::EnumType *enum_type = cast(qual_type.getTypePtr()); - const clang::EnumDecl *enum_decl = enum_type->getDecl(); - assert(enum_decl); - clang::EnumDecl::enumerator_iterator enum_pos, enum_end_pos; - uint32_t offset = byte_offset; - const int64_t enum_value = data.GetMaxU64Bitfield (&offset, byte_size, bitfield_bit_size, bitfield_bit_offset); - for (enum_pos = enum_decl->enumerator_begin(), enum_end_pos = enum_decl->enumerator_end(); enum_pos != enum_end_pos; ++enum_pos) - { - if (enum_pos->getInitVal() == enum_value) - { - s->PutCString (enum_pos->getNameAsCString()); - return true; - } - } - // If we have gotten here we didn't get find the enumerator in the - // enum decl, so just print the integer. - - s->Printf("%lli", enum_value); - return true; - } - break; - - case clang::Type::Typedef: - { - clang::QualType typedef_qual_type = cast(qual_type)->LookThroughTypedefs(); - lldb::Format typedef_format = Type::GetFormat(typedef_qual_type.getAsOpaquePtr()); - std::pair typedef_type_info = ast_context->getTypeInfo(typedef_qual_type); - uint64_t typedef_byte_size = typedef_type_info.first / 8; - - return Type::DumpTypeValue( - s, - ast_context, // The clang AST context for this type - typedef_qual_type.getAsOpaquePtr(), // The clang type we want to dump - typedef_format, // The format with which to display the element - data, // Data buffer containing all bytes for this type - byte_offset, // Offset into "data" where to grab value from - typedef_byte_size, // Size of this type in bytes - bitfield_bit_size, // Size in bits of a bitfield value, if zero don't treat as a bitfield - bitfield_bit_offset); // Offset in bits of a bitfield value if bitfield_bit_size != 0 - } - break; - - default: - // We are down the a scalar type that we just need to display. - return data.Dump(s, - byte_offset, - format, - byte_size, - 1, - UINT32_MAX, - LLDB_INVALID_ADDRESS, - bitfield_bit_size, - bitfield_bit_offset); - break; - } - } - return 0; -} - -bool -lldb_private::Type::GetValueAsScalar -( - clang::ASTContext *ast_context, - void *clang_type, - const lldb_private::DataExtractor &data, - uint32_t data_byte_offset, - size_t data_byte_size, - Scalar &value -) -{ - clang::QualType qual_type(clang::QualType::getFromOpaquePtr(clang_type)); - - if (ClangASTContext::IsAggregateType (clang_type)) - { - return false; // Aggregate types don't have scalar values - } - else - { - uint32_t count = 0; - lldb::Encoding encoding = Type::GetEncoding (clang_type, count); - - if (encoding == lldb::eEncodingInvalid || count != 1) - return false; - - uint64_t bit_width = ast_context->getTypeSize(qual_type); - uint32_t byte_size = (bit_width + 7 ) / 8; - uint32_t offset = data_byte_offset; - switch (encoding) - { - case lldb::eEncodingUint: - if (byte_size <= sizeof(unsigned long long)) - { - uint64_t uval64 = data.GetMaxU64 (&offset, byte_size); - if (byte_size <= sizeof(unsigned int)) - { - value = (unsigned int)uval64; - return true; - } - else if (byte_size <= sizeof(unsigned long)) - { - value = (unsigned long)uval64; - return true; - } - else if (byte_size <= sizeof(unsigned long long)) - { - value = (unsigned long long )uval64; - return true; - } - else - value.Clear(); - } - break; - - case lldb::eEncodingSint: - if (byte_size <= sizeof(long long)) - { - int64_t sval64 = (int64_t)data.GetMaxU64 (&offset, byte_size); - if (byte_size <= sizeof(int)) - { - value = (int)sval64; - return true; - } - else if (byte_size <= sizeof(long)) - { - value = (long)sval64; - return true; - } - else if (byte_size <= sizeof(long long)) - { - value = (long long )sval64; - return true; - } - else - value.Clear(); - } - break; - - case lldb::eEncodingIEEE754: - if (byte_size <= sizeof(long double)) - { - uint32_t u32; - uint64_t u64; - if (byte_size == sizeof(float)) - { - if (sizeof(float) == sizeof(uint32_t)) - { - u32 = data.GetU32(&offset); - value = *((float *)&u32); - return true; - } - else if (sizeof(float) == sizeof(uint64_t)) - { - u64 = data.GetU64(&offset); - value = *((float *)&u64); - return true; - } - } - else - if (byte_size == sizeof(double)) - { - if (sizeof(double) == sizeof(uint32_t)) - { - u32 = data.GetU32(&offset); - value = *((double *)&u32); - return true; - } - else if (sizeof(double) == sizeof(uint64_t)) - { - u64 = data.GetU64(&offset); - value = *((double *)&u64); - return true; - } - } - else - if (byte_size == sizeof(long double)) - { - if (sizeof(long double) == sizeof(uint32_t)) - { - u32 = data.GetU32(&offset); - value = *((long double *)&u32); - return true; - } - else if (sizeof(long double) == sizeof(uint64_t)) - { - u64 = data.GetU64(&offset); - value = *((long double *)&u64); - return true; - } - } - } - break; - } - } - return false; -} - -bool -lldb_private::Type::SetValueFromScalar -( - clang::ASTContext *ast_context, - void *clang_type, - const Scalar &value, - Stream &strm -) -{ - clang::QualType qual_type(clang::QualType::getFromOpaquePtr(clang_type)); - - // Aggregate types don't have scalar values - if (!ClangASTContext::IsAggregateType (clang_type)) - { - strm.GetFlags().Set(Stream::eBinary); - uint32_t count = 0; - lldb::Encoding encoding = Type::GetEncoding (clang_type, count); - - if (encoding == lldb::eEncodingInvalid || count != 1) - return false; - - uint64_t bit_width = ast_context->getTypeSize(qual_type); - // This function doesn't currently handle non-byte aligned assignments - if ((bit_width % 8) != 0) - return false; - - uint32_t byte_size = (bit_width + 7 ) / 8; - switch (encoding) - { - case lldb::eEncodingUint: - switch (byte_size) - { - case 1: strm.PutHex8(value.UInt()); return true; - case 2: strm.PutHex16(value.UInt()); return true; - case 4: strm.PutHex32(value.UInt()); return true; - case 8: strm.PutHex64(value.ULongLong()); return true; - default: - break; - } - break; - - case lldb::eEncodingSint: - switch (byte_size) - { - case 1: strm.PutHex8(value.SInt()); return true; - case 2: strm.PutHex16(value.SInt()); return true; - case 4: strm.PutHex32(value.SInt()); return true; - case 8: strm.PutHex64(value.SLongLong()); return true; - default: - break; - } - break; - - case lldb::eEncodingIEEE754: - if (byte_size <= sizeof(long double)) - { - if (byte_size == sizeof(float)) - { - strm.PutFloat(value.Float()); - return true; - } - else - if (byte_size == sizeof(double)) - { - strm.PutDouble(value.Double()); - return true; - } - else - if (byte_size == sizeof(long double)) - { - strm.PutDouble(value.LongDouble()); - return true; - } - } - break; - } + lldb_private::ClangASTType::DumpValue (GetClangAST (), + m_clang_qual_type, + exe_ctx, + s, + format == lldb::eFormatDefault ? GetFormat() : format, + data, + data_byte_offset, + GetByteSize(), + 0, // Bitfield bit size + 0, // Bitfield bit offset + show_types, + show_summary, + verbose, + 0); } - return false; } - uint64_t lldb_private::Type::GetByteSize() { @@ -1066,86 +379,10 @@ // Make sure we resolve our type if it already hasn't been. if (!ResolveClangType()) return lldb::eFormatInvalid; - return lldb_private::Type::GetFormat (m_clang_qual_type); + return lldb_private::ClangASTType::GetFormat (m_clang_qual_type); } -lldb::Format -lldb_private::Type::GetFormat (void *clang_type) -{ - clang::QualType qual_type(clang::QualType::getFromOpaquePtr(clang_type)); - - switch (qual_type->getTypeClass()) - { - case clang::Type::FunctionNoProto: - case clang::Type::FunctionProto: - break; - - case clang::Type::IncompleteArray: - case clang::Type::VariableArray: - break; - - case clang::Type::ConstantArray: - break; - - case clang::Type::ExtVector: - case clang::Type::Vector: - break; - - case clang::Type::Builtin: - switch (cast(qual_type)->getKind()) - { - default: assert(0 && "Unknown builtin type!"); - case clang::BuiltinType::Void: - break; - - case clang::BuiltinType::Bool: return lldb::eFormatBoolean; - case clang::BuiltinType::Char_S: - case clang::BuiltinType::SChar: - case clang::BuiltinType::Char_U: - case clang::BuiltinType::UChar: - case clang::BuiltinType::WChar: return lldb::eFormatChar; - case clang::BuiltinType::Char16: return lldb::eFormatUnicode16; - case clang::BuiltinType::Char32: return lldb::eFormatUnicode32; - case clang::BuiltinType::UShort: return lldb::eFormatHex; - case clang::BuiltinType::Short: return lldb::eFormatDecimal; - case clang::BuiltinType::UInt: return lldb::eFormatHex; - case clang::BuiltinType::Int: return lldb::eFormatDecimal; - case clang::BuiltinType::ULong: return lldb::eFormatHex; - case clang::BuiltinType::Long: return lldb::eFormatDecimal; - case clang::BuiltinType::ULongLong: return lldb::eFormatHex; - case clang::BuiltinType::LongLong: return lldb::eFormatDecimal; - case clang::BuiltinType::UInt128: return lldb::eFormatHex; - case clang::BuiltinType::Int128: return lldb::eFormatDecimal; - case clang::BuiltinType::Float: return lldb::eFormatFloat; - case clang::BuiltinType::Double: return lldb::eFormatFloat; - case clang::BuiltinType::LongDouble: return lldb::eFormatFloat; - case clang::BuiltinType::NullPtr: return lldb::eFormatHex; - } - break; - case clang::Type::ObjCObjectPointer: return lldb::eFormatHex; - case clang::Type::BlockPointer: return lldb::eFormatHex; - case clang::Type::Pointer: return lldb::eFormatHex; - case clang::Type::LValueReference: - case clang::Type::RValueReference: return lldb::eFormatHex; - case clang::Type::MemberPointer: break; - case clang::Type::Complex: return lldb::eFormatComplex; - case clang::Type::ObjCInterface: break; - case clang::Type::Record: break; - case clang::Type::Enum: return lldb::eFormatEnum; - case clang::Type::Typedef: - return lldb_private::Type::GetFormat(cast(qual_type)->LookThroughTypedefs().getAsOpaquePtr()); - - case clang::Type::TypeOfExpr: - case clang::Type::TypeOf: - case clang::Type::Decltype: -// case clang::Type::QualifiedName: - case clang::Type::TemplateSpecialization: break; - } - // We don't know hot to display this type... - return lldb::eFormatBytes; -} - lldb::Encoding lldb_private::Type::GetEncoding (uint32_t &count) @@ -1154,99 +391,10 @@ if (!ResolveClangType()) return lldb::eEncodingInvalid; - return Type::GetEncoding (m_clang_qual_type, count); + return lldb_private::ClangASTType::GetEncoding (m_clang_qual_type, count); } -lldb::Encoding -lldb_private::Type::GetEncoding (void *clang_type, uint32_t &count) -{ - count = 1; - clang::QualType qual_type(clang::QualType::getFromOpaquePtr(clang_type)); - - switch (qual_type->getTypeClass()) - { - case clang::Type::FunctionNoProto: - case clang::Type::FunctionProto: - break; - - case clang::Type::IncompleteArray: - case clang::Type::VariableArray: - break; - - case clang::Type::ConstantArray: - break; - - case clang::Type::ExtVector: - case clang::Type::Vector: - // TODO: Set this to more than one??? - break; - - case clang::Type::Builtin: - switch (cast(qual_type)->getKind()) - { - default: assert(0 && "Unknown builtin type!"); - case clang::BuiltinType::Void: - break; - - case clang::BuiltinType::Bool: - case clang::BuiltinType::Char_S: - case clang::BuiltinType::SChar: - case clang::BuiltinType::WChar: - case clang::BuiltinType::Char16: - case clang::BuiltinType::Char32: - case clang::BuiltinType::Short: - case clang::BuiltinType::Int: - case clang::BuiltinType::Long: - case clang::BuiltinType::LongLong: - case clang::BuiltinType::Int128: return lldb::eEncodingSint; - - case clang::BuiltinType::Char_U: - case clang::BuiltinType::UChar: - case clang::BuiltinType::UShort: - case clang::BuiltinType::UInt: - case clang::BuiltinType::ULong: - case clang::BuiltinType::ULongLong: - case clang::BuiltinType::UInt128: return lldb::eEncodingUint; - - case clang::BuiltinType::Float: - case clang::BuiltinType::Double: - case clang::BuiltinType::LongDouble: return lldb::eEncodingIEEE754; - - case clang::BuiltinType::NullPtr: return lldb::eEncodingUint; - } - break; - // All pointer types are represented as unsigned integer encodings. - // We may nee to add a eEncodingPointer if we ever need to know the - // difference - case clang::Type::ObjCObjectPointer: - case clang::Type::BlockPointer: - case clang::Type::Pointer: - case clang::Type::LValueReference: - case clang::Type::RValueReference: - case clang::Type::MemberPointer: return lldb::eEncodingUint; - // Complex numbers are made up of floats - case clang::Type::Complex: - count = 2; - return lldb::eEncodingIEEE754; - - case clang::Type::ObjCInterface: break; - case clang::Type::Record: break; - case clang::Type::Enum: return lldb::eEncodingSint; - case clang::Type::Typedef: - return Type::GetEncoding(cast(qual_type)->LookThroughTypedefs().getAsOpaquePtr(), count); - break; - - case clang::Type::TypeOfExpr: - case clang::Type::TypeOf: - case clang::Type::Decltype: -// case clang::Type::QualifiedName: - case clang::Type::TemplateSpecialization: break; - } - count = 0; - return lldb::eEncodingInvalid; -} - bool lldb_private::Type::DumpValueInMemory @@ -1273,93 +421,6 @@ return false; } -bool -lldb_private::Type::ReadFromMemory -( - lldb_private::ExecutionContext *exe_ctx, - clang::ASTContext *ast_context, - void *clang_type, - lldb::addr_t addr, - lldb::AddressType address_type, - lldb_private::DataExtractor &data -) -{ - if (address_type == lldb::eAddressTypeFile) - { - // Can't convert a file address to anything valid without more - // context (which Module it came from) - return false; - } - clang::QualType qual_type(clang::QualType::getFromOpaquePtr(clang_type)); - - const uint32_t byte_size = (ast_context->getTypeSize (qual_type) + 7) / 8; - if (data.GetByteSize() < byte_size) - { - lldb::DataBufferSP data_sp(new DataBufferHeap (byte_size, '\0')); - data.SetData(data_sp); - } - - uint8_t* dst = (uint8_t*)data.PeekData(0, byte_size); - if (dst != NULL) - { - if (address_type == lldb::eAddressTypeHost) - { - // The address is an address in this process, so just copy it - memcpy (dst, (uint8_t*)NULL + addr, byte_size); - return true; - } - else - { - if (exe_ctx && exe_ctx->process) - { - Error error; - return exe_ctx->process->ReadMemory(addr, dst, byte_size, error) == byte_size; - } - } - } - return false; -} - -bool -lldb_private::Type::WriteToMemory -( - lldb_private::ExecutionContext *exe_ctx, - clang::ASTContext *ast_context, - void *clang_type, - lldb::addr_t addr, - lldb::AddressType address_type, - StreamString &new_value -) -{ - if (address_type == lldb::eAddressTypeFile) - { - // Can't convert a file address to anything valid without more - // context (which Module it came from) - return false; - } - clang::QualType qual_type(clang::QualType::getFromOpaquePtr(clang_type)); - const uint32_t byte_size = (ast_context->getTypeSize (qual_type) + 7) / 8; - - if (byte_size > 0) - { - if (address_type == lldb::eAddressTypeHost) - { - // The address is an address in this process, so just copy it - memcpy ((void *)addr, new_value.GetData(), byte_size); - return true; - } - else - { - if (exe_ctx && exe_ctx->process) - { - Error error; - return exe_ctx->process->WriteMemory(addr, new_value.GetData(), byte_size, error) == byte_size; - } - } - } - return false; -} - bool lldb_private::Type::ReadFromMemory (lldb_private::ExecutionContext *exe_ctx, lldb::addr_t addr, lldb::AddressType address_type, lldb_private::DataExtractor &data) From wilsons at start.ca Thu Jul 22 13:05:53 2010 From: wilsons at start.ca (Stephen Wilson) Date: Thu, 22 Jul 2010 14:05:53 -0400 Subject: [Lldb-commits] [PATCH] Avoid segfault in pthread_cancel. Message-ID: An embedded and charset-unspecified text was scrubbed... Name: process-private-thread.patch Url: http://lists.cs.uiuc.edu/pipermail/lldb-commits/attachments/20100722/542f4d99/attachment.pl From gclayton at apple.com Thu Jul 22 13:30:50 2010 From: gclayton at apple.com (Greg Clayton) Date: Thu, 22 Jul 2010 18:30:50 -0000 Subject: [Lldb-commits] [lldb] r109130 - in /lldb/trunk: include/lldb/Symbol/ClangASTContext.h source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h source/Symbol/ClangASTContext.cpp Message-ID: <20100722183051.035EC2A6C12C@llvm.org> Author: gclayton Date: Thu Jul 22 13:30:50 2010 New Revision: 109130 URL: http://llvm.org/viewvc/llvm-project?rev=109130&view=rev Log: Added a new enumeration named "ClangASTContext::AccessType" that abstracts the type creation from the various access enumerations in Clang. Currently there are clang::AccessSpecifier and the objective C ivars have their own enumeration. So I added a new enumeration that will allow a consistent interface when creating types through ClangASTContext. I also added new functions to create an Objective C class, ivar and set an objective C superclass. They aren't hooked up in the DWARF parser yet. That is the next step, though I am unsure if I will do this in the DWARF parser or try and do it generically in the existing Record manipulation functions. Modified: lldb/trunk/include/lldb/Symbol/ClangASTContext.h lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h lldb/trunk/source/Symbol/ClangASTContext.cpp Modified: lldb/trunk/include/lldb/Symbol/ClangASTContext.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Symbol/ClangASTContext.h?rev=109130&r1=109129&r2=109130&view=diff ============================================================================== --- lldb/trunk/include/lldb/Symbol/ClangASTContext.h (original) +++ lldb/trunk/include/lldb/Symbol/ClangASTContext.h Thu Jul 22 13:30:50 2010 @@ -30,6 +30,22 @@ class ClangASTContext { public: + // Define access values that can be used for all functions in this + // class since Clang uses different values for all of the different + // access values (C++ AccessSpecifier enums differ from ObjC AccessControl). + // The SymbolFile classes that use these methods to created types + // will then be able to use one enumeration for all access and we can + // translate them correctly into the correct Clang versions depending on + // what the access is applied to. + typedef enum AccessType + { + eAccessNone, + eAccessPublic, + eAccessPrivate, + eAccessProtected, + eAccessPackage + }; + //------------------------------------------------------------------ // Constructors and Destructors //------------------------------------------------------------------ @@ -107,7 +123,7 @@ static void * CopyType(clang::ASTContext *dest_context, clang::ASTContext *source_context, - void * clang_type); + void *clang_type); static bool AreTypesSame(clang::ASTContext *ast_context, @@ -126,13 +142,13 @@ //------------------------------------------------------------------ static void * - AddConstModifier (void * clang_type); + AddConstModifier (void *clang_type); static void * - AddRestrictModifier (void * clang_type); + AddRestrictModifier (void *clang_type); static void * - AddVolatileModifier (void * clang_type); + AddVolatileModifier (void *clang_type); //------------------------------------------------------------------ // Structure, Unions, Classes @@ -147,7 +163,7 @@ AddFieldToRecordType (void * record_qual_type, const char *name, void * field_type, - int access, + AccessType access, uint32_t bitfield_bit_size); bool @@ -163,19 +179,37 @@ RecordHasFields (const clang::RecordDecl *record_decl); void - SetDefaultAccessForRecordFields (void * clang_qual_type, + SetDefaultAccessForRecordFields (void *clang_type, int default_accessibility, int *assigned_accessibilities, size_t num_assigned_accessibilities); + + void * + CreateObjCClass (const char *name, + clang::DeclContext *decl_ctx, + bool isForwardDecl, + bool isInternal); + + bool + AddObjCClassIVar (void *class_opaque_type, + const char *name, + void *ivar_opaque_type, + AccessType access, + uint32_t bitfield_bit_size, + bool isSynthesized); + + bool + SetObjCSuperClass (void *class_clang_type, + void *superclass_clang_type); //------------------------------------------------------------------ // Aggregate Types //------------------------------------------------------------------ static bool - IsAggregateType (void * clang_type); + IsAggregateType (void *clang_type); static uint32_t - GetNumChildren (void * clang_type, + GetNumChildren (void *clang_type, bool omit_empty_base_classes); void * @@ -237,7 +271,7 @@ clang::CXXBaseSpecifier * CreateBaseClassSpecifier (void * base_class_type, - int access, + AccessType access, bool is_virtual, bool base_of_class); @@ -329,13 +363,13 @@ // Pointers & References //------------------------------------------------------------------ void * - CreatePointerType (void * clang_type); + CreatePointerType (void *clang_type); void * - CreateLValueReferenceType (void * clang_type); + CreateLValueReferenceType (void *clang_type); void * - CreateRValueReferenceType (void * clang_type); + CreateRValueReferenceType (void *clang_type); void * CreateMemberPointerType (void * clang_pointee_type, @@ -345,32 +379,32 @@ GetPointerBitSize (); static size_t - GetTypeBitSize (clang::ASTContext *ast_context, void * clang_type); + GetTypeBitSize (clang::ASTContext *ast_context, void *clang_type); static size_t - GetTypeBitAlign (clang::ASTContext *ast_context, void * clang_type); + GetTypeBitAlign (clang::ASTContext *ast_context, void *clang_type); static bool - IsIntegerType (void * clang_type, bool &is_signed); + IsIntegerType (void *clang_type, bool &is_signed); static bool - IsPointerType (void * clang_type, void **target_type = NULL); + IsPointerType (void *clang_type, void **target_type = NULL); static bool - IsPointerOrReferenceType (void * clang_type, void **target_type = NULL); + IsPointerOrReferenceType (void *clang_type, void **target_type = NULL); static bool - IsCStringType (void * clang_type, uint32_t &length); + IsCStringType (void *clang_type, uint32_t &length); static bool - IsArrayType (void * clang_type, void **member_type = NULL, uint64_t *size = NULL); + IsArrayType (void *clang_type, void **member_type = NULL, uint64_t *size = NULL); //------------------------------------------------------------------ // Typedefs //------------------------------------------------------------------ void * CreateTypedefType (const char *name, - void * clang_type, + void *clang_type, clang::DeclContext *decl_ctx); //------------------------------------------------------------------ @@ -380,11 +414,11 @@ GetTypeName(void *clang_type); static bool - IsFloatingPointType (void * clang_type, uint32_t &count, bool &is_complex); + IsFloatingPointType (void *clang_type, uint32_t &count, bool &is_complex); //static bool //ConvertFloatValueToString (clang::ASTContext *ast_context, - // void * clang_type, + // void *clang_type, // const uint8_t* bytes, // size_t byte_size, // int apint_byte_order, @@ -392,7 +426,7 @@ static size_t ConvertStringToFloatValue (clang::ASTContext *ast_context, - void * clang_type, + void *clang_type, const char *s, uint8_t *dst, size_t dst_size); Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp?rev=109130&r1=109129&r2=109130&view=diff ============================================================================== --- lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp (original) +++ lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp Thu Jul 22 13:30:50 2010 @@ -57,20 +57,17 @@ using namespace lldb_private; -static uint32_t -DwarfToClangAccessibility (uint32_t dwarf_accessibility) +static ClangASTContext::AccessType +DW_ACCESS_to_AccessType (uint32_t dwarf_accessibility) { switch (dwarf_accessibility) { - case DW_ACCESS_public: - return clang::AS_public; - case DW_ACCESS_private: - return clang::AS_private; - case DW_ACCESS_protected: - return clang::AS_protected; - default: - return clang::AS_none; + case DW_ACCESS_public: return ClangASTContext::eAccessPublic; + case DW_ACCESS_private: return ClangASTContext::eAccessPrivate; + case DW_ACCESS_protected: return ClangASTContext::eAccessProtected; + default: break; } + return ClangASTContext::eAccessNone; } void @@ -1216,7 +1213,7 @@ const DWARFDebugInfoEntry *parent_die, std::vector& base_classes, std::vector& member_accessibilities, - int& default_accessibility, + ClangASTContext::AccessType& default_accessibility, bool &is_a_class ) { @@ -1243,7 +1240,7 @@ DWARFExpression location; const char *name = NULL; lldb::user_id_t encoding_uid = LLDB_INVALID_UID; - uint32_t accessibility = clang::AS_none; + ClangASTContext::AccessType accessibility = ClangASTContext::eAccessNone; off_t member_offset = 0; size_t byte_size = 0; size_t bit_offset = 0; @@ -1280,7 +1277,7 @@ } break; - case DW_AT_accessibility: accessibility = DwarfToClangAccessibility (form_value.Unsigned()); break; + case DW_AT_accessibility: accessibility = DW_ACCESS_to_AccessType (form_value.Unsigned()); break; case DW_AT_declaration: case DW_AT_description: case DW_AT_mutable: @@ -1294,7 +1291,7 @@ Type *member_type = ResolveTypeUID(encoding_uid); assert(member_type); - if (accessibility == clang::AS_none) + if (accessibility == ClangASTContext::eAccessNone) accessibility = default_accessibility; member_accessibilities.push_back(accessibility); @@ -1306,8 +1303,8 @@ case DW_TAG_subprogram: { is_a_class = true; - if (default_accessibility == clang::AS_none) - default_accessibility = clang::AS_private; + if (default_accessibility == ClangASTContext::eAccessNone) + default_accessibility = ClangASTContext::eAccessPrivate; // TODO: implement DW_TAG_subprogram type parsing // UserDefTypeChildInfo method_info(die->GetOffset()); // @@ -1323,8 +1320,8 @@ case DW_TAG_inheritance: { is_a_class = true; - if (default_accessibility == clang::AS_none) - default_accessibility = clang::AS_private; + if (default_accessibility == ClangASTContext::eAccessNone) + default_accessibility = ClangASTContext::eAccessPrivate; // TODO: implement DW_TAG_inheritance type parsing DWARFDebugInfoEntry::Attributes attributes; const size_t num_attributes = die->GetAttributes(this, dwarf_cu, attributes); @@ -1333,7 +1330,7 @@ Declaration decl; DWARFExpression location; lldb::user_id_t encoding_uid = LLDB_INVALID_UID; - uint32_t accessibility = default_accessibility; + ClangASTContext::AccessType accessibility = default_accessibility; bool is_virtual = false; bool is_base_of_class = true; off_t member_offset = 0; @@ -1366,7 +1363,7 @@ break; case DW_AT_accessibility: - accessibility = DwarfToClangAccessibility(form_value.Unsigned()); + accessibility = DW_ACCESS_to_AccessType(form_value.Unsigned()); break; case DW_AT_virtuality: is_virtual = form_value.Unsigned() != 0; break; @@ -2574,7 +2571,7 @@ { TypeSP type_sp; - uint32_t accessibility = clang::AS_none; + ClangASTContext::AccessType accessibility = ClangASTContext::eAccessNone; if (die != NULL) { dw_tag_t tag = die->Tag(); @@ -2732,7 +2729,7 @@ type_name_dbstr.SetCString(type_name_cstr); break; case DW_AT_byte_size: byte_size = form_value.Unsigned(); break; - case DW_AT_accessibility: accessibility = DwarfToClangAccessibility(form_value.Unsigned()); break; break; + case DW_AT_accessibility: accessibility = DW_ACCESS_to_AccessType(form_value.Unsigned()); break; break; case DW_AT_declaration: is_forward_declaration = form_value.Unsigned() != 0; break; case DW_AT_allocated: case DW_AT_associated: @@ -2749,21 +2746,21 @@ } int tag_decl_kind = -1; - int default_accessibility = clang::AS_none; + ClangASTContext::AccessType default_accessibility = ClangASTContext::eAccessNone; if (tag == DW_TAG_structure_type) { tag_decl_kind = clang::TTK_Struct; - default_accessibility = clang::AS_public; + default_accessibility = ClangASTContext::eAccessPublic; } else if (tag == DW_TAG_union_type) { tag_decl_kind = clang::TTK_Union; - default_accessibility = clang::AS_public; + default_accessibility = ClangASTContext::eAccessPublic; } else if (tag == DW_TAG_class_type) { tag_decl_kind = clang::TTK_Class; - default_accessibility = clang::AS_private; + default_accessibility = ClangASTContext::eAccessPrivate; } assert (tag_decl_kind != -1); @@ -2804,7 +2801,7 @@ { // This is a class and all members that didn't have // their access specified are private. - type_list->GetClangASTContext().SetDefaultAccessForRecordFields (clang_type, clang::AS_private, &member_accessibilities.front(), member_accessibilities.size()); + type_list->GetClangASTContext().SetDefaultAccessForRecordFields (clang_type, ClangASTContext::eAccessPrivate, &member_accessibilities.front(), member_accessibilities.size()); } if (!base_classes.empty()) @@ -2853,7 +2850,7 @@ break; case DW_AT_type: encoding_uid = form_value.Reference(dwarf_cu); break; case DW_AT_byte_size: byte_size = form_value.Unsigned(); break; - case DW_AT_accessibility: accessibility = DwarfToClangAccessibility(form_value.Unsigned()); break; + case DW_AT_accessibility: accessibility = DW_ACCESS_to_AccessType(form_value.Unsigned()); break; case DW_AT_declaration: is_forward_declaration = form_value.Unsigned() != 0; break; case DW_AT_allocated: case DW_AT_associated: @@ -2926,7 +2923,7 @@ case DW_AT_MIPS_linkage_name: mangled = form_value.AsCString(&get_debug_str_data()); break; case DW_AT_type: type_die_offset = form_value.Reference(dwarf_cu); break; - case DW_AT_accessibility: accessibility = DwarfToClangAccessibility(form_value.Unsigned()); break; + case DW_AT_accessibility: accessibility = DW_ACCESS_to_AccessType(form_value.Unsigned()); break; case DW_AT_declaration: is_forward_declaration = form_value.Unsigned() != 0; break; case DW_AT_external: if (form_value.Unsigned()) @@ -3043,7 +3040,7 @@ case DW_AT_byte_size: byte_size = form_value.Unsigned(); break; case DW_AT_byte_stride: byte_stride = form_value.Unsigned(); break; case DW_AT_bit_stride: bit_stride = form_value.Unsigned(); break; - case DW_AT_accessibility: accessibility = DwarfToClangAccessibility(form_value.Unsigned()); break; + case DW_AT_accessibility: accessibility = DW_ACCESS_to_AccessType(form_value.Unsigned()); break; case DW_AT_declaration: is_forward_declaration = form_value.Unsigned() != 0; break; case DW_AT_allocated: case DW_AT_associated: @@ -3366,7 +3363,7 @@ DWARFExpression location; bool is_external = false; bool is_artificial = false; - uint32_t accessibility = clang::AS_none; + ClangASTContext::AccessType accessibility = ClangASTContext::eAccessNone; for (i=0; i& base_classes, std::vector& member_accessibilities, - int &default_accessibility, + lldb_private::ClangASTContext::AccessType &default_accessibility, bool &is_a_class); size_t ParseChildParameters( Modified: lldb/trunk/source/Symbol/ClangASTContext.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/ClangASTContext.cpp?rev=109130&r1=109129&r2=109130&view=diff ============================================================================== --- lldb/trunk/source/Symbol/ClangASTContext.cpp (original) +++ lldb/trunk/source/Symbol/ClangASTContext.cpp Thu Jul 22 13:30:50 2010 @@ -18,6 +18,7 @@ #include "clang/AST/ASTContext.h" #include "clang/AST/ASTImporter.h" #include "clang/AST/CXXInheritance.h" +#include "clang/AST/DeclObjC.h" #include "clang/AST/RecordLayout.h" #include "clang/AST/Type.h" #include "clang/Basic/Builtins.h" @@ -37,6 +38,36 @@ using namespace llvm; using namespace clang; +static AccessSpecifier +ConvertAccessTypeToAccessSpecifier (ClangASTContext::AccessType access) +{ + switch (access) + { + default: break; + case ClangASTContext::eAccessNone: return AS_none; + case ClangASTContext::eAccessPublic: return AS_public; + case ClangASTContext::eAccessPrivate: return AS_private; + case ClangASTContext::eAccessProtected: return AS_protected; + } + return AS_none; +} + +static ObjCIvarDecl::AccessControl +ConvertAccessTypeToObjCIvarAccessControl (ClangASTContext::AccessType access) +{ + switch (access) + { + default: break; + case ClangASTContext::eAccessNone: return ObjCIvarDecl::None; + case ClangASTContext::eAccessPublic: return ObjCIvarDecl::Public; + case ClangASTContext::eAccessPrivate: return ObjCIvarDecl::Private; + case ClangASTContext::eAccessProtected: return ObjCIvarDecl::Protected; + case ClangASTContext::eAccessPackage: return ObjCIvarDecl::Package; + } + return ObjCIvarDecl::None; +} + + static void ParseLangArgs ( @@ -661,7 +692,7 @@ void * ClangASTContext::CopyType(clang::ASTContext *dest_context, clang::ASTContext *source_context, - void * clang_type) + void *clang_type) { Diagnostic diagnostics; FileManager file_manager; @@ -745,7 +776,14 @@ } bool -ClangASTContext::AddFieldToRecordType (void * record_clang_type, const char *name, void * field_type, int access, uint32_t bitfield_bit_size) +ClangASTContext::AddFieldToRecordType +( + void *record_clang_type, + const char *name, + void *field_type, + AccessType access, + uint32_t bitfield_bit_size +) { if (record_clang_type == NULL || field_type == NULL) return false; @@ -777,16 +815,16 @@ APInt bitfield_bit_size_apint(ast_context->getTypeSize(ast_context->IntTy), bitfield_bit_size); bit_width = new (*ast_context)IntegerLiteral (bitfield_bit_size_apint, ast_context->IntTy, SourceLocation()); } - FieldDecl *field = FieldDecl::Create(*ast_context, - record_decl, - SourceLocation(), - name ? &identifier_table->get(name) : NULL, // Identifier - QualType::getFromOpaquePtr(field_type), // Field type - NULL, // DeclaratorInfo * - bit_width, // BitWidth - false); // Mutable + FieldDecl *field = FieldDecl::Create (*ast_context, + record_decl, + SourceLocation(), + name ? &identifier_table->get(name) : NULL, // Identifier + QualType::getFromOpaquePtr(field_type), // Field type + NULL, // DeclaratorInfo * + bit_width, // BitWidth + false); // Mutable - field->setAccess((AccessSpecifier)access); + field->setAccess (ConvertAccessTypeToAccessSpecifier (access)); if (field) { @@ -891,7 +929,7 @@ #pragma mark C++ Base Classes CXXBaseSpecifier * -ClangASTContext::CreateBaseClassSpecifier (void *base_class_type, int access, bool is_virtual, bool base_of_class) +ClangASTContext::CreateBaseClassSpecifier (void *base_class_type, AccessType access, bool is_virtual, bool base_of_class) { if (base_class_type) return new CXXBaseSpecifier(SourceRange(), is_virtual, base_of_class, (AccessSpecifier)access, QualType::getFromOpaquePtr(base_class_type)); @@ -931,7 +969,128 @@ } return false; } +#pragma mark Objective C Classes +void * +ClangASTContext::CreateObjCClass +( + const char *name, + DeclContext *decl_ctx, + bool isForwardDecl, + bool isInternal +) +{ + ASTContext *ast_context = getASTContext(); + assert (ast_context != NULL); + assert (name && name[0]); + if (decl_ctx == NULL) + decl_ctx = ast_context->getTranslationUnitDecl(); + + // NOTE: Eventually CXXRecordDecl will be merged back into RecordDecl and + // we will need to update this code. I was told to currently always use + // the CXXRecordDecl class since we often don't know from debug information + // if something is struct or a class, so we default to always use the more + // complete definition just in case. + ObjCInterfaceDecl *decl = ObjCInterfaceDecl::Create (*ast_context, + decl_ctx, + SourceLocation(), + &ast_context->Idents.get(name), + SourceLocation(), + isForwardDecl, + isInternal); + + return QualType (decl->getTypeForDecl(), 0).getAsOpaquePtr(); +} + +bool +ClangASTContext::SetObjCSuperClass (void *class_opaque_type, void *super_opaque_type) +{ + if (class_opaque_type && super_opaque_type) + { + QualType class_qual_type(QualType::getFromOpaquePtr(class_opaque_type)); + QualType super_qual_type(QualType::getFromOpaquePtr(super_opaque_type)); + clang::Type *class_type = class_qual_type.getTypePtr(); + clang::Type *super_type = super_qual_type.getTypePtr(); + if (class_type && super_type) + { + ObjCObjectType *objc_class_type = dyn_cast(class_type); + ObjCObjectType *objc_super_type = dyn_cast(super_type); + if (objc_class_type && objc_super_type) + { + ObjCInterfaceDecl *class_interface_decl = objc_class_type->getInterface(); + ObjCInterfaceDecl *super_interface_decl = objc_super_type->getInterface(); + if (class_interface_decl && super_interface_decl) + { + class_interface_decl->setSuperClass(super_interface_decl); + return true; + } + } + } + } + return false; +} + + +bool +ClangASTContext::AddObjCClassIVar +( + void *class_opaque_type, + const char *name, + void *ivar_opaque_type, + AccessType access, + uint32_t bitfield_bit_size, + bool isSynthesized +) +{ + if (class_opaque_type == NULL || ivar_opaque_type == NULL) + return false; + + ASTContext *ast_context = getASTContext(); + IdentifierTable *identifier_table = getIdentifierTable(); + + assert (ast_context != NULL); + assert (identifier_table != NULL); + + QualType class_qual_type(QualType::getFromOpaquePtr(class_opaque_type)); + + clang::Type *class_type = class_qual_type.getTypePtr(); + if (class_type) + { + ObjCObjectType *objc_class_type = dyn_cast(class_type); + + if (objc_class_type) + { + ObjCInterfaceDecl *class_interface_decl = objc_class_type->getInterface(); + + if (class_interface_decl) + { + clang::Expr *bit_width = NULL; + if (bitfield_bit_size != 0) + { + APInt bitfield_bit_size_apint(ast_context->getTypeSize(ast_context->IntTy), bitfield_bit_size); + bit_width = new (*ast_context)IntegerLiteral (bitfield_bit_size_apint, ast_context->IntTy, SourceLocation()); + } + + //ObjCIvarDecl *field = + ObjCIvarDecl::Create (*ast_context, + class_interface_decl, + SourceLocation(), + &identifier_table->get(name), // Identifier + QualType::getFromOpaquePtr(ivar_opaque_type), // Field type + NULL, // TypeSourceInfo * + ConvertAccessTypeToObjCIvarAccessControl (access), + bit_width, + isSynthesized); + // TODO: Do I need to do an addDecl? I am thinking I don't since + // I passed the "class_interface_decl" into "ObjCIvarDecl::Create" + // above. Verify this. Also verify it is ok to pass NULL TypeSourceInfo + // above. + return true; + } + } + } + return false; +} #pragma mark Aggregate Types @@ -1956,7 +2115,7 @@ } ParmVarDecl * -ClangASTContext::CreateParmeterDeclaration (const char *name, void * return_type, int storage) +ClangASTContext::CreateParmeterDeclaration (const char *name, void *return_type, int storage) { ASTContext *ast_context = getASTContext(); assert (ast_context != NULL); @@ -2147,7 +2306,7 @@ } void * -ClangASTContext::CreateMemberPointerType (void * clang_pointee_type, void * clang_class_type) +ClangASTContext::CreateMemberPointerType (void *clang_pointee_type, void *clang_class_type) { if (clang_pointee_type && clang_pointee_type) return getASTContext()->getMemberPointerType(QualType::getFromOpaquePtr(clang_pointee_type), @@ -2220,7 +2379,7 @@ } bool -ClangASTContext::IsIntegerType (void * clang_type, bool &is_signed) +ClangASTContext::IsIntegerType (void *clang_type, bool &is_signed) { if (!clang_type) return false; @@ -2376,7 +2535,7 @@ } bool -ClangASTContext::IsArrayType (void * clang_type, void **member_type, uint64_t *size) +ClangASTContext::IsArrayType (void *clang_type, void **member_type, uint64_t *size) { if (!clang_type) return false; From gclayton at apple.com Thu Jul 22 13:34:22 2010 From: gclayton at apple.com (Greg Clayton) Date: Thu, 22 Jul 2010 18:34:22 -0000 Subject: [Lldb-commits] [lldb] r109131 - /lldb/trunk/source/Target/Process.cpp Message-ID: <20100722183422.44AB32A6C12C@llvm.org> Author: gclayton Date: Thu Jul 22 13:34:21 2010 New Revision: 109131 URL: http://llvm.org/viewvc/llvm-project?rev=109131&view=rev Log: This patch changes the point at which Process::m_private_state_thread is invalidated. There was a race condition where the private thread would invalidate its own pthread_t object before the parent could perform a pthread_cancel/pthread_join sequence. Patch from Stephen Wilson. Modified: lldb/trunk/source/Target/Process.cpp Modified: lldb/trunk/source/Target/Process.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/Process.cpp?rev=109131&r1=109130&r2=109131&view=diff ============================================================================== --- lldb/trunk/source/Target/Process.cpp (original) +++ lldb/trunk/source/Target/Process.cpp Thu Jul 22 13:34:21 2010 @@ -1433,6 +1433,7 @@ thread_result_t result = NULL; Host::ThreadJoin (m_private_state_thread, &result, NULL); + m_private_state_thread = LLDB_INVALID_HOST_THREAD; } } } @@ -1470,7 +1471,6 @@ { Process *proc = static_cast (arg); void *result = proc->RunPrivateStateThread (); - proc->m_private_state_thread = LLDB_INVALID_HOST_THREAD; return result; } From gclayton at apple.com Thu Jul 22 13:34:32 2010 From: gclayton at apple.com (Greg Clayton) Date: Thu, 22 Jul 2010 11:34:32 -0700 Subject: [Lldb-commits] [PATCH] Avoid segfault in pthread_cancel. In-Reply-To: References: Message-ID: <28AEF4E4-1F47-478C-9305-46B5E5D7F002@apple.com> Committed revision 109131. On Jul 22, 2010, at 11:05 AM, Stephen Wilson wrote: > Hi, > > This patch changes the point at which Process::m_private_state_thread is > invalidated. There was a race condition where the private thread would > invalidate its own pthread_t object before the parent could perform a > pthread_cancel/pthread_join sequence. > > > Take care, > Steve > > _______________________________________________ > lldb-commits mailing list > lldb-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/lldb-commits From scallanan at apple.com Thu Jul 22 19:16:21 2010 From: scallanan at apple.com (Sean Callanan) Date: Fri, 23 Jul 2010 00:16:21 -0000 Subject: [Lldb-commits] [lldb] r109199 - in /lldb/trunk: include/lldb/Expression/ClangExpressionDeclMap.h include/lldb/Expression/ClangFunction.h include/lldb/Symbol/TaggedASTType.h lldb.xcodeproj/project.pbxproj source/Commands/CommandObjectExpression.cpp source/Expression/ClangExpressionDeclMap.cpp source/Expression/ClangFunction.cpp Message-ID: <20100723001621.DC6982A6C12C@llvm.org> Author: spyffe Date: Thu Jul 22 19:16:21 2010 New Revision: 109199 URL: http://llvm.org/viewvc/llvm-project?rev=109199&view=rev Log: Modified TaggedASTType to inherit from ClangASTType and moved it to its own header file for cleanliness. Added more logging to ClangFunction so that we can diagnose crashes in the executing expression. Added code to extract the result of the expression from the struct that is passed to the JIT-compiled code. Added: lldb/trunk/include/lldb/Symbol/TaggedASTType.h Modified: lldb/trunk/include/lldb/Expression/ClangExpressionDeclMap.h lldb/trunk/include/lldb/Expression/ClangFunction.h lldb/trunk/lldb.xcodeproj/project.pbxproj lldb/trunk/source/Commands/CommandObjectExpression.cpp lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp lldb/trunk/source/Expression/ClangFunction.cpp Modified: lldb/trunk/include/lldb/Expression/ClangExpressionDeclMap.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Expression/ClangExpressionDeclMap.h?rev=109199&r1=109198&r2=109199&view=diff ============================================================================== --- lldb/trunk/include/lldb/Expression/ClangExpressionDeclMap.h (original) +++ lldb/trunk/include/lldb/Expression/ClangExpressionDeclMap.h Thu Jul 22 19:16:21 2010 @@ -21,7 +21,7 @@ // Project includes #include "lldb/Core/ClangForward.h" #include "lldb/Core/Value.h" -#include "lldb/Symbol/ClangASTType.h" +#include "lldb/Symbol/TaggedASTType.h" namespace llvm { class Value; Modified: lldb/trunk/include/lldb/Expression/ClangFunction.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Expression/ClangFunction.h?rev=109199&r1=109198&r2=109199&view=diff ============================================================================== --- lldb/trunk/include/lldb/Expression/ClangFunction.h (original) +++ lldb/trunk/include/lldb/Expression/ClangFunction.h Thu Jul 22 19:16:21 2010 @@ -91,6 +91,9 @@ // This variant writes down function_address and arg_value. bool WriteFunctionArguments (ExecutionContext &exc_context, lldb::addr_t &args_addr_ref, Address function_address, ValueList &arg_values, Stream &errors); + // Run a function at a particular address, with a given address passed on the stack. + static ExecutionResults ExecuteFunction (ExecutionContext &exe_ctx, lldb::addr_t function_address, lldb::addr_t &void_arg, bool stop_others, bool try_all_threads, uint32_t single_thread_timeout_usec, Stream &errors); + //------------------------------------------------------------------ /// Run the function this ClangFunction was created with. /// @@ -198,7 +201,14 @@ ExecutionResults ExecuteFunction(ExecutionContext &context, lldb::addr_t *args_addr_ptr, Stream &errors, bool stop_others, uint32_t single_thread_timeout_usec, bool try_all_threads, Value &results); ExecutionResults ExecuteFunctionWithABI(ExecutionContext &context, Stream &errors, Value &results); - ThreadPlan *GetThreadPlanToCallFunction (ExecutionContext &exc_context, lldb::addr_t &args_addr_ref, Stream &errors, bool stop_others, bool discard_on_error = true); + static ThreadPlan * + GetThreadPlanToCallFunction (ExecutionContext &exc_context, lldb::addr_t func_addr, lldb::addr_t &args_addr_ref, Stream &errors, bool stop_others, bool discard_on_error = true); + + ThreadPlan * + GetThreadPlanToCallFunction (ExecutionContext &exc_context, lldb::addr_t &args_addr_ref, Stream &errors, bool stop_others, bool discard_on_error = true) + { + return ClangFunction::GetThreadPlanToCallFunction (exc_context, m_wrapper_function_addr, args_addr_ref, errors, stop_others, discard_on_error); + } bool FetchFunctionResults (ExecutionContext &exc_context, lldb::addr_t args_addr, Value &ret_value); void DeallocateFunctionResults (ExecutionContext &exc_context, lldb::addr_t args_addr); Added: lldb/trunk/include/lldb/Symbol/TaggedASTType.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Symbol/TaggedASTType.h?rev=109199&view=auto ============================================================================== --- lldb/trunk/include/lldb/Symbol/TaggedASTType.h (added) +++ lldb/trunk/include/lldb/Symbol/TaggedASTType.h Thu Jul 22 19:16:21 2010 @@ -0,0 +1,43 @@ +//===-- TaggedASTType.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_TaggedASTType_h_ +#define liblldb_TaggedASTType_h_ + +#include "lldb/Symbol/ClangASTType.h" + +namespace lldb_private +{ + +// For cases in which there are multiple classes of types that are not +// interchangeable, to allow static type checking. +template class TaggedASTType : public ClangASTType +{ +public: + TaggedASTType (void *type, clang::ASTContext *ast_context) : + ClangASTType(type, ast_context) { } + + TaggedASTType (const TaggedASTType &tw) : + ClangASTType(tw) { } + + TaggedASTType () : + ClangASTType() { } + + ~TaggedASTType() { } + + TaggedASTType &operator= (const TaggedASTType &tw) + { + ClangASTType::operator= (tw); + return *this; + } +}; + +} + +#endif Modified: lldb/trunk/lldb.xcodeproj/project.pbxproj URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/lldb.xcodeproj/project.pbxproj?rev=109199&r1=109198&r2=109199&view=diff ============================================================================== --- lldb/trunk/lldb.xcodeproj/project.pbxproj (original) +++ lldb/trunk/lldb.xcodeproj/project.pbxproj Thu Jul 22 19:16:21 2010 @@ -331,6 +331,7 @@ 49307AB211DEA4F20081F992 /* IRForTarget.h in Headers */ = {isa = PBXBuildFile; fileRef = 49307AB111DEA4F20081F992 /* IRForTarget.h */; }; 49A8A3A011D568A300AD3B68 /* ClangResultSynthesizer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 49A8A39F11D568A300AD3B68 /* ClangResultSynthesizer.cpp */; }; 49A8A3A411D568BF00AD3B68 /* ClangResultSynthesizer.h in Headers */ = {isa = PBXBuildFile; fileRef = 49A8A3A311D568BF00AD3B68 /* ClangResultSynthesizer.h */; }; + 49BB309611F79450001A4197 /* TaggedASTType.h in Headers */ = {isa = PBXBuildFile; fileRef = 49BB309511F79450001A4197 /* TaggedASTType.h */; }; 49D7072711B5AD03001AD875 /* ClangASTSource.h in Headers */ = {isa = PBXBuildFile; fileRef = 49D7072611B5AD03001AD875 /* ClangASTSource.h */; }; 49D7072911B5AD11001AD875 /* ClangASTSource.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 49D7072811B5AD11001AD875 /* ClangASTSource.cpp */; settings = {COMPILER_FLAGS = "-fno-rtti"; }; }; 49DA743011DE6A5A006AEF7E /* IRToDWARF.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 49DA742F11DE6A5A006AEF7E /* IRToDWARF.cpp */; }; @@ -906,6 +907,7 @@ 499F381F11A5B3F300F5CE02 /* CommandObjectArgs.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = CommandObjectArgs.cpp; path = source/Commands/CommandObjectArgs.cpp; sourceTree = ""; }; 49A8A39F11D568A300AD3B68 /* ClangResultSynthesizer.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = ClangResultSynthesizer.cpp; path = source/Expression/ClangResultSynthesizer.cpp; sourceTree = ""; }; 49A8A3A311D568BF00AD3B68 /* ClangResultSynthesizer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ClangResultSynthesizer.h; path = include/lldb/Expression/ClangResultSynthesizer.h; sourceTree = ""; }; + 49BB309511F79450001A4197 /* TaggedASTType.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = TaggedASTType.h; path = include/lldb/Symbol/TaggedASTType.h; sourceTree = ""; }; 49BF48DC11ADF356008863BD /* ObjCObjectPrinter.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = ObjCObjectPrinter.cpp; path = source/Target/ObjCObjectPrinter.cpp; sourceTree = ""; }; 49BF48E011ADF37D008863BD /* ObjCObjectPrinter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ObjCObjectPrinter.h; path = include/lldb/Target/ObjCObjectPrinter.h; sourceTree = ""; }; 49D7072611B5AD03001AD875 /* ClangASTSource.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ClangASTSource.h; path = include/lldb/Expression/ClangASTSource.h; sourceTree = ""; }; @@ -1700,6 +1702,7 @@ 26BC7C6310F1B6E900F91463 /* SymbolVendor.h */, 26BC7C6410F1B6E900F91463 /* Symtab.h */, 26BC7F1F10F1B8EC00F91463 /* Symtab.cpp */, + 49BB309511F79450001A4197 /* TaggedASTType.h */, 26BC7C6510F1B6E900F91463 /* Type.h */, 26BC7F2010F1B8EC00F91463 /* Type.cpp */, 26BC7C6610F1B6E900F91463 /* TypeList.h */, @@ -2202,6 +2205,7 @@ 4C5DBBC911E3FEC60035160F /* CommandObjectCommands.h in Headers */, 26D27CA011ED3A4E0024D721 /* ELFHeader.h in Headers */, 49E45FAA11F660DC008F7B28 /* ClangASTType.h in Headers */, + 49BB309611F79450001A4197 /* TaggedASTType.h in Headers */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -2764,7 +2768,7 @@ "$(LLVM_BUILD_DIR)", ); LLVM_BUILD_DIR = "$(SRCROOT)/llvm"; - LLVM_CONFIGURATION = Release; + LLVM_CONFIGURATION = "Debug+Asserts"; OTHER_CFLAGS = ( "-DFOR_DYLD=0", "-DSUPPORT_REMOTE_UNWINDING", @@ -2817,7 +2821,7 @@ "$(LLVM_BUILD_DIR)", ); LLVM_BUILD_DIR = "$(SRCROOT)/llvm"; - LLVM_CONFIGURATION = Release; + LLVM_CONFIGURATION = "Debug+Asserts"; OTHER_CFLAGS = ( "-DFOR_DYLD=0", "-DSUPPORT_REMOTE_UNWINDING", @@ -2927,7 +2931,7 @@ "$(LLVM_BUILD_DIR)", ); LLVM_BUILD_DIR = "$(DERIVED_FILE_DIR)/llvm.build"; - LLVM_CONFIGURATION = Release; + LLVM_CONFIGURATION = "Debug+Asserts"; OTHER_CFLAGS = ( "-DFOR_DYLD=0", "-DSUPPORT_REMOTE_UNWINDING", Modified: lldb/trunk/source/Commands/CommandObjectExpression.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectExpression.cpp?rev=109199&r1=109198&r2=109199&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectExpression.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectExpression.cpp Thu Jul 22 19:16:21 2010 @@ -12,26 +12,25 @@ // C Includes // C++ Includes // Other libraries and framework includes -#include "llvm/ADT/StringRef.h" - // Project includes -#include "lldb/Core/Debugger.h" +#include "lldb/Interpreter/Args.h" #include "lldb/Core/Value.h" #include "lldb/Core/InputReader.h" #include "lldb/Expression/ClangExpression.h" #include "lldb/Expression/ClangExpressionDeclMap.h" #include "lldb/Expression/ClangExpressionVariable.h" +#include "lldb/Expression/CLangFunction.h" #include "lldb/Expression/DWARFExpression.h" #include "lldb/Host/Host.h" -#include "lldb/Interpreter/Args.h" +#include "lldb/Core/Debugger.h" #include "lldb/Interpreter/CommandInterpreter.h" #include "lldb/Interpreter/CommandReturnObject.h" -#include "lldb/Symbol/ClangASTType.h" #include "lldb/Symbol/ObjectFile.h" #include "lldb/Symbol/Variable.h" #include "lldb/Target/Process.h" #include "lldb/Target/StackFrame.h" #include "lldb/Target/Target.h" +#include "llvm/ADT/StringRef.h" using namespace lldb; using namespace lldb_private; @@ -256,6 +255,10 @@ bool success; bool canInterpret = false; + clang::ASTContext *ast_context = clang_expr.GetASTContext (); + Value expr_result; + Error expr_error; + if (m_options.use_ir) { canInterpret = clang_expr.ConvertIRToDWARF (expr_local_vars, dwarf_opcodes); @@ -306,21 +309,56 @@ return false; } - Error err; lldb::addr_t struct_address; - if (!expr_decl_map.Materialize(&m_exe_ctx, struct_address, err)) + if (!expr_decl_map.Materialize(&m_exe_ctx, struct_address, expr_error)) { - error_stream.Printf ("Couldn't materialize struct: %s\n", err.AsCString("unknown error")); + error_stream.Printf ("Couldn't materialize struct: %s\n", expr_error.AsCString("unknown error")); return false; } - log->Printf("Function address : 0x%llx", (uint64_t)function_address); - log->Printf("Structure address : 0x%llx", (uint64_t)struct_address); + if (log) + { + log->Printf("Function address : 0x%llx", (uint64_t)function_address); + log->Printf("Structure address : 0x%llx", (uint64_t)struct_address); + } + + ClangFunction::ExecutionResults execution_result = + ClangFunction::ExecuteFunction (m_exe_ctx, function_address, struct_address, true, true, 10000, error_stream); + + if (execution_result != ClangFunction::eExecutionCompleted) + { + const char *result_name; + + switch (execution_result) + { + case ClangFunction::eExecutionCompleted: + result_name = "eExecutionCompleted"; + break; + case ClangFunction::eExecutionDiscarded: + result_name = "eExecutionDiscarded"; + break; + case ClangFunction::eExecutionInterrupted: + result_name = "eExecutionInterrupted"; + break; + case ClangFunction::eExecutionSetupError: + result_name = "eExecutionSetupError"; + break; + case ClangFunction::eExecutionTimedOut: + result_name = "eExecutionTimedOut"; + break; + } + + error_stream.Printf ("Couldn't execute function; result was %s\n", result_name); + return false; + } + + if (!expr_decl_map.Dematerialize(&m_exe_ctx, expr_result, expr_error)) + { + error_stream.Printf ("Couldn't dematerialize struct: %s\n", expr_error.AsCString("unknown error")); + return false; + } } - - return true; - } else { @@ -356,9 +394,6 @@ log->PutCString (stream_string.GetString ().c_str ()); } - 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) @@ -366,81 +401,77 @@ 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; - } - - if (format == eFormatDefault) - format = expr_result.GetValueDefaultFormat (); - - void *clang_type = expr_result.GetValueOpaqueClangQualType (); - - if (clang_type) - { - if (m_options.show_types) - { - ConstString type_name(ClangASTType::GetClangTypeName (clang_type)); - if (type_name) - output_stream.Printf("(%s) ", type_name.AsCString("")); - } - - ClangASTType::DumpValue (ast_context, // The ASTContext that the clang type belongs to - clang_type, // The opaque clang type we want to dump that value of - &m_exe_ctx, // The execution context for memory and variable access - &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 - { - 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(); - + /////////////////////////////////////// + // 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; + } + + if (format == eFormatDefault) + format = expr_result.GetValueDefaultFormat (); + + void *clang_type = expr_result.GetValueOpaqueClangQualType (); + + if (clang_type) + { + if (m_options.show_types) + output_stream.PutCString(ClangASTType::GetClangTypeName (clang_type).GetCString()); + + ClangASTType::DumpValue (ast_context, // The ASTContext that the clang type belongs to + clang_type, // The opaque clang type we want to dump that value of + &m_exe_ctx, // The execution context for memory and variable access + &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 + { + 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(); + + return true; } bool Modified: lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp?rev=109199&r1=109198&r2=109199&view=diff ============================================================================== --- lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp (original) +++ lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp Thu Jul 22 19:16:21 2010 @@ -295,8 +295,10 @@ iter->m_parser_type.GetOpaqueQualType()), context); - result_value->SetContext(Value::eContextTypeOpaqueClangQualType, - copied_type.GetOpaqueQualType()); + result_value->SetContext(Value::eContextTypeOpaqueClangQualType, copied_type.GetOpaqueQualType()); + + result_value->SetValueType(Value::eValueTypeLoadAddress); + result_value->GetScalar() = (uintptr_t)m_materialized_location + iter->m_offset; } continue; @@ -330,10 +332,8 @@ return false; } - log->Printf("%s %s with type %p", - (dematerialize ? "Dematerializing" : "Materializing"), - name, - type.GetOpaqueQualType()); + if (log) + log->Printf("%s %s with type %p", (dematerialize ? "Dematerializing" : "Materializing"), name, type.GetOpaqueQualType()); std::auto_ptr location_value(GetVariableValue(exe_ctx, var, @@ -349,8 +349,7 @@ { lldb::addr_t value_addr = location_value->GetScalar().ULongLong(); - size_t bit_size = ClangASTContext::GetTypeBitSize (type.GetASTContext(), - type.GetOpaqueQualType()); + size_t bit_size = ClangASTContext::GetTypeBitSize(type.GetASTContext(), type.GetOpaqueQualType()); size_t byte_size = bit_size % 8 ? ((bit_size + 8) / 8) : (bit_size / 8); DataBufferHeap data; @@ -493,9 +492,7 @@ if (type->GetASTContext() == var->GetType()->GetClangAST()) { - if (!ClangASTContext::AreTypesSame(type->GetASTContext(), - type->GetOpaqueQualType(), - var->GetType()->GetOpaqueClangQualType())) + if (!ClangASTContext::AreTypesSame(type->GetASTContext(), type->GetOpaqueQualType(), var->GetType()->GetOpaqueClangQualType())) return NULL; } else Modified: lldb/trunk/source/Expression/ClangFunction.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/ClangFunction.cpp?rev=109199&r1=109198&r2=109199&view=diff ============================================================================== --- lldb/trunk/source/Expression/ClangFunction.cpp (original) +++ lldb/trunk/source/Expression/ClangFunction.cpp Thu Jul 22 19:16:21 2010 @@ -32,6 +32,7 @@ #include "lldb/Symbol/Function.h" #include "lldb/Target/ExecutionContext.h" #include "lldb/Target/Process.h" +#include "lldb/Target/RegisterContext.h" #include "lldb/Target/Thread.h" #include "lldb/Target/ThreadPlan.h" #include "lldb/Target/ThreadPlanCallFunction.h" @@ -385,7 +386,7 @@ } ThreadPlan * -ClangFunction::GetThreadPlanToCallFunction (ExecutionContext &exc_context, lldb::addr_t &args_addr, Stream &errors, bool stop_others, bool discard_on_error) +ClangFunction::GetThreadPlanToCallFunction (ExecutionContext &exc_context, lldb::addr_t func_addr, lldb::addr_t &args_addr, Stream &errors, bool stop_others, bool discard_on_error) { // FIXME: Use the errors Stream for better error reporting. @@ -399,7 +400,7 @@ // Okay, now run the function: - Address wrapper_address (NULL, m_wrapper_function_addr); + Address wrapper_address (NULL, func_addr); ThreadPlan *new_plan = new ThreadPlanCallFunction (*exc_context.thread, wrapper_address, args_addr, @@ -473,86 +474,68 @@ return ExecuteFunction (exc_context, NULL, errors, true, single_thread_timeout_usec, try_all_threads, results); } -ClangFunction::ExecutionResults -ClangFunction::ExecuteFunction( +// This is the static function +ClangFunction::ExecutionResults +ClangFunction::ExecuteFunction ( ExecutionContext &exc_context, - lldb::addr_t *args_addr_ptr, - Stream &errors, - bool stop_others, - uint32_t single_thread_timeout_usec, - bool try_all_threads, - Value &results) + lldb::addr_t function_address, + lldb::addr_t &void_arg, + bool stop_others, + bool try_all_threads, + uint32_t single_thread_timeout_usec, + Stream &errors) { - using namespace clang; - ExecutionResults return_value = eExecutionSetupError; - Process *process = exc_context.process; - - lldb::addr_t args_addr; - - if (args_addr_ptr != NULL) - args_addr = *args_addr_ptr; - else - args_addr = LLDB_INVALID_ADDRESS; - - if (CompileFunction(errors) != 0) - return eExecutionSetupError; - - if (args_addr == LLDB_INVALID_ADDRESS) - { - if (!InsertFunction(exc_context, args_addr, errors)) - return eExecutionSetupError; - } - + ClangFunction::ExecutionResults return_value = eExecutionSetupError; - lldb::ThreadPlanSP call_plan_sp(GetThreadPlanToCallFunction(exc_context, args_addr, errors, stop_others, false)); + lldb::ThreadPlanSP call_plan_sp(ClangFunction::GetThreadPlanToCallFunction(exc_context, function_address, void_arg, errors, stop_others, false)); ThreadPlanCallFunction *call_plan_ptr = static_cast (call_plan_sp.get()); - if (args_addr_ptr != NULL) - *args_addr_ptr = args_addr; - if (call_plan_sp == NULL) - return return_value; - + return eExecutionSetupError; + call_plan_sp->SetPrivate(true); exc_context.thread->QueueThreadPlan(call_plan_sp, true); - + // We need to call the function synchronously, so spin waiting for it to return. // If we get interrupted while executing, we're going to lose our context, and // won't be able to gather the result at this point. - + TimeValue* timeout_ptr = NULL; TimeValue real_timeout; + if (single_thread_timeout_usec != 0) { real_timeout = TimeValue::Now(); real_timeout.OffsetWithMicroSeconds(single_thread_timeout_usec); timeout_ptr = &real_timeout; } - process->Resume (); - + + exc_context.process->Resume (); + + Log *log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_STEP); while (1) { lldb::EventSP event_sp; - + // Now wait for the process to stop again: // FIXME: Probably want a time out. - lldb::StateType stop_state = process->WaitForStateChangedEvents (timeout_ptr, event_sp); + lldb::StateType stop_state = exc_context.process->WaitForStateChangedEvents (timeout_ptr, event_sp); + if (stop_state == lldb::eStateInvalid && timeout_ptr != NULL) { // Right now this is the only way to tell we've timed out... // We should interrupt the process here... // Not really sure what to do if Halt fails here... - Log *log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_STEP); if (log) log->Printf ("Running function with timeout: %d timed out, trying with all threads enabled.", single_thread_timeout_usec); - - if (process->Halt().Success()) + + if (exc_context.process->Halt().Success()) { timeout_ptr = NULL; - stop_state = process->WaitForStateChangedEvents (timeout_ptr, event_sp); + stop_state = exc_context.process->WaitForStateChangedEvents (timeout_ptr, event_sp); if (stop_state == lldb::eStateInvalid) { errors.Printf ("Got an invalid stop state after halt."); @@ -574,10 +557,9 @@ return_value = eExecutionCompleted; break; } - - + call_plan_ptr->SetStopOthers (false); - process->Resume(); + exc_context.process->Resume(); continue; } else @@ -586,7 +568,7 @@ } if (stop_state == lldb::eStateRunning || stop_state == lldb::eStateStepping) continue; - + if (exc_context.thread->IsThreadPlanDone (call_plan_sp.get())) { return_value = eExecutionCompleted; @@ -599,12 +581,114 @@ } else { + if (log) + { + StreamString s; + event_sp->Dump (&s); + StreamString ts; + + const char *event_explanation; + + do + { + const Process::ProcessEventData *event_data = Process::ProcessEventData::GetEventDataFromEvent (event_sp.get()); + + if (!event_data) + { + event_explanation = ""; + break; + } + + Process *process = event_data->GetProcessSP().get(); + + if (!process) + { + event_explanation = ""; + break; + } + + ThreadList &thread_list = process->GetThreadList(); + + uint32_t num_threads = thread_list.GetSize(); + uint32_t thread_index; + + ts.Printf("<%u threads> ", num_threads); + + for (thread_index = 0; + thread_index < num_threads; + ++thread_index) + { + Thread *thread = thread_list.GetThreadAtIndex(thread_index).get(); + + if (!thread) + { + ts.Printf(" "); + continue; + } + + Thread::StopInfo stop_info; + thread->GetStopInfo(&stop_info); + + ts.Printf("<"); + RegisterContext *register_context = thread->GetRegisterContext(); + + if (register_context) + ts.Printf("[ip 0x%llx] ", register_context->GetPC()); + else + ts.Printf("[ip unknown] "); + + stop_info.Dump(&ts); + ts.Printf(">"); + } + + event_explanation = ts.GetData(); + } while (0); + + log->Printf("Execution interrupted: %s %s", s.GetData(), event_explanation); + } + return_value = eExecutionInterrupted; break; } + } + + return return_value; +} +ClangFunction::ExecutionResults +ClangFunction::ExecuteFunction( + ExecutionContext &exc_context, + lldb::addr_t *args_addr_ptr, + Stream &errors, + bool stop_others, + uint32_t single_thread_timeout_usec, + bool try_all_threads, + Value &results) +{ + using namespace clang; + ExecutionResults return_value = eExecutionSetupError; + + lldb::addr_t args_addr; + + if (args_addr_ptr != NULL) + args_addr = *args_addr_ptr; + else + args_addr = LLDB_INVALID_ADDRESS; + + if (CompileFunction(errors) != 0) + return eExecutionSetupError; + + if (args_addr == LLDB_INVALID_ADDRESS) + { + if (!InsertFunction(exc_context, args_addr, errors)) + return eExecutionSetupError; } + + return_value = ClangFunction::ExecuteFunction(exc_context, m_wrapper_function_addr, args_addr, stop_others, try_all_threads, single_thread_timeout_usec, errors); + if (args_addr_ptr != NULL) + *args_addr_ptr = args_addr; + if (return_value != eExecutionCompleted) return return_value; From scallanan at apple.com Thu Jul 22 19:16:53 2010 From: scallanan at apple.com (Sean Callanan) Date: Fri, 23 Jul 2010 00:16:53 -0000 Subject: [Lldb-commits] [lldb] r109200 - /lldb/trunk/lldb.xcodeproj/project.pbxproj Message-ID: <20100723001653.2CB652A6C12C@llvm.org> Author: spyffe Date: Thu Jul 22 19:16:53 2010 New Revision: 109200 URL: http://llvm.org/viewvc/llvm-project?rev=109200&view=rev Log: Whoops, fixed the LLVM_CONFIGURATION. Modified: lldb/trunk/lldb.xcodeproj/project.pbxproj Modified: lldb/trunk/lldb.xcodeproj/project.pbxproj URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/lldb.xcodeproj/project.pbxproj?rev=109200&r1=109199&r2=109200&view=diff ============================================================================== --- lldb/trunk/lldb.xcodeproj/project.pbxproj (original) +++ lldb/trunk/lldb.xcodeproj/project.pbxproj Thu Jul 22 19:16:53 2010 @@ -2768,7 +2768,7 @@ "$(LLVM_BUILD_DIR)", ); LLVM_BUILD_DIR = "$(SRCROOT)/llvm"; - LLVM_CONFIGURATION = "Debug+Asserts"; + LLVM_CONFIGURATION = Release; OTHER_CFLAGS = ( "-DFOR_DYLD=0", "-DSUPPORT_REMOTE_UNWINDING", @@ -2821,7 +2821,7 @@ "$(LLVM_BUILD_DIR)", ); LLVM_BUILD_DIR = "$(SRCROOT)/llvm"; - LLVM_CONFIGURATION = "Debug+Asserts"; + LLVM_CONFIGURATION = Release; OTHER_CFLAGS = ( "-DFOR_DYLD=0", "-DSUPPORT_REMOTE_UNWINDING", @@ -2931,7 +2931,7 @@ "$(LLVM_BUILD_DIR)", ); LLVM_BUILD_DIR = "$(DERIVED_FILE_DIR)/llvm.build"; - LLVM_CONFIGURATION = "Debug+Asserts"; + LLVM_CONFIGURATION = Release; OTHER_CFLAGS = ( "-DFOR_DYLD=0", "-DSUPPORT_REMOTE_UNWINDING", From scallanan at apple.com Thu Jul 22 21:19:15 2010 From: scallanan at apple.com (Sean Callanan) Date: Fri, 23 Jul 2010 02:19:15 -0000 Subject: [Lldb-commits] [lldb] r109209 - in /lldb/trunk: include/lldb/Expression/ClangExpression.h include/lldb/Expression/RecordingMemoryManager.h source/Commands/CommandObjectExpression.cpp source/Expression/ClangExpression.cpp source/Expression/RecordingMemoryManager.cpp source/Plugins/Disassembler/llvm/DisassemblerLLVM.cpp Message-ID: <20100723021915.C27D82A6C12C@llvm.org> Author: spyffe Date: Thu Jul 22 21:19:15 2010 New Revision: 109209 URL: http://llvm.org/viewvc/llvm-project?rev=109209&view=rev Log: Added extensive logging of the code that is actually going to be executed by the inferior. This required explicit support from RecordingMemoryManager for finding the address range belonging to a particular function. Also fixed a bug in DisassemblerLLVM where the disassembler assumed there was an AddressRange available even when it was NULL. Modified: lldb/trunk/include/lldb/Expression/ClangExpression.h lldb/trunk/include/lldb/Expression/RecordingMemoryManager.h lldb/trunk/source/Commands/CommandObjectExpression.cpp lldb/trunk/source/Expression/ClangExpression.cpp lldb/trunk/source/Expression/RecordingMemoryManager.cpp lldb/trunk/source/Plugins/Disassembler/llvm/DisassemblerLLVM.cpp Modified: lldb/trunk/include/lldb/Expression/ClangExpression.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Expression/ClangExpression.h?rev=109209&r1=109208&r2=109209&view=diff ============================================================================== --- lldb/trunk/include/lldb/Expression/ClangExpression.h (original) +++ lldb/trunk/include/lldb/Expression/ClangExpression.h Thu Jul 22 21:19:15 2010 @@ -78,6 +78,9 @@ lldb::addr_t GetFunctionAddress (const char *name); + + Error + DisassembleFunction (Stream &stream, ExecutionContext &exc_context, const char *name); clang::CompilerInstance * GetCompilerInstance () Modified: lldb/trunk/include/lldb/Expression/RecordingMemoryManager.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Expression/RecordingMemoryManager.h?rev=109209&r1=109208&r2=109209&view=diff ============================================================================== --- lldb/trunk/include/lldb/Expression/RecordingMemoryManager.h (original) +++ lldb/trunk/include/lldb/Expression/RecordingMemoryManager.h Thu Jul 22 21:19:15 2010 @@ -113,6 +113,9 @@ lldb::addr_t GetRemoteAddressForLocal (lldb::addr_t local_address); + + std::pair + GetRemoteRangeForLocal (lldb::addr_t local_address); bool WriteJITRegions (const ExecutionContext &exc_context); Modified: lldb/trunk/source/Commands/CommandObjectExpression.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectExpression.cpp?rev=109209&r1=109208&r2=109209&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectExpression.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectExpression.cpp Thu Jul 22 21:19:15 2010 @@ -321,8 +321,21 @@ { log->Printf("Function address : 0x%llx", (uint64_t)function_address); log->Printf("Structure address : 0x%llx", (uint64_t)struct_address); - } + StreamString insns; + + Error err = clang_expr.DisassembleFunction(insns, m_exe_ctx, "___clang_expr"); + + if (!err.Success()) + { + log->Printf("Couldn't disassemble function : %s", err.AsCString("unknown error")); + } + else + { + log->Printf("Function disassembly:\n%s", insns.GetData()); + } + } + ClangFunction::ExecutionResults execution_result = ClangFunction::ExecuteFunction (m_exe_ctx, function_address, struct_address, true, true, 10000, error_stream); Modified: lldb/trunk/source/Expression/ClangExpression.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/ClangExpression.cpp?rev=109209&r1=109208&r2=109209&view=diff ============================================================================== --- lldb/trunk/source/Expression/ClangExpression.cpp (original) +++ lldb/trunk/source/Expression/ClangExpression.cpp Thu Jul 22 21:19:15 2010 @@ -56,6 +56,8 @@ // Project includes #include "lldb/Core/Log.h" #include "lldb/Core/ClangForward.h" +#include "lldb/Core/DataBufferHeap.h" +#include "lldb/Core/Disassembler.h" #include "lldb/Expression/ClangExpression.h" #include "lldb/Expression/ClangASTSource.h" #include "lldb/Expression/ClangResultSynthesizer.h" @@ -66,6 +68,7 @@ #include "lldb/Expression/RecordingMemoryManager.h" #include "lldb/Target/ExecutionContext.h" #include "lldb/Target/Process.h" +#include "lldb/Target/Target.h" #include "lldb/Core/StreamString.h" #include "lldb/Host/Mutex.h" @@ -613,6 +616,128 @@ return LLDB_INVALID_ADDRESS; } +Error +ClangExpression::DisassembleFunction (Stream &stream, ExecutionContext &exe_ctx, const char *name) +{ + Log *log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS); + + Error ret; + + ret.Clear(); + + lldb::addr_t func_local_addr = LLDB_INVALID_ADDRESS; + lldb::addr_t func_remote_addr = LLDB_INVALID_ADDRESS; + + std::vector::iterator pos, end = m_jitted_functions.end(); + + for (pos = m_jitted_functions.begin(); pos < end; pos++) + { + if (strcmp(pos->m_name.c_str(), name) == 0) + { + func_local_addr = pos->m_local_addr; + func_remote_addr = pos->m_remote_addr; + } + } + + if (func_local_addr == LLDB_INVALID_ADDRESS) + { + ret.SetErrorToGenericError(); + ret.SetErrorStringWithFormat("Couldn't find function %s for disassembly", name); + return ret; + } + + if(log) + log->Printf("Found function, has local address 0x%llx and remote address 0x%llx", (uint64_t)func_local_addr, (uint64_t)func_remote_addr); + + std::pair func_range; + + func_range = m_jit_mm_ptr->GetRemoteRangeForLocal(func_local_addr); + + if (func_range.first == 0 && func_range.second == 0) + { + ret.SetErrorToGenericError(); + ret.SetErrorStringWithFormat("Couldn't find code range for function %s", name); + return ret; + } + + if(log) + log->Printf("Function's code range is [0x%llx-0x%llx]", func_range.first, func_range.second); + + if (!exe_ctx.target) + { + ret.SetErrorToGenericError(); + ret.SetErrorString("Couldn't find the target"); + } + + lldb::DataBufferSP buffer_sp(new DataBufferHeap(func_range.second - func_range.first, 0)); + + Error err; + exe_ctx.process->ReadMemory(func_range.first, buffer_sp->GetBytes(), buffer_sp->GetByteSize(), err); + + if (!err.Success()) + { + ret.SetErrorToGenericError(); + ret.SetErrorStringWithFormat("Couldn't read from process: %s", err.AsCString("unknown error")); + return ret; + } + + ArchSpec arch(exe_ctx.target->GetArchitecture()); + + Disassembler *disassembler = Disassembler::FindPlugin(arch); + + if (disassembler == NULL) + { + ret.SetErrorToGenericError(); + ret.SetErrorStringWithFormat("Unable to find disassembler plug-in for %s architecture.", arch.AsCString()); + return ret; + } + + if (!exe_ctx.process) + { + ret.SetErrorToGenericError(); + ret.SetErrorString("Couldn't find the process"); + return ret; + } + + DataExtractor extractor(buffer_sp, + exe_ctx.process->GetByteOrder(), + 32); + + if(log) + { + log->Printf("Function data has contents:"); + extractor.PutToLog (log, + 0, + extractor.GetByteSize(), + func_range.first, + 16, + DataExtractor::TypeUInt8); + } + + disassembler->DecodeInstructions(extractor, 0, UINT32_MAX); + + Disassembler::InstructionList &instruction_list = disassembler->GetInstructionList(); + + uint32_t bytes_offset = 0; + + for (uint32_t instruction_index = 0, num_instructions = instruction_list.GetSize(); + instruction_index < num_instructions; + ++instruction_index) + { + Disassembler::Instruction *instruction = instruction_list.GetInstructionAtIndex(instruction_index); + instruction->Dump (&stream, + NULL, + &extractor, + bytes_offset, + exe_ctx, + true); + stream.PutChar('\n'); + bytes_offset += instruction->GetByteSize(); + } + + return ret; +} + unsigned ClangExpression::Compile() { Modified: lldb/trunk/source/Expression/RecordingMemoryManager.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/RecordingMemoryManager.cpp?rev=109209&r1=109208&r2=109209&view=diff ============================================================================== --- lldb/trunk/source/Expression/RecordingMemoryManager.cpp (original) +++ lldb/trunk/source/Expression/RecordingMemoryManager.cpp Thu Jul 22 21:19:15 2010 @@ -122,6 +122,25 @@ return LLDB_INVALID_ADDRESS; } +std::pair +RecordingMemoryManager::GetRemoteRangeForLocal (lldb::addr_t local_address) +{ + std::vector::iterator pos, end = m_address_map.end(); + + for (pos = m_address_map.begin(); pos < end; ++pos) + { + lldb::addr_t lstart = pos->m_local_start; + lldb::addr_t lend = lstart + pos->m_size; + + if (local_address >= lstart && local_address < lend) + { + return std::pair (pos->m_remote_start, pos->m_remote_start + pos->m_size); + } + } + + return std::pair (0, 0); +} + void RecordingMemoryManager::AddToLocalToRemoteMap (lldb::addr_t lstart, size_t size, lldb::addr_t rstart) { Modified: lldb/trunk/source/Plugins/Disassembler/llvm/DisassemblerLLVM.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Disassembler/llvm/DisassemblerLLVM.cpp?rev=109209&r1=109208&r2=109209&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Disassembler/llvm/DisassemblerLLVM.cpp (original) +++ lldb/trunk/source/Plugins/Disassembler/llvm/DisassemblerLLVM.cpp Thu Jul 22 21:19:15 2010 @@ -140,14 +140,18 @@ int currentOpIndex = -1; lldb_private::Process *process = exe_ctx.process; - addr_t base_addr = LLDB_INVALID_ADDRESS; - if (process && process->IsAlive()) - base_addr = inst_addr_ptr->GetLoadAddress (process); - if (base_addr == LLDB_INVALID_ADDRESS) - base_addr = inst_addr_ptr->GetFileAddress (); - - RegisterReaderArg rra(base_addr + EDInstByteSize(m_inst), m_disassembler); - + std::auto_ptr rra; + + if (!raw) + { + addr_t base_addr = LLDB_INVALID_ADDRESS; + if (process && process->IsAlive()) + base_addr = inst_addr_ptr->GetLoadAddress (process); + if (base_addr == LLDB_INVALID_ADDRESS) + base_addr = inst_addr_ptr->GetFileAddress (); + + rra.reset(new RegisterReaderArg(base_addr + EDInstByteSize(m_inst), m_disassembler)); + } bool printTokenized = false; @@ -228,7 +232,7 @@ { uint64_t operand_value; - if (!EDEvaluateOperand(&operand_value, operand, IPRegisterReader, &rra)) + if (!EDEvaluateOperand(&operand_value, operand, IPRegisterReader, rra.get())) { if (EDInstIsBranch(m_inst)) { From gclayton at apple.com Thu Jul 22 22:40:38 2010 From: gclayton at apple.com (Greg Clayton) Date: Fri, 23 Jul 2010 03:40:38 -0000 Subject: [Lldb-commits] [lldb] r109214 - /lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp Message-ID: <20100723034038.7BD292A6C12C@llvm.org> Author: gclayton Date: Thu Jul 22 22:40:38 2010 New Revision: 109214 URL: http://llvm.org/viewvc/llvm-project?rev=109214&view=rev Log: Added Mach exception stop descriptions. The chunk of code I just added needs to be placed into a utility location so it can be used by ProcessMacOSX and debugserver. Modified: lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp 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=109214&r1=109213&r2=109214&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp (original) +++ lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp Thu Jul 22 22:40:38 2010 @@ -47,15 +47,6 @@ #include "ThreadGDBRemote.h" #include "MacOSXLibunwindCallbacks.h" -#if defined (__i386__) || defined (__x86_64__) -#define MACH_EXC_DATA0_SOFTWARE_BREAKPOINT EXC_I386_BPT -#define MACH_EXC_DATA0_TRACE EXC_I386_SGL -#elif defined (__powerpc__) || defined (__ppc__) || defined (__ppc64__) -#define MACH_EXC_DATA0_SOFTWARE_BREAKPOINT EXC_PPC_BREAKPOINT -#elif defined (__arm__) -#define MACH_EXC_DATA0_SOFTWARE_BREAKPOINT EXC_ARM_BREAKPOINT -#endif - #define DEBUGSERVER_BASENAME "debugserver" using namespace lldb; @@ -1020,49 +1011,236 @@ gdb_thread->SetStopInfoStopID (GetStopID()); if (exc_type != 0) { - if (exc_type == EXC_SOFTWARE && exc_data.size() == 2 && exc_data[0] == EXC_SOFT_SIGNAL) - { - stop_info.SetStopReasonWithSignal(exc_data[1]); - } -#if defined (MACH_EXC_DATA0_SOFTWARE_BREAKPOINT) - else if (exc_type == EXC_BREAKPOINT && exc_data[0] == MACH_EXC_DATA0_SOFTWARE_BREAKPOINT) - { - addr_t pc = gdb_thread->GetRegisterContext()->GetPC(); - lldb::BreakpointSiteSP bp_site_sp = GetBreakpointSiteList().FindByAddress(pc); - if (!bp_site_sp) + bool exc_translated = false; + const char *exc_desc = NULL; + const char *code_label = "code"; + const char *code_desc = NULL; + const char *subcode_label = "subcode"; + const char *subcode_desc = NULL; + switch (exc_type) + { + case 1: // EXC_BAD_ACCESS + exc_desc = "EXC_BAD_ACCESS"; + subcode_label = "address"; + switch (GetArchSpec().GetGenericCPUType()) + { + case ArchSpec::eCPU_arm: + switch (exc_data[0]) + { + case 0x101: code_desc = "EXC_ARM_DA_ALIGN"; break; + case 0x102: code_desc = "EXC_ARM_DA_DEBUG"; break; + } + break; + + case ArchSpec::eCPU_ppc: + case ArchSpec::eCPU_ppc64: + switch (exc_data[0]) + { + case 0x101: code_desc = "EXC_PPC_VM_PROT_READ"; break; + case 0x102: code_desc = "EXC_PPC_BADSPACE"; break; + case 0x103: code_desc = "EXC_PPC_UNALIGNED"; break; + } + break; + + default: + break; + } + break; + + case 2: // EXC_BAD_INSTRUCTION + exc_desc = "EXC_BAD_INSTRUCTION"; + switch (GetArchSpec().GetGenericCPUType()) { - //log->Printf("got EXC_BREAKPOINT at 0x%llx but didn't find a breakpoint site.\n", pc); - stop_info.SetStopReasonWithException(exc_type, exc_data.size()); - for (uint32_t i=0; iValidForThisThread (thread_sp.get())) + case ArchSpec::eCPU_i386: + case ArchSpec::eCPU_x86_64: + switch (exc_data[0]) { - stop_info.Clear (); - stop_info.SetStopReasonWithBreakpointSiteID (bp_site_sp->GetID()); + case 1: code_desc = "EXC_I386_DIV"; break; + case 2: code_desc = "EXC_I386_INTO"; break; + case 3: code_desc = "EXC_I386_NOEXT"; break; + case 4: code_desc = "EXC_I386_EXTOVR"; break; + case 5: code_desc = "EXC_I386_EXTERR"; break; + case 6: code_desc = "EXC_I386_EMERR"; break; + case 7: code_desc = "EXC_I386_BOUND"; break; + case 8: code_desc = "EXC_I386_SSEEXTERR"; break; } - else + break; + + case ArchSpec::eCPU_ppc: + case ArchSpec::eCPU_ppc64: + switch (exc_data[0]) { - stop_info.Clear (); - stop_info.SetStopReasonToNone(); + case 1: code_desc = "EXC_PPC_OVERFLOW"; break; + case 2: code_desc = "EXC_PPC_ZERO_DIVIDE"; break; + case 3: code_desc = "EXC_PPC_FLT_INEXACT"; break; + case 4: code_desc = "EXC_PPC_FLT_ZERO_DIVIDE"; break; + case 5: code_desc = "EXC_PPC_FLT_UNDERFLOW"; break; + case 6: code_desc = "EXC_PPC_FLT_OVERFLOW"; break; + case 7: code_desc = "EXC_PPC_FLT_NOT_A_NUMBER"; break; } + break; + default: + break; } + break; + + case 4: // EXC_EMULATION + exc_desc = "EXC_EMULATION"; + break; + + + case 5: // EXC_SOFTWARE + exc_desc = "EXC_SOFTWARE"; + if (exc_data[0] == EXC_SOFT_SIGNAL && exc_data.size() == 2) + { + stop_info.SetStopReasonWithSignal(exc_data[1]); + exc_translated = true; + } + break; + + case 6: + { + exc_desc = "EXC_SOFTWARE"; + bool is_software_breakpoint = false; + switch (GetArchSpec().GetGenericCPUType()) + { + case ArchSpec::eCPU_i386: + case ArchSpec::eCPU_x86_64: + if (exc_data[0] == 1) // EXC_I386_SGL + { + exc_translated = true; + stop_info.SetStopReasonToTrace (); + } + else if (exc_data[0] == 2) // EXC_I386_BPT + { + is_software_breakpoint = true; + } + break; + + case ArchSpec::eCPU_ppc: + case ArchSpec::eCPU_ppc64: + is_software_breakpoint = exc_data[0] == 1; // EXC_PPC_BREAKPOINT + break; + + case ArchSpec::eCPU_arm: + is_software_breakpoint = exc_data[0] == 1; // EXC_ARM_BREAKPOINT + break; + + default: + break; + } + + if (is_software_breakpoint) + { + addr_t pc = gdb_thread->GetRegisterContext()->GetPC(); + lldb::BreakpointSiteSP bp_site_sp = GetBreakpointSiteList().FindByAddress(pc); + if (bp_site_sp) + { + exc_translated = true; + if (bp_site_sp->ValidForThisThread (thread_sp.get())) + { + stop_info.Clear (); + stop_info.SetStopReasonWithBreakpointSiteID (bp_site_sp->GetID()); + } + else + { + stop_info.Clear (); + stop_info.SetStopReasonToNone(); + } + + } + } + } + break; + + case 7: + exc_desc = "EXC_SYSCALL"; + break; + + case 8: + exc_desc = "EXC_MACH_SYSCALL"; + break; + + case 9: + exc_desc = "EXC_RPC_ALERT"; + break; + + case 10: + exc_desc = "EXC_CRASH"; + break; } -#endif -#if defined (MACH_EXC_DATA0_TRACE) - else if (exc_type == EXC_BREAKPOINT && exc_data[0] == MACH_EXC_DATA0_TRACE) - { - stop_info.SetStopReasonToTrace (); - } -#endif - else + + if (!exc_translated) { stop_info.SetStopReasonWithException(exc_type, exc_data.size()); for (uint32_t i=0; i= 1) + { + if (code_desc) + desc_strm.Printf(" (%s=%s", code_label, code_desc); + else + desc_strm.Printf(" (%s=%llu", code_label, exc_data[0]); + } + + if (exc_data.size() >= 2) + { + if (subcode_desc) + desc_strm.Printf(", %s=%s", subcode_label, subcode_desc); + else + desc_strm.Printf(", %s=0x%llx", subcode_label, exc_data[1]); + } + + if (exc_data.empty() == false) + desc_strm.PutChar(')'); + + stop_info.SetStopDescription(desc_strm.GetString().c_str()); } } else if (signo) From wilsons at start.ca Thu Jul 22 23:26:10 2010 From: wilsons at start.ca (Stephen Wilson) Date: Fri, 23 Jul 2010 00:26:10 -0400 Subject: [Lldb-commits] [PATCH] Thread deadlock and termination. Message-ID: An embedded and charset-unspecified text was scrubbed... Name: communication.patch Url: http://lists.cs.uiuc.edu/pipermail/lldb-commits/attachments/20100723/84ead8a6/attachment.pl -------------- next part -------------- An embedded and charset-unspecified text was scrubbed... Name: host.patch Url: http://lists.cs.uiuc.edu/pipermail/lldb-commits/attachments/20100723/84ead8a6/attachment-0001.pl From gclayton at apple.com Fri Jul 23 10:37:46 2010 From: gclayton at apple.com (Greg Clayton) Date: Fri, 23 Jul 2010 15:37:46 -0000 Subject: [Lldb-commits] [lldb] r109226 - in /lldb/trunk: include/lldb/Host/ include/lldb/Interpreter/ source/Core/ source/Host/macosx/cfcpp/ source/Plugins/Process/MacOSX-User/source/ source/Plugins/Process/MacOSX-User/source/MacOSX/ source/Plugins/Process/Utility/libunwind/src/ source/Symbol/ source/Target/ Message-ID: <20100723153746.EE0E62A6C12C@llvm.org> Author: gclayton Date: Fri Jul 23 10:37:46 2010 New Revision: 109226 URL: http://llvm.org/viewvc/llvm-project?rev=109226&view=rev Log: Warnings cleanup patch from Jean-Daniel Dupas. Modified: lldb/trunk/include/lldb/Host/Predicate.h lldb/trunk/include/lldb/Interpreter/CommandObjectRegexCommand.h lldb/trunk/source/Core/ConnectionFileDescriptor.cpp lldb/trunk/source/Host/macosx/cfcpp/CFCMutableSet.cpp lldb/trunk/source/Plugins/Process/MacOSX-User/source/MacOSX/MachTask.cpp lldb/trunk/source/Plugins/Process/MacOSX-User/source/ProcessMacOSX.cpp lldb/trunk/source/Plugins/Process/Utility/libunwind/src/AssemblyParser.hpp lldb/trunk/source/Plugins/Process/Utility/libunwind/src/DwarfParser.hpp lldb/trunk/source/Plugins/Process/Utility/libunwind/src/RemoteProcInfo.hpp lldb/trunk/source/Plugins/Process/Utility/libunwind/src/RemoteRegisterMap.hpp lldb/trunk/source/Plugins/Process/Utility/libunwind/src/UnwindCursor.hpp lldb/trunk/source/Symbol/ClangASTContext.cpp lldb/trunk/source/Symbol/Type.cpp lldb/trunk/source/Target/Thread.cpp Modified: lldb/trunk/include/lldb/Host/Predicate.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Host/Predicate.h?rev=109226&r1=109225&r2=109226&view=diff ============================================================================== --- lldb/trunk/include/lldb/Host/Predicate.h (original) +++ lldb/trunk/include/lldb/Host/Predicate.h Fri Jul 23 10:37:46 2010 @@ -262,7 +262,7 @@ #ifdef DB_PTHREAD_LOG_EVENTS printf("%s (bits = 0x%8.8x, abstime = %p), m_value = 0x%8.8x", __FUNCTION__, bits, abstime, m_value); #endif - while (err == 0 && (m_value & bits != 0)) + while (err == 0 && ((m_value & bits) != 0)) { err = m_condition.Wait (m_mutex.GetMutex(), abstime); } Modified: lldb/trunk/include/lldb/Interpreter/CommandObjectRegexCommand.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Interpreter/CommandObjectRegexCommand.h?rev=109226&r1=109225&r2=109226&view=diff ============================================================================== --- lldb/trunk/include/lldb/Interpreter/CommandObjectRegexCommand.h (original) +++ lldb/trunk/include/lldb/Interpreter/CommandObjectRegexCommand.h Fri Jul 23 10:37:46 2010 @@ -52,7 +52,7 @@ AddRegexCommand (const char *re_cstr, const char *command_cstr); protected: - typedef struct Entry + struct Entry { RegularExpression regex; std::string command; Modified: lldb/trunk/source/Core/ConnectionFileDescriptor.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/ConnectionFileDescriptor.cpp?rev=109226&r1=109225&r2=109226&view=diff ============================================================================== --- lldb/trunk/source/Core/ConnectionFileDescriptor.cpp (original) +++ lldb/trunk/source/Core/ConnectionFileDescriptor.cpp Fri Jul 23 10:37:46 2010 @@ -406,7 +406,7 @@ "%p ConnectionFileDescriptor::SocketListen (port = %i)", this, listen_port_num); - Close (m_fd, false); + Close (m_fd, NULL); m_is_socket = true; int listen_port = ::socket (AF_INET, SOCK_STREAM, IPPROTO_TCP); if (listen_port == -1) @@ -470,7 +470,7 @@ lldb_private::LogIfAnyCategoriesSet (LIBLLDB_LOG_CONNECTION, "%p ConnectionFileDescriptor::SocketConnect (host/port = %s)", this, host_and_port); - Close (m_fd, false); + Close (m_fd, NULL); m_is_socket = true; RegularExpression regex ("([^:]+):([0-9]+)"); @@ -534,7 +534,7 @@ else error_ptr->SetErrorStringWithFormat("Invalid host string: '%s'.\n", host_str.c_str()); } - Close (m_fd, false); + Close (m_fd, NULL); return eConnectionStatusError; } } @@ -543,7 +543,7 @@ { if (error_ptr) error_ptr->SetErrorToErrno(); - Close (m_fd, false); + Close (m_fd, NULL); return eConnectionStatusError; } Modified: lldb/trunk/source/Host/macosx/cfcpp/CFCMutableSet.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/macosx/cfcpp/CFCMutableSet.cpp?rev=109226&r1=109225&r2=109226&view=diff ============================================================================== --- lldb/trunk/source/Host/macosx/cfcpp/CFCMutableSet.cpp (original) +++ lldb/trunk/source/Host/macosx/cfcpp/CFCMutableSet.cpp Fri Jul 23 10:37:46 2010 @@ -84,7 +84,7 @@ if (set == NULL) { if (can_create == false) - return false; + return NULL; set = ::CFSetCreateMutable(kCFAllocatorDefault, 0, &kCFTypeSetCallBacks); reset ( set ); } Modified: lldb/trunk/source/Plugins/Process/MacOSX-User/source/MacOSX/MachTask.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/MacOSX-User/source/MacOSX/MachTask.cpp?rev=109226&r1=109225&r2=109226&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Process/MacOSX-User/source/MacOSX/MachTask.cpp (original) +++ lldb/trunk/source/Plugins/Process/MacOSX-User/source/MacOSX/MachTask.cpp Fri Jul 23 10:37:46 2010 @@ -39,9 +39,9 @@ m_process (process), m_task (TASK_NULL), m_vm_memory (), + m_exc_port_info(), m_exception_thread (0), - m_exception_port (MACH_PORT_NULL), - m_exc_port_info() + m_exception_port (MACH_PORT_NULL) { memset(&m_exc_port_info, 0, sizeof(m_exc_port_info)); Modified: lldb/trunk/source/Plugins/Process/MacOSX-User/source/ProcessMacOSX.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/MacOSX-User/source/ProcessMacOSX.cpp?rev=109226&r1=109225&r2=109226&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Process/MacOSX-User/source/ProcessMacOSX.cpp (original) +++ lldb/trunk/source/Plugins/Process/MacOSX-User/source/ProcessMacOSX.cpp Fri Jul 23 10:37:46 2010 @@ -219,9 +219,6 @@ //---------------------------------------------------------------------- ProcessMacOSX::ProcessMacOSX(Target& target, Listener &listener) : Process (target, listener), - m_dynamic_loader_ap (), -// m_wait_thread (LLDB_INVALID_HOST_THREAD), - m_byte_order (eByteOrderHost), m_stdio_ours (false), m_child_stdin (-1), m_child_stdout (-1), @@ -233,7 +230,10 @@ m_stdout_data (), m_exception_messages (), m_exception_messages_mutex (Mutex::eMutexTypeRecursive), - m_arch_spec () + m_arch_spec (), + m_dynamic_loader_ap (), +// m_wait_thread (LLDB_INVALID_HOST_THREAD), + m_byte_order (eByteOrderHost) { } Modified: lldb/trunk/source/Plugins/Process/Utility/libunwind/src/AssemblyParser.hpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Utility/libunwind/src/AssemblyParser.hpp?rev=109226&r1=109225&r2=109226&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Process/Utility/libunwind/src/AssemblyParser.hpp (original) +++ lldb/trunk/source/Plugins/Process/Utility/libunwind/src/AssemblyParser.hpp Fri Jul 23 10:37:46 2010 @@ -46,7 +46,7 @@ public: enum { kMaxInstructionByteSize = 32 }; - AssemblyParse_x86 (RemoteProcInfo& procinfo, unw_accessors_t *acc, unw_addr_space_t as, void *arg) : fArg(arg), fAccessors(acc), fAs(as), fRemoteProcInfo(procinfo) { + AssemblyParse_x86 (RemoteProcInfo& procinfo, unw_accessors_t *acc, unw_addr_space_t as, void *arg) : fArg(arg), fRemoteProcInfo(procinfo), fAccessors(acc), fAs(as) { fRegisterMap = fRemoteProcInfo.getRegisterMap(); if (fRemoteProcInfo.getTargetArch() == UNW_TARGET_X86_64) { fStackPointerRegnum = UNW_X86_64_RSP; Modified: lldb/trunk/source/Plugins/Process/Utility/libunwind/src/DwarfParser.hpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Utility/libunwind/src/DwarfParser.hpp?rev=109226&r1=109225&r2=109226&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Process/Utility/libunwind/src/DwarfParser.hpp (original) +++ lldb/trunk/source/Plugins/Process/Utility/libunwind/src/DwarfParser.hpp Fri Jul 23 10:37:46 2010 @@ -390,7 +390,7 @@ cieContentEnd = p + cieLength; } if ( cieLength == 0 ) - return false; + return NULL; // CIE ID is always 0 if ( addressSpace.get32(p) != 0 ) return "CIE ID is not zero"; Modified: lldb/trunk/source/Plugins/Process/Utility/libunwind/src/RemoteProcInfo.hpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Utility/libunwind/src/RemoteProcInfo.hpp?rev=109226&r1=109225&r2=109226&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Process/Utility/libunwind/src/RemoteProcInfo.hpp (original) +++ lldb/trunk/source/Plugins/Process/Utility/libunwind/src/RemoteProcInfo.hpp Fri Jul 23 10:37:46 2010 @@ -77,7 +77,7 @@ RemoteMemoryBlob (uint8_t *buf, free_callback_with_arg to_free, uint64_t startaddr, uint64_t len, uint64_t mh, void *arg) : - fBuf(buf), fToFreeWithArg(to_free), fToFree(NULL), + fBuf(buf), fToFree(NULL), fToFreeWithArg(to_free), fStartAddr(startaddr), fLen(len), fMachHeader(mh), fArg(arg) { } RemoteMemoryBlob (uint8_t *buf, free_callback to_free, uint64_t startaddr, @@ -88,9 +88,9 @@ // the following is to create a dummy RMB object for lower_bound's use in // searching. - RemoteMemoryBlob (uint64_t startaddr) : fStartAddr(startaddr), fToFree(NULL), - fBuf(NULL), fToFreeWithArg(NULL), fArg(NULL), fMachHeader(-1), - fLen(0) { } + RemoteMemoryBlob (uint64_t startaddr) : fBuf(NULL), fToFree(NULL), + fToFreeWithArg(NULL), fStartAddr(startaddr), fLen(0), + fMachHeader(-1), fArg(NULL) { } ~RemoteMemoryBlob () { if (fToFreeWithArg) fToFreeWithArg(fBuf, fArg); @@ -417,7 +417,7 @@ img = &i->second; } else - return false; + return NULL; std::map::iterator j; j = img->profiles.lower_bound (pc); if (j == img->profiles.begin() && j == img->profiles.end()) Modified: lldb/trunk/source/Plugins/Process/Utility/libunwind/src/RemoteRegisterMap.hpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Utility/libunwind/src/RemoteRegisterMap.hpp?rev=109226&r1=109225&r2=109226&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Process/Utility/libunwind/src/RemoteRegisterMap.hpp (original) +++ lldb/trunk/source/Plugins/Process/Utility/libunwind/src/RemoteRegisterMap.hpp Fri Jul 23 10:37:46 2010 @@ -65,8 +65,8 @@ int machine_regno; // What the actual bits/bytes are in instructions char *name; unw_regtype_t type; - reg () : unwind_regno(-1), machine_regno(-1), caller_regno(-1), - eh_frame_regno(-1), name(NULL), type(UNW_NOT_A_REG) { } + reg () : unwind_regno(-1), caller_regno(-1), eh_frame_regno(-1), + machine_regno(-1), name(NULL), type(UNW_NOT_A_REG) { } }; unw_accessors_t fAccessors; Modified: lldb/trunk/source/Plugins/Process/Utility/libunwind/src/UnwindCursor.hpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Utility/libunwind/src/UnwindCursor.hpp?rev=109226&r1=109225&r2=109226&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Process/Utility/libunwind/src/UnwindCursor.hpp (original) +++ lldb/trunk/source/Plugins/Process/Utility/libunwind/src/UnwindCursor.hpp Fri Jul 23 10:37:46 2010 @@ -933,7 +933,7 @@ template RemoteUnwindCursor::RemoteUnwindCursor(A& as, unw_context_t* regs, void* arg) - : UnwindCursor::UnwindCursor(regs, as), fIsFirstFrame (false), fIsLeafFrame(false), fArg(arg) + : UnwindCursor::UnwindCursor(regs, as), fIsLeafFrame(false), fIsFirstFrame (false), fArg(arg) { COMPILE_TIME_ASSERT( sizeof(RemoteUnwindCursor) < sizeof(unw_cursor_t) ); } Modified: lldb/trunk/source/Symbol/ClangASTContext.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/ClangASTContext.cpp?rev=109226&r1=109225&r2=109226&view=diff ============================================================================== --- lldb/trunk/source/Symbol/ClangASTContext.cpp (original) +++ lldb/trunk/source/Symbol/ClangASTContext.cpp Fri Jul 23 10:37:46 2010 @@ -1428,7 +1428,7 @@ break; } } - return false; + return NULL; } static inline bool Modified: lldb/trunk/source/Symbol/Type.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/Type.cpp?rev=109226&r1=109225&r2=109226&view=diff ============================================================================== --- lldb/trunk/source/Symbol/Type.cpp (original) +++ lldb/trunk/source/Symbol/Type.cpp Fri Jul 23 10:37:46 2010 @@ -599,7 +599,7 @@ ) { if (!ResolveClangType()) - return false; + return NULL; std::string name_str; void *child_qual_type = GetClangASTContext().GetChildClangTypeAtIndex ( Modified: lldb/trunk/source/Target/Thread.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/Thread.cpp?rev=109226&r1=109225&r2=109226&view=diff ============================================================================== --- lldb/trunk/source/Target/Thread.cpp (original) +++ lldb/trunk/source/Target/Thread.cpp Fri Jul 23 10:37:46 2010 @@ -938,7 +938,7 @@ { thread_plan_sp.reset(new ThreadPlanStepThrough (*this, stop_other_threads)); if (thread_plan_sp && !thread_plan_sp->ValidatePlan (NULL)) - return false; + return NULL; } QueueThreadPlan (thread_plan_sp, abort_other_plans); return thread_plan_sp.get(); From gclayton at apple.com Fri Jul 23 10:43:25 2010 From: gclayton at apple.com (Greg Clayton) Date: Fri, 23 Jul 2010 15:43:25 -0000 Subject: [Lldb-commits] [lldb] r109227 - /lldb/trunk/source/Core/Communication.cpp Message-ID: <20100723154325.AEC982A6C12C@llvm.org> Author: gclayton Date: Fri Jul 23 10:43:25 2010 New Revision: 109227 URL: http://llvm.org/viewvc/llvm-project?rev=109227&view=rev Log: Remove a premature invalidation of a threads pthread_t handle, thus avoiding a segfault when calling pthread_cancel. Also, sets m_read_thread_enabled if the thread is actually spawned. Patch from Stephen Wilson. Modified: lldb/trunk/source/Core/Communication.cpp Modified: lldb/trunk/source/Core/Communication.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/Communication.cpp?rev=109227&r1=109226&r2=109227&view=diff ============================================================================== --- lldb/trunk/source/Core/Communication.cpp (original) +++ lldb/trunk/source/Core/Communication.cpp Fri Jul 23 10:43:25 2010 @@ -211,9 +211,9 @@ char thread_name[1024]; snprintf(thread_name, sizeof(thread_name), "", m_broadcaster_name.AsCString()); - m_read_thread_enabled = true; m_read_thread = Host::ThreadCreate (thread_name, Communication::ReadThread, this, error_ptr); - return m_read_thread != LLDB_INVALID_HOST_THREAD; + m_read_thread_enabled = m_read_thread != LLDB_INVALID_HOST_THREAD; + return m_read_thread_enabled; } bool @@ -232,6 +232,7 @@ Host::ThreadCancel (m_read_thread, error_ptr); return Host::ThreadJoin (m_read_thread, NULL, error_ptr); + m_read_thread = LLDB_INVALID_HOST_THREAD; } @@ -339,7 +340,6 @@ log->Printf ("%p Communication::ReadThread () thread exiting...", p); // Let clients know that this thread is exiting - comm->m_read_thread = LLDB_INVALID_HOST_THREAD; comm->BroadcastEvent (eBroadcastBitReadThreadDidExit); return NULL; } From gclayton at apple.com Fri Jul 23 10:47:19 2010 From: gclayton at apple.com (Greg Clayton) Date: Fri, 23 Jul 2010 15:47:19 -0000 Subject: [Lldb-commits] [lldb] r109228 - /lldb/trunk/source/Host/linux/Host.cpp Message-ID: <20100723154719.B3B212A6C12C@llvm.org> Author: gclayton Date: Fri Jul 23 10:47:19 2010 New Revision: 109228 URL: http://llvm.org/viewvc/llvm-project?rev=109228&view=rev Log: Remove a deadlock condition. A bit of explanation is needed: When calling ThreadCancel in Host::WillTerminate g_monitor_thread may be blocked on a call to pthread_cond_wait (for example, line 640). Now, by default, when a cancellation request is serviced g_monitor_thread will again own the mutex guarding the condition variable it was waiting on. This causes the call to SetValue in Host::WillTerminate to hit a deadlock. The call to SetValue does not appear to be needed, so removing it solves the issue. Patch from Stephen Wilson. Modified: lldb/trunk/source/Host/linux/Host.cpp Modified: lldb/trunk/source/Host/linux/Host.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/linux/Host.cpp?rev=109228&r1=109227&r2=109228&view=diff ============================================================================== --- lldb/trunk/source/Host/linux/Host.cpp (original) +++ lldb/trunk/source/Host/linux/Host.cpp Fri Jul 23 10:47:19 2010 @@ -742,7 +742,6 @@ if (g_monitor_thread != NULL) { ThreadCancel (g_monitor_thread, NULL); - GetChildProcessPredicate ().SetValue (true, eBroadcastAlways); ThreadJoin(g_monitor_thread, NULL, NULL); g_monitor_thread = NULL; } From gclayton at apple.com Fri Jul 23 10:55:12 2010 From: gclayton at apple.com (Greg Clayton) Date: Fri, 23 Jul 2010 08:55:12 -0700 Subject: [Lldb-commits] [PATCH] Thread deadlock and termination. In-Reply-To: References: Message-ID: On Jul 22, 2010, at 9:26 PM, Stephen Wilson wrote: > > The attached communication.patch removes a premature invalidation of a > threads pthread_t handle, thus avoiding a segfault when calling > pthread_cancel. Also, sets m_read_thread_enabled iff the thread is > actually spawned. Committed r109227. > In host.patch a deadlock condition is removed. A bit of explanation is > needed: When calling ThreadCancel in Host::WillTerminate > g_monitor_thread may be blocked on a call to pthread_cond_wait (for > example, line 640). Now, by default, when a cancellation request is > serviced g_monitor_thread will again own the mutex guarding the > condition variable it was waiting on. This causes the call to SetValue > in Host::WillTerminate to hit a deadlock. > > The call to SetValue does not appear to be needed, so removing it solves > the issue. Committed r109228. > Note that the above is in the linux side of the code. I see similar > code in source/Host/macosx/Host.mm but am not sure if it is an issue > there as well. We are about to remove the global waitpid thread and have anyone that is interested in child process reaping through a modified Host layer where you give it a callback. The host layer will then spawn a new thread just for that process. The main reason for this change is the waitpid code is happening in a shared library (lldb.so on linux, LLDB.framework on Mac OS X) and is currently being done from a single thread that watches for all child processes (waitpid with -1 as the pid) which we really shouldn't be doing since the program that is using LLDB, say an IDE, might be interested in monitoring its own child processes and we shouldn't be reaping those for them. So though the issue may exist in the host layer right now, we will be fixing this today in a different way that shouldn't cause the Host API to change, so everything should just work. Greg Clayton From gclayton at apple.com Fri Jul 23 11:45:51 2010 From: gclayton at apple.com (Greg Clayton) Date: Fri, 23 Jul 2010 16:45:51 -0000 Subject: [Lldb-commits] [lldb] r109235 - in /lldb/trunk: include/lldb/Target/Thread.h source/Plugins/Process/MacOSX-User/source/MacOSX/MachException.cpp source/Plugins/Process/MacOSX-User/source/MacOSX/MachException.h source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp source/Target/Thread.cpp Message-ID: <20100723164552.1025D2A6C12C@llvm.org> Author: gclayton Date: Fri Jul 23 11:45:51 2010 New Revision: 109235 URL: http://llvm.org/viewvc/llvm-project?rev=109235&view=rev Log: Centralized the Mach exception stop info code by adding it as a first class citizen on the StopInfo class. Modified: lldb/trunk/include/lldb/Target/Thread.h lldb/trunk/source/Plugins/Process/MacOSX-User/source/MacOSX/MachException.cpp lldb/trunk/source/Plugins/Process/MacOSX-User/source/MacOSX/MachException.h lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp lldb/trunk/source/Target/Thread.cpp Modified: lldb/trunk/include/lldb/Target/Thread.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/Thread.h?rev=109235&r1=109234&r2=109235&view=diff ============================================================================== --- lldb/trunk/include/lldb/Target/Thread.h (original) +++ lldb/trunk/include/lldb/Target/Thread.h Fri Jul 23 11:45:51 2010 @@ -68,7 +68,7 @@ SetStopReasonToTrace (); void - SetStopReasonWithException (uint32_t exc_type, size_t exc_data_count); + SetStopReasonWithGenericException (uint32_t exc_type, size_t exc_data_count); void SetStopReasonWithPlan (lldb::ThreadPlanSP &plan); @@ -81,6 +81,11 @@ void SetStopDescription(const char *desc); + + void + SetStopReasonWithMachException (uint32_t exc_type, + size_t exc_data_count, + const lldb::addr_t *exc_data); lldb::user_id_t GetBreakpointSiteID() const; Modified: lldb/trunk/source/Plugins/Process/MacOSX-User/source/MacOSX/MachException.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/MacOSX-User/source/MacOSX/MachException.cpp?rev=109235&r1=109234&r2=109235&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Process/MacOSX-User/source/MacOSX/MachException.cpp (original) +++ lldb/trunk/source/Plugins/Process/MacOSX-User/source/MacOSX/MachException.cpp Fri Jul 23 11:45:51 2010 @@ -209,42 +209,9 @@ return true; // We always stop with a mach exceptions const size_t exc_data_count = exc_data.size(); - stop_info->SetStopReasonWithException(exc_type, exc_data_count); - - // Fill in a text description - const char * exc_name = MachException::Name(exc_type); - StreamString sstr; - if (exc_name) - sstr.PutCString(exc_name); - else - sstr.Printf ("%i", exc_type); - - int signal = SoftSignal(); - if (signal > 0) - { - const char *sig_str = Host::GetSignalAsCString(signal); - if (sig_str) - sstr.Printf (" EXC_SOFT_SIGNAL(%s)", sig_str); - else - sstr.Printf (" EXC_SOFT_SIGNAL(%i)", signal); - } - else - { - // No special disassembly for exception data, just - sstr.Printf (" data[%zu] = {", exc_data_count); - - for (size_t idx = 0; idx < exc_data_count; ++idx) - sstr.Printf (MACH_EXCEPTION_DATA_FMT_MINHEX "%s", exc_data[idx], ((idx + 1 == exc_data_count) ? "" : ",")); - - sstr.PutChar('}'); - } - - stop_info->SetStopDescription (sstr.GetData()); - - // Copy the exception data - size_t i; - for (i=0; iSetExceptionDataAtIndex(i, exc_data[i]); + stop_info->SetStopReasonWithMachException (exc_type, + exc_data_count, + exc_data_count ? &exc_data[0] : NULL); return true; } Modified: lldb/trunk/source/Plugins/Process/MacOSX-User/source/MacOSX/MachException.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/MacOSX-User/source/MacOSX/MachException.h?rev=109235&r1=109234&r2=109235&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Process/MacOSX-User/source/MacOSX/MachException.h (original) +++ lldb/trunk/source/Plugins/Process/MacOSX-User/source/MacOSX/MachException.h Fri Jul 23 11:45:51 2010 @@ -63,7 +63,7 @@ task_t task_port; lldb::tid_t thread_port; exception_type_t exc_type; - std::vector exc_data; + std::vector exc_data; Data() : task_port(TASK_NULL), thread_port(THREAD_NULL), @@ -125,7 +125,7 @@ typedef std::vector collection; typedef collection::iterator iterator; - typedef collection::const_iterator const_iterator; + typedef collection::const_iterator const_iterator; }; enum 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=109235&r1=109234&r2=109235&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp (original) +++ lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp Fri Jul 23 11:45:51 2010 @@ -964,7 +964,7 @@ std::string value; std::string thread_name; uint32_t exc_type = 0; - std::vector exc_data; + std::vector exc_data; uint32_t tid = LLDB_INVALID_THREAD_ID; addr_t thread_dispatch_qaddr = LLDB_INVALID_ADDRESS; uint32_t exc_data_count = 0; @@ -1011,245 +1011,17 @@ gdb_thread->SetStopInfoStopID (GetStopID()); if (exc_type != 0) { - bool exc_translated = false; - const char *exc_desc = NULL; - const char *code_label = "code"; - const char *code_desc = NULL; - const char *subcode_label = "subcode"; - const char *subcode_desc = NULL; - switch (exc_type) - { - case 1: // EXC_BAD_ACCESS - exc_desc = "EXC_BAD_ACCESS"; - subcode_label = "address"; - switch (GetArchSpec().GetGenericCPUType()) - { - case ArchSpec::eCPU_arm: - switch (exc_data[0]) - { - case 0x101: code_desc = "EXC_ARM_DA_ALIGN"; break; - case 0x102: code_desc = "EXC_ARM_DA_DEBUG"; break; - } - break; - - case ArchSpec::eCPU_ppc: - case ArchSpec::eCPU_ppc64: - switch (exc_data[0]) - { - case 0x101: code_desc = "EXC_PPC_VM_PROT_READ"; break; - case 0x102: code_desc = "EXC_PPC_BADSPACE"; break; - case 0x103: code_desc = "EXC_PPC_UNALIGNED"; break; - } - break; - - default: - break; - } - break; - - case 2: // EXC_BAD_INSTRUCTION - exc_desc = "EXC_BAD_INSTRUCTION"; - switch (GetArchSpec().GetGenericCPUType()) - { - case ArchSpec::eCPU_i386: - case ArchSpec::eCPU_x86_64: - if (exc_data[0] == 1) - code_desc = "EXC_I386_INVOP"; - break; - - case ArchSpec::eCPU_ppc: - case ArchSpec::eCPU_ppc64: - switch (exc_data[0]) - { - case 1: code_desc = "EXC_PPC_INVALID_SYSCALL"; break; - case 2: code_desc = "EXC_PPC_UNIPL_INST"; break; - case 3: code_desc = "EXC_PPC_PRIVINST"; break; - case 4: code_desc = "EXC_PPC_PRIVREG"; break; - case 5: // EXC_PPC_TRACE - stop_info.SetStopReasonToTrace(); - exc_translated = true; - break; - case 6: code_desc = "EXC_PPC_PERFMON"; break; - } - break; - - case ArchSpec::eCPU_arm: - if (exc_data[0] == 1) - code_desc = "EXC_ARM_UNDEFINED"; - break; - - default: - break; - } - break; - - case 3: // EXC_ARITHMETIC - exc_desc = "EXC_ARITHMETIC"; - switch (GetArchSpec().GetGenericCPUType()) - { - case ArchSpec::eCPU_i386: - case ArchSpec::eCPU_x86_64: - switch (exc_data[0]) - { - case 1: code_desc = "EXC_I386_DIV"; break; - case 2: code_desc = "EXC_I386_INTO"; break; - case 3: code_desc = "EXC_I386_NOEXT"; break; - case 4: code_desc = "EXC_I386_EXTOVR"; break; - case 5: code_desc = "EXC_I386_EXTERR"; break; - case 6: code_desc = "EXC_I386_EMERR"; break; - case 7: code_desc = "EXC_I386_BOUND"; break; - case 8: code_desc = "EXC_I386_SSEEXTERR"; break; - } - break; - - case ArchSpec::eCPU_ppc: - case ArchSpec::eCPU_ppc64: - switch (exc_data[0]) - { - case 1: code_desc = "EXC_PPC_OVERFLOW"; break; - case 2: code_desc = "EXC_PPC_ZERO_DIVIDE"; break; - case 3: code_desc = "EXC_PPC_FLT_INEXACT"; break; - case 4: code_desc = "EXC_PPC_FLT_ZERO_DIVIDE"; break; - case 5: code_desc = "EXC_PPC_FLT_UNDERFLOW"; break; - case 6: code_desc = "EXC_PPC_FLT_OVERFLOW"; break; - case 7: code_desc = "EXC_PPC_FLT_NOT_A_NUMBER"; break; - } - break; - - default: - break; - } - break; - - case 4: // EXC_EMULATION - exc_desc = "EXC_EMULATION"; - break; - - - case 5: // EXC_SOFTWARE - exc_desc = "EXC_SOFTWARE"; - if (exc_data[0] == EXC_SOFT_SIGNAL && exc_data.size() == 2) - { - stop_info.SetStopReasonWithSignal(exc_data[1]); - exc_translated = true; - } - break; - - case 6: - { - exc_desc = "EXC_SOFTWARE"; - bool is_software_breakpoint = false; - switch (GetArchSpec().GetGenericCPUType()) - { - case ArchSpec::eCPU_i386: - case ArchSpec::eCPU_x86_64: - if (exc_data[0] == 1) // EXC_I386_SGL - { - exc_translated = true; - stop_info.SetStopReasonToTrace (); - } - else if (exc_data[0] == 2) // EXC_I386_BPT - { - is_software_breakpoint = true; - } - break; - - case ArchSpec::eCPU_ppc: - case ArchSpec::eCPU_ppc64: - is_software_breakpoint = exc_data[0] == 1; // EXC_PPC_BREAKPOINT - break; - - case ArchSpec::eCPU_arm: - is_software_breakpoint = exc_data[0] == 1; // EXC_ARM_BREAKPOINT - break; - - default: - break; - } - - if (is_software_breakpoint) - { - addr_t pc = gdb_thread->GetRegisterContext()->GetPC(); - lldb::BreakpointSiteSP bp_site_sp = GetBreakpointSiteList().FindByAddress(pc); - if (bp_site_sp) - { - exc_translated = true; - if (bp_site_sp->ValidForThisThread (thread_sp.get())) - { - stop_info.Clear (); - stop_info.SetStopReasonWithBreakpointSiteID (bp_site_sp->GetID()); - } - else - { - stop_info.Clear (); - stop_info.SetStopReasonToNone(); - } - - } - } - } - break; - - case 7: - exc_desc = "EXC_SYSCALL"; - break; - - case 8: - exc_desc = "EXC_MACH_SYSCALL"; - break; - - case 9: - exc_desc = "EXC_RPC_ALERT"; - break; - - case 10: - exc_desc = "EXC_CRASH"; - break; - } - - if (!exc_translated) - { - stop_info.SetStopReasonWithException(exc_type, exc_data.size()); - for (uint32_t i=0; i= 1) - { - if (code_desc) - desc_strm.Printf(" (%s=%s", code_label, code_desc); - else - desc_strm.Printf(" (%s=%llu", code_label, exc_data[0]); - } - - if (exc_data.size() >= 2) - { - if (subcode_desc) - desc_strm.Printf(", %s=%s", subcode_label, subcode_desc); - else - desc_strm.Printf(", %s=0x%llx", subcode_label, exc_data[1]); - } - - if (exc_data.empty() == false) - desc_strm.PutChar(')'); - - stop_info.SetStopDescription(desc_strm.GetString().c_str()); - } + stop_info.SetStopReasonWithMachException (exc_type, + exc_data.size(), + &exc_data[0]); } else if (signo) { - stop_info.SetStopReasonWithSignal(signo); + stop_info.SetStopReasonWithSignal (signo); } else { - stop_info.SetStopReasonToNone(); + stop_info.SetStopReasonToNone (); } } return eStateStopped; Modified: lldb/trunk/source/Target/Thread.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/Thread.cpp?rev=109235&r1=109234&r2=109235&view=diff ============================================================================== --- lldb/trunk/source/Target/Thread.cpp (original) +++ lldb/trunk/source/Target/Thread.cpp Fri Jul 23 11:45:51 2010 @@ -17,6 +17,7 @@ #include "lldb/Target/ExecutionContext.h" #include "lldb/Target/Process.h" #include "lldb/Target/RegisterContext.h" +#include "lldb/Target/Target.h" #include "lldb/Target/Thread.h" #include "lldb/Target/ThreadPlan.h" #include "lldb/Target/ThreadPlanCallFunction.h" @@ -139,6 +140,254 @@ } void +Thread::StopInfo::SetStopReasonWithMachException +( + uint32_t exc_type, + size_t exc_data_count, + const addr_t *exc_data +) +{ + assert (exc_data_count < LLDB_THREAD_MAX_STOP_EXC_DATA); + assert (m_thread != NULL); + m_reason = eStopReasonException; + m_details.exception.type = exc_type; + m_details.exception.data_count = exc_data_count; + for (size_t i=0; iGetProcess().GetTarget().GetArchitecture().GetGenericCPUType(); + + bool exc_translated = false; + const char *exc_desc = NULL; + const char *code_label = "code"; + const char *code_desc = NULL; + const char *subcode_label = "subcode"; + const char *subcode_desc = NULL; + switch (m_details.exception.type) + { + case 1: // EXC_BAD_ACCESS + exc_desc = "EXC_BAD_ACCESS"; + subcode_label = "address"; + switch (cpu) + { + case ArchSpec::eCPU_arm: + switch (m_details.exception.data[0]) + { + case 0x101: code_desc = "EXC_ARM_DA_ALIGN"; break; + case 0x102: code_desc = "EXC_ARM_DA_DEBUG"; break; + } + break; + + case ArchSpec::eCPU_ppc: + case ArchSpec::eCPU_ppc64: + switch (m_details.exception.data[0]) + { + case 0x101: code_desc = "EXC_PPC_VM_PROT_READ"; break; + case 0x102: code_desc = "EXC_PPC_BADSPACE"; break; + case 0x103: code_desc = "EXC_PPC_UNALIGNED"; break; + } + break; + + default: + break; + } + break; + + case 2: // EXC_BAD_INSTRUCTION + exc_desc = "EXC_BAD_INSTRUCTION"; + switch (cpu) + { + case ArchSpec::eCPU_i386: + case ArchSpec::eCPU_x86_64: + if (m_details.exception.data[0] == 1) + code_desc = "EXC_I386_INVOP"; + break; + + case ArchSpec::eCPU_ppc: + case ArchSpec::eCPU_ppc64: + switch (m_details.exception.data[0]) + { + case 1: code_desc = "EXC_PPC_INVALID_SYSCALL"; break; + case 2: code_desc = "EXC_PPC_UNIPL_INST"; break; + case 3: code_desc = "EXC_PPC_PRIVINST"; break; + case 4: code_desc = "EXC_PPC_PRIVREG"; break; + case 5: // EXC_PPC_TRACE + SetStopReasonToTrace(); + exc_translated = true; + break; + case 6: code_desc = "EXC_PPC_PERFMON"; break; + } + break; + + case ArchSpec::eCPU_arm: + if (m_details.exception.data[0] == 1) + code_desc = "EXC_ARM_UNDEFINED"; + break; + + default: + break; + } + break; + + case 3: // EXC_ARITHMETIC + exc_desc = "EXC_ARITHMETIC"; + switch (cpu) + { + case ArchSpec::eCPU_i386: + case ArchSpec::eCPU_x86_64: + switch (m_details.exception.data[0]) + { + case 1: code_desc = "EXC_I386_DIV"; break; + case 2: code_desc = "EXC_I386_INTO"; break; + case 3: code_desc = "EXC_I386_NOEXT"; break; + case 4: code_desc = "EXC_I386_EXTOVR"; break; + case 5: code_desc = "EXC_I386_EXTERR"; break; + case 6: code_desc = "EXC_I386_EMERR"; break; + case 7: code_desc = "EXC_I386_BOUND"; break; + case 8: code_desc = "EXC_I386_SSEEXTERR"; break; + } + break; + + case ArchSpec::eCPU_ppc: + case ArchSpec::eCPU_ppc64: + switch (m_details.exception.data[0]) + { + case 1: code_desc = "EXC_PPC_OVERFLOW"; break; + case 2: code_desc = "EXC_PPC_ZERO_DIVIDE"; break; + case 3: code_desc = "EXC_PPC_FLT_INEXACT"; break; + case 4: code_desc = "EXC_PPC_FLT_ZERO_DIVIDE"; break; + case 5: code_desc = "EXC_PPC_FLT_UNDERFLOW"; break; + case 6: code_desc = "EXC_PPC_FLT_OVERFLOW"; break; + case 7: code_desc = "EXC_PPC_FLT_NOT_A_NUMBER"; break; + } + break; + + default: + break; + } + break; + + case 4: // EXC_EMULATION + exc_desc = "EXC_EMULATION"; + break; + + + case 5: // EXC_SOFTWARE + exc_desc = "EXC_SOFTWARE"; + if (m_details.exception.data[0] == EXC_SOFT_SIGNAL && m_details.exception.data_count == 2) + { + SetStopReasonWithSignal(m_details.exception.data[1]); + exc_translated = true; + } + break; + + case 6: + { + exc_desc = "EXC_SOFTWARE"; + bool is_software_breakpoint = false; + switch (cpu) + { + case ArchSpec::eCPU_i386: + case ArchSpec::eCPU_x86_64: + if (m_details.exception.data[0] == 1) // EXC_I386_SGL + { + exc_translated = true; + SetStopReasonToTrace (); + } + else if (m_details.exception.data[0] == 2) // EXC_I386_BPT + { + is_software_breakpoint = true; + } + break; + + case ArchSpec::eCPU_ppc: + case ArchSpec::eCPU_ppc64: + is_software_breakpoint = m_details.exception.data[0] == 1; // EXC_PPC_BREAKPOINT + break; + + case ArchSpec::eCPU_arm: + is_software_breakpoint = m_details.exception.data[0] == 1; // EXC_ARM_BREAKPOINT + break; + + default: + break; + } + + if (is_software_breakpoint) + { + addr_t pc = m_thread->GetRegisterContext()->GetPC(); + lldb::BreakpointSiteSP bp_site_sp = m_thread->GetProcess().GetBreakpointSiteList().FindByAddress(pc); + if (bp_site_sp) + { + exc_translated = true; + if (bp_site_sp->ValidForThisThread (m_thread)) + { + Clear (); + SetStopReasonWithBreakpointSiteID (bp_site_sp->GetID()); + } + else + { + Clear (); + SetStopReasonToNone(); + } + + } + } + } + break; + + case 7: + exc_desc = "EXC_SYSCALL"; + break; + + case 8: + exc_desc = "EXC_MACH_SYSCALL"; + break; + + case 9: + exc_desc = "EXC_RPC_ALERT"; + break; + + case 10: + exc_desc = "EXC_CRASH"; + break; + } + + if (!exc_translated) + { + StreamString desc_strm; + + if (exc_desc) + desc_strm.PutCString(exc_desc); + else + desc_strm.Printf("EXC_??? (%u)", exc_type); + + if (m_details.exception.data_count >= 1) + { + if (code_desc) + desc_strm.Printf(" (%s=%s", code_label, code_desc); + else + desc_strm.Printf(" (%s=%llu", code_label, exc_data[0]); + } + + if (m_details.exception.data_count >= 2) + { + if (subcode_desc) + desc_strm.Printf(", %s=%s", subcode_label, subcode_desc); + else + desc_strm.Printf(", %s=0x%llx", subcode_label, exc_data[1]); + } + + if (m_details.exception.data_count > 0) + desc_strm.PutChar(')'); + + SetStopDescription(desc_strm.GetString().c_str()); + } + } +} +void Thread::StopInfo::SetThread (Thread* thread) { m_thread = thread; @@ -227,7 +476,7 @@ } void -Thread::StopInfo::SetStopReasonWithException (uint32_t exc_type, size_t exc_data_count) +Thread::StopInfo::SetStopReasonWithGenericException (uint32_t exc_type, size_t exc_data_count) { m_reason = eStopReasonException; m_details.exception.type = exc_type; From gclayton at apple.com Fri Jul 23 12:42:15 2010 From: gclayton at apple.com (Greg Clayton) Date: Fri, 23 Jul 2010 17:42:15 -0000 Subject: [Lldb-commits] [lldb] r109239 - in /lldb/trunk: include/lldb/Utility/CleanUp.h lldb.xcodeproj/project.pbxproj Message-ID: <20100723174215.B63812A6C12C@llvm.org> Author: gclayton Date: Fri Jul 23 12:42:15 2010 New Revision: 109239 URL: http://llvm.org/viewvc/llvm-project?rev=109239&view=rev Log: Added a new utility class that I have wanted for a while. The CleanUp class is a templatized class that allows you to have a cleanup function called on a data value of type T when the value is set or when the object goes out of scope. It has support for very rudimentary invalid value detection that can be enabled by using the appropriate constructor. Anyone with template experience that can see ways of improving this class please let me know. The example code shows a few typical scenarios in which I would like to use it. It is currently coded with simple type T values in mind (integer file descriptors, pointers, etc), but I am sure some specialization might help out the class for more complex types. There is a lot of documentation including examples in the CleanUp.h header file. Added: lldb/trunk/include/lldb/Utility/CleanUp.h Modified: lldb/trunk/lldb.xcodeproj/project.pbxproj Added: lldb/trunk/include/lldb/Utility/CleanUp.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Utility/CleanUp.h?rev=109239&view=auto ============================================================================== --- lldb/trunk/include/lldb/Utility/CleanUp.h (added) +++ lldb/trunk/include/lldb/Utility/CleanUp.h Fri Jul 23 12:42:15 2010 @@ -0,0 +1,188 @@ +//===-- CleanUp.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_CleanUp_h_ +#define liblldb_CleanUp_h_ + +#include "lldb/lldb-include.h" + +namespace lldb_utility { + +//---------------------------------------------------------------------- +// Templated class that guarantees that a cleanup callback function will +// be called. The cleanup function will be called once under the +// following conditions: +// - when the object goes out of scope +// - when the user explicitly calls clean. +// - the current value will be cleaned up when a new value is set using +// set(T value) as long as the current value hasn't already been cleaned. +// +// This class is designed to be used with simple types for type T (like +// file descriptors, opaque handles, pointers, etc). If more complex +// type T objects are desired, we need to probably specialize this class +// to take "const T&" for all input T parameters. Yet if a type T is +// complex already it might be better to build the cleanup funcionality +// into T. +// +// The cleanup function must take one argument that is of type T. +// The calback fucntion return type is R. The return value is currently +// needed for "CallbackType". If there is an easy way to get around the +// need for the return value we can change this class. +// +// The two template parameters are: +// T - The variable type of value that will be stored and used as the +// sole argument for the cleanup callback. +// R - The return type for the cleanup function. +// +// EXAMPLES +// // Use with file handles that get opened where you want to close +// // them. Below we use "int open(const char *path, int oflag, ...)" +// // which returns an integer file descriptor. -1 is the invalid file +// // descriptor so to make an object that will call "int close(int fd)" +// // automatically we can use: +// +// CleanUp fd(open("/tmp/a.txt", O_RDONLY, 0), -1, close); +// +// // malloc/free example +// CleanUp malloced_bytes(malloc(32), NULL, free); +//---------------------------------------------------------------------- +template +class CleanUp +{ +public: + typedef T value_type; + typedef R (*CallbackType)(value_type); + + //---------------------------------------------------------------------- + // Constructor that sets the current value only. No values are + // considered to be invalid and the cleanup function will be called + // regardless of the value of m_current_value. + //---------------------------------------------------------------------- + CleanUp (value_type value, CallbackType callback) : + m_current_value (value), + m_invalid_value (), + m_callback (callback), + m_callback_called (false), + m_invalid_value_is_valid (false) + { + } + + //---------------------------------------------------------------------- + // Constructor that sets the current value and also the invalid value. + // The cleanup function will be called on "m_value" as long as it isn't + // equal to "m_invalid_value". + //---------------------------------------------------------------------- + CleanUp (value_type value, value_type invalid, CallbackType callback) : + m_current_value (value), + m_callback (callback), + m_invalid_value (invalid), + m_callback_called (false), + m_invalid_value_is_valid (true) + { + } + + //---------------------------------------------------------------------- + // Automatically cleanup when this object goes out of scope. + //---------------------------------------------------------------------- + ~CleanUp () + { + clean(); + } + + //---------------------------------------------------------------------- + // Access the value stored in this class + //---------------------------------------------------------------------- + value_type get() + { + return m_current_value; + } + + //---------------------------------------------------------------------- + // Access the value stored in this class + //---------------------------------------------------------------------- + const value_type + get() const + { + return m_current_value; + } + + //---------------------------------------------------------------------- + // Reset the owned value to "value". If a current value is valid and + // the cleanup callback hasn't been called, the previous value will + // be cleaned up (see void CleanUp::clean()). + //---------------------------------------------------------------------- + void + set (const value_type value) + { + // Cleanup the current value if needed + clean (); + // Now set the new value and mark our callback as not called + m_callback_called = false; + m_current_value = value; + } + + //---------------------------------------------------------------------- + // Checks is "m_current_value" is valid. The value is considered valid + // no invalid value was supplied during construction of this object or + // if an invalid value was supplied and "m_current_value" is not equal + // to "m_invalid_value". + // + // Returns true if "m_current_value" is valid, false otherwise. + //---------------------------------------------------------------------- + bool + is_valid() const + { + if (m_invalid_value_is_valid) + return m_current_value != m_invalid_value; + return true; + } + + //---------------------------------------------------------------------- + // This function will call the cleanup callback provided in the + // constructor one time if the value is considered valid (See is_valid()). + // This function sets m_callback_called to true so we don't call the + // cleanup callback multiple times on the same value. + //---------------------------------------------------------------------- + void + clean() + { + if (m_callback && !m_callback_called) + { + m_callback_called = true; + if (is_valid()) + m_callback(m_current_value); + } + } + + //---------------------------------------------------------------------- + // Cancels the cleanup that would have been called on "m_current_value" + // if it was valid. This function can be used to release the value + // contained in this object so ownership can be transfered to the caller. + //---------------------------------------------------------------------- + value_type + release () + { + m_callback_called = true; + return m_current_value; + } + +private: + value_type m_current_value; + const value_type m_invalid_value; + CallbackType m_callback; + bool m_callback_called; + bool m_invalid_value_is_valid; + + // Outlaw default constructor, copy constructor and the assignment operator + DISALLOW_COPY_AND_ASSIGN (CleanUp); +}; + +} // namespace lldb_utility + +#endif // #ifndef liblldb_CleanUp_h_ Modified: lldb/trunk/lldb.xcodeproj/project.pbxproj URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/lldb.xcodeproj/project.pbxproj?rev=109239&r1=109238&r2=109239&view=diff ============================================================================== --- lldb/trunk/lldb.xcodeproj/project.pbxproj (original) +++ lldb/trunk/lldb.xcodeproj/project.pbxproj Fri Jul 23 12:42:15 2010 @@ -13,6 +13,7 @@ 261B5A5411C3F2AD00AABD0A /* SharingPtr.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 261B5A5211C3F2AD00AABD0A /* SharingPtr.cpp */; }; 261B5A5511C3F2AD00AABD0A /* SharingPtr.h in Headers */ = {isa = PBXBuildFile; fileRef = 261B5A5311C3F2AD00AABD0A /* SharingPtr.h */; settings = {ATTRIBUTES = (Public, ); }; }; 262CFC7711A4510000946C6C /* debugserver in Resources */ = {isa = PBXBuildFile; fileRef = 26CE05A0115C31E50022F371 /* debugserver */; }; + 264723A611FA076E00DE380C /* CleanUp.h in Headers */ = {isa = PBXBuildFile; fileRef = 264723A511FA076E00DE380C /* CleanUp.h */; }; 265ABF6310F42EE900531910 /* DebugSymbols.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 265ABF6210F42EE900531910 /* DebugSymbols.framework */; }; 2668020E115FD12C008E1FE4 /* lldb-defines.h in Headers */ = {isa = PBXBuildFile; fileRef = 26BC7C2510F1B3BC00F91463 /* lldb-defines.h */; settings = {ATTRIBUTES = (Public, ); }; }; 2668020F115FD12C008E1FE4 /* lldb-enumerations.h in Headers */ = {isa = PBXBuildFile; fileRef = 26BC7C2610F1B3BC00F91463 /* lldb-enumerations.h */; settings = {ATTRIBUTES = (Public, ); }; }; @@ -513,6 +514,7 @@ 263FEDA5112CC1DA00E4C208 /* ThreadSafeSTLMap.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ThreadSafeSTLMap.h; path = include/lldb/Core/ThreadSafeSTLMap.h; sourceTree = ""; }; 264334381110F63100CDB6C6 /* ValueObjectRegister.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = ValueObjectRegister.cpp; path = source/Core/ValueObjectRegister.cpp; sourceTree = ""; }; 2643343A1110F63C00CDB6C6 /* ValueObjectRegister.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ValueObjectRegister.h; path = include/lldb/Core/ValueObjectRegister.h; sourceTree = ""; }; + 264723A511FA076E00DE380C /* CleanUp.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CleanUp.h; path = include/lldb/Utility/CleanUp.h; sourceTree = ""; }; 264AD83711095BA600E0B039 /* CommandObjectLog.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = CommandObjectLog.cpp; path = source/Commands/CommandObjectLog.cpp; sourceTree = ""; }; 264AD83911095BBD00E0B039 /* CommandObjectLog.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CommandObjectLog.h; path = source/Commands/CommandObjectLog.h; sourceTree = ""; }; 265ABF6210F42EE900531910 /* DebugSymbols.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = DebugSymbols.framework; path = /System/Library/PrivateFrameworks/DebugSymbols.framework; sourceTree = ""; }; @@ -1505,6 +1507,7 @@ 2682F168115ED9C800CCFF99 /* Utility */ = { isa = PBXGroup; children = ( + 264723A511FA076E00DE380C /* CleanUp.h */, 261B5A5211C3F2AD00AABD0A /* SharingPtr.cpp */, 261B5A5311C3F2AD00AABD0A /* SharingPtr.h */, 26F996A7119B79C300412154 /* ARM_DWARF_Registers.h */, @@ -2206,6 +2209,7 @@ 26D27CA011ED3A4E0024D721 /* ELFHeader.h in Headers */, 49E45FAA11F660DC008F7B28 /* ClangASTType.h in Headers */, 49BB309611F79450001A4197 /* TaggedASTType.h in Headers */, + 264723A611FA076E00DE380C /* CleanUp.h in Headers */, ); runOnlyForDeploymentPostprocessing = 0; }; From benny.kra at googlemail.com Fri Jul 23 13:59:12 2010 From: benny.kra at googlemail.com (Benjamin Kramer) Date: Fri, 23 Jul 2010 18:59:12 -0000 Subject: [Lldb-commits] [lldb] r109254 - /lldb/trunk/include/lldb/Symbol/ClangASTContext.h Message-ID: <20100723185912.34AA92A6C12C@llvm.org> Author: d0k Date: Fri Jul 23 13:59:12 2010 New Revision: 109254 URL: http://llvm.org/viewvc/llvm-project?rev=109254&view=rev Log: Remove useless typedef keyword, fix a clang warning. Modified: lldb/trunk/include/lldb/Symbol/ClangASTContext.h Modified: lldb/trunk/include/lldb/Symbol/ClangASTContext.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Symbol/ClangASTContext.h?rev=109254&r1=109253&r2=109254&view=diff ============================================================================== --- lldb/trunk/include/lldb/Symbol/ClangASTContext.h (original) +++ lldb/trunk/include/lldb/Symbol/ClangASTContext.h Fri Jul 23 13:59:12 2010 @@ -37,7 +37,7 @@ // will then be able to use one enumeration for all access and we can // translate them correctly into the correct Clang versions depending on // what the access is applied to. - typedef enum AccessType + enum AccessType { eAccessNone, eAccessPublic, From wilsons at start.ca Fri Jul 23 16:42:20 2010 From: wilsons at start.ca (Stephen Wilson) Date: Fri, 23 Jul 2010 17:42:20 -0400 Subject: [Lldb-commits] [lldb] r109235 - in /lldb/trunk: include/lldb/Target/Thread.h source/Plugins/Process/MacOSX-User/source/MacOSX/MachException.cpp source/Plugins/Process/MacOSX-User/source/MacOSX/MachException.h source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp source/Target/Thread.cpp In-Reply-To: <20100723164552.1025D2A6C12C@llvm.org> (Greg Clayton's message of "Fri, 23 Jul 2010 16:45:51 -0000") References: <20100723164552.1025D2A6C12C@llvm.org> Message-ID: Hi Greg, Greg Clayton writes: > + case 5: // EXC_SOFTWARE > + exc_desc = "EXC_SOFTWARE"; > + if (m_details.exception.data[0] == EXC_SOFT_SIGNAL && m_details.exception.data_count == 2) > + { > + SetStopReasonWithSignal(m_details.exception.data[1]); > + exc_translated = true; > + } > + break; Build failure on linux. Looks like EXC_SOFT_SIGNAL needs to be replaced by the appropriate magic constant. Take care, Steve From wilsons at start.ca Fri Jul 23 16:47:22 2010 From: wilsons at start.ca (Stephen Wilson) Date: Fri, 23 Jul 2010 21:47:22 -0000 Subject: [Lldb-commits] [lldb] r109271 - /lldb/trunk/source/Commands/CommandObjectExpression.cpp Message-ID: <20100723214722.2E4EF2A6C12C@llvm.org> Author: wilsons Date: Fri Jul 23 16:47:22 2010 New Revision: 109271 URL: http://llvm.org/viewvc/llvm-project?rev=109271&view=rev Log: Fix a typo. 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=109271&r1=109270&r2=109271&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectExpression.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectExpression.cpp Fri Jul 23 16:47:22 2010 @@ -19,7 +19,7 @@ #include "lldb/Expression/ClangExpression.h" #include "lldb/Expression/ClangExpressionDeclMap.h" #include "lldb/Expression/ClangExpressionVariable.h" -#include "lldb/Expression/CLangFunction.h" +#include "lldb/Expression/ClangFunction.h" #include "lldb/Expression/DWARFExpression.h" #include "lldb/Host/Host.h" #include "lldb/Core/Debugger.h" From scallanan at apple.com Fri Jul 23 17:19:18 2010 From: scallanan at apple.com (Sean Callanan) Date: Fri, 23 Jul 2010 22:19:18 -0000 Subject: [Lldb-commits] [lldb] r109278 - in /lldb/trunk: include/lldb/Expression/ClangExpressionDeclMap.h source/Commands/CommandObjectExpression.cpp source/Expression/ClangExpression.cpp source/Expression/ClangExpressionDeclMap.cpp Message-ID: <20100723221918.986582A6C12C@llvm.org> Author: spyffe Date: Fri Jul 23 17:19:18 2010 New Revision: 109278 URL: http://llvm.org/viewvc/llvm-project?rev=109278&view=rev Log: Added logging: - When we JIT an expression, we print the disassembly of the generated code - When we put the structure into the target, we print the individual entries in the structure byte for byte. Modified: lldb/trunk/include/lldb/Expression/ClangExpressionDeclMap.h lldb/trunk/source/Commands/CommandObjectExpression.cpp lldb/trunk/source/Expression/ClangExpression.cpp lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp Modified: lldb/trunk/include/lldb/Expression/ClangExpressionDeclMap.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Expression/ClangExpressionDeclMap.h?rev=109278&r1=109277&r2=109278&view=diff ============================================================================== --- lldb/trunk/include/lldb/Expression/ClangExpressionDeclMap.h (original) +++ lldb/trunk/include/lldb/Expression/ClangExpressionDeclMap.h Fri Jul 23 17:19:18 2010 @@ -96,6 +96,10 @@ lldb::addr_t &struct_address, Error &error); + bool DumpMaterializedStruct(ExecutionContext *exe_ctx, + Stream &s, + Error &error); + bool Dematerialize(ExecutionContext *exe_ctx, lldb_private::Value &result_value, Error &error); @@ -155,7 +159,6 @@ void AddOneVariable(NameSearchContext &context, Variable *var); void AddOneFunction(NameSearchContext &context, Function *fun); - // Set D to dematerialize instead bool DoMaterialize (bool dematerialize, ExecutionContext *exe_ctx, lldb_private::Value *result_value, /* must be non-NULL if D is set */ Modified: lldb/trunk/source/Commands/CommandObjectExpression.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectExpression.cpp?rev=109278&r1=109277&r2=109278&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectExpression.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectExpression.cpp Fri Jul 23 17:19:18 2010 @@ -334,6 +334,17 @@ { log->Printf("Function disassembly:\n%s", insns.GetData()); } + + StreamString args; + + if (!expr_decl_map.DumpMaterializedStruct(&m_exe_ctx, args, err)) + { + log->Printf("Couldn't extract variable values : %s", err.AsCString("unknown error")); + } + else + { + log->Printf("Structure contents:\n%s", args.GetData()); + } } ClangFunction::ExecutionResults execution_result = Modified: lldb/trunk/source/Expression/ClangExpression.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/ClangExpression.cpp?rev=109278&r1=109277&r2=109278&view=diff ============================================================================== --- lldb/trunk/source/Expression/ClangExpression.cpp (original) +++ lldb/trunk/source/Expression/ClangExpression.cpp Fri Jul 23 17:19:18 2010 @@ -669,10 +669,10 @@ ret.SetErrorString("Couldn't find the target"); } - lldb::DataBufferSP buffer_sp(new DataBufferHeap(func_range.second - func_range.first, 0)); + lldb::DataBufferSP buffer_sp(new DataBufferHeap(func_range.second - func_remote_addr, 0)); Error err; - exe_ctx.process->ReadMemory(func_range.first, buffer_sp->GetBytes(), buffer_sp->GetByteSize(), err); + exe_ctx.process->ReadMemory(func_remote_addr, buffer_sp->GetBytes(), buffer_sp->GetByteSize(), err); if (!err.Success()) { @@ -701,7 +701,7 @@ DataExtractor extractor(buffer_sp, exe_ctx.process->GetByteOrder(), - 32); + exe_ctx.target->GetArchitecture().GetAddressByteSize()); if(log) { @@ -709,7 +709,7 @@ extractor.PutToLog (log, 0, extractor.GetByteSize(), - func_range.first, + func_remote_addr, 16, DataExtractor::TypeUInt8); } @@ -725,8 +725,9 @@ ++instruction_index) { Disassembler::Instruction *instruction = instruction_list.GetInstructionAtIndex(instruction_index); + Address addr(NULL, func_remote_addr + bytes_offset); instruction->Dump (&stream, - NULL, + &addr, &extractor, bytes_offset, exe_ctx, Modified: lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp?rev=109278&r1=109277&r2=109278&view=diff ============================================================================== --- lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp (original) +++ lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp Fri Jul 23 17:19:18 2010 @@ -215,6 +215,71 @@ return DoMaterialize(true, exe_ctx, &result_value, err); } +bool +ClangExpressionDeclMap::DumpMaterializedStruct(ExecutionContext *exe_ctx, + Stream &s, + Error &err) +{ + if (!m_struct_laid_out) + { + err.SetErrorString("Structure hasn't been laid out yet"); + return false; + } + + if (!exe_ctx) + { + err.SetErrorString("Received null execution context"); + return false; + } + + + if (!exe_ctx->process) + { + err.SetErrorString("Couldn't find the process"); + return false; + } + + if (!exe_ctx->target) + { + err.SetErrorString("Couldn't find the target"); + return false; + } + + lldb::DataBufferSP data(new DataBufferHeap(m_struct_size, 0)); + + Error error; + if (exe_ctx->process->ReadMemory (m_materialized_location, data->GetBytes(), data->GetByteSize(), error) != data->GetByteSize()) + { + err.SetErrorStringWithFormat ("Couldn't read struct from the target: %s", error.AsCString()); + return false; + } + + DataExtractor extractor(data, exe_ctx->process->GetByteOrder(), exe_ctx->target->GetArchitecture().GetAddressByteSize()); + + StructMemberIterator iter; + + for (iter = m_members.begin(); + iter != m_members.end(); + ++iter) + { + s.Printf("[%s]\n", iter->m_name.c_str()); + + extractor.Dump(&s, // stream + iter->m_offset, // offset + lldb::eFormatBytesWithASCII, // format + 1, // byte size of individual entries + iter->m_size, // number of entries + 16, // entries per line + m_materialized_location + iter->m_offset, // address to print + 0, // bit size (bitfields only; 0 means ignore) + 0); // bit alignment (bitfields only; 0 means ignore) + + s.PutChar('\n'); + } + + return true; +} + bool ClangExpressionDeclMap::DoMaterialize (bool dematerialize, ExecutionContext *exe_ctx, From gclayton at apple.com Fri Jul 23 17:50:09 2010 From: gclayton at apple.com (Greg Clayton) Date: Fri, 23 Jul 2010 22:50:09 -0000 Subject: [Lldb-commits] [lldb] r109281 - /lldb/trunk/source/Target/Thread.cpp Message-ID: <20100723225009.A5D4B2A6C12C@llvm.org> Author: gclayton Date: Fri Jul 23 17:50:09 2010 New Revision: 109281 URL: http://llvm.org/viewvc/llvm-project?rev=109281&view=rev Log: Get rid of using EXC_SOFT_SIGNAL define in host agnostic code. Modified: lldb/trunk/source/Target/Thread.cpp Modified: lldb/trunk/source/Target/Thread.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/Thread.cpp?rev=109281&r1=109280&r2=109281&view=diff ============================================================================== --- lldb/trunk/source/Target/Thread.cpp (original) +++ lldb/trunk/source/Target/Thread.cpp Fri Jul 23 17:50:09 2010 @@ -276,7 +276,8 @@ case 5: // EXC_SOFTWARE exc_desc = "EXC_SOFTWARE"; - if (m_details.exception.data[0] == EXC_SOFT_SIGNAL && m_details.exception.data_count == 2) + // Check for EXC_SOFT_SIGNAL + if (m_details.exception.data[0] == 0x10003 && m_details.exception.data_count == 2) { SetStopReasonWithSignal(m_details.exception.data[1]); exc_translated = true; From gclayton at apple.com Fri Jul 23 17:50:33 2010 From: gclayton at apple.com (Greg Clayton) Date: Fri, 23 Jul 2010 15:50:33 -0700 Subject: [Lldb-commits] [lldb] r109235 - in /lldb/trunk: include/lldb/Target/Thread.h source/Plugins/Process/MacOSX-User/source/MacOSX/MachException.cpp source/Plugins/Process/MacOSX-User/source/MacOSX/MachException.h source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp source/Target/Thread.cpp In-Reply-To: References: <20100723164552.1025D2A6C12C@llvm.org> Message-ID: <97E244BC-1FDA-4C27-98C5-06537CCEDEFA@apple.com> Fixed in r109281 On Jul 23, 2010, at 2:42 PM, Stephen Wilson wrote: > > Hi Greg, > > Greg Clayton writes: >> + case 5: // EXC_SOFTWARE >> + exc_desc = "EXC_SOFTWARE"; >> + if (m_details.exception.data[0] == EXC_SOFT_SIGNAL && m_details.exception.data_count == 2) >> + { >> + SetStopReasonWithSignal(m_details.exception.data[1]); >> + exc_translated = true; >> + } >> + break; > > Build failure on linux. Looks like EXC_SOFT_SIGNAL needs to be replaced > by the appropriate magic constant. > > > Take care, > Steve From gclayton at apple.com Fri Jul 23 18:33:18 2010 From: gclayton at apple.com (Greg Clayton) Date: Fri, 23 Jul 2010 23:33:18 -0000 Subject: [Lldb-commits] [lldb] r109289 - in /lldb/trunk: include/lldb/ include/lldb/API/ include/lldb/Breakpoint/ source/API/ source/Breakpoint/ source/Commands/ source/Target/ Message-ID: <20100723233318.240432A6C12C@llvm.org> Author: gclayton Date: Fri Jul 23 18:33:17 2010 New Revision: 109289 URL: http://llvm.org/viewvc/llvm-project?rev=109289&view=rev Log: Added needed breakpoint functionality to the public API that includes: SBTarget: - get breakpoint count - get breakpoint at index SBBreakpoint: - Extract data from breakpoint events Modified: lldb/trunk/include/lldb/API/SBBreakpoint.h lldb/trunk/include/lldb/API/SBEvent.h lldb/trunk/include/lldb/API/SBTarget.h lldb/trunk/include/lldb/Breakpoint/Breakpoint.h lldb/trunk/include/lldb/Breakpoint/BreakpointList.h lldb/trunk/include/lldb/Breakpoint/BreakpointLocationList.h lldb/trunk/include/lldb/lldb-enumerations.h lldb/trunk/source/API/SBBreakpoint.cpp lldb/trunk/source/API/SBTarget.cpp lldb/trunk/source/Breakpoint/Breakpoint.cpp lldb/trunk/source/Breakpoint/BreakpointIDList.cpp lldb/trunk/source/Breakpoint/BreakpointList.cpp lldb/trunk/source/Breakpoint/BreakpointLocationList.cpp lldb/trunk/source/Commands/CommandObjectBreakpoint.cpp lldb/trunk/source/Target/Target.cpp Modified: lldb/trunk/include/lldb/API/SBBreakpoint.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBBreakpoint.h?rev=109289&r1=109288&r2=109289&view=diff ============================================================================== --- lldb/trunk/include/lldb/API/SBBreakpoint.h (original) +++ lldb/trunk/include/lldb/API/SBBreakpoint.h Fri Jul 23 18:33:17 2010 @@ -68,6 +68,9 @@ bool IsEnabled (); + uint32_t + GetHitCount () const; + void SetIgnoreCount (uint32_t count); @@ -110,7 +113,14 @@ void GetDescription (FILE *, const char *description_level, bool describe_locations = false); + static lldb::BreakpointEventType + GetBreakpointEventTypeFromEvent (const lldb::SBEvent& event); + static lldb::SBBreakpoint + GetBreakpointFromEvent (const lldb::SBEvent& event); + + static lldb::SBBreakpointLocation + GetBreakpointLocationAtIndexFromEvent (const lldb::SBEvent& event, uint32_t loc_idx); private: friend class SBBreakpointLocation; Modified: lldb/trunk/include/lldb/API/SBEvent.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBEvent.h?rev=109289&r1=109288&r2=109289&view=diff ============================================================================== --- lldb/trunk/include/lldb/API/SBEvent.h (original) +++ lldb/trunk/include/lldb/API/SBEvent.h Fri Jul 23 18:33:17 2010 @@ -59,6 +59,7 @@ protected: friend class SBListener; friend class SBBroadcaster; + friend class SBBreakpoint; friend class SBDebugger; friend class SBProcess; Modified: lldb/trunk/include/lldb/API/SBTarget.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBTarget.h?rev=109289&r1=109288&r2=109289&view=diff ============================================================================== --- lldb/trunk/include/lldb/API/SBTarget.h (original) +++ lldb/trunk/include/lldb/API/SBTarget.h Fri Jul 23 18:33:17 2010 @@ -97,12 +97,15 @@ lldb::SBBreakpoint BreakpointCreateByAddress (addr_t address); + uint32_t + GetNumBreakpoints () const; + + lldb::SBBreakpoint + GetBreakpointAtIndex (uint32_t idx) const; + bool BreakpointDelete (break_id_t break_id); - void - ListAllBreakpoints (); - lldb::SBBreakpoint FindBreakpointByID (break_id_t break_id); Modified: lldb/trunk/include/lldb/Breakpoint/Breakpoint.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Breakpoint/Breakpoint.h?rev=109289&r1=109288&r2=109289&view=diff ============================================================================== --- lldb/trunk/include/lldb/Breakpoint/Breakpoint.h (original) +++ lldb/trunk/include/lldb/Breakpoint/Breakpoint.h Fri Jul 23 18:33:17 2010 @@ -104,25 +104,14 @@ virtual const ConstString & GetFlavor () const; - - enum EventSubType - { - eBreakpointInvalidType = (1 << 0), - eBreakpointAdded = (1 << 1), - eBreakpointRemoved = (1 << 2), - eBreakpointLocationsAdded = (1 << 3), - eBreakpointLocationsRemoved = (1 << 4), - eBreakpointLocationResolved = (1 << 5) - }; - - BreakpointEventData (EventSubType sub_type, + BreakpointEventData (lldb::BreakpointEventType sub_type, lldb::BreakpointSP &new_breakpoint_sp); virtual ~BreakpointEventData(); - EventSubType - GetSubType () const; + lldb::BreakpointEventType + GetBreakpointEventType () const; lldb::BreakpointSP & GetBreakpoint (); @@ -131,17 +120,20 @@ virtual void Dump (Stream *s) const; - static BreakpointEventData * - GetEventDataFromEvent (const lldb::EventSP &event_sp); - - static EventSubType - GetSubTypeFromEvent (const lldb::EventSP &event_sp); + static lldb::BreakpointEventType + GetBreakpointEventTypeFromEvent (const lldb::EventSP &event_sp); static lldb::BreakpointSP GetBreakpointFromEvent (const lldb::EventSP &event_sp); + static lldb::BreakpointLocationSP + GetBreakpointLocationAtIndexFromEvent (const lldb::EventSP &event_sp, uint32_t loc_idx); + private: - EventSubType m_sub_type; + static BreakpointEventData * + GetEventDataFromEvent (const lldb::EventSP &event_sp); + + lldb::BreakpointEventType m_breakpoint_event; lldb::BreakpointSP m_new_breakpoint_sp; BreakpointLocationCollection m_locations; @@ -324,7 +316,7 @@ SetIgnoreCount (uint32_t count); //------------------------------------------------------------------ - /// Return the current Ignore Count. + /// Return the current ignore count/ /// @return /// The number of breakpoint hits to be ignored. //------------------------------------------------------------------ @@ -332,6 +324,15 @@ GetIgnoreCount () const; //------------------------------------------------------------------ + /// Return the current hit count for all locations. + /// @return + /// The current hit count for all locations. + //------------------------------------------------------------------ + uint32_t + GetHitCount () const; + + + //------------------------------------------------------------------ /// Set the valid thread to be checked when the breakpoint is hit. /// @param[in] thread_id /// If this thread hits the breakpoint, we stop, otherwise not. Modified: lldb/trunk/include/lldb/Breakpoint/BreakpointList.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Breakpoint/BreakpointList.h?rev=109289&r1=109288&r2=109289&view=diff ============================================================================== --- lldb/trunk/include/lldb/Breakpoint/BreakpointList.h (original) +++ lldb/trunk/include/lldb/Breakpoint/BreakpointList.h Fri Jul 23 18:33:17 2010 @@ -47,7 +47,7 @@ /// Returns breakpoint id. //------------------------------------------------------------------ virtual lldb::break_id_t - Add (lldb::BreakpointSP& bp_sp); + Add (lldb::BreakpointSP& bp_sp, bool notify); //------------------------------------------------------------------ /// Standard "Dump" method. At present it does nothing. @@ -92,7 +92,7 @@ /// breakpoint doesn't exist. //------------------------------------------------------------------ lldb::BreakpointSP - GetBreakpointByIndex (uint32_t i); + GetBreakpointAtIndex (uint32_t i); //------------------------------------------------------------------ /// Returns a shared pointer to the breakpoint with index \a i, const version @@ -105,7 +105,7 @@ /// breakpoint doesn't exist. //------------------------------------------------------------------ const lldb::BreakpointSP - GetBreakpointByIndex (uint32_t i) const; + GetBreakpointAtIndex (uint32_t i) const; //------------------------------------------------------------------ /// Returns the number of elements in this breakpoint list. @@ -126,7 +126,7 @@ /// \b true if the breakpoint \a breakID was in the list. //------------------------------------------------------------------ bool - Remove (lldb::break_id_t breakID); + Remove (lldb::break_id_t breakID, bool notify); void SetEnabledAll (bool enabled); @@ -135,7 +135,7 @@ /// Removes all the breakpoints from this list. //------------------------------------------------------------------ void - RemoveAll (); + RemoveAll (bool notify); //------------------------------------------------------------------ /// Tell all the breakpoints to update themselves due to a change in the Modified: lldb/trunk/include/lldb/Breakpoint/BreakpointLocationList.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Breakpoint/BreakpointLocationList.h?rev=109289&r1=109288&r2=109289&view=diff ============================================================================== --- lldb/trunk/include/lldb/Breakpoint/BreakpointLocationList.h (original) +++ lldb/trunk/include/lldb/Breakpoint/BreakpointLocationList.h Fri Jul 23 18:33:17 2010 @@ -173,6 +173,15 @@ GetNumResolvedLocations() const; //------------------------------------------------------------------ + /// Returns the number hit count of all locations in this list. + /// + /// @result + /// Hit count of all locations in this list. + //------------------------------------------------------------------ + uint32_t + GetHitCount () const; + + //------------------------------------------------------------------ /// Removes the breakpoint location given by \b breakID from this /// list. /// Modified: lldb/trunk/include/lldb/lldb-enumerations.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/lldb-enumerations.h?rev=109289&r1=109288&r2=109289&view=diff ============================================================================== --- lldb/trunk/include/lldb/lldb-enumerations.h (original) +++ lldb/trunk/include/lldb/lldb-enumerations.h Fri Jul 23 18:33:17 2010 @@ -404,18 +404,30 @@ typedef enum FunctionNameType { - eFunctionNameTypeNone = 0, - eFunctionNameTypeFull = (1 << 1), // The function name. + eFunctionNameTypeNone = 0u, + eFunctionNameTypeFull = (1u << 1),// The function name. // For C this is the same as just the name of the function // For C++ this is the demangled version of the mangled name. // For ObjC this is the full function signature with the + or // - and the square brackets and the class and selector - eFunctionNameTypeBase = (1 << 2), // The function name only, no namespaces or arguments and no class + eFunctionNameTypeBase = (1u << 2),// The function name only, no namespaces or arguments and no class // methods or selectors will be searched. - eFunctionNameTypeMethod = (1 << 3), // Find function by method name (C++) with no namespace or arguments - eFunctionNameTypeSelector = (1 << 4) // Find function by selector name (ObjC) names + eFunctionNameTypeMethod = (1u << 3),// Find function by method name (C++) with no namespace or arguments + eFunctionNameTypeSelector = (1u << 4) // Find function by selector name (ObjC) names } FunctionNameType; + +typedef enum BreakpointEventType +{ + eBreakpointEventTypeInvalidType = (1u << 0), + eBreakpointEventTypeAdded = (1u << 1), + eBreakpointEventTypeRemoved = (1u << 2), + eBreakpointEventTypeLocationsAdded = (1u << 3), + eBreakpointEventTypeLocationsRemoved = (1u << 4), + eBreakpointEventTypeLocationsResolved = (1u << 5) +} BreakpointEventType; + + } // namespace lldb Modified: lldb/trunk/source/API/SBBreakpoint.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBBreakpoint.cpp?rev=109289&r1=109288&r2=109289&view=diff ============================================================================== --- lldb/trunk/source/API/SBBreakpoint.cpp (original) +++ lldb/trunk/source/API/SBBreakpoint.cpp Fri Jul 23 18:33:17 2010 @@ -10,6 +10,7 @@ #include "lldb/API/SBBreakpoint.h" #include "lldb/API/SBBreakpointLocation.h" #include "lldb/API/SBDebugger.h" +#include "lldb/API/SBEvent.h" #include "lldb/API/SBProcess.h" #include "lldb/API/SBThread.h" @@ -242,6 +243,15 @@ } uint32_t +SBBreakpoint::GetHitCount () const +{ + if (m_opaque_sp) + return m_opaque_sp->GetHitCount(); + else + return 0; +} + +uint32_t SBBreakpoint::GetIgnoreCount () const { if (m_opaque_sp) @@ -457,3 +467,30 @@ return m_opaque_sp; } +BreakpointEventType +SBBreakpoint::GetBreakpointEventTypeFromEvent (const SBEvent& event) +{ + if (event.IsValid()) + return Breakpoint::BreakpointEventData::GetBreakpointEventTypeFromEvent (event.GetSP()); + return eBreakpointEventTypeInvalidType; +} + +SBBreakpoint +SBBreakpoint::GetBreakpointFromEvent (const lldb::SBEvent& event) +{ + SBBreakpoint sb_breakpoint; + if (event.IsValid()) + sb_breakpoint.m_opaque_sp = Breakpoint::BreakpointEventData::GetBreakpointFromEvent (event.GetSP()); + return sb_breakpoint; +} + +SBBreakpointLocation +SBBreakpoint::GetBreakpointLocationAtIndexFromEvent (const lldb::SBEvent& event, uint32_t loc_idx) +{ + SBBreakpointLocation sb_breakpoint_loc; + if (event.IsValid()) + sb_breakpoint_loc.SetLocation (Breakpoint::BreakpointEventData::GetBreakpointLocationAtIndexFromEvent (event.GetSP(), loc_idx)); + return sb_breakpoint_loc; +} + + Modified: lldb/trunk/source/API/SBTarget.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBTarget.cpp?rev=109289&r1=109288&r2=109289&view=diff ============================================================================== --- lldb/trunk/source/API/SBTarget.cpp (original) +++ lldb/trunk/source/API/SBTarget.cpp Fri Jul 23 18:33:17 2010 @@ -277,36 +277,32 @@ return sb_bp; } -void -SBTarget::ListAllBreakpoints () +SBBreakpoint +SBTarget::FindBreakpointByID (break_id_t bp_id) { - FILE *out_file = m_opaque_sp->GetDebugger().GetOutputFileHandle(); - - if (out_file == NULL) - return; + SBBreakpoint sb_breakpoint; + if (m_opaque_sp && bp_id != LLDB_INVALID_BREAK_ID) + *sb_breakpoint = m_opaque_sp->GetBreakpointByID (bp_id); + return sb_breakpoint; +} +uint32_t +SBTarget::GetNumBreakpoints () const +{ if (m_opaque_sp) - { - const BreakpointList &bp_list = m_opaque_sp->GetBreakpointList(); - size_t num_bps = bp_list.GetSize(); - for (size_t i = 0; i < num_bps; ++i) - { - SBBreakpoint sb_breakpoint (bp_list.GetBreakpointByIndex (i)); - sb_breakpoint.GetDescription (out_file, "full"); - } - } + return m_opaque_sp->GetBreakpointList().GetSize(); + return 0; } SBBreakpoint -SBTarget::FindBreakpointByID (break_id_t bp_id) +SBTarget::GetBreakpointAtIndex (uint32_t idx) const { SBBreakpoint sb_breakpoint; - if (m_opaque_sp && bp_id != LLDB_INVALID_BREAK_ID) - *sb_breakpoint = m_opaque_sp->GetBreakpointByID (bp_id); + if (m_opaque_sp) + *sb_breakpoint = m_opaque_sp->GetBreakpointList().GetBreakpointAtIndex(idx); return sb_breakpoint; } - bool SBTarget::BreakpointDelete (break_id_t bp_id) { Modified: lldb/trunk/source/Breakpoint/Breakpoint.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Breakpoint/Breakpoint.cpp?rev=109289&r1=109288&r2=109289&view=diff ============================================================================== --- lldb/trunk/source/Breakpoint/Breakpoint.cpp (original) +++ lldb/trunk/source/Breakpoint/Breakpoint.cpp Fri Jul 23 18:33:17 2010 @@ -164,6 +164,12 @@ return m_options.GetIgnoreCount(); } +uint32_t +Breakpoint::GetHitCount () const +{ + return m_locations.GetHitCount(); +} + void Breakpoint::SetThreadID (lldb::tid_t thread_id) { @@ -405,10 +411,10 @@ } } -Breakpoint::BreakpointEventData::BreakpointEventData (Breakpoint::BreakpointEventData::EventSubType sub_type, +Breakpoint::BreakpointEventData::BreakpointEventData (BreakpointEventType sub_type, BreakpointSP &new_breakpoint_sp) : EventData (), - m_sub_type (sub_type), + m_breakpoint_event (sub_type), m_new_breakpoint_sp (new_breakpoint_sp) { } @@ -437,10 +443,10 @@ return m_new_breakpoint_sp; } -Breakpoint::BreakpointEventData::EventSubType -Breakpoint::BreakpointEventData::GetSubType () const +BreakpointEventType +Breakpoint::BreakpointEventData::GetBreakpointEventType () const { - return m_sub_type; + return m_breakpoint_event; } void @@ -460,29 +466,43 @@ return NULL; } -Breakpoint::BreakpointEventData::EventSubType -Breakpoint::BreakpointEventData::GetSubTypeFromEvent (const EventSP &event_sp) +BreakpointEventType +Breakpoint::BreakpointEventData::GetBreakpointEventTypeFromEvent (const EventSP &event_sp) { BreakpointEventData *data = GetEventDataFromEvent (event_sp); if (data == NULL) - return eBreakpointInvalidType; + return eBreakpointEventTypeInvalidType; else - return data->GetSubType(); + return data->GetBreakpointEventType(); } BreakpointSP Breakpoint::BreakpointEventData::GetBreakpointFromEvent (const EventSP &event_sp) { + BreakpointSP bp_sp; + BreakpointEventData *data = GetEventDataFromEvent (event_sp); + if (data) + bp_sp = data->GetBreakpoint(); - if (data == NULL) + return bp_sp; +} + +lldb::BreakpointLocationSP +Breakpoint::BreakpointEventData::GetBreakpointLocationAtIndexFromEvent (const lldb::EventSP &event_sp, uint32_t bp_loc_idx) +{ + lldb::BreakpointLocationSP bp_loc_sp; + + BreakpointEventData *data = GetEventDataFromEvent (event_sp); + if (data) { - BreakpointSP ret_val; - return ret_val; + Breakpoint *bp = data->GetBreakpoint().get(); + if (bp) + bp_loc_sp = bp->GetLocationAtIndex(bp_loc_idx); } - else - return data->GetBreakpoint(); + + return bp_loc_sp; } Modified: lldb/trunk/source/Breakpoint/BreakpointIDList.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Breakpoint/BreakpointIDList.cpp?rev=109289&r1=109288&r2=109289&view=diff ============================================================================== --- lldb/trunk/source/Breakpoint/BreakpointIDList.cpp (original) +++ lldb/trunk/source/Breakpoint/BreakpointIDList.cpp Fri Jul 23 18:33:17 2010 @@ -231,7 +231,7 @@ const size_t num_breakpoints = breakpoints.GetSize(); for (size_t j = 0; j < num_breakpoints; ++j) { - Breakpoint *breakpoint = breakpoints.GetBreakpointByIndex (j).get(); + Breakpoint *breakpoint = breakpoints.GetBreakpointAtIndex (j).get(); break_id_t cur_bp_id = breakpoint->GetID(); if ((cur_bp_id < start_bp_id) || (cur_bp_id > end_bp_id)) Modified: lldb/trunk/source/Breakpoint/BreakpointList.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Breakpoint/BreakpointList.cpp?rev=109289&r1=109288&r2=109289&view=diff ============================================================================== --- lldb/trunk/source/Breakpoint/BreakpointList.cpp (original) +++ lldb/trunk/source/Breakpoint/BreakpointList.cpp Fri Jul 23 18:33:17 2010 @@ -13,6 +13,7 @@ // C++ Includes // Other libraries and framework includes // Project includes +#include "lldb/Target/Target.h" using namespace lldb; using namespace lldb_private; @@ -31,23 +32,37 @@ break_id_t -BreakpointList::Add (BreakpointSP &bp) +BreakpointList::Add (BreakpointSP &bp_sp, bool notify) { Mutex::Locker locker(m_mutex); // Internal breakpoint IDs are negative, normal ones are positive - bp->SetID (m_is_internal ? --m_next_break_id : ++m_next_break_id); - m_breakpoints.push_back(bp); - return bp->GetID(); + bp_sp->SetID (m_is_internal ? --m_next_break_id : ++m_next_break_id); + + m_breakpoints.push_back(bp_sp); + if (notify) + { + if (bp_sp->GetTarget().EventTypeHasListeners(Target::eBroadcastBitBreakpointChanged)) + bp_sp->GetTarget().BroadcastEvent (Target::eBroadcastBitBreakpointChanged, + new Breakpoint::BreakpointEventData (eBreakpointEventTypeAdded, bp_sp)); + } + return bp_sp->GetID(); } bool -BreakpointList::Remove (break_id_t break_id) +BreakpointList::Remove (break_id_t break_id, bool notify) { Mutex::Locker locker(m_mutex); bp_collection::iterator pos = GetBreakpointIDIterator(break_id); // Predicate if (pos != m_breakpoints.end()) { + BreakpointSP bp_sp (*pos); m_breakpoints.erase(pos); + if (notify) + { + if (bp_sp->GetTarget().EventTypeHasListeners(Target::eBroadcastBitBreakpointChanged)) + bp_sp->GetTarget().BroadcastEvent (Target::eBroadcastBitBreakpointChanged, + new Breakpoint::BreakpointEventData (eBreakpointEventTypeRemoved, bp_sp)); + } return true; } return false; @@ -64,11 +79,19 @@ void -BreakpointList::RemoveAll () +BreakpointList::RemoveAll (bool notify) { Mutex::Locker locker(m_mutex); ClearAllBreakpointSites (); + if (notify) + { + bp_collection::iterator pos, end = m_breakpoints.end(); + for (pos = m_breakpoints.begin(); pos != end; ++pos) + if ((*pos)->GetTarget().EventTypeHasListeners(Target::eBroadcastBitBreakpointChanged)) + (*pos)->GetTarget().BroadcastEvent (Target::eBroadcastBitBreakpointChanged, + new Breakpoint::BreakpointEventData (eBreakpointEventTypeRemoved, *pos)); + } m_breakpoints.erase (m_breakpoints.begin(), m_breakpoints.end()); } @@ -144,7 +167,7 @@ BreakpointSP -BreakpointList::GetBreakpointByIndex (uint32_t i) +BreakpointList::GetBreakpointAtIndex (uint32_t i) { Mutex::Locker locker(m_mutex); BreakpointSP stop_sp; @@ -160,7 +183,7 @@ } const BreakpointSP -BreakpointList::GetBreakpointByIndex (uint32_t i) const +BreakpointList::GetBreakpointAtIndex (uint32_t i) const { Mutex::Locker locker(m_mutex); BreakpointSP stop_sp; Modified: lldb/trunk/source/Breakpoint/BreakpointLocationList.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Breakpoint/BreakpointLocationList.cpp?rev=109289&r1=109288&r2=109289&view=diff ============================================================================== --- lldb/trunk/source/Breakpoint/BreakpointLocationList.cpp (original) +++ lldb/trunk/source/Breakpoint/BreakpointLocationList.cpp Fri Jul 23 18:33:17 2010 @@ -263,6 +263,17 @@ (*pos)->ResolveBreakpointSite(); } +uint32_t +BreakpointLocationList::GetHitCount () const +{ + uint32_t hit_count = 0; + Mutex::Locker locker (m_mutex); + collection::const_iterator pos, end = m_locations.end(); + for (pos = m_locations.begin(); pos != end; ++pos) + hit_count += (*pos)->GetHitCount(); + return hit_count; +} + size_t BreakpointLocationList::GetNumResolvedLocations() const { Modified: lldb/trunk/source/Commands/CommandObjectBreakpoint.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectBreakpoint.cpp?rev=109289&r1=109288&r2=109289&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectBreakpoint.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectBreakpoint.cpp Fri Jul 23 18:33:17 2010 @@ -735,7 +735,7 @@ result.AppendMessage ("Current breakpoints:"); for (size_t i = 0; i < num_breakpoints; ++i) { - Breakpoint *breakpoint = breakpoints.GetBreakpointByIndex (i).get(); + Breakpoint *breakpoint = breakpoints.GetBreakpointAtIndex (i).get(); AddBreakpointDescription (&output_stream, breakpoint, m_options.m_level); } result.SetStatus (eReturnStatusSuccessFinishNoResult); Modified: lldb/trunk/source/Target/Target.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/Target.cpp?rev=109289&r1=109288&r2=109289&view=diff ============================================================================== --- lldb/trunk/source/Target/Target.cpp (original) +++ lldb/trunk/source/Target/Target.cpp Fri Jul 23 18:33:17 2010 @@ -231,9 +231,9 @@ resolver_sp->SetBreakpoint (bp_sp.get()); if (internal) - m_internal_breakpoint_list.Add (bp_sp); + m_internal_breakpoint_list.Add (bp_sp, false); else - m_breakpoint_list.Add (bp_sp); + m_breakpoint_list.Add (bp_sp, true); Log *log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_BREAKPOINTS); if (log) @@ -243,13 +243,6 @@ log->Printf ("Target::%s (internal = %s) => break_id = %s\n", __FUNCTION__, internal ? "yes" : "no", s.GetData()); } - // Broadcast the breakpoint creation event. - if (!internal && EventTypeHasListeners(eBroadcastBitBreakpointChanged)) - { - BroadcastEvent (eBroadcastBitBreakpointChanged, - new Breakpoint::BreakpointEventData (Breakpoint::BreakpointEventData::eBreakpointAdded, bp_sp)); - } - bp_sp->ResolveBreakpoint(); } return bp_sp; @@ -262,9 +255,9 @@ if (log) log->Printf ("Target::%s (internal_also = %s)\n", __FUNCTION__, internal_also ? "yes" : "no"); - m_breakpoint_list.RemoveAll(); + m_breakpoint_list.RemoveAll (true); if (internal_also) - m_internal_breakpoint_list.RemoveAll(); + m_internal_breakpoint_list.RemoveAll (false); } void @@ -301,9 +294,9 @@ if (DisableBreakpointByID (break_id)) { if (LLDB_BREAK_ID_IS_INTERNAL (break_id)) - m_internal_breakpoint_list.Remove(break_id); + m_internal_breakpoint_list.Remove(break_id, false); else - m_breakpoint_list.Remove(break_id); + m_breakpoint_list.Remove(break_id, true); return true; } return false; From scallanan at apple.com Fri Jul 23 20:37:44 2010 From: scallanan at apple.com (Sean Callanan) Date: Sat, 24 Jul 2010 01:37:44 -0000 Subject: [Lldb-commits] [lldb] r109317 - in /lldb/trunk: include/lldb/Expression/IRForTarget.h source/Expression/ClangExpressionDeclMap.cpp source/Expression/ClangResultSynthesizer.cpp source/Expression/IRForTarget.cpp Message-ID: <20100724013744.D23862A6C12C@llvm.org> Author: spyffe Date: Fri Jul 23 20:37:44 2010 New Revision: 109317 URL: http://llvm.org/viewvc/llvm-project?rev=109317&view=rev Log: Updated the IR converter for the target to eliminate spurious guard variables on expression statics. Updated the AST result synthesizer to eliminate the unneeded result pointer. Very rudimentary expressions now evaluate correctly in the target using the new JIT-based mechanism. Modified: lldb/trunk/include/lldb/Expression/IRForTarget.h lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp lldb/trunk/source/Expression/ClangResultSynthesizer.cpp lldb/trunk/source/Expression/IRForTarget.cpp Modified: lldb/trunk/include/lldb/Expression/IRForTarget.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Expression/IRForTarget.h?rev=109317&r1=109316&r2=109317&view=diff ============================================================================== --- lldb/trunk/include/lldb/Expression/IRForTarget.h (original) +++ lldb/trunk/include/lldb/Expression/IRForTarget.h Fri Jul 23 20:37:44 2010 @@ -42,6 +42,8 @@ bool Store); bool runOnBasicBlock(llvm::Module &M, llvm::BasicBlock &BB); + bool removeGuards(llvm::Module &M, + llvm::BasicBlock &BB); bool replaceVariables(llvm::Module &M, llvm::Function *F); Modified: lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp?rev=109317&r1=109316&r2=109317&view=diff ============================================================================== --- lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp (original) +++ lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp Fri Jul 23 20:37:44 2010 @@ -300,6 +300,12 @@ return LLDB_INVALID_ADDRESS; } + if (!exe_ctx->frame) + { + err.SetErrorString("Received null execution frame"); + return LLDB_INVALID_ADDRESS; + } + const SymbolContext &sym_ctx(exe_ctx->frame->GetSymbolContext(lldb::eSymbolContextEverything)); if (!dematerialize) Modified: lldb/trunk/source/Expression/ClangResultSynthesizer.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/ClangResultSynthesizer.cpp?rev=109317&r1=109316&r2=109317&view=diff ============================================================================== --- lldb/trunk/source/Expression/ClangResultSynthesizer.cpp (original) +++ lldb/trunk/source/Expression/ClangResultSynthesizer.cpp Fri Jul 23 20:37:44 2010 @@ -147,9 +147,7 @@ } IdentifierInfo &result_id = Ctx.Idents.get("___clang_expr_result"); - - DeclContext *decl_context = function_decl->getDeclContext(); - + clang::VarDecl *result_decl = VarDecl::Create(Ctx, function_decl, SourceLocation(), @@ -189,87 +187,11 @@ SourceLocation(), SourceLocation())); - - /////////////////////////////////////////////// - // Synthesize external void pointer variable - // - - IdentifierInfo &result_ptr_id = Ctx.Idents.get("___clang_expr_result_ptr"); - - clang::VarDecl *result_ptr_decl = VarDecl::Create(Ctx, - decl_context, - SourceLocation(), - &result_ptr_id, - Ctx.VoidPtrTy, - NULL, - VarDecl::Extern, - VarDecl::Extern); - - ///////////////////////////////////////////// - // Build a DeclRef for the result variable - // - - DeclRefExpr *result_decl_ref_expr = DeclRefExpr::Create(Ctx, - NULL, - SourceRange(), - result_decl, - SourceLocation(), - expr_qual_type); - - /////////////////////// - // call ActOnUnaryOp - // - - Scope my_scope(NULL, (Scope::BlockScope | Scope::FnScope | Scope::DeclScope)); - - Parser::DeclPtrTy result_ptr_decl_ptr; - result_ptr_decl_ptr.set(result_ptr_decl); - - Parser::OwningExprResult addressof_expr_result(m_action->ActOnUnaryOp(&my_scope, - SourceLocation(), - tok::amp, - Parser::ExprArg(*m_action, result_decl_ref_expr))); - - //////////////////////////////////////////// - // Build a DeclRef for the result pointer - // - - DeclRefExpr *result_ptr_decl_ref_expr = DeclRefExpr::Create(Ctx, - NULL, - SourceRange(), - result_ptr_decl, - SourceLocation(), - Ctx.VoidPtrTy); - - //////////////////////// - // call ActOnBinaryOp - // - - Parser::OwningExprResult assignment_expr_result(m_action->ActOnBinOp(&my_scope, - SourceLocation(), - tok::equal, - Parser::ExprArg(*m_action, result_ptr_decl_ref_expr), - Parser::ExprArg(*m_action, addressof_expr_result.take()))); - - //////////////////////////// - // call ActOnCompoundStmt - // - - void *stmts[2]; - - stmts[0] = result_initialization_stmt_result.take(); - stmts[1] = assignment_expr_result.take(); - - Parser::OwningStmtResult compound_stmt_result(m_action->ActOnCompoundStmt(SourceLocation(), - SourceLocation(), - Parser::MultiStmtArg(*m_action, stmts, 2), - false)); - //////////////////////////////////////////////// // replace the old statement with the new one // - *last_stmt_ptr = reinterpret_cast(compound_stmt_result.take()); + *last_stmt_ptr = reinterpret_cast(result_initialization_stmt_result.take()); if (log) { Modified: lldb/trunk/source/Expression/IRForTarget.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/IRForTarget.cpp?rev=109317&r1=109316&r2=109317&view=diff ============================================================================== --- lldb/trunk/source/Expression/IRForTarget.cpp (original) +++ lldb/trunk/source/Expression/IRForTarget.cpp Fri Jul 23 20:37:44 2010 @@ -162,6 +162,85 @@ return s; } +static bool isGuardVariableRef(llvm::Value *V) +{ + ConstantExpr *C = dyn_cast(V); + + if (!C || C->getOpcode() != Instruction::BitCast) + return false; + + GlobalVariable *GV = dyn_cast(C->getOperand(0)); + + if (!GV || !GV->hasName() || !GV->getName().startswith("_ZGV")) + return false; + + return true; +} + +static void TurnGuardLoadIntoZero(Instruction* guard_load, Module &M) +{ + Constant* zero(ConstantInt::get(Type::getInt8Ty(M.getContext()), 0, true)); + + Value::use_iterator ui; + + for (ui = guard_load->use_begin(); + ui != guard_load->use_end(); + ++ui) + ui->replaceUsesOfWith(guard_load, zero); + + guard_load->eraseFromParent(); +} + +static void ExciseGuardStore(Instruction* guard_store) +{ + guard_store->eraseFromParent(); +} + +bool +IRForTarget::removeGuards(Module &M, BasicBlock &BB) +{ + /////////////////////////////////////////////////////// + // Eliminate any reference to guard variables found. + // + + llvm::BasicBlock::iterator ii; + + typedef llvm::SmallVector InstrList; + typedef InstrList::iterator InstrIterator; + + InstrList guard_loads; + InstrList guard_stores; + + for (ii = BB.begin(); + ii != BB.end(); + ++ii) + { + Instruction &inst = *ii; + + if (LoadInst *load = dyn_cast(&inst)) + if (isGuardVariableRef(load->getPointerOperand())) + guard_loads.push_back(&inst); + + if (StoreInst *store = dyn_cast(&inst)) + if (isGuardVariableRef(store->getPointerOperand())) + guard_stores.push_back(&inst); + } + + InstrIterator iter; + + for (iter = guard_loads.begin(); + iter != guard_loads.end(); + ++iter) + TurnGuardLoadIntoZero(*iter, M); + + for (iter = guard_stores.begin(); + iter != guard_stores.end(); + ++iter) + ExciseGuardStore(*iter); + + return true; +} + // UnfoldConstant operates on a constant [C] which has just been replaced with a value // [new_value]. We assume that new_value has been properly placed early in the function, // most likely somewhere in front of the first instruction in the entry basic block @@ -363,6 +442,9 @@ { if (!runOnBasicBlock(M, *bbi)) return false; + + if (!removeGuards(M, *bbi)) + return false; } if (!replaceVariables(M, function)) From wilsons at start.ca Fri Jul 23 21:19:04 2010 From: wilsons at start.ca (Stephen Wilson) Date: Sat, 24 Jul 2010 02:19:04 -0000 Subject: [Lldb-commits] [lldb] r109318 - in /lldb/trunk: lib/ source/ source/Plugins/ source/Plugins/Process/Linux/ Message-ID: <20100724021905.1B08E2A6C12C@llvm.org> Author: wilsons Date: Fri Jul 23 21:19:04 2010 New Revision: 109318 URL: http://llvm.org/viewvc/llvm-project?rev=109318&view=rev Log: Add a new Process plugin for Linux. This component is still at an early stage, but allows for simple breakpoint/step-over operations and basic process control. The makefiles are set up to build the plugin under Linux only. Added: lldb/trunk/source/Plugins/Process/Linux/ lldb/trunk/source/Plugins/Process/Linux/LinuxThread.cpp lldb/trunk/source/Plugins/Process/Linux/LinuxThread.h lldb/trunk/source/Plugins/Process/Linux/Makefile lldb/trunk/source/Plugins/Process/Linux/ProcessLinux.cpp lldb/trunk/source/Plugins/Process/Linux/ProcessLinux.h lldb/trunk/source/Plugins/Process/Linux/ProcessMessage.h lldb/trunk/source/Plugins/Process/Linux/ProcessMonitor.cpp lldb/trunk/source/Plugins/Process/Linux/ProcessMonitor.h lldb/trunk/source/Plugins/Process/Linux/RegisterContextLinux.h lldb/trunk/source/Plugins/Process/Linux/RegisterContextLinux_x86_64.cpp lldb/trunk/source/Plugins/Process/Linux/RegisterContextLinux_x86_64.h Modified: lldb/trunk/lib/Makefile lldb/trunk/source/Plugins/Makefile lldb/trunk/source/lldb.cpp Modified: lldb/trunk/lib/Makefile URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/lib/Makefile?rev=109318&r1=109317&r2=109318&view=diff ============================================================================== --- lldb/trunk/lib/Makefile (original) +++ lldb/trunk/lib/Makefile Fri Jul 23 21:19:04 2010 @@ -33,7 +33,6 @@ lldbPluginObjectFileELF.a \ lldbPluginSymbolFileDWARF.a \ lldbPluginSymbolFileSymtab.a \ - lldbPluginSymbolVendorMacOSX.a \ lldbSymbol.a \ lldbTarget.a \ lldbUtility.a \ @@ -65,11 +64,13 @@ lldbPluginObjectContainerUniversalMachO.a \ lldbPluginObjectFileMachO.a \ lldbPluginProcessGDBRemote.a \ - lldbPluginUtility.a + lldbPluginUtility.a \ + lldbSymbolVendorMaxOSX.a endif ifeq ($(HOST_OS),Linux) - USEDLIBS += lldbHostLinux.a + USEDLIBS += lldbHostLinux.a \ + lldbPluginProcessLinux.a endif include $(LEVEL)/Makefile.common Modified: lldb/trunk/source/Plugins/Makefile URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Makefile?rev=109318&r1=109317&r2=109318&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Makefile (original) +++ lldb/trunk/source/Plugins/Makefile Fri Jul 23 21:19:04 2010 @@ -12,10 +12,17 @@ include $(LLDB_LEVEL)/../../Makefile.config -DIRS := ABI/MacOSX-i386 ABI/SysV-x86_64 Disassembler/llvm ObjectContainer/BSD-Archive ObjectFile/ELF SymbolFile/DWARF SymbolFile/Symtab +DIRS := ABI/MacOSX-i386 ABI/SysV-x86_64 Disassembler/llvm \ + ObjectContainer/BSD-Archive ObjectFile/ELF SymbolFile/DWARF \ + SymbolFile/Symtab ifeq ($(HOST_OS),Darwin) - DIRS += DynamicLoader/MacOSX-DYLD ObjectContainer/Universal-Mach-O ObjectFile/Mach-O Process/gdb-remote Process/Utility SymbolVendor/MacOSX +DIRS += DynamicLoader/MacOSX-DYLD ObjectContainer/Universal-Mach-O \ + ObjectFile/Mach-O Process/gdb-remote Process/Utility SymbolVendor/MacOSX +endif + +ifeq ($(HOST_OS),Linux) +DIRS += Process/Linux endif include $(LLDB_LEVEL)/Makefile Added: lldb/trunk/source/Plugins/Process/Linux/LinuxThread.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Linux/LinuxThread.cpp?rev=109318&view=auto ============================================================================== --- lldb/trunk/source/Plugins/Process/Linux/LinuxThread.cpp (added) +++ lldb/trunk/source/Plugins/Process/Linux/LinuxThread.cpp Fri Jul 23 21:19:04 2010 @@ -0,0 +1,198 @@ +//===-- LinuxThread.cpp -----------------------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#include + +// C Includes +// C++ Includes +// Other libraries and framework includes +#include "lldb/Target/Process.h" +#include "lldb/Target/Target.h" + +#include "LinuxThread.h" +#include "ProcessLinux.h" +#include "ProcessMonitor.h" +#include "RegisterContextLinux_x86_64.h" + +using namespace lldb_private; + +LinuxThread::LinuxThread(Process &process, lldb::tid_t tid) + : Thread(process, tid), + m_frame_ap(0), + m_register_ap(0), + m_note(eNone) +{ + ArchSpec arch = process.GetTarget().GetArchitecture(); + + switch (arch.GetGenericCPUType()) + { + default: + assert(false && "CPU type not supported!"); + break; + + case ArchSpec::eCPU_x86_64: + m_register_ap.reset(new RegisterContextLinux_x86_64(*this, NULL)); + break; + } +} + +ProcessMonitor & +LinuxThread::GetMonitor() +{ + ProcessLinux *process = static_cast(CalculateProcess()); + return process->GetMonitor(); +} + +void +LinuxThread::RefreshStateAfterStop() +{ +} + +const char * +LinuxThread::GetInfo() +{ + return NULL; +} + +uint32_t +LinuxThread::GetStackFrameCount() +{ + return 0; +} + +lldb::StackFrameSP +LinuxThread::GetStackFrameAtIndex(uint32_t idx) +{ + if (idx == 0) + { + RegisterContextLinux *regs = GetRegisterContext(); + StackFrame *frame = new StackFrame( + idx, *this, regs->GetFP(), regs->GetPC()); + return lldb::StackFrameSP(frame); + } + else + return lldb::StackFrameSP(); +} + +RegisterContextLinux * +LinuxThread::GetRegisterContext() +{ + return m_register_ap.get(); +} + +bool +LinuxThread::SaveFrameZeroState(RegisterCheckpoint &checkpoint) +{ + return false; +} + +bool +LinuxThread::RestoreSaveFrameZero(const RegisterCheckpoint &checkpoint) +{ + return false; +} + +RegisterContextLinux * +LinuxThread::CreateRegisterContextForFrame(lldb_private::StackFrame *frame) +{ + return new RegisterContextLinux_x86_64(*this, frame); +} + +bool +LinuxThread::GetRawStopReason(StopInfo *stop_info) +{ + stop_info->Clear(); + + switch (m_note) + { + default: + stop_info->SetStopReasonToNone(); + break; + + case eBreak: + stop_info->SetStopReasonWithBreakpointSiteID(m_breakpoint->GetID()); + break; + + case eTrace: + stop_info->SetStopReasonToTrace(); + } + + return true; +} + +bool +LinuxThread::WillResume(lldb::StateType resume_state) +{ + SetResumeState(resume_state); + return Thread::WillResume(resume_state); +} + +bool +LinuxThread::Resume() +{ + lldb::StateType resume_state = GetResumeState(); + ProcessMonitor &monitor = GetMonitor(); + bool status; + + switch (GetResumeState()) + { + default: + assert(false && "Unexpected state for resume!"); + status = false; + break; + + case lldb::eStateSuspended: + // FIXME: Implement process suspension. + status = false; + + case lldb::eStateRunning: + SetState(resume_state); + status = monitor.Resume(GetID()); + break; + + case lldb::eStateStepping: + SetState(resume_state); + status = GetRegisterContext()->HardwareSingleStep(true); + break; + } + + m_note = eNone; + return status; +} + +void +LinuxThread::BreakNotify() +{ + bool status; + + status = GetRegisterContext()->UpdateAfterBreakpoint(); + assert(status && "Breakpoint update failed!"); + + // With our register state restored, resolve the breakpoint object + // corresponding to our current PC. + lldb::addr_t pc = GetRegisterContext()->GetPC(); + lldb::BreakpointSiteSP bp_site = + GetProcess().GetBreakpointSiteList().FindByAddress(pc); + assert(bp_site && bp_site->ValidForThisThread(this)); + + m_note = eBreak; + m_breakpoint = bp_site; +} + +void +LinuxThread::TraceNotify() +{ + m_note = eTrace; +} + +void +LinuxThread::ExitNotify() +{ + m_note = eExit; +} Added: lldb/trunk/source/Plugins/Process/Linux/LinuxThread.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Linux/LinuxThread.h?rev=109318&view=auto ============================================================================== --- lldb/trunk/source/Plugins/Process/Linux/LinuxThread.h (added) +++ lldb/trunk/source/Plugins/Process/Linux/LinuxThread.h Fri Jul 23 21:19:04 2010 @@ -0,0 +1,89 @@ +//===-- LinuxThread.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_LinuxThread_H_ +#define liblldb_LinuxThread_H_ + +// C Includes +// C++ Includes +#include + +// Other libraries and framework includes +#include "lldb/Target/Thread.h" +#include "RegisterContextLinux.h" + +class ProcessMonitor; + +//------------------------------------------------------------------------------ +// @class LinuxThread +// @brief Abstraction of a linux process (thread). +class LinuxThread + : public lldb_private::Thread +{ +public: + LinuxThread(lldb_private::Process &process, lldb::tid_t tid); + + void + RefreshStateAfterStop(); + + bool + WillResume(lldb::StateType resume_state); + + const char * + GetInfo(); + + uint32_t + GetStackFrameCount(); + + lldb::StackFrameSP + GetStackFrameAtIndex(uint32_t idx); + + RegisterContextLinux * + GetRegisterContext(); + + bool + SaveFrameZeroState(RegisterCheckpoint &checkpoint); + + bool + RestoreSaveFrameZero(const RegisterCheckpoint &checkpoint); + + RegisterContextLinux * + CreateRegisterContextForFrame(lldb_private::StackFrame *frame); + + bool + GetRawStopReason(StopInfo *stop_info); + + //-------------------------------------------------------------------------- + // These methods form a specialized interface to linux threads. + // + bool Resume(); + + void BreakNotify(); + void TraceNotify(); + void ExitNotify(); + +private: + std::auto_ptr m_frame_ap; + std::auto_ptr m_register_ap; + + lldb::BreakpointSiteSP m_breakpoint; + + enum Notification { + eNone, + eBreak, + eTrace, + eExit + }; + + Notification m_note; + + ProcessMonitor &GetMonitor(); +}; + +#endif // #ifndef liblldb_LinuxThread_H_ Added: lldb/trunk/source/Plugins/Process/Linux/Makefile URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Linux/Makefile?rev=109318&view=auto ============================================================================== --- lldb/trunk/source/Plugins/Process/Linux/Makefile (added) +++ lldb/trunk/source/Plugins/Process/Linux/Makefile Fri Jul 23 21:19:04 2010 @@ -0,0 +1,14 @@ +##===- source/Plugins/Process/Linux/Makefile ---------------*- Makefile -*-===## +# +# The LLVM Compiler Infrastructure +# +# This file is distributed under the University of Illinois Open Source +# License. See LICENSE.TXT for details. +# +##===----------------------------------------------------------------------===## + +LLDB_LEVEL := ../../../.. +LIBRARYNAME := lldbPluginProcessLinux +BUILD_ARCHIVE = 1 + +include $(LLDB_LEVEL)/Makefile Added: lldb/trunk/source/Plugins/Process/Linux/ProcessLinux.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Linux/ProcessLinux.cpp?rev=109318&view=auto ============================================================================== --- lldb/trunk/source/Plugins/Process/Linux/ProcessLinux.cpp (added) +++ lldb/trunk/source/Plugins/Process/Linux/ProcessLinux.cpp Fri Jul 23 21:19:04 2010 @@ -0,0 +1,443 @@ +//===-- ProcessLinux.cpp ----------------------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// C Includes +// C++ Includes +// Other libraries and framework includes +#include "lldb/Core/PluginManager.h" +#include "lldb/Host/Host.h" +#include "lldb/Symbol/ObjectFile.h" +#include "lldb/Target/Target.h" + +#include "ProcessLinux.h" +#include "ProcessMonitor.h" +#include "LinuxThread.h" + +using namespace lldb; +using namespace lldb_private; + +//------------------------------------------------------------------------------ +// Static functions. + +Process* +ProcessLinux::CreateInstance(Target& target, Listener &listener) +{ + return new ProcessLinux(target, listener); +} + +void +ProcessLinux::Initialize() +{ + static bool g_initialized = false; + + if (!g_initialized) + { + PluginManager::RegisterPlugin(GetPluginNameStatic(), + GetPluginDescriptionStatic(), + CreateInstance); + g_initialized = true; + } +} + +void +ProcessLinux::Terminate() +{ +} + +const char * +ProcessLinux::GetPluginNameStatic() +{ + return "plugin.process.linux"; +} + +const char * +ProcessLinux::GetPluginDescriptionStatic() +{ + return "Process plugin for Linux"; +} + + +//------------------------------------------------------------------------------ +// Constructors and destructors. + +ProcessLinux::ProcessLinux(Target& target, Listener &listener) + : Process(target, listener), + m_monitor(NULL), + m_module(NULL) +{ + // FIXME: Putting this code in the ctor and saving the byte order in a + // member variable is a hack to avoid const qual issues in GetByteOrder. + ObjectFile *obj_file = GetTarget().GetExecutableModule()->GetObjectFile(); + m_byte_order = obj_file->GetByteOrder(); +} + +ProcessLinux::~ProcessLinux() +{ + delete m_monitor; +} + +//------------------------------------------------------------------------------ +// Process protocol. + +bool +ProcessLinux::CanDebug(Target &target) +{ + // For now we are just making sure the file exists for a given module + ModuleSP exe_module_sp(target.GetExecutableModule()); + if (exe_module_sp.get()) + return exe_module_sp->GetFileSpec().Exists(); + return false; +} + +Error +ProcessLinux::DoAttachToProcessWithID(lldb::pid_t pid) +{ + return Error(1, eErrorTypeGeneric); +} + +Error +ProcessLinux::DoLaunch(Module *module, + char const *argv[], + char const *envp[], + const char *stdin_path, + const char *stdout_path, + const char *stderr_path) +{ + Error error; + assert(m_monitor == NULL); + + SetPrivateState(eStateLaunching); + m_monitor = new ProcessMonitor(this, module, + argv, envp, + stdin_path, stdout_path, stderr_path, + error); + + m_module = module; + + if (!error.Success()) + return error; + + return error; +} + +void +ProcessLinux::DidLaunch() +{ + UpdateLoadedSections(); +} + +Error +ProcessLinux::DoResume() +{ + assert(GetPrivateState() == eStateStopped && "Bad state for DoResume!"); + + // Set our state to running. This ensures inferior threads do not post a + // state change first. + SetPrivateState(eStateRunning); + + bool did_resume = false; + uint32_t thread_count = m_thread_list.GetSize(false); + for (uint32_t i = 0; i < thread_count; ++i) + { + LinuxThread *thread = static_cast( + m_thread_list.GetThreadAtIndex(i, false).get()); + did_resume = thread->Resume() || did_resume; + } + assert(did_resume && "Process resume failed!"); + + return Error(); +} + +Error +ProcessLinux::DoHalt() +{ + return Error(1, eErrorTypeGeneric); +} + +Error +ProcessLinux::DoDetach() +{ + return Error(1, eErrorTypeGeneric); +} + +Error +ProcessLinux::DoSignal(int signal) +{ + return Error(1, eErrorTypeGeneric); +} + +Error +ProcessLinux::DoDestroy() +{ + Error error; + + if (!HasExited()) + { + // Shut down the private state thread as we will syncronize with events + // ourselves. Discard all current thread plans. + PausePrivateStateThread(); + GetThreadList().DiscardThreadPlans(); + + // Bringing the inferior into limbo will be caught by our monitor + // thread, in turn updating the process state. + if (!m_monitor->BringProcessIntoLimbo()) + { + error.SetErrorToGenericError(); + error.SetErrorString("Process termination failed."); + return error; + } + + // Wait for the event to arrive. This guaranteed to be an exit event. + StateType state; + EventSP event; + do { + state = WaitForStateChangedEventsPrivate(NULL, event); + } while (state != eStateExited); + + // Restart standard event handling and send the process the final kill, + // driving it out of limbo. + ResumePrivateStateThread(); + } + + if (kill(m_monitor->GetPID(), SIGKILL)) + error.SetErrorToErrno(); + return error; +} + +void +ProcessLinux::SendMessage(const ProcessMessage &message) +{ + Mutex::Locker lock(m_message_mutex); + m_message_queue.push(message); + + switch (message.GetKind()) + { + default: + SetPrivateState(eStateStopped); + break; + + case ProcessMessage::eExitMessage: + SetExitStatus(message.GetExitStatus(), NULL); + break; + + case ProcessMessage::eSignalMessage: + SetExitStatus(-1, NULL); + break; + } +} + +void +ProcessLinux::RefreshStateAfterStop() +{ + Mutex::Locker lock(m_message_mutex); + if (m_message_queue.empty()) + return; + + ProcessMessage &message = m_message_queue.front(); + + // Resolve the thread this message corresponds to. + lldb::tid_t tid = message.GetTID(); + LinuxThread *thread = static_cast( + GetThreadList().FindThreadByID(tid, false).get()); + + switch (message.GetKind()) + { + default: + assert(false && "Unexpected message kind!"); + break; + + case ProcessMessage::eExitMessage: + case ProcessMessage::eSignalMessage: + thread->ExitNotify(); + break; + + case ProcessMessage::eTraceMessage: + thread->TraceNotify(); + break; + + case ProcessMessage::eBreakpointMessage: + thread->BreakNotify(); + break; + } + + m_message_queue.pop(); +} + +bool +ProcessLinux::IsAlive() +{ + StateType state = GetPrivateState(); + return state != eStateExited && state != eStateInvalid; +} + +size_t +ProcessLinux::DoReadMemory(addr_t vm_addr, + void *buf, size_t size, Error &error) +{ + return m_monitor->ReadMemory(vm_addr, buf, size, error); +} + +size_t +ProcessLinux::DoWriteMemory(addr_t vm_addr, const void *buf, size_t size, + Error &error) +{ + return m_monitor->WriteMemory(vm_addr, buf, size, error); +} + +addr_t +ProcessLinux::DoAllocateMemory(size_t size, uint32_t permissions, + Error &error) +{ + return 0; +} + +addr_t +ProcessLinux::AllocateMemory(size_t size, uint32_t permissions, Error &error) +{ + return 0; +} + +Error +ProcessLinux::DoDeallocateMemory(lldb::addr_t ptr) +{ + return Error(1, eErrorTypeGeneric); +} + +size_t +ProcessLinux::GetSoftwareBreakpointTrapOpcode(BreakpointSite* bp_site) +{ + static const uint8_t g_i386_opcode[] = { 0xCC }; + + ArchSpec arch = GetTarget().GetArchitecture(); + const uint8_t *opcode = NULL; + size_t opcode_size = 0; + + switch (arch.GetGenericCPUType()) + { + default: + assert(false && "CPU type not supported!"); + break; + + case ArchSpec::eCPU_i386: + case ArchSpec::eCPU_x86_64: + opcode = g_i386_opcode; + opcode_size = sizeof(g_i386_opcode); + break; + } + + bp_site->SetTrapOpcode(opcode, opcode_size); + return opcode_size; +} + +Error +ProcessLinux::EnableBreakpoint(BreakpointSite *bp_site) +{ + return EnableSoftwareBreakpoint(bp_site); +} + +Error +ProcessLinux::DisableBreakpoint(BreakpointSite *bp_site) +{ + return DisableSoftwareBreakpoint(bp_site); +} + +uint32_t +ProcessLinux::UpdateThreadListIfNeeded() +{ + // Do not allow recursive updates. + return m_thread_list.GetSize(false); +} + +ByteOrder +ProcessLinux::GetByteOrder() const +{ + // FIXME: We should be able to extract this value directly. See comment in + // ProcessLinux(). + return m_byte_order; +} + +//------------------------------------------------------------------------------ +// ProcessInterface protocol. + +const char * +ProcessLinux::GetPluginName() +{ + return "process.linux"; +} + +const char * +ProcessLinux::GetShortPluginName() +{ + return "process.linux"; +} + +uint32_t +ProcessLinux::GetPluginVersion() +{ + return 1; +} + +void +ProcessLinux::GetPluginCommandHelp(const char *command, Stream *strm) +{ +} + +Error +ProcessLinux::ExecutePluginCommand(Args &command, Stream *strm) +{ + return Error(1, eErrorTypeGeneric); +} + +Log * +ProcessLinux::EnablePluginLogging(Stream *strm, Args &command) +{ + return NULL; +} + +//------------------------------------------------------------------------------ +// Utility functions. + +void +ProcessLinux::UpdateLoadedSections() +{ + ObjectFile *obj_file = m_module->GetObjectFile(); + SectionList *sections = obj_file->GetSectionList(); + + // FIXME: SectionList provides iterator types, but no begin/end methods. + size_t num_sections = sections->GetSize(); + for (unsigned i = 0; i < num_sections; ++i) + { + Section *section = sections->GetSectionAtIndex(i).get(); + + lldb::addr_t new_load_addr = section->GetFileAddress(); + lldb::addr_t old_load_addr = GetSectionLoadAddress(section); + + if (old_load_addr == LLDB_INVALID_ADDRESS || + old_load_addr != new_load_addr) + SectionLoaded(section, new_load_addr); + } +} + +bool +ProcessLinux::HasExited() +{ + switch (GetPrivateState()) + { + default: + break; + + case eStateUnloaded: + case eStateCrashed: + case eStateDetached: + case eStateExited: + return true; + } + + return false; +} Added: lldb/trunk/source/Plugins/Process/Linux/ProcessLinux.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Linux/ProcessLinux.h?rev=109318&view=auto ============================================================================== --- lldb/trunk/source/Plugins/Process/Linux/ProcessLinux.h (added) +++ lldb/trunk/source/Plugins/Process/Linux/ProcessLinux.h Fri Jul 23 21:19:04 2010 @@ -0,0 +1,188 @@ +//===-- ProcessLinux.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_ProcessLinux_H_ +#define liblldb_ProcessLinux_H_ + +// C Includes + +// C++ Includes +#include + +// Other libraries and framework includes +#include "lldb/Target/Process.h" +#include "ProcessMessage.h" + +class ProcessMonitor; + +class ProcessLinux : + public lldb_private::Process +{ +public: + //------------------------------------------------------------------ + // Static functions. + //------------------------------------------------------------------ + static Process* + CreateInstance(lldb_private::Target& target, + lldb_private::Listener &listener); + + static void + Initialize(); + + static void + Terminate(); + + static const char * + GetPluginNameStatic(); + + static const char * + GetPluginDescriptionStatic(); + + //------------------------------------------------------------------ + // Constructors and destructors + //------------------------------------------------------------------ + ProcessLinux(lldb_private::Target& target, + lldb_private::Listener &listener); + + virtual + ~ProcessLinux(); + + //------------------------------------------------------------------ + // Process protocol. + //------------------------------------------------------------------ + virtual bool + CanDebug(lldb_private::Target &target); + + virtual lldb_private::Error + DoAttachToProcessWithID(lldb::pid_t pid); + + virtual lldb_private::Error + DoLaunch(lldb_private::Module *module, + char const *argv[], + char const *envp[], + const char *stdin_path, + const char *stdout_path, + const char *stderr_path); + + virtual void + DidLaunch(); + + virtual lldb_private::Error + DoResume(); + + virtual lldb_private::Error + DoHalt(); + + virtual lldb_private::Error + DoDetach(); + + virtual lldb_private::Error + DoSignal(int signal); + + virtual lldb_private::Error + DoDestroy(); + + virtual void + RefreshStateAfterStop(); + + virtual bool + IsAlive(); + + virtual size_t + DoReadMemory(lldb::addr_t vm_addr, + void *buf, + size_t size, + lldb_private::Error &error); + + virtual size_t + DoWriteMemory(lldb::addr_t vm_addr, const void *buf, size_t size, + lldb_private::Error &error); + + virtual lldb::addr_t + DoAllocateMemory(size_t size, uint32_t permissions, + lldb_private::Error &error); + + lldb::addr_t + AllocateMemory(size_t size, uint32_t permissions, + lldb_private::Error &error); + + virtual lldb_private::Error + DoDeallocateMemory(lldb::addr_t ptr); + + virtual size_t + GetSoftwareBreakpointTrapOpcode(lldb_private::BreakpointSite* bp_site); + + virtual lldb_private::Error + EnableBreakpoint(lldb_private::BreakpointSite *bp_site); + + virtual lldb_private::Error + DisableBreakpoint(lldb_private::BreakpointSite *bp_site); + + virtual uint32_t + UpdateThreadListIfNeeded(); + + virtual lldb::ByteOrder + GetByteOrder() const; + + //------------------------------------------------------------------ + // PluginInterface protocol + //------------------------------------------------------------------ + virtual const char * + GetPluginName(); + + virtual const char * + GetShortPluginName(); + + virtual uint32_t + GetPluginVersion(); + + virtual void + GetPluginCommandHelp(const char *command, lldb_private::Stream *strm); + + virtual lldb_private::Error + ExecutePluginCommand(lldb_private::Args &command, + lldb_private::Stream *strm); + + virtual lldb_private::Log * + EnablePluginLogging(lldb_private::Stream *strm, + lldb_private::Args &command); + + //-------------------------------------------------------------------------- + // ProcessLinux internal API. + + /// Registers the given message with this process. + void SendMessage(const ProcessMessage &message); + + ProcessMonitor &GetMonitor() { return *m_monitor; } + +private: + /// Target byte order. + lldb::ByteOrder m_byte_order; + + /// Process monitor; + ProcessMonitor *m_monitor; + + /// The module we are executing. + lldb_private::Module *m_module; + + /// Message queue notifying this instance of inferior process state changes. + lldb_private::Mutex m_message_mutex; + std::queue m_message_queue; + + /// Updates the loaded sections provided by the executable. + /// + /// FIXME: It would probably be better to delegate this task to the + /// DynamicLoader plugin, when we have one. + void UpdateLoadedSections(); + + /// Returns true if the process has exited. + bool HasExited(); +}; + +#endif // liblldb_MacOSXProcess_H_ Added: lldb/trunk/source/Plugins/Process/Linux/ProcessMessage.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Linux/ProcessMessage.h?rev=109318&view=auto ============================================================================== --- lldb/trunk/source/Plugins/Process/Linux/ProcessMessage.h (added) +++ lldb/trunk/source/Plugins/Process/Linux/ProcessMessage.h Fri Jul 23 21:19:04 2010 @@ -0,0 +1,88 @@ +//===-- ProcessMessage.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_ProcessMessage_H_ +#define liblldb_ProcessMessage_H_ + +#include + +#include "lldb/lldb-defines.h" +#include "lldb/lldb-types.h" + +class ProcessMessage +{ +public: + + /// The type of signal this message can correspond to. + enum Kind + { + eInvalidMessage, + eExitMessage, + eLimboMessage, + eSignalMessage, + eTraceMessage, + eBreakpointMessage + }; + + ProcessMessage() + : m_kind(eInvalidMessage), + m_tid(LLDB_INVALID_PROCESS_ID), + m_data(0) { } + + Kind GetKind() const { return m_kind; } + + lldb::tid_t GetTID() const { return m_tid; } + + static ProcessMessage Exit(lldb::tid_t tid, int status) { + return ProcessMessage(tid, eExitMessage, status); + } + + static ProcessMessage Limbo(lldb::tid_t tid, int status) { + return ProcessMessage(tid, eLimboMessage, status); + } + + static ProcessMessage Signal(lldb::tid_t tid, int signum) { + return ProcessMessage(tid, eSignalMessage, signum); + } + + static ProcessMessage Trace(lldb::tid_t tid) { + return ProcessMessage(tid, eTraceMessage); + } + + static ProcessMessage Break(lldb::tid_t tid) { + return ProcessMessage(tid, eBreakpointMessage); + } + + int GetExitStatus() const { + assert(GetKind() == eExitMessage || GetKind() == eLimboMessage); + return m_data; + } + + int GetSignal() const { + assert(GetKind() == eSignalMessage); + return m_data; + } + + int GetStopStatus() const { + assert(GetKind() == eSignalMessage); + return m_data; + } + +private: + ProcessMessage(lldb::tid_t tid, Kind kind, int data = 0) + : m_kind(kind), + m_tid(tid), + m_data(data) { } + + Kind m_kind; + lldb::tid_t m_tid; + int m_data; +}; + +#endif // #ifndef liblldb_ProcessMessage_H_ Added: lldb/trunk/source/Plugins/Process/Linux/ProcessMonitor.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Linux/ProcessMonitor.cpp?rev=109318&view=auto ============================================================================== --- lldb/trunk/source/Plugins/Process/Linux/ProcessMonitor.cpp (added) +++ lldb/trunk/source/Plugins/Process/Linux/ProcessMonitor.cpp Fri Jul 23 21:19:04 2010 @@ -0,0 +1,925 @@ +//===-- ProcessMonitor.cpp ------------------------------------ -*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// C Includes +#include +#include +#include +#include +#include +#include +#include +#include + +// C++ Includes +// Other libraries and framework includes +#include "lldb/Core/Error.h" +#include "lldb/Core/Scalar.h" +#include "lldb/Host/Host.h" +#include "lldb/Target/Thread.h" +#include "lldb/Target/RegisterContext.h" +#include "lldb/Utility/PseudoTerminal.h" + +#include "LinuxThread.h" +#include "ProcessLinux.h" +#include "ProcessMonitor.h" + + +using namespace lldb_private; + +//------------------------------------------------------------------------------ +// Static implementations of ProcessMonitor::ReadMemory and +// ProcessMonitor::WriteMemory. This enables mutual recursion between these +// functions without needed to go thru the thread funnel. + +static size_t +DoReadMemory(lldb::pid_t pid, unsigned word_size, + lldb::addr_t vm_addr, void *buf, size_t size, Error &error) +{ + unsigned char *dst = static_cast(buf); + size_t bytes_read; + size_t remainder; + long data; + + for (bytes_read = 0; bytes_read < size; bytes_read += remainder) + { + errno = 0; + data = ptrace(PTRACE_PEEKDATA, pid, vm_addr, NULL); + + if (data == -1L && errno) + { + error.SetErrorToErrno(); + return bytes_read; + } + + remainder = size - bytes_read; + remainder = remainder > word_size ? word_size : remainder; + for (unsigned i = 0; i < remainder; ++i) + dst[i] = ((data >> i*8) & 0xFF); + vm_addr += word_size; + dst += word_size; + } + + return bytes_read; +} + +static size_t +DoWriteMemory(lldb::pid_t pid, unsigned word_size, + lldb::addr_t vm_addr, const void *buf, size_t size, Error &error) +{ + const unsigned char *src = static_cast(buf); + size_t bytes_written = 0; + size_t remainder; + + for (bytes_written = 0; bytes_written < size; bytes_written += remainder) + { + remainder = size - bytes_written; + remainder = remainder > word_size ? word_size : remainder; + + if (remainder == word_size) + { + unsigned long data = 0; + for (unsigned i = 0; i < word_size; ++i) + data |= (unsigned long)src[i] << i*8; + + if (ptrace(PTRACE_POKEDATA, pid, vm_addr, data)) + { + error.SetErrorToErrno(); + return bytes_written; + } + } + else + { + unsigned char buff[8]; + if (DoReadMemory(pid, word_size, vm_addr, + buff, word_size, error) != word_size) + return bytes_written; + + memcpy(buff, src, remainder); + + if (DoWriteMemory(pid, word_size, vm_addr, + buff, word_size, error) != word_size) + return bytes_written; + } + + vm_addr += word_size; + src += word_size; + } + return bytes_written; +} + + +//------------------------------------------------------------------------------ +/// @class Operation +/// @brief Represents a ProcessMonitor operation. +/// +/// Under Linux, it is not possible to ptrace() from any other thread but the +/// one that spawned or attached to the process from the start. Therefore, when +/// a ProcessMonitor is asked to deliver or change the state of an inferior +/// process the operation must be "funneled" to a specific thread to perform the +/// task. The Operation class provides an abstract base for all services the +/// ProcessMonitor must perform via the single virtual function Execute, thus +/// encapsulating the code that needs to run in the privileged context. +class Operation +{ +public: + virtual void Execute(ProcessMonitor *monitor) = 0; +}; + +//------------------------------------------------------------------------------ +/// @class ReadOperation +/// @brief Implements ProcessMonitor::ReadMemory. +class ReadOperation : public Operation +{ +public: + ReadOperation(lldb::addr_t addr, void *buff, size_t size, + Error &error, size_t &result) + : m_addr(addr), m_buff(buff), m_size(size), + m_error(error), m_result(result) + { } + + void Execute(ProcessMonitor *monitor); + +private: + lldb::addr_t m_addr; + void *m_buff; + size_t m_size; + Error &m_error; + size_t &m_result; +}; + +void +ReadOperation::Execute(ProcessMonitor *monitor) +{ + const unsigned word_size = monitor->GetProcess().GetAddressByteSize(); + lldb::pid_t pid = monitor->GetPID(); + + m_result = DoReadMemory(pid, word_size, m_addr, m_buff, m_size, m_error); +} + +//------------------------------------------------------------------------------ +/// @class ReadOperation +/// @brief Implements ProcessMonitor::WriteMemory. +class WriteOperation : public Operation +{ +public: + WriteOperation(lldb::addr_t addr, const void *buff, size_t size, + Error &error, size_t &result) + : m_addr(addr), m_buff(buff), m_size(size), + m_error(error), m_result(result) + { } + + void Execute(ProcessMonitor *monitor); + +private: + lldb::addr_t m_addr; + const void *m_buff; + size_t m_size; + Error &m_error; + size_t &m_result; +}; + +void +WriteOperation::Execute(ProcessMonitor *monitor) +{ + const unsigned word_size = monitor->GetProcess().GetAddressByteSize(); + lldb::pid_t pid = monitor->GetPID(); + + m_result = DoWriteMemory(pid, word_size, m_addr, m_buff, m_size, m_error); +} + +//------------------------------------------------------------------------------ +/// @class ReadRegOperation +/// @brief Implements ProcessMonitor::ReadRegisterValue. +class ReadRegOperation : public Operation +{ +public: + ReadRegOperation(unsigned offset, Scalar &value, bool &result) + : m_offset(offset), m_value(value), m_result(result) + { } + + void Execute(ProcessMonitor *monitor); + +private: + unsigned m_offset; + Scalar &m_value; + bool &m_result; +}; + +void +ReadRegOperation::Execute(ProcessMonitor *monitor) +{ + lldb::pid_t pid = monitor->GetPID(); + + // Set errno to zero so that we can detect a failed peek. + errno = 0; + unsigned long data = ptrace(PTRACE_PEEKUSER, pid, m_offset, NULL); + + if (data == -1UL && errno) + m_result = false; + else + { + m_value = data; + m_result = true; + } +} + +//------------------------------------------------------------------------------ +/// @class WriteRegOperation +/// @brief Implements ProcessMonitor::WriteRegisterValue. +class WriteRegOperation : public Operation +{ +public: + WriteRegOperation(unsigned offset, const Scalar &value, bool &result) + : m_offset(offset), m_value(value), m_result(result) + { } + + void Execute(ProcessMonitor *monitor); + +private: + unsigned m_offset; + const Scalar &m_value; + bool &m_result; +}; + +void +WriteRegOperation::Execute(ProcessMonitor *monitor) +{ + lldb::pid_t pid = monitor->GetPID(); + + if (ptrace(PTRACE_POKEUSER, pid, m_offset, m_value.ULong())) + m_result = false; + else + m_result = true; +} + +//------------------------------------------------------------------------------ +/// @class ResumeOperation +/// @brief Implements ProcessMonitor::Resume. +class ResumeOperation : public Operation +{ +public: + ResumeOperation(lldb::tid_t tid, bool &result) : + m_tid(tid), m_result(result) { } + + void Execute(ProcessMonitor *monitor); + +private: + lldb::tid_t m_tid; + bool &m_result; +}; + +void +ResumeOperation::Execute(ProcessMonitor *monitor) +{ + if (ptrace(PTRACE_CONT, m_tid, NULL, NULL)) + m_result = false; + else + m_result = true; +} + +//------------------------------------------------------------------------------ +/// @class ResumeOperation +/// @brief Implements ProcessMonitor::SingleStep. +class SingleStepOperation : public Operation +{ +public: + SingleStepOperation(lldb::tid_t tid, bool &result) + : m_tid(tid), m_result(result) { } + + void Execute(ProcessMonitor *monitor); + +private: + lldb::tid_t m_tid; + bool &m_result; +}; + +void +SingleStepOperation::Execute(ProcessMonitor *monitor) +{ + if (ptrace(PTRACE_SINGLESTEP, m_tid, NULL, NULL)) + m_result = false; + else + m_result = true; +} + +//------------------------------------------------------------------------------ +/// @class SiginfoOperation +/// @brief Implements ProcessMonitor::GetSignalInfo. +class SiginfoOperation : public Operation +{ +public: + SiginfoOperation(lldb::tid_t tid, void *info, bool &result) + : m_tid(tid), m_info(info), m_result(result) { } + + void Execute(ProcessMonitor *monitor); + +private: + lldb::tid_t m_tid; + void *m_info; + bool &m_result; +}; + +void +SiginfoOperation::Execute(ProcessMonitor *monitor) +{ + if (ptrace(PTRACE_GETSIGINFO, m_tid, NULL, m_info)) + m_result = false; + else + m_result = true; +} + +//------------------------------------------------------------------------------ +/// @class EventMessageOperation +/// @brief Implements ProcessMonitor::GetEventMessage. +class EventMessageOperation : public Operation +{ +public: + EventMessageOperation(lldb::tid_t tid, unsigned long *message, bool &result) + : m_tid(tid), m_message(message), m_result(result) { } + + void Execute(ProcessMonitor *monitor); + +private: + lldb::tid_t m_tid; + unsigned long *m_message; + bool &m_result; +}; + +void +EventMessageOperation::Execute(ProcessMonitor *monitor) +{ + if (ptrace(PTRACE_GETEVENTMSG, m_tid, NULL, m_message)) + m_result = false; + else + m_result = true; +} + +//------------------------------------------------------------------------------ +/// @class KillOperation +/// @brief Implements ProcessMonitor::BringProcessIntoLimbo. +class KillOperation : public Operation +{ +public: + KillOperation(bool &result) : m_result(result) { } + + void Execute(ProcessMonitor *monitor); + +private: + bool &m_result; +}; + +void +KillOperation::Execute(ProcessMonitor *monitor) +{ + lldb::pid_t pid = monitor->GetPID(); + + if (ptrace(PTRACE_KILL, pid, NULL, NULL)) + m_result = false; + else + m_result = true; + +#if 0 + // First, stop the inferior process. + if (kill(pid, SIGSTOP)) + { + m_result = false; + return; + } + + // Clear any ptrace options. When PTRACE_O_TRACEEXIT is set, a plain + // PTRACE_KILL (or any termination signal) will not truely terminate the + // inferior process. Instead, the process is left in a state of "limbo" + // allowing us to interrogate its state. However in this case we really do + // want the process gone. + if (ptrace(PTRACE_SETOPTIONS, pid, NULL, 0UL)) + { + m_result = false; + return; + } + + // Kill it. + if (ptrace(PTRACE_KILL, pid, NULL, NULL)) + m_result = false; + else + m_result = true; +#endif +} + +ProcessMonitor::LaunchArgs::LaunchArgs(ProcessMonitor *monitor, + lldb_private::Module *module, + char const **argv, + char const **envp, + const char *stdin_path, + const char *stdout_path, + const char *stderr_path) + : m_monitor(monitor), + m_module(module), + m_argv(argv), + m_envp(envp), + m_stdin_path(stdin_path), + m_stdout_path(stdout_path), + m_stderr_path(stderr_path) +{ + sem_init(&m_semaphore, 0, 0); +} + +ProcessMonitor::LaunchArgs::~LaunchArgs() +{ + sem_destroy(&m_semaphore); +} + +//------------------------------------------------------------------------------ +/// The basic design of the ProcessMonitor is built around two threads. +/// +/// One thread (@see SignalThread) simply blocks on a call to waitpid() looking +/// for changes in the debugee state. When a change is detected a +/// ProcessMessage is sent to the associated ProcessLinux instance. This thread +/// "drives" state changes in the debugger. +/// +/// The second thread (@see OperationThread) is responsible for two things 1) +/// lauching or attaching to the inferior process, and then 2) servicing +/// operations such as register reads/writes, stepping, etc. See the comments +/// on the Operation class for more info as to why this is needed. +ProcessMonitor::ProcessMonitor(ProcessLinux *process, + Module *module, + const char *argv[], + const char *envp[], + const char *stdin_path, + const char *stdout_path, + const char *stderr_path, + lldb_private::Error &error) + : m_process(process), + m_operation_thread(LLDB_INVALID_HOST_THREAD), + m_pid(LLDB_INVALID_PROCESS_ID), + m_terminal_fd(-1), + m_monitor_handle(0), + m_client_fd(-1), + m_server_fd(-1) +{ + LaunchArgs args(this, module, argv, envp, + stdin_path, stdout_path, stderr_path); + + // Server/client descriptors. + if (!EnableIPC()) + { + error.SetErrorToGenericError(); + error.SetErrorString("Monitor failed to initialize."); + } + + StartOperationThread(&args, error); + if (!error.Success()) + return; + +WAIT_AGAIN: + // Wait for the operation thread to initialize. + if (sem_wait(&args.m_semaphore)) + { + if (errno == EINTR) + goto WAIT_AGAIN; + else + { + error.SetErrorToErrno(); + return; + } + } + + // Check that the launch was a success. + if (!args.m_error.Success()) + { + StopOperationThread(); + error = args.m_error; + return; + } + + // Finally, start monitoring the child process for change in state. + if (!(m_monitor_handle = Host::StartMonitoringChildProcess( + ProcessMonitor::MonitorCallback, this, GetPID(), true))) + { + error.SetErrorToGenericError(); + error.SetErrorString("Process launch failed."); + return; + } +} + +ProcessMonitor::~ProcessMonitor() +{ + Host::StopMonitoringChildProcess(m_monitor_handle); + StopOperationThread(); + + close(m_terminal_fd); + close(m_client_fd); + close(m_server_fd); +} + +//------------------------------------------------------------------------------ +// Thread setup and tear down. +void +ProcessMonitor::StartOperationThread(LaunchArgs *args, Error &error) +{ + static const char *g_thread_name = "lldb.process.linux.operation"; + + if (m_operation_thread != LLDB_INVALID_HOST_THREAD) + return; + + m_operation_thread = + Host::ThreadCreate(g_thread_name, OperationThread, args, &error); +} + +void +ProcessMonitor::StopOperationThread() +{ + lldb::thread_result_t result; + + if (m_operation_thread == LLDB_INVALID_HOST_THREAD) + return; + + Host::ThreadCancel(m_operation_thread, NULL); + Host::ThreadJoin(m_operation_thread, &result, NULL); +} + +void * +ProcessMonitor::OperationThread(void *arg) +{ + LaunchArgs *args = static_cast(arg); + + if (!Launch(args)) + return NULL; + + ServeOperation(args->m_monitor); + return NULL; +} + +bool +ProcessMonitor::Launch(LaunchArgs *args) +{ + ProcessMonitor *monitor = args->m_monitor; + ProcessLinux &process = monitor->GetProcess(); + const char **argv = args->m_argv; + const char **envp = args->m_envp; + const char *stdin_path = args->m_stdin_path; + const char *stdout_path = args->m_stdout_path; + const char *stderr_path = args->m_stderr_path; + + lldb_utility::PseudoTerminal terminal; + const size_t err_len = 1024; + char err_str[err_len]; + lldb::pid_t pid; + + lldb::ThreadSP inferior; + + // Pseudo terminal setup. + if (!terminal.OpenFirstAvailableMaster(O_RDWR | O_NOCTTY, err_str, err_len)) + { + args->m_error.SetErrorToGenericError(); + args->m_error.SetErrorString("Could not open controlling TTY."); + goto FINISH; + } + + if ((pid = terminal.Fork(err_str, err_len)) < 0) + { + args->m_error.SetErrorToGenericError(); + args->m_error.SetErrorString("Process fork failed."); + goto FINISH; + } + + // Child process. + if (pid == 0) + { + // Trace this process. + ptrace(PTRACE_TRACEME, 0, NULL, NULL); + + // Do not inherit setgid powers. + setgid(getgid()); + + // Let us have our own process group. + setpgid(0, 0); + + // Dup file discriptors if needed. + // + // FIXME: If two or more of the paths are the same we needlessly open + // the same file multiple times. + if (stdin_path != NULL && stdin_path[0]) + if (!DupDescriptor(stdin_path, STDIN_FILENO, O_RDONLY | O_CREAT)) + exit(1); + + if (stdout_path != NULL && stdout_path[0]) + if (!DupDescriptor(stdout_path, STDOUT_FILENO, O_WRONLY | O_CREAT)) + exit(1); + + if (stderr_path != NULL && stderr_path[0]) + if (!DupDescriptor(stderr_path, STDOUT_FILENO, O_WRONLY | O_CREAT)) + exit(1); + + // Execute. We should never return. + execve(argv[0], + const_cast(argv), + const_cast(envp)); + exit(-1); + } + + // Wait for the child process to to trap on its call to execve. + int status; + if ((status = waitpid(pid, NULL, 0)) < 0) + { + // execve likely failed for some reason. + args->m_error.SetErrorToErrno(); + goto FINISH; + } + assert(status == pid && "Could not sync with inferior process."); + + // Have the child raise an event on exit. This is used to keep the child in + // limbo until it is destroyed. + if (ptrace(PTRACE_SETOPTIONS, pid, NULL, PTRACE_O_TRACEEXIT) < 0) + { + args->m_error.SetErrorToErrno(); + goto FINISH; + } + + // Release the master terminal descriptor and pass it off to the + // ProcessMonitor instance. Similarly stash the inferior pid. + monitor->m_terminal_fd = terminal.ReleaseMasterFileDescriptor(); + monitor->m_pid = pid; + + // Update the process thread list with this new thread and mark it as + // current. + inferior.reset(new LinuxThread(process, pid)); + process.GetThreadList().AddThread(inferior); + process.GetThreadList().SetCurrentThreadByID(pid); + + // Let our process instance know the thread has stopped. + process.SendMessage(ProcessMessage::Trace(pid)); + +FINISH: + // Sync with our parent thread now that the launch operation is complete. + sem_post(&args->m_semaphore); + return args->m_error.Success(); +} + +bool +ProcessMonitor::EnableIPC() +{ + int fd[2]; + + if (socketpair(AF_UNIX, SOCK_STREAM, 0, fd)) + return false; + + m_client_fd = fd[0]; + m_server_fd = fd[1]; + return true; +} + +bool +ProcessMonitor::MonitorCallback(void *callback_baton, + lldb::pid_t pid, + int signal, + int status) +{ + ProcessMessage message; + ProcessMonitor *monitor = static_cast(callback_baton); + ProcessLinux *process = monitor->m_process; + + switch (signal) + { + case 0: + // No signal. The child has exited normally. + message = ProcessMessage::Exit(pid, status); + break; + + case SIGTRAP: + // Specially handle SIGTRAP and form the appropriate message. + message = MonitorSIGTRAP(monitor, pid); + break; + + default: + // For all other signals simply notify the process instance. Note that + // the process exit status is set when the signal resulted in + // termination. + // + // FIXME: We need a specialized message to inform the process instance + // about "crashes". + if (status) + message = ProcessMessage::Exit(pid, status); + else + message = ProcessMessage::Signal(pid, signal); + } + + process->SendMessage(message); + bool stop_monitoring = message.GetKind() == ProcessMessage::eExitMessage; + return stop_monitoring; +} + +ProcessMessage +ProcessMonitor::MonitorSIGTRAP(ProcessMonitor *monitor, lldb::pid_t pid) +{ + siginfo_t info; + ProcessMessage message; + bool status; + + status = monitor->GetSignalInfo(pid, &info); + assert(status && "GetSignalInfo failed!"); + + assert(info.si_signo == SIGTRAP && "Unexpected child signal!"); + + switch (info.si_code) + { + default: + assert(false && "Unexpected SIGTRAP code!"); + break; + + case (SIGTRAP | (PTRACE_EVENT_EXIT << 8)): + { + // The inferior process is about to exit. Maintain the process in a + // state of "limbo" until we are explicitly commanded to detach, + // destroy, resume, etc. + unsigned long data = 0; + if (!monitor->GetEventMessage(pid, &data)) + data = -1; + message = ProcessMessage::Exit(pid, (data >> 8)); + break; + } + + case 0: + case TRAP_TRACE: + message = ProcessMessage::Trace(pid); + break; + + case SI_KERNEL: + case TRAP_BRKPT: + message = ProcessMessage::Break(pid); + break; + } + + return message; +} + +void +ProcessMonitor::ServeOperation(ProcessMonitor *monitor) +{ + int status; + pollfd fdset; + + fdset.fd = monitor->m_server_fd; + fdset.events = POLLIN | POLLPRI; + fdset.revents = 0; + + for (;;) + { + if ((status = poll(&fdset, 1, -1)) < 0) + { + switch (errno) + { + default: + assert(false && "Unexpected poll() failure!"); + continue; + + case EINTR: continue; // Just poll again. + case EBADF: return; // Connection terminated. + } + } + + assert(status == 1 && "Too many descriptors!"); + + if (fdset.revents & POLLIN) + { + Operation *op = NULL; + + READ_AGAIN: + if ((status = read(fdset.fd, &op, sizeof(op))) < 0) + { + // There is only one acceptable failure. + assert(errno == EINTR); + goto READ_AGAIN; + } + + assert(status == sizeof(op)); + op->Execute(monitor); + write(fdset.fd, &op, sizeof(op)); + } + } +} + +void +ProcessMonitor::DoOperation(Operation *op) +{ + int status; + Operation *ack = NULL; + Mutex::Locker lock(m_server_mutex); + + // FIXME: Do proper error checking here. + write(m_client_fd, &op, sizeof(op)); + +READ_AGAIN: + if ((status = read(m_client_fd, &ack, sizeof(ack))) < 0) + { + // If interrupted by a signal handler try again. Otherwise the monitor + // thread probably died and we have a stale file descriptor -- abort the + // operation. + if (errno == EINTR) + goto READ_AGAIN; + return; + } + + assert(status == sizeof(ack)); + assert(ack == op && "Invalid monitor thread response!"); +} + +size_t +ProcessMonitor::ReadMemory(lldb::addr_t vm_addr, void *buf, size_t size, + Error &error) +{ + size_t result; + ReadOperation op(vm_addr, buf, size, error, result); + DoOperation(&op); + return result; +} + +size_t +ProcessMonitor::WriteMemory(lldb::addr_t vm_addr, const void *buf, size_t size, + lldb_private::Error &error) +{ + size_t result; + WriteOperation op(vm_addr, buf, size, error, result); + DoOperation(&op); + return result; +} + +bool +ProcessMonitor::ReadRegisterValue(unsigned offset, Scalar &value) +{ + bool result; + ReadRegOperation op(offset, value, result); + DoOperation(&op); + return result; +} + +bool +ProcessMonitor::WriteRegisterValue(unsigned offset, const Scalar &value) +{ + bool result; + WriteRegOperation op(offset, value, result); + DoOperation(&op); + return result; +} + +bool +ProcessMonitor::Resume(lldb::tid_t tid) +{ + bool result; + ResumeOperation op(tid, result); + DoOperation(&op); + return result; +} + +bool +ProcessMonitor::SingleStep(lldb::tid_t tid) +{ + bool result; + SingleStepOperation op(tid, result); + DoOperation(&op); + return result; +} + +bool +ProcessMonitor::BringProcessIntoLimbo() +{ + bool result; + KillOperation op(result); + DoOperation(&op); + return result; +} + +bool +ProcessMonitor::GetSignalInfo(lldb::tid_t tid, void *siginfo) +{ + bool result; + SiginfoOperation op(tid, siginfo, result); + DoOperation(&op); + return result; +} + +bool +ProcessMonitor::GetEventMessage(lldb::tid_t tid, unsigned long *message) +{ + bool result; + EventMessageOperation op(tid, message, result); + DoOperation(&op); + return result; +} + +bool +ProcessMonitor::DupDescriptor(const char *path, int fd, int flags) +{ + int target_fd = open(path, flags); + + if (target_fd == -1) + return false; + + return (dup2(fd, target_fd) == -1) ? false : true; +} Added: lldb/trunk/source/Plugins/Process/Linux/ProcessMonitor.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Linux/ProcessMonitor.h?rev=109318&view=auto ============================================================================== --- lldb/trunk/source/Plugins/Process/Linux/ProcessMonitor.h (added) +++ lldb/trunk/source/Plugins/Process/Linux/ProcessMonitor.h Fri Jul 23 21:19:04 2010 @@ -0,0 +1,208 @@ +//===-- ProcessMonitor.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_ProcessMonitor_H_ +#define liblldb_ProcessMonitor_H_ + +// C Includes +#include + +// C++ Includes +// Other libraries and framework includes +#include "lldb/lldb-types.h" +#include "lldb/Host/Mutex.h" + +namespace lldb_private +{ +class Error; +class Module; +class Scalar; +} // End lldb_private namespace. + +class ProcessLinux; +class Operation; + +/// @class ProcessMonitor +/// @brief Manages communication with the inferior (debugee) process. +/// +/// Upon construction, this class prepares and launches an inferior process for +/// debugging. +/// +/// Changes in the inferior process state are propagated to the associated +/// ProcessLinux instance by calling ProcessLinux::SendMessage with the +/// appropriate ProcessMessage events. +/// +/// A purposely minimal set of operations are provided to interrogate and change +/// the inferior process state. +class ProcessMonitor +{ +public: + + /// Launches an inferior process ready for debugging. Forms the + /// implementation of Process::DoLaunch. + ProcessMonitor(ProcessLinux *process, + lldb_private::Module *module, + char const *argv[], + char const *envp[], + const char *stdin_path, + const char *stdout_path, + const char *stderr_path, + lldb_private::Error &error); + + ~ProcessMonitor(); + + /// Provides the process number of debugee. + lldb::pid_t + GetPID() const { return m_pid; } + + /// Returns the process associated with this ProcessMonitor. + ProcessLinux & + GetProcess() { return *m_process; } + + /// Returns a file descriptor to the controling terminal of the inferior + /// process. + /// + /// Reads from this file descriptor yeild both the standard output and + /// standard error of this debugee. Even if stderr and stdout were + /// redirected on launch it may still happen that data is available on this + /// descriptor (if the inferior process opens /dev/tty, for example). + /// + /// If this monitor was attached to an existing process this method returns + /// -1. + int + GetTerminalFD() const { return m_terminal_fd; } + + /// Reads @p size bytes from address @vm_adder in the inferior process + /// address space. + /// + /// This method is provided to implement Process::DoReadMemory. + size_t + ReadMemory(lldb::addr_t vm_addr, void *buf, size_t size, + lldb_private::Error &error); + + /// Writes @p size bytes from address @p vm_adder in the inferior process + /// address space. + /// + /// This method is provided to implement Process::DoWriteMemory. + size_t + WriteMemory(lldb::addr_t vm_addr, const void *buf, size_t size, + lldb_private::Error &error); + + /// Reads the contents from the register identified by the given (architecture + /// dependent) offset. + /// + /// This method is provided for use by RegisterContextLinux derivatives. + bool + ReadRegisterValue(unsigned offset, lldb_private::Scalar &value); + + /// Writes the given value to the register identified by the given + /// (architecture dependent) offset. + /// + /// This method is provided for use by RegisterContextLinux derivatives. + bool + WriteRegisterValue(unsigned offset, const lldb_private::Scalar &value); + + /// Writes a siginfo_t structure corresponding to the given thread ID to the + /// memory region pointed to by @p siginfo. + bool + GetSignalInfo(lldb::tid_t tid, void *siginfo); + + /// Writes the raw event message code (vis-a-vis PTRACE_GETEVENTMSG) + /// corresponding to the given thread IDto the memory pointed to by @p + /// message. + bool + GetEventMessage(lldb::tid_t tid, unsigned long *message); + + /// Resumes the given thread. + bool + Resume(lldb::tid_t tid); + + /// Single steps the given thread. + bool + SingleStep(lldb::tid_t tid); + + /// Sends the inferior process a PTRACE_KILL signal. The inferior will + /// still exists and can be interrogated. Once resumed it will exit as + /// though it received a SIGKILL. + bool + BringProcessIntoLimbo(); + +private: + ProcessLinux *m_process; + + lldb::thread_t m_operation_thread; + lldb::pid_t m_pid; + int m_terminal_fd; + + uint32_t m_monitor_handle; + + lldb_private::Mutex m_server_mutex; + int m_client_fd; + int m_server_fd; + + /// @class LauchArgs + /// + /// @brief Simple structure to pass data to the thread responsible for + /// launching a child process. + struct LaunchArgs + { + LaunchArgs(ProcessMonitor *monitor, + lldb_private::Module *module, + char const **argv, + char const **envp, + const char *stdin_path, + const char *stdout_path, + const char *stderr_path); + + ~LaunchArgs(); + + ProcessMonitor *m_monitor; // The monitor performing the launch. + lldb_private::Module *m_module; // The executable image to launch. + char const **m_argv; // Process arguments. + char const **m_envp; // Process environment. + const char *m_stdin_path; // Redirect stdin or NULL. + const char *m_stdout_path; // Redirect stdout or NULL. + const char *m_stderr_path; // Redirect stderr or NULL. + sem_t m_semaphore; // Posted to once launch complete. + lldb_private::Error m_error; // Set if process launch failed. + }; + + void + StartOperationThread(LaunchArgs *args, lldb_private::Error &error); + + void + StopOperationThread(); + + static void * + OperationThread(void *arg); + + static bool + Launch(LaunchArgs *args); + + bool + EnableIPC(); + + static void + ServeOperation(ProcessMonitor *monitor); + + static bool + DupDescriptor(const char *path, int fd, int flags); + + static bool + MonitorCallback(void *callback_baton, + lldb::pid_t pid, int signal, int status); + + static ProcessMessage + MonitorSIGTRAP(ProcessMonitor *monitor, lldb::pid_t pid); + + void + DoOperation(Operation *op); +}; + +#endif // #ifndef liblldb_ProcessMonitor_H_ Added: lldb/trunk/source/Plugins/Process/Linux/RegisterContextLinux.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Linux/RegisterContextLinux.h?rev=109318&view=auto ============================================================================== --- lldb/trunk/source/Plugins/Process/Linux/RegisterContextLinux.h (added) +++ lldb/trunk/source/Plugins/Process/Linux/RegisterContextLinux.h Fri Jul 23 21:19:04 2010 @@ -0,0 +1,40 @@ +//===-- RegisterContext_x86_64.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_RegisterContextLinux_H_ +#define liblldb_RegisterContextLinux_H_ + +// C Includes +// C++ Includes +// Other libraries and framework includes +#include "lldb/Target/RegisterContext.h" + +//------------------------------------------------------------------------------ +/// @class RegisterContextLinux +/// +/// @brief Extends RegisterClass with a few virtual operations useful on Linux. +class RegisterContextLinux + : public lldb_private::RegisterContext +{ +public: + RegisterContextLinux(lldb_private::Thread &thread, + lldb_private::StackFrame *frame) + : RegisterContext(thread, frame) { } + + /// Updates the register state of the associated thread after hitting a + /// breakpoint (if that make sense for the architecture). Default + /// implementation simply returns true for architectures which do not + /// require any upadte. + /// + /// @return + /// True if the operation succeeded and false otherwise. + virtual bool UpdateAfterBreakpoint() { return true; } +}; + +#endif // #ifndef liblldb_RegisterContextLinux_H_ Added: lldb/trunk/source/Plugins/Process/Linux/RegisterContextLinux_x86_64.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Linux/RegisterContextLinux_x86_64.cpp?rev=109318&view=auto ============================================================================== --- lldb/trunk/source/Plugins/Process/Linux/RegisterContextLinux_x86_64.cpp (added) +++ lldb/trunk/source/Plugins/Process/Linux/RegisterContextLinux_x86_64.cpp Fri Jul 23 21:19:04 2010 @@ -0,0 +1,653 @@ +//===-- RegisterContextLinux_x86_64.cpp -------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#include +#include +#include + +#include "lldb/Core/Scalar.h" +#include "lldb/Target/Thread.h" + +#include "ProcessLinux.h" +#include "ProcessMonitor.h" +#include "RegisterContextLinux_x86_64.h" + +using namespace lldb_private; +using namespace lldb; + +// Internal codes for all x86_64 registers. +enum +{ + gpr_rax = 0, + gpr_rbx, + gpr_rcx, + gpr_rdx, + gpr_rdi, + gpr_rsi, + gpr_rbp, + gpr_rsp, + gpr_r8, + gpr_r9, + gpr_r10, + gpr_r11, + gpr_r12, + gpr_r13, + gpr_r14, + gpr_r15, + gpr_rip, + gpr_rflags, + gpr_cs, + gpr_fs, + gpr_gs, + gpr_ss, + gpr_ds, + gpr_es, + + // Number of GPR's. + k_num_gpr_registers, + + fpu_fcw = k_num_gpr_registers, + fpu_fsw, + fpu_ftw, + fpu_fop, + fpu_ip, + fpu_cs, + fpu_dp, + fpu_ds, + fpu_mxcsr, + fpu_mxcsrmask, + fpu_stmm0, + fpu_stmm1, + fpu_stmm2, + fpu_stmm3, + fpu_stmm4, + fpu_stmm5, + fpu_stmm6, + fpu_stmm7, + fpu_xmm0, + fpu_xmm1, + fpu_xmm2, + fpu_xmm3, + fpu_xmm4, + fpu_xmm5, + fpu_xmm6, + fpu_xmm7, + fpu_xmm8, + fpu_xmm9, + fpu_xmm10, + fpu_xmm11, + fpu_xmm12, + fpu_xmm13, + fpu_xmm14, + fpu_xmm15, + + // Total number of registers. + k_num_registers, + + // Number of FPR's. + k_num_fpu_registers = k_num_registers - k_num_gpr_registers +}; + +// Number of register sets provided by this context. +enum +{ + k_num_register_sets = 2 +}; + +enum gcc_dwarf_regnums +{ + gcc_dwarf_gpr_rax = 0, + gcc_dwarf_gpr_rdx, + gcc_dwarf_gpr_rcx, + gcc_dwarf_gpr_rbx, + gcc_dwarf_gpr_rsi, + gcc_dwarf_gpr_rdi, + gcc_dwarf_gpr_rbp, + gcc_dwarf_gpr_rsp, + gcc_dwarf_gpr_r8, + gcc_dwarf_gpr_r9, + gcc_dwarf_gpr_r10, + gcc_dwarf_gpr_r11, + gcc_dwarf_gpr_r12, + gcc_dwarf_gpr_r13, + gcc_dwarf_gpr_r14, + gcc_dwarf_gpr_r15, + gcc_dwarf_gpr_rip, + gcc_dwarf_fpu_xmm0, + gcc_dwarf_fpu_xmm1, + gcc_dwarf_fpu_xmm2, + gcc_dwarf_fpu_xmm3, + gcc_dwarf_fpu_xmm4, + gcc_dwarf_fpu_xmm5, + gcc_dwarf_fpu_xmm6, + gcc_dwarf_fpu_xmm7, + gcc_dwarf_fpu_xmm8, + gcc_dwarf_fpu_xmm9, + gcc_dwarf_fpu_xmm10, + gcc_dwarf_fpu_xmm11, + gcc_dwarf_fpu_xmm12, + gcc_dwarf_fpu_xmm13, + gcc_dwarf_fpu_xmm14, + gcc_dwarf_fpu_xmm15, + gcc_dwarf_fpu_stmm0, + gcc_dwarf_fpu_stmm1, + gcc_dwarf_fpu_stmm2, + gcc_dwarf_fpu_stmm3, + gcc_dwarf_fpu_stmm4, + gcc_dwarf_fpu_stmm5, + gcc_dwarf_fpu_stmm6, + gcc_dwarf_fpu_stmm7 +}; + +enum gdb_regnums +{ + gdb_gpr_rax = 0, + gdb_gpr_rbx = 1, + gdb_gpr_rcx = 2, + gdb_gpr_rdx = 3, + gdb_gpr_rsi = 4, + gdb_gpr_rdi = 5, + gdb_gpr_rbp = 6, + gdb_gpr_rsp = 7, + gdb_gpr_r8 = 8, + gdb_gpr_r9 = 9, + gdb_gpr_r10 = 10, + gdb_gpr_r11 = 11, + gdb_gpr_r12 = 12, + gdb_gpr_r13 = 13, + gdb_gpr_r14 = 14, + gdb_gpr_r15 = 15, + gdb_gpr_rip = 16, + gdb_gpr_rflags = 17, + gdb_gpr_cs = 18, + gdb_gpr_ss = 19, + gdb_gpr_ds = 20, + gdb_gpr_es = 21, + gdb_gpr_fs = 22, + gdb_gpr_gs = 23, + gdb_fpu_stmm0 = 24, + gdb_fpu_stmm1 = 25, + gdb_fpu_stmm2 = 26, + gdb_fpu_stmm3 = 27, + gdb_fpu_stmm4 = 28, + gdb_fpu_stmm5 = 29, + gdb_fpu_stmm6 = 30, + gdb_fpu_stmm7 = 31, + gdb_fpu_fcw = 32, + gdb_fpu_fsw = 33, + gdb_fpu_ftw = 34, + gdb_fpu_cs = 35, + gdb_fpu_ip = 36, + gdb_fpu_ds = 37, + gdb_fpu_dp = 38, + gdb_fpu_fop = 39, + gdb_fpu_xmm0 = 40, + gdb_fpu_xmm1 = 41, + gdb_fpu_xmm2 = 42, + gdb_fpu_xmm3 = 43, + gdb_fpu_xmm4 = 44, + gdb_fpu_xmm5 = 45, + gdb_fpu_xmm6 = 46, + gdb_fpu_xmm7 = 47, + gdb_fpu_xmm8 = 48, + gdb_fpu_xmm9 = 49, + gdb_fpu_xmm10 = 50, + gdb_fpu_xmm11 = 51, + gdb_fpu_xmm12 = 52, + gdb_fpu_xmm13 = 53, + gdb_fpu_xmm14 = 54, + gdb_fpu_xmm15 = 55, + gdb_fpu_mxcsr = 56 +}; + +static const +uint32_t g_gpr_regnums[k_num_gpr_registers] = +{ + gpr_rax, + gpr_rbx, + gpr_rcx, + gpr_rdx, + gpr_rdi, + gpr_rsi, + gpr_rbp, + gpr_rsp, + gpr_r8, + gpr_r9, + gpr_r10, + gpr_r11, + gpr_r12, + gpr_r13, + gpr_r14, + gpr_r15, + gpr_rip, + gpr_rflags, + gpr_cs, + gpr_fs, + gpr_gs, + gpr_ss, + gpr_ds, + gpr_es +}; + +static const uint32_t +g_fpu_regnums[k_num_fpu_registers] = +{ + fpu_fcw, + fpu_fsw, + fpu_ftw, + fpu_fop, + fpu_ip, + fpu_cs, + fpu_dp, + fpu_ds, + fpu_mxcsr, + fpu_mxcsrmask, + fpu_stmm0, + fpu_stmm1, + fpu_stmm2, + fpu_stmm3, + fpu_stmm4, + fpu_stmm5, + fpu_stmm6, + fpu_stmm7, + fpu_xmm0, + fpu_xmm1, + fpu_xmm2, + fpu_xmm3, + fpu_xmm4, + fpu_xmm5, + fpu_xmm6, + fpu_xmm7, + fpu_xmm8, + fpu_xmm9, + fpu_xmm10, + fpu_xmm11, + fpu_xmm12, + fpu_xmm13, + fpu_xmm14, + fpu_xmm15 +}; + +static const RegisterSet +g_reg_sets[k_num_register_sets] = +{ + { "General Purpose Registers", "gpr", k_num_gpr_registers, g_gpr_regnums }, + { "Floating Point Registers", "fpu", k_num_fpu_registers, g_fpu_regnums } +}; + +// Computes the offset of the given GPR in the user data area. +#define GPR_OFFSET(regname) \ + (offsetof(RegisterContextLinux_x86_64::UserArea, regs) + \ + offsetof(RegisterContextLinux_x86_64::GPR, regname)) + +// Computes the offset of the given FPR in the user data area. +#define FPR_OFFSET(regname) \ + (offsetof(RegisterContextLinux_x86_64::UserArea, i387) + \ + offsetof(RegisterContextLinux_x86_64::FPU, regname)) + +// Number of bytes needed to represet a GPR. +#define GPR_SIZE(reg) sizeof(((RegisterContextLinux_x86_64::GPR*)NULL)->reg) + +// Number of bytes needed to represet a FPR. +#define FPR_SIZE(reg) sizeof(((RegisterContextLinux_x86_64::FPU*)NULL)->reg) + +// Number of bytes needed to represet the i'th FP register. +#define FP_SIZE sizeof(((RegisterContextLinux_x86_64::MMSReg*)NULL)->bytes) + +// Number of bytes needed to represet an XMM register. +#define XMM_SIZE sizeof(RegisterContextLinux_x86_64::XMMReg) + +#define DEFINE_GPR(reg, alt, kind1, kind2, kind3, kind4) \ + { #reg, alt, GPR_SIZE(reg), GPR_OFFSET(reg), eEncodingUint, \ + eFormatHex, gpr_##reg, { kind1, kind2, kind3, kind4 } } + +#define DEFINE_FPR(reg, kind1, kind2, kind3, kind4) \ + { #reg, NULL, FPR_SIZE(reg), FPR_OFFSET(reg), eEncodingUint, \ + eFormatHex, fpu_##reg, { kind1, kind2, kind3, kind4 } } + +#define DEFINE_FP(reg, i) \ + { #reg#i, NULL, FP_SIZE, FPR_OFFSET(reg[i]), eEncodingVector, \ + eFormatVectorOfUInt8, fpu_##reg##i, \ + { gcc_dwarf_fpu_##reg##i, gcc_dwarf_fpu_##reg##i, \ + LLDB_INVALID_REGNUM, gdb_fpu_##reg##i } } + +#define DEFINE_XMM(reg, i) \ + { #reg#i, NULL, XMM_SIZE, FPR_OFFSET(reg[i]), eEncodingVector, \ + eFormatVectorOfUInt8, fpu_##reg##i, \ + { gcc_dwarf_fpu_##reg##i, gcc_dwarf_fpu_##reg##i, \ + LLDB_INVALID_REGNUM, gdb_fpu_##reg##i } } + +static RegisterInfo +g_register_infos[k_num_registers] = +{ + // General purpose registers. + DEFINE_GPR(rax, NULL, gcc_dwarf_gpr_rax, gcc_dwarf_gpr_rax, LLDB_INVALID_REGNUM, gdb_gpr_rax), + DEFINE_GPR(rbx, NULL, gcc_dwarf_gpr_rbx, gcc_dwarf_gpr_rbx, LLDB_INVALID_REGNUM, gdb_gpr_rbx), + DEFINE_GPR(rcx, NULL, gcc_dwarf_gpr_rcx, gcc_dwarf_gpr_rcx, LLDB_INVALID_REGNUM, gdb_gpr_rcx), + DEFINE_GPR(rdx, NULL, gcc_dwarf_gpr_rdx, gcc_dwarf_gpr_rdx, LLDB_INVALID_REGNUM, gdb_gpr_rdx), + DEFINE_GPR(rdi, NULL, gcc_dwarf_gpr_rdi, gcc_dwarf_gpr_rdi, LLDB_INVALID_REGNUM, gdb_gpr_rdi), + DEFINE_GPR(rsi, NULL, gcc_dwarf_gpr_rsi, gcc_dwarf_gpr_rsi, LLDB_INVALID_REGNUM, gdb_gpr_rsi), + DEFINE_GPR(rbp, "fp", gcc_dwarf_gpr_rbp, gcc_dwarf_gpr_rbp, LLDB_REGNUM_GENERIC_FP, gdb_gpr_rbp), + DEFINE_GPR(rsp, "sp", gcc_dwarf_gpr_rsp, gcc_dwarf_gpr_rsp, LLDB_REGNUM_GENERIC_SP, gdb_gpr_rsp), + DEFINE_GPR(r8, NULL, gcc_dwarf_gpr_r8, gcc_dwarf_gpr_r8, LLDB_INVALID_REGNUM, gdb_gpr_r8), + DEFINE_GPR(r9, NULL, gcc_dwarf_gpr_r9, gcc_dwarf_gpr_r9, LLDB_INVALID_REGNUM, gdb_gpr_r9), + DEFINE_GPR(r10, NULL, gcc_dwarf_gpr_r10, gcc_dwarf_gpr_r10, LLDB_INVALID_REGNUM, gdb_gpr_r10), + DEFINE_GPR(r11, NULL, gcc_dwarf_gpr_r11, gcc_dwarf_gpr_r11, LLDB_INVALID_REGNUM, gdb_gpr_r11), + DEFINE_GPR(r12, NULL, gcc_dwarf_gpr_r12, gcc_dwarf_gpr_r12, LLDB_INVALID_REGNUM, gdb_gpr_r12), + DEFINE_GPR(r13, NULL, gcc_dwarf_gpr_r13, gcc_dwarf_gpr_r13, LLDB_INVALID_REGNUM, gdb_gpr_r13), + DEFINE_GPR(r14, NULL, gcc_dwarf_gpr_r14, gcc_dwarf_gpr_r14, LLDB_INVALID_REGNUM, gdb_gpr_r14), + DEFINE_GPR(r15, NULL, gcc_dwarf_gpr_r15, gcc_dwarf_gpr_r15, LLDB_INVALID_REGNUM, gdb_gpr_r15), + DEFINE_GPR(rip, "pc", gcc_dwarf_gpr_rip, gcc_dwarf_gpr_rip, LLDB_REGNUM_GENERIC_PC, gdb_gpr_rip), + DEFINE_GPR(rflags, "flags", LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_REGNUM_GENERIC_FLAGS, gdb_gpr_rflags), + DEFINE_GPR(cs, NULL, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, gdb_gpr_cs), + DEFINE_GPR(fs, NULL, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, gdb_gpr_fs), + DEFINE_GPR(gs, NULL, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, gdb_gpr_gs), + DEFINE_GPR(ss, NULL, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, gdb_gpr_ss), + DEFINE_GPR(ds, NULL, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, gdb_gpr_ds), + DEFINE_GPR(es, NULL, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, gdb_gpr_es), + + // i387 Floating point registers. + DEFINE_FPR(fcw, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, gdb_fpu_fcw), + DEFINE_FPR(fsw, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, gdb_fpu_fsw), + DEFINE_FPR(ftw, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, gdb_fpu_ftw), + DEFINE_FPR(fop, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, gdb_fpu_fop), + DEFINE_FPR(ip, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, gdb_fpu_ip), + // FIXME: Extract segment from ip. + DEFINE_FPR(ip, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, gdb_fpu_cs), + DEFINE_FPR(dp, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, gdb_fpu_dp), + // FIXME: Extract segment from dp. + DEFINE_FPR(dp, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, gdb_fpu_ds), + DEFINE_FPR(mxcsr, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, gdb_fpu_mxcsr), + DEFINE_FPR(mxcsrmask, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM), + + // FP registers. + DEFINE_FP(stmm, 0), + DEFINE_FP(stmm, 1), + DEFINE_FP(stmm, 2), + DEFINE_FP(stmm, 3), + DEFINE_FP(stmm, 4), + DEFINE_FP(stmm, 5), + DEFINE_FP(stmm, 6), + DEFINE_FP(stmm, 7), + + // XMM registers + DEFINE_XMM(xmm, 0), + DEFINE_XMM(xmm, 1), + DEFINE_XMM(xmm, 2), + DEFINE_XMM(xmm, 3), + DEFINE_XMM(xmm, 4), + DEFINE_XMM(xmm, 5), + DEFINE_XMM(xmm, 6), + DEFINE_XMM(xmm, 7), + DEFINE_XMM(xmm, 8), + DEFINE_XMM(xmm, 9), + DEFINE_XMM(xmm, 10), + DEFINE_XMM(xmm, 11), + DEFINE_XMM(xmm, 12), + DEFINE_XMM(xmm, 13), + DEFINE_XMM(xmm, 14), + DEFINE_XMM(xmm, 15) +}; + +static unsigned GetRegOffset(unsigned reg) +{ + assert(reg < k_num_registers && "Invalid register number."); + return g_register_infos[reg].byte_offset; +} + +RegisterContextLinux_x86_64::RegisterContextLinux_x86_64(Thread &thread, + StackFrame *frame) + : RegisterContextLinux(thread, frame) +{ +} + +RegisterContextLinux_x86_64::~RegisterContextLinux_x86_64() +{ +} + +ProcessMonitor & +RegisterContextLinux_x86_64::GetMonitor() +{ + ProcessLinux *process = static_cast(CalculateProcess()); + return process->GetMonitor(); +} + +void +RegisterContextLinux_x86_64::Invalidate() +{ +} + +size_t +RegisterContextLinux_x86_64::GetRegisterCount() +{ + return k_num_registers; +} + +const RegisterInfo * +RegisterContextLinux_x86_64::GetRegisterInfoAtIndex(uint32_t reg) +{ + if (reg < k_num_registers) + return &g_register_infos[reg]; + else + return NULL; +} + +size_t +RegisterContextLinux_x86_64::GetRegisterSetCount() +{ + return k_num_register_sets; +} + +const RegisterSet * +RegisterContextLinux_x86_64::GetRegisterSet(uint32_t set) +{ + if (set < k_num_register_sets) + return &g_reg_sets[set]; + else + return NULL; +} + +bool +RegisterContextLinux_x86_64::ReadRegisterValue(uint32_t reg, + Scalar &value) +{ + ProcessMonitor &monitor = GetMonitor(); + return monitor.ReadRegisterValue(GetRegOffset(reg), value); +} + +bool +RegisterContextLinux_x86_64::ReadRegisterBytes(uint32_t reg, + DataExtractor &data) +{ + return false; +} + +bool +RegisterContextLinux_x86_64::ReadAllRegisterValues(DataBufferSP &data_sp) +{ + return false; +} + +bool +RegisterContextLinux_x86_64::WriteRegisterValue(uint32_t reg, + const Scalar &value) +{ + ProcessMonitor &monitor = GetMonitor(); + return monitor.WriteRegisterValue(GetRegOffset(reg), value); +} + +bool +RegisterContextLinux_x86_64::WriteRegisterBytes(uint32_t reg, + DataExtractor &data, + uint32_t data_offset) +{ + return false; +} + +bool +RegisterContextLinux_x86_64::WriteAllRegisterValues(const DataBufferSP &data) +{ + return false; +} + +bool +RegisterContextLinux_x86_64::UpdateAfterBreakpoint() +{ + // PC points one byte past the int3 responsible for the breakpoint. + lldb::addr_t pc; + + if ((pc = GetPC()) == LLDB_INVALID_ADDRESS) + return false; + + SetPC(pc - 1); + return true; +} + +uint32_t +RegisterContextLinux_x86_64::ConvertRegisterKindToRegisterNumber(uint32_t kind, + uint32_t num) +{ + if (kind == eRegisterKindGeneric) + { + switch (num) + { + case LLDB_REGNUM_GENERIC_PC: return gpr_rip; + case LLDB_REGNUM_GENERIC_SP: return gpr_rsp; + case LLDB_REGNUM_GENERIC_FP: return gpr_rbp; + case LLDB_REGNUM_GENERIC_FLAGS: return gpr_rflags; + case LLDB_REGNUM_GENERIC_RA: + default: + return LLDB_INVALID_REGNUM; + } + } + + if (kind == eRegisterKindGCC || kind == eRegisterKindDWARF) + { + switch (num) + { + case gcc_dwarf_gpr_rax: return gpr_rax; + case gcc_dwarf_gpr_rdx: return gpr_rdx; + case gcc_dwarf_gpr_rcx: return gpr_rcx; + case gcc_dwarf_gpr_rbx: return gpr_rbx; + case gcc_dwarf_gpr_rsi: return gpr_rsi; + case gcc_dwarf_gpr_rdi: return gpr_rdi; + case gcc_dwarf_gpr_rbp: return gpr_rbp; + case gcc_dwarf_gpr_rsp: return gpr_rsp; + case gcc_dwarf_gpr_r8: return gpr_r8; + case gcc_dwarf_gpr_r9: return gpr_r9; + case gcc_dwarf_gpr_r10: return gpr_r10; + case gcc_dwarf_gpr_r11: return gpr_r11; + case gcc_dwarf_gpr_r12: return gpr_r12; + case gcc_dwarf_gpr_r13: return gpr_r13; + case gcc_dwarf_gpr_r14: return gpr_r14; + case gcc_dwarf_gpr_r15: return gpr_r15; + case gcc_dwarf_gpr_rip: return gpr_rip; + case gcc_dwarf_fpu_xmm0: return fpu_xmm0; + case gcc_dwarf_fpu_xmm1: return fpu_xmm1; + case gcc_dwarf_fpu_xmm2: return fpu_xmm2; + case gcc_dwarf_fpu_xmm3: return fpu_xmm3; + case gcc_dwarf_fpu_xmm4: return fpu_xmm4; + case gcc_dwarf_fpu_xmm5: return fpu_xmm5; + case gcc_dwarf_fpu_xmm6: return fpu_xmm6; + case gcc_dwarf_fpu_xmm7: return fpu_xmm7; + case gcc_dwarf_fpu_xmm8: return fpu_xmm8; + case gcc_dwarf_fpu_xmm9: return fpu_xmm9; + case gcc_dwarf_fpu_xmm10: return fpu_xmm10; + case gcc_dwarf_fpu_xmm11: return fpu_xmm11; + case gcc_dwarf_fpu_xmm12: return fpu_xmm12; + case gcc_dwarf_fpu_xmm13: return fpu_xmm13; + case gcc_dwarf_fpu_xmm14: return fpu_xmm14; + case gcc_dwarf_fpu_xmm15: return fpu_xmm15; + case gcc_dwarf_fpu_stmm0: return fpu_stmm0; + case gcc_dwarf_fpu_stmm1: return fpu_stmm1; + case gcc_dwarf_fpu_stmm2: return fpu_stmm2; + case gcc_dwarf_fpu_stmm3: return fpu_stmm3; + case gcc_dwarf_fpu_stmm4: return fpu_stmm4; + case gcc_dwarf_fpu_stmm5: return fpu_stmm5; + case gcc_dwarf_fpu_stmm6: return fpu_stmm6; + case gcc_dwarf_fpu_stmm7: return fpu_stmm7; + default: + return LLDB_INVALID_REGNUM; + } + } + + if (kind == eRegisterKindGDB) + { + switch (num) + { + case gdb_gpr_rax : return gpr_rax; + case gdb_gpr_rbx : return gpr_rbx; + case gdb_gpr_rcx : return gpr_rcx; + case gdb_gpr_rdx : return gpr_rdx; + case gdb_gpr_rsi : return gpr_rsi; + case gdb_gpr_rdi : return gpr_rdi; + case gdb_gpr_rbp : return gpr_rbp; + case gdb_gpr_rsp : return gpr_rsp; + case gdb_gpr_r8 : return gpr_r8; + case gdb_gpr_r9 : return gpr_r9; + case gdb_gpr_r10 : return gpr_r10; + case gdb_gpr_r11 : return gpr_r11; + case gdb_gpr_r12 : return gpr_r12; + case gdb_gpr_r13 : return gpr_r13; + case gdb_gpr_r14 : return gpr_r14; + case gdb_gpr_r15 : return gpr_r15; + case gdb_gpr_rip : return gpr_rip; + case gdb_gpr_rflags : return gpr_rflags; + case gdb_gpr_cs : return gpr_cs; + case gdb_gpr_ss : return gpr_ss; + case gdb_gpr_ds : return gpr_ds; + case gdb_gpr_es : return gpr_es; + case gdb_gpr_fs : return gpr_fs; + case gdb_gpr_gs : return gpr_gs; + case gdb_fpu_stmm0 : return fpu_stmm0; + case gdb_fpu_stmm1 : return fpu_stmm1; + case gdb_fpu_stmm2 : return fpu_stmm2; + case gdb_fpu_stmm3 : return fpu_stmm3; + case gdb_fpu_stmm4 : return fpu_stmm4; + case gdb_fpu_stmm5 : return fpu_stmm5; + case gdb_fpu_stmm6 : return fpu_stmm6; + case gdb_fpu_stmm7 : return fpu_stmm7; + case gdb_fpu_fcw : return fpu_fcw; + case gdb_fpu_fsw : return fpu_fsw; + case gdb_fpu_ftw : return fpu_ftw; + case gdb_fpu_cs : return fpu_cs; + case gdb_fpu_ip : return fpu_ip; + case gdb_fpu_ds : return fpu_ds; + case gdb_fpu_dp : return fpu_dp; + case gdb_fpu_fop : return fpu_fop; + case gdb_fpu_xmm0 : return fpu_xmm0; + case gdb_fpu_xmm1 : return fpu_xmm1; + case gdb_fpu_xmm2 : return fpu_xmm2; + case gdb_fpu_xmm3 : return fpu_xmm3; + case gdb_fpu_xmm4 : return fpu_xmm4; + case gdb_fpu_xmm5 : return fpu_xmm5; + case gdb_fpu_xmm6 : return fpu_xmm6; + case gdb_fpu_xmm7 : return fpu_xmm7; + case gdb_fpu_xmm8 : return fpu_xmm8; + case gdb_fpu_xmm9 : return fpu_xmm9; + case gdb_fpu_xmm10 : return fpu_xmm10; + case gdb_fpu_xmm11 : return fpu_xmm11; + case gdb_fpu_xmm12 : return fpu_xmm12; + case gdb_fpu_xmm13 : return fpu_xmm13; + case gdb_fpu_xmm14 : return fpu_xmm14; + case gdb_fpu_xmm15 : return fpu_xmm15; + case gdb_fpu_mxcsr : return fpu_mxcsr; + default: + return LLDB_INVALID_REGNUM; + } + } + + return LLDB_INVALID_REGNUM; +} + +bool +RegisterContextLinux_x86_64::HardwareSingleStep(bool enable) +{ + return GetMonitor().SingleStep(GetThreadID()); +} Added: lldb/trunk/source/Plugins/Process/Linux/RegisterContextLinux_x86_64.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Linux/RegisterContextLinux_x86_64.h?rev=109318&view=auto ============================================================================== --- lldb/trunk/source/Plugins/Process/Linux/RegisterContextLinux_x86_64.h (added) +++ lldb/trunk/source/Plugins/Process/Linux/RegisterContextLinux_x86_64.h Fri Jul 23 21:19:04 2010 @@ -0,0 +1,155 @@ +//===-- RegisterContextLinux_x86_64.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_RegisterContextLinux_x86_64_H_ +#define liblldb_RegisterContextLinux_x86_64_H_ + +#include "RegisterContextLinux.h" + +class ProcessMonitor; + +class RegisterContextLinux_x86_64 + : public RegisterContextLinux +{ +public: + RegisterContextLinux_x86_64(lldb_private::Thread &thread, + lldb_private::StackFrame *frame); + + ~RegisterContextLinux_x86_64(); + + void + Invalidate(); + + size_t + GetRegisterCount(); + + const lldb::RegisterInfo * + GetRegisterInfoAtIndex(uint32_t reg); + + size_t + GetRegisterSetCount(); + + const lldb::RegisterSet * + GetRegisterSet(uint32_t set); + + bool + ReadRegisterValue(uint32_t reg, lldb_private::Scalar &value); + + bool + ReadRegisterBytes(uint32_t reg, lldb_private::DataExtractor &data); + + bool + ReadAllRegisterValues(lldb::DataBufferSP &data_sp); + + bool + WriteRegisterValue(uint32_t reg, const lldb_private::Scalar &value); + + bool + WriteRegisterBytes(uint32_t reg, lldb_private::DataExtractor &data, + uint32_t data_offset = 0); + + bool + WriteAllRegisterValues(const lldb::DataBufferSP &data_sp); + + uint32_t + ConvertRegisterKindToRegisterNumber(uint32_t kind, uint32_t num); + + bool + HardwareSingleStep(bool enable); + + bool + UpdateAfterBreakpoint(); + + struct GPR + { + uint64_t r15; + uint64_t r14; + uint64_t r13; + uint64_t r12; + uint64_t rbp; + uint64_t rbx; + uint64_t r11; + uint64_t r10; + uint64_t r9; + uint64_t r8; + uint64_t rax; + uint64_t rcx; + uint64_t rdx; + uint64_t rsi; + uint64_t rdi; + uint64_t orig_ax; + uint64_t rip; + uint64_t cs; + uint64_t rflags; + uint64_t rsp; + uint64_t ss; + uint64_t fs_base; + uint64_t gs_base; + uint64_t ds; + uint64_t es; + uint64_t fs; + uint64_t gs; + }; + + struct MMSReg + { + uint8_t bytes[10]; + uint8_t pad[6]; + }; + + struct XMMReg + { + uint8_t bytes[16]; + }; + + struct FPU + { + uint16_t fcw; + uint16_t fsw; + uint16_t ftw; + uint16_t fop; + uint64_t ip; + uint64_t dp; + uint32_t mxcsr; + uint32_t mxcsrmask; + MMSReg stmm[8]; + XMMReg xmm[16]; + uint32_t padding[24]; + }; + + struct UserArea + { + GPR regs; // General purpose registers. + int32_t fpvalid; // True if FPU is being used. + int32_t pad0; + FPU i387; // FPU registers. + uint64_t tsize; // Text segment size. + uint64_t dsize; // Data segment size. + uint64_t ssize; // Stack segement size. + uint64_t start_code; // VM address of text. + uint64_t start_stack; // VM address of stack bottom (top in rsp). + int64_t signal; // Signal causing core dump. + int32_t reserved; // Unused. + int32_t pad1; + uint64_t ar0; // Location of GPR's. + FPU* fpstate; // Location of FPR's. + uint64_t magic; // Identifier for core dumps. + char u_comm[32]; // Command causing core dump. + uint64_t u_debugreg[8]; // Debug registers (DR0 - DR7). + uint64_t error_code; // CPU error code. + uint64_t fault_address; // Control register CR3. + }; + +private: + UserArea user; + + ProcessMonitor &GetMonitor(); +}; + +#endif // #ifndef liblldb_RegisterContextLinux_x86_64_H_ Modified: lldb/trunk/source/lldb.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/lldb.cpp?rev=109318&r1=109317&r2=109318&view=diff ============================================================================== --- lldb/trunk/source/lldb.cpp (original) +++ lldb/trunk/source/lldb.cpp Fri Jul 23 21:19:04 2010 @@ -22,6 +22,7 @@ #include "Plugins/SymbolFile/DWARF/SymbolFileDWARF.h" #include "Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h" #include "Plugins/SymbolFile/Symtab/SymbolFileSymtab.h" + #ifdef __APPLE__ #include "Plugins/ABI/MacOSX-i386/ABIMacOSX_i386.h" #include "Plugins/ABI/SysV-x86_64/ABISysV_x86_64.h" @@ -32,6 +33,10 @@ #include "Plugins/Process/gdb-remote/ProcessGDBRemote.h" #endif +#ifdef __linux__ +#include "Plugins/Process/Linux/ProcessLinux.h" +#endif + using namespace lldb_private; @@ -55,10 +60,10 @@ DisassemblerLLVM::Initialize(); ObjectContainerBSDArchive::Initialize(); ObjectFileELF::Initialize(); - SymbolVendorMacOSX::Initialize(); SymbolFileDWARF::Initialize(); SymbolFileDWARFDebugMap::Initialize(); SymbolFileSymtab::Initialize(); + #ifdef __APPLE__ ABIMacOSX_i386::Initialize(); ABISysV_x86_64::Initialize(); @@ -66,7 +71,12 @@ ObjectContainerUniversalMachO::Initialize(); ObjectFileMachO::Initialize(); ProcessGDBRemote::Initialize(); -// ProcessMacOSX::Initialize(); + ProcessMacOSX::Initialize(); + SymbolVendorMacOSX::Initialize(); +#endif + +#ifdef __linux__ + ProcessLinux::Initialize(); #endif } } @@ -84,16 +94,21 @@ DisassemblerLLVM::Terminate(); ObjectContainerBSDArchive::Terminate(); ObjectFileELF::Terminate(); - SymbolVendorMacOSX::Terminate(); SymbolFileDWARF::Terminate(); SymbolFileDWARFDebugMap::Terminate(); SymbolFileSymtab::Terminate(); + #ifdef __APPLE__ DynamicLoaderMacOSXDYLD::Terminate(); ObjectContainerUniversalMachO::Terminate(); ObjectFileMachO::Terminate(); ProcessGDBRemote::Terminate(); -// ProcessMacOSX::Terminate(); + ProcessMacOSX::Terminate(); + SymbolVendorMacOSX::Terminate(); +#endif + +#ifdef __linux__ + ProcessLinux::Terminate(); #endif } From wilsons at start.ca Fri Jul 23 23:10:59 2010 From: wilsons at start.ca (Stephen Wilson) Date: Sat, 24 Jul 2010 04:10:59 -0000 Subject: [Lldb-commits] [lldb] r109327 - in /lldb/trunk: lib/Makefile source/Plugins/Makefile Message-ID: <20100724041059.80C232A6C12C@llvm.org> Author: wilsons Date: Fri Jul 23 23:10:59 2010 New Revision: 109327 URL: http://llvm.org/viewvc/llvm-project?rev=109327&view=rev Log: Fix makefiles to build properly on Darwin. Patch by William Lynch! Modified: lldb/trunk/lib/Makefile lldb/trunk/source/Plugins/Makefile Modified: lldb/trunk/lib/Makefile URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/lib/Makefile?rev=109327&r1=109326&r2=109327&view=diff ============================================================================== --- lldb/trunk/lib/Makefile (original) +++ lldb/trunk/lib/Makefile Fri Jul 23 23:10:59 2010 @@ -65,7 +65,7 @@ lldbPluginObjectFileMachO.a \ lldbPluginProcessGDBRemote.a \ lldbPluginUtility.a \ - lldbSymbolVendorMaxOSX.a + lldbPluginSymbolVendorMaxOSX.a endif ifeq ($(HOST_OS),Linux) Modified: lldb/trunk/source/Plugins/Makefile URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Makefile?rev=109327&r1=109326&r2=109327&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Makefile (original) +++ lldb/trunk/source/Plugins/Makefile Fri Jul 23 23:10:59 2010 @@ -18,7 +18,8 @@ ifeq ($(HOST_OS),Darwin) DIRS += DynamicLoader/MacOSX-DYLD ObjectContainer/Universal-Mach-O \ - ObjectFile/Mach-O Process/gdb-remote Process/Utility SymbolVendor/MacOSX + ObjectFile/Mach-O Process/gdb-remote Process/Utility \ + SymbolVendor/MacOSX Process/MacOSX-User endif ifeq ($(HOST_OS),Linux) From wilsons at start.ca Sat Jul 24 00:18:16 2010 From: wilsons at start.ca (Stephen Wilson) Date: Sat, 24 Jul 2010 05:18:16 -0000 Subject: [Lldb-commits] [lldb] r109328 - /lldb/trunk/lib/Makefile Message-ID: <20100724051816.A2F2D2A6C12C@llvm.org> Author: wilsons Date: Sat Jul 24 00:18:16 2010 New Revision: 109328 URL: http://llvm.org/viewvc/llvm-project?rev=109328&view=rev Log: Missed an aspect of the previous makefile patch. Thanks again to William Lynch! Modified: lldb/trunk/lib/Makefile Modified: lldb/trunk/lib/Makefile URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/lib/Makefile?rev=109328&r1=109327&r2=109328&view=diff ============================================================================== --- lldb/trunk/lib/Makefile (original) +++ lldb/trunk/lib/Makefile Sat Jul 24 00:18:16 2010 @@ -65,7 +65,7 @@ lldbPluginObjectFileMachO.a \ lldbPluginProcessGDBRemote.a \ lldbPluginUtility.a \ - lldbPluginSymbolVendorMaxOSX.a + lldbPluginSymbolVendorMacOSX.a endif ifeq ($(HOST_OS),Linux)