From johnny.chen at apple.com Mon Nov 8 10:53:28 2010 From: johnny.chen at apple.com (Johnny Chen) Date: Mon, 08 Nov 2010 16:53:28 -0000 Subject: [Lldb-commits] [lldb] r118415 - /lldb/trunk/test/forward/TestForwardDeclaration.py Message-ID: <20101108165328.25BA72A6C12C@llvm.org> Author: johnny Date: Mon Nov 8 10:53:27 2010 New Revision: 118415 URL: http://llvm.org/viewvc/llvm-project?rev=118415&view=rev Log: Skipped due to rdar://problem/8641483 ./dotest.py -v -t -w forward seg faults. Modified: lldb/trunk/test/forward/TestForwardDeclaration.py Modified: lldb/trunk/test/forward/TestForwardDeclaration.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/forward/TestForwardDeclaration.py?rev=118415&r1=118414&r2=118415&view=diff ============================================================================== --- lldb/trunk/test/forward/TestForwardDeclaration.py (original) +++ lldb/trunk/test/forward/TestForwardDeclaration.py Mon Nov 8 10:53:27 2010 @@ -5,6 +5,7 @@ import lldb from lldbtest import * + at unittest2.skip("rdar://problem/8641483 ./dotest.py -v -t -w forward seg faults") class ForwardDeclarationTestCase(TestBase): mydir = "forward" From johnny.chen at apple.com Mon Nov 8 13:03:37 2010 From: johnny.chen at apple.com (Johnny Chen) Date: Mon, 08 Nov 2010 19:03:37 -0000 Subject: [Lldb-commits] [lldb] r118427 - /lldb/trunk/test/dotest.py Message-ID: <20101108190337.A86122A6C12C@llvm.org> Author: johnny Date: Mon Nov 8 13:03:37 2010 New Revision: 118427 URL: http://llvm.org/viewvc/llvm-project?rev=118427&view=rev Log: Let's also emit the informational message for where to find the session logs for failed/errored tests at the start of the test run, in case the test run crashes for any reason. That way, it is easy to locate the session logs for accumulated failures/errors. Modified: lldb/trunk/test/dotest.py Modified: lldb/trunk/test/dotest.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/dotest.py?rev=118427&r1=118426&r2=118427&view=diff ============================================================================== --- lldb/trunk/test/dotest.py (original) +++ lldb/trunk/test/dotest.py Mon Nov 8 13:03:37 2010 @@ -573,6 +573,7 @@ timestamp = datetime.datetime.now().strftime("%Y-%m-%d-%H_%M_%S") sdir_name = timestamp os.environ["LLDB_SESSION_DIRNAME"] = sdir_name +sys.stderr.write("\nSession info for test failures/errors will go into directory '%s'\n" % sdir_name) # # Invoke the default TextTestRunner to run the test suite, possibly iterating From johnny.chen at apple.com Mon Nov 8 14:17:04 2010 From: johnny.chen at apple.com (Johnny Chen) Date: Mon, 08 Nov 2010 20:17:04 -0000 Subject: [Lldb-commits] [lldb] r118438 - /lldb/trunk/test/dotest.py Message-ID: <20101108201704.ED44C2A6C12C@llvm.org> Author: johnny Date: Mon Nov 8 14:17:04 2010 New Revision: 118438 URL: http://llvm.org/viewvc/llvm-project?rev=118438&view=rev Log: Better wording of the help text for the '-f testclass.testmethod' option usage. Modified: lldb/trunk/test/dotest.py Modified: lldb/trunk/test/dotest.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/dotest.py?rev=118438&r1=118437&r2=118438&view=diff ============================================================================== --- lldb/trunk/test/dotest.py (original) +++ lldb/trunk/test/dotest.py Mon Nov 8 14:17:04 2010 @@ -104,7 +104,7 @@ (see also lldb-trunk/example/test/usage-config) -d : delay startup for 10 seconds (in order for the debugger to attach) -f : specify a filter, which consists of the test class name, a dot, followed by - the test method, to admit tests into the test suite + the test method, to only admit such test into the test suite e.g., -f 'ClassTypesTestCase.test_with_dwarf_and_python_api' -g : if specified, the filterspec by -f is not exclusive, i.e., if a test module does not match the filterspec (testclass.testmethod), the whole module is From johnny.chen at apple.com Mon Nov 8 16:08:21 2010 From: johnny.chen at apple.com (Johnny Chen) Date: Mon, 08 Nov 2010 22:08:21 -0000 Subject: [Lldb-commits] [lldb] r118450 - /lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp Message-ID: <20101108220821.8AEBE2A6C12C@llvm.org> Author: johnny Date: Mon Nov 8 16:08:21 2010 New Revision: 118450 URL: http://llvm.org/viewvc/llvm-project?rev=118450&view=rev Log: Minor comment fix. Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp?rev=118450&r1=118449&r2=118450&view=diff ============================================================================== --- lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp (original) +++ lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp Mon Nov 8 16:08:21 2010 @@ -138,7 +138,7 @@ //---------------------------------------------------------------------- // ParseCompileUnitDIEsIfNeeded // -// Parses a compile unit and indexes its DIEs if it already hasn't been +// Parses a compile unit and indexes its DIEs if it hasn't already been // done. //---------------------------------------------------------------------- size_t From johnny.chen at apple.com Mon Nov 8 18:24:51 2010 From: johnny.chen at apple.com (Johnny Chen) Date: Tue, 09 Nov 2010 00:24:51 -0000 Subject: [Lldb-commits] [lldb] r118460 - /lldb/trunk/utils/emacs/gud.el Message-ID: <20101109002451.9DC102A6C12C@llvm.org> Author: johnny Date: Mon Nov 8 18:24:51 2010 New Revision: 118460 URL: http://llvm.org/viewvc/llvm-project?rev=118460&view=rev Log: Add keyboard shortcuts: 'run' => Control-C r (gud-run) "Run the program." 'process kill' => Control-C s (gud-stop-subjoball) "Stop the program." Modified: lldb/trunk/utils/emacs/gud.el Modified: lldb/trunk/utils/emacs/gud.el URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/utils/emacs/gud.el?rev=118460&r1=118459&r2=118460&view=diff ============================================================================== --- lldb/trunk/utils/emacs/gud.el (original) +++ lldb/trunk/utils/emacs/gud.el Mon Nov 8 18:24:51 2010 @@ -1057,9 +1057,9 @@ (gud-def gud-pstar "expression -- *%e" nil "Evaluate C dereferenced pointer expression at point.") (gud-def gud-run "run" - nil "Run the program.") + "r" "Run the program.") (gud-def gud-stop-subjob "process kill" - nil "Stop the program.") + "s" "Stop the program.") (setq comint-prompt-regexp "\\(^\\|\n\\)\\*") (setq paragraph-start comint-prompt-regexp) From jmolenda at apple.com Mon Nov 8 19:21:22 2010 From: jmolenda at apple.com (Jason Molenda) Date: Tue, 09 Nov 2010 01:21:22 -0000 Subject: [Lldb-commits] [lldb] r118467 - in /lldb/trunk: include/lldb/Symbol/FuncUnwinders.h source/Plugins/Process/Utility/RegisterContextLLDB.cpp source/Plugins/Process/Utility/UnwindLLDB.h source/Symbol/UnwindTable.cpp Message-ID: <20101109012122.78C702A6C12C@llvm.org> Author: jmolenda Date: Mon Nov 8 19:21:22 2010 New Revision: 118467 URL: http://llvm.org/viewvc/llvm-project?rev=118467&view=rev Log: Fix thinko in UnwindTable.cpp where it wouldn't provde a FuncUnwinders object if the eh_frame section was missing from an objfile. Worked fine on x86_64 but on i386 where eh_frame is unusual, that resulted in the arch default UnwindPlan being used all the time instead of picking up an assembly profile based unwindplan. Modified: lldb/trunk/include/lldb/Symbol/FuncUnwinders.h lldb/trunk/source/Plugins/Process/Utility/RegisterContextLLDB.cpp lldb/trunk/source/Plugins/Process/Utility/UnwindLLDB.h lldb/trunk/source/Symbol/UnwindTable.cpp Modified: lldb/trunk/include/lldb/Symbol/FuncUnwinders.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Symbol/FuncUnwinders.h?rev=118467&r1=118466&r2=118467&view=diff ============================================================================== --- lldb/trunk/include/lldb/Symbol/FuncUnwinders.h (original) +++ lldb/trunk/include/lldb/Symbol/FuncUnwinders.h Mon Nov 8 19:21:22 2010 @@ -61,8 +61,8 @@ return m_range.ContainsFileAddress (addr); } -protected: +private: UnwindTable& m_unwind_table; UnwindAssemblyProfiler *m_assembly_profiler; AddressRange m_range; Modified: lldb/trunk/source/Plugins/Process/Utility/RegisterContextLLDB.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Utility/RegisterContextLLDB.cpp?rev=118467&r1=118466&r2=118467&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Process/Utility/RegisterContextLLDB.cpp (original) +++ lldb/trunk/source/Plugins/Process/Utility/RegisterContextLLDB.cpp Mon Nov 8 19:21:22 2010 @@ -764,9 +764,14 @@ { if (log) { - log->Printf("%*sFrame %d could not convert lldb regnum %d into %d RegisterKind reg numbering scheme", - m_frame_number < 100 ? m_frame_number : 100, "", m_frame_number, - lldb_regnum, (int) unwindplan_registerkind); + if (unwindplan_registerkind == eRegisterKindGeneric) + log->Printf("%*sFrame %d could not convert lldb regnum %d into eRegisterKindGeneric reg numbering scheme", + m_frame_number < 100 ? m_frame_number : 100, "", m_frame_number, + lldb_regnum); + else + log->Printf("%*sFrame %d could not convert lldb regnum %d into %d RegisterKind reg numbering scheme", + m_frame_number < 100 ? m_frame_number : 100, "", m_frame_number, + lldb_regnum, (int) unwindplan_registerkind); } return false; } Modified: lldb/trunk/source/Plugins/Process/Utility/UnwindLLDB.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Utility/UnwindLLDB.h?rev=118467&r1=118466&r2=118467&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Process/Utility/UnwindLLDB.h (original) +++ lldb/trunk/source/Plugins/Process/Utility/UnwindLLDB.h Mon Nov 8 19:21:22 2010 @@ -56,6 +56,7 @@ lldb::RegisterContextSP reg_ctx; // These are all RegisterContextLLDB's Cursor () : start_pc (LLDB_INVALID_ADDRESS), cfa (LLDB_INVALID_ADDRESS), sctx(), reg_ctx() { } + private: DISALLOW_COPY_AND_ASSIGN (Cursor); }; Modified: lldb/trunk/source/Symbol/UnwindTable.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/UnwindTable.cpp?rev=118467&r1=118466&r2=118467&view=diff ============================================================================== --- lldb/trunk/source/Symbol/UnwindTable.cpp (original) +++ lldb/trunk/source/Symbol/UnwindTable.cpp Mon Nov 8 19:21:22 2010 @@ -77,11 +77,6 @@ initialize(); - if (m_eh_frame == NULL) - { - return no_unwind_found; - } - // Create a FuncUnwinders object for the binary search below AddressRange search_range(addr, 1); FuncUnwindersSP search_unwind(new FuncUnwinders (*this, NULL, search_range)); @@ -111,7 +106,7 @@ if (!sc.GetAddressRange(eSymbolContextFunction | eSymbolContextSymbol, range) || !range.GetBaseAddress().IsValid()) { // Does the eh_frame unwind info has a function bounds for this addr? - if (!m_eh_frame->GetAddressRange (addr, range)) + if (m_eh_frame == NULL || !m_eh_frame->GetAddressRange (addr, range)) { return no_unwind_found; } From jmolenda at apple.com Mon Nov 8 20:31:21 2010 From: jmolenda at apple.com (Jason Molenda) Date: Tue, 09 Nov 2010 02:31:21 -0000 Subject: [Lldb-commits] [lldb] r118477 - in /lldb/trunk/source/Plugins/Process/Utility: UnwindLLDB.cpp UnwindLLDB.h Message-ID: <20101109023121.851102A6C12C@llvm.org> Author: jmolenda Date: Mon Nov 8 20:31:21 2010 New Revision: 118477 URL: http://llvm.org/viewvc/llvm-project?rev=118477&view=rev Log: Refactor UnwindLLDB so it doesn't populate the entire stack unless the frame count is requested or each frame is individually requested. In practice this doesn't seem to help anything because we have functions like StackFrameList::GetNumFrames() which is going to request each frame anyway. And classes like ThreadPlanStepRange and ThreadPlanStepOverRange get the stack depth in their ctor forcing a full stack walk. But at least UnwindLLDB will delay doing a full walk if it can. Modified: lldb/trunk/source/Plugins/Process/Utility/UnwindLLDB.cpp lldb/trunk/source/Plugins/Process/Utility/UnwindLLDB.h Modified: lldb/trunk/source/Plugins/Process/Utility/UnwindLLDB.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Utility/UnwindLLDB.cpp?rev=118477&r1=118476&r2=118477&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Process/Utility/UnwindLLDB.cpp (original) +++ lldb/trunk/source/Plugins/Process/Utility/UnwindLLDB.cpp Mon Nov 8 20:31:21 2010 @@ -31,97 +31,120 @@ uint32_t UnwindLLDB::GetFrameCount() { - LogSP log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_UNWIND)); if (m_frames.empty()) { - // First, set up the 0th (initial) frame - CursorSP first_cursor_sp(new Cursor ()); - RegisterContextSP no_frame; // an empty shared pointer - RegisterContextLLDB *first_register_ctx = new RegisterContextLLDB(m_thread, no_frame, first_cursor_sp->sctx, 0); - if (!first_register_ctx->IsValid()) - { - delete first_register_ctx; + if (!AddFirstFrame ()) return 0; + while (AddOneMoreFrame ()) + ; + } + return m_frames.size (); +} + +bool +UnwindLLDB::AddFirstFrame () +{ + // First, set up the 0th (initial) frame + CursorSP first_cursor_sp(new Cursor ()); + RegisterContextSP no_frame; + RegisterContextLLDB *first_register_ctx = new RegisterContextLLDB(m_thread, no_frame, first_cursor_sp->sctx, 0); + if (!first_register_ctx->IsValid()) + { + delete first_register_ctx; + return false; + } + if (!first_register_ctx->GetCFA (first_cursor_sp->cfa)) + { + delete first_register_ctx; + return false; + } + if (!first_register_ctx->GetPC (first_cursor_sp->start_pc)) + { + delete first_register_ctx; + return false; + } + // Reuse the StackFrame provided by the processor native machine context for the first frame + first_register_ctx->SetStackFrame (m_thread.GetStackFrameAtIndex(0).get()); + RegisterContextSP first_register_ctx_sp(first_register_ctx); + first_cursor_sp->reg_ctx = first_register_ctx_sp; + m_frames.push_back (first_cursor_sp); + return true; +} + +// For adding a non-zero stack frame to m_frames. +bool +UnwindLLDB::AddOneMoreFrame () +{ + LogSP log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_UNWIND)); + CursorSP cursor_sp(new Cursor ()); + RegisterContextLLDB *register_ctx; + + // Frame zero is a little different + if (m_frames.size() == 0) + return false; + + uint32_t cur_idx = m_frames.size (); + register_ctx = new RegisterContextLLDB (m_thread, m_frames[cur_idx - 1]->reg_ctx, cursor_sp->sctx, cur_idx); + + if (!register_ctx->IsValid()) + { + delete register_ctx; + if (log) + { + log->Printf("%*sFrame %d invalid RegisterContext for this frame, stopping stack walk", + cur_idx < 100 ? cur_idx : 100, "", cur_idx); } - if (!first_register_ctx->GetCFA (first_cursor_sp->cfa)) + return false; + } + if (!register_ctx->GetCFA (cursor_sp->cfa)) + { + delete register_ctx; + if (log) { - delete first_register_ctx; - return 0; + log->Printf("%*sFrame %d did not get CFA for this frame, stopping stack walk", + cur_idx < 100 ? cur_idx : 100, "", cur_idx); } - if (!first_register_ctx->GetPC (first_cursor_sp->start_pc)) + return false; + } + if (cursor_sp->cfa == (addr_t) -1 || cursor_sp->cfa == 1 || cursor_sp->cfa == 0) + { + delete register_ctx; + if (log) { - delete first_register_ctx; - return 0; + log->Printf("%*sFrame %d did not get a valid CFA for this frame, stopping stack walk", + cur_idx < 100 ? cur_idx : 100, "", cur_idx); } - // Reuse the StackFrame provided by the processor native machine context for the first frame - first_register_ctx->SetStackFrame (m_thread.GetStackFrameAtIndex(0).get()); - RegisterContextSP first_register_ctx_sp(first_register_ctx); - first_cursor_sp->reg_ctx = first_register_ctx_sp; - m_frames.push_back (first_cursor_sp); - - // Now walk up the rest of the stack - while (1) + return false; + } + if (!register_ctx->GetPC (cursor_sp->start_pc)) + { + delete register_ctx; + if (log) { - CursorSP cursor_sp(new Cursor ()); - RegisterContextLLDB *register_ctx; - uint32_t cur_idx = m_frames.size (); - register_ctx = new RegisterContextLLDB (m_thread, m_frames[cur_idx - 1]->reg_ctx, cursor_sp->sctx, cur_idx); - if (!register_ctx->IsValid()) - { - delete register_ctx; - if (log) - { - log->Printf("%*sFrame %d invalid RegisterContext for this frame, stopping stack walk", - cur_idx < 100 ? cur_idx : 100, "", cur_idx); - } - break; - } - if (!register_ctx->GetCFA (cursor_sp->cfa)) - { - delete register_ctx; - if (log) - { - log->Printf("%*sFrame %d did not get CFA for this frame, stopping stack walk", - cur_idx < 100 ? cur_idx : 100, "", cur_idx); - } - break; - } - if (cursor_sp->cfa == (addr_t) -1 || cursor_sp->cfa == 1 || cursor_sp->cfa == 0) - { - delete register_ctx; - if (log) - { - log->Printf("%*sFrame %d did not get a valid CFA for this frame, stopping stack walk", - cur_idx < 100 ? cur_idx : 100, "", cur_idx); - } - break; - } - if (!register_ctx->GetPC (cursor_sp->start_pc)) - { - delete register_ctx; - if (log) - { - log->Printf("%*sFrame %d did not get PC for this frame, stopping stack walk", - cur_idx < 100 ? cur_idx : 100, "", cur_idx); - } - break; - } - RegisterContextSP register_ctx_sp(register_ctx); - StackFrame *frame = new StackFrame(cur_idx, cur_idx, m_thread, register_ctx_sp, cursor_sp->cfa, cursor_sp->start_pc, &(cursor_sp->sctx)); - register_ctx->SetStackFrame (frame); - cursor_sp->reg_ctx = register_ctx_sp; - m_frames.push_back (cursor_sp); + log->Printf("%*sFrame %d did not get PC for this frame, stopping stack walk", + cur_idx < 100 ? cur_idx : 100, "", cur_idx); } + return false; } - return m_frames.size (); + RegisterContextSP register_ctx_sp(register_ctx); + StackFrame *frame = new StackFrame(cur_idx, cur_idx, m_thread, register_ctx_sp, cursor_sp->cfa, cursor_sp->start_pc, &(cursor_sp->sctx)); + register_ctx->SetStackFrame (frame); + cursor_sp->reg_ctx = register_ctx_sp; + m_frames.push_back (cursor_sp); + return true; } bool UnwindLLDB::GetFrameInfoAtIndex (uint32_t idx, addr_t& cfa, addr_t& pc) { - // FIXME don't get the entire stack if it isn't needed. if (m_frames.size() == 0) - GetFrameCount(); + { + if (!AddFirstFrame()) + return false; + } + + while (idx >= m_frames.size() && AddOneMoreFrame ()) + ; if (idx < m_frames.size ()) { @@ -136,15 +159,21 @@ UnwindLLDB::CreateRegisterContextForFrame (StackFrame *frame) { uint32_t idx = frame->GetFrameIndex (); - - // FIXME don't get the entire stack if it isn't needed. - if (m_frames.size() == 0) - GetFrameCount(); - + if (idx == 0) { return m_thread.GetRegisterContext(); } + + if (m_frames.size() == 0) + { + if (!AddFirstFrame()) + return NULL; + } + + while (idx >= m_frames.size() && AddOneMoreFrame ()) + ; + if (idx < m_frames.size ()) return m_frames[idx]->reg_ctx.get(); return NULL; Modified: lldb/trunk/source/Plugins/Process/Utility/UnwindLLDB.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Utility/UnwindLLDB.h?rev=118477&r1=118476&r2=118477&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Process/Utility/UnwindLLDB.h (original) +++ lldb/trunk/source/Plugins/Process/Utility/UnwindLLDB.h Mon Nov 8 20:31:21 2010 @@ -63,6 +63,9 @@ typedef lldb::SharedPtr::Type CursorSP; std::vector m_frames; + bool AddOneMoreFrame (); + bool AddFirstFrame (); + //------------------------------------------------------------------ // For UnwindLLDB only //------------------------------------------------------------------ From jmolenda at apple.com Mon Nov 8 22:31:16 2010 From: jmolenda at apple.com (Jason Molenda) Date: Tue, 09 Nov 2010 04:31:16 -0000 Subject: [Lldb-commits] [lldb] r118486 - in /lldb/trunk/source/Plugins/Process/Utility: RegisterContextLLDB.cpp RegisterContextLLDB.h Message-ID: <20101109043116.B0F4A2A6C12C@llvm.org> Author: jmolenda Date: Mon Nov 8 22:31:16 2010 New Revision: 118486 URL: http://llvm.org/viewvc/llvm-project?rev=118486&view=rev Log: Implement RegisterContext::WriteRegisterBytes in RegisterContextLLDB. I only did a tiny bit of testing; in the one case I tried changing the contents of a radar in the middle of a stack and it was still current in the live register context so it filtered down to frame 0 and was handed over to the live register set RegisterContext. I need to test a case where a register is saved on the stack in memory before I check this one off. Modified: lldb/trunk/source/Plugins/Process/Utility/RegisterContextLLDB.cpp lldb/trunk/source/Plugins/Process/Utility/RegisterContextLLDB.h Modified: lldb/trunk/source/Plugins/Process/Utility/RegisterContextLLDB.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Utility/RegisterContextLLDB.cpp?rev=118486&r1=118485&r2=118486&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Process/Utility/RegisterContextLLDB.cpp (original) +++ lldb/trunk/source/Plugins/Process/Utility/RegisterContextLLDB.cpp Mon Nov 8 22:31:16 2010 @@ -677,6 +677,54 @@ } bool +RegisterContextLLDB::WriteRegisterBytesToRegisterLocation (uint32_t regnum, RegisterLocation regloc, DataExtractor &data, uint32_t data_offset) +{ + if (!IsValid()) + return false; + + if (regloc.type == eRegisterInRegister) + { + if (IsFrameZero ()) + { + return m_base_reg_ctx->WriteRegisterBytes (regloc.location.register_number, data, data_offset); + } + else + { + return m_next_frame->WriteRegisterBytes (regloc.location.register_number, data, data_offset); + } + } + if (regloc.type == eRegisterNotSaved) + { + return false; + } + if (regloc.type == eRegisterValueInferred) + { + return false; + } + if (regloc.type == eRegisterSavedAtHostMemoryLocation) + { + assert ("FIXME debugger inferior function call unwind"); + } + if (regloc.type != eRegisterSavedAtMemoryLocation) + { + assert ("Unknown RegisterLocation type."); + } + + Error error; + const RegisterInfo *reg_info = m_base_reg_ctx->GetRegisterInfoAtIndex (regnum); + if (reg_info->byte_size == 0) + return false; + uint8_t *buf = (uint8_t*) alloca (reg_info->byte_size); + if (data.ExtractBytes (data_offset, reg_info->byte_size, m_thread.GetProcess().GetByteOrder(), buf) != reg_info->byte_size) + return false; + if (m_thread.GetProcess().WriteMemory (regloc.location.target_memory_location, buf, reg_info->byte_size, error) != reg_info->byte_size) + return false; + + return true; +} + + +bool RegisterContextLLDB::IsValid () const { return m_frame_type != eNotAValidFrame; @@ -907,7 +955,8 @@ lldb_regnum); } - assert ("UnwindPlan::Row types atDWARFExpression and isDWARFExpression are unsupported."); + + // assert ("UnwindPlan::Row types atDWARFExpression and isDWARFExpression are unsupported."); return false; } @@ -1013,23 +1062,50 @@ } bool -RegisterContextLLDB::ReadAllRegisterValues (lldb::DataBufferSP &data_sp) +RegisterContextLLDB::WriteRegisterBytes (uint32_t lldb_reg, DataExtractor &data, uint32_t data_offset) { - assert ("not yet implemented"); // FIXME - return false; + LogSP log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_UNWIND)); + if (!IsValid()) + return false; + + if (log && IsLogVerbose ()) + { + log->Printf("%*sFrame %d looking for register saved location for reg %d", + m_frame_number < 100 ? m_frame_number : 100, "", m_frame_number, + lldb_reg); + } + + // If this is the 0th frame, hand this over to the live register context + if (IsFrameZero ()) + { + if (log) + { + log->Printf("%*sFrame %d passing along to the live register context for reg %d", + m_frame_number < 100 ? m_frame_number : 100, "", m_frame_number, + lldb_reg); + } + return m_base_reg_ctx->WriteRegisterBytes (lldb_reg, data, data_offset); + } + + RegisterLocation regloc; + // Find out where the NEXT frame saved THIS frame's register contents + if (!((RegisterContextLLDB*)m_next_frame.get())->SavedLocationForRegister (lldb_reg, regloc)) + return false; + + return WriteRegisterBytesToRegisterLocation (lldb_reg, regloc, data, data_offset); } +// Don't need to implement this one bool -RegisterContextLLDB::WriteRegisterBytes (uint32_t reg, DataExtractor &data, uint32_t data_offset) +RegisterContextLLDB::ReadAllRegisterValues (lldb::DataBufferSP &data_sp) { - assert ("not yet implemented"); // FIXME return false; } +// Don't need to implement this one bool RegisterContextLLDB::WriteAllRegisterValues (const lldb::DataBufferSP& data_sp) { - assert ("not yet implemented"); // FIXME return false; } Modified: lldb/trunk/source/Plugins/Process/Utility/RegisterContextLLDB.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Utility/RegisterContextLLDB.h?rev=118486&r1=118485&r2=118486&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Process/Utility/RegisterContextLLDB.h (original) +++ lldb/trunk/source/Plugins/Process/Utility/RegisterContextLLDB.h Mon Nov 8 22:31:16 2010 @@ -139,7 +139,7 @@ ReadRegisterBytesFromRegisterLocation (uint32_t regnum, RegisterLocation regloc, lldb_private::DataExtractor &data); bool - WriteRegisterBytesFromRegisterLocation (uint32_t regnum, RegisterLocation regloc, lldb_private::Scalar value); + WriteRegisterBytesToRegisterLocation (uint32_t regnum, RegisterLocation regloc, lldb_private::DataExtractor &data, uint32_t data_offset); // Get the contents of a general purpose (address-size) register for this frame // (usually retrieved from the m_next_frame) From gclayton at apple.com Mon Nov 8 22:42:43 2010 From: gclayton at apple.com (Greg Clayton) Date: Tue, 09 Nov 2010 04:42:43 -0000 Subject: [Lldb-commits] [lldb] r118488 - in /lldb/trunk/source: Expression/ClangExpressionDeclMap.cpp Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp Message-ID: <20101109044243.CE2DE2A6C12C@llvm.org> Author: gclayton Date: Mon Nov 8 22:42:43 2010 New Revision: 118488 URL: http://llvm.org/viewvc/llvm-project?rev=118488&view=rev Log: Fixed an issue in the DWARF parser that was causing forward declarations to not get resolved. Fixed the "void **isa_ptr" variable inside the objective C verifier to start with a '$' character so we don't go looking for it in our program. Moved the lookup for "$__lldb_class" into the part that knows we are looking for internal types that start with a '$'. Modified: lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp Modified: lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp?rev=118488&r1=118487&r2=118488&view=diff ============================================================================== --- lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp (original) +++ lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp Mon Nov 8 22:42:43 2010 @@ -970,45 +970,6 @@ if (m_exe_ctx.frame == NULL) return; - static ConstString g_lldb_class_name ("$__lldb_class"); - if (name == g_lldb_class_name) - { - // Clang is looking for the type of "this" - - VariableList *vars = m_exe_ctx.frame->GetVariableList(false); - - if (!vars) - return; - - lldb::VariableSP this_var = vars->FindVariable(ConstString("this")); - - if (!this_var) - return; - - Type *this_type = this_var->GetType(); - - if (!this_type) - return; - - TypeFromUser this_user_type(this_type->GetClangType(), - this_type->GetClangAST()); - - m_object_pointer_type = this_user_type; - - void *pointer_target_type; - - if (!ClangASTContext::IsPointerType(this_user_type.GetOpaqueQualType(), - &pointer_target_type)) - return; - - TypeFromUser class_user_type(pointer_target_type, - this_type->GetClangAST()); - - AddOneType(context, class_user_type, true); - - return; - } - SymbolContextList sym_ctxs; // Only look for functions by name out in our symbols if the function @@ -1066,6 +1027,45 @@ } else { + static ConstString g_lldb_class_name ("$__lldb_class"); + if (name == g_lldb_class_name) + { + // Clang is looking for the type of "this" + + VariableList *vars = m_exe_ctx.frame->GetVariableList(false); + + if (!vars) + return; + + lldb::VariableSP this_var = vars->FindVariable(ConstString("this")); + + if (!this_var) + return; + + Type *this_type = this_var->GetType(); + + if (!this_type) + return; + + TypeFromUser this_user_type(this_type->GetClangType(), + this_type->GetClangAST()); + + m_object_pointer_type = this_user_type; + + void *pointer_target_type; + + if (!ClangASTContext::IsPointerType(this_user_type.GetOpaqueQualType(), + &pointer_target_type)) + return; + + TypeFromUser class_user_type(pointer_target_type, + this_type->GetClangAST()); + + AddOneType(context, class_user_type, true); + + return; + } + ClangExpressionVariable *pvar(m_persistent_vars->GetVariable(name)); if (pvar) Modified: lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp?rev=118488&r1=118487&r2=118488&view=diff ============================================================================== --- lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp (original) +++ lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp Mon Nov 8 22:42:43 2010 @@ -268,14 +268,14 @@ else { assert(snprintf(&buf->contents[0], sizeof(buf->contents), - "extern \"C\" int gdb_class_getClass(void *); \n" - "extern \"C\" void \n" - "%s(void *$__lldb_arg_obj) \n" - "{ \n" - " void **isa_ptr = (void **)$__lldb_arg_obj; \n" - " if (!isa_ptr || !gdb_class_getClass(*isa_ptr)) \n" - " abort(); \n" - "} \n", + "extern \"C\" int gdb_class_getClass(void *); \n" + "extern \"C\" void \n" + "%s(void *$__lldb_arg_obj) \n" + "{ \n" + " void **$isa_ptr = (void **)$__lldb_arg_obj; \n" + " if (!$isa_ptr || !gdb_class_getClass(*$isa_ptr)) \n" + " abort(); \n" + "} \n", name) < sizeof(buf->contents)); } 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=118488&r1=118487&r2=118488&view=diff ============================================================================== --- lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp (original) +++ lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp Mon Nov 8 22:42:43 2010 @@ -2857,27 +2857,27 @@ } -// if (is_forward_declaration) -// { -// // We have a forward declaration to a type and we need -// // to try and find a full declaration. We look in the -// // current type index just in case we have a forward -// // declaration followed by an actual declarations in the -// // DWARF. If this fails, we need to look elsewhere... -// -// type_sp = FindDefinitionTypeForDIE (dwarf_cu, die, type_name_const_str); -// -// if (!type_sp) -// { -// // We weren't able to find a full declaration in -// // this DWARF, see if we have a declaration anywhere -// // else... -// if (m_debug_map_symfile) -// type_sp = m_debug_map_symfile->FindDefinitionTypeForDIE (dwarf_cu, die, type_name_const_str); -// } -// if (type_sp) -// return type_sp; -// } + if (is_forward_declaration) + { + // We have a forward declaration to a type and we need + // to try and find a full declaration. We look in the + // current type index just in case we have a forward + // declaration followed by an actual declarations in the + // DWARF. If this fails, we need to look elsewhere... + + type_sp = FindDefinitionTypeForDIE (dwarf_cu, die, type_name_const_str); + + if (!type_sp) + { + // We weren't able to find a full declaration in + // this DWARF, see if we have a declaration anywhere + // else... + if (m_debug_map_symfile) + type_sp = m_debug_map_symfile->FindDefinitionTypeForDIE (dwarf_cu, die, type_name_const_str); + } + if (type_sp) + return type_sp; + } assert (tag_decl_kind != -1); bool clang_type_was_created = false; clang_type = m_forward_decl_die_to_clang_type.lookup (die); From gclayton at apple.com Mon Nov 8 22:43:39 2010 From: gclayton at apple.com (Greg Clayton) Date: Tue, 09 Nov 2010 04:43:39 -0000 Subject: [Lldb-commits] [lldb] r118489 - in /lldb/trunk: lldb.xcodeproj/project.pbxproj resources/LLDB-Info.plist tools/debugserver/debugserver.xcodeproj/project.pbxproj Message-ID: <20101109044339.8FA252A6C12C@llvm.org> Author: gclayton Date: Mon Nov 8 22:43:39 2010 New Revision: 118489 URL: http://llvm.org/viewvc/llvm-project?rev=118489&view=rev Log: Bumped versions in Xcode projects to lldb-31 and debugserver-118. Modified: lldb/trunk/lldb.xcodeproj/project.pbxproj lldb/trunk/resources/LLDB-Info.plist lldb/trunk/tools/debugserver/debugserver.xcodeproj/project.pbxproj Modified: lldb/trunk/lldb.xcodeproj/project.pbxproj URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/lldb.xcodeproj/project.pbxproj?rev=118489&r1=118488&r2=118489&view=diff ============================================================================== --- lldb/trunk/lldb.xcodeproj/project.pbxproj (original) +++ lldb/trunk/lldb.xcodeproj/project.pbxproj Mon Nov 8 22:43:39 2010 @@ -3001,9 +3001,9 @@ buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; COPY_PHASE_STRIP = NO; - CURRENT_PROJECT_VERSION = 30; + CURRENT_PROJECT_VERSION = 31; DYLIB_COMPATIBILITY_VERSION = 1; - DYLIB_CURRENT_VERSION = 30; + DYLIB_CURRENT_VERSION = 31; EXPORTED_SYMBOLS_FILE = "resources/lldb-framework-exports"; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", @@ -3053,11 +3053,11 @@ buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; COPY_PHASE_STRIP = NO; - CURRENT_PROJECT_VERSION = 30; + CURRENT_PROJECT_VERSION = 31; DEAD_CODE_STRIPPING = YES; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; DYLIB_COMPATIBILITY_VERSION = 1; - DYLIB_CURRENT_VERSION = 30; + DYLIB_CURRENT_VERSION = 31; EXPORTED_SYMBOLS_FILE = "resources/lldb-framework-exports"; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", @@ -3127,7 +3127,7 @@ isa = XCBuildConfiguration; buildSettings = { COPY_PHASE_STRIP = YES; - CURRENT_PROJECT_VERSION = 30; + CURRENT_PROJECT_VERSION = 31; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", @@ -3162,11 +3162,11 @@ buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; COPY_PHASE_STRIP = YES; - CURRENT_PROJECT_VERSION = 30; + CURRENT_PROJECT_VERSION = 31; DEAD_CODE_STRIPPING = YES; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; DYLIB_COMPATIBILITY_VERSION = 1; - DYLIB_CURRENT_VERSION = 30; + DYLIB_CURRENT_VERSION = 31; EXPORTED_SYMBOLS_FILE = "resources/lldb-framework-exports"; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", @@ -3215,7 +3215,7 @@ buildSettings = { CODE_SIGN_IDENTITY = lldb_codesign; COPY_PHASE_STRIP = NO; - CURRENT_PROJECT_VERSION = 30; + CURRENT_PROJECT_VERSION = 31; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", "\"$(SYSTEM_LIBRARY_DIR)/PrivateFrameworks\"", @@ -3253,7 +3253,7 @@ ); CODE_SIGN_IDENTITY = lldb_codesign; COPY_PHASE_STRIP = YES; - CURRENT_PROJECT_VERSION = 30; + CURRENT_PROJECT_VERSION = 31; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", Modified: lldb/trunk/resources/LLDB-Info.plist URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/resources/LLDB-Info.plist?rev=118489&r1=118488&r2=118489&view=diff ============================================================================== --- lldb/trunk/resources/LLDB-Info.plist (original) +++ lldb/trunk/resources/LLDB-Info.plist Mon Nov 8 22:43:39 2010 @@ -17,7 +17,7 @@ CFBundleSignature ???? CFBundleVersion - 30 + 31 CFBundleName ${EXECUTABLE_NAME} Modified: lldb/trunk/tools/debugserver/debugserver.xcodeproj/project.pbxproj URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/debugserver/debugserver.xcodeproj/project.pbxproj?rev=118489&r1=118488&r2=118489&view=diff ============================================================================== --- lldb/trunk/tools/debugserver/debugserver.xcodeproj/project.pbxproj (original) +++ lldb/trunk/tools/debugserver/debugserver.xcodeproj/project.pbxproj Mon Nov 8 22:43:39 2010 @@ -456,7 +456,7 @@ i386, ); COPY_PHASE_STRIP = NO; - CURRENT_PROJECT_VERSION = 117; + CURRENT_PROJECT_VERSION = 118; GCC_WARN_ABOUT_RETURN_TYPE = YES; GCC_WARN_UNUSED_VARIABLE = YES; STRIP_INSTALLED_PRODUCT = NO; @@ -474,7 +474,7 @@ x86_64, i386, ); - CURRENT_PROJECT_VERSION = 117; + CURRENT_PROJECT_VERSION = 118; DEAD_CODE_STRIPPING = YES; GCC_WARN_ABOUT_RETURN_TYPE = YES; GCC_WARN_UNUSED_VARIABLE = YES; @@ -494,7 +494,7 @@ x86_64, i386, ); - CURRENT_PROJECT_VERSION = 117; + CURRENT_PROJECT_VERSION = 118; DEAD_CODE_STRIPPING = YES; GCC_WARN_ABOUT_RETURN_TYPE = YES; GCC_WARN_UNUSED_VARIABLE = YES; @@ -511,7 +511,7 @@ buildSettings = { "CODE_SIGN_ENTITLEMENTS[sdk=iphoneos*]" = "source/debugserver-entitlements.plist"; COPY_PHASE_STRIP = YES; - CURRENT_PROJECT_VERSION = 117; + CURRENT_PROJECT_VERSION = 118; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; FRAMEWORK_SEARCH_PATHS = $SDKROOT/System/Library/PrivateFrameworks; "FRAMEWORK_SEARCH_PATHS[sdk=iphoneos*][arch=*]" = ( @@ -552,7 +552,7 @@ "CODE_SIGN_ENTITLEMENTS[sdk=iphoneos*]" = "source/debugserver-entitlements.plist"; "CODE_SIGN_IDENTITY[sdk=macosx*]" = lldb_codesign; COPY_PHASE_STRIP = YES; - CURRENT_PROJECT_VERSION = 117; + CURRENT_PROJECT_VERSION = 118; FRAMEWORK_SEARCH_PATHS = $SDKROOT/System/Library/PrivateFrameworks; "FRAMEWORK_SEARCH_PATHS[sdk=iphoneos*][arch=*]" = ( "$(SDKROOT)/System/Library/PrivateFrameworks", @@ -593,7 +593,7 @@ "CODE_SIGN_ENTITLEMENTS[sdk=iphoneos*]" = "source/debugserver-entitlements.plist"; "CODE_SIGN_IDENTITY[sdk=macosx*]" = lldb_codesign; COPY_PHASE_STRIP = YES; - CURRENT_PROJECT_VERSION = 117; + CURRENT_PROJECT_VERSION = 118; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; FRAMEWORK_SEARCH_PATHS = $SDKROOT/System/Library/PrivateFrameworks; "FRAMEWORK_SEARCH_PATHS[sdk=iphoneos*][arch=*]" = ( From johnny.chen at apple.com Tue Nov 9 11:09:20 2010 From: johnny.chen at apple.com (Johnny Chen) Date: Tue, 09 Nov 2010 17:09:20 -0000 Subject: [Lldb-commits] [lldb] r118511 - /lldb/trunk/test/macosx/universal/TestUniversal.py Message-ID: <20101109170920.96A1E2A6C12C@llvm.org> Author: johnny Date: Tue Nov 9 11:09:20 2010 New Revision: 118511 URL: http://llvm.org/viewvc/llvm-project?rev=118511&view=rev Log: Make the specification of relative directory more robust. Modified: lldb/trunk/test/macosx/universal/TestUniversal.py Modified: lldb/trunk/test/macosx/universal/TestUniversal.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/macosx/universal/TestUniversal.py?rev=118511&r1=118510&r2=118511&view=diff ============================================================================== --- lldb/trunk/test/macosx/universal/TestUniversal.py (original) +++ lldb/trunk/test/macosx/universal/TestUniversal.py Tue Nov 9 11:09:20 2010 @@ -7,7 +7,7 @@ class UniversalTestCase(TestBase): - mydir = "macosx/universal" + mydir = os.path.join("macosx", "universal") def setUp(self): # Call super's setUp(). From johnny.chen at apple.com Tue Nov 9 11:51:11 2010 From: johnny.chen at apple.com (Johnny Chen) Date: Tue, 09 Nov 2010 17:51:11 -0000 Subject: [Lldb-commits] [lldb] r118590 - in /lldb/trunk/test/expression_command: ./ radar_8638051/ radar_8638051/Makefile radar_8638051/Test8638051.py radar_8638051/main.c Message-ID: <20101109175111.E7D532A6C12C@llvm.org> Author: johnny Date: Tue Nov 9 11:51:11 2010 New Revision: 118590 URL: http://llvm.org/viewvc/llvm-project?rev=118590&view=rev Log: Add a test for expression parser crash which has been fixed. Added: lldb/trunk/test/expression_command/ lldb/trunk/test/expression_command/radar_8638051/ lldb/trunk/test/expression_command/radar_8638051/Makefile lldb/trunk/test/expression_command/radar_8638051/Test8638051.py lldb/trunk/test/expression_command/radar_8638051/main.c Added: lldb/trunk/test/expression_command/radar_8638051/Makefile URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/expression_command/radar_8638051/Makefile?rev=118590&view=auto ============================================================================== --- lldb/trunk/test/expression_command/radar_8638051/Makefile (added) +++ lldb/trunk/test/expression_command/radar_8638051/Makefile Tue Nov 9 11:51:11 2010 @@ -0,0 +1,5 @@ +LEVEL = ../../make + +C_SOURCES := main.c + +include $(LEVEL)/Makefile.rules Added: lldb/trunk/test/expression_command/radar_8638051/Test8638051.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/expression_command/radar_8638051/Test8638051.py?rev=118590&view=auto ============================================================================== --- lldb/trunk/test/expression_command/radar_8638051/Test8638051.py (added) +++ lldb/trunk/test/expression_command/radar_8638051/Test8638051.py Tue Nov 9 11:51:11 2010 @@ -0,0 +1,43 @@ +""" +Test the robustness of lldb expression parser. +""" + +import os, time +import unittest2 +import lldb +from lldbtest import * + +class Radar8638051TestCase(TestBase): + + mydir = os.path.join("expression_command", "radar_8638051") + + def test_expr_commands(self): + """The following expression commands should not crash.""" + self.buildDefault() + + self.runCmd("file a.out", CURRENT_EXECUTABLE_SET) + + self.runCmd("breakpoint set -n c") + + self.runCmd("run", RUN_SUCCEEDED) + + self.expect("expression val", + startstr = "(int) $0 = 1") + # (int) $0 = 1 + + self.expect("expression *(&val)", + startstr = "(int) $1 = 1") + # (int) $1 = 1 + + # rdar://problem/8638051 + # lldb expression command: Could this crash be avoided + self.expect("expression &val", + startstr = "(int *) $2 = ") + # (int *) $2 = 0x.... + + +if __name__ == '__main__': + import atexit + lldb.SBDebugger.Initialize() + atexit.register(lambda: lldb.SBDebugger.Terminate()) + unittest2.main() Added: lldb/trunk/test/expression_command/radar_8638051/main.c URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/expression_command/radar_8638051/main.c?rev=118590&view=auto ============================================================================== --- lldb/trunk/test/expression_command/radar_8638051/main.c (added) +++ lldb/trunk/test/expression_command/radar_8638051/main.c Tue Nov 9 11:51:11 2010 @@ -0,0 +1,54 @@ +//===-- main.c --------------------------------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +#include + +// This simple program is to demonstrate the capability of the lldb command +// "breakpoint command add" to add a set of commands to a breakpoint to be +// executed when the breakpoint is hit. +// +// In particular, we want to break within c(), but only if the immediate caller +// is a(). + +int a(int); +int b(int); +int c(int); + +int a(int val) +{ + if (val <= 1) + return b(val); + else if (val >= 3) + return c(val); // Find the line number where c's parent frame is a here. + + return val; +} + +int b(int val) +{ + return c(val); +} + +int c(int val) +{ + return val + 3; +} + +int main (int argc, char const *argv[]) +{ + int A1 = a(1); // a(1) -> b(1) -> c(1) + printf("a(1) returns %d\n", A1); + + int B2 = b(2); // b(2) -> c(2) + printf("b(2) returns %d\n", B2); + + int A3 = a(3); // a(3) -> c(3) + printf("a(3) returns %d\n", A3); + + return 0; +} From johnny.chen at apple.com Tue Nov 9 11:57:37 2010 From: johnny.chen at apple.com (Johnny Chen) Date: Tue, 09 Nov 2010 17:57:37 -0000 Subject: [Lldb-commits] [lldb] r118591 - in /lldb/trunk/test: expression_command/persistent_variables/ expression_command/persistent_variables/Makefile expression_command/persistent_variables/TestPersistentVariables.py persistent_variables/ Message-ID: <20101109175737.59E192A6C12C@llvm.org> Author: johnny Date: Tue Nov 9 11:57:37 2010 New Revision: 118591 URL: http://llvm.org/viewvc/llvm-project?rev=118591&view=rev Log: Move the persistent_variables directory under expression_command directory. Added: lldb/trunk/test/expression_command/persistent_variables/ - copied from r118510, lldb/trunk/test/persistent_variables/ Removed: lldb/trunk/test/persistent_variables/ Modified: lldb/trunk/test/expression_command/persistent_variables/Makefile lldb/trunk/test/expression_command/persistent_variables/TestPersistentVariables.py Modified: lldb/trunk/test/expression_command/persistent_variables/Makefile URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/expression_command/persistent_variables/Makefile?rev=118591&r1=118510&r2=118591&view=diff ============================================================================== --- lldb/trunk/test/expression_command/persistent_variables/Makefile (original) +++ lldb/trunk/test/expression_command/persistent_variables/Makefile Tue Nov 9 11:57:37 2010 @@ -1,4 +1,4 @@ -LEVEL = ../make +LEVEL = ../../make C_SOURCES := main.c Modified: lldb/trunk/test/expression_command/persistent_variables/TestPersistentVariables.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/expression_command/persistent_variables/TestPersistentVariables.py?rev=118591&r1=118510&r2=118591&view=diff ============================================================================== --- lldb/trunk/test/expression_command/persistent_variables/TestPersistentVariables.py (original) +++ lldb/trunk/test/expression_command/persistent_variables/TestPersistentVariables.py Tue Nov 9 11:57:37 2010 @@ -9,7 +9,7 @@ class PersistentVariablesTestCase(TestBase): - mydir = "persistent_variables" + mydir = os.path.join("expression_command", "persistent_variables") def test_persistent_variables(self): """Test that lldb persistent variables works correctly.""" From johnny.chen at apple.com Tue Nov 9 12:42:22 2010 From: johnny.chen at apple.com (Johnny Chen) Date: Tue, 09 Nov 2010 18:42:22 -0000 Subject: [Lldb-commits] [lldb] r118599 - /lldb/trunk/test/lldbtest.py Message-ID: <20101109184222.93E672A6C12C@llvm.org> Author: johnny Date: Tue Nov 9 12:42:22 2010 New Revision: 118599 URL: http://llvm.org/viewvc/llvm-project?rev=118599&view=rev Log: Distinguish between the assert messages for runCmd and expect. The former now takes the form: "Command '%s' returns successfully" % str and the latter takes the form: "'%s' returns expected result" % str or "'%s' matches expected result" % str Modified: lldb/trunk/test/lldbtest.py Modified: lldb/trunk/test/lldbtest.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/lldbtest.py?rev=118599&r1=118598&r2=118599&view=diff ============================================================================== --- lldb/trunk/test/lldbtest.py (original) +++ lldb/trunk/test/lldbtest.py Tue Nov 9 12:42:22 2010 @@ -177,11 +177,15 @@ # # And a generic "Command '%s' returns successfully" message generator. # -def CMD_MSG(str, exe): - if exe: - return "Command '%s' returns successfully" % str - else: - return "'%s' compares successfully" % str +def CMD_MSG(str): + return "Command '%s' returns successfully" % str + +# +# And a generic "'%s' returns expected result" message generator if exe. +# Otherwise, it's "'%s' matches expected result" +# +def EXP_MSG(str, exe): + return "'%s' %s expected result" % (str, 'returns' if exe else 'matches') # # And a generic "Value of setting '%s' is correct" message generator. @@ -657,7 +661,7 @@ if check: self.assertTrue(self.res.Succeeded(), - msg if msg else CMD_MSG(cmd, True)) + msg if msg else CMD_MSG(cmd)) def expect(self, str, msg=None, patterns=None, startstr=None, substrs=None, trace=False, error=False, matching=True, exe=True): """ @@ -741,7 +745,7 @@ break self.assertTrue(matched if matching else not matched, - msg if msg else CMD_MSG(str, exe)) + msg if msg else EXP_MSG(str, exe)) def invoke(self, obj, name, trace=False): """Use reflection to call a method dynamically with no argument.""" From johnny.chen at apple.com Tue Nov 9 12:49:57 2010 From: johnny.chen at apple.com (Johnny Chen) Date: Tue, 09 Nov 2010 18:49:57 -0000 Subject: [Lldb-commits] [lldb] r118602 - in /lldb/trunk/test/types: TestFloatTypesExpr.py TestIntegerTypesExpr.py Message-ID: <20101109184957.EE1452A6C12C@llvm.org> Author: johnny Date: Tue Nov 9 12:49:57 2010 New Revision: 118602 URL: http://llvm.org/viewvc/llvm-project?rev=118602&view=rev Log: We should make the class name of test cases which emphasize expression command be different than the class name which uses frame variable command. Modified: lldb/trunk/test/types/TestFloatTypesExpr.py lldb/trunk/test/types/TestIntegerTypesExpr.py Modified: lldb/trunk/test/types/TestFloatTypesExpr.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/types/TestFloatTypesExpr.py?rev=118602&r1=118601&r2=118602&view=diff ============================================================================== --- lldb/trunk/test/types/TestFloatTypesExpr.py (original) +++ lldb/trunk/test/types/TestFloatTypesExpr.py Tue Nov 9 12:49:57 2010 @@ -7,7 +7,7 @@ import lldb import sys -class FloatTypesTestCase(AbstractBase.GenericTester): +class FloatTypesExprTestCase(AbstractBase.GenericTester): mydir = "types" Modified: lldb/trunk/test/types/TestIntegerTypesExpr.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/types/TestIntegerTypesExpr.py?rev=118602&r1=118601&r2=118602&view=diff ============================================================================== --- lldb/trunk/test/types/TestIntegerTypesExpr.py (original) +++ lldb/trunk/test/types/TestIntegerTypesExpr.py Tue Nov 9 12:49:57 2010 @@ -7,7 +7,7 @@ import lldb import sys -class IntegerTypesTestCase(AbstractBase.GenericTester): +class IntegerTypesExprTestCase(AbstractBase.GenericTester): mydir = "types" From johnny.chen at apple.com Tue Nov 9 15:14:23 2010 From: johnny.chen at apple.com (Johnny Chen) Date: Tue, 09 Nov 2010 21:14:23 -0000 Subject: [Lldb-commits] [lldb] r118632 - /lldb/trunk/test/forward/TestForwardDeclaration.py Message-ID: <20101109211423.4978F2A6C12C@llvm.org> Author: johnny Date: Tue Nov 9 15:14:23 2010 New Revision: 118632 URL: http://llvm.org/viewvc/llvm-project?rev=118632&view=rev Log: Remove the @skip decorator for the whole class: @unittest2.skip("rdar://problem/8641483 ./dotest.py -v -t -w forward seg faults") and add a @skip decorator for test_with_dwarf_and_run_command() method: @unittest2.skip("rdar://problem/8648070 'expression *bar_ptr' seg faults") Modified: lldb/trunk/test/forward/TestForwardDeclaration.py Modified: lldb/trunk/test/forward/TestForwardDeclaration.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/forward/TestForwardDeclaration.py?rev=118632&r1=118631&r2=118632&view=diff ============================================================================== --- lldb/trunk/test/forward/TestForwardDeclaration.py (original) +++ lldb/trunk/test/forward/TestForwardDeclaration.py Tue Nov 9 15:14:23 2010 @@ -5,7 +5,6 @@ import lldb from lldbtest import * - at unittest2.skip("rdar://problem/8641483 ./dotest.py -v -t -w forward seg faults") class ForwardDeclarationTestCase(TestBase): mydir = "forward" @@ -16,9 +15,11 @@ self.buildDsym() self.forward_declaration() + # rdar://problem/8648070 + # 'expression *bar_ptr' seg faults # rdar://problem/8546815 # './dotest.py -v -t forward' fails for test_with_dwarf_and_run_command - @unittest2.expectedFailure + @unittest2.skip("rdar://problem/8648070 'expression *bar_ptr' seg faults") def test_with_dwarf_and_run_command(self): """Display *bar_ptr when stopped on a function with forward declaration of struct bar.""" self.buildDwarf() From scallanan at apple.com Tue Nov 9 16:37:10 2010 From: scallanan at apple.com (Sean Callanan) Date: Tue, 09 Nov 2010 22:37:10 -0000 Subject: [Lldb-commits] [lldb] r118638 - /lldb/trunk/source/Symbol/ClangASTContext.cpp Message-ID: <20101109223710.87BA42A6C12F@llvm.org> Author: spyffe Date: Tue Nov 9 16:37:10 2010 New Revision: 118638 URL: http://llvm.org/viewvc/llvm-project?rev=118638&view=rev Log: Added a named container for the source QualType in the type copy routine to make type problems easier to debug. Modified: lldb/trunk/source/Symbol/ClangASTContext.cpp Modified: lldb/trunk/source/Symbol/ClangASTContext.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/ClangASTContext.cpp?rev=118638&r1=118637&r2=118638&view=diff ============================================================================== --- lldb/trunk/source/Symbol/ClangASTContext.cpp (original) +++ lldb/trunk/source/Symbol/ClangASTContext.cpp Tue Nov 9 16:37:10 2010 @@ -733,8 +733,11 @@ ASTImporter importer(diagnostics, *dest_context, file_manager, *source_context, file_manager); - QualType ret = importer.Import(QualType::getFromOpaquePtr(clang_type)); - return ret.getAsOpaquePtr(); + + QualType src = QualType::getFromOpaquePtr(clang_type); + QualType dst = importer.Import(src); + + return dst.getAsOpaquePtr(); } bool From johnny.chen at apple.com Tue Nov 9 16:56:12 2010 From: johnny.chen at apple.com (Johnny Chen) Date: Tue, 09 Nov 2010 22:56:12 -0000 Subject: [Lldb-commits] [lldb] r118646 - /lldb/trunk/test/lldbtest.py Message-ID: <20101109225612.5A3402A6C12C@llvm.org> Author: johnny Date: Tue Nov 9 16:56:12 2010 New Revision: 118646 URL: http://llvm.org/viewvc/llvm-project?rev=118646&view=rev Log: When dumping the session log for a failed/errored test, also emit the command to invoke the test driver to rerun the very same test. Example output: /Volumes/data/lldb/svn/trunk/test $ tail 2010-11-09-14_51_34/ExpectedFailure-TestSettings.SettingsCommandTestCase.test_set_output_path.log Traceback (most recent call last): File "/Volumes/data/lldb/svn/trunk/test/settings/TestSettings.py", line 136, in test_set_output_path "'stdout.txt' exists due to target.process.output-path.") AssertionError: False is not True : 'stdout.txt' exists due to target.process.output-path. To rerun this test, issue the following command from the 'test' directory: ./dotest.py -v -t -f SettingsCommandTestCase.test_set_output_path Modified: lldb/trunk/test/lldbtest.py Modified: lldb/trunk/test/lldbtest.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/lldbtest.py?rev=118646&r1=118645&r2=118646&view=diff ============================================================================== --- lldb/trunk/test/lldbtest.py (original) +++ lldb/trunk/test/lldbtest.py Tue Nov 9 16:56:12 2010 @@ -572,6 +572,9 @@ import datetime print >> f, "Session info generated @", datetime.datetime.now().ctime() print >> f, self.session.getvalue() + print >> f, "To rerun this test, issue the following command from the 'test' directory:\n" + print >> f, "./dotest.py -v -t -f %s.%s" % (self.__class__.__name__, + self._testMethodName) def setTearDownCleanup(self, dictionary=None): """Register a cleanup action at tearDown() time with a dictinary""" From johnny.chen at apple.com Tue Nov 9 17:42:01 2010 From: johnny.chen at apple.com (Johnny Chen) Date: Tue, 09 Nov 2010 23:42:01 -0000 Subject: [Lldb-commits] [lldb] r118650 - /lldb/trunk/test/dotest.py Message-ID: <20101109234201.310CE2A6C12C@llvm.org> Author: johnny Date: Tue Nov 9 17:42:00 2010 New Revision: 118650 URL: http://llvm.org/viewvc/llvm-project?rev=118650&view=rev Log: Rephrase the output message about session information; make it both "session logs". Modified: lldb/trunk/test/dotest.py Modified: lldb/trunk/test/dotest.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/dotest.py?rev=118650&r1=118649&r2=118650&view=diff ============================================================================== --- lldb/trunk/test/dotest.py (original) +++ lldb/trunk/test/dotest.py Tue Nov 9 17:42:00 2010 @@ -573,7 +573,7 @@ timestamp = datetime.datetime.now().strftime("%Y-%m-%d-%H_%M_%S") sdir_name = timestamp os.environ["LLDB_SESSION_DIRNAME"] = sdir_name -sys.stderr.write("\nSession info for test failures/errors will go into directory '%s'\n" % sdir_name) +sys.stderr.write("\nSession logs for test failures/errors will go into directory '%s'\n" % sdir_name) # # Invoke the default TextTestRunner to run the test suite, possibly iterating @@ -714,7 +714,7 @@ if sdir_has_content: - sys.stderr.write("\nSession logs for test failures/errors can be found in directory '%s'\n" % sdir_name) + sys.stderr.write("Session logs for test failures/errors can be found in directory '%s'\n" % sdir_name) # Terminate the test suite if ${LLDB_TESTSUITE_FORCE_FINISH} is defined. # This should not be necessary now. From gclayton at apple.com Tue Nov 9 17:46:38 2010 From: gclayton at apple.com (Greg Clayton) Date: Tue, 09 Nov 2010 23:46:38 -0000 Subject: [Lldb-commits] [lldb] r118654 - in /lldb/trunk: include/lldb/Core/ include/lldb/Expression/ source/Expression/ source/Plugins/SymbolFile/DWARF/ Message-ID: <20101109234638.35BA52A6C12C@llvm.org> Author: gclayton Date: Tue Nov 9 17:46:37 2010 New Revision: 118654 URL: http://llvm.org/viewvc/llvm-project?rev=118654&view=rev Log: Did a lot of code cleanup. Fixed the DWARF plug-in such that when it gets all attributes for a DIE, that it omits the DW_AT_sibling and DW_AT_declaration when getting attributes from a DW_AT_abstract_origin or DW_AT_specification DIE. Modified: lldb/trunk/include/lldb/Core/ClangForward.h lldb/trunk/include/lldb/Expression/ClangASTSource.h lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.h lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.h lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDefines.cpp lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDefines.h lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFLocationDescription.cpp lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h Modified: lldb/trunk/include/lldb/Core/ClangForward.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/ClangForward.h?rev=118654&r1=118653&r2=118654&view=diff ============================================================================== --- lldb/trunk/include/lldb/Core/ClangForward.h (original) +++ lldb/trunk/include/lldb/Core/ClangForward.h Tue Nov 9 17:46:37 2010 @@ -104,6 +104,7 @@ class TemplateTemplateParmDecl; class TemplateTypeParmDecl; class TextDiagnosticBuffer; + class TranslationUnitDecl; class Type; class TypedefDecl; class TypesCompatibleExpr; Modified: lldb/trunk/include/lldb/Expression/ClangASTSource.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Expression/ClangASTSource.h?rev=118654&r1=118653&r2=118654&view=diff ============================================================================== --- lldb/trunk/include/lldb/Expression/ClangASTSource.h (original) +++ lldb/trunk/include/lldb/Expression/ClangASTSource.h Tue Nov 9 17:46:37 2010 @@ -28,12 +28,9 @@ /// to Clang for these names, consulting the ClangExpressionDeclMap to do /// the actual lookups. //---------------------------------------------------------------------- -class ClangASTSource : public clang::ExternalSemaSource { - clang::ASTContext &m_ast_context; ///< The parser's AST context, for copying types into - ClangExpressionDeclMap &m_decl_map; ///< The object that looks up named entities in LLDB +class ClangASTSource : public clang::ExternalSemaSource +{ public: - friend struct NameSearchContext; - //------------------------------------------------------------------ /// Constructor /// @@ -91,20 +88,21 @@ /// @return /// Whatever SetExternalVisibleDeclsForName returns. //------------------------------------------------------------------ - clang::DeclContextLookupResult FindExternalVisibleDeclsByName(const clang::DeclContext *DC, - clang::DeclarationName Name); + clang::DeclContextLookupResult + FindExternalVisibleDeclsByName (const clang::DeclContext *DC, + clang::DeclarationName Name); //------------------------------------------------------------------ /// Interface stub. //------------------------------------------------------------------ - void MaterializeVisibleDecls(const clang::DeclContext *DC); + void MaterializeVisibleDecls (const clang::DeclContext *DC); //------------------------------------------------------------------ /// Interface stub that returns true. //------------------------------------------------------------------ - bool FindExternalLexicalDecls(const clang::DeclContext *DC, - bool (*isKindWeWant)(clang::Decl::Kind), - llvm::SmallVectorImpl &Decls); + bool FindExternalLexicalDecls (const clang::DeclContext *DC, + bool (*isKindWeWant)(clang::Decl::Kind), + llvm::SmallVectorImpl &Decls); //------------------------------------------------------------------ /// Called on entering a translation unit. Tells Clang by calling @@ -114,7 +112,13 @@ /// @param[in] ASTConsumer /// Unused. //------------------------------------------------------------------ - void StartTranslationUnit(clang::ASTConsumer *Consumer); + void StartTranslationUnit (clang::ASTConsumer *Consumer); + +protected: + friend struct NameSearchContext; + + clang::ASTContext &m_ast_context; ///< The parser's AST context, for copying types into + ClangExpressionDeclMap &m_decl_map; ///< The object that looks up named entities in LLDB }; //---------------------------------------------------------------------- Modified: lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp?rev=118654&r1=118653&r2=118654&view=diff ============================================================================== --- lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp (original) +++ lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp Tue Nov 9 17:46:37 2010 @@ -301,15 +301,15 @@ if (m_exe_ctx.frame == NULL) return false; - SymbolContextList sym_ctxs; + SymbolContextList sc_list; - m_sym_ctx.FindFunctionsByName(name, false, sym_ctxs); + m_sym_ctx.FindFunctionsByName(name, false, sc_list); - if (!sym_ctxs.GetSize()) + if (!sc_list.GetSize()) return false; SymbolContext sym_ctx; - sym_ctxs.GetContextAtIndex(0, sym_ctx); + sc_list.GetContextAtIndex(0, sym_ctx); const Address *fun_address; @@ -955,11 +955,7 @@ // Interface for ClangASTSource void -ClangExpressionDeclMap::GetDecls -( - NameSearchContext &context, - const ConstString &name -) +ClangExpressionDeclMap::GetDecls (NameSearchContext &context, const ConstString &name) { lldb::LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS)); @@ -970,7 +966,7 @@ if (m_exe_ctx.frame == NULL) return; - SymbolContextList sym_ctxs; + SymbolContextList sc_list; // Only look for functions by name out in our symbols if the function // doesn't start with our phony prefix of '$' @@ -986,18 +982,18 @@ } else { - m_sym_ctx.FindFunctionsByName (name, false, sym_ctxs); + m_sym_ctx.FindFunctionsByName (name, false, sc_list); bool found_specific = false; Symbol *generic_symbol = NULL; Symbol *non_extern_symbol = NULL; - for (uint32_t index = 0, num_indices = sym_ctxs.GetSize(); + for (uint32_t index = 0, num_indices = sc_list.GetSize(); index < num_indices; ++index) { SymbolContext sym_ctx; - sym_ctxs.GetContextAtIndex(index, sym_ctx); + sc_list.GetContextAtIndex(index, sym_ctx); if (sym_ctx.function) { Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp?rev=118654&r1=118653&r2=118654&view=diff ============================================================================== --- lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp (original) +++ lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp Tue Nov 9 17:46:37 2010 @@ -644,15 +644,8 @@ break; case DW_AT_declaration: - // Make sure the declaration is from this DIE, and not from - // a DW_AT_specification or DW_AT_abstract_origin by checking - // this die and seeing if its abbreviations have the - // DW_AT_declaration attribute - if (die.GetAbbreviationDeclarationPtr()->FindAttributeIndex (DW_AT_declaration) != DW_INVALID_INDEX) - { - if (attributes.ExtractFormValueAtIndex(m_dwarf2Data, i, form_value)) - is_declaration = form_value.Unsigned() != 0; - } + if (attributes.ExtractFormValueAtIndex(m_dwarf2Data, i, form_value)) + is_declaration = form_value.Unsigned() != 0; break; case DW_AT_artificial: Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.h?rev=118654&r1=118653&r2=118654&view=diff ============================================================================== --- lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.h (original) +++ lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.h Tue Nov 9 17:46:37 2010 @@ -65,8 +65,7 @@ { eDumpFlag_Verbose = (1<<0), // Verbose dumping eDumpFlag_ShowForm = (1<<1), // Show the DW_form type - eDumpFlag_EnglishyNames = (1<<2), // Show the DW_TAG, DW_AT and DW_FORM types in more englishy names instead of as DWARF definitions values - eDumpFlag_ShowAncestors = (1<<3) // Show all parent DIEs when dumping single DIEs + eDumpFlag_ShowAncestors = (1<<2) // Show all parent DIEs when dumping single DIEs }; Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp?rev=118654&r1=118653&r2=118654&view=diff ============================================================================== --- lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp (original) +++ lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp Tue Nov 9 17:46:37 2010 @@ -1098,7 +1098,6 @@ { const DataExtractor& debug_info_data = dwarf2Data->get_debug_info_data(); uint32_t offset = m_offset; - bool english = s->GetFlags().Test (DWARFDebugInfo::eDumpFlag_EnglishyNames); if (debug_info_data.ValidOffset(offset)) { @@ -1110,10 +1109,7 @@ { if (m_abbrevDecl) { - if (english) - s->PutCString(DW_TAG_value_to_englishy_name(m_abbrevDecl->Tag())); - else - s->PutCString(DW_TAG_value_to_name(m_abbrevDecl->Tag())); + s->PutCString(DW_TAG_value_to_name(m_abbrevDecl->Tag())); s->Printf( " [%u] %c\n", abbrCode, m_abbrevDecl->HasChildren() ? '*':' '); // Dump all data in the .debug_info for the attributes @@ -1172,22 +1168,16 @@ { bool verbose = s->GetVerbose(); bool show_form = s->GetFlags().Test(DWARFDebugInfo::eDumpFlag_ShowForm); - bool english = s->GetFlags().Test(DWARFDebugInfo::eDumpFlag_EnglishyNames); const DataExtractor* debug_str_data = dwarf2Data ? &dwarf2Data->get_debug_str_data() : NULL; if (verbose) - s->Offset(*offset_ptr); - else - s->Printf( " "); - s->Indent(); - - if (english) - s->PutCString(DW_AT_value_to_englishy_name(attr)); + s->Offset (*offset_ptr); else - s->PutCString(DW_AT_value_to_name(attr)); + s->Printf (" "); + s->Indent(DW_AT_value_to_name(attr)); if (show_form) { - s->Printf( "[%s", english ? DW_FORM_value_to_englishy_name(form) : DW_FORM_value_to_name(form)); + s->Printf( "[%s", DW_FORM_value_to_name(form)); } DWARFFormValue form_value(form); @@ -1199,7 +1189,7 @@ { if (form == DW_FORM_indirect) { - s->Printf( " [%s]", english ? DW_FORM_value_to_englishy_name(form_value.Form()) : DW_FORM_value_to_name(form_value.Form())); + s->Printf( " [%s]", DW_FORM_value_to_name(form_value.Form())); } s->PutCString("] "); @@ -1326,7 +1316,8 @@ SymbolFileDWARF* dwarf2Data, const DWARFCompileUnit* cu, const uint8_t *fixed_form_sizes, - DWARFDebugInfoEntry::Attributes& attributes + DWARFDebugInfoEntry::Attributes& attributes, + uint32_t curr_depth ) const { if (m_abbrevDecl) @@ -1347,7 +1338,27 @@ for (i=0; iGetAttrAndFormByIndexUnchecked (i, attr, form); - attributes.Append(cu, offset, attr, form); + + // If we are tracking down DW_AT_specification or DW_AT_abstract_origin + // attributes, the depth will be non-zero. We need to omit certain + // attributes that don't make sense. + switch (attr) + { + case DW_AT_sibling: + case DW_AT_declaration: + if (curr_depth > 0) + { + // This attribute doesn't make sense when combined with + // the DIE that references this DIE. We know a DIE is + // referencing this DIE because curr_depth is not zero + break; + } + // Fall through... + default: + attributes.Append(cu, offset, attr, form); + break; + } + if ((attr == DW_AT_specification) || (attr == DW_AT_abstract_origin)) { form_value.SetForm(form); @@ -1359,14 +1370,14 @@ { die = const_cast(cu)->GetDIEPtr(die_offset); if (die) - die->GetAttributes(dwarf2Data, cu, fixed_form_sizes, attributes); + die->GetAttributes(dwarf2Data, cu, fixed_form_sizes, attributes, curr_depth + 1); } else { DWARFCompileUnitSP cu_sp_ptr; die = const_cast(dwarf2Data)->DebugInfo()->GetDIEPtr(die_offset, &cu_sp_ptr); if (die) - die->GetAttributes(dwarf2Data, cu_sp_ptr.get(), fixed_form_sizes, attributes); + die->GetAttributes(dwarf2Data, cu_sp_ptr.get(), fixed_form_sizes, attributes, curr_depth + 1); } } } Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.h?rev=118654&r1=118653&r2=118654&view=diff ============================================================================== --- lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.h (original) +++ lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.h Tue Nov 9 17:46:37 2010 @@ -142,7 +142,8 @@ SymbolFileDWARF* dwarf2Data, const DWARFCompileUnit* cu, const uint8_t *fixed_form_sizes, - DWARFDebugInfoEntry::Attributes& attrs) const; + DWARFDebugInfoEntry::Attributes& attrs, + uint32_t curr_depth = 0) const; // "curr_depth" for internal use only, don't set this yourself!!! dw_offset_t GetAttributeValue( SymbolFileDWARF* dwarf2Data, Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDefines.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDefines.cpp?rev=118654&r1=118653&r2=118654&view=diff ============================================================================== --- lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDefines.cpp (original) +++ lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDefines.cpp Tue Nov 9 17:46:37 2010 @@ -23,7 +23,7 @@ if (val == 0) return "NULL"; - const char *llvmstr = TagString (val); + const char *llvmstr = llvm::dwarf::TagString (val); if (llvmstr == NULL) { snprintf (invalid, sizeof (invalid), "Unknown DW_TAG constant: 0x%x", val); @@ -33,37 +33,10 @@ } const char * -DW_TAG_value_to_englishy_name (uint32_t val) -{ - static char invalid[100]; - - if (val == 0) - return "NULL"; - - const char *llvmstr = TagString (val); - if (llvmstr == NULL) - { - snprintf (invalid, sizeof (invalid), "Unknown DW_TAG constant: 0x%x", val); - return invalid; - } - - std::string str; - if (strncmp (llvmstr, "DW_TAG_", 7) == 0) - llvmstr += 7; - - for (const char *i = llvmstr; *i != '\0'; i++) - str += *i == '_' ? ' ' : *i; - - ConstString const_str (str.c_str()); - - return const_str.GetCString(); -} - -const char * DW_CHILDREN_value_to_name (uint8_t val) { static char invalid[100]; - const char *llvmstr = ChildrenString (val); + const char *llvmstr = llvm::dwarf::ChildrenString (val); if (llvmstr == NULL) { snprintf (invalid, sizeof (invalid), "Unknown DW_CHILDREN constant: 0x%x", val); @@ -76,7 +49,7 @@ DW_AT_value_to_name (uint32_t val) { static char invalid[100]; - const char *llvmstr = AttributeString (val); + const char *llvmstr = llvm::dwarf::AttributeString (val); if (llvmstr == NULL) { snprintf (invalid, sizeof (invalid), "Unknown DW_AT constant: 0x%x", val); @@ -86,32 +59,10 @@ } const char * -DW_AT_value_to_englishy_name (uint32_t val) -{ - static char invalid[100]; - const char *llvmstr = AttributeString (val); - if (llvmstr == NULL) - { - snprintf (invalid, sizeof (invalid), "Unknown DW_AT constant: 0x%x", val); - return invalid; - } - - std::string str; - if (strncmp (llvmstr, "DW_AT_", 6) == 0) - llvmstr += 6; - - for (const char *i = llvmstr; *i != '\0'; i++) - str += *i == '_' ? ' ' : *i; - - ConstString const_str (str.c_str()); - return const_str.GetCString(); -} - -const char * DW_FORM_value_to_name (uint32_t val) { static char invalid[100]; - const char *llvmstr = FormEncodingString (val); + const char *llvmstr = llvm::dwarf::FormEncodingString (val); if (llvmstr == NULL) { snprintf (invalid, sizeof (invalid), "Unknown DW_FORM constant: 0x%x", val); @@ -121,32 +72,10 @@ } const char * -DW_FORM_value_to_englishy_name (uint32_t val) -{ - static char invalid[100]; - const char *llvmstr = FormEncodingString (val); - if (llvmstr == NULL) - { - snprintf (invalid, sizeof (invalid), "Unknown DW_FORM constant: 0x%x", val); - return invalid; - } - - std::string str; - if (strncmp (llvmstr, "DW_FORM_", 8) == 0) - llvmstr += 8; - - for (const char *i = llvmstr; *i != '\0'; i++) - str += *i == '_' ? ' ' : *i; - - ConstString const_str (str.c_str()); - return const_str.GetCString(); -} - -const char * DW_OP_value_to_name (uint32_t val) { static char invalid[100]; - const char *llvmstr = OperationEncodingString (val); + const char *llvmstr = llvm::dwarf::OperationEncodingString (val); if (llvmstr == NULL) { snprintf (invalid, sizeof (invalid), "Unknown DW_OP constant: 0x%x", val); @@ -155,28 +84,6 @@ return llvmstr; } -const char * -DW_OP_value_to_englishy_name (uint32_t val) -{ - static char invalid[100]; - const char *llvmstr = OperationEncodingString (val); - if (llvmstr == NULL) - { - snprintf (invalid, sizeof (invalid), "Unknown DW_OP constant: 0x%x", val); - return invalid; - } - - std::string str; - if (strncmp (llvmstr, "DW_OP_", 6) == 0) - llvmstr += 6; - - for (const char *i = llvmstr; *i != '\0'; i++) - str += *i == '_' ? ' ' : *i; - - ConstString const_str (str.c_str()); - return const_str.GetCString(); -} - DRC_class DW_OP_value_to_class (uint32_t val) { @@ -341,7 +248,7 @@ DW_ATE_value_to_name (uint32_t val) { static char invalid[100]; - const char *llvmstr = AttributeEncodingString (val); + const char *llvmstr = llvm::dwarf::AttributeEncodingString (val); if (llvmstr == NULL) { snprintf (invalid, sizeof (invalid), "Unknown DW_ATE constant: 0x%x", val); @@ -355,7 +262,7 @@ { static char invalid[100]; - const char *llvmstr = AccessibilityString (val); + const char *llvmstr = llvm::dwarf::AccessibilityString (val); if (llvmstr == NULL) { snprintf (invalid, sizeof (invalid), "Unknown DW_ACCESS constant: 0x%x", val); @@ -368,7 +275,7 @@ DW_VIS_value_to_name (uint32_t val) { static char invalid[100]; - const char *llvmstr = VisibilityString (val); + const char *llvmstr = llvm::dwarf::VisibilityString (val); if (llvmstr == NULL) { snprintf (invalid, sizeof (invalid), "Unknown DW_VIS constant: 0x%x", val); @@ -381,7 +288,7 @@ DW_VIRTUALITY_value_to_name (uint32_t val) { static char invalid[100]; - const char *llvmstr = VirtualityString (val); + const char *llvmstr = llvm::dwarf::VirtualityString (val); if (llvmstr == NULL) { snprintf (invalid, sizeof (invalid), "Unknown DW_VIRTUALITY constant: 0x%x", val); @@ -394,7 +301,7 @@ DW_LANG_value_to_name (uint32_t val) { static char invalid[100]; - const char *llvmstr = LanguageString (val); + const char *llvmstr = llvm::dwarf::LanguageString (val); if (llvmstr == NULL) { snprintf (invalid, sizeof (invalid), "Unknown DW_LANG constant: 0x%x", val); @@ -407,7 +314,7 @@ DW_ID_value_to_name (uint32_t val) { static char invalid[100]; - const char *llvmstr = CaseString (val); + const char *llvmstr = llvm::dwarf::CaseString (val); if (llvmstr == NULL) { snprintf (invalid, sizeof (invalid), "Unknown DW_ID constant: 0x%x", val); @@ -420,7 +327,7 @@ DW_CC_value_to_name (uint32_t val) { static char invalid[100]; - const char *llvmstr = ConventionString (val); + const char *llvmstr = llvm::dwarf::ConventionString (val); if (llvmstr == NULL) { snprintf (invalid, sizeof (invalid), "Unknown DW_CC constant: 0x%x", val); @@ -433,7 +340,7 @@ DW_INL_value_to_name (uint32_t val) { static char invalid[100]; - const char *llvmstr = InlineCodeString (val); + const char *llvmstr = llvm::dwarf::InlineCodeString (val); if (llvmstr == NULL) { snprintf (invalid, sizeof (invalid), "Unknown DW_INL constant: 0x%x", val); @@ -446,7 +353,7 @@ DW_ORD_value_to_name (uint32_t val) { static char invalid[100]; - const char *llvmstr = ArrayOrderString (val); + const char *llvmstr = llvm::dwarf::ArrayOrderString (val); if (llvmstr == NULL) { snprintf (invalid, sizeof (invalid), "Unknown DW_ORD constant: 0x%x", val); @@ -459,7 +366,7 @@ DW_DSC_value_to_name (uint32_t val) { static char invalid[100]; - const char *llvmstr = DiscriminantString (val); + const char *llvmstr = llvm::dwarf::DiscriminantString (val); if (llvmstr == NULL) { snprintf (invalid, sizeof (invalid), "Unknown DW_DSC constant: 0x%x", val); @@ -472,7 +379,7 @@ DW_LNS_value_to_name (uint32_t val) { static char invalid[100]; - const char *llvmstr = LNStandardString (val); + const char *llvmstr = llvm::dwarf::LNStandardString (val); if (llvmstr == NULL) { snprintf (invalid, sizeof (invalid), "Unknown DW_LNS constant: 0x%x", val); @@ -485,7 +392,7 @@ DW_LNE_value_to_name (uint32_t val) { static char invalid[100]; - const char *llvmstr = LNExtendedString (val); + const char *llvmstr = llvm::dwarf::LNExtendedString (val); if (llvmstr == NULL) { snprintf (invalid, sizeof (invalid), "Unknown DW_LNE constant: 0x%x", val); @@ -498,7 +405,7 @@ DW_MACINFO_value_to_name (uint32_t val) { static char invalid[100]; - const char *llvmstr = MacinfoString (val); + const char *llvmstr = llvm::dwarf::MacinfoString (val); if (llvmstr == NULL) { snprintf (invalid, sizeof (invalid), "Unknown DW_MACINFO constant: 0x%x", val); @@ -511,7 +418,7 @@ DW_CFA_value_to_name (uint32_t val) { static char invalid[100]; - const char *llvmstr = CallFrameString (val); + const char *llvmstr = llvm::dwarf::CallFrameString (val); if (llvmstr == NULL) { snprintf (invalid, sizeof (invalid), "Unknown DW_CFA constant: 0x%x", val); Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDefines.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDefines.h?rev=118654&r1=118653&r2=118654&view=diff ============================================================================== --- lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDefines.h (original) +++ lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDefines.h Tue Nov 9 17:46:37 2010 @@ -27,20 +27,19 @@ }; typedef enum DW_TAG_Category DW_TAG_CategoryEnum; + const char *DW_TAG_value_to_name (uint32_t val); -const char *DW_TAG_value_to_englishy_name (uint32_t val); + DW_TAG_CategoryEnum get_tag_category (uint16_t tag); const char *DW_CHILDREN_value_to_name (uint8_t val); const char *DW_AT_value_to_name (uint32_t val); -const char *DW_AT_value_to_englishy_name (uint32_t val); const char *DW_FORM_value_to_name (uint32_t val); -const char *DW_FORM_value_to_englishy_name (uint32_t val); const char *DW_OP_value_to_name (uint32_t val); -const char *DW_OP_value_to_englishy_name (uint32_t val); + DRC_class DW_OP_value_to_class (uint32_t val); const char *DW_ATE_value_to_name (uint32_t val); Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFLocationDescription.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFLocationDescription.cpp?rev=118654&r1=118653&r2=118654&view=diff ============================================================================== --- lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFLocationDescription.cpp (original) +++ lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFLocationDescription.cpp Tue Nov 9 17:46:37 2010 @@ -61,7 +61,7 @@ opcode_class = DW_OP_value_to_class (opcode) & (~DRC_DWARFv3); - s->Printf("%s ", DW_OP_value_to_englishy_name (opcode)); + s->Printf("%s ", DW_OP_value_to_name (opcode)); /* Does this take zero parameters? If so we can shortcut this function. */ if (opcode_class == DRC_ZEROOPERANDS) 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=118654&r1=118653&r2=118654&view=diff ============================================================================== --- lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp (original) +++ lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp Tue Nov 9 17:46:37 2010 @@ -145,6 +145,7 @@ SymbolFileDWARF::SymbolFileDWARF(ObjectFile* objfile) : SymbolFile (objfile), m_debug_map_symfile (NULL), + m_clang_tu_decl (NULL), m_flags(), m_data_debug_abbrev(), m_data_debug_frame(), @@ -2531,7 +2532,10 @@ die = die->GetParent(); } - return NULL; + // Right now we have only one translation unit per module... + if (m_clang_tu_decl == NULL) + m_clang_tu_decl = m_obj_file->GetModule()->GetTypeList()->GetClangASTContext().getASTContext()->getTranslationUnitDecl(); + return m_clang_tu_decl; } // This function can be used when a DIE is found that is a forward declaration @@ -2810,12 +2814,7 @@ break; case DW_AT_declaration: - // Make sure the declaration is from this DIE, and not from - // a DW_AT_specification or DW_AT_abstract_origin by checking - // this die and seeing if its abbreviations have the - // DW_AT_declaration attribute - if (die->GetAbbreviationDeclarationPtr()->FindAttributeIndex (DW_AT_declaration) != DW_INVALID_INDEX) - is_forward_declaration = form_value.Unsigned() != 0; + is_forward_declaration = form_value.Unsigned() != 0; break; case DW_AT_APPLE_runtime_class: @@ -2938,24 +2937,17 @@ { switch (attr) { - case DW_AT_decl_file: decl.SetFile(sc.comp_unit->GetSupportFiles().GetFileSpecAtIndex(form_value.Unsigned())); break; - case DW_AT_decl_line: decl.SetLine(form_value.Unsigned()); break; - case DW_AT_decl_column: decl.SetColumn(form_value.Unsigned()); break; + case DW_AT_decl_file: decl.SetFile(sc.comp_unit->GetSupportFiles().GetFileSpecAtIndex(form_value.Unsigned())); break; + case DW_AT_decl_line: decl.SetLine(form_value.Unsigned()); break; + case DW_AT_decl_column: decl.SetColumn(form_value.Unsigned()); break; case DW_AT_name: type_name_cstr = form_value.AsCString(&get_debug_str_data()); type_name_const_str.SetCString(type_name_cstr); 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 = DW_ACCESS_to_AccessType(form_value.Unsigned()); break; - case DW_AT_declaration: - // Make sure the declaration is from this DIE, and not from - // a DW_AT_specification or DW_AT_abstract_origin by checking - // this die and seeing if its abbreviations have the - // DW_AT_declaration attribute - if (die->GetAbbreviationDeclarationPtr()->FindAttributeIndex (DW_AT_declaration) != DW_INVALID_INDEX) - is_forward_declaration = form_value.Unsigned() != 0; - 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 = 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: case DW_AT_bit_stride: @@ -3047,14 +3039,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 = DW_ACCESS_to_AccessType(form_value.Unsigned()); break; - case DW_AT_declaration: - // Make sure the declaration is from this DIE, and not from - // a DW_AT_specification or DW_AT_abstract_origin by checking - // this die and seeing if its abbreviations have the - // DW_AT_declaration attribute - if (die->GetAbbreviationDeclarationPtr()->FindAttributeIndex (DW_AT_declaration) != DW_INVALID_INDEX) - is_forward_declaration = form_value.Unsigned() != 0; - break; + case DW_AT_declaration: is_forward_declaration = form_value.Unsigned() != 0; break; case DW_AT_inline: is_inline = form_value.Unsigned() != 0; break; case DW_AT_virtuality: is_virtual = form_value.Unsigned() != 0; break; case DW_AT_explicit: is_explicit = form_value.Unsigned() != 0; break; @@ -3267,14 +3252,7 @@ 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 = DW_ACCESS_to_AccessType(form_value.Unsigned()); break; - case DW_AT_declaration: - // Make sure the declaration is from this DIE, and not from - // a DW_AT_specification or DW_AT_abstract_origin by checking - // this die and seeing if its abbreviations have the - // DW_AT_declaration attribute - if (die->GetAbbreviationDeclarationPtr()->FindAttributeIndex (DW_AT_declaration) != DW_INVALID_INDEX) - is_forward_declaration = form_value.Unsigned() != 0; - break; + case DW_AT_declaration: is_forward_declaration = form_value.Unsigned() != 0; break; case DW_AT_allocated: case DW_AT_associated: case DW_AT_data_location: 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=118654&r1=118653&r2=118654&view=diff ============================================================================== --- lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h (original) +++ lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h Tue Nov 9 17:46:37 2010 @@ -20,6 +20,7 @@ // Other libraries and framework includes #include "llvm/ADT/DenseMap.h" +#include "lldb/Core/ClangForward.h" #include "lldb/Core/ConstString.h" #include "lldb/Core/dwarf.h" #include "lldb/Core/DataExtractor.h" @@ -296,7 +297,8 @@ m_debug_map_symfile = debug_map_symfile; } - SymbolFileDWARFDebugMap* m_debug_map_symfile; + SymbolFileDWARFDebugMap * m_debug_map_symfile; + clang::TranslationUnitDecl * m_clang_tu_decl; lldb_private::Flags m_flags; lldb_private::DataExtractor m_dwarf_data; lldb_private::DataExtractor m_data_debug_abbrev; From johnny.chen at apple.com Tue Nov 9 17:56:14 2010 From: johnny.chen at apple.com (Johnny Chen) Date: Tue, 09 Nov 2010 23:56:14 -0000 Subject: [Lldb-commits] [lldb] r118655 - /lldb/trunk/test/dotest.py Message-ID: <20101109235614.8579E2A6C12C@llvm.org> Author: johnny Date: Tue Nov 9 17:56:14 2010 New Revision: 118655 URL: http://llvm.org/viewvc/llvm-project?rev=118655&view=rev Log: Add more comments on LLDBTestResult class. Modified: lldb/trunk/test/dotest.py Modified: lldb/trunk/test/dotest.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/dotest.py?rev=118655&r1=118654&r2=118655&view=diff ============================================================================== --- lldb/trunk/test/dotest.py (original) +++ lldb/trunk/test/dotest.py Tue Nov 9 17:56:14 2010 @@ -670,10 +670,14 @@ % (suite.countTestCases(), suite.countTestCases() != 1 and "s" or "")) - # Invoke the test runner. class LLDBTestResult(unittest2.TextTestResult): """ - Enforce a singleton pattern to allow inspection of test progress. + Enforce a singleton pattern to allow introspection of test progress. + + Overwrite addError(), addFailure(), and addExpectedFailure() methods + to enable each test instance to track its failure/error status. It + is used in the LLDB test framework to emit detailed trace messages + to a log file for easier human inspection of test failres/errors. """ __singleton__ = None @@ -709,6 +713,7 @@ if method: method() + # Invoke the test runner. result = unittest2.TextTestRunner(stream=sys.stderr, verbosity=verbose, resultclass=LLDBTestResult).run(suite) From scallanan at apple.com Tue Nov 9 19:38:28 2010 From: scallanan at apple.com (Sean Callanan) Date: Wed, 10 Nov 2010 01:38:28 -0000 Subject: [Lldb-commits] [lldb] r118666 - /lldb/trunk/source/Plugins/Disassembler/llvm/DisassemblerLLVM.cpp Message-ID: <20101110013829.08E262A6C12C@llvm.org> Author: spyffe Date: Tue Nov 9 19:38:28 2010 New Revision: 118666 URL: http://llvm.org/viewvc/llvm-project?rev=118666&view=rev Log: Fixed a bug where the LLVM disassembler was ignoring the show_address parameter. Modified: lldb/trunk/source/Plugins/Disassembler/llvm/DisassemblerLLVM.cpp 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=118666&r1=118665&r2=118666&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Disassembler/llvm/DisassemblerLLVM.cpp (original) +++ lldb/trunk/source/Plugins/Disassembler/llvm/DisassemblerLLVM.cpp Tue Nov 9 19:38:28 2010 @@ -115,7 +115,7 @@ exe_scope = exe_ctx->GetBestExecutionContextScope(); // If we have an address, print it out - if (GetAddress().IsValid()) + if (GetAddress().IsValid() && show_address) { if (GetAddress().Dump (s, exe_scope, From gclayton at apple.com Tue Nov 9 22:57:05 2010 From: gclayton at apple.com (Greg Clayton) Date: Wed, 10 Nov 2010 04:57:05 -0000 Subject: [Lldb-commits] [lldb] r118672 - in /lldb/trunk: include/lldb/Host/Host.h include/lldb/Symbol/SymbolFile.h source/Host/common/Host.cpp source/Host/macosx/Host.mm source/Interpreter/CommandInterpreter.cpp source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h source/Symbol/SymbolFile.cpp source/Symbol/Type.cpp Message-ID: <20101110045705.47FE32A6C12C@llvm.org> Author: gclayton Date: Tue Nov 9 22:57:04 2010 New Revision: 118672 URL: http://llvm.org/viewvc/llvm-project?rev=118672&view=rev Log: Modified lldb_private::SymboleFile to be able to override where its TypeList comes from by using a virtual function to provide it from the Module's SymbolVendor by default. This allows the DWARF parser, when being used to parse DWARF in .o files with a parent DWARF + debug map parser, to get its type list from the DWARF + debug map parser so when we go and find full definitions for types (that might come from other .o files), we can use the type list from the debug map parser. Otherwise we ended up mixing clang types from one .o file (say a const pointer to a forward declaration "class A") with the a full type from another .o file. This causes expression parsing, when copying the clang types from those parsed by the DWARF parser into the expression AST, to fail -- for good reason. Now all types are created in the same list. Also added host support for crash description strings that can be set before doing a piece of work. On MacOSX, this ties in with CrashReporter support that allows a string to be dispalyed when the app crashes and allows LLDB.framework to print a description string in the crash log. Right now this is hookup up the the CommandInterpreter::HandleCommand() where each command notes that it is about to be executed, so if we crash while trying to do this command, we should be able to see the command that caused LLDB to exit. For all other platforms, this is a nop. Modified: lldb/trunk/include/lldb/Host/Host.h lldb/trunk/include/lldb/Symbol/SymbolFile.h lldb/trunk/source/Host/common/Host.cpp lldb/trunk/source/Host/macosx/Host.mm lldb/trunk/source/Interpreter/CommandInterpreter.cpp lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h lldb/trunk/source/Symbol/SymbolFile.cpp lldb/trunk/source/Symbol/Type.cpp Modified: lldb/trunk/include/lldb/Host/Host.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Host/Host.h?rev=118672&r1=118671&r2=118672&view=diff ============================================================================== --- lldb/trunk/include/lldb/Host/Host.h (original) +++ lldb/trunk/include/lldb/Host/Host.h Tue Nov 9 22:57:04 2010 @@ -297,6 +297,25 @@ GetLLDBPath (lldb::PathType path_type, FileSpec &file_spec); + //------------------------------------------------------------------ + /// Set a string that can be displayed if host application crashes. + /// + /// Some operating systems have the ability to print a description + /// for shared libraries when a program crashes. If the host OS + /// supports such a mechanism, it should be implemented to help + /// with crash triage. + /// + /// @param[in] format + /// A printf format that will be used to form a new crash + /// description string. + //------------------------------------------------------------------ + static void + SetCrashDescriptionWithFormat (const char *format, ...); + + static void + SetCrashDescription (const char *description); + + static uint32_t ListProcessesMatchingName (const char *name, StringList &matches, std::vector &pids); Modified: lldb/trunk/include/lldb/Symbol/SymbolFile.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Symbol/SymbolFile.h?rev=118672&r1=118671&r2=118672&view=diff ============================================================================== --- lldb/trunk/include/lldb/Symbol/SymbolFile.h (original) +++ lldb/trunk/include/lldb/Symbol/SymbolFile.h Tue Nov 9 22:57:04 2010 @@ -80,6 +80,7 @@ virtual uint32_t FindFunctions (const RegularExpression& regex, bool append, SymbolContextList& sc_list) = 0; virtual uint32_t FindTypes (const SymbolContext& sc, const ConstString &name, bool append, uint32_t max_matches, TypeList& types) = 0; // virtual uint32_t FindTypes (const SymbolContext& sc, const RegularExpression& regex, bool append, uint32_t max_matches, TypeList& types) = 0; + virtual TypeList * GetTypeList (); ObjectFile* GetObjectFile() { return m_obj_file; } const ObjectFile* GetObjectFile() const { return m_obj_file; } Modified: lldb/trunk/source/Host/common/Host.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/common/Host.cpp?rev=118672&r1=118671&r2=118672&view=diff ============================================================================== --- lldb/trunk/source/Host/common/Host.cpp (original) +++ lldb/trunk/source/Host/common/Host.cpp Tue Nov 9 22:57:04 2010 @@ -867,6 +867,15 @@ return false; } +void +Host::SetCrashDescriptionWithFormat (const char *format, ...) +{ +} + +void +Host::SetCrashDescription (const char *description) +{ +} lldb::pid_t LaunchApplication (const FileSpec &app_file_spec) Modified: lldb/trunk/source/Host/macosx/Host.mm URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/macosx/Host.mm?rev=118672&r1=118671&r2=118672&view=diff ============================================================================== --- lldb/trunk/source/Host/macosx/Host.mm (original) +++ lldb/trunk/source/Host/macosx/Host.mm Tue Nov 9 22:57:04 2010 @@ -528,6 +528,48 @@ #endif } +// On MacOSX CrashReporter will display a string for each shared library if +// the shared library has an exported symbol named "__crashreporter_info__". + +static Mutex& +GetCrashReporterMutex () +{ + static Mutex g_mutex; + return g_mutex; +} + +extern "C" { + const char *__crashreporter_info__ = NULL; +}; + +asm(".desc ___crashreporter_info__, 0x10"); + +void +Host::SetCrashDescriptionWithFormat (const char *format, ...) +{ + static StreamString g_crash_description; + Mutex::Locker locker (GetCrashReporterMutex ()); + + if (format) + { + va_list args; + va_start (args, format); + g_crash_description.PrintfVarArg(format, args); + va_end (args); + __crashreporter_info__ = g_crash_description.GetData(); + } + else + { + __crashreporter_info__ = NULL; + } +} + +void +Host::SetCrashDescription (const char *cstr) +{ + Mutex::Locker locker (GetCrashReporterMutex ()); + __crashreporter_info__ = cstr; +} bool Host::OpenFileInExternalEditor (const FileSpec &file_spec, uint32_t line_no) Modified: lldb/trunk/source/Interpreter/CommandInterpreter.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Interpreter/CommandInterpreter.cpp?rev=118672&r1=118671&r2=118672&view=diff ============================================================================== --- lldb/trunk/source/Interpreter/CommandInterpreter.cpp (original) +++ lldb/trunk/source/Interpreter/CommandInterpreter.cpp Tue Nov 9 22:57:04 2010 @@ -45,6 +45,7 @@ #include "lldb/Target/Process.h" #include "lldb/Target/Thread.h" #include "lldb/Target/TargetList.h" +#include "lldb/Utility/CleanUp.h" #include "lldb/Interpreter/CommandReturnObject.h" #include "lldb/Interpreter/CommandInterpreter.h" @@ -504,6 +505,12 @@ // FIXME: there should probably be a mutex to make sure only one thread can // run the interpreter at a time. + Host::SetCrashDescriptionWithFormat ("HandleCommand(command = \"%s\")", command_line); + + // Make a scoped cleanup object that will clear the crash description string + // on exit of this function. + lldb_utility::CleanUp crash_description_cleanup(NULL, Host::SetCrashDescription); + // TODO: this should be a logging channel in lldb. // if (DebugSelf()) // { 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=118672&r1=118671&r2=118672&view=diff ============================================================================== --- lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp (original) +++ lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp Tue Nov 9 22:57:04 2010 @@ -117,6 +117,22 @@ return new SymbolFileDWARF(obj_file); } + +ClangASTContext & +SymbolFileDWARF::GetClangASTContext() +{ + return GetTypeList()->GetClangASTContext(); +} + +TypeList * +SymbolFileDWARF::GetTypeList () +{ + if (m_debug_map_symfile) + return m_debug_map_symfile->GetTypeList(); + return m_obj_file->GetModule()->GetTypeList(); + +} + //---------------------------------------------------------------------- // Gets the first parent that is a lexical block, function or inlined // subroutine, or compile unit. @@ -1057,8 +1073,6 @@ if (parent_die == NULL) return 0; - TypeList* type_list = m_obj_file->GetModule()->GetTypeList(); - size_t count = 0; const DWARFDebugInfoEntry *die; const uint8_t *fixed_form_sizes = DWARFFormValue::GetFixedFormSizesForAddressSize (dwarf_cu->GetAddressByteSize()); @@ -1144,7 +1158,7 @@ accessibility = default_accessibility; member_accessibilities.push_back(accessibility); - type_list->GetClangASTContext().AddFieldToRecordType (class_clang_type, name, member_type->GetClangType(), accessibility, bit_size); + GetClangASTContext().AddFieldToRecordType (class_clang_type, name, member_type->GetClangType(), accessibility, bit_size); } } } @@ -1217,11 +1231,11 @@ if (class_language == eLanguageTypeObjC) { - type_list->GetClangASTContext().SetObjCSuperClass(class_clang_type, base_class_dctype->GetClangType()); + GetClangASTContext().SetObjCSuperClass(class_clang_type, base_class_dctype->GetClangType()); } else { - base_classes.push_back (type_list->GetClangASTContext().CreateBaseClassSpecifier (base_class_dctype->GetClangType(), accessibility, is_virtual, is_base_of_class)); + base_classes.push_back (GetClangASTContext().CreateBaseClassSpecifier (base_class_dctype->GetClangType(), accessibility, is_virtual, is_base_of_class)); assert(base_classes.back()); } } @@ -1288,18 +1302,21 @@ const dw_tag_t tag = die->Tag(); - DEBUG_PRINTF ("0x%8.8x: %s (\"%s\") - resolve forward declaration...\n", die->GetOffset(), DW_TAG_value_to_name(tag), type->GetName().AsCString()); + DEBUG_PRINTF ("0x%8.8x: %s (\"%s\") - resolve forward declaration...\n", + die->GetOffset(), + DW_TAG_value_to_name(tag), + type->GetName().AsCString()); assert (clang_type); DWARFDebugInfoEntry::Attributes attributes; - TypeList* type_list = m_obj_file->GetModule()->GetTypeList(); + ClangASTContext &ast = GetClangASTContext(); switch (tag) { case DW_TAG_structure_type: case DW_TAG_union_type: case DW_TAG_class_type: - type_list->GetClangASTContext().StartTagDeclarationDefinition (clang_type); + ast.StartTagDeclarationDefinition (clang_type); if (die->HasChildren()) { LanguageType class_language = eLanguageTypeUnknown; @@ -1386,7 +1403,7 @@ if (class_language != eLanguageTypeObjC) { if (is_a_class && tag_decl_kind != clang::TTK_Class) - type_list->GetClangASTContext().SetTagTypeKind (clang_type, clang::TTK_Class); + ast.SetTagTypeKind (clang_type, clang::TTK_Class); } // Since DW_TAG_structure_type gets used for both classes @@ -1403,30 +1420,36 @@ { // This is a class and all members that didn't have // their access specified are private. - type_list->GetClangASTContext().SetDefaultAccessForRecordFields (clang_type, eAccessPrivate, &member_accessibilities.front(), member_accessibilities.size()); + ast.SetDefaultAccessForRecordFields (clang_type, + eAccessPrivate, + &member_accessibilities.front(), + member_accessibilities.size()); } if (!base_classes.empty()) { - type_list->GetClangASTContext().SetBaseClassesForClassType (clang_type, &base_classes.front(), base_classes.size()); + ast.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()); + ClangASTContext::DeleteBaseClassSpecifiers (&base_classes.front(), + base_classes.size()); } } - type_list->GetClangASTContext().CompleteTagDeclarationDefinition (clang_type); + ast.CompleteTagDeclarationDefinition (clang_type); return clang_type; case DW_TAG_enumeration_type: - type_list->GetClangASTContext().StartTagDeclarationDefinition (clang_type); + ast.StartTagDeclarationDefinition (clang_type); if (die->HasChildren()) { SymbolContext sc(GetCompUnitForDWARFCompUnit(cu)); ParseChildEnumerators(sc, clang_type, type->GetByteSize(), cu, die); } - type_list->GetClangASTContext().CompleteTagDeclarationDefinition (clang_type); + ast.CompleteTagDeclarationDefinition (clang_type); return clang_type; default: @@ -2066,7 +2089,7 @@ if (matching_type) { // We found a type pointer, now find the shared pointer form our type list - TypeSP type_sp (m_obj_file->GetModule()->GetTypeList()->FindType(matching_type->GetID())); + TypeSP type_sp (GetTypeList()->FindType(matching_type->GetID())); assert (type_sp.get() != NULL); types.InsertUnique (type_sp); if (types.GetSize() >= max_matches) @@ -2094,7 +2117,7 @@ if (matching_type) { // We found a type pointer, now find the shared pointer form our type list - TypeSP type_sp (m_obj_file->GetModule()->GetTypeList()->FindType(matching_type->GetID())); + TypeSP type_sp (GetTypeList()->FindType(matching_type->GetID())); assert (type_sp.get() != NULL); types.InsertUnique (type_sp); ++num_matches; @@ -2213,7 +2236,7 @@ { function_param_types.push_back (type->GetClangForwardType()); - clang::ParmVarDecl *param_var_decl = type_list->GetClangASTContext().CreateParameterDeclaration (name, type->GetClangForwardType(), storage); + clang::ParmVarDecl *param_var_decl = GetClangASTContext().CreateParameterDeclaration (name, type->GetClangForwardType(), storage); assert(param_var_decl); function_param_decls.push_back(param_var_decl); } @@ -2291,13 +2314,12 @@ if (name && name[0] && got_value) { - TypeList* type_list = m_obj_file->GetModule()->GetTypeList(); - type_list->GetClangASTContext().AddEnumerationValueToEnumerationType (enumerator_clang_type, - enumerator_clang_type, - decl, - name, - enum_value, - enumerator_byte_size * 8); + GetClangASTContext().AddEnumerationValueToEnumerationType (enumerator_clang_type, + enumerator_clang_type, + decl, + name, + enum_value, + enumerator_byte_size * 8); ++enumerators_added; } } @@ -2470,7 +2492,7 @@ else if (type_ptr != DIE_IS_BEING_PARSED) { // Grab the existing type from the master types lists - type_sp = m_obj_file->GetModule()->GetTypeList()->FindType(type_ptr->GetID()); + type_sp = GetTypeList()->FindType(type_ptr->GetID()); } } @@ -2507,10 +2529,8 @@ const char *namespace_name = die->GetAttributeValueAsString(this, cu, DW_AT_name, NULL); if (namespace_name) { - TypeList* type_list = m_obj_file->GetModule()->GetTypeList(); - assert(type_list); Declaration decl; // TODO: fill in the decl object - clang::NamespaceDecl *namespace_decl = type_list->GetClangASTContext().GetUniqueNamespaceDeclaration (namespace_name, decl, GetClangDeclContextForDIE (cu, die->GetParent())); + clang::NamespaceDecl *namespace_decl = GetClangASTContext().GetUniqueNamespaceDeclaration (namespace_name, decl, GetClangDeclContextForDIE (cu, die->GetParent())); if (namespace_decl) m_die_to_decl_ctx[die] = (clang::DeclContext*)namespace_decl; return namespace_decl; @@ -2534,7 +2554,7 @@ } // Right now we have only one translation unit per module... if (m_clang_tu_decl == NULL) - m_clang_tu_decl = m_obj_file->GetModule()->GetTypeList()->GetClangASTContext().getASTContext()->getTranslationUnitDecl(); + m_clang_tu_decl = GetClangASTContext().getASTContext()->getTranslationUnitDecl(); return m_clang_tu_decl; } @@ -2592,7 +2612,7 @@ type_cu->GetOffset()); m_die_to_type[die] = resolved_type; - type_sp = m_obj_file->GetModule()->GetTypeList()->FindType(resolved_type->GetID()); + type_sp = GetTypeList()->FindType(resolved_type->GetID()); if (!type_sp) { DEBUG_PRINTF("unable to resolve type '%s' from DIE 0x%8.8x\n", type_name.GetCString(), die->GetOffset()); @@ -2618,8 +2638,10 @@ if (die != NULL) { Type *type_ptr = m_die_to_type.lookup (die); + TypeList* type_list = GetTypeList(); if (type_ptr == NULL) { + ClangASTContext &ast = GetClangASTContext(); if (type_is_new_ptr) *type_is_new_ptr = true; @@ -2632,7 +2654,6 @@ Type::EncodingDataType encoding_data_type = Type::eEncodingIsUID; clang_type_t clang_type = NULL; - TypeList* type_list = m_obj_file->GetModule()->GetTypeList(); dw_attr_t attr; switch (tag) @@ -2689,7 +2710,9 @@ { default: case DW_TAG_base_type: - clang_type = type_list->GetClangASTContext().GetBuiltinTypeForDWARFEncodingAndBitSize (type_name_cstr, encoding, byte_size * 8); + clang_type = ast.GetBuiltinTypeForDWARFEncodingAndBitSize (type_name_cstr, + encoding, + byte_size * 8); break; case DW_TAG_pointer_type: @@ -2738,20 +2761,29 @@ if (type_name_const_str == g_objc_type_name_id) { - clang_type = type_list->GetClangASTContext().GetBuiltInType_objc_id(); + clang_type = ast.GetBuiltInType_objc_id(); } else if (type_name_const_str == g_objc_type_name_Class) { - clang_type = type_list->GetClangASTContext().GetBuiltInType_objc_Class(); + clang_type = ast.GetBuiltInType_objc_Class(); } else if (type_name_const_str == g_objc_type_name_selector) { - clang_type = type_list->GetClangASTContext().GetBuiltInType_objc_selector(); + clang_type = ast.GetBuiltInType_objc_selector(); } } - type_sp.reset( new Type(die->GetOffset(), this, type_name_const_str, byte_size, NULL, encoding_uid, encoding_data_type, &decl, clang_type, clang_type == NULL)); - + type_sp.reset( new Type (die->GetOffset(), + this, + type_name_const_str, + byte_size, + NULL, + encoding_uid, + encoding_data_type, + &decl, + clang_type, + clang_type == NULL)); + m_die_to_type[die] = type_sp.get(); // Type* encoding_type = GetUniquedTypeForDIEOffset(encoding_uid, type_sp, NULL, 0, 0, false); @@ -2883,7 +2915,10 @@ if (clang_type == NULL) { clang_type_was_created = true; - clang_type = type_list->GetClangASTContext().CreateRecordType (type_name_cstr, tag_decl_kind, GetClangDeclContextForDIE (dwarf_cu, die), class_language); + clang_type = ast.CreateRecordType (type_name_cstr, + tag_decl_kind, + GetClangDeclContextForDIE (dwarf_cu, die), + class_language); } // Store a forward declaration to this class type in case any @@ -2891,15 +2926,24 @@ // types for function prototypes. m_die_to_decl_ctx[die] = ClangASTContext::GetDeclContextForType (clang_type); const bool is_forward_decl = die->HasChildren(); - type_sp.reset (new Type(die->GetOffset(), this, type_name_const_str, byte_size, NULL, LLDB_INVALID_UID, Type::eEncodingIsUID, &decl, clang_type, is_forward_decl)); - + type_sp.reset (new Type (die->GetOffset(), + this, + type_name_const_str, + byte_size, + NULL, + LLDB_INVALID_UID, + Type::eEncodingIsUID, + &decl, + clang_type, + is_forward_decl)); + m_die_to_type[die] = type_sp.get(); if (die->HasChildren() == false && is_forward_declaration == false) { // No children for this struct/union/class, lets finish it - type_list->GetClangASTContext().StartTagDeclarationDefinition (clang_type); - type_list->GetClangASTContext().CompleteTagDeclarationDefinition (clang_type); + ast.StartTagDeclarationDefinition (clang_type); + ast.CompleteTagDeclarationDefinition (clang_type); } else if (clang_type_was_created) { @@ -2970,8 +3014,12 @@ clang_type = m_forward_decl_die_to_clang_type.lookup (die); if (clang_type == NULL) { - enumerator_clang_type = type_list->GetClangASTContext().GetBuiltinTypeForDWARFEncodingAndBitSize (NULL, DW_ATE_signed, byte_size * 8); - clang_type = type_list->GetClangASTContext().CreateEnumerationType(decl, type_name_cstr, enumerator_clang_type); + enumerator_clang_type = ast.GetBuiltinTypeForDWARFEncodingAndBitSize (NULL, + DW_ATE_signed, + byte_size * 8); + clang_type = ast.CreateEnumerationType (decl, + type_name_cstr, + enumerator_clang_type); } else { @@ -2980,8 +3028,17 @@ } m_die_to_decl_ctx[die] = ClangASTContext::GetDeclContextForType (clang_type); - type_sp.reset( new Type(die->GetOffset(), this, type_name_const_str, byte_size, NULL, encoding_uid, Type::eEncodingIsUID, &decl, clang_type, true)); - + type_sp.reset( new Type (die->GetOffset(), + this, + type_name_const_str, + byte_size, + NULL, + encoding_uid, + Type::eEncodingIsUID, + &decl, + clang_type, + true)); + m_die_to_type[die] = type_sp.get(); // Leave this as a forward declaration until we need @@ -3098,7 +3155,7 @@ if (func_type) return_clang_type = func_type->GetClangForwardType(); else - return_clang_type = type_list->GetClangASTContext().GetBuiltInType_void(); + return_clang_type = ast.GetBuiltInType_void(); std::vector function_param_types; @@ -3108,12 +3165,23 @@ if (die->HasChildren()) { bool skip_artificial = true; - ParseChildParameters (sc, type_sp, dwarf_cu, die, skip_artificial, type_list, function_param_types, function_param_decls); + ParseChildParameters (sc, + type_sp, + dwarf_cu, + die, + skip_artificial, + type_list, + function_param_types, + function_param_decls); } // clang_type will get the function prototype clang type after this call - clang_type = type_list->GetClangASTContext().CreateFunctionType (return_clang_type, &function_param_types[0], function_param_types.size(), is_variadic, type_quals); - + clang_type = ast.CreateFunctionType (return_clang_type, + &function_param_types[0], + function_param_types.size(), + is_variadic, + type_quals); + if (type_name_cstr) { bool type_handled = false; @@ -3157,10 +3225,10 @@ accessibility = eAccessPublic; clang::ObjCMethodDecl *objc_method_decl; - objc_method_decl = type_list->GetClangASTContext().AddMethodToObjCObjectType (class_opaque_type, - type_name_cstr, - clang_type, - accessibility); + objc_method_decl = ast.AddMethodToObjCObjectType (class_opaque_type, + type_name_cstr, + clang_type, + accessibility); type_handled = objc_method_decl != NULL; } } @@ -3182,14 +3250,14 @@ accessibility = eAccessPublic; clang::CXXMethodDecl *cxx_method_decl; - cxx_method_decl = type_list->GetClangASTContext().AddMethodToCXXRecordType (class_opaque_type, - type_name_cstr, - clang_type, - accessibility, - is_virtual, - is_static, - is_inline, - is_explicit); + cxx_method_decl = ast.AddMethodToCXXRecordType (class_opaque_type, + type_name_cstr, + clang_type, + accessibility, + is_virtual, + is_static, + is_inline, + is_explicit); type_handled = cxx_method_decl != NULL; } } @@ -3199,17 +3267,31 @@ if (!type_handled) { // We just have a function that isn't part of a class - clang::FunctionDecl *function_decl = type_list->GetClangASTContext().CreateFunctionDeclaration (type_name_cstr, clang_type, storage, is_inline); + clang::FunctionDecl *function_decl = ast.CreateFunctionDeclaration (type_name_cstr, + clang_type, + storage, + is_inline); // Add the decl to our DIE to decl context map 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.front(), function_param_decls.size()); + ast.SetFunctionParameters (function_decl, + &function_param_decls.front(), + function_param_decls.size()); } } - type_sp.reset( new Type(die->GetOffset(), this, type_name_const_str, 0, NULL, LLDB_INVALID_UID, Type::eEncodingIsUID, &decl, clang_type, false)); - + type_sp.reset( new Type (die->GetOffset(), + this, + type_name_const_str, + 0, + NULL, + LLDB_INVALID_UID, + Type::eEncodingIsUID, + &decl, + clang_type, + false)); + m_die_to_type[die] = type_sp.get(); assert(type_sp.get()); } @@ -3289,12 +3371,23 @@ for (pos = element_orders.rbegin(); pos != end; ++pos) { num_elements = *pos; - clang_type = type_list->GetClangASTContext().CreateArrayType (array_element_type, num_elements, num_elements * array_element_bit_stride); + clang_type = ast.CreateArrayType (array_element_type, + num_elements, + num_elements * array_element_bit_stride); array_element_type = clang_type; array_element_bit_stride = array_element_bit_stride * num_elements; } ConstString empty_name; - type_sp.reset( new Type(die->GetOffset(), this, empty_name, array_element_bit_stride / 8, NULL, LLDB_INVALID_UID, Type::eEncodingIsUID, &decl, clang_type, false)); + type_sp.reset( new Type (die->GetOffset(), + this, + empty_name, + array_element_bit_stride / 8, + NULL, + LLDB_INVALID_UID, + Type::eEncodingIsUID, + &decl, + clang_type, + false)); m_die_to_type[die] = type_sp.get(); } } @@ -3332,11 +3425,22 @@ clang_type_t pointee_clang_type = pointee_type->GetClangType(); clang_type_t class_clang_type = class_type->GetClangType(); - clang_type = type_list->GetClangASTContext().CreateMemberPointerType(pointee_clang_type, class_clang_type); + clang_type = ast.CreateMemberPointerType(pointee_clang_type, + class_clang_type); - size_t byte_size = ClangASTType::GetClangTypeBitWidth (type_list->GetClangASTContext().getASTContext(), clang_type) / 8; + size_t byte_size = ClangASTType::GetClangTypeBitWidth (ast.getASTContext(), + clang_type) / 8; - type_sp.reset( new Type(die->GetOffset(), this, type_name_const_str, byte_size, NULL, LLDB_INVALID_UID, Type::eEncodingIsUID, NULL, clang_type, false)); + type_sp.reset( new Type (die->GetOffset(), + this, + type_name_const_str, + byte_size, + NULL, + LLDB_INVALID_UID, + Type::eEncodingIsUID, + NULL, + clang_type, + false)); m_die_to_type[die] = type_sp.get(); } @@ -3379,10 +3483,7 @@ if (type_sp.unique()) { // We are ready to put this type into the uniqued list up at the module level - m_obj_file->GetModule()->GetTypeList()->Insert (type_sp); - - if (m_debug_map_symfile) - m_debug_map_symfile->GetObjectFile()->GetModule()->GetTypeList()->Insert (type_sp); + type_list->Insert (type_sp); m_die_to_type[die] = type_sp.get(); } @@ -3390,7 +3491,7 @@ } else if (type_ptr != DIE_IS_BEING_PARSED) { - type_sp = m_obj_file->GetModule()->GetTypeList()->FindType(type_ptr->GetID()); + type_sp = type_list->FindType(type_ptr->GetID()); } } return type_sp; 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=118672&r1=118671&r2=118672&view=diff ============================================================================== --- lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h (original) +++ lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h Tue Nov 9 22:57:04 2010 @@ -109,6 +109,7 @@ virtual uint32_t FindFunctions(const lldb_private::RegularExpression& regex, bool append, lldb_private::SymbolContextList& sc_list); virtual uint32_t FindTypes (const lldb_private::SymbolContext& sc, const lldb_private::ConstString &name, bool append, uint32_t max_matches, lldb_private::TypeList& types); // virtual uint32_t FindTypes(const lldb_private::SymbolContext& sc, const lldb_private::RegularExpression& regex, bool append, uint32_t max_matches, lldb::Type::Encoding encoding, lldb::user_id_t udt_uid, lldb_private::TypeList& types); + virtual lldb_private::TypeList *GetTypeList (); //------------------------------------------------------------------ @@ -297,6 +298,9 @@ m_debug_map_symfile = debug_map_symfile; } + lldb_private::ClangASTContext & + GetClangASTContext(); + SymbolFileDWARFDebugMap * m_debug_map_symfile; clang::TranslationUnitDecl * m_clang_tu_decl; lldb_private::Flags m_flags; Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp?rev=118672&r1=118671&r2=118672&view=diff ============================================================================== --- lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp (original) +++ lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp Tue Nov 9 22:57:04 2010 @@ -72,6 +72,12 @@ { } +lldb_private::ClangASTContext & +SymbolFileDWARFDebugMap::GetClangASTContext () +{ + return GetTypeList()->GetClangASTContext(); +} + void SymbolFileDWARFDebugMap::InitOSO () { Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h?rev=118672&r1=118671&r2=118672&view=diff ============================================================================== --- lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h (original) +++ lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h Tue Nov 9 22:57:04 2010 @@ -197,6 +197,9 @@ const DWARFDebugInfoEntry *die, const lldb_private::ConstString &type_name); + lldb_private::ClangASTContext & + GetClangASTContext (); + //------------------------------------------------------------------ // Member Variables //------------------------------------------------------------------ Modified: lldb/trunk/source/Symbol/SymbolFile.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/SymbolFile.cpp?rev=118672&r1=118671&r2=118672&view=diff ============================================================================== --- lldb/trunk/source/Symbol/SymbolFile.cpp (original) +++ lldb/trunk/source/Symbol/SymbolFile.cpp Tue Nov 9 22:57:04 2010 @@ -9,7 +9,9 @@ #include "lldb/lldb-private.h" #include "lldb/Symbol/SymbolFile.h" +#include "lldb/Core/Module.h" #include "lldb/Core/PluginManager.h" +#include "lldb/Symbol/ObjectFile.h" using namespace lldb_private; @@ -47,4 +49,8 @@ return best_sym_file_ap.release(); } - +TypeList * +SymbolFile::GetTypeList () +{ + return m_obj_file->GetModule()->GetTypeList(); +} Modified: lldb/trunk/source/Symbol/Type.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/Type.cpp?rev=118672&r1=118671&r2=118672&view=diff ============================================================================== --- lldb/trunk/source/Symbol/Type.cpp (original) +++ lldb/trunk/source/Symbol/Type.cpp Tue Nov 9 22:57:04 2010 @@ -412,7 +412,7 @@ lldb_private::TypeList* lldb_private::Type::GetTypeList() { - return GetSymbolFile()->GetObjectFile()->GetModule()->GetTypeList(); + return GetSymbolFile()->GetTypeList(); } const lldb_private::Declaration & From jingham at apple.com Wed Nov 10 12:17:03 2010 From: jingham at apple.com (Jim Ingham) Date: Wed, 10 Nov 2010 18:17:03 -0000 Subject: [Lldb-commits] [lldb] r118691 - /lldb/trunk/source/Target/Thread.cpp Message-ID: <20101110181703.7D8172A6C12C@llvm.org> Author: jingham Date: Wed Nov 10 12:17:03 2010 New Revision: 118691 URL: http://llvm.org/viewvc/llvm-project?rev=118691&view=rev Log: Remove an obsolete reference to immediate plans. 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=118691&r1=118690&r2=118691&view=diff ============================================================================== --- lldb/trunk/source/Target/Thread.cpp (original) +++ lldb/trunk/source/Target/Thread.cpp Wed Nov 10 12:17:03 2010 @@ -374,7 +374,7 @@ ThreadPlanSP &plan = m_plan_stack.back(); if (log) { - log->Printf("Popping plan: \"%s\", tid = 0x%4.4x, immediate = false.", plan->GetName(), plan->GetThread().GetID()); + log->Printf("Popping plan: \"%s\", tid = 0x%4.4x.", plan->GetName(), plan->GetThread().GetID()); } m_completed_plan_stack.push_back (plan); plan->WillPop(); From johnny.chen at apple.com Wed Nov 10 12:25:18 2010 From: johnny.chen at apple.com (Johnny Chen) Date: Wed, 10 Nov 2010 18:25:18 -0000 Subject: [Lldb-commits] [lldb] r118695 - /lldb/trunk/test/forward/TestForwardDeclaration.py Message-ID: <20101110182518.F04A22A6C12C@llvm.org> Author: johnny Date: Wed Nov 10 12:25:18 2010 New Revision: 118695 URL: http://llvm.org/viewvc/llvm-project?rev=118695&view=rev Log: Remove @skip decorator: @unittest2.skip("rdar://problem/8648070 'expression *bar_ptr' seg faults") It has been fixed by r118672. Modified: lldb/trunk/test/forward/TestForwardDeclaration.py Modified: lldb/trunk/test/forward/TestForwardDeclaration.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/forward/TestForwardDeclaration.py?rev=118695&r1=118694&r2=118695&view=diff ============================================================================== --- lldb/trunk/test/forward/TestForwardDeclaration.py (original) +++ lldb/trunk/test/forward/TestForwardDeclaration.py Wed Nov 10 12:25:18 2010 @@ -19,7 +19,6 @@ # 'expression *bar_ptr' seg faults # rdar://problem/8546815 # './dotest.py -v -t forward' fails for test_with_dwarf_and_run_command - @unittest2.skip("rdar://problem/8648070 'expression *bar_ptr' seg faults") def test_with_dwarf_and_run_command(self): """Display *bar_ptr when stopped on a function with forward declaration of struct bar.""" self.buildDwarf() From johnny.chen at apple.com Wed Nov 10 13:02:11 2010 From: johnny.chen at apple.com (Johnny Chen) Date: Wed, 10 Nov 2010 19:02:11 -0000 Subject: [Lldb-commits] [lldb] r118697 - /lldb/trunk/source/Expression/ClangUserExpression.cpp Message-ID: <20101110190211.BADDA2A6C12C@llvm.org> Author: johnny Date: Wed Nov 10 13:02:11 2010 New Revision: 118697 URL: http://llvm.org/viewvc/llvm-project?rev=118697&view=rev Log: Trivial fix for an error message. Modified: lldb/trunk/source/Expression/ClangUserExpression.cpp Modified: lldb/trunk/source/Expression/ClangUserExpression.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/ClangUserExpression.cpp?rev=118697&r1=118696&r2=118697&view=diff ============================================================================== --- lldb/trunk/source/Expression/ClangUserExpression.cpp (original) +++ lldb/trunk/source/Expression/ClangUserExpression.cpp Wed Nov 10 13:02:11 2010 @@ -402,7 +402,7 @@ } else { - error_stream.Printf("Expression can't be run; neither DWARF nor a JIT compiled function are present"); + error_stream.Printf("Expression can't be run; neither DWARF nor a JIT compiled function is present"); return false; } } From ctice at apple.com Wed Nov 10 13:18:14 2010 From: ctice at apple.com (Caroline Tice) Date: Wed, 10 Nov 2010 19:18:14 -0000 Subject: [Lldb-commits] [lldb] r118700 - in /lldb/trunk: include/lldb/Interpreter/ScriptInterpreterPython.h include/lldb/lldb-private-log.h source/Interpreter/ScriptInterpreterPython.cpp source/lldb-log.cpp Message-ID: <20101110191814.A7CFD2A6C12C@llvm.org> Author: ctice Date: Wed Nov 10 13:18:14 2010 New Revision: 118700 URL: http://llvm.org/viewvc/llvm-project?rev=118700&view=rev Log: Move the embedded Python interpreter onto a separate thread, to prevent main thread from having to wait on it (which was causing some I/O hangs). Modified: lldb/trunk/include/lldb/Interpreter/ScriptInterpreterPython.h lldb/trunk/include/lldb/lldb-private-log.h lldb/trunk/source/Interpreter/ScriptInterpreterPython.cpp lldb/trunk/source/lldb-log.cpp Modified: lldb/trunk/include/lldb/Interpreter/ScriptInterpreterPython.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Interpreter/ScriptInterpreterPython.h?rev=118700&r1=118699&r2=118700&view=diff ============================================================================== --- lldb/trunk/include/lldb/Interpreter/ScriptInterpreterPython.h (original) +++ lldb/trunk/include/lldb/Interpreter/ScriptInterpreterPython.h Wed Nov 10 13:18:14 2010 @@ -11,6 +11,7 @@ #ifndef liblldb_ScriptInterpreterPython_h_ #define liblldb_ScriptInterpreterPython_h_ +#include "lldb/lldb-private.h" #include "lldb/Interpreter/ScriptInterpreter.h" #include "lldb/Core/InputReader.h" @@ -68,6 +69,9 @@ StringList ReadCommandInputFromUser (FILE *in_file); + + static lldb::thread_result_t + RunEmbeddedPythonInterpreter (lldb::thread_arg_t baton); private: @@ -81,6 +85,8 @@ void *m_compiled_module; struct termios m_termios; bool m_termios_valid; + lldb_utility::PseudoTerminal m_embedded_python_pty; + lldb::InputReaderSP m_embedded_thread_input_reader_sp; }; } // namespace lldb_private Modified: lldb/trunk/include/lldb/lldb-private-log.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/lldb-private-log.h?rev=118700&r1=118699&r2=118700&view=diff ============================================================================== --- lldb/trunk/include/lldb/lldb-private-log.h (original) +++ lldb/trunk/include/lldb/lldb-private-log.h Wed Nov 10 13:18:14 2010 @@ -36,6 +36,7 @@ #define LIBLLDB_LOG_HOST (1u << 14) #define LIBLLDB_LOG_UNWIND (1u << 15) #define LIBLLDB_LOG_API (1u << 16) +#define LIBLLDB_LOG_SCRIPT (1u << 17) #define LIBLLDB_LOG_ALL (UINT32_MAX) #define LIBLLDB_LOG_DEFAULT (LIBLLDB_LOG_PROCESS |\ LIBLLDB_LOG_THREAD |\ Modified: lldb/trunk/source/Interpreter/ScriptInterpreterPython.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Interpreter/ScriptInterpreterPython.cpp?rev=118700&r1=118699&r2=118700&view=diff ============================================================================== --- lldb/trunk/source/Interpreter/ScriptInterpreterPython.cpp (original) +++ lldb/trunk/source/Interpreter/ScriptInterpreterPython.cpp Wed Nov 10 13:18:14 2010 @@ -161,7 +161,10 @@ ScriptInterpreterPython::ScriptInterpreterPython (CommandInterpreter &interpreter) : ScriptInterpreter (interpreter, eScriptLanguagePython), m_compiled_module (NULL), - m_termios_valid (false) + m_termios (), + m_termios_valid (false), + m_embedded_python_pty (), + m_embedded_thread_input_reader_sp () { Timer scoped_timer (__PRETTY_FUNCTION__, __PRETTY_FUNCTION__); @@ -342,6 +345,9 @@ size_t bytes_len ) { + lldb::thread_t embedded_interpreter_thread; + LogSP log (lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_SCRIPT)); + if (baton == NULL) return 0; @@ -366,6 +372,37 @@ tmp_termios.c_cc[VEOF] = _POSIX_VDISABLE; ::tcsetattr (input_fd, TCSANOW, &tmp_termios); } + char error_str[1024]; + if (script_interpreter->m_embedded_python_pty.OpenFirstAvailableMaster (O_RDWR|O_NOCTTY, error_str, + sizeof(error_str))) + { + if (log) + log->Printf ("ScriptInterpreterPython::InputReaderCallback, Activate, succeeded in opening master pty (fd = %d).", + script_interpreter->m_embedded_python_pty.GetMasterFileDescriptor()); + embedded_interpreter_thread = Host::ThreadCreate ("", + ScriptInterpreterPython::RunEmbeddedPythonInterpreter, + script_interpreter, NULL); + if (embedded_interpreter_thread != LLDB_INVALID_HOST_THREAD) + { + if (log) + log->Printf ("ScriptInterpreterPython::InputReaderCallback, Activate, succeeded in creating thread (thread = %d)", embedded_interpreter_thread); + Error detach_error; + Host::ThreadDetach (embedded_interpreter_thread, &detach_error); + } + else + { + if (log) + log->Printf ("ScriptInterpreterPython::InputReaderCallback, Activate, failed in creating thread"); + reader.SetIsDone (true); + } + } + else + { + if (log) + log->Printf ("ScriptInterpreterPython::InputReaderCallback, Activate, failed to open master pty "); + reader.SetIsDone (true); + } + } break; @@ -376,14 +413,29 @@ break; case eInputReaderGotToken: - if (bytes && bytes_len) + if (script_interpreter->m_embedded_python_pty.GetMasterFileDescriptor() != -1) { - if ((int) bytes[0] == 4) - ::write (script_interpreter->GetMasterFileDescriptor(), "quit()", 6); - else - ::write (script_interpreter->GetMasterFileDescriptor(), bytes, bytes_len); + if (log) + log->Printf ("ScriptInterpreterPython::InputReaderCallback, GotToken, bytes='%s', byte_len = %d", bytes, + bytes_len); + if (bytes && bytes_len) + { + if ((int) bytes[0] == 4) + ::write (script_interpreter->m_embedded_python_pty.GetMasterFileDescriptor(), "quit()", 6); + else + ::write (script_interpreter->m_embedded_python_pty.GetMasterFileDescriptor(), bytes, bytes_len); + } + ::write (script_interpreter->m_embedded_python_pty.GetMasterFileDescriptor(), "\n", 1); + } + else + { + if (log) + log->Printf ("ScriptInterpreterPython::InputReaderCallback, GotToken, bytes='%s', byte_len = %d, Master File Descriptor is bad.", + bytes, + bytes_len); + reader.SetIsDone (true); } - ::write (script_interpreter->GetMasterFileDescriptor(), "\n", 1); + break; case eInputReaderDone: @@ -392,6 +444,8 @@ // Write a newline out to the reader output //::fwrite ("\n", 1, 1, out_fh); // Restore terminal settings if they were validly saved + if (log) + log->Printf ("ScriptInterpreterPython::InputReaderCallback, Done, closing down input reader."); if (script_interpreter->m_termios_valid) { int input_fd; @@ -403,6 +457,7 @@ ::tcsetattr (input_fd, TCSANOW, &script_interpreter->m_termios); } + script_interpreter->m_embedded_python_pty.CloseMasterFileDescriptor(); break; } @@ -438,8 +493,7 @@ if (error.Success()) { debugger.PushInputReader (reader_sp); - ExecuteOneLine ("run_python_interpreter(ConsoleDict)", NULL); - debugger.PopInputReader (reader_sp); + m_embedded_thread_input_reader_sp = reader_sp; } } } @@ -858,3 +912,58 @@ // trying to call the script function return true; } + +lldb::thread_result_t +ScriptInterpreterPython::RunEmbeddedPythonInterpreter (lldb::thread_arg_t baton) +{ + ScriptInterpreterPython *script_interpreter = (ScriptInterpreterPython *) baton; + + LogSP log (lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_SCRIPT)); + + if (log) + log->Printf ("%p ScriptInterpreterPython::RunEmbeddedPythonInterpreter () thread starting...", baton); + + char error_str[1024]; + const char *pty_slave_name = script_interpreter->m_embedded_python_pty.GetSlaveName (error_str, sizeof (error_str)); + if (pty_slave_name != NULL) + { + StreamString run_string; + PyRun_SimpleString ("save_stderr = sys.stderr"); + PyRun_SimpleString ("sys.stderr = sys.stdout"); + PyRun_SimpleString ("save_stdin = sys.stdin"); + run_string.Printf ("sys.stdin = open ('%s', 'r')", pty_slave_name); + PyRun_SimpleString (run_string.GetData()); + PyRun_SimpleString ("new_mode = tcgetattr(sys.stdin)"); + PyRun_SimpleString ("new_mode[3] = new_mode[3] | ECHO | ICANON"); + PyRun_SimpleString ("new_mode[6][VEOF] = 255"); + PyRun_SimpleString ("tcsetattr (sys.stdin, TCSANOW, new_mode)"); + + // The following call drops into the embedded interpreter loop and stays there until the + // user chooses to exit from the Python interpreter. + script_interpreter->ExecuteOneLine ("run_python_interpreter(ConsoleDict)", NULL); + + PyRun_SimpleString ("sys.stdin = save_stdin"); + PyRun_SimpleString ("sys.stderr = save_stderr"); + } + + if (script_interpreter->m_embedded_thread_input_reader_sp) + script_interpreter->m_embedded_thread_input_reader_sp->SetIsDone (true); + + script_interpreter->m_embedded_python_pty.CloseSlaveFileDescriptor(); + + log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_SCRIPT); + if (log) + log->Printf ("%p ScriptInterpreterPython::RunEmbeddedPythonInterpreter () thread exiting...", baton); + + + // Clean up the input reader and make the debugger pop it off the stack. + Debugger &debugger = script_interpreter->m_interpreter.GetDebugger(); + const InputReaderSP reader_sp = script_interpreter->m_embedded_thread_input_reader_sp; + script_interpreter->m_embedded_thread_input_reader_sp.reset(); + debugger.PopInputReader (reader_sp); + + return NULL; +} + + + Modified: lldb/trunk/source/lldb-log.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/lldb-log.cpp?rev=118700&r1=118699&r2=118700&view=diff ============================================================================== --- lldb/trunk/source/lldb-log.cpp (original) +++ lldb/trunk/source/lldb-log.cpp Wed Nov 10 13:18:14 2010 @@ -120,6 +120,7 @@ else if (strcasestr(arg, "expr") == arg) flag_bits &= ~LIBLLDB_LOG_EXPRESSIONS; else if (strcasestr(arg, "object") == arg) flag_bits &= ~LIBLLDB_LOG_OBJECT; else if (strcasecmp(arg, "process") == 0 ) flag_bits &= ~LIBLLDB_LOG_PROCESS; + else if (strcasecmp(arg, "script") == 0) flag_bits &= ~LIBLLDB_LOG_SCRIPT; else if (strcasecmp(arg, "state") == 0 ) flag_bits &= ~LIBLLDB_LOG_STATE; else if (strcasecmp(arg, "step") == 0 ) flag_bits &= ~LIBLLDB_LOG_STEP; else if (strcasecmp(arg, "thread") == 0 ) flag_bits &= ~LIBLLDB_LOG_THREAD; @@ -183,6 +184,7 @@ else if (strcasestr(arg, "expr") == arg) flag_bits |= LIBLLDB_LOG_EXPRESSIONS; else if (strcasestr(arg, "object") == arg) flag_bits |= LIBLLDB_LOG_OBJECT; else if (strcasecmp(arg, "process") == 0 ) flag_bits |= LIBLLDB_LOG_PROCESS; + else if (strcasecmp(arg, "script") == 0) flag_bits |= LIBLLDB_LOG_SCRIPT; else if (strcasecmp(arg, "state") == 0 ) flag_bits |= LIBLLDB_LOG_STATE; else if (strcasecmp(arg, "step") == 0 ) flag_bits |= LIBLLDB_LOG_STEP; else if (strcasecmp(arg, "thread") == 0 ) flag_bits |= LIBLLDB_LOG_THREAD; @@ -225,6 +227,7 @@ "\tobject - log object construction/destruction for important objects\n" "\tprocess - log process events and activities\n" "\tthread - log thread events and activities\n" + "\tscript - log events about the script interpreter\n" "\tshlib - log shared library related activities\n" "\tstate - log private and public process state changes\n" "\tstep - log step related activities\n" From gclayton at apple.com Wed Nov 10 13:43:41 2010 From: gclayton at apple.com (Greg Clayton) Date: Wed, 10 Nov 2010 19:43:41 -0000 Subject: [Lldb-commits] [lldb] r118703 - /lldb/trunk/source/Host/macosx/Host.mm Message-ID: <20101110194341.1A8E32A6C12C@llvm.org> Author: gclayton Date: Wed Nov 10 13:43:40 2010 New Revision: 118703 URL: http://llvm.org/viewvc/llvm-project?rev=118703&view=rev Log: Don't keep appending to the current crash description with each formatted crash description call. Modified: lldb/trunk/source/Host/macosx/Host.mm Modified: lldb/trunk/source/Host/macosx/Host.mm URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/macosx/Host.mm?rev=118703&r1=118702&r2=118703&view=diff ============================================================================== --- lldb/trunk/source/Host/macosx/Host.mm (original) +++ lldb/trunk/source/Host/macosx/Host.mm Wed Nov 10 13:43:40 2010 @@ -554,6 +554,7 @@ { va_list args; va_start (args, format); + g_crash_description.GetString().clear(); g_crash_description.PrintfVarArg(format, args); va_end (args); __crashreporter_info__ = g_crash_description.GetData(); From benny.kra at googlemail.com Wed Nov 10 14:16:47 2010 From: benny.kra at googlemail.com (Benjamin Kramer) Date: Wed, 10 Nov 2010 20:16:47 -0000 Subject: [Lldb-commits] [lldb] r118710 - in /lldb/trunk/source: Commands/CommandObjectFrame.cpp Host/macosx/Host.mm Plugins/Process/Utility/RegisterContextLLDB.h Message-ID: <20101110201647.915F82A6C12C@llvm.org> Author: d0k Date: Wed Nov 10 14:16:47 2010 New Revision: 118710 URL: http://llvm.org/viewvc/llvm-project?rev=118710&view=rev Log: Silence a bunch of clang warnings. Modified: lldb/trunk/source/Commands/CommandObjectFrame.cpp lldb/trunk/source/Host/macosx/Host.mm lldb/trunk/source/Plugins/Process/Utility/RegisterContextLLDB.h Modified: lldb/trunk/source/Commands/CommandObjectFrame.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectFrame.cpp?rev=118710&r1=118709&r2=118710&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectFrame.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectFrame.cpp Wed Nov 10 14:16:47 2010 @@ -124,7 +124,7 @@ break; default: - ("Invalid short option character '%c'.\n", short_option); + error.SetErrorStringWithFormat ("Invalid short option character '%c'.\n", short_option); break; } Modified: lldb/trunk/source/Host/macosx/Host.mm URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/macosx/Host.mm?rev=118710&r1=118709&r2=118710&view=diff ============================================================================== --- lldb/trunk/source/Host/macosx/Host.mm (original) +++ lldb/trunk/source/Host/macosx/Host.mm Wed Nov 10 14:16:47 2010 @@ -142,7 +142,7 @@ FSRef app_fsref; CFCString app_cfstr (app_path, kCFStringEncodingUTF8); - OSStatus error = ::FSPathMakeRef ((const UInt8 *)app_path, &app_fsref, false); + OSStatus error = ::FSPathMakeRef ((const UInt8 *)app_path, &app_fsref, NULL); // If we found the app, then store away the name so we don't have to re-look it up. if (error != noErr) Modified: lldb/trunk/source/Plugins/Process/Utility/RegisterContextLLDB.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Utility/RegisterContextLLDB.h?rev=118710&r1=118709&r2=118710&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Process/Utility/RegisterContextLLDB.h (original) +++ lldb/trunk/source/Plugins/Process/Utility/RegisterContextLLDB.h Wed Nov 10 14:16:47 2010 @@ -76,7 +76,7 @@ private: - typedef enum FrameType + enum FrameType { eNormalFrame, eSigtrampFrame, From johnny.chen at apple.com Wed Nov 10 14:20:06 2010 From: johnny.chen at apple.com (Johnny Chen) Date: Wed, 10 Nov 2010 20:20:06 -0000 Subject: [Lldb-commits] [lldb] r118711 - in /lldb/trunk/test: bitfields/TestBitfields.py lldbtest.py Message-ID: <20101110202006.C41B72A6C12C@llvm.org> Author: johnny Date: Wed Nov 10 14:20:06 2010 New Revision: 118711 URL: http://llvm.org/viewvc/llvm-project?rev=118711&view=rev Log: Add the actual stop reason to an assert message for bitfields_variable_python() test method when asserting: thread.GetStopReason() == lldb.eStopReasonBreakpoint Modified: lldb/trunk/test/bitfields/TestBitfields.py lldb/trunk/test/lldbtest.py Modified: lldb/trunk/test/bitfields/TestBitfields.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/bitfields/TestBitfields.py?rev=118711&r1=118710&r2=118711&view=diff ============================================================================== --- lldb/trunk/test/bitfields/TestBitfields.py (original) +++ lldb/trunk/test/bitfields/TestBitfields.py Wed Nov 10 14:20:06 2010 @@ -84,6 +84,8 @@ def bitfields_variable_python(self): """Use Python APIs to inspect a bitfields variable.""" + from lldbutil import StopReasonString + exe = os.path.join(os.getcwd(), "a.out") target = self.dbg.CreateTarget(exe) @@ -102,7 +104,7 @@ # The stop reason of the thread should be breakpoint. thread = target.GetProcess().GetThreadAtIndex(0) self.assertTrue(thread.GetStopReason() == lldb.eStopReasonBreakpoint, - STOPPED_DUE_TO_BREAKPOINT) + STOPPED_DUE_TO_BREAKPOINT_WITH_STOP_REASON_AS % StopReasonString(thread.GetStopReason())) # The breakpoint should have a hit count of 1. self.assertTrue(breakpoint.GetHitCount() == 1, BREAKPOINT_HIT_ONCE) Modified: lldb/trunk/test/lldbtest.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/lldbtest.py?rev=118711&r1=118710&r2=118711&view=diff ============================================================================== --- lldb/trunk/test/lldbtest.py (original) +++ lldb/trunk/test/lldbtest.py Wed Nov 10 14:20:06 2010 @@ -151,7 +151,9 @@ STEP_OUT_SUCCEEDED = "Thread step-out succeeded" -STOPPED_DUE_TO_BREAKPOINT = "Process state is stopped due to breakpoint" +STOPPED_DUE_TO_BREAKPOINT = "Process is stopped due to breakpoint" + +STOPPED_DUE_TO_BREAKPOINT_WITH_STOP_REASON_AS = "Process is stopped due to breakpoint (actual stop reason: '%s')" STOPPED_DUE_TO_BREAKPOINT_CONDITION = "Stopped due to breakpoint condition" From johnny.chen at apple.com Wed Nov 10 14:30:37 2010 From: johnny.chen at apple.com (Johnny Chen) Date: Wed, 10 Nov 2010 20:30:37 -0000 Subject: [Lldb-commits] [lldb] r118713 - in /lldb/trunk/test: array_types/TestArrayTypes.py bitfields/TestBitfields.py class_types/TestClassTypes.py hello_world/TestHelloWorld.py Message-ID: <20101110203037.632532A6C12C@llvm.org> Author: johnny Date: Wed Nov 10 14:30:37 2010 New Revision: 118713 URL: http://llvm.org/viewvc/llvm-project?rev=118713&view=rev Log: Finish adding the actual stop reason as part of the assert message when asserting: thread.GetStopReason() == lldb.eStopReasonBreakpoint Modified: lldb/trunk/test/array_types/TestArrayTypes.py lldb/trunk/test/bitfields/TestBitfields.py lldb/trunk/test/class_types/TestClassTypes.py lldb/trunk/test/hello_world/TestHelloWorld.py Modified: lldb/trunk/test/array_types/TestArrayTypes.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/array_types/TestArrayTypes.py?rev=118713&r1=118712&r2=118713&view=diff ============================================================================== --- lldb/trunk/test/array_types/TestArrayTypes.py (original) +++ lldb/trunk/test/array_types/TestArrayTypes.py Wed Nov 10 14:30:37 2010 @@ -120,9 +120,10 @@ "executable = a.out"]) # The stop reason of the thread should be breakpoint. + from lldbutil import StopReasonString thread = self.process.GetThreadAtIndex(0) self.assertTrue(thread.GetStopReason() == lldb.eStopReasonBreakpoint, - STOPPED_DUE_TO_BREAKPOINT) + STOPPED_DUE_TO_BREAKPOINT_WITH_STOP_REASON_AS % StopReasonString(thread.GetStopReason())) # Sanity check the print representation of thread. thr = repr(thread) Modified: lldb/trunk/test/bitfields/TestBitfields.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/bitfields/TestBitfields.py?rev=118713&r1=118712&r2=118713&view=diff ============================================================================== --- lldb/trunk/test/bitfields/TestBitfields.py (original) +++ lldb/trunk/test/bitfields/TestBitfields.py Wed Nov 10 14:30:37 2010 @@ -84,8 +84,6 @@ def bitfields_variable_python(self): """Use Python APIs to inspect a bitfields variable.""" - from lldbutil import StopReasonString - exe = os.path.join(os.getcwd(), "a.out") target = self.dbg.CreateTarget(exe) @@ -102,6 +100,7 @@ self.assertTrue(self.process.IsValid(), PROCESS_IS_VALID) # The stop reason of the thread should be breakpoint. + from lldbutil import StopReasonString thread = target.GetProcess().GetThreadAtIndex(0) self.assertTrue(thread.GetStopReason() == lldb.eStopReasonBreakpoint, STOPPED_DUE_TO_BREAKPOINT_WITH_STOP_REASON_AS % StopReasonString(thread.GetStopReason())) Modified: lldb/trunk/test/class_types/TestClassTypes.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/class_types/TestClassTypes.py?rev=118713&r1=118712&r2=118713&view=diff ============================================================================== --- lldb/trunk/test/class_types/TestClassTypes.py (original) +++ lldb/trunk/test/class_types/TestClassTypes.py Wed Nov 10 14:30:37 2010 @@ -130,10 +130,10 @@ lldbutil.StateTypeString(self.process.GetState())) # The stop reason of the thread should be breakpoint. + from lldbutil import StopReasonString thread = self.process.GetThreadAtIndex(0) - self.assertTrue(thread.GetStopReason() == lldb.eStopReasonBreakpoint, - STOPPED_DUE_TO_BREAKPOINT) + STOPPED_DUE_TO_BREAKPOINT_WITH_STOP_REASON_AS % StopReasonString(thread.GetStopReason())) # The filename of frame #0 should be 'main.cpp' and the line number # should be 93. Modified: lldb/trunk/test/hello_world/TestHelloWorld.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/hello_world/TestHelloWorld.py?rev=118713&r1=118712&r2=118713&view=diff ============================================================================== --- lldb/trunk/test/hello_world/TestHelloWorld.py (original) +++ lldb/trunk/test/hello_world/TestHelloWorld.py Wed Nov 10 14:30:37 2010 @@ -68,9 +68,10 @@ self.process = target.GetProcess() self.assertTrue(self.process.IsValid(), PROCESS_IS_VALID) + from lldbutil import StopReasonString thread = self.process.GetThreadAtIndex(0) self.assertTrue(thread.GetStopReason() == lldb.eStopReasonBreakpoint, - STOPPED_DUE_TO_BREAKPOINT) + STOPPED_DUE_TO_BREAKPOINT_WITH_STOP_REASON_AS % StopReasonString(thread.GetStopReason())) # The breakpoint should have a hit count of 1. self.assertTrue(breakpoint.GetHitCount() == 1, BREAKPOINT_HIT_ONCE) From johnny.chen at apple.com Wed Nov 10 17:14:41 2010 From: johnny.chen at apple.com (Johnny Chen) Date: Wed, 10 Nov 2010 23:14:41 -0000 Subject: [Lldb-commits] [lldb] r118731 - in /lldb/trunk/test: array_types/TestArrayTypes.py bitfields/TestBitfields.py class_types/TestClassTypes.py hello_world/TestHelloWorld.py Message-ID: <20101110231441.803282A6C12C@llvm.org> Author: johnny Date: Wed Nov 10 17:14:41 2010 New Revision: 118731 URL: http://llvm.org/viewvc/llvm-project?rev=118731&view=rev Log: Slight changes to how to phrase the assert for Python API thread.GetStopReason(). Modified: lldb/trunk/test/array_types/TestArrayTypes.py lldb/trunk/test/bitfields/TestBitfields.py lldb/trunk/test/class_types/TestClassTypes.py lldb/trunk/test/hello_world/TestHelloWorld.py Modified: lldb/trunk/test/array_types/TestArrayTypes.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/array_types/TestArrayTypes.py?rev=118731&r1=118730&r2=118731&view=diff ============================================================================== --- lldb/trunk/test/array_types/TestArrayTypes.py (original) +++ lldb/trunk/test/array_types/TestArrayTypes.py Wed Nov 10 17:14:41 2010 @@ -120,10 +120,11 @@ "executable = a.out"]) # The stop reason of the thread should be breakpoint. - from lldbutil import StopReasonString thread = self.process.GetThreadAtIndex(0) - self.assertTrue(thread.GetStopReason() == lldb.eStopReasonBreakpoint, - STOPPED_DUE_TO_BREAKPOINT_WITH_STOP_REASON_AS % StopReasonString(thread.GetStopReason())) + if thread.GetStopReason() != lldb.eStopReasonBreakpoint: + from lldbutil import StopReasonString + self.fail(STOPPED_DUE_TO_BREAKPOINT_WITH_STOP_REASON_AS % + StopReasonString(thread.GetStopReason())) # Sanity check the print representation of thread. thr = repr(thread) Modified: lldb/trunk/test/bitfields/TestBitfields.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/bitfields/TestBitfields.py?rev=118731&r1=118730&r2=118731&view=diff ============================================================================== --- lldb/trunk/test/bitfields/TestBitfields.py (original) +++ lldb/trunk/test/bitfields/TestBitfields.py Wed Nov 10 17:14:41 2010 @@ -100,10 +100,11 @@ self.assertTrue(self.process.IsValid(), PROCESS_IS_VALID) # The stop reason of the thread should be breakpoint. - from lldbutil import StopReasonString thread = target.GetProcess().GetThreadAtIndex(0) - self.assertTrue(thread.GetStopReason() == lldb.eStopReasonBreakpoint, - STOPPED_DUE_TO_BREAKPOINT_WITH_STOP_REASON_AS % StopReasonString(thread.GetStopReason())) + if thread.GetStopReason() != lldb.eStopReasonBreakpoint: + from lldbutil import StopReasonString + self.fail(STOPPED_DUE_TO_BREAKPOINT_WITH_STOP_REASON_AS % + StopReasonString(thread.GetStopReason())) # The breakpoint should have a hit count of 1. self.assertTrue(breakpoint.GetHitCount() == 1, BREAKPOINT_HIT_ONCE) Modified: lldb/trunk/test/class_types/TestClassTypes.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/class_types/TestClassTypes.py?rev=118731&r1=118730&r2=118731&view=diff ============================================================================== --- lldb/trunk/test/class_types/TestClassTypes.py (original) +++ lldb/trunk/test/class_types/TestClassTypes.py Wed Nov 10 17:14:41 2010 @@ -130,10 +130,11 @@ lldbutil.StateTypeString(self.process.GetState())) # The stop reason of the thread should be breakpoint. - from lldbutil import StopReasonString thread = self.process.GetThreadAtIndex(0) - self.assertTrue(thread.GetStopReason() == lldb.eStopReasonBreakpoint, - STOPPED_DUE_TO_BREAKPOINT_WITH_STOP_REASON_AS % StopReasonString(thread.GetStopReason())) + if thread.GetStopReason() != lldb.eStopReasonBreakpoint: + from lldbutil import StopReasonString + self.fail(STOPPED_DUE_TO_BREAKPOINT_WITH_STOP_REASON_AS % + StopReasonString(thread.GetStopReason())) # The filename of frame #0 should be 'main.cpp' and the line number # should be 93. Modified: lldb/trunk/test/hello_world/TestHelloWorld.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/hello_world/TestHelloWorld.py?rev=118731&r1=118730&r2=118731&view=diff ============================================================================== --- lldb/trunk/test/hello_world/TestHelloWorld.py (original) +++ lldb/trunk/test/hello_world/TestHelloWorld.py Wed Nov 10 17:14:41 2010 @@ -68,10 +68,11 @@ self.process = target.GetProcess() self.assertTrue(self.process.IsValid(), PROCESS_IS_VALID) - from lldbutil import StopReasonString thread = self.process.GetThreadAtIndex(0) - self.assertTrue(thread.GetStopReason() == lldb.eStopReasonBreakpoint, - STOPPED_DUE_TO_BREAKPOINT_WITH_STOP_REASON_AS % StopReasonString(thread.GetStopReason())) + if thread.GetStopReason() != lldb.eStopReasonBreakpoint: + from lldbutil import StopReasonString + self.fail(STOPPED_DUE_TO_BREAKPOINT_WITH_STOP_REASON_AS % + StopReasonString(thread.GetStopReason())) # The breakpoint should have a hit count of 1. self.assertTrue(breakpoint.GetHitCount() == 1, BREAKPOINT_HIT_ONCE) From gclayton at apple.com Wed Nov 10 17:42:09 2010 From: gclayton at apple.com (Greg Clayton) Date: Wed, 10 Nov 2010 23:42:09 -0000 Subject: [Lldb-commits] [lldb] r118737 - in /lldb/trunk: include/lldb/Symbol/SymbolFile.h lldb.xcodeproj/project.pbxproj source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.cpp source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.h Message-ID: <20101110234210.080662A6C12C@llvm.org> Author: gclayton Date: Wed Nov 10 17:42:09 2010 New Revision: 118737 URL: http://llvm.org/viewvc/llvm-project?rev=118737&view=rev Log: Added initial support to the lldb_private::SymbolFile for finding namespaces by name given an optional symbol context. I might end up dressing up the "clang::NamespaceDecl" into a lldb_private::Namespace class if we need to do more than is currenlty required of namespaces. Currently we only need to be able to lookup a namespace by name when parsing expressions, so I kept it simple for now. The idea here is even though we are passing around a "clang::NamespaceDecl *", that we always have it be an opaque pointer (it is forward declared inside of "lldb/Core/ClangForward.h") and we only use clang::NamespaceDecl implementations inside of ClangASTContext, or ClangASTType when we need to extract information from the namespace decl object. Modified: lldb/trunk/include/lldb/Symbol/SymbolFile.h lldb/trunk/lldb.xcodeproj/project.pbxproj lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h lldb/trunk/source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.cpp lldb/trunk/source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.h Modified: lldb/trunk/include/lldb/Symbol/SymbolFile.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Symbol/SymbolFile.h?rev=118737&r1=118736&r2=118737&view=diff ============================================================================== --- lldb/trunk/include/lldb/Symbol/SymbolFile.h (original) +++ lldb/trunk/include/lldb/Symbol/SymbolFile.h Wed Nov 10 17:42:09 2010 @@ -81,6 +81,9 @@ virtual uint32_t FindTypes (const SymbolContext& sc, const ConstString &name, bool append, uint32_t max_matches, TypeList& types) = 0; // virtual uint32_t FindTypes (const SymbolContext& sc, const RegularExpression& regex, bool append, uint32_t max_matches, TypeList& types) = 0; virtual TypeList * GetTypeList (); + virtual clang::NamespaceDecl * + FindNamespace (const SymbolContext& sc, + const ConstString &name) = 0; ObjectFile* GetObjectFile() { return m_obj_file; } const ObjectFile* GetObjectFile() const { return m_obj_file; } Modified: lldb/trunk/lldb.xcodeproj/project.pbxproj URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/lldb.xcodeproj/project.pbxproj?rev=118737&r1=118736&r2=118737&view=diff ============================================================================== --- lldb/trunk/lldb.xcodeproj/project.pbxproj (original) +++ lldb/trunk/lldb.xcodeproj/project.pbxproj Wed Nov 10 17:42:09 2010 @@ -2438,7 +2438,6 @@ isa = PBXProject; buildConfigurationList = 1DEB91EF08733DB70010E9CD /* Build configuration list for PBXProject "lldb" */; compatibilityVersion = "Xcode 3.1"; - developmentRegion = English; hasScannedForEncodings = 1; knownRegions = ( en, @@ -2926,7 +2925,7 @@ GCC_WARN_ABOUT_RETURN_TYPE = YES; GCC_WARN_HIDDEN_VIRTUAL_FUNCTIONS = YES; GCC_WARN_UNUSED_VARIABLE = YES; - ONLY_ACTIVE_ARCH = NO; + ONLY_ACTIVE_ARCH = YES; PREBINDING = NO; VALID_ARCHS = "x86_64 i386"; }; 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=118737&r1=118736&r2=118737&view=diff ============================================================================== --- lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp (original) +++ lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp Wed Nov 10 17:42:09 2010 @@ -53,7 +53,7 @@ #include -//#define ENABLE_DEBUG_PRINTF // COMMENT OUT THIS LINE PRIOR TO CHECKIN +#define ENABLE_DEBUG_PRINTF // COMMENT OUT THIS LINE PRIOR TO CHECKIN #ifdef ENABLE_DEBUG_PRINTF #include @@ -506,16 +506,16 @@ } bool -SymbolFileDWARF::ParseCompileUnit (DWARFCompileUnit* cu, CompUnitSP& compile_unit_sp) +SymbolFileDWARF::ParseCompileUnit (DWARFCompileUnit* curr_cu, CompUnitSP& compile_unit_sp) { - if (cu != NULL) + if (curr_cu != NULL) { - const DWARFDebugInfoEntry * cu_die = cu->GetCompileUnitDIEOnly (); + const DWARFDebugInfoEntry * cu_die = curr_cu->GetCompileUnitDIEOnly (); if (cu_die) { - const char * cu_die_name = cu_die->GetName(this, cu); - const char * cu_comp_dir = cu_die->GetAttributeValueAsString(this, cu, DW_AT_comp_dir, NULL); - LanguageType class_language = (LanguageType)cu_die->GetAttributeValueAsUnsigned(this, cu, DW_AT_language, 0); + const char * cu_die_name = cu_die->GetName(this, curr_cu); + const char * cu_comp_dir = cu_die->GetAttributeValueAsString(this, curr_cu, DW_AT_comp_dir, NULL); + LanguageType class_language = (LanguageType)cu_die->GetAttributeValueAsUnsigned(this, curr_cu, DW_AT_language, 0); if (cu_die_name) { FileSpec cu_file_spec; @@ -535,10 +535,10 @@ cu_file_spec.SetFile (fullpath.c_str(), false); } - compile_unit_sp.reset(new CompileUnit(m_obj_file->GetModule(), cu, cu_file_spec, cu->GetOffset(), class_language)); + compile_unit_sp.reset(new CompileUnit(m_obj_file->GetModule(), curr_cu, cu_file_spec, curr_cu->GetOffset(), class_language)); if (compile_unit_sp.get()) { - cu->SetUserData(compile_unit_sp.get()); + curr_cu->SetUserData(compile_unit_sp.get()); return true; } } @@ -563,15 +563,15 @@ DWARFDebugInfo* info = DebugInfo(); if (info) { - DWARFCompileUnit* cu = info->GetCompileUnitAtIndex(cu_idx); - if (cu != NULL) + DWARFCompileUnit* curr_cu = info->GetCompileUnitAtIndex(cu_idx); + if (curr_cu != NULL) { // Our symbol vendor shouldn't be asking us to add a compile unit that // has already been added to it, which this DWARF plug-in knows as it // stores the lldb compile unit (CompileUnit) pointer in each // DWARFCompileUnit object when it gets added. - assert(cu->GetUserData() == NULL); - ParseCompileUnit(cu, comp_unit); + assert(curr_cu->GetUserData() == NULL); + ParseCompileUnit(curr_cu, comp_unit); } } return comp_unit; @@ -714,14 +714,14 @@ SymbolFileDWARF::ParseCompileUnitSupportFiles (const SymbolContext& sc, FileSpecList& support_files) { assert (sc.comp_unit); - DWARFCompileUnit* cu = GetDWARFCompileUnitForUID(sc.comp_unit->GetID()); - assert (cu); - const DWARFDebugInfoEntry * cu_die = cu->GetCompileUnitDIEOnly(); + DWARFCompileUnit* curr_cu = GetDWARFCompileUnitForUID(sc.comp_unit->GetID()); + assert (curr_cu); + const DWARFDebugInfoEntry * cu_die = curr_cu->GetCompileUnitDIEOnly(); if (cu_die) { - const char * cu_comp_dir = cu_die->GetAttributeValueAsString(this, cu, DW_AT_comp_dir, NULL); - dw_offset_t stmt_list = cu_die->GetAttributeValueAsUnsigned(this, cu, DW_AT_stmt_list, DW_INVALID_OFFSET); + const char * cu_comp_dir = cu_die->GetAttributeValueAsString(this, curr_cu, DW_AT_comp_dir, NULL); + dw_offset_t stmt_list = cu_die->GetAttributeValueAsUnsigned(this, curr_cu, DW_AT_stmt_list, DW_INVALID_OFFSET); // All file indexes in DWARF are one based and a file of index zero is // supposed to be the compile unit itself. @@ -1297,7 +1297,7 @@ DWARFDebugInfo* debug_info = DebugInfo(); - DWARFCompileUnit *cu = debug_info->GetCompileUnitContainingDIE (die->GetOffset()).get(); + DWARFCompileUnit *curr_cu = debug_info->GetCompileUnitContainingDIE (die->GetOffset()).get(); Type *type = m_die_to_type.lookup (die); const dw_tag_t tag = die->Tag(); @@ -1342,7 +1342,7 @@ default_accessibility = eAccessPrivate; } - SymbolContext sc(GetCompUnitForDWARFCompUnit(cu)); + SymbolContext sc(GetCompUnitForDWARFCompUnit(curr_cu)); std::vector base_classes; std::vector member_accessibilities; bool is_a_class = false; @@ -1350,7 +1350,7 @@ DWARFDIECollection member_function_dies; ParseChildMembers (sc, - cu, + curr_cu, die, clang_type, class_language, @@ -1366,7 +1366,7 @@ { for (size_t i=0; iHasChildren()) { - SymbolContext sc(GetCompUnitForDWARFCompUnit(cu)); - ParseChildEnumerators(sc, clang_type, type->GetByteSize(), cu, die); + SymbolContext sc(GetCompUnitForDWARFCompUnit(curr_cu)); + ParseChildEnumerators(sc, clang_type, type->GetByteSize(), curr_cu, die); } ast.CompleteTagDeclarationDefinition (clang_type); return clang_type; @@ -1460,13 +1460,13 @@ } Type* -SymbolFileDWARF::ResolveType (DWARFCompileUnit* cu, const DWARFDebugInfoEntry* type_die, bool assert_not_being_parsed) +SymbolFileDWARF::ResolveType (DWARFCompileUnit* curr_cu, const DWARFDebugInfoEntry* type_die, bool assert_not_being_parsed) { if (type_die != NULL) { Type *type = m_die_to_type.lookup (type_die); if (type == NULL) - type = GetTypeForDIE (cu, type_die).get(); + type = GetTypeForDIE (curr_cu, type_die).get(); if (assert_not_being_parsed) assert (type != DIE_IS_BEING_PARSED); return type; @@ -1475,20 +1475,20 @@ } CompileUnit* -SymbolFileDWARF::GetCompUnitForDWARFCompUnit (DWARFCompileUnit* cu, uint32_t cu_idx) +SymbolFileDWARF::GetCompUnitForDWARFCompUnit (DWARFCompileUnit* curr_cu, uint32_t cu_idx) { // Check if the symbol vendor already knows about this compile unit? - if (cu->GetUserData() == NULL) + if (curr_cu->GetUserData() == NULL) { // The symbol vendor doesn't know about this compile unit, we // need to parse and add it to the symbol vendor object. CompUnitSP dc_cu; - ParseCompileUnit(cu, dc_cu); + ParseCompileUnit(curr_cu, dc_cu); if (dc_cu.get()) { // Figure out the compile unit index if we weren't given one if (cu_idx == UINT32_MAX) - DebugInfo()->GetCompileUnit(cu->GetOffset(), &cu_idx); + DebugInfo()->GetCompileUnit(curr_cu->GetOffset(), &cu_idx); m_obj_file->GetModule()->GetSymbolVendor()->SetCompileUnitAtIndex(dc_cu, cu_idx); @@ -1496,20 +1496,20 @@ m_debug_map_symfile->SetCompileUnit(this, dc_cu); } } - return (CompileUnit*)cu->GetUserData(); + return (CompileUnit*)curr_cu->GetUserData(); } bool -SymbolFileDWARF::GetFunction (DWARFCompileUnit* cu, const DWARFDebugInfoEntry* func_die, SymbolContext& sc) +SymbolFileDWARF::GetFunction (DWARFCompileUnit* curr_cu, const DWARFDebugInfoEntry* func_die, SymbolContext& sc) { sc.Clear(); // Check if the symbol vendor already knows about this compile unit? sc.module_sp = m_obj_file->GetModule()->GetSP(); - sc.comp_unit = GetCompUnitForDWARFCompUnit(cu, UINT32_MAX); + sc.comp_unit = GetCompUnitForDWARFCompUnit(curr_cu, UINT32_MAX); sc.function = sc.comp_unit->FindFunctionByUID (func_die->GetOffset()).get(); if (sc.function == NULL) - sc.function = ParseCompileUnitFunction(sc, cu, func_die); + sc.function = ParseCompileUnitFunction(sc, curr_cu, func_die); return sc.function != NULL; } @@ -1538,10 +1538,10 @@ if (cu_offset != DW_INVALID_OFFSET) { uint32_t cu_idx; - DWARFCompileUnit* cu = debug_info->GetCompileUnit(cu_offset, &cu_idx).get(); - if (cu) + DWARFCompileUnit* curr_cu = debug_info->GetCompileUnit(cu_offset, &cu_idx).get(); + if (curr_cu) { - sc.comp_unit = GetCompUnitForDWARFCompUnit(cu, cu_idx); + sc.comp_unit = GetCompUnitForDWARFCompUnit(curr_cu, cu_idx); assert(sc.comp_unit != NULL); resolved |= eSymbolContextCompUnit; @@ -1577,18 +1577,18 @@ DWARFDebugInfoEntry *block_die = NULL; if (resolve_scope & eSymbolContextBlock) { - cu->LookupAddress(file_vm_addr, &function_die, &block_die); + curr_cu->LookupAddress(file_vm_addr, &function_die, &block_die); } else { - cu->LookupAddress(file_vm_addr, &function_die, NULL); + curr_cu->LookupAddress(file_vm_addr, &function_die, NULL); } if (function_die != NULL) { sc.function = sc.comp_unit->FindFunctionByUID (function_die->GetOffset()).get(); if (sc.function == NULL) - sc.function = ParseCompileUnitFunction(sc, cu, function_die); + sc.function = ParseCompileUnitFunction(sc, curr_cu, function_die); } if (sc.function != NULL) @@ -1627,16 +1627,16 @@ if (debug_info) { uint32_t cu_idx; - DWARFCompileUnit* cu = NULL; + DWARFCompileUnit* curr_cu = NULL; - for (cu_idx = 0; (cu = debug_info->GetCompileUnitAtIndex(cu_idx)) != NULL; ++cu_idx) + for (cu_idx = 0; (curr_cu = debug_info->GetCompileUnitAtIndex(cu_idx)) != NULL; ++cu_idx) { - CompileUnit *dc_cu = GetCompUnitForDWARFCompUnit(cu, cu_idx); + CompileUnit *dc_cu = GetCompUnitForDWARFCompUnit(curr_cu, cu_idx); bool file_spec_matches_cu_file_spec = dc_cu != NULL && FileSpec::Compare(file_spec, *dc_cu, false) == 0; if (check_inlines || file_spec_matches_cu_file_spec) { SymbolContext sc (m_obj_file->GetModule()); - sc.comp_unit = GetCompUnitForDWARFCompUnit(cu, cu_idx); + sc.comp_unit = GetCompUnitForDWARFCompUnit(curr_cu, cu_idx); assert(sc.comp_unit != NULL); uint32_t file_idx = UINT32_MAX; @@ -1678,13 +1678,13 @@ { DWARFDebugInfoEntry *function_die = NULL; DWARFDebugInfoEntry *block_die = NULL; - cu->LookupAddress(file_vm_addr, &function_die, resolve_scope & eSymbolContextBlock ? &block_die : NULL); + curr_cu->LookupAddress(file_vm_addr, &function_die, resolve_scope & eSymbolContextBlock ? &block_die : NULL); if (function_die != NULL) { sc.function = sc.comp_unit->FindFunctionByUID (function_die->GetOffset()).get(); if (sc.function == NULL) - sc.function = ParseCompileUnitFunction(sc, cu, function_die); + sc.function = ParseCompileUnitFunction(sc, curr_cu, function_die); } if (sc.function != NULL) @@ -1746,11 +1746,11 @@ const uint32_t num_compile_units = GetNumCompileUnits(); for (cu_idx = 0; cu_idx < num_compile_units; ++cu_idx) { - DWARFCompileUnit* cu = debug_info->GetCompileUnitAtIndex(cu_idx); + DWARFCompileUnit* curr_cu = debug_info->GetCompileUnitAtIndex(cu_idx); - bool clear_dies = cu->ExtractDIEsIfNeeded (false) > 1; + bool clear_dies = curr_cu->ExtractDIEsIfNeeded (false) > 1; - cu->Index (cu_idx, + curr_cu->Index (cu_idx, m_function_basename_index, m_function_fullname_index, m_function_method_index, @@ -1765,7 +1765,7 @@ // Keep memory down by clearing DIEs if this generate function // caused them to be parsed if (clear_dies) - cu->ClearDIEs (true); + curr_cu->ClearDIEs (true); } m_aranges->Sort(); @@ -1776,14 +1776,14 @@ GetObjectFile()->GetModule()->GetArchitecture().AsCString(), GetObjectFile()->GetFileSpec().GetDirectory().AsCString(), GetObjectFile()->GetFileSpec().GetFilename().AsCString()); - s.Printf("\nFunction basenames:\n"); m_function_basename_index.Dump (&s); - s.Printf("\nFunction fullnames:\n"); m_function_fullname_index.Dump (&s); - s.Printf("\nFunction methods:\n"); m_function_method_index.Dump (&s); - s.Printf("\nFunction selectors:\n"); m_function_selector_index.Dump (&s); - s.Printf("\nObjective C class selectors:\n"); m_objc_class_selectors_index.Dump (&s); - s.Printf("\nGlobals and statics:\n"); m_global_index.Dump (&s); +// s.Printf("\nFunction basenames:\n"); m_function_basename_index.Dump (&s); +// s.Printf("\nFunction fullnames:\n"); m_function_fullname_index.Dump (&s); +// s.Printf("\nFunction methods:\n"); m_function_method_index.Dump (&s); +// s.Printf("\nFunction selectors:\n"); m_function_selector_index.Dump (&s); +// s.Printf("\nObjective C class selectors:\n"); m_objc_class_selectors_index.Dump (&s); +// s.Printf("\nGlobals and statics:\n"); m_global_index.Dump (&s); s.Printf("\nTypes:\n"); m_type_index.Dump (&s); - s.Printf("\nNamepaces:\n"); m_namespace_index.Dump (&s); +// s.Printf("\nNamepaces:\n"); m_namespace_index.Dump (&s); #endif } @@ -1812,24 +1812,24 @@ sc.module_sp = m_obj_file->GetModule()->GetSP(); assert (sc.module_sp); - DWARFCompileUnit* cu = NULL; + DWARFCompileUnit* curr_cu = NULL; DWARFCompileUnit* prev_cu = NULL; const DWARFDebugInfoEntry* die = NULL; std::vector die_info_array; const size_t num_matches = m_global_index.Find(name, die_info_array); - for (size_t i=0; iGetCompileUnitAtIndex(die_info_array[i].cu_idx); + curr_cu = info->GetCompileUnitAtIndex(die_info_array[i].cu_idx); - if (cu != prev_cu) - cu->ExtractDIEsIfNeeded (false); + if (curr_cu != prev_cu) + curr_cu->ExtractDIEsIfNeeded (false); - die = cu->GetDIEAtIndexUnchecked(die_info_array[i].die_idx); + die = curr_cu->GetDIEAtIndexUnchecked(die_info_array[i].die_idx); - sc.comp_unit = GetCompUnitForDWARFCompUnit(cu, UINT32_MAX); + sc.comp_unit = GetCompUnitForDWARFCompUnit(curr_cu, UINT32_MAX); assert(sc.comp_unit != NULL); - ParseVariables(sc, cu, LLDB_INVALID_ADDRESS, die, false, false, &variables); + ParseVariables(sc, curr_cu, LLDB_INVALID_ADDRESS, die, false, false, &variables); if (variables.GetSize() - original_size >= max_matches) break; @@ -1862,24 +1862,24 @@ sc.module_sp = m_obj_file->GetModule()->GetSP(); assert (sc.module_sp); - DWARFCompileUnit* cu = NULL; + DWARFCompileUnit* curr_cu = NULL; DWARFCompileUnit* prev_cu = NULL; const DWARFDebugInfoEntry* die = NULL; std::vector die_info_array; const size_t num_matches = m_global_index.Find(regex, die_info_array); - for (size_t i=0; iGetCompileUnitAtIndex(die_info_array[i].cu_idx); + curr_cu = info->GetCompileUnitAtIndex(die_info_array[i].cu_idx); - if (cu != prev_cu) - cu->ExtractDIEsIfNeeded (false); + if (curr_cu != prev_cu) + curr_cu->ExtractDIEsIfNeeded (false); - die = cu->GetDIEAtIndexUnchecked(die_info_array[i].die_idx); + die = curr_cu->GetDIEAtIndexUnchecked(die_info_array[i].die_idx); - sc.comp_unit = GetCompUnitForDWARFCompUnit(cu, UINT32_MAX); + sc.comp_unit = GetCompUnitForDWARFCompUnit(curr_cu, UINT32_MAX); assert(sc.comp_unit != NULL); - ParseVariables(sc, cu, LLDB_INVALID_ADDRESS, die, false, false, &variables); + ParseVariables(sc, curr_cu, LLDB_INVALID_ADDRESS, die, false, false, &variables); if (variables.GetSize() - original_size >= max_matches) break; @@ -1906,20 +1906,20 @@ sc.module_sp = m_obj_file->GetModule()->GetSP(); assert (sc.module_sp); - DWARFCompileUnit* cu = NULL; + DWARFCompileUnit* curr_cu = NULL; DWARFCompileUnit* prev_cu = NULL; const DWARFDebugInfoEntry* die = NULL; std::vector die_info_array; const size_t num_matches = name_to_die.Find(name, die_info_array); - for (size_t i=0; iGetCompileUnitAtIndex(die_info_array[i].cu_idx); + curr_cu = info->GetCompileUnitAtIndex(die_info_array[i].cu_idx); - if (cu != prev_cu) - cu->ExtractDIEsIfNeeded (false); + if (curr_cu != prev_cu) + curr_cu->ExtractDIEsIfNeeded (false); - die = cu->GetDIEAtIndexUnchecked(die_info_array[i].die_idx); - if (GetFunction (cu, die, sc)) + die = curr_cu->GetDIEAtIndexUnchecked(die_info_array[i].die_idx); + if (GetFunction (curr_cu, die, sc)) { // We found the function, so we should find the line table // and line table entry as well @@ -1954,20 +1954,20 @@ sc.module_sp = m_obj_file->GetModule()->GetSP(); assert (sc.module_sp); - DWARFCompileUnit* cu = NULL; + DWARFCompileUnit* curr_cu = NULL; DWARFCompileUnit* prev_cu = NULL; const DWARFDebugInfoEntry* die = NULL; std::vector die_info_array; const size_t num_matches = name_to_die.Find(regex, die_info_array); - for (size_t i=0; iGetCompileUnitAtIndex(die_info_array[i].cu_idx); + curr_cu = info->GetCompileUnitAtIndex(die_info_array[i].cu_idx); - if (cu != prev_cu) - cu->ExtractDIEsIfNeeded (false); + if (curr_cu != prev_cu) + curr_cu->ExtractDIEsIfNeeded (false); - die = cu->GetDIEAtIndexUnchecked(die_info_array[i].die_idx); - if (GetFunction (cu, die, sc)) + die = curr_cu->GetDIEAtIndexUnchecked(die_info_array[i].die_idx); + if (GetFunction (curr_cu, die, sc)) { // We found the function, so we should find the line table // and line table entry as well @@ -2071,21 +2071,21 @@ Index (); const uint32_t initial_types_size = types.GetSize(); - DWARFCompileUnit* cu = NULL; + DWARFCompileUnit* curr_cu = NULL; DWARFCompileUnit* prev_cu = NULL; const DWARFDebugInfoEntry* die = NULL; std::vector die_info_array; const size_t num_matches = m_type_index.Find (name, die_info_array); - for (size_t i=0; iGetCompileUnitAtIndex(die_info_array[i].cu_idx); + curr_cu = info->GetCompileUnitAtIndex(die_info_array[i].cu_idx); - if (cu != prev_cu) - cu->ExtractDIEsIfNeeded (false); + if (curr_cu != prev_cu) + curr_cu->ExtractDIEsIfNeeded (false); - die = cu->GetDIEAtIndexUnchecked(die_info_array[i].die_idx); + die = curr_cu->GetDIEAtIndexUnchecked(die_info_array[i].die_idx); - Type *matching_type = ResolveType (cu, die); + Type *matching_type = ResolveType (curr_cu, die); if (matching_type) { // We found a type pointer, now find the shared pointer form our type list @@ -2100,6 +2100,38 @@ } +clang::NamespaceDecl * +SymbolFileDWARF::FindNamespace (const SymbolContext& sc, + const ConstString &name) +{ + DWARFDebugInfo* info = DebugInfo(); + if (info == NULL) + return 0; + + // Index if we already haven't to make sure the compile units + // get indexed and make their global DIE index list + if (!m_indexed) + Index (); + + DWARFCompileUnit* curr_cu = NULL; + DWARFCompileUnit* prev_cu = NULL; + const DWARFDebugInfoEntry* die = NULL; + std::vector die_info_array; + const size_t num_matches = m_namespace_index.Find (name, die_info_array); + for (size_t i=0; iGetCompileUnitAtIndex(die_info_array[i].cu_idx); + + if (curr_cu != prev_cu) + curr_cu->ExtractDIEsIfNeeded (false); + + die = curr_cu->GetDIEAtIndexUnchecked(die_info_array[i].die_idx); + + return ResolveNamespaceDIE (curr_cu, die); + } + return NULL; +} + uint32_t SymbolFileDWARF::FindTypes(std::vector die_offsets, uint32_t max_matches, TypeList& types) { @@ -2220,8 +2252,8 @@ // HACK: Objective C formal parameters "self" and "_cmd" // are not marked as artificial in the DWARF... - CompileUnit *cu = GetCompUnitForDWARFCompUnit(dwarf_cu, UINT32_MAX); - if (cu && (cu->GetLanguage() == eLanguageTypeObjC || cu->GetLanguage() == eLanguageTypeObjC_plus_plus)) + CompileUnit *curr_cu = GetCompUnitForDWARFCompUnit(dwarf_cu, UINT32_MAX); + if (curr_cu && (curr_cu->GetLanguage() == eLanguageTypeObjC || curr_cu->GetLanguage() == eLanguageTypeObjC_plus_plus)) { if (name && name[0] && (strcmp (name, "self") == 0 || strcmp (name, "_cmd") == 0)) skip = true; @@ -2477,17 +2509,17 @@ } TypeSP -SymbolFileDWARF::GetTypeForDIE (DWARFCompileUnit *cu, const DWARFDebugInfoEntry* die) +SymbolFileDWARF::GetTypeForDIE (DWARFCompileUnit *curr_cu, const DWARFDebugInfoEntry* die) { TypeSP type_sp; if (die != NULL) { - assert(cu != NULL); + assert(curr_cu != NULL); Type *type_ptr = m_die_to_type.lookup (die); if (type_ptr == NULL) { - SymbolContext sc(GetCompUnitForDWARFCompUnit(cu)); - type_sp = ParseType(sc, cu, die, NULL); + SymbolContext sc(GetCompUnitForDWARFCompUnit(curr_cu)); + type_sp = ParseType(sc, curr_cu, die, NULL); } else if (type_ptr != DIE_IS_BEING_PARSED) { @@ -2512,9 +2544,26 @@ } +clang::NamespaceDecl * +SymbolFileDWARF::ResolveNamespaceDIE (DWARFCompileUnit *curr_cu, const DWARFDebugInfoEntry *die) +{ + if (die->Tag() == DW_TAG_namespace) + { + const char *namespace_name = die->GetAttributeValueAsString(this, curr_cu, DW_AT_name, NULL); + if (namespace_name) + { + Declaration decl; // TODO: fill in the decl object + clang::NamespaceDecl *namespace_decl = GetClangASTContext().GetUniqueNamespaceDeclaration (namespace_name, decl, GetClangDeclContextForDIE (curr_cu, die->GetParent())); + if (namespace_decl) + m_die_to_decl_ctx[die] = (clang::DeclContext*)namespace_decl; + return namespace_decl; + } + } + return NULL; +} clang::DeclContext * -SymbolFileDWARF::GetClangDeclContextForDIE (DWARFCompileUnit *cu, const DWARFDebugInfoEntry *die) +SymbolFileDWARF::GetClangDeclContextForDIE (DWARFCompileUnit *curr_cu, const DWARFDebugInfoEntry *die) { DIEToDeclContextMap::iterator pos = m_die_to_decl_ctx.find(die); if (pos != m_die_to_decl_ctx.end()) @@ -2526,11 +2575,11 @@ { case DW_TAG_namespace: { - const char *namespace_name = die->GetAttributeValueAsString(this, cu, DW_AT_name, NULL); + const char *namespace_name = die->GetAttributeValueAsString(this, curr_cu, DW_AT_name, NULL); if (namespace_name) { Declaration decl; // TODO: fill in the decl object - clang::NamespaceDecl *namespace_decl = GetClangASTContext().GetUniqueNamespaceDeclaration (namespace_name, decl, GetClangDeclContextForDIE (cu, die->GetParent())); + clang::NamespaceDecl *namespace_decl = GetClangASTContext().GetUniqueNamespaceDeclaration (namespace_name, decl, GetClangDeclContextForDIE (curr_cu, die->GetParent())); if (namespace_decl) m_die_to_decl_ctx[die] = (clang::DeclContext*)namespace_decl; return namespace_decl; @@ -2542,11 +2591,11 @@ break; } clang::DeclContext *decl_ctx; - decl_ctx = GetClangDeclContextForDIEOffset (die->GetAttributeValueAsUnsigned(this, cu, DW_AT_specification, DW_INVALID_OFFSET)); + decl_ctx = GetClangDeclContextForDIEOffset (die->GetAttributeValueAsUnsigned(this, curr_cu, DW_AT_specification, DW_INVALID_OFFSET)); if (decl_ctx) return decl_ctx; - decl_ctx = GetClangDeclContextForDIEOffset (die->GetAttributeValueAsUnsigned(this, cu, DW_AT_abstract_origin, DW_INVALID_OFFSET)); + decl_ctx = GetClangDeclContextForDIEOffset (die->GetAttributeValueAsUnsigned(this, curr_cu, DW_AT_abstract_origin, DW_INVALID_OFFSET)); if (decl_ctx) return decl_ctx; @@ -2562,14 +2611,14 @@ // DIE and we want to try and find a type that has the complete definition. TypeSP SymbolFileDWARF::FindDefinitionTypeForDIE ( - DWARFCompileUnit* cu, + DWARFCompileUnit* curr_cu, const DWARFDebugInfoEntry *die, const ConstString &type_name ) { TypeSP type_sp; - if (cu == NULL || die == NULL || !type_name) + if (curr_cu == NULL || die == NULL || !type_name) return type_sp; const dw_tag_t type_tag = die->Tag(); @@ -2578,7 +2627,7 @@ if (num_matches > 0) { DWARFCompileUnit* type_cu = NULL; - DWARFCompileUnit* curr_cu = cu; + DWARFCompileUnit* curr_cu = curr_cu; DWARFDebugInfo *info = DebugInfo(); for (size_t i=0; iGetOffset(), - dwarf_cu->GetOffset(), + curr_cu->GetOffset(), m_obj_file->GetFileSpec().GetFilename().AsCString(), type_die->GetOffset(), type_cu->GetOffset()); 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=118737&r1=118736&r2=118737&view=diff ============================================================================== --- lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h (original) +++ lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h Wed Nov 10 17:42:09 2010 @@ -110,7 +110,9 @@ virtual uint32_t FindTypes (const lldb_private::SymbolContext& sc, const lldb_private::ConstString &name, bool append, uint32_t max_matches, lldb_private::TypeList& types); // virtual uint32_t FindTypes(const lldb_private::SymbolContext& sc, const lldb_private::RegularExpression& regex, bool append, uint32_t max_matches, lldb::Type::Encoding encoding, lldb::user_id_t udt_uid, lldb_private::TypeList& types); virtual lldb_private::TypeList *GetTypeList (); - + virtual clang::NamespaceDecl * + FindNamespace (const lldb_private::SymbolContext& sc, + const lldb_private::ConstString &name); //------------------------------------------------------------------ // PluginInterface protocol @@ -299,8 +301,11 @@ } lldb_private::ClangASTContext & - GetClangASTContext(); + GetClangASTContext(); + clang::NamespaceDecl * + ResolveNamespaceDIE (DWARFCompileUnit *curr_cu, const DWARFDebugInfoEntry *die); + SymbolFileDWARFDebugMap * m_debug_map_symfile; clang::TranslationUnitDecl * m_clang_tu_decl; lldb_private::Flags m_flags; Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp?rev=118737&r1=118736&r2=118737&view=diff ============================================================================== --- lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp (original) +++ lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp Wed Nov 10 17:42:09 2010 @@ -952,6 +952,36 @@ // return 0; //} + +clang::NamespaceDecl * +SymbolFileDWARFDebugMap::FindNamespace (const lldb_private::SymbolContext& sc, + const lldb_private::ConstString &name) +{ + clang::NamespaceDecl *matching_namespace = NULL; + SymbolFileDWARF *oso_dwarf; + + if (sc.comp_unit) + { + oso_dwarf = GetSymbolFile (sc); + if (oso_dwarf) + matching_namespace = oso_dwarf->FindNamespace (sc, name); + } + else + { + for (uint32_t oso_idx = 0; + ((oso_dwarf = GetSymbolFileByOSOIndex (oso_idx)) != NULL); + ++oso_idx) + { + matching_namespace = oso_dwarf->FindNamespace (sc, name); + + if (matching_namespace) + break; + } + } + + return matching_namespace; +} + //------------------------------------------------------------------ // PluginInterface protocol //------------------------------------------------------------------ Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h?rev=118737&r1=118736&r2=118737&view=diff ============================================================================== --- lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h (original) +++ lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h Wed Nov 10 17:42:09 2010 @@ -71,6 +71,9 @@ virtual uint32_t FindFunctions (const lldb_private::RegularExpression& regex, bool append, lldb_private::SymbolContextList& sc_list); virtual uint32_t FindTypes (const lldb_private::SymbolContext& sc, const lldb_private::ConstString &name, bool append, uint32_t max_matches, lldb_private::TypeList& types); // virtual uint32_t FindTypes (const lldb_private::SymbolContext& sc, const RegularExpression& regex, bool append, uint32_t max_matches, Type::Encoding encoding, lldb::user_id_t udt_uid, TypeList& types); + virtual clang::NamespaceDecl * + FindNamespace (const lldb_private::SymbolContext& sc, + const lldb_private::ConstString &name); //------------------------------------------------------------------ // PluginInterface protocol Modified: lldb/trunk/source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.cpp?rev=118737&r1=118736&r2=118737&view=diff ============================================================================== --- lldb/trunk/source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.cpp (original) +++ lldb/trunk/source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.cpp Wed Nov 10 17:42:09 2010 @@ -277,6 +277,11 @@ return NULL; } +clang::NamespaceDecl * +SymbolFileSymtab::FindNamespace (const SymbolContext& sc, const ConstString &name) +{ + return NULL; +} uint32_t SymbolFileSymtab::ResolveSymbolContext (const Address& so_addr, uint32_t resolve_scope, SymbolContext& sc) Modified: lldb/trunk/source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.h?rev=118737&r1=118736&r2=118737&view=diff ============================================================================== --- lldb/trunk/source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.h (original) +++ lldb/trunk/source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.h Wed Nov 10 17:42:09 2010 @@ -101,6 +101,10 @@ // virtual uint32_t // FindTypes(const lldb_private::SymbolContext& sc, const lldb_private::RegularExpression& regex, bool append, uint32_t max_matches, lldb_private::TypeList& types); + virtual clang::NamespaceDecl * + FindNamespace (const lldb_private::SymbolContext& sc, + const lldb_private::ConstString &name); + //------------------------------------------------------------------ // PluginInterface protocol //------------------------------------------------------------------ From johnny.chen at apple.com Wed Nov 10 17:46:38 2010 From: johnny.chen at apple.com (Johnny Chen) Date: Wed, 10 Nov 2010 23:46:38 -0000 Subject: [Lldb-commits] [lldb] r118739 - /lldb/trunk/test/lldbtest.py Message-ID: <20101110234638.8363C2A6C12C@llvm.org> Author: johnny Date: Wed Nov 10 17:46:38 2010 New Revision: 118739 URL: http://llvm.org/viewvc/llvm-project?rev=118739&view=rev Log: Some rewordings of the assert messages for process stopped due to breakpoint. Modified: lldb/trunk/test/lldbtest.py Modified: lldb/trunk/test/lldbtest.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/lldbtest.py?rev=118739&r1=118738&r2=118739&view=diff ============================================================================== --- lldb/trunk/test/lldbtest.py (original) +++ lldb/trunk/test/lldbtest.py Wed Nov 10 17:46:38 2010 @@ -151,9 +151,10 @@ STEP_OUT_SUCCEEDED = "Thread step-out succeeded" -STOPPED_DUE_TO_BREAKPOINT = "Process is stopped due to breakpoint" +STOPPED_DUE_TO_BREAKPOINT = "Process should be stopped due to breakpoint" -STOPPED_DUE_TO_BREAKPOINT_WITH_STOP_REASON_AS = "Process is stopped due to breakpoint (actual stop reason: '%s')" +STOPPED_DUE_TO_BREAKPOINT_WITH_STOP_REASON_AS = "%s, %s" % ( + STOPPED_DUE_TO_BREAKPOINT, "instead, the actual stop reason is: '%s'") STOPPED_DUE_TO_BREAKPOINT_CONDITION = "Stopped due to breakpoint condition" From gclayton at apple.com Wed Nov 10 19:09:45 2010 From: gclayton at apple.com (Greg Clayton) Date: Thu, 11 Nov 2010 01:09:45 -0000 Subject: [Lldb-commits] [lldb] r118758 - /lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp Message-ID: <20101111010945.CBC8D2A6C12D@llvm.org> Author: gclayton Date: Wed Nov 10 19:09:45 2010 New Revision: 118758 URL: http://llvm.org/viewvc/llvm-project?rev=118758&view=rev Log: Disable the debug logging I accidentally left enabled. Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp 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=118758&r1=118757&r2=118758&view=diff ============================================================================== --- lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp (original) +++ lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp Wed Nov 10 19:09:45 2010 @@ -53,7 +53,7 @@ #include -#define ENABLE_DEBUG_PRINTF // COMMENT OUT THIS LINE PRIOR TO CHECKIN +//#define ENABLE_DEBUG_PRINTF // COMMENT OUT THIS LINE PRIOR TO CHECKIN #ifdef ENABLE_DEBUG_PRINTF #include From gclayton at apple.com Wed Nov 10 20:14:53 2010 From: gclayton at apple.com (Greg Clayton) Date: Thu, 11 Nov 2010 02:14:53 -0000 Subject: [Lldb-commits] [lldb] r118770 - in /lldb/trunk: lldb.xcodeproj/project.pbxproj source/Symbol/ClangASTContext.cpp Message-ID: <20101111021453.90F412A6C12C@llvm.org> Author: gclayton Date: Wed Nov 10 20:14:53 2010 New Revision: 118770 URL: http://llvm.org/viewvc/llvm-project?rev=118770&view=rev Log: Fixed an issue where we might not be able to track down a real definition of a forward declaration to a struct and hangle it gracefully (don't crash trying to ask clang how many children an empty record has). Modified: lldb/trunk/lldb.xcodeproj/project.pbxproj lldb/trunk/source/Symbol/ClangASTContext.cpp Modified: lldb/trunk/lldb.xcodeproj/project.pbxproj URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/lldb.xcodeproj/project.pbxproj?rev=118770&r1=118769&r2=118770&view=diff ============================================================================== --- lldb/trunk/lldb.xcodeproj/project.pbxproj (original) +++ lldb/trunk/lldb.xcodeproj/project.pbxproj Wed Nov 10 20:14:53 2010 @@ -2438,6 +2438,7 @@ isa = PBXProject; buildConfigurationList = 1DEB91EF08733DB70010E9CD /* Build configuration list for PBXProject "lldb" */; compatibilityVersion = "Xcode 3.1"; + developmentRegion = English; hasScannedForEncodings = 1; knownRegions = ( en, Modified: lldb/trunk/source/Symbol/ClangASTContext.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/ClangASTContext.cpp?rev=118770&r1=118769&r2=118770&view=diff ============================================================================== --- lldb/trunk/source/Symbol/ClangASTContext.cpp (original) +++ lldb/trunk/source/Symbol/ClangASTContext.cpp Wed Nov 10 20:14:53 2010 @@ -1836,6 +1836,7 @@ break; case clang::Type::Record: + if (ClangASTType::IsDefined (clang_qual_type)) { const RecordType *record_type = cast(qual_type.getTypePtr()); const RecordDecl *record_decl = record_type->getDecl(); From gclayton at apple.com Wed Nov 10 20:22:58 2010 From: gclayton at apple.com (Greg Clayton) Date: Thu, 11 Nov 2010 02:22:58 -0000 Subject: [Lldb-commits] [lldb] r118772 - in /lldb/trunk: lldb.xcodeproj/project.pbxproj resources/LLDB-Info.plist tools/debugserver/debugserver.xcodeproj/project.pbxproj Message-ID: <20101111022259.087A62A6C12C@llvm.org> Author: gclayton Date: Wed Nov 10 20:22:58 2010 New Revision: 118772 URL: http://llvm.org/viewvc/llvm-project?rev=118772&view=rev Log: Bumped Xcode versions to lldb-32 and debugserver-119. Modified: lldb/trunk/lldb.xcodeproj/project.pbxproj lldb/trunk/resources/LLDB-Info.plist lldb/trunk/tools/debugserver/debugserver.xcodeproj/project.pbxproj Modified: lldb/trunk/lldb.xcodeproj/project.pbxproj URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/lldb.xcodeproj/project.pbxproj?rev=118772&r1=118771&r2=118772&view=diff ============================================================================== --- lldb/trunk/lldb.xcodeproj/project.pbxproj (original) +++ lldb/trunk/lldb.xcodeproj/project.pbxproj Wed Nov 10 20:22:58 2010 @@ -3001,9 +3001,9 @@ buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; COPY_PHASE_STRIP = NO; - CURRENT_PROJECT_VERSION = 31; + CURRENT_PROJECT_VERSION = 32; DYLIB_COMPATIBILITY_VERSION = 1; - DYLIB_CURRENT_VERSION = 31; + DYLIB_CURRENT_VERSION = 32; EXPORTED_SYMBOLS_FILE = "resources/lldb-framework-exports"; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", @@ -3053,11 +3053,11 @@ buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; COPY_PHASE_STRIP = NO; - CURRENT_PROJECT_VERSION = 31; + CURRENT_PROJECT_VERSION = 32; DEAD_CODE_STRIPPING = YES; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; DYLIB_COMPATIBILITY_VERSION = 1; - DYLIB_CURRENT_VERSION = 31; + DYLIB_CURRENT_VERSION = 32; EXPORTED_SYMBOLS_FILE = "resources/lldb-framework-exports"; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", @@ -3127,7 +3127,7 @@ isa = XCBuildConfiguration; buildSettings = { COPY_PHASE_STRIP = YES; - CURRENT_PROJECT_VERSION = 31; + CURRENT_PROJECT_VERSION = 32; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", @@ -3162,11 +3162,11 @@ buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; COPY_PHASE_STRIP = YES; - CURRENT_PROJECT_VERSION = 31; + CURRENT_PROJECT_VERSION = 32; DEAD_CODE_STRIPPING = YES; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; DYLIB_COMPATIBILITY_VERSION = 1; - DYLIB_CURRENT_VERSION = 31; + DYLIB_CURRENT_VERSION = 32; EXPORTED_SYMBOLS_FILE = "resources/lldb-framework-exports"; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", @@ -3215,7 +3215,7 @@ buildSettings = { CODE_SIGN_IDENTITY = lldb_codesign; COPY_PHASE_STRIP = NO; - CURRENT_PROJECT_VERSION = 31; + CURRENT_PROJECT_VERSION = 32; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", "\"$(SYSTEM_LIBRARY_DIR)/PrivateFrameworks\"", @@ -3253,7 +3253,7 @@ ); CODE_SIGN_IDENTITY = lldb_codesign; COPY_PHASE_STRIP = YES; - CURRENT_PROJECT_VERSION = 31; + CURRENT_PROJECT_VERSION = 32; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", Modified: lldb/trunk/resources/LLDB-Info.plist URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/resources/LLDB-Info.plist?rev=118772&r1=118771&r2=118772&view=diff ============================================================================== --- lldb/trunk/resources/LLDB-Info.plist (original) +++ lldb/trunk/resources/LLDB-Info.plist Wed Nov 10 20:22:58 2010 @@ -17,7 +17,7 @@ CFBundleSignature ???? CFBundleVersion - 31 + 32 CFBundleName ${EXECUTABLE_NAME} Modified: lldb/trunk/tools/debugserver/debugserver.xcodeproj/project.pbxproj URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/debugserver/debugserver.xcodeproj/project.pbxproj?rev=118772&r1=118771&r2=118772&view=diff ============================================================================== --- lldb/trunk/tools/debugserver/debugserver.xcodeproj/project.pbxproj (original) +++ lldb/trunk/tools/debugserver/debugserver.xcodeproj/project.pbxproj Wed Nov 10 20:22:58 2010 @@ -456,7 +456,7 @@ i386, ); COPY_PHASE_STRIP = NO; - CURRENT_PROJECT_VERSION = 118; + CURRENT_PROJECT_VERSION = 119; GCC_WARN_ABOUT_RETURN_TYPE = YES; GCC_WARN_UNUSED_VARIABLE = YES; STRIP_INSTALLED_PRODUCT = NO; @@ -474,7 +474,7 @@ x86_64, i386, ); - CURRENT_PROJECT_VERSION = 118; + CURRENT_PROJECT_VERSION = 119; DEAD_CODE_STRIPPING = YES; GCC_WARN_ABOUT_RETURN_TYPE = YES; GCC_WARN_UNUSED_VARIABLE = YES; @@ -494,7 +494,7 @@ x86_64, i386, ); - CURRENT_PROJECT_VERSION = 118; + CURRENT_PROJECT_VERSION = 119; DEAD_CODE_STRIPPING = YES; GCC_WARN_ABOUT_RETURN_TYPE = YES; GCC_WARN_UNUSED_VARIABLE = YES; @@ -511,7 +511,7 @@ buildSettings = { "CODE_SIGN_ENTITLEMENTS[sdk=iphoneos*]" = "source/debugserver-entitlements.plist"; COPY_PHASE_STRIP = YES; - CURRENT_PROJECT_VERSION = 118; + CURRENT_PROJECT_VERSION = 119; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; FRAMEWORK_SEARCH_PATHS = $SDKROOT/System/Library/PrivateFrameworks; "FRAMEWORK_SEARCH_PATHS[sdk=iphoneos*][arch=*]" = ( @@ -552,7 +552,7 @@ "CODE_SIGN_ENTITLEMENTS[sdk=iphoneos*]" = "source/debugserver-entitlements.plist"; "CODE_SIGN_IDENTITY[sdk=macosx*]" = lldb_codesign; COPY_PHASE_STRIP = YES; - CURRENT_PROJECT_VERSION = 118; + CURRENT_PROJECT_VERSION = 119; FRAMEWORK_SEARCH_PATHS = $SDKROOT/System/Library/PrivateFrameworks; "FRAMEWORK_SEARCH_PATHS[sdk=iphoneos*][arch=*]" = ( "$(SDKROOT)/System/Library/PrivateFrameworks", @@ -593,7 +593,7 @@ "CODE_SIGN_ENTITLEMENTS[sdk=iphoneos*]" = "source/debugserver-entitlements.plist"; "CODE_SIGN_IDENTITY[sdk=macosx*]" = lldb_codesign; COPY_PHASE_STRIP = YES; - CURRENT_PROJECT_VERSION = 118; + CURRENT_PROJECT_VERSION = 119; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; FRAMEWORK_SEARCH_PATHS = $SDKROOT/System/Library/PrivateFrameworks; "FRAMEWORK_SEARCH_PATHS[sdk=iphoneos*][arch=*]" = ( From johnny.chen at apple.com Thu Nov 11 13:15:04 2010 From: johnny.chen at apple.com (Johnny Chen) Date: Thu, 11 Nov 2010 19:15:04 -0000 Subject: [Lldb-commits] [lldb] r118820 - /lldb/trunk/test/foundation/TestObjCMethods.py Message-ID: <20101111191504.D33162A6C12C@llvm.org> Author: johnny Date: Thu Nov 11 13:15:04 2010 New Revision: 118820 URL: http://llvm.org/viewvc/llvm-project?rev=118820&view=rev Log: Added a simple test for: rdar://problem/8651752 don't crash trying to ask clang how many children an empty record has Modified: lldb/trunk/test/foundation/TestObjCMethods.py Modified: lldb/trunk/test/foundation/TestObjCMethods.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/foundation/TestObjCMethods.py?rev=118820&r1=118819&r2=118820&view=diff ============================================================================== --- lldb/trunk/test/foundation/TestObjCMethods.py (original) +++ lldb/trunk/test/foundation/TestObjCMethods.py Thu Nov 11 13:15:04 2010 @@ -122,6 +122,10 @@ patterns = ["ARG: \(.*\) _cmd", "(struct objc_selector *)|(SEL)"]) + # rdar://problem/8651752 + # don't crash trying to ask clang how many children an empty record has + self.runCmd("frame variable *_cmd") + # rdar://problem/8492646 # test/foundation fails after updating to tot r115023 # self->str displays nothing as output From jingham at apple.com Thu Nov 11 13:26:09 2010 From: jingham at apple.com (Jim Ingham) Date: Thu, 11 Nov 2010 19:26:09 -0000 Subject: [Lldb-commits] [lldb] r118824 - in /lldb/trunk: include/lldb/ include/lldb/Target/ lldb.xcodeproj/ source/Core/ source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/ source/Target/ Message-ID: <20101111192609.A3A002A6C12D@llvm.org> Author: jingham Date: Thu Nov 11 13:26:09 2010 New Revision: 118824 URL: http://llvm.org/viewvc/llvm-project?rev=118824&view=rev Log: Add ThreadPlanTracer class to allow instruction step tracing of execution. Also changed eSetVarTypeBool to eSetVarTypeBoolean to make it consistent with eArgTypeBoolean. Added: lldb/trunk/include/lldb/Target/ThreadPlanTracer.h lldb/trunk/source/Target/ThreadPlanTracer.cpp Modified: lldb/trunk/include/lldb/Target/Thread.h lldb/trunk/include/lldb/Target/ThreadPlan.h lldb/trunk/include/lldb/Target/ThreadPlanBase.h lldb/trunk/include/lldb/Target/ThreadPlanCallFunction.h lldb/trunk/include/lldb/Target/ThreadPlanRunToAddress.h lldb/trunk/include/lldb/Target/ThreadPlanStepInstruction.h lldb/trunk/include/lldb/Target/ThreadPlanStepOut.h lldb/trunk/include/lldb/Target/ThreadPlanStepOverBreakpoint.h lldb/trunk/include/lldb/Target/ThreadPlanStepRange.h lldb/trunk/include/lldb/Target/ThreadPlanStepThrough.h lldb/trunk/include/lldb/Target/ThreadPlanStepUntil.h lldb/trunk/include/lldb/Target/ThreadPlanTestCondition.h lldb/trunk/include/lldb/lldb-enumerations.h lldb/trunk/include/lldb/lldb-forward-rtti.h lldb/trunk/include/lldb/lldb-forward.h lldb/trunk/lldb.xcodeproj/project.pbxproj lldb/trunk/source/Core/Debugger.cpp lldb/trunk/source/Core/UserSettingsController.cpp lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleThreadPlanStepThroughObjCTrampoline.cpp lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleThreadPlanStepThroughObjCTrampoline.h lldb/trunk/source/Target/Process.cpp lldb/trunk/source/Target/Thread.cpp lldb/trunk/source/Target/ThreadPlan.cpp lldb/trunk/source/Target/ThreadPlanBase.cpp lldb/trunk/source/Target/ThreadPlanCallFunction.cpp lldb/trunk/source/Target/ThreadPlanRunToAddress.cpp lldb/trunk/source/Target/ThreadPlanStepInstruction.cpp lldb/trunk/source/Target/ThreadPlanStepOut.cpp lldb/trunk/source/Target/ThreadPlanStepOverBreakpoint.cpp lldb/trunk/source/Target/ThreadPlanStepRange.cpp lldb/trunk/source/Target/ThreadPlanStepThrough.cpp lldb/trunk/source/Target/ThreadPlanStepUntil.cpp lldb/trunk/source/Target/ThreadPlanTestCondition.cpp Modified: lldb/trunk/include/lldb/Target/Thread.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/Thread.h?rev=118824&r1=118823&r2=118824&view=diff ============================================================================== --- lldb/trunk/include/lldb/Target/Thread.h (original) +++ lldb/trunk/include/lldb/Target/Thread.h Thu Nov 11 13:26:09 2010 @@ -20,9 +20,6 @@ #define LLDB_THREAD_MAX_STOP_EXC_DATA 8 -// I forward declare these here so I don't have to #include ThreadPlan, so in turn I -// can use Thread.h in ThreadPlan.h. - namespace lldb_private { class ThreadInstanceSettings : public InstanceSettings @@ -64,6 +61,14 @@ static const ConstString & StepAvoidRegexpVarName (); + + bool + GetTraceEnabledState() + { + return m_trace_enabled; + } + static const ConstString & + GetTraceThreadVarName (); protected: @@ -77,6 +82,7 @@ private: std::auto_ptr m_avoid_regexp_ap; + bool m_trace_enabled; }; class Thread : @@ -590,6 +596,12 @@ void DumpThreadPlans (Stream *s) const; + void + EnableTracer (bool value, bool single_step); + + void + SetTracer (lldb::ThreadPlanTracerSP &tracer_sp); + //------------------------------------------------------------------ /// The regular expression returned determines symbols that this /// thread won't stop in during "step-in" operations. Modified: lldb/trunk/include/lldb/Target/ThreadPlan.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/ThreadPlan.h?rev=118824&r1=118823&r2=118824&view=diff ============================================================================== --- lldb/trunk/include/lldb/Target/ThreadPlan.h (original) +++ lldb/trunk/include/lldb/Target/ThreadPlan.h Thu Nov 11 13:26:09 2010 @@ -19,6 +19,8 @@ #include "lldb/Core/UserID.h" #include "lldb/Host/Mutex.h" #include "lldb/Target/Thread.h" +#include "lldb/Target/ThreadPlanTracer.h" +#include "lldb/Target/StopInfo.h" namespace lldb_private { @@ -155,7 +157,7 @@ // //------------------------------------------------------------------ -class ThreadPlan: +class ThreadPlan : public UserID { public: @@ -247,10 +249,19 @@ virtual bool PlanExplainsStop () = 0; + + bool + TracerExplainsStop () + { + if (!m_tracer_sp) + return false; + else + return m_tracer_sp->TracerExplainsStop(); + } - virtual lldb::StateType - RunState () = 0; + lldb::StateType + RunState (); virtual bool ShouldStop (Event *event_ptr) = 0; @@ -325,6 +336,25 @@ void SetPlanComplete (); + + lldb::ThreadPlanTracerSP & + GetThreadPlanTracer() + { + return m_tracer_sp; + } + + void + SetThreadPlanTracer (lldb::ThreadPlanTracerSP new_tracer_sp) + { + m_tracer_sp = new_tracer_sp; + } + + void + DoTraceLog () + { + if (m_tracer_sp && m_tracer_sp->TracingEnabled()) + m_tracer_sp->Log(); + } protected: //------------------------------------------------------------------ @@ -352,6 +382,10 @@ { m_thread.SetStopInfo (stop_reason_sp); } + + virtual lldb::StateType + GetPlanRunState () = 0; + Thread &m_thread; lldb::Vote m_stop_vote; @@ -369,6 +403,8 @@ bool m_plan_complete; bool m_plan_private; bool m_okay_to_discard; + + lldb::ThreadPlanTracerSP m_tracer_sp; private: DISALLOW_COPY_AND_ASSIGN(ThreadPlan); Modified: lldb/trunk/include/lldb/Target/ThreadPlanBase.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/ThreadPlanBase.h?rev=118824&r1=118823&r2=118824&view=diff ============================================================================== --- lldb/trunk/include/lldb/Target/ThreadPlanBase.h (original) +++ lldb/trunk/include/lldb/Target/ThreadPlanBase.h Thu Nov 11 13:26:09 2010 @@ -36,7 +36,7 @@ virtual bool PlanExplainsStop (); virtual bool ShouldStop (Event *event_ptr); virtual bool StopOthers (); - virtual lldb::StateType RunState (); + virtual lldb::StateType GetPlanRunState (); virtual bool WillStop (); virtual bool MischiefManaged (); Modified: lldb/trunk/include/lldb/Target/ThreadPlanCallFunction.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/ThreadPlanCallFunction.h?rev=118824&r1=118823&r2=118824&view=diff ============================================================================== --- lldb/trunk/include/lldb/Target/ThreadPlanCallFunction.h (original) +++ lldb/trunk/include/lldb/Target/ThreadPlanCallFunction.h Thu Nov 11 13:26:09 2010 @@ -58,7 +58,7 @@ SetStopOthers (bool new_value); virtual lldb::StateType - RunState (); + GetPlanRunState (); virtual void DidPush (); Modified: lldb/trunk/include/lldb/Target/ThreadPlanRunToAddress.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/ThreadPlanRunToAddress.h?rev=118824&r1=118823&r2=118824&view=diff ============================================================================== --- lldb/trunk/include/lldb/Target/ThreadPlanRunToAddress.h (original) +++ lldb/trunk/include/lldb/Target/ThreadPlanRunToAddress.h Thu Nov 11 13:26:09 2010 @@ -59,7 +59,7 @@ SetStopOthers (bool new_value); virtual lldb::StateType - RunState (); + GetPlanRunState (); virtual bool WillStop (); Modified: lldb/trunk/include/lldb/Target/ThreadPlanStepInstruction.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/ThreadPlanStepInstruction.h?rev=118824&r1=118823&r2=118824&view=diff ============================================================================== --- lldb/trunk/include/lldb/Target/ThreadPlanStepInstruction.h (original) +++ lldb/trunk/include/lldb/Target/ThreadPlanStepInstruction.h Thu Nov 11 13:26:09 2010 @@ -30,7 +30,7 @@ virtual bool PlanExplainsStop (); virtual bool ShouldStop (Event *event_ptr); virtual bool StopOthers (); - virtual lldb::StateType RunState (); + virtual lldb::StateType GetPlanRunState (); virtual bool WillStop (); virtual bool MischiefManaged (); Modified: lldb/trunk/include/lldb/Target/ThreadPlanStepOut.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/ThreadPlanStepOut.h?rev=118824&r1=118823&r2=118824&view=diff ============================================================================== --- lldb/trunk/include/lldb/Target/ThreadPlanStepOut.h (original) +++ lldb/trunk/include/lldb/Target/ThreadPlanStepOut.h Thu Nov 11 13:26:09 2010 @@ -30,7 +30,7 @@ virtual bool PlanExplainsStop (); virtual bool ShouldStop (Event *event_ptr); virtual bool StopOthers (); - virtual lldb::StateType RunState (); + virtual lldb::StateType GetPlanRunState (); virtual bool WillResume (lldb::StateType resume_state, bool current_plan); virtual bool WillStop (); virtual bool MischiefManaged (); Modified: lldb/trunk/include/lldb/Target/ThreadPlanStepOverBreakpoint.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/ThreadPlanStepOverBreakpoint.h?rev=118824&r1=118823&r2=118824&view=diff ============================================================================== --- lldb/trunk/include/lldb/Target/ThreadPlanStepOverBreakpoint.h (original) +++ lldb/trunk/include/lldb/Target/ThreadPlanStepOverBreakpoint.h Thu Nov 11 13:26:09 2010 @@ -30,7 +30,7 @@ virtual bool PlanExplainsStop (); virtual bool ShouldStop (Event *event_ptr); virtual bool StopOthers (); - virtual lldb::StateType RunState (); + virtual lldb::StateType GetPlanRunState (); virtual bool WillResume (lldb::StateType resume_state, bool current_plan); virtual bool WillStop (); virtual bool MischiefManaged (); Modified: lldb/trunk/include/lldb/Target/ThreadPlanStepRange.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/ThreadPlanStepRange.h?rev=118824&r1=118823&r2=118824&view=diff ============================================================================== --- lldb/trunk/include/lldb/Target/ThreadPlanStepRange.h (original) +++ lldb/trunk/include/lldb/Target/ThreadPlanStepRange.h Thu Nov 11 13:26:09 2010 @@ -33,7 +33,7 @@ virtual bool ShouldStop (Event *event_ptr) = 0; virtual lldb::Vote ShouldReportStop (Event *event_ptr); virtual bool StopOthers (); - virtual lldb::StateType RunState (); + virtual lldb::StateType GetPlanRunState (); virtual bool WillStop (); virtual bool MischiefManaged (); Modified: lldb/trunk/include/lldb/Target/ThreadPlanStepThrough.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/ThreadPlanStepThrough.h?rev=118824&r1=118823&r2=118824&view=diff ============================================================================== --- lldb/trunk/include/lldb/Target/ThreadPlanStepThrough.h (original) +++ lldb/trunk/include/lldb/Target/ThreadPlanStepThrough.h Thu Nov 11 13:26:09 2010 @@ -29,7 +29,7 @@ virtual bool PlanExplainsStop (); virtual bool ShouldStop (Event *event_ptr); virtual bool StopOthers (); - virtual lldb::StateType RunState (); + virtual lldb::StateType GetPlanRunState (); virtual bool WillResume (lldb::StateType resume_state, bool current_plan); virtual bool WillStop (); virtual bool MischiefManaged (); Modified: lldb/trunk/include/lldb/Target/ThreadPlanStepUntil.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/ThreadPlanStepUntil.h?rev=118824&r1=118823&r2=118824&view=diff ============================================================================== --- lldb/trunk/include/lldb/Target/ThreadPlanStepUntil.h (original) +++ lldb/trunk/include/lldb/Target/ThreadPlanStepUntil.h Thu Nov 11 13:26:09 2010 @@ -30,7 +30,7 @@ virtual bool PlanExplainsStop (); virtual bool ShouldStop (Event *event_ptr); virtual bool StopOthers (); - virtual lldb::StateType RunState (); + virtual lldb::StateType GetPlanRunState (); virtual bool WillResume (lldb::StateType resume_state, bool current_plan); virtual bool WillStop (); virtual bool MischiefManaged (); Modified: lldb/trunk/include/lldb/Target/ThreadPlanTestCondition.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/ThreadPlanTestCondition.h?rev=118824&r1=118823&r2=118824&view=diff ============================================================================== --- lldb/trunk/include/lldb/Target/ThreadPlanTestCondition.h (original) +++ lldb/trunk/include/lldb/Target/ThreadPlanTestCondition.h Thu Nov 11 13:26:09 2010 @@ -41,7 +41,7 @@ virtual bool ShouldStop (Event *event_ptr); virtual lldb::Vote ShouldReportStop (Event *event_ptr); virtual bool StopOthers (); - virtual lldb::StateType RunState (); + virtual lldb::StateType GetPlanRunState (); virtual bool WillStop (); virtual bool MischiefManaged (); virtual void DidPush (); Added: lldb/trunk/include/lldb/Target/ThreadPlanTracer.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/ThreadPlanTracer.h?rev=118824&view=auto ============================================================================== --- lldb/trunk/include/lldb/Target/ThreadPlanTracer.h (added) +++ lldb/trunk/include/lldb/Target/ThreadPlanTracer.h Thu Nov 11 13:26:09 2010 @@ -0,0 +1,81 @@ +//===-- ThreadPlanTracer.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_ThreadPlanTracer_h_ +#define liblldb_ThreadPlanTracer_h_ + +// C Includes +// C++ Includes +// Other libraries and framework includes +// Project includes +#include "lldb/lldb-private.h" +#include "lldb/Target/Thread.h" + +namespace lldb_private { + +class ThreadPlanTracer +{ +friend class ThreadPlan; + +public: + ThreadPlanTracer (Thread &thread, lldb::StreamSP &stream_sp); + ThreadPlanTracer (Thread &thread); + + virtual ~ThreadPlanTracer() + { + } + + bool + EnableTracing(bool value) + { + bool old_value = m_enabled; + m_enabled = value; + return old_value; + } + + bool + TracingEnabled() + { + return m_enabled; + } + + bool + EnableSingleStep (bool value) + { + bool old_value = m_single_step; + m_single_step = value; + return old_value; + } + + bool + SingleStepEnabled () + { + return m_single_step; + } + +protected: + Thread &m_thread; + + Stream * + GetLogStream (); + + virtual void Log(); + +private: + bool + TracerExplainsStop (); + + bool m_single_step; + bool m_enabled; + lldb::StreamSP m_stream_sp; +}; + +} // namespace lldb_private + +#endif // liblldb_ThreadPlanTracer_h_ Modified: lldb/trunk/include/lldb/lldb-enumerations.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/lldb-enumerations.h?rev=118824&r1=118823&r2=118824&view=diff ============================================================================== --- lldb/trunk/include/lldb/lldb-enumerations.h (original) +++ lldb/trunk/include/lldb/lldb-enumerations.h Thu Nov 11 13:26:09 2010 @@ -486,7 +486,7 @@ typedef enum SettableVariableType { eSetVarTypeInt, - eSetVarTypeBool, + eSetVarTypeBoolean, eSetVarTypeString, eSetVarTypeArray, eSetVarTypeDictionary, Modified: lldb/trunk/include/lldb/lldb-forward-rtti.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/lldb-forward-rtti.h?rev=118824&r1=118823&r2=118824&view=diff ============================================================================== --- lldb/trunk/include/lldb/lldb-forward-rtti.h (original) +++ lldb/trunk/include/lldb/lldb-forward-rtti.h Thu Nov 11 13:26:09 2010 @@ -61,6 +61,7 @@ typedef SharedPtr::Type TargetSP; typedef SharedPtr::Type ThreadSP; typedef SharedPtr::Type ThreadPlanSP; + typedef SharedPtr::Type ThreadPlanTracerSP; typedef SharedPtr::Type TypeSP; typedef SharedPtr::Type FuncUnwindersSP; typedef SharedPtr::Type UserSettingsControllerSP; Modified: lldb/trunk/include/lldb/lldb-forward.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/lldb-forward.h?rev=118824&r1=118823&r2=118824&view=diff ============================================================================== --- lldb/trunk/include/lldb/lldb-forward.h (original) +++ lldb/trunk/include/lldb/lldb-forward.h Thu Nov 11 13:26:09 2010 @@ -135,6 +135,7 @@ class ThreadPlanStepOverBreakpoint; class ThreadPlanStepRange; class ThreadPlanStepThrough; +class ThreadPlanTracer; class ThreadSpec; class TimeValue; class Type; Modified: lldb/trunk/lldb.xcodeproj/project.pbxproj URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/lldb.xcodeproj/project.pbxproj?rev=118824&r1=118823&r2=118824&view=diff ============================================================================== --- lldb/trunk/lldb.xcodeproj/project.pbxproj (original) +++ lldb/trunk/lldb.xcodeproj/project.pbxproj Thu Nov 11 13:26:09 2010 @@ -344,6 +344,8 @@ 4CB4436C124944B000C13DC2 /* ItaniumABILanguageRuntime.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4CB4436A124944B000C13DC2 /* ItaniumABILanguageRuntime.cpp */; }; 4CB443BE1249920C00C13DC2 /* CPPLanguageRuntime.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4CB443BC1249920C00C13DC2 /* CPPLanguageRuntime.cpp */; }; 4CB443F312499B5000C13DC2 /* ObjCLanguageRuntime.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4CB443F212499B5000C13DC2 /* ObjCLanguageRuntime.cpp */; }; + 4CC2A149128C73ED001531C4 /* ThreadPlanTracer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4CC2A148128C73ED001531C4 /* ThreadPlanTracer.cpp */; }; + 4CC2A14D128C7409001531C4 /* ThreadPlanTracer.h in Headers */ = {isa = PBXBuildFile; fileRef = 4CC2A14C128C7409001531C4 /* ThreadPlanTracer.h */; }; 69A01E211236C5D400C660B5 /* Condition.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 69A01E1B1236C5D400C660B5 /* Condition.cpp */; }; 69A01E221236C5D400C660B5 /* Host.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 69A01E1C1236C5D400C660B5 /* Host.cpp */; }; 69A01E241236C5D400C660B5 /* Mutex.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 69A01E1E1236C5D400C660B5 /* Mutex.cpp */; }; @@ -993,6 +995,8 @@ 4CB443BC1249920C00C13DC2 /* CPPLanguageRuntime.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = CPPLanguageRuntime.cpp; path = source/Target/CPPLanguageRuntime.cpp; sourceTree = ""; }; 4CB443F212499B5000C13DC2 /* ObjCLanguageRuntime.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = ObjCLanguageRuntime.cpp; path = source/Target/ObjCLanguageRuntime.cpp; sourceTree = ""; }; 4CB443F612499B6E00C13DC2 /* ObjCLanguageRuntime.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ObjCLanguageRuntime.h; path = include/lldb/Target/ObjCLanguageRuntime.h; sourceTree = ""; }; + 4CC2A148128C73ED001531C4 /* ThreadPlanTracer.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = ThreadPlanTracer.cpp; path = source/Target/ThreadPlanTracer.cpp; sourceTree = ""; }; + 4CC2A14C128C7409001531C4 /* ThreadPlanTracer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ThreadPlanTracer.h; path = include/lldb/Target/ThreadPlanTracer.h; sourceTree = ""; }; 4CEDAED311754F5E00E875A6 /* ThreadPlanStepUntil.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ThreadPlanStepUntil.h; path = include/lldb/Target/ThreadPlanStepUntil.h; sourceTree = ""; }; 4CEE62FA1145F2130064CF93 /* ProcessGDBRemote.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = ProcessGDBRemote.cpp; path = "source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp"; sourceTree = ""; }; 4CEE62FB1145F2130064CF93 /* ProcessGDBRemote.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ProcessGDBRemote.h; path = "source/Plugins/Process/gdb-remote/ProcessGDBRemote.h"; sourceTree = ""; }; @@ -2073,6 +2077,8 @@ 2660D9FE11922A7F00958FBD /* ThreadPlanStepUntil.cpp */, 4C1AB23E1263E61100D0F04A /* ThreadPlanTestCondition.h */, 4C1AB23A1263E5F400D0F04A /* ThreadPlanTestCondition.cpp */, + 4CC2A14C128C7409001531C4 /* ThreadPlanTracer.h */, + 4CC2A148128C73ED001531C4 /* ThreadPlanTracer.cpp */, 4C08CDEB11C81F1E001610A8 /* ThreadSpec.h */, 4C08CDE711C81EF8001610A8 /* ThreadSpec.cpp */, 4C00986F11500B4300F316B0 /* UnixSignals.h */, @@ -2367,6 +2373,7 @@ 2635DA87127D0D0400675BC1 /* SharingPtr.h in Headers */, 4C61978D12823D4300FAFFCC /* AppleObjCRuntime.h in Headers */, 4C61978F12823D4300FAFFCC /* AppleObjCRuntimeV1.h in Headers */, + 4CC2A14D128C7409001531C4 /* ThreadPlanTracer.h in Headers */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -2438,7 +2445,6 @@ isa = PBXProject; buildConfigurationList = 1DEB91EF08733DB70010E9CD /* Build configuration list for PBXProject "lldb" */; compatibilityVersion = "Xcode 3.1"; - developmentRegion = English; hasScannedForEncodings = 1; knownRegions = ( en, @@ -2869,6 +2875,7 @@ 4C1AB23B1263E5F400D0F04A /* ThreadPlanTestCondition.cpp in Sources */, 4C61978C12823D4300FAFFCC /* AppleObjCRuntime.cpp in Sources */, 4C61978E12823D4300FAFFCC /* AppleObjCRuntimeV1.cpp in Sources */, + 4CC2A149128C73ED001531C4 /* ThreadPlanTracer.cpp in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; Modified: lldb/trunk/source/Core/Debugger.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/Debugger.cpp?rev=118824&r1=118823&r2=118824&view=diff ============================================================================== --- lldb/trunk/source/Core/Debugger.cpp (original) +++ lldb/trunk/source/Core/Debugger.cpp Thu Nov 11 13:26:09 2010 @@ -1681,7 +1681,7 @@ { "script-lang", eSetVarTypeString, "python", NULL, false, false, "The script language to be used for evaluating user-written scripts." }, { "term-width", eSetVarTypeInt, "80" , NULL, false, false, "The maximum number of columns to use for displaying text." }, { "thread-format", eSetVarTypeString, DEFAULT_THREAD_FORMAT, NULL, false, false, "The default thread format string to use when displaying thread information." }, -{ "use-external-editor", eSetVarTypeBool, "false", NULL, false, false, "Whether to use an external editor or not." }, -{ "auto-confirm", eSetVarTypeBool, "false", NULL, false, false, "If true all confirmation prompts will receive their default reply." }, +{ "use-external-editor", eSetVarTypeBoolean, "false", NULL, false, false, "Whether to use an external editor or not." }, +{ "auto-confirm", eSetVarTypeBoolean, "false", NULL, false, false, "If true all confirmation prompts will receive their default reply." }, { NULL, eSetVarTypeNone, NULL, NULL, false, false, NULL } }; Modified: lldb/trunk/source/Core/UserSettingsController.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/UserSettingsController.cpp?rev=118824&r1=118823&r2=118824&view=diff ============================================================================== --- lldb/trunk/source/Core/UserSettingsController.cpp (original) +++ lldb/trunk/source/Core/UserSettingsController.cpp Thu Nov 11 13:26:09 2010 @@ -1010,7 +1010,7 @@ { case lldb::eSetVarTypeInt: return "int"; - case lldb::eSetVarTypeBool: + case lldb::eSetVarTypeBoolean: return "boolean"; case lldb::eSetVarTypeString: return "string"; @@ -1520,7 +1520,7 @@ if (entry == NULL) return 0; - if (entry->var_type == lldb::eSetVarTypeBool) + if (entry->var_type == lldb::eSetVarTypeBoolean) return UserSettingsController::BooleanMatches (partial_value, word_complete, matches); else if (entry->var_type == lldb::eSetVarTypeEnum) return UserSettingsController::EnumMatches (partial_value, entry->enum_values, word_complete, matches); Modified: lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleThreadPlanStepThroughObjCTrampoline.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleThreadPlanStepThroughObjCTrampoline.cpp?rev=118824&r1=118823&r2=118824&view=diff ============================================================================== --- lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleThreadPlanStepThroughObjCTrampoline.cpp (original) +++ lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleThreadPlanStepThroughObjCTrampoline.cpp Thu Nov 11 13:26:09 2010 @@ -94,7 +94,7 @@ } lldb::StateType -AppleThreadPlanStepThroughObjCTrampoline::RunState () +AppleThreadPlanStepThroughObjCTrampoline::GetPlanRunState () { return eStateRunning; } Modified: lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleThreadPlanStepThroughObjCTrampoline.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleThreadPlanStepThroughObjCTrampoline.h?rev=118824&r1=118823&r2=118824&view=diff ============================================================================== --- lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleThreadPlanStepThroughObjCTrampoline.h (original) +++ lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleThreadPlanStepThroughObjCTrampoline.h Thu Nov 11 13:26:09 2010 @@ -50,7 +50,7 @@ virtual lldb::StateType - RunState (); + GetPlanRunState (); virtual bool ShouldStop (Event *event_ptr); Modified: lldb/trunk/source/Target/Process.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/Process.cpp?rev=118824&r1=118823&r2=118824&view=diff ============================================================================== --- lldb/trunk/source/Target/Process.cpp (original) +++ lldb/trunk/source/Target/Process.cpp Thu Nov 11 13:26:09 2010 @@ -2374,7 +2374,7 @@ { "output-path", eSetVarTypeString, "/dev/stdout", NULL, false, false, "The file/path to be used by the executable program for writing its output." }, { "error-path", eSetVarTypeString, "/dev/stderr", NULL, false, false, "The file/path to be used by the executable program for writings its error messages." }, { "plugin", eSetVarTypeEnum, NULL , g_plugins, false, false, "The plugin to be used to run the process." }, - { "disable-aslr", eSetVarTypeBool, "true", NULL, false, false, "Disable Address Space Layout Randomization (ASLR)" }, + { "disable-aslr", eSetVarTypeBoolean, "true", NULL, false, false, "Disable Address Space Layout Randomization (ASLR)" }, { NULL, eSetVarTypeNone, NULL, NULL, 0, 0, NULL } }; Modified: lldb/trunk/source/Target/Thread.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/Thread.cpp?rev=118824&r1=118823&r2=118824&view=diff ============================================================================== --- lldb/trunk/source/Target/Thread.cpp (original) +++ lldb/trunk/source/Target/Thread.cpp Thu Nov 11 13:26:09 2010 @@ -227,6 +227,9 @@ DumpThreadPlans(&s); log->PutCString (s.GetData()); } + + // The top most plan always gets to do the trace log... + current_plan->DoTraceLog (); if (current_plan->PlanExplainsStop()) { @@ -268,6 +271,10 @@ if (over_ride_stop) should_stop = false; } + else if (current_plan->TracerExplainsStop()) + { + return false; + } else { // If the current plan doesn't explain the stop, then, find one that @@ -346,8 +353,11 @@ { if (thread_plan_sp) { + // If the thread plan doesn't already have a tracer, give it its parent's tracer: + if (!thread_plan_sp->GetThreadPlanTracer()) + thread_plan_sp->SetThreadPlanTracer(m_plan_stack.back()->GetThreadPlanTracer()); m_plan_stack.push_back (thread_plan_sp); - + thread_plan_sp->DidPush(); LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_STEP)); @@ -489,6 +499,29 @@ PushPlan (thread_plan_sp); } + +void +Thread::EnableTracer (bool value, bool single_stepping) +{ + int stack_size = m_plan_stack.size(); + for (int i = 0; i < stack_size; i++) + { + if (m_plan_stack[i]->GetThreadPlanTracer()) + { + m_plan_stack[i]->GetThreadPlanTracer()->EnableTracing(value); + m_plan_stack[i]->GetThreadPlanTracer()->EnableSingleStep(single_stepping); + } + } +} + +void +Thread::SetTracer (lldb::ThreadPlanTracerSP &tracer_sp) +{ + int stack_size = m_plan_stack.size(); + for (int i = 0; i < stack_size; i++) + m_plan_stack[i]->SetThreadPlanTracer(tracer_sp); +} + void Thread::DiscardThreadPlansUpToPlan (lldb::ThreadPlanSP &up_to_plan_sp) { @@ -936,6 +969,49 @@ Thread::GetSettingsController()->RenameInstanceSettings (GetInstanceName().AsCString(), sstr.GetData()); } +lldb::StackFrameSP +Thread::GetStackFrameSPForStackFramePtr (StackFrame *stack_frame_ptr) +{ + return GetStackFrameList().GetStackFrameSPForStackFramePtr (stack_frame_ptr); +} + +const char * +Thread::StopReasonAsCString (lldb::StopReason reason) +{ + switch (reason) + { + case eStopReasonInvalid: return "invalid"; + case eStopReasonNone: return "none"; + case eStopReasonTrace: return "trace"; + case eStopReasonBreakpoint: return "breakpoint"; + case eStopReasonWatchpoint: return "watchpoint"; + case eStopReasonSignal: return "signal"; + case eStopReasonException: return "exception"; + case eStopReasonPlanComplete: return "plan complete"; + } + + + static char unknown_state_string[64]; + snprintf(unknown_state_string, sizeof (unknown_state_string), "StopReason = %i", reason); + return unknown_state_string; +} + +const char * +Thread::RunModeAsCString (lldb::RunMode mode) +{ + switch (mode) + { + case eOnlyThisThread: return "only this thread"; + case eAllThreads: return "all threads"; + case eOnlyDuringStepping: return "only during stepping"; + } + + static char unknown_state_string[64]; + snprintf(unknown_state_string, sizeof (unknown_state_string), "RunMode = %i", mode); + return unknown_state_string; +} + +#pragma mark "Thread::ThreadSettingsController" //-------------------------------------------------------------- // class Thread::ThreadSettingsController //-------------------------------------------------------------- @@ -960,13 +1036,15 @@ return new_settings_sp; } +#pragma mark "ThreadInstanceSettings" //-------------------------------------------------------------- // class ThreadInstanceSettings //-------------------------------------------------------------- ThreadInstanceSettings::ThreadInstanceSettings (UserSettingsController &owner, bool live_instance, const char *name) : InstanceSettings (owner, (name == NULL ? InstanceSettings::InvalidName().AsCString() : name), live_instance), - m_avoid_regexp_ap () + m_avoid_regexp_ap (), + m_trace_enabled (false) { // CopyInstanceSettings is a pure virtual function in InstanceSettings; it therefore cannot be called // until the vtables for ThreadInstanceSettings are properly set up, i.e. AFTER all the initializers. @@ -989,7 +1067,8 @@ ThreadInstanceSettings::ThreadInstanceSettings (const ThreadInstanceSettings &rhs) : InstanceSettings (*(Thread::GetSettingsController().get()), CreateInstanceName().AsCString()), - m_avoid_regexp_ap () + m_avoid_regexp_ap (), + m_trace_enabled (rhs.m_trace_enabled) { if (m_instance_name != InstanceSettings::GetDefaultName()) { @@ -1015,7 +1094,7 @@ else m_avoid_regexp_ap.reset(NULL); } - + m_trace_enabled = rhs.m_trace_enabled; return *this; } @@ -1044,6 +1123,26 @@ } } + else if (var_name == GetTraceThreadVarName()) + { + bool success; + bool result = Args::StringToBoolean(value, false, &success); + + if (success) + { + m_trace_enabled = result; + if (!pending) + { + Thread *myself = static_cast (this); + myself->EnableTracer(m_trace_enabled, true); + } + } + else + { + err.SetErrorStringWithFormat ("Bad value \"%s\" for trace-thread, should be Boolean.", value); + } + + } } void @@ -1077,6 +1176,10 @@ } } + else if (var_name == GetTraceThreadVarName()) + { + value.AppendString(m_trace_enabled ? "true" : "false"); + } else { if (err) @@ -1102,9 +1205,17 @@ const ConstString & ThreadInstanceSettings::StepAvoidRegexpVarName () { - static ConstString run_args_var_name ("step-avoid-regexp"); + static ConstString step_avoid_var_name ("step-avoid-regexp"); - return run_args_var_name; + return step_avoid_var_name; +} + +const ConstString & +ThreadInstanceSettings::GetTraceThreadVarName () +{ + static ConstString trace_thread_var_name ("trace-thread"); + + return trace_thread_var_name; } //-------------------------------------------------- @@ -1124,47 +1235,6 @@ { //{ "var-name", var-type, "default", enum-table, init'd, hidden, "help-text"}, { "step-avoid-regexp", eSetVarTypeString, "", NULL, false, false, "A regular expression defining functions step-in won't stop in." }, + { "trace-thread", eSetVarTypeBoolean, "false", NULL, false, false, "If true, this thread will single-step and log execution." }, { NULL, eSetVarTypeNone, NULL, NULL, 0, 0, NULL } }; - -lldb::StackFrameSP -Thread::GetStackFrameSPForStackFramePtr (StackFrame *stack_frame_ptr) -{ - return GetStackFrameList().GetStackFrameSPForStackFramePtr (stack_frame_ptr); -} - -const char * -Thread::StopReasonAsCString (lldb::StopReason reason) -{ - switch (reason) - { - case eStopReasonInvalid: return "invalid"; - case eStopReasonNone: return "none"; - case eStopReasonTrace: return "trace"; - case eStopReasonBreakpoint: return "breakpoint"; - case eStopReasonWatchpoint: return "watchpoint"; - case eStopReasonSignal: return "signal"; - case eStopReasonException: return "exception"; - case eStopReasonPlanComplete: return "plan complete"; - } - - - static char unknown_state_string[64]; - snprintf(unknown_state_string, sizeof (unknown_state_string), "StopReason = %i", reason); - return unknown_state_string; -} - -const char * -Thread::RunModeAsCString (lldb::RunMode mode) -{ - switch (mode) - { - case eOnlyThisThread: return "only this thread"; - case eAllThreads: return "all threads"; - case eOnlyDuringStepping: return "only during stepping"; - } - - static char unknown_state_string[64]; - snprintf(unknown_state_string, sizeof (unknown_state_string), "RunMode = %i", mode); - return unknown_state_string; -} Modified: lldb/trunk/source/Target/ThreadPlan.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/ThreadPlan.cpp?rev=118824&r1=118823&r2=118824&view=diff ============================================================================== --- lldb/trunk/source/Target/ThreadPlan.cpp (original) +++ lldb/trunk/source/Target/ThreadPlan.cpp Thu Nov 11 13:26:09 2010 @@ -13,10 +13,13 @@ // C++ Includes // Other libraries and framework includes // Project includes +#include "lldb/Core/Debugger.h" #include "lldb/Core/Log.h" #include "lldb/Core/State.h" #include "lldb/Target/RegisterContext.h" #include "lldb/Target/Thread.h" +#include "lldb/Target/Process.h" +#include "lldb/Target/Target.h" using namespace lldb; using namespace lldb_private; @@ -208,3 +211,11 @@ return m_okay_to_discard; } +lldb::StateType +ThreadPlan::RunState () +{ + if (m_tracer_sp && m_tracer_sp->TracingEnabled() && m_tracer_sp->SingleStepEnabled()) + return eStateStepping; + else + return GetPlanRunState(); +} Modified: lldb/trunk/source/Target/ThreadPlanBase.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/ThreadPlanBase.cpp?rev=118824&r1=118823&r2=118824&view=diff ============================================================================== --- lldb/trunk/source/Target/ThreadPlanBase.cpp (original) +++ lldb/trunk/source/Target/ThreadPlanBase.cpp Thu Nov 11 13:26:09 2010 @@ -35,7 +35,10 @@ ThreadPlanBase::ThreadPlanBase (Thread &thread) : ThreadPlan(ThreadPlan::eKindBase, "base plan", thread, eVoteYes, eVoteNoOpinion) { - + // Set the tracer to a default tracer. + ThreadPlanTracerSP new_tracer_sp (new ThreadPlanTracer (m_thread)); + new_tracer_sp->EnableTracing (m_thread.GetTraceEnabledState()); + SetThreadPlanTracer(new_tracer_sp); } ThreadPlanBase::~ThreadPlanBase () @@ -58,7 +61,12 @@ bool ThreadPlanBase::PlanExplainsStop () { - return true; + // The base plan should defer to its tracer, since by default it + // always handles the stop. + if (TracerExplainsStop()) + return false; + else + return true; } bool @@ -153,7 +161,7 @@ } StateType -ThreadPlanBase::RunState () +ThreadPlanBase::GetPlanRunState () { return eStateRunning; } Modified: lldb/trunk/source/Target/ThreadPlanCallFunction.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/ThreadPlanCallFunction.cpp?rev=118824&r1=118823&r2=118824&view=diff ============================================================================== --- lldb/trunk/source/Target/ThreadPlanCallFunction.cpp (original) +++ lldb/trunk/source/Target/ThreadPlanCallFunction.cpp Thu Nov 11 13:26:09 2010 @@ -330,7 +330,7 @@ } StateType -ThreadPlanCallFunction::RunState () +ThreadPlanCallFunction::GetPlanRunState () { return eStateRunning; } Modified: lldb/trunk/source/Target/ThreadPlanRunToAddress.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/ThreadPlanRunToAddress.cpp?rev=118824&r1=118823&r2=118824&view=diff ============================================================================== --- lldb/trunk/source/Target/ThreadPlanRunToAddress.cpp (original) +++ lldb/trunk/source/Target/ThreadPlanRunToAddress.cpp Thu Nov 11 13:26:09 2010 @@ -201,7 +201,7 @@ } StateType -ThreadPlanRunToAddress::RunState () +ThreadPlanRunToAddress::GetPlanRunState () { return eStateRunning; } Modified: lldb/trunk/source/Target/ThreadPlanStepInstruction.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/ThreadPlanStepInstruction.cpp?rev=118824&r1=118823&r2=118824&view=diff ============================================================================== --- lldb/trunk/source/Target/ThreadPlanStepInstruction.cpp (original) +++ lldb/trunk/source/Target/ThreadPlanStepInstruction.cpp Thu Nov 11 13:26:09 2010 @@ -162,7 +162,7 @@ } StateType -ThreadPlanStepInstruction::RunState () +ThreadPlanStepInstruction::GetPlanRunState () { return eStateStepping; } Modified: lldb/trunk/source/Target/ThreadPlanStepOut.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/ThreadPlanStepOut.cpp?rev=118824&r1=118823&r2=118824&view=diff ============================================================================== --- lldb/trunk/source/Target/ThreadPlanStepOut.cpp (original) +++ lldb/trunk/source/Target/ThreadPlanStepOut.cpp Thu Nov 11 13:26:09 2010 @@ -161,7 +161,7 @@ } StateType -ThreadPlanStepOut::RunState () +ThreadPlanStepOut::GetPlanRunState () { return eStateRunning; } Modified: lldb/trunk/source/Target/ThreadPlanStepOverBreakpoint.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/ThreadPlanStepOverBreakpoint.cpp?rev=118824&r1=118823&r2=118824&view=diff ============================================================================== --- lldb/trunk/source/Target/ThreadPlanStepOverBreakpoint.cpp (original) +++ lldb/trunk/source/Target/ThreadPlanStepOverBreakpoint.cpp Thu Nov 11 13:26:09 2010 @@ -77,7 +77,7 @@ } StateType -ThreadPlanStepOverBreakpoint::RunState () +ThreadPlanStepOverBreakpoint::GetPlanRunState () { return eStateStepping; } Modified: lldb/trunk/source/Target/ThreadPlanStepRange.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/ThreadPlanStepRange.cpp?rev=118824&r1=118823&r2=118824&view=diff ============================================================================== --- lldb/trunk/source/Target/ThreadPlanStepRange.cpp (original) +++ lldb/trunk/source/Target/ThreadPlanStepRange.cpp Thu Nov 11 13:26:09 2010 @@ -226,7 +226,7 @@ } StateType -ThreadPlanStepRange::RunState () +ThreadPlanStepRange::GetPlanRunState () { return eStateStepping; } Modified: lldb/trunk/source/Target/ThreadPlanStepThrough.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/ThreadPlanStepThrough.cpp?rev=118824&r1=118823&r2=118824&view=diff ============================================================================== --- lldb/trunk/source/Target/ThreadPlanStepThrough.cpp (original) +++ lldb/trunk/source/Target/ThreadPlanStepThrough.cpp Thu Nov 11 13:26:09 2010 @@ -82,7 +82,7 @@ } StateType -ThreadPlanStepThrough::RunState () +ThreadPlanStepThrough::GetPlanRunState () { return eStateStepping; } Modified: lldb/trunk/source/Target/ThreadPlanStepUntil.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/ThreadPlanStepUntil.cpp?rev=118824&r1=118823&r2=118824&view=diff ============================================================================== --- lldb/trunk/source/Target/ThreadPlanStepUntil.cpp (original) +++ lldb/trunk/source/Target/ThreadPlanStepUntil.cpp Thu Nov 11 13:26:09 2010 @@ -290,7 +290,7 @@ } StateType -ThreadPlanStepUntil::RunState () +ThreadPlanStepUntil::GetPlanRunState () { return eStateRunning; } Modified: lldb/trunk/source/Target/ThreadPlanTestCondition.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/ThreadPlanTestCondition.cpp?rev=118824&r1=118823&r2=118824&view=diff ============================================================================== --- lldb/trunk/source/Target/ThreadPlanTestCondition.cpp (original) +++ lldb/trunk/source/Target/ThreadPlanTestCondition.cpp Thu Nov 11 13:26:09 2010 @@ -168,7 +168,7 @@ } StateType -ThreadPlanTestCondition::RunState () +ThreadPlanTestCondition::GetPlanRunState () { return eStateRunning; } Added: lldb/trunk/source/Target/ThreadPlanTracer.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/ThreadPlanTracer.cpp?rev=118824&view=auto ============================================================================== --- lldb/trunk/source/Target/ThreadPlanTracer.cpp (added) +++ lldb/trunk/source/Target/ThreadPlanTracer.cpp Thu Nov 11 13:26:09 2010 @@ -0,0 +1,77 @@ +//===-- ThreadPlan.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/Target/ThreadPlan.h" + +// C Includes +// C++ Includes +// Other libraries and framework includes +// Project includes +#include "lldb/Core/Debugger.h" +#include "lldb/Core/Log.h" +#include "lldb/Core/State.h" +#include "lldb/Target/RegisterContext.h" +#include "lldb/Target/Thread.h" +#include "lldb/Target/Process.h" +#include "lldb/Target/Target.h" + +using namespace lldb; +using namespace lldb_private; + +ThreadPlanTracer::ThreadPlanTracer (Thread &thread, lldb::StreamSP &stream_sp) : + m_single_step(true), + m_enabled (false), + m_thread (thread), + m_stream_sp (stream_sp) +{ +} + +ThreadPlanTracer::ThreadPlanTracer (Thread &thread) : + m_single_step(true), + m_enabled (false), + m_thread (thread), + m_stream_sp () +{ +} + +Stream * +ThreadPlanTracer::GetLogStream () +{ + + if (m_stream_sp.get()) + return m_stream_sp.get(); + else + return &(m_thread.GetProcess().GetTarget().GetDebugger().GetOutputStream()); +} + +void +ThreadPlanTracer::Log() +{ + SymbolContext sc; + bool show_frame_index = false; + bool show_fullpaths = false; + + m_thread.GetStackFrameAtIndex(0)->Dump (GetLogStream(), show_frame_index, show_fullpaths); + GetLogStream()->Printf("\n"); +} + +bool +ThreadPlanTracer::TracerExplainsStop () +{ + if (m_enabled && m_single_step) + { + lldb::StopInfoSP stop_info = m_thread.GetStopInfo(); + if (stop_info->GetStopReason() == eStopReasonTrace) + return true; + else + return false; + } + else + return false; +} From gclayton at apple.com Thu Nov 11 14:13:30 2010 From: gclayton at apple.com (Greg Clayton) Date: Thu, 11 Nov 2010 20:13:30 -0000 Subject: [Lldb-commits] [lldb] r118830 - /lldb/trunk/source/Symbol/Function.cpp Message-ID: <20101111201330.653A72A6C12C@llvm.org> Author: gclayton Date: Thu Nov 11 14:13:30 2010 New Revision: 118830 URL: http://llvm.org/viewvc/llvm-project?rev=118830&view=rev Log: Fixed an issue with Function::GetPrologueByteSize() where if a function's first line table entry didn't have the same address as the start address of the function itself, we could end up returning and incorrect value. Modified: lldb/trunk/source/Symbol/Function.cpp Modified: lldb/trunk/source/Symbol/Function.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/Function.cpp?rev=118830&r1=118829&r2=118830&view=diff ============================================================================== --- lldb/trunk/source/Symbol/Function.cpp (original) +++ lldb/trunk/source/Symbol/Function.cpp Thu Nov 11 14:13:30 2010 @@ -500,7 +500,16 @@ { LineEntry line_entry; if (line_table->FindLineEntryByAddress(GetAddressRange().GetBaseAddress(), line_entry)) - m_prologue_byte_size = line_entry.range.GetByteSize(); + { + // We need to take the delta of the end of the first line entry + // as a file address and the start file address of the function + // in case the first line entry doesn't start at the beginning + // of the function. + const addr_t func_start_file_addr = m_range.GetBaseAddress().GetFileAddress(); + const addr_t line_entry_end_file_addr = line_entry.range.GetBaseAddress().GetFileAddress() + line_entry.range.GetByteSize(); + if (line_entry_end_file_addr > func_start_file_addr) + m_prologue_byte_size = line_entry_end_file_addr - func_start_file_addr; + } } } return m_prologue_byte_size; From johnny.chen at apple.com Thu Nov 11 14:18:36 2010 From: johnny.chen at apple.com (Johnny Chen) Date: Thu, 11 Nov 2010 20:18:36 -0000 Subject: [Lldb-commits] [lldb] r118832 - in /lldb/trunk/test/threads: TestPrintStackTraces.py main.cpp Message-ID: <20101111201836.532962A6C12C@llvm.org> Author: johnny Date: Thu Nov 11 14:18:36 2010 New Revision: 118832 URL: http://llvm.org/viewvc/llvm-project?rev=118832&view=rev Log: Fixed compilation warnings emitted by clang. Plus make finding the break line number in main.cpp more robust. Modified: lldb/trunk/test/threads/TestPrintStackTraces.py lldb/trunk/test/threads/main.cpp Modified: lldb/trunk/test/threads/TestPrintStackTraces.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/threads/TestPrintStackTraces.py?rev=118832&r1=118831&r2=118832&view=diff ============================================================================== --- lldb/trunk/test/threads/TestPrintStackTraces.py (original) +++ lldb/trunk/test/threads/TestPrintStackTraces.py Thu Nov 11 14:18:36 2010 @@ -12,6 +12,12 @@ mydir = "threads" + def setUp(self): + # Call super's setUp(). + TestBase.setUp(self) + # Find the line number to break inside main(). + self.line = line_number('main.cpp', '// Set break point at this line.') + def test_stack_traces(self): """Test SBprocess and SBThread APIs with printing of the stack traces.""" self.buildDefault() @@ -24,7 +30,7 @@ target = self.dbg.CreateTarget(exe) self.assertTrue(target.IsValid(), VALID_TARGET) - breakpoint = target.BreakpointCreateByLocation("main.cpp", 68) + breakpoint = target.BreakpointCreateByLocation("main.cpp", self.line) self.assertTrue(breakpoint.IsValid(), VALID_BREAKPOINT) # Now launch the process, and do not stop at entry point. Modified: lldb/trunk/test/threads/main.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/threads/main.cpp?rev=118832&r1=118831&r2=118832&view=diff ============================================================================== --- lldb/trunk/test/threads/main.cpp (original) +++ lldb/trunk/test/threads/main.cpp Thu Nov 11 14:18:36 2010 @@ -14,8 +14,6 @@ #include #include -using namespace std; - pthread_t g_thread_1 = NULL; pthread_t g_thread_2 = NULL; pthread_t g_thread_3 = NULL; @@ -65,10 +63,10 @@ long usec = ::random() % 3000000; printf ("%s (thread = %u) doing a usleep (%li)...\n", __FUNCTION__, thread_index, usec); ::usleep (usec); - printf ("%s (thread = %u) after usleep ...\n", __FUNCTION__, thread_index); + printf ("%s (thread = %u) after usleep ...\n", __FUNCTION__, thread_index); // Set break point at this line. } printf ("%s (thread index = %u) exiting...\n", __FUNCTION__, thread_index); - + return NULL; } From johnny.chen at apple.com Thu Nov 11 15:22:12 2010 From: johnny.chen at apple.com (Johnny Chen) Date: Thu, 11 Nov 2010 21:22:12 -0000 Subject: [Lldb-commits] [lldb] r118839 - /lldb/trunk/test/signal/main.c Message-ID: <20101111212212.5995D2A6C12C@llvm.org> Author: johnny Date: Thu Nov 11 15:22:12 2010 New Revision: 118839 URL: http://llvm.org/viewvc/llvm-project?rev=118839&view=rev Log: Make clang happy. Modified: lldb/trunk/test/signal/main.c Modified: lldb/trunk/test/signal/main.c URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/signal/main.c?rev=118839&r1=118838&r2=118839&view=diff ============================================================================== --- lldb/trunk/test/signal/main.c (original) +++ lldb/trunk/test/signal/main.c Thu Nov 11 15:22:12 2010 @@ -1,4 +1,6 @@ #include +#include +#include void handler_usr1 (int i) { @@ -10,7 +12,7 @@ puts ("got signal ALRM"); } -main () +int main () { int i = 0; From johnny.chen at apple.com Thu Nov 11 16:14:56 2010 From: johnny.chen at apple.com (Johnny Chen) Date: Thu, 11 Nov 2010 22:14:56 -0000 Subject: [Lldb-commits] [lldb] r118847 - /lldb/trunk/test/dotest.py Message-ID: <20101111221456.961A12A6C12C@llvm.org> Author: johnny Date: Thu Nov 11 16:14:56 2010 New Revision: 118847 URL: http://llvm.org/viewvc/llvm-project?rev=118847&view=rev Log: Add help message for the scenario of using lldb.py module distributed by Xcode4 to invoke the test driver. Modified: lldb/trunk/test/dotest.py Modified: lldb/trunk/test/dotest.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/dotest.py?rev=118847&r1=118846&r2=118847&view=diff ============================================================================== --- lldb/trunk/test/dotest.py (original) +++ lldb/trunk/test/dotest.py Thu Nov 11 16:14:56 2010 @@ -169,7 +169,33 @@ Running of this script also sets up the LLDB_TEST environment variable so that individual test cases can locate their supporting files correctly. The script tries to set up Python's search paths for modules by looking at the build tree -relative to this script. See also the '-i' option. +relative to this script. See also the '-i' option in the following example. + +Finally, this is an example of using the lldb.py module distributed/installed by +Xcode4 to run against the tests under the 'forward' directory, and with the '-w' +option to add some delay between two tests. It uses ARCH=x86_64 to specify that +as the architecture and CC=clang to specify the compiler used for the test run: + +$ PYTHONPATH=/Xcode4/Library/PrivateFrameworks/LLDB.framework/Versions/A/Resources/Python ARCH=x86_64 CC=clang ./dotest.py -v -w -i forward + +Session logs for test failures/errors will go into directory '2010-11-11-13_56_16' +---------------------------------------------------------------------- +Collected 2 tests + +test_with_dsym_and_run_command (TestForwardDeclaration.ForwardDeclarationTestCase) +Display *bar_ptr when stopped on a function with forward declaration of struct bar. ... ok +test_with_dwarf_and_run_command (TestForwardDeclaration.ForwardDeclarationTestCase) +Display *bar_ptr when stopped on a function with forward declaration of struct bar. ... ok + +---------------------------------------------------------------------- +Ran 2 tests in 5.659s + +OK + +The 'Session ...' verbiage is recently introduced (see also the '-s' option) to +notify the directory containing the session logs for test failures or errors. +In case there is any test failure/error, a similar message is appended at the +end of the stderr output for your convenience. Environment variables related to loggings: From johnny.chen at apple.com Thu Nov 11 16:58:37 2010 From: johnny.chen at apple.com (Johnny Chen) Date: Thu, 11 Nov 2010 22:58:37 -0000 Subject: [Lldb-commits] [lldb] r118851 - /lldb/trunk/test/namespace/Makefile Message-ID: <20101111225837.766DD2A6C12C@llvm.org> Author: johnny Date: Thu Nov 11 16:58:37 2010 New Revision: 118851 URL: http://llvm.org/viewvc/llvm-project?rev=118851&view=rev Log: Simplify Makefile. Modified: lldb/trunk/test/namespace/Makefile Modified: lldb/trunk/test/namespace/Makefile URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/namespace/Makefile?rev=118851&r1=118850&r2=118851&view=diff ============================================================================== --- lldb/trunk/test/namespace/Makefile (original) +++ lldb/trunk/test/namespace/Makefile Thu Nov 11 16:58:37 2010 @@ -1,125 +1,5 @@ -#---------------------------------------------------------------------- -# Fill in the source files to build -#---------------------------------------------------------------------- -C_SOURCES := -CXX_SOURCES :=main.cpp -OBJC_SOURCES := -OBJCXX_SOURCES := - -# Uncomment line below for debugging shell commands -# SHELL = /bin/sh -x - -#---------------------------------------------------------------------- -# Change any build/tool options needed -#---------------------------------------------------------------------- -DS := /usr/bin/dsymutil -DSFLAGS = -CFLAGS ?=-arch x86_64 -gdwarf-2 -O0 -CPLUSPLUSFLAGS +=$(CFLAGS) -CPPFLAGS +=$(CFLAGS) -LD = gcc -LDFLAGS = $(CFLAGS) -OBJECTS = -EXE=a.out -DSYM=$(EXE).dSYM - -#---------------------------------------------------------------------- -# Check if we have any C source files -#---------------------------------------------------------------------- -ifneq "$(strip $(C_SOURCES))" "" - OBJECTS +=$(strip $(C_SOURCES:.c=.o)) -endif - -#---------------------------------------------------------------------- -# Check if we have any C++ source files -#---------------------------------------------------------------------- -ifneq "$(strip $(CXX_SOURCES))" "" - OBJECTS +=$(strip $(CXX_SOURCES:.cpp=.o)) - LD = g++ -endif - -#---------------------------------------------------------------------- -# Check if we have any ObjC source files -#---------------------------------------------------------------------- -ifneq "$(strip $(OBJC_SOURCES))" "" - OBJECTS +=$(strip $(OBJC_SOURCES:.m=.o)) - LDFLAGS +=-lobjc -endif - -#---------------------------------------------------------------------- -# Check if we have any ObjC++ source files -#---------------------------------------------------------------------- -ifneq "$(strip $(OBJCXX_SOURCES))" "" - OBJECTS +=$(strip $(OBJCXX_SOURCES:.mm=.o)) - LD = g++ - ifeq $(findstring lobjc,$(LDFLAGS)) "" - LDFLAGS +=-lobjc - endif -endif - - -#---------------------------------------------------------------------- -# Make the dSYM file from the executable -#---------------------------------------------------------------------- -$(DSYM) : $(EXE) - $(DS) $(DSFLAGS) -o "$(DSYM)" "$(EXE)" - -#---------------------------------------------------------------------- -# Compile the executable from all the objects (default rule) with no -# dsym file. -#---------------------------------------------------------------------- -$(EXE) : $(OBJECTS) - $(LD) $(LDFLAGS) $(OBJECTS) -o "$(EXE)" - - -#---------------------------------------------------------------------- -# Automatic variables based on items already entered. Below we create -# an objects lists from the list of sources by replacing all entries -# that end with .c with .o, and we also create a list of prerequisite -# files by replacing all .c files with .d. -#---------------------------------------------------------------------- -PREREQS := $(OBJECTS:.o=.d) - -#---------------------------------------------------------------------- -# Rule for Generating Prerequisites Automatically using .d files and -# the compiler -MM option. The -M option will list all system headers, -# and the -MM option will list all non-system dependencies. -#---------------------------------------------------------------------- -%.d: %.c - @set -e; rm -f $@; \ - $(CC) -M $(CPPFLAGS) $< > $@.$$$$; \ - sed 's,\($*\)\.o[ :]*,\1.o $@ : ,g' < $@.$$$$ > $@; \ - rm -f $@.$$$$ - -%.d: %.cpp - @set -e; rm -f $@; \ - $(CC) -M $(CPPFLAGS) $< > $@.$$$$; \ - sed 's,\($*\)\.o[ :]*,\1.o $@ : ,g' < $@.$$$$ > $@; \ - rm -f $@.$$$$ - -%.d: %.m - @set -e; rm -f $@; \ - $(CC) -M $(CPPFLAGS) $< > $@.$$$$; \ - sed 's,\($*\)\.o[ :]*,\1.o $@ : ,g' < $@.$$$$ > $@; \ - rm -f $@.$$$$ - -%.d: %.mm - @set -e; rm -f $@; \ - $(CC) -M $(CPPFLAGS) $< > $@.$$$$; \ - sed 's,\($*\)\.o[ :]*,\1.o $@ : ,g' < $@.$$$$ > $@; \ - rm -f $@.$$$$ - -#---------------------------------------------------------------------- -# Include all of the makefiles for each source file so we don't have -# to manually track all of the prerequisites for each source file. -#---------------------------------------------------------------------- -sinclude $(PREREQS) - -.PHONY: clean -dsym: $(DSYM) -all: $(EXE) $(DSYM) -clean: - rm -rf "$(EXE)" "$(DSYM)" $(OBJECTS) $(PREREQS) - +LEVEL = ../make +CXX_SOURCES := main.cpp +include $(LEVEL)/Makefile.rules From johnny.chen at apple.com Thu Nov 11 17:29:55 2010 From: johnny.chen at apple.com (Johnny Chen) Date: Thu, 11 Nov 2010 23:29:55 -0000 Subject: [Lldb-commits] [lldb] r118856 - in /lldb/trunk/test/namespace: TestNamespace.py main.cpp Message-ID: <20101111232955.198872A6C12C@llvm.org> Author: johnny Date: Thu Nov 11 17:29:54 2010 New Revision: 118856 URL: http://llvm.org/viewvc/llvm-project?rev=118856&view=rev Log: Add TestNamespace.py to exercise printing of anonymous and named namespace variables. Added: lldb/trunk/test/namespace/TestNamespace.py Modified: lldb/trunk/test/namespace/main.cpp Added: lldb/trunk/test/namespace/TestNamespace.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/namespace/TestNamespace.py?rev=118856&view=auto ============================================================================== --- lldb/trunk/test/namespace/TestNamespace.py (added) +++ lldb/trunk/test/namespace/TestNamespace.py Thu Nov 11 17:29:54 2010 @@ -0,0 +1,66 @@ +""" +Test the printing of anonymous and named namespace variables. +""" + +import os, time +import unittest2 +import lldb +from lldbtest import * + +class NamespaceTestCase(TestBase): + + mydir = "namespace" + + @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin") + def test_with_dsym_and_run_command(self): + """Test that anonymous and named namespace variables display correctly.""" + self.buildDsym() + self.namespace_variable_commands() + + def test_with_dwarf_and_run_command(self): + """Test that anonymous and named namespace variables display correctly.""" + self.buildDwarf() + self.namespace_variable_commands() + + def setUp(self): + # Call super's setUp(). + TestBase.setUp(self) + # Find the line numbers for declarations of namespace variables i and j. + self.line_var_i = line_number('main.cpp', + '// Find the line number for anonymous namespace variable i.') + self.line_var_j = line_number('main.cpp', + '// Find the line number for named namespace variable j.') + # And the line number to break at. + self.line_break = line_number('main.cpp', + '// Set break point at this line.') + + def namespace_variable_commands(self): + """Test that anonymous and named namespace variables display correctly.""" + self.runCmd("file a.out", CURRENT_EXECUTABLE_SET) + + self.expect("breakpoint set -f main.cpp -l %d" % self.line_break, + BREAKPOINT_CREATED, + startstr = "Breakpoint created: 1: file ='main.cpp', line = %d, locations = 1" % + self.line_break) + + self.runCmd("run", RUN_SUCCEEDED) + + # The stop reason of the thread should be breakpoint. + self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT, + substrs = ['state is stopped', + 'stop reason = breakpoint']) + + self.expect("frame variable -c -G i", + startstr = "main.cpp:%d: (int) (anonymous namespace)::i = 3" % self.line_var_i) + # main.cpp:12: (int) (anonymous namespace)::i = 3 + + self.expect("frame variable -c -G j", + startstr = "main.cpp:%d: (int) A::B::j = 4" % self.line_var_j) + # main.cpp:19: (int) A::B::j = 4 + + +if __name__ == '__main__': + import atexit + lldb.SBDebugger.Initialize() + atexit.register(lambda: lldb.SBDebugger.Terminate()) + unittest2.main() Modified: lldb/trunk/test/namespace/main.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/namespace/main.cpp?rev=118856&r1=118855&r2=118856&view=diff ============================================================================== --- lldb/trunk/test/namespace/main.cpp (original) +++ lldb/trunk/test/namespace/main.cpp Thu Nov 11 17:29:54 2010 @@ -9,14 +9,14 @@ namespace { typedef unsigned int uint_t; - int i; + int i; // Find the line number for anonymous namespace variable i. } namespace A { typedef unsigned int uint_t; namespace B { typedef unsigned int uint_t; - int j; + int j; // Find the line number for named namespace variable j. int myfunc (int a); int myfunc2(int a) { @@ -59,7 +59,7 @@ Y::uint_t y_uint = 3; i = 3; j = 4; - return myfunc2(3) + j + i + a + 2 + anon_uint + a_uint + b_uint + y_uint; + return myfunc2(3) + j + i + a + 2 + anon_uint + a_uint + b_uint + y_uint; // Set break point at this line. } int From johnny.chen at apple.com Thu Nov 11 17:54:12 2010 From: johnny.chen at apple.com (Johnny Chen) Date: Thu, 11 Nov 2010 23:54:12 -0000 Subject: [Lldb-commits] [lldb] r118860 - in /lldb/trunk/test: lldbtest.py plugins/darwin.py Message-ID: <20101111235412.93B2F2A6C12C@llvm.org> Author: johnny Date: Thu Nov 11 17:54:12 2010 New Revision: 118860 URL: http://llvm.org/viewvc/llvm-project?rev=118860&view=rev Log: The session log entry containing the command to rerun the same test now also includes the architecture and compiler specs. Modified: lldb/trunk/test/lldbtest.py lldb/trunk/test/plugins/darwin.py Modified: lldb/trunk/test/lldbtest.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/lldbtest.py?rev=118860&r1=118859&r2=118860&view=diff ============================================================================== --- lldb/trunk/test/lldbtest.py (original) +++ lldb/trunk/test/lldbtest.py Thu Nov 11 17:54:12 2010 @@ -576,8 +576,9 @@ print >> f, "Session info generated @", datetime.datetime.now().ctime() print >> f, self.session.getvalue() print >> f, "To rerun this test, issue the following command from the 'test' directory:\n" - print >> f, "./dotest.py -v -t -f %s.%s" % (self.__class__.__name__, - self._testMethodName) + print >> f, "%s ./dotest.py -v -t -f %s.%s" % (self.getRunSpec(), + self.__class__.__name__, + self._testMethodName) def setTearDownCleanup(self, dictionary=None): """Register a cleanup action at tearDown() time with a dictinary""" @@ -807,6 +808,12 @@ # End of while loop. + def getRunSpec(self): + """Environment variable spec to run this test again, invoked from within + dumpSessionInfo().""" + module = __import__(sys.platform) + return module.getRunSpec() + def buildDefault(self, architecture=None, compiler=None, dictionary=None): """Platform specific way to build the default binaries.""" module = __import__(sys.platform) Modified: lldb/trunk/test/plugins/darwin.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/plugins/darwin.py?rev=118860&r1=118859&r2=118860&view=diff ============================================================================== --- lldb/trunk/test/plugins/darwin.py (original) +++ lldb/trunk/test/plugins/darwin.py Thu Nov 11 17:54:12 2010 @@ -17,6 +17,11 @@ #print "Hello, darwin plugin!" +def getRunSpec(): + """Environment variable spec to run this test again, invoked from within + dumpSessionInfo().""" + return "%s%s" % (getArchSpec(None), getCCSpec(None)) + def getArchSpec(architecture): """ Helper function to return the key-value string to specify the architecture From johnny.chen at apple.com Thu Nov 11 18:00:15 2010 From: johnny.chen at apple.com (Johnny Chen) Date: Fri, 12 Nov 2010 00:00:15 -0000 Subject: [Lldb-commits] [lldb] r118861 - /lldb/trunk/test/namespace/TestNamespace.py Message-ID: <20101112000015.A836D2A6C12C@llvm.org> Author: johnny Date: Thu Nov 11 18:00:15 2010 New Revision: 118861 URL: http://llvm.org/viewvc/llvm-project?rev=118861&view=rev Log: Add @expectedFailure decorator for test_with_dwarf_and_run_command() test method: rdar://problem/8659840 test failure: ./dotest.py -v -t -f NamespaceTestCase.test_with_dwarf_and_run_command Modified: lldb/trunk/test/namespace/TestNamespace.py Modified: lldb/trunk/test/namespace/TestNamespace.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/namespace/TestNamespace.py?rev=118861&r1=118860&r2=118861&view=diff ============================================================================== --- lldb/trunk/test/namespace/TestNamespace.py (original) +++ lldb/trunk/test/namespace/TestNamespace.py Thu Nov 11 18:00:15 2010 @@ -17,6 +17,7 @@ self.buildDsym() self.namespace_variable_commands() + @unittest2.expectedFailre("rdar://problem/8659840") def test_with_dwarf_and_run_command(self): """Test that anonymous and named namespace variables display correctly.""" self.buildDwarf() From gclayton at apple.com Thu Nov 11 18:49:23 2010 From: gclayton at apple.com (Greg Clayton) Date: Fri, 12 Nov 2010 00:49:23 -0000 Subject: [Lldb-commits] [lldb] r118866 - in /lldb/trunk/tools/debugserver/source/MacOSX: MachThread.cpp MachThread.h MachThreadList.cpp Message-ID: <20101112004923.EF5C52A6C12C@llvm.org> Author: gclayton Date: Thu Nov 11 18:49:23 2010 New Revision: 118866 URL: http://llvm.org/viewvc/llvm-project?rev=118866&view=rev Log: Fixed an issue with the MachThread class where we might not get the initial thread basic info state and not realize that a thread was already suspended or if a thread was starting up and not ready to be displayed to the user (in an uninterruptable state). If it is not user ready yet, we don't add it to our list of threads that can be played with. Modified: lldb/trunk/tools/debugserver/source/MacOSX/MachThread.cpp lldb/trunk/tools/debugserver/source/MacOSX/MachThread.h lldb/trunk/tools/debugserver/source/MacOSX/MachThreadList.cpp Modified: lldb/trunk/tools/debugserver/source/MacOSX/MachThread.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/debugserver/source/MacOSX/MachThread.cpp?rev=118866&r1=118865&r2=118866&view=diff ============================================================================== --- lldb/trunk/tools/debugserver/source/MacOSX/MachThread.cpp (original) +++ lldb/trunk/tools/debugserver/source/MacOSX/MachThread.cpp Thu Nov 11 18:49:23 2010 @@ -39,7 +39,10 @@ if (num_reg_sets > 0) m_regSets.assign(regSetInfo, regSetInfo + num_reg_sets); - ::memset (&m_basicInfo, 0, sizeof (m_basicInfo)); + // Get the thread state so we know if a thread is in a state where we can't + // muck with it and also so we get the suspend count correct in case it was + // already suspended + GetBasicInfo(); DNBLogThreadedIf(LOG_THREAD | LOG_VERBOSE, "MachThread::MachThread ( process = %p, tid = 0x%4.4x, seq_id = %u )", &m_process, m_tid, m_seq_id); } @@ -189,6 +192,36 @@ } bool +MachThread::IsUserReady() +{ + if (m_basicInfo.run_state == 0) + GetBasicInfo (); + + switch (m_basicInfo.run_state) + { + default: + case TH_STATE_UNINTERRUPTIBLE: + break; + + case TH_STATE_RUNNING: + case TH_STATE_STOPPED: + case TH_STATE_WAITING: + case TH_STATE_HALTED: + return true; + } + return false; +} + +struct thread_basic_info * +MachThread::GetBasicInfo () +{ + if (MachThread::GetBasicInfo(m_tid, &m_basicInfo)) + return &m_basicInfo; + return NULL; +} + + +bool MachThread::GetBasicInfo(thread_t thread, struct thread_basic_info *basicInfoPtr) { if (ThreadIDIsValid(thread)) Modified: lldb/trunk/tools/debugserver/source/MacOSX/MachThread.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/debugserver/source/MacOSX/MachThread.h?rev=118866&r1=118865&r2=118866&view=diff ============================================================================== --- lldb/trunk/tools/debugserver/source/MacOSX/MachThread.h (original) +++ lldb/trunk/tools/debugserver/source/MacOSX/MachThread.h Thu Nov 11 18:49:23 2010 @@ -89,6 +89,10 @@ nub_size_t GetRegisterContext (void *buf, nub_size_t buf_len); nub_size_t SetRegisterContext (const void *buf, nub_size_t buf_len); void NotifyBreakpointChanged (const DNBBreakpoint *bp); + + bool IsUserReady(); + struct thread_basic_info * + GetBasicInfo (); const char * GetBasicInfoAsString () const; const char * GetName (); protected: Modified: lldb/trunk/tools/debugserver/source/MacOSX/MachThreadList.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/debugserver/source/MacOSX/MachThreadList.cpp?rev=118866&r1=118865&r2=118866&view=diff ============================================================================== --- lldb/trunk/tools/debugserver/source/MacOSX/MachThreadList.cpp (original) +++ lldb/trunk/tools/debugserver/source/MacOSX/MachThreadList.cpp Thu Nov 11 18:49:23 2010 @@ -237,7 +237,10 @@ { // We don't have this thread, lets add it. MachThreadSP threadSP(new MachThread(process, thread_list[idx])); - currThreads.push_back(threadSP); + // Make sure the thread is ready to be displayed and shown to users + // before we add this thread to our list... + if (threadSP->IsUserReady()) + currThreads.push_back(threadSP); } } From johnny.chen at apple.com Thu Nov 11 18:50:46 2010 From: johnny.chen at apple.com (Johnny Chen) Date: Fri, 12 Nov 2010 00:50:46 -0000 Subject: [Lldb-commits] [lldb] r118867 - /lldb/trunk/test/namespace/TestNamespace.py Message-ID: <20101112005046.1B24D2A6C12C@llvm.org> Author: johnny Date: Thu Nov 11 18:50:45 2010 New Revision: 118867 URL: http://llvm.org/viewvc/llvm-project?rev=118867&view=rev Log: Fix the @expectedFailure usage error and add a commented out section of code to exercise 'expression' command on namespaced variables. Modified: lldb/trunk/test/namespace/TestNamespace.py Modified: lldb/trunk/test/namespace/TestNamespace.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/namespace/TestNamespace.py?rev=118867&r1=118866&r2=118867&view=diff ============================================================================== --- lldb/trunk/test/namespace/TestNamespace.py (original) +++ lldb/trunk/test/namespace/TestNamespace.py Thu Nov 11 18:50:45 2010 @@ -17,7 +17,8 @@ self.buildDsym() self.namespace_variable_commands() - @unittest2.expectedFailre("rdar://problem/8659840") + @unittest2.expectedFailure + # rdar://problem/8659840 def test_with_dwarf_and_run_command(self): """Test that anonymous and named namespace variables display correctly.""" self.buildDwarf() @@ -59,6 +60,9 @@ startstr = "main.cpp:%d: (int) A::B::j = 4" % self.line_var_j) # main.cpp:19: (int) A::B::j = 4 + #self.expect("expression -- i + j", + # startstr = "(int) $0 = 7") + # (int) $0 = 7 if __name__ == '__main__': import atexit From johnny.chen at apple.com Thu Nov 11 18:55:31 2010 From: johnny.chen at apple.com (Johnny Chen) Date: Fri, 12 Nov 2010 00:55:31 -0000 Subject: [Lldb-commits] [lldb] r118868 - /lldb/trunk/test/foundation/TestObjCMethods.py Message-ID: <20101112005531.7546F2A6C12C@llvm.org> Author: johnny Date: Thu Nov 11 18:55:31 2010 New Revision: 118868 URL: http://llvm.org/viewvc/llvm-project?rev=118868&view=rev Log: Run commands 'expression self->str' and 'expression self->date'. They should not fail. Modified: lldb/trunk/test/foundation/TestObjCMethods.py Modified: lldb/trunk/test/foundation/TestObjCMethods.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/foundation/TestObjCMethods.py?rev=118868&r1=118867&r2=118868&view=diff ============================================================================== --- lldb/trunk/test/foundation/TestObjCMethods.py (original) +++ lldb/trunk/test/foundation/TestObjCMethods.py Thu Nov 11 18:55:31 2010 @@ -148,12 +148,9 @@ COMMAND_FAILED_AS_EXPECTED, error=True, startstr = "error: 'MyString' does not have a member named 'non_existent_member'") - # This currently fails. - # rdar://problem/8492646 - # # Use expression parser. - #self.runCmd("expression self->str") - #self.runCmd("expression self->date") + self.runCmd("expression self->str") + self.runCmd("expression self->date") # (lldb) expression self->str # error: instance variable 'str' is protected From johnny.chen at apple.com Thu Nov 11 19:00:56 2010 From: johnny.chen at apple.com (Johnny Chen) Date: Fri, 12 Nov 2010 01:00:56 -0000 Subject: [Lldb-commits] [lldb] r118869 - /lldb/trunk/test/namespace/TestNamespace.py Message-ID: <20101112010056.2A8172A6C12C@llvm.org> Author: johnny Date: Thu Nov 11 19:00:56 2010 New Revision: 118869 URL: http://llvm.org/viewvc/llvm-project?rev=118869&view=rev Log: Add information for two bugs exposed by this test file. Modified: lldb/trunk/test/namespace/TestNamespace.py Modified: lldb/trunk/test/namespace/TestNamespace.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/namespace/TestNamespace.py?rev=118869&r1=118868&r2=118869&view=diff ============================================================================== --- lldb/trunk/test/namespace/TestNamespace.py (original) +++ lldb/trunk/test/namespace/TestNamespace.py Thu Nov 11 19:00:56 2010 @@ -19,6 +19,9 @@ @unittest2.expectedFailure # rdar://problem/8659840 + # runCmd: frame variable -c -G i + # runCmd failed! + # error: can't find global variable 'i' def test_with_dwarf_and_run_command(self): """Test that anonymous and named namespace variables display correctly.""" self.buildDwarf() @@ -60,6 +63,8 @@ startstr = "main.cpp:%d: (int) A::B::j = 4" % self.line_var_j) # main.cpp:19: (int) A::B::j = 4 + # rdar://problem/8660275 + # test/namespace: 'expression -- i+j' not working #self.expect("expression -- i + j", # startstr = "(int) $0 = 7") # (int) $0 = 7 From scallanan at apple.com Thu Nov 11 19:37:02 2010 From: scallanan at apple.com (Sean Callanan) Date: Fri, 12 Nov 2010 01:37:02 -0000 Subject: [Lldb-commits] [lldb] r118871 - in /lldb/trunk: include/lldb/Target/ABI.h include/lldb/Target/Thread.h include/lldb/Target/ThreadPlanCallFunction.h source/Target/Thread.cpp source/Target/ThreadPlanCallFunction.cpp Message-ID: <20101112013702.4F36F2A6C12C@llvm.org> Author: spyffe Date: Thu Nov 11 19:37:02 2010 New Revision: 118871 URL: http://llvm.org/viewvc/llvm-project?rev=118871&view=rev Log: Excised a version of the low-level function calling logic that supported calling functions with arbitrary arguments. We use ClangFunction for this, and the low-level logic is only required to support one or two pointer arguments. Modified: lldb/trunk/include/lldb/Target/ABI.h lldb/trunk/include/lldb/Target/Thread.h lldb/trunk/include/lldb/Target/ThreadPlanCallFunction.h lldb/trunk/source/Target/Thread.cpp lldb/trunk/source/Target/ThreadPlanCallFunction.cpp Modified: lldb/trunk/include/lldb/Target/ABI.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/ABI.h?rev=118871&r1=118870&r2=118871&view=diff ============================================================================== --- lldb/trunk/include/lldb/Target/ABI.h (original) +++ lldb/trunk/include/lldb/Target/ABI.h Thu Nov 11 19:37:02 2010 @@ -38,13 +38,6 @@ lldb::addr_t *this_arg) const = 0; virtual bool - PrepareNormalCall (Thread &thread, - lldb::addr_t sp, - lldb::addr_t functionAddress, - lldb::addr_t returnAddress, - ValueList &args) const = 0; - - virtual bool GetArgumentValues (Thread &thread, ValueList &values) const = 0; Modified: lldb/trunk/include/lldb/Target/Thread.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/Thread.h?rev=118871&r1=118870&r2=118871&view=diff ============================================================================== --- lldb/trunk/include/lldb/Target/Thread.h (original) +++ lldb/trunk/include/lldb/Target/Thread.h Thu Nov 11 19:37:02 2010 @@ -492,13 +492,6 @@ lldb::addr_t arg, bool stop_other_threads, bool discard_on_error = false); - - virtual ThreadPlan * - QueueThreadPlanForCallFunction (bool abort_other_plans, - Address& function, - ValueList &args, - bool stop_other_threads, - bool discard_on_error = false); //------------------------------------------------------------------ // Thread Plan accessors: Modified: lldb/trunk/include/lldb/Target/ThreadPlanCallFunction.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/ThreadPlanCallFunction.h?rev=118871&r1=118870&r2=118871&view=diff ============================================================================== --- lldb/trunk/include/lldb/Target/ThreadPlanCallFunction.h (original) +++ lldb/trunk/include/lldb/Target/ThreadPlanCallFunction.h Thu Nov 11 19:37:02 2010 @@ -30,12 +30,6 @@ bool discard_on_error = true, lldb::addr_t *this_arg = 0); - ThreadPlanCallFunction (Thread &thread, - Address &function, - ValueList &args, - bool stop_other_threads, - bool discard_on_error = true); - virtual ~ThreadPlanCallFunction (); Modified: lldb/trunk/source/Target/Thread.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/Thread.cpp?rev=118871&r1=118870&r2=118871&view=diff ============================================================================== --- lldb/trunk/source/Target/Thread.cpp (original) +++ lldb/trunk/source/Target/Thread.cpp Thu Nov 11 19:37:02 2010 @@ -726,18 +726,6 @@ } ThreadPlan * -Thread::QueueThreadPlanForCallFunction (bool abort_other_plans, - Address& function, - ValueList &args, - bool stop_other_threads, - bool discard_on_error) -{ - ThreadPlanSP thread_plan_sp (new ThreadPlanCallFunction (*this, function, args, stop_other_threads, discard_on_error)); - QueueThreadPlan (thread_plan_sp, abort_other_plans); - return thread_plan_sp.get(); -} - -ThreadPlan * Thread::QueueThreadPlanForRunToAddress (bool abort_other_plans, Address &target_addr, bool stop_other_threads) Modified: lldb/trunk/source/Target/ThreadPlanCallFunction.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/ThreadPlanCallFunction.cpp?rev=118871&r1=118870&r2=118871&view=diff ============================================================================== --- lldb/trunk/source/Target/ThreadPlanCallFunction.cpp (original) +++ lldb/trunk/source/Target/ThreadPlanCallFunction.cpp Thu Nov 11 19:37:02 2010 @@ -111,81 +111,6 @@ m_valid = true; } -ThreadPlanCallFunction::ThreadPlanCallFunction (Thread &thread, - Address &function, - ValueList &args, - bool stop_other_threads, - bool discard_on_error) : - ThreadPlan (ThreadPlan::eKindCallFunction, "Call function plan", thread, eVoteNoOpinion, eVoteNoOpinion), - m_valid (false), - m_stop_other_threads (stop_other_threads), - m_arg_addr (0), - m_args (&args), - m_process (thread.GetProcess()), - m_thread (thread) -{ - - SetOkayToDiscard (discard_on_error); - - Process& process = thread.GetProcess(); - Target& target = process.GetTarget(); - const ABI *abi = process.GetABI(); - - if(!abi) - return; - - SetBreakpoints(); - - lldb::addr_t spBelowRedZone = thread.GetRegisterContext()->GetSP() - abi->GetRedZoneSize(); - - SymbolContextList contexts; - SymbolContext context; - ModuleSP executableModuleSP (target.GetExecutableModule()); - - if (!executableModuleSP || - !executableModuleSP->FindSymbolsWithNameAndType(ConstString ("start"), eSymbolTypeCode, contexts)) - return; - - contexts.GetContextAtIndex(0, context); - - m_start_addr = context.symbol->GetValue(); - lldb::addr_t StartLoadAddr = m_start_addr.GetLoadAddress(&target); - - if(!thread.SaveFrameZeroState(m_register_backup)) - return; - - m_function_addr = function; - lldb::addr_t FunctionLoadAddr = m_function_addr.GetLoadAddress(&target); - - if (!abi->PrepareNormalCall(thread, - spBelowRedZone, - FunctionLoadAddr, - StartLoadAddr, - *m_args)) - return; - - LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_STEP)); - - if (log) - { - RegisterContext *reg_ctx = m_thread.GetRegisterContext(); - - log->PutCString("Function call was set up. Register state was:"); - - for (uint32_t register_index = 0, num_registers = reg_ctx->GetRegisterCount(); - register_index < num_registers; - ++register_index) - { - const char *register_name = reg_ctx->GetRegisterName(register_index); - uint64_t register_value = reg_ctx->ReadRegisterAsUnsigned(register_index, LLDB_INVALID_ADDRESS); - - log->Printf(" %s = 0x%llx", register_name, register_value); - } - } - - m_valid = true; -} - ThreadPlanCallFunction::~ThreadPlanCallFunction () { if (m_valid && !IsPlanComplete()) From scallanan at apple.com Thu Nov 11 19:41:35 2010 From: scallanan at apple.com (Sean Callanan) Date: Fri, 12 Nov 2010 01:41:35 -0000 Subject: [Lldb-commits] [lldb] r118872 - in /lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime: AppleObjCRuntimeV1.cpp AppleObjCRuntimeV1.h AppleObjCRuntimeV2.cpp AppleObjCRuntimeV2.h Message-ID: <20101112014135.42E312A6C12C@llvm.org> Author: spyffe Date: Thu Nov 11 19:41:35 2010 New Revision: 118872 URL: http://llvm.org/viewvc/llvm-project?rev=118872&view=rev Log: Removed redundant code for object introspection. Modified: lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV1.cpp lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV1.h lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.h Modified: lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV1.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV1.cpp?rev=118872&r1=118871&r2=118872&view=diff ============================================================================== --- lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV1.cpp (original) +++ lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV1.cpp Thu Nov 11 19:41:35 2010 @@ -40,125 +40,6 @@ static const char *pluginDesc = "Apple Objective C Language Runtime - Version 1"; static const char *pluginShort = "language.apple.objc.v1"; -bool -AppleObjCRuntimeV1::GetObjectDescription (Stream &str, ValueObject &object, ExecutionContextScope *exe_scope) -{ - - // ObjC objects can only be pointers: - if (!object.IsPointerType()) - return NULL; - - // Make the argument list: we pass one arg, the address of our pointer, to the print function. - Scalar scalar; - - if (!ClangASTType::GetValueAsScalar (object.GetClangAST(), - object.GetClangType(), - object.GetDataExtractor(), - 0, - object.GetByteSize(), - scalar)) - return NULL; - - Value val(scalar); - return GetObjectDescription(str, val, exe_scope); - -} -bool -AppleObjCRuntimeV1::GetObjectDescription (Stream &str, Value &value, ExecutionContextScope *exe_scope) -{ - if (!m_read_objc_library) - return false; - - ExecutionContext exe_ctx; - exe_scope->CalculateExecutionContext(exe_ctx); - - if (!exe_ctx.process) - return false; - - // We need other parts of the exe_ctx, but the processes have to match. - assert (m_process == exe_ctx.process); - - // Get the function address for the print function. - const Address *function_address = GetPrintForDebuggerAddr(); - if (!function_address) - return false; - - if (value.GetClangType()) - { - clang::QualType value_type = clang::QualType::getFromOpaquePtr (value.GetClangType()); - if (!value_type->isObjCObjectPointerType()) - { - str.Printf ("Value doesn't point to an ObjC object.\n"); - return false; - } - } - else - { - // If it is not a pointer, see if we can make it into a pointer. - ClangASTContext *ast_context = exe_ctx.target->GetScratchClangASTContext(); - void *opaque_type_ptr = ast_context->GetBuiltInType_objc_id(); - if (opaque_type_ptr == NULL) - opaque_type_ptr = ast_context->GetVoidPtrType(false); - value.SetContext(Value::eContextTypeOpaqueClangQualType, opaque_type_ptr); - } - - ValueList arg_value_list; - arg_value_list.PushValue(value); - - // This is the return value: - const char *target_triple = exe_ctx.process->GetTargetTriple().GetCString(); - ClangASTContext *ast_context = exe_ctx.target->GetScratchClangASTContext(); - - void *return_qualtype = ast_context->GetCStringType(true); - Value ret; - ret.SetContext(Value::eContextTypeOpaqueClangQualType, return_qualtype); - - // Now we're ready to call the function: - ClangFunction func(target_triple, ast_context, return_qualtype, *function_address, arg_value_list); - StreamString error_stream; - - lldb::addr_t wrapper_struct_addr = LLDB_INVALID_ADDRESS; - func.InsertFunction(exe_ctx, wrapper_struct_addr, error_stream); - - bool unwind_on_error = true; - bool try_all_threads = true; - bool stop_others = true; - - ClangFunction::ExecutionResults results - = func.ExecuteFunction(exe_ctx, &wrapper_struct_addr, error_stream, stop_others, 1000, try_all_threads, unwind_on_error, ret); - if (results != ClangFunction::eExecutionCompleted) - { - str.Printf("Error evaluating Print Object function: %d.\n", results); - return false; - } - - addr_t result_ptr = ret.GetScalar().ULongLong(LLDB_INVALID_ADDRESS); - - // FIXME: poor man's strcpy - we should have a "read memory as string interface... - - Error error; - std::vector desc; - while (1) - { - char byte = '\0'; - if (exe_ctx.process->ReadMemory(result_ptr + desc.size(), &byte, 1, error) != 1) - break; - - desc.push_back(byte); - - if (byte == '\0') - break; - } - - if (!desc.empty()) - { - str.PutCString(&desc.front()); - return true; - } - return false; - -} - lldb::ValueObjectSP AppleObjCRuntimeV1::GetDynamicValue (lldb::ValueObjectSP in_value, ExecutionContextScope *exe_scope) { Modified: lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV1.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV1.h?rev=118872&r1=118871&r2=118872&view=diff ============================================================================== --- lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV1.h (original) +++ lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV1.h Thu Nov 11 19:41:35 2010 @@ -31,12 +31,6 @@ ~AppleObjCRuntimeV1() { } // These are generic runtime functions: - virtual bool - GetObjectDescription (Stream &str, Value &value, ExecutionContextScope *exe_scope); - - virtual bool - GetObjectDescription (Stream &str, ValueObject &object, ExecutionContextScope *exe_scope); - virtual lldb::ValueObjectSP GetDynamicValue (lldb::ValueObjectSP in_value, ExecutionContextScope *exe_scope); Modified: lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp?rev=118872&r1=118871&r2=118872&view=diff ============================================================================== --- lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp (original) +++ lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp Thu Nov 11 19:41:35 2010 @@ -46,126 +46,6 @@ m_has_object_getClass = (objc_module_sp->FindFirstSymbolWithNameAndType(ConstString("gdb_object_getClass")) != NULL); } -bool -AppleObjCRuntimeV2::GetObjectDescription (Stream &str, ValueObject &object, ExecutionContextScope *exe_scope) -{ - - // ObjC objects can only be pointers: - if (!object.IsPointerType()) - return NULL; - - // Make the argument list: we pass one arg, the address of our pointer, to the print function. - Scalar scalar; - - if (!ClangASTType::GetValueAsScalar (object.GetClangAST(), - object.GetClangType(), - object.GetDataExtractor(), - 0, - object.GetByteSize(), - scalar)) - return NULL; - - Value val(scalar); - return GetObjectDescription(str, val, exe_scope); - -} -bool -AppleObjCRuntimeV2::GetObjectDescription (Stream &str, Value &value, ExecutionContextScope *exe_scope) -{ - if (!m_read_objc_library) - return false; - - ExecutionContext exe_ctx; - exe_scope->CalculateExecutionContext(exe_ctx); - - if (!exe_ctx.process) - return false; - - // We need other parts of the exe_ctx, but the processes have to match. - assert (m_process == exe_ctx.process); - - // Get the function address for the print function. - const Address *function_address = GetPrintForDebuggerAddr(); - if (!function_address) - return false; - - if (value.GetClangType()) - { - clang::QualType value_type = clang::QualType::getFromOpaquePtr (value.GetClangType()); - if (!value_type->isObjCObjectPointerType()) - { - str.Printf ("Value doesn't point to an ObjC object.\n"); - return false; - } - } - else - { - // If it is not a pointer, see if we can make it into a pointer. - ClangASTContext *ast_context = exe_ctx.target->GetScratchClangASTContext(); - void *opaque_type_ptr = ast_context->GetBuiltInType_objc_id(); - if (opaque_type_ptr == NULL) - opaque_type_ptr = ast_context->GetVoidPtrType(false); - value.SetContext(Value::eContextTypeOpaqueClangQualType, opaque_type_ptr); - } - - ValueList arg_value_list; - arg_value_list.PushValue(value); - - // This is the return value: - const char *target_triple = exe_ctx.process->GetTargetTriple().GetCString(); - ClangASTContext *ast_context = exe_ctx.target->GetScratchClangASTContext(); - - void *return_qualtype = ast_context->GetCStringType(true); - Value ret; - ret.SetContext(Value::eContextTypeOpaqueClangQualType, return_qualtype); - - // Now we're ready to call the function: - ClangFunction func(target_triple, ast_context, return_qualtype, *function_address, arg_value_list); - StreamString error_stream; - - lldb::addr_t wrapper_struct_addr = LLDB_INVALID_ADDRESS; - func.InsertFunction(exe_ctx, wrapper_struct_addr, error_stream); - - const bool stop_others = true; - const bool try_all_threads = true; - const bool discard_on_error = true; - - ClangFunction::ExecutionResults results - = func.ExecuteFunction(exe_ctx, &wrapper_struct_addr, error_stream, stop_others, 1000, - try_all_threads, discard_on_error, ret); - if (results != ClangFunction::eExecutionCompleted) - { - str.Printf("Error evaluating Print Object function: %d.\n", results); - return false; - } - - addr_t result_ptr = ret.GetScalar().ULongLong(LLDB_INVALID_ADDRESS); - - // FIXME: poor man's strcpy - we should have a "read memory as string interface... - - Error error; - std::vector desc; - while (1) - { - char byte = '\0'; - if (exe_ctx.process->ReadMemory(result_ptr + desc.size(), &byte, 1, error) != 1) - break; - - desc.push_back(byte); - - if (byte == '\0') - break; - } - - if (!desc.empty()) - { - str.PutCString(&desc.front()); - return true; - } - return false; - -} - lldb::ValueObjectSP AppleObjCRuntimeV2::GetDynamicValue (lldb::ValueObjectSP in_value, ExecutionContextScope *exe_scope) { Modified: lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.h?rev=118872&r1=118871&r2=118872&view=diff ============================================================================== --- lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.h (original) +++ lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.h Thu Nov 11 19:41:35 2010 @@ -31,12 +31,6 @@ ~AppleObjCRuntimeV2() { } // These are generic runtime functions: - virtual bool - GetObjectDescription (Stream &str, Value &value, ExecutionContextScope *exe_scope); - - virtual bool - GetObjectDescription (Stream &str, ValueObject &object, ExecutionContextScope *exe_scope); - virtual lldb::ValueObjectSP GetDynamicValue (lldb::ValueObjectSP in_value, ExecutionContextScope *exe_scope); From scallanan at apple.com Thu Nov 11 19:49:03 2010 From: scallanan at apple.com (Sean Callanan) Date: Fri, 12 Nov 2010 01:49:03 -0000 Subject: [Lldb-commits] [lldb] r118873 - /lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.cpp Message-ID: <20101112014903.6CA0C2A6C12C@llvm.org> Author: spyffe Date: Thu Nov 11 19:49:03 2010 New Revision: 118873 URL: http://llvm.org/viewvc/llvm-project?rev=118873&view=rev Log: Temporary extension of the timeout for Objective-C object diagnostic expressions while we work on the logic for handling the timeout. Modified: lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.cpp Modified: lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.cpp?rev=118873&r1=118872&r2=118873&view=diff ============================================================================== --- lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.cpp (original) +++ lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.cpp Thu Nov 11 19:49:03 2010 @@ -123,7 +123,7 @@ bool stop_others = true; ClangFunction::ExecutionResults results - = func.ExecuteFunction(exe_ctx, &wrapper_struct_addr, error_stream, stop_others, 1000, try_all_threads, unwind_on_error, ret); + = func.ExecuteFunction(exe_ctx, &wrapper_struct_addr, error_stream, stop_others, 1000000, try_all_threads, unwind_on_error, ret); if (results != ClangFunction::eExecutionCompleted) { str.Printf("Error evaluating Print Object function: %d.\n", results); From jingham at apple.com Thu Nov 11 20:30:38 2010 From: jingham at apple.com (Jim Ingham) Date: Fri, 12 Nov 2010 02:30:38 -0000 Subject: [Lldb-commits] [lldb] r118876 - /lldb/trunk/include/lldb/Target/ThreadPlanTracer.h Message-ID: <20101112023038.6DD3E2A6C12C@llvm.org> Author: jingham Date: Thu Nov 11 20:30:38 2010 New Revision: 118876 URL: http://llvm.org/viewvc/llvm-project?rev=118876&view=rev Log: Added OnStart and OnEnd methods to the tracer. Modified: lldb/trunk/include/lldb/Target/ThreadPlanTracer.h Modified: lldb/trunk/include/lldb/Target/ThreadPlanTracer.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/ThreadPlanTracer.h?rev=118876&r1=118875&r2=118876&view=diff ============================================================================== --- lldb/trunk/include/lldb/Target/ThreadPlanTracer.h (original) +++ lldb/trunk/include/lldb/Target/ThreadPlanTracer.h Thu Nov 11 20:30:38 2010 @@ -24,6 +24,14 @@ friend class ThreadPlan; public: + + typedef enum ThreadPlanTracerStyle + { + eLocation = 0, + eStateChange, + eCheckFrames, + ePython, + } ThreadPlanTracerStyle; ThreadPlanTracer (Thread &thread, lldb::StreamSP &stream_sp); ThreadPlanTracer (Thread &thread); @@ -31,11 +39,26 @@ { } + virtual void TracingStarted () + { + + } + + virtual void TracingEnded () + { + + } + bool EnableTracing(bool value) { bool old_value = m_enabled; m_enabled = value; + if (old_value == false && value == true) + TracingStarted(); + else if (old_value == true && value == false) + TracingEnded(); + return old_value; } From gclayton at apple.com Thu Nov 11 20:37:39 2010 From: gclayton at apple.com (Greg Clayton) Date: Fri, 12 Nov 2010 02:37:39 -0000 Subject: [Lldb-commits] [lldb] r118877 - /lldb/trunk/tools/debugserver/source/MacOSX/MachThread.cpp Message-ID: <20101112023739.B45482A6C12C@llvm.org> Author: gclayton Date: Thu Nov 11 20:37:39 2010 New Revision: 118877 URL: http://llvm.org/viewvc/llvm-project?rev=118877&view=rev Log: Fixed more thread suspend/resume issues. Modified: lldb/trunk/tools/debugserver/source/MacOSX/MachThread.cpp Modified: lldb/trunk/tools/debugserver/source/MacOSX/MachThread.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/debugserver/source/MacOSX/MachThread.cpp?rev=118877&r1=118876&r2=118877&view=diff ============================================================================== --- lldb/trunk/tools/debugserver/source/MacOSX/MachThread.cpp (original) +++ lldb/trunk/tools/debugserver/source/MacOSX/MachThread.cpp Thu Nov 11 20:37:39 2010 @@ -24,15 +24,15 @@ } MachThread::MachThread (MachProcess *process, thread_t thread) : - m_process(process), - m_tid(thread), - m_seq_id(GetSequenceID()), - m_state(eStateUnloaded), - m_state_mutex(PTHREAD_MUTEX_RECURSIVE), - m_breakID(INVALID_NUB_BREAK_ID), - m_suspendCount(0), - m_arch(this), - m_regSets() + m_process (process), + m_tid (thread), + m_seq_id (GetSequenceID()), + m_state (eStateUnloaded), + m_state_mutex (PTHREAD_MUTEX_RECURSIVE), + m_breakID (INVALID_NUB_BREAK_ID), + m_suspendCount (0), + m_arch (this), + m_regSets () { nub_size_t num_reg_sets = 0; const DNBRegisterSetInfo *regSetInfo = m_arch.GetRegisterSetInfo(&num_reg_sets); @@ -74,14 +74,7 @@ DNBLogThreadedIf(LOG_THREAD | LOG_VERBOSE, "MachThread::%s ( )", __FUNCTION__); if (ThreadIDIsValid(m_tid)) { - while (m_suspendCount > 0) - { - DNBError err(::thread_resume (m_tid), DNBError::MachKernel); - if (err.Success()) - m_suspendCount--; - if (DNBLogCheckLogBit(LOG_THREAD) || err.Fail()) - err.LogThreaded("::thread_resume (%4.4x)", m_tid); - } + RestoreSuspendCount(); } return SuspendCount(); } @@ -93,29 +86,40 @@ DNBError err; if (ThreadIDIsValid(m_tid) == false) return false; - else if (m_suspendCount > m_basicInfo.suspend_count) + if (m_suspendCount > 0) { - while (m_suspendCount > m_basicInfo.suspend_count) + while (m_suspendCount > 0) { err = ::thread_resume (m_tid); - if (err.Success()) - --m_suspendCount; if (DNBLogCheckLogBit(LOG_THREAD) || err.Fail()) err.LogThreaded("::thread_resume (%4.4x)", m_tid); - } - } - else if (m_suspendCount < m_basicInfo.suspend_count) - { - while (m_suspendCount < m_basicInfo.suspend_count) - { - err = ::thread_suspend (m_tid); if (err.Success()) --m_suspendCount; - if (DNBLogCheckLogBit(LOG_THREAD) || err.Fail()) - err.LogThreaded("::thread_suspend (%4.4x)", m_tid); + else + { + if (GetBasicInfo()) + m_suspendCount = m_basicInfo.suspend_count; + else + m_suspendCount = 0; + return false; // ??? + } } } - return m_suspendCount == m_basicInfo.suspend_count; + // We don't currently really support resuming a thread that was externally + // suspended. If/when we do, we will need to make the code below work and + // m_suspendCount will need to become signed instead of unsigned. +// else if (m_suspendCount < 0) +// { +// while (m_suspendCount < 0) +// { +// err = ::thread_suspend (m_tid); +// if (err.Success()) +// ++m_suspendCount; +// if (DNBLogCheckLogBit(LOG_THREAD) || err.Fail()) +// err.LogThreaded("::thread_suspend (%4.4x)", m_tid); +// } +// } + return true; } @@ -199,7 +203,9 @@ switch (m_basicInfo.run_state) { - default: + default: + assert (!"Invalid run_state encountered"); + case TH_STATE_UNINTERRUPTIBLE: break; @@ -430,7 +436,6 @@ // Update the basic information for a thread MachThread::GetBasicInfo(m_tid, &m_basicInfo); - m_suspendCount = m_basicInfo.suspend_count; // See if we were at a breakpoint when we last resumed that we disabled, // re-enable it. @@ -439,7 +444,7 @@ if (NUB_BREAK_ID_IS_VALID(breakID)) { m_process->EnableBreakpoint(breakID); - if (m_suspendCount > 0) + if (m_basicInfo.suspend_count > 0) { SetState(eStateSuspended); } @@ -462,7 +467,7 @@ } else { - if (m_suspendCount > 0) + if (m_basicInfo.suspend_count > 0) { SetState(eStateSuspended); } From scallanan at apple.com Thu Nov 11 21:22:22 2010 From: scallanan at apple.com (Sean Callanan) Date: Fri, 12 Nov 2010 03:22:22 -0000 Subject: [Lldb-commits] [lldb] r118879 - in /lldb/trunk: include/lldb/Target/ThreadPlanTracer.h source/Target/ThreadPlanTracer.cpp Message-ID: <20101112032222.1EED22A6C12C@llvm.org> Author: spyffe Date: Thu Nov 11 21:22:21 2010 New Revision: 118879 URL: http://llvm.org/viewvc/llvm-project?rev=118879&view=rev Log: Added a thread plan tracer that prints lines of assembly as well as registers that changed. Modified: lldb/trunk/include/lldb/Target/ThreadPlanTracer.h lldb/trunk/source/Target/ThreadPlanTracer.cpp Modified: lldb/trunk/include/lldb/Target/ThreadPlanTracer.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/ThreadPlanTracer.h?rev=118879&r1=118878&r2=118879&view=diff ============================================================================== --- lldb/trunk/include/lldb/Target/ThreadPlanTracer.h (original) +++ lldb/trunk/include/lldb/Target/ThreadPlanTracer.h Thu Nov 11 21:22:21 2010 @@ -15,6 +15,7 @@ // Other libraries and framework includes // Project includes #include "lldb/lldb-private.h" +#include "lldb/Symbol/TaggedASTType.h" #include "lldb/Target/Thread.h" namespace lldb_private { @@ -98,6 +99,24 @@ bool m_enabled; lldb::StreamSP m_stream_sp; }; + +class ThreadPlanAssemblyTracer : public ThreadPlanTracer +{ +public: + ThreadPlanAssemblyTracer (Thread &thread, lldb::StreamSP &stream_sp); + virtual ~ThreadPlanAssemblyTracer (); + virtual void TracingStarted (); + virtual void TracingEnded (); + virtual void Log(); +private: + Process &m_process; + Target &m_target; + Disassembler *m_disassembler; + const ABI *m_abi; + TypeFromUser m_intptr_type; + std::vector m_register_values; + lldb::DataBufferSP m_buffer_sp; +}; } // namespace lldb_private Modified: lldb/trunk/source/Target/ThreadPlanTracer.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/ThreadPlanTracer.cpp?rev=118879&r1=118878&r2=118879&view=diff ============================================================================== --- lldb/trunk/source/Target/ThreadPlanTracer.cpp (original) +++ lldb/trunk/source/Target/ThreadPlanTracer.cpp Thu Nov 11 21:22:21 2010 @@ -10,12 +10,18 @@ #include "lldb/Target/ThreadPlan.h" // C Includes +#include // C++ Includes // Other libraries and framework includes // Project includes +#include "lldb/Core/ArchSpec.h" +#include "lldb/Core/DataBufferHeap.h" #include "lldb/Core/Debugger.h" +#include "lldb/Core/Disassembler.h" #include "lldb/Core/Log.h" #include "lldb/Core/State.h" +#include "lldb/Core/Value.h" +#include "lldb/Symbol/TypeList.h" #include "lldb/Target/RegisterContext.h" #include "lldb/Target/Thread.h" #include "lldb/Target/Process.h" @@ -24,6 +30,8 @@ using namespace lldb; using namespace lldb_private; +#pragma mark ThreadPlanTracer + ThreadPlanTracer::ThreadPlanTracer (Thread &thread, lldb::StreamSP &stream_sp) : m_single_step(true), m_enabled (false), @@ -75,3 +83,200 @@ else return false; } + +#pragma mark ThreadPlanAssemblyTracer + +ThreadPlanAssemblyTracer::ThreadPlanAssemblyTracer (Thread &thread, lldb::StreamSP &stream_sp) : + ThreadPlanTracer (thread, stream_sp), + m_process(thread.GetProcess()), + m_target(thread.GetProcess().GetTarget()) +{ + Process &process = thread.GetProcess(); + Target &target = process.GetTarget(); + + ArchSpec arch(target.GetArchitecture()); + + m_disassembler = Disassembler::FindPlugin(arch); + + m_abi = process.GetABI(); + + ModuleSP executableModuleSP (target.GetExecutableModule()); + TypeList *type_list = executableModuleSP->GetTypeList(); + + if (type_list) + { + m_intptr_type = TypeFromUser(type_list->GetClangASTContext().GetBuiltinTypeForEncodingAndBitSize(eEncodingUint, arch.GetAddressByteSize() * 8), + type_list->GetClangASTContext().getASTContext()); + } + + const unsigned int buf_size = 32; + + m_buffer_sp.reset(new DataBufferHeap(buf_size, 0)); +} + +ThreadPlanAssemblyTracer::~ThreadPlanAssemblyTracer() +{ +} + +void ThreadPlanAssemblyTracer::TracingStarted () +{ + RegisterContext *reg_ctx = m_thread.GetRegisterContext(); + + if (m_register_values.size() == 0) + { + for (uint32_t reg_index = 0, num_registers = reg_ctx->GetRegisterCount(); + reg_index < num_registers; + ++reg_index) + m_register_values.push_back(0); + } +} + +void ThreadPlanAssemblyTracer::TracingEnded () +{ + for (uint32_t reg_index = 0, num_registers = m_register_values.size(); + reg_index < num_registers; + ++reg_index) + m_register_values[reg_index] = 0; +} + +static const char *Padding(int length) +{ + const int padding_size = 256; + + static char* padding = NULL; + static int prev_length = 256; + + if (!padding) { + padding = new char[padding_size]; + memset(padding, ' ', padding_size); + } + + if (length > 255) + length = 255; + + if (prev_length < 256) + padding[prev_length] = ' '; + + padding[length] = '\0'; + + prev_length = length; + + return padding; +} + +static void PadOutTo(StreamString &stream, int target) +{ + stream.Flush(); + + int length = stream.GetString().length(); + + if (length + 1 < target) + stream.PutCString(Padding(target - (length + 1))); + + stream.PutCString(" "); +} + +void ThreadPlanAssemblyTracer::Log () +{ + Stream *stream = GetLogStream (); + + if (!stream) + return; + + RegisterContext *reg_ctx = m_thread.GetRegisterContext(); + + lldb::addr_t pc = reg_ctx->GetPC(); + Address pc_addr; + bool addr_valid = false; + + StreamString desc; + + int desired_width = 0; + + addr_valid = m_process.GetTarget().GetSectionLoadList().ResolveLoadAddress (pc, pc_addr); + + pc_addr.Dump(&desc, &m_thread, Address::DumpStyleResolvedDescription, Address::DumpStyleModuleWithFileAddress); + + desired_width += 64; + PadOutTo(desc, desired_width); + + if (m_disassembler) + { + bzero(m_buffer_sp->GetBytes(), m_buffer_sp->GetByteSize()); + + Error err; + m_process.ReadMemory(pc, m_buffer_sp->GetBytes(), m_buffer_sp->GetByteSize(), err); + + if (err.Success()) + { + DataExtractor extractor(m_buffer_sp, + m_process.GetByteOrder(), + m_process.GetAddressByteSize()); + + if (addr_valid) + m_disassembler->DecodeInstructions (pc_addr, extractor, 0, 1); + else + m_disassembler->DecodeInstructions (Address (NULL, pc), extractor, 0, 1); + + InstructionList &instruction_list = m_disassembler->GetInstructionList(); + + if (instruction_list.GetSize()) + { + Instruction *instruction = instruction_list.GetInstructionAtIndex(0).get(); + instruction->Dump (&desc, + false, + NULL, + 0, + NULL, + true); + } + } + + desired_width += 32; + PadOutTo(desc, desired_width); + } + + if (m_abi && m_intptr_type.GetOpaqueQualType()) + { + ValueList value_list; + const int num_args = 1; + + for (int arg_index = 0; arg_index < num_args; ++arg_index) + { + Value value; + value.SetValueType (Value::eValueTypeScalar); + value.SetContext (Value::eContextTypeOpaqueClangQualType, m_intptr_type.GetOpaqueQualType()); + value_list.PushValue (value); + } + + if (m_abi->GetArgumentValues (m_thread, value_list)) + { + for (int arg_index = 0; arg_index < num_args; ++arg_index) + { + desc.Printf("arg[%d]=%llx", arg_index, value_list.GetValueAtIndex(arg_index)->GetScalar().ULongLong()); + + if (arg_index + 1 < num_args) + desc.Printf(", "); + } + } + } + + desired_width += 20; + PadOutTo(desc, desired_width); + + for (uint32_t reg_index = 0, num_registers = reg_ctx->GetRegisterCount(); + reg_index < num_registers; + ++reg_index) + { + uint64_t reg_value = reg_ctx->ReadRegisterAsUnsigned(reg_index, 0x0); + + if (reg_value != m_register_values[reg_index]) + { + desc.Printf ("%s:0x%llx->0x%llx ", reg_ctx->GetRegisterName(reg_index), m_register_values[reg_index], reg_value); + + m_register_values[reg_index] = reg_value; + } + } + + stream->Printf ("Single-step: %s", desc.GetString().c_str()); +} From jmolenda at apple.com Thu Nov 11 23:23:10 2010 From: jmolenda at apple.com (Jason Molenda) Date: Fri, 12 Nov 2010 05:23:10 -0000 Subject: [Lldb-commits] [lldb] r118882 - in /lldb/trunk: include/lldb/Symbol/FuncUnwinders.h source/Plugins/Process/Utility/RegisterContextLLDB.cpp source/Plugins/Process/Utility/RegisterContextLLDB.h source/Symbol/FuncUnwinders.cpp Message-ID: <20101112052310.AC1BD2A6C12C@llvm.org> Author: jmolenda Date: Thu Nov 11 23:23:10 2010 New Revision: 118882 URL: http://llvm.org/viewvc/llvm-project?rev=118882&view=rev Log: I'm not thrilled with how I structured this but RegisterContextLLDB needs to use the current pc and current offset in two ways: To determine which function we are currently executing, and the decide how much of that function has executed so far. For the former use, we need to back up the saved pc value by one byte if we're going to use the correct function's unwind information -- we may be executing a CALL instruction at the end of a function and the following instruction belongs to a new function, or we may be looking at unwind information which only covers the call instruction and not the subsequent instruction. But when we're talking about deciding which row of an UnwindPlan to execute, we want to use the actual byte offset in the function, not the byte offset - 1. Right now RegisterContextLLDB is tracking both the "real" offset and an "offset minus one" and different parts of the class have to know which one to use and they need to be updated/set in tandem. I want to revisit this at some point. The second change made in looking up eh_frame information; it was formerly done by looking for the start address of the function we are currently executing. But it is possible to have unwind information for a function which only covers a small section of the function's address range. In which case looking up by the start pc value may not find the eh_frame FDE. The hand-written _sigtramp() unwind info on Mac OS X, which covers exactly one instruction in the middle of the function, happens to trigger both of these issues. I still need to get the UnwindPlan runner to handle arbitrary dwarf expressions in the FDE but there's a good chance it will be easy to reuse the DWARFExpression class to do this. Modified: lldb/trunk/include/lldb/Symbol/FuncUnwinders.h lldb/trunk/source/Plugins/Process/Utility/RegisterContextLLDB.cpp lldb/trunk/source/Plugins/Process/Utility/RegisterContextLLDB.h lldb/trunk/source/Symbol/FuncUnwinders.cpp Modified: lldb/trunk/include/lldb/Symbol/FuncUnwinders.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Symbol/FuncUnwinders.h?rev=118882&r1=118881&r2=118882&view=diff ============================================================================== --- lldb/trunk/include/lldb/Symbol/FuncUnwinders.h (original) +++ lldb/trunk/include/lldb/Symbol/FuncUnwinders.h Thu Nov 11 23:23:10 2010 @@ -37,8 +37,13 @@ ~FuncUnwinders (); + // current_offset is the byte offset into the function. + // 0 means no instructions have executed yet. -1 means the offset is unknown. + // On architectures where the pc points to the next instruction that will execute, this + // offset value will have already been decremented by 1 to stay within the bounds of the + // correct function body. UnwindPlan* - GetUnwindPlanAtCallSite (); + GetUnwindPlanAtCallSite (int current_offset); UnwindPlan* GetUnwindPlanAtNonCallSite (lldb_private::Thread& thread); Modified: lldb/trunk/source/Plugins/Process/Utility/RegisterContextLLDB.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Utility/RegisterContextLLDB.cpp?rev=118882&r1=118881&r2=118882&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Process/Utility/RegisterContextLLDB.cpp (original) +++ lldb/trunk/source/Plugins/Process/Utility/RegisterContextLLDB.cpp Thu Nov 11 23:23:10 2010 @@ -35,7 +35,7 @@ m_sym_ctx(sym_ctx), m_all_registers_available(false), m_registers(), m_cfa (LLDB_INVALID_ADDRESS), m_start_pc (), m_current_pc (), m_frame_number (frame_number), m_full_unwind_plan(NULL), m_fast_unwind_plan(NULL), m_base_reg_ctx (), m_frame_type (-1), - m_current_offset (0), m_sym_ctx_valid (false) + m_current_offset (0), m_current_offset_backed_up_one (0), m_sym_ctx_valid (false) { m_sym_ctx.Clear(); m_sym_ctx_valid = false; @@ -107,11 +107,13 @@ { m_start_pc = addr_range.GetBaseAddress(); m_current_offset = frame_sp->GetFrameCodeAddress().GetOffset() - m_start_pc.GetOffset(); + m_current_offset_backed_up_one = m_current_offset; } else { m_start_pc = m_current_pc; m_current_offset = -1; + m_current_offset_backed_up_one = -1; } // We've set m_frame_type and m_sym_ctx before these calls. @@ -224,6 +226,7 @@ m_frame_type = eNormalFrame; m_all_registers_available = false; m_current_offset = -1; + m_current_offset_backed_up_one = -1; addr_t cfa_regval; int row_register_kind = m_full_unwind_plan->GetRegisterKind (); uint32_t cfa_regnum = m_full_unwind_plan->GetRowForFunctionOffset(0)->GetCFARegister(); @@ -276,16 +279,42 @@ m_sym_ctx_valid = false; } - static ConstString sigtramp_name ("_sigtramp"); - if ((m_sym_ctx.function && m_sym_ctx.function->GetMangled().GetMangledName() == sigtramp_name) - || (m_sym_ctx.symbol && m_sym_ctx.symbol->GetMangled().GetMangledName() == sigtramp_name)) - { - m_frame_type = eSigtrampFrame; - } - else - { - // FIXME: Detect eDebuggerFrame here. - m_frame_type = eNormalFrame; + bool decr_pc_and_recompute_addr_range = false; + + // If the symbol lookup failed... + if (m_sym_ctx_valid == false) + decr_pc_and_recompute_addr_range = true; + + // Or if we're in the middle of the stack (and not "above" an asynchornous event like sigtramp), + // and our "current" pc is the start of a function... + if (m_sym_ctx_valid + && ((RegisterContextLLDB*) m_next_frame.get())->m_frame_type != eSigtrampFrame + && ((RegisterContextLLDB*) m_next_frame.get())->m_frame_type != eDebuggerFrame + && addr_range.GetBaseAddress().IsValid() + && addr_range.GetBaseAddress().GetSection() == m_current_pc.GetSection() + && addr_range.GetBaseAddress().GetOffset() == m_current_pc.GetOffset()) + { + decr_pc_and_recompute_addr_range = true; + } + + // We need to back up the pc by 1 byte and re-search for the Symbol to handle the case where the "saved pc" + // value is pointing to the next function, e.g. if a function ends with a CALL instruction. + // FIXME this may need to be an architectural-dependent behavior; if so we'll need to add a member function + // to the ABI plugin and consult that. + if (decr_pc_and_recompute_addr_range) + { + Address temporary_pc(m_current_pc); + temporary_pc.SetOffset(m_current_pc.GetOffset() - 1); + m_sym_ctx.Clear(); + m_sym_ctx_valid = false; + if ((m_current_pc.GetModule()->ResolveSymbolContextForAddress (temporary_pc, eSymbolContextFunction| eSymbolContextSymbol, m_sym_ctx) & eSymbolContextSymbol) == eSymbolContextSymbol) + { + m_sym_ctx_valid = true; + } + if (!m_sym_ctx.GetAddressRange (eSymbolContextFunction | eSymbolContextSymbol, addr_range)) + { + m_sym_ctx_valid = false; + } } // If we were able to find a symbol/function, set addr_range_ptr to the bounds of that symbol/function. @@ -294,11 +323,27 @@ { m_start_pc = addr_range.GetBaseAddress(); m_current_offset = m_current_pc.GetOffset() - m_start_pc.GetOffset(); + m_current_offset_backed_up_one = m_current_offset; + if (decr_pc_and_recompute_addr_range && m_current_offset_backed_up_one > 0) + m_current_offset_backed_up_one--; } else { m_start_pc = m_current_pc; m_current_offset = -1; + m_current_offset_backed_up_one = -1; + } + + static ConstString sigtramp_name ("_sigtramp"); + if ((m_sym_ctx.function && m_sym_ctx.function->GetMangled().GetMangledName() == sigtramp_name) + || (m_sym_ctx.symbol && m_sym_ctx.symbol->GetMangled().GetMangledName() == sigtramp_name)) + { + m_frame_type = eSigtrampFrame; + } + else + { + // FIXME: Detect eDebuggerFrame here. + m_frame_type = eNormalFrame; } // We've set m_frame_type and m_sym_ctx before this call. @@ -386,6 +431,7 @@ // 1. m_frame_type should already be set to eSigtrampFrame/eDebuggerFrame if either of those are correct, // 2. m_sym_ctx should already be filled in, and // 3. m_current_pc should have the current pc value for this frame +// 4. m_current_offset_backed_up_one should have the current byte offset into the function, maybe backed up by 1, -1 if unknown UnwindPlan * RegisterContextLLDB::GetFastUnwindPlanForFrame () @@ -437,6 +483,7 @@ // 1. m_frame_type should already be set to eSigtrampFrame/eDebuggerFrame if either of those are correct, // 2. m_sym_ctx should already be filled in, and // 3. m_current_pc should have the current pc value for this frame +// 4. m_current_offset_backed_up_one should have the current byte offset into the function, maybe backed up by 1, -1 if unknown UnwindPlan * RegisterContextLLDB::GetFullUnwindPlanForFrame () @@ -499,8 +546,8 @@ if (m_frame_type == eSigtrampFrame) { m_fast_unwind_plan = NULL; - up = fu->GetUnwindPlanAtCallSite (); - if (up->PlanValidAtAddress (m_current_pc)) + up = fu->GetUnwindPlanAtCallSite (m_current_offset_backed_up_one); + if (up && up->PlanValidAtAddress (m_current_pc)) { return up; } @@ -521,7 +568,7 @@ } // Typically this is unwind info from an eh_frame section intended for exception handling; only valid at call sites - up = fu->GetUnwindPlanAtCallSite (); + up = fu->GetUnwindPlanAtCallSite (m_current_offset_backed_up_one); if (up && up->PlanValidAtAddress (m_current_pc)) { if (log && IsLogVerbose()) Modified: lldb/trunk/source/Plugins/Process/Utility/RegisterContextLLDB.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Utility/RegisterContextLLDB.h?rev=118882&r1=118881&r2=118882&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Process/Utility/RegisterContextLLDB.h (original) +++ lldb/trunk/source/Plugins/Process/Utility/RegisterContextLLDB.h Thu Nov 11 23:23:10 2010 @@ -167,16 +167,27 @@ lldb_private::UnwindPlan *m_full_unwind_plan; bool m_all_registers_available; // Can we retrieve all regs or just nonvolatile regs? int m_frame_type; // enum FrameType + + lldb::addr_t m_cfa; + lldb_private::Address m_start_pc; + lldb_private::Address m_current_pc; + int m_current_offset; // how far into the function we've executed; -1 if unknown + // 0 if no instructions have been executed yet. + + int m_current_offset_backed_up_one; // how far into the function we've executed; -1 if unknown + // 0 if no instructions have been executed yet. + // On architectures where the return address on the stack points + // to the instruction after the CALL, this value will have 1 + // subtracted from it. Else a function that ends in a CALL will + // have an offset pointing into the next function's address range. + // m_current_pc has the actual address of the "current" pc. + lldb_private::SymbolContext& m_sym_ctx; bool m_sym_ctx_valid; // if ResolveSymbolContextForAddress fails, don't try to use m_sym_ctx int m_frame_number; // What stack frame level this frame is - used for debug logging - lldb::addr_t m_cfa; - lldb_private::Address m_start_pc; - lldb_private::Address m_current_pc; - std::map m_registers; // where to find reg values for this frame //------------------------------------------------------------------ Modified: lldb/trunk/source/Symbol/FuncUnwinders.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/FuncUnwinders.cpp?rev=118882&r1=118881&r2=118882&view=diff ============================================================================== --- lldb/trunk/source/Symbol/FuncUnwinders.cpp (original) +++ lldb/trunk/source/Symbol/FuncUnwinders.cpp Thu Nov 11 23:23:10 2010 @@ -47,24 +47,39 @@ } UnwindPlan* -FuncUnwinders::GetUnwindPlanAtCallSite () +FuncUnwinders::GetUnwindPlanAtCallSite (int current_offset) { if (m_unwind_at_call_site != NULL) return m_unwind_at_call_site; if (!m_range.GetBaseAddress().IsValid()) return NULL; + // We have cases (e.g. with _sigtramp on Mac OS X) where the hand-written eh_frame unwind info for a + // function does not cover the entire range of the function and so the FDE only lists a subset of the + // address range. If we try to look up the unwind info by the starting address of the function + // (i.e. m_range.GetBaseAddress()) we may not find the eh_frame FDE. We need to use the actual byte offset + // into the function when looking it up. + + Address current_pc (m_range.GetBaseAddress ()); + if (current_offset != -1) + current_pc.SetOffset (current_pc.GetOffset() + current_offset); + DWARFCallFrameInfo *eh_frame = m_unwind_table.GetEHFrameInfo(); + UnwindPlan *up = NULL; if (eh_frame) { - UnwindPlan *up = new UnwindPlan; - if (eh_frame->GetUnwindPlan (m_range.GetBaseAddress (), *up) == true) + up = new UnwindPlan; + if (!eh_frame->GetUnwindPlan (current_pc, *up)) { - m_unwind_at_call_site = up; - return m_unwind_at_call_site; + delete up; + return NULL; } } - return NULL; + if (!up) + return NULL; + + m_unwind_at_call_site = up; + return m_unwind_at_call_site; } UnwindPlan* From johnny.chen at apple.com Fri Nov 12 15:50:28 2010 From: johnny.chen at apple.com (Johnny Chen) Date: Fri, 12 Nov 2010 21:50:28 -0000 Subject: [Lldb-commits] [lldb] r118930 - /lldb/trunk/test/set_values/TestSetValues.py Message-ID: <20101112215028.D5E8D2A6C12C@llvm.org> Author: johnny Date: Fri Nov 12 15:50:28 2010 New Revision: 118930 URL: http://llvm.org/viewvc/llvm-project?rev=118930&view=rev Log: Implement TODO's of using expression command to set vaiables and to verify that they are displayed correctly. Modified: lldb/trunk/test/set_values/TestSetValues.py Modified: lldb/trunk/test/set_values/TestSetValues.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/set_values/TestSetValues.py?rev=118930&r1=118929&r2=118930&view=diff ============================================================================== --- lldb/trunk/test/set_values/TestSetValues.py (original) +++ lldb/trunk/test/set_values/TestSetValues.py Fri Nov 12 15:50:28 2010 @@ -77,8 +77,10 @@ self.expect("frame variable -t", VARIABLES_DISPLAYED_CORRECTLY, startstr = "(char) i = 'a'") - # TODO: # Now set variable 'i' and check that it is correctly displayed. + self.runCmd("expression i = \\'b\\'") # Escape the single quotes. + self.expect("frame variable -t", VARIABLES_DISPLAYED_CORRECTLY, + startstr = "(char) i = 'b'") self.runCmd("continue") @@ -87,8 +89,10 @@ self.expect("frame variable -t", VARIABLES_DISPLAYED_CORRECTLY, patterns = ["\((short unsigned int|unsigned short)\) i = 33"]) - # TODO: # Now set variable 'i' and check that it is correctly displayed. + self.runCmd("expression i = 333") + self.expect("frame variable -t", VARIABLES_DISPLAYED_CORRECTLY, + patterns = ["\((short unsigned int|unsigned short)\) i = 333"]) self.runCmd("continue") @@ -97,8 +101,10 @@ self.expect("frame variable -t", VARIABLES_DISPLAYED_CORRECTLY, startstr = "(long int) i = 33") - # TODO: # Now set variable 'i' and check that it is correctly displayed. + self.runCmd("expression i = 33333") + self.expect("frame variable -t", VARIABLES_DISPLAYED_CORRECTLY, + startstr = "(long int) i = 33333") self.runCmd("continue") @@ -107,8 +113,10 @@ self.expect("frame variable -t", VARIABLES_DISPLAYED_CORRECTLY, startstr = "(double) i = 3.14159") - # TODO: # Now set variable 'i' and check that it is correctly displayed. + self.runCmd("expression i = 3.14") + self.expect("frame variable -t", VARIABLES_DISPLAYED_CORRECTLY, + startstr = "(double) i = 3.14") self.runCmd("continue") @@ -119,8 +127,10 @@ self.expect("frame variable -t", VARIABLES_DISPLAYED_CORRECTLY, startstr = "(long double) i = 3.14159") - # TODO: # Now set variable 'i' and check that it is correctly displayed. + self.runCmd("expression i = 3.1") + self.expect("frame variable -t", VARIABLES_DISPLAYED_CORRECTLY, + startstr = "(long double) i = 3.1") if __name__ == '__main__': From gclayton at apple.com Fri Nov 12 21:52:48 2010 From: gclayton at apple.com (Greg Clayton) Date: Sat, 13 Nov 2010 03:52:48 -0000 Subject: [Lldb-commits] [lldb] r118976 - in /lldb/trunk: include/lldb/ include/lldb/Core/ include/lldb/Expression/ include/lldb/Symbol/ lldb.xcodeproj/ source/Commands/ source/Core/ source/Expression/ source/Plugins/ABI/MacOSX-i386/ source/Plugins/ABI/SysV-x86_64/ source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/ source/Plugins/SymbolFile/DWARF/ source/Plugins/SymbolFile/Symtab/ source/Symbol/ source/Target/ Message-ID: <20101113035248.A3E2D2A6C12C@llvm.org> Author: gclayton Date: Fri Nov 12 21:52:47 2010 New Revision: 118976 URL: http://llvm.org/viewvc/llvm-project?rev=118976&view=rev Log: Modified the lldb_private::Type clang type resolving code to handle three cases when getting the clang type: - need only a forward declaration - need a clang type that can be used for layout (members and args/return types) - need a full clang type This allows us to partially parse the clang types and be as lazy as possible. The first case is when we just need to declare a type and we will complete it later. The forward declaration happens only for class/union/structs and enums. The layout type allows us to resolve the full clang type _except_ if we have any modifiers on a pointer or reference (both R and L value). In this case when we are adding members or function args or return types, we only need to know how the type will be laid out and we can defer completing the pointee type until we later need it. The last type means we need a full definition for the clang type. Did some renaming of some enumerations to get rid of the old "DC" prefix (which stands for DebugCore which is no longer around). Modified the clang namespace support to be almost ready to be fed to the expression parser. I made a new ClangNamespaceDecl class that can carry around the AST and the namespace decl so we can copy it into the expression AST. I modified the symbol vendor and symbol file plug-ins to use this new class. Added: lldb/trunk/include/lldb/Symbol/ClangNamespaceDecl.h lldb/trunk/source/Symbol/ClangNamespaceDecl.cpp Modified: lldb/trunk/include/lldb/Core/ConstString.h lldb/trunk/include/lldb/Core/Value.h lldb/trunk/include/lldb/Expression/ClangExpressionDeclMap.h lldb/trunk/include/lldb/Symbol/ClangASTContext.h lldb/trunk/include/lldb/Symbol/SymbolContext.h lldb/trunk/include/lldb/Symbol/SymbolFile.h lldb/trunk/include/lldb/Symbol/SymbolVendor.h lldb/trunk/include/lldb/Symbol/Type.h lldb/trunk/include/lldb/lldb-forward.h lldb/trunk/lldb.xcodeproj/project.pbxproj lldb/trunk/source/Commands/CommandObjectArgs.cpp lldb/trunk/source/Commands/CommandObjectCall.cpp lldb/trunk/source/Core/Value.cpp lldb/trunk/source/Core/ValueObject.cpp lldb/trunk/source/Core/ValueObjectChild.cpp lldb/trunk/source/Core/ValueObjectConstResult.cpp lldb/trunk/source/Core/ValueObjectRegister.cpp lldb/trunk/source/Core/ValueObjectVariable.cpp lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp lldb/trunk/source/Expression/ClangExpressionVariable.cpp lldb/trunk/source/Expression/ClangFunction.cpp lldb/trunk/source/Expression/DWARFExpression.cpp lldb/trunk/source/Plugins/ABI/MacOSX-i386/ABIMacOSX_i386.cpp lldb/trunk/source/Plugins/ABI/SysV-x86_64/ABISysV_x86_64.cpp lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.cpp lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTrampolineHandler.cpp lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h lldb/trunk/source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.cpp lldb/trunk/source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.h lldb/trunk/source/Symbol/ClangASTContext.cpp lldb/trunk/source/Symbol/Function.cpp lldb/trunk/source/Symbol/SymbolContext.cpp lldb/trunk/source/Symbol/SymbolVendor.cpp lldb/trunk/source/Symbol/Type.cpp lldb/trunk/source/Target/ThreadPlanTracer.cpp Modified: lldb/trunk/include/lldb/Core/ConstString.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/ConstString.h?rev=118976&r1=118975&r2=118976&view=diff ============================================================================== --- lldb/trunk/include/lldb/Core/ConstString.h (original) +++ lldb/trunk/include/lldb/Core/ConstString.h Fri Nov 12 21:52:47 2010 @@ -134,8 +134,8 @@ /// @endcode /// /// @return - /// A pointer to this object if the string isn't empty, NULL - /// otherwise. + /// /b True this object contains a valid non-empty C string, \b + /// false otherwise. //------------------------------------------------------------------ operator bool() const { Modified: lldb/trunk/include/lldb/Core/Value.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/Value.h?rev=118976&r1=118975&r2=118976&view=diff ============================================================================== --- lldb/trunk/include/lldb/Core/Value.h (original) +++ lldb/trunk/include/lldb/Core/Value.h Fri Nov 12 21:52:47 2010 @@ -44,10 +44,10 @@ // m_context contains... // ==================== eContextTypeInvalid, // undefined - eContextTypeOpaqueClangQualType,// void * (an opaque clang::QualType * that can be fed to "static QualType QualType::getFromOpaquePtr(void *)") - eContextTypeDCRegisterInfo, // lldb::RegisterInfo * - eContextTypeDCType, // Type * - eContextTypeDCVariable, // Variable * + eContextTypeClangType, // void * (an opaque clang::QualType * that can be fed to "static QualType QualType::getFromOpaquePtr(void *)") + eContextTypeRegisterInfo, // lldb::RegisterInfo * + eContextTypeLLDBType, // lldb_private::Type * + eContextTypeVariable, // lldb_private::Variable * eContextTypeValue // Value * (making this a proxy value. Used when putting locals on the DWARF expression parser stack) }; Modified: lldb/trunk/include/lldb/Expression/ClangExpressionDeclMap.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Expression/ClangExpressionDeclMap.h?rev=118976&r1=118975&r2=118976&view=diff ============================================================================== --- lldb/trunk/include/lldb/Expression/ClangExpressionDeclMap.h (original) +++ lldb/trunk/include/lldb/Expression/ClangExpressionDeclMap.h Fri Nov 12 21:52:47 2010 @@ -93,6 +93,10 @@ const ConstString & GetPersistentResultName (); + clang::NamespaceDecl * + AddNamespace (NameSearchContext &context, + const ClangNamespaceDecl &namespace_decl); + //------------------------------------------------------------------ /// [Used by IRForTarget] Add a variable to the list of persistent /// variables for the process. Modified: lldb/trunk/include/lldb/Symbol/ClangASTContext.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Symbol/ClangASTContext.h?rev=118976&r1=118975&r2=118976&view=diff ============================================================================== --- lldb/trunk/include/lldb/Symbol/ClangASTContext.h (original) +++ lldb/trunk/include/lldb/Symbol/ClangASTContext.h Fri Nov 12 21:52:47 2010 @@ -144,6 +144,11 @@ clang::ASTContext *source_context, lldb::clang_type_t clang_type); + static clang::Decl * + CopyDecl (clang::ASTContext *dest_context, + clang::ASTContext *source_context, + clang::Decl *source_decl); + static bool AreTypesSame(clang::ASTContext *ast_context, lldb::clang_type_t type1, Added: lldb/trunk/include/lldb/Symbol/ClangNamespaceDecl.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Symbol/ClangNamespaceDecl.h?rev=118976&view=auto ============================================================================== --- lldb/trunk/include/lldb/Symbol/ClangNamespaceDecl.h (added) +++ lldb/trunk/include/lldb/Symbol/ClangNamespaceDecl.h Fri Nov 12 21:52:47 2010 @@ -0,0 +1,100 @@ +//===-- ClangNamespaceDecl.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_ClangNamespaceDecl_h_ +#define liblldb_ClangNamespaceDecl_h_ + +#include "lldb/lldb-include.h" +#include "lldb/Core/ClangForward.h" + +namespace lldb_private { + +class ClangNamespaceDecl +{ +public: + ClangNamespaceDecl () : + m_ast (NULL), + m_namespace_decl (NULL) + { + } + + ClangNamespaceDecl (clang::ASTContext *ast, clang::NamespaceDecl *namespace_decl) : + m_ast (ast), + m_namespace_decl (namespace_decl) + { + } + + ClangNamespaceDecl (const ClangNamespaceDecl &rhs) : + m_ast (rhs.m_ast), + m_namespace_decl (rhs.m_namespace_decl) + { + } + + const ClangNamespaceDecl & + operator = (const ClangNamespaceDecl &rhs) + { + m_ast = rhs.m_ast; + m_namespace_decl = rhs.m_namespace_decl; + return *this; + } + + //------------------------------------------------------------------ + /// Convert to bool operator. + /// + /// This allows code to check a ClangNamespaceDecl object to see if + /// it contains a valid namespace decl using code such as: + /// + /// @code + /// ClangNamespaceDecl ns_decl(...); + /// if (ns_decl) + /// { ... + /// @endcode + /// + /// @return + /// /b True this object contains a valid namespace decl, \b + /// false otherwise. + //------------------------------------------------------------------ + operator bool() const + { + return m_ast != NULL && m_namespace_decl != NULL; + } + + clang::ASTContext * + GetASTContext() const + { + return m_ast; + } + + void + SetASTContext (clang::ASTContext *ast) + { + m_ast = ast; + } + + clang::NamespaceDecl * + GetNamespaceDecl () const + { + return m_namespace_decl; + } + + void + SetNamespaceDecl (clang::NamespaceDecl *namespace_decl) + { + m_namespace_decl = namespace_decl; + } + +protected: + clang::ASTContext *m_ast; + clang::NamespaceDecl *m_namespace_decl; +}; + + +} // namespace lldb_private + +#endif // #ifndef liblldb_ClangNamespaceDecl_h_ Modified: lldb/trunk/include/lldb/Symbol/SymbolContext.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Symbol/SymbolContext.h?rev=118976&r1=118975&r2=118976&view=diff ============================================================================== --- lldb/trunk/include/lldb/Symbol/SymbolContext.h (original) +++ lldb/trunk/include/lldb/Symbol/SymbolContext.h Fri Nov 12 21:52:47 2010 @@ -15,6 +15,7 @@ #include "lldb/lldb-private.h" #include "lldb/Core/Address.h" +#include "lldb/Symbol/ClangASTType.h" #include "lldb/Symbol/LineEntry.h" namespace lldb_private { @@ -208,6 +209,10 @@ bool append, SymbolContextList &sc_list) const; + + ClangNamespaceDecl + FindNamespace (const ConstString &name) const; + //------------------------------------------------------------------ /// Find a variable matching the given name, working out from this /// symbol context. @@ -215,8 +220,8 @@ /// @return /// A shared pointer to the variable found. //------------------------------------------------------------------ - lldb::VariableSP - FindVariableByName (const char *name) const; + //lldb::VariableSP + //FindVariableByName (const char *name) const; //------------------------------------------------------------------ /// Find a type matching the given name, working out from this Modified: lldb/trunk/include/lldb/Symbol/SymbolFile.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Symbol/SymbolFile.h?rev=118976&r1=118975&r2=118976&view=diff ============================================================================== --- lldb/trunk/include/lldb/Symbol/SymbolFile.h (original) +++ lldb/trunk/include/lldb/Symbol/SymbolFile.h Fri Nov 12 21:52:47 2010 @@ -12,6 +12,8 @@ #include "lldb/lldb-private.h" #include "lldb/Core/PluginInterface.h" +#include "lldb/Symbol/ClangASTType.h" +#include "lldb/Symbol/ClangNamespaceDecl.h" #include "lldb/Symbol/Type.h" namespace lldb_private { @@ -81,7 +83,7 @@ virtual uint32_t FindTypes (const SymbolContext& sc, const ConstString &name, bool append, uint32_t max_matches, TypeList& types) = 0; // virtual uint32_t FindTypes (const SymbolContext& sc, const RegularExpression& regex, bool append, uint32_t max_matches, TypeList& types) = 0; virtual TypeList * GetTypeList (); - virtual clang::NamespaceDecl * + virtual ClangNamespaceDecl FindNamespace (const SymbolContext& sc, const ConstString &name) = 0; Modified: lldb/trunk/include/lldb/Symbol/SymbolVendor.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Symbol/SymbolVendor.h?rev=118976&r1=118975&r2=118976&view=diff ============================================================================== --- lldb/trunk/include/lldb/Symbol/SymbolVendor.h (original) +++ lldb/trunk/include/lldb/Symbol/SymbolVendor.h Fri Nov 12 21:52:47 2010 @@ -16,6 +16,7 @@ #include "lldb/Core/ModuleChild.h" #include "lldb/Core/PluginInterface.h" #include "lldb/Host/Mutex.h" +#include "lldb/Symbol/ClangNamespaceDecl.h" #include "lldb/Symbol/TypeList.h" @@ -126,12 +127,9 @@ uint32_t max_matches, TypeList& types); -// virtual uint32_t -// FindTypes (const SymbolContext& sc, -// const RegularExpression& regex, -// bool append, -// uint32_t max_matches, -// TypeList& types); + virtual lldb_private::ClangNamespaceDecl + FindNamespace (const SymbolContext& sc, + const ConstString &name); virtual uint32_t GetNumCompileUnits(); Modified: lldb/trunk/include/lldb/Symbol/Type.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Symbol/Type.h?rev=118976&r1=118975&r2=118976&view=diff ============================================================================== --- lldb/trunk/include/lldb/Symbol/Type.h (original) +++ lldb/trunk/include/lldb/Symbol/Type.h Fri Nov 12 21:52:47 2010 @@ -21,10 +21,10 @@ class Type : public UserID { public: - typedef enum + typedef enum EncodingDataTypeTag { eEncodingInvalid, - eEncodingIsUID, ///< This type is the type whose UID is m_encoding_uid + eEncodingIsUID, ///< This type is the type whose UID is m_encoding_uid eEncodingIsConstUID, ///< This type is the type whose UID is m_encoding_uid with the const qualifier added eEncodingIsRestrictUID, ///< This type is the type whose UID is m_encoding_uid with the restrict qualifier added eEncodingIsVolatileUID, ///< This type is the type whose UID is m_encoding_uid with the volatile qualifier added @@ -35,6 +35,14 @@ eEncodingIsSyntheticUID } EncodingDataType; + typedef enum ResolveStateTag + { + eResolveStateUnresolved = 0, + eResolveStateForward = 1, + eResolveStateLayout = 2, + eResolveStateFull = 3 + } ResolveState; + Type (lldb::user_id_t uid, SymbolFile* symbol_file, const ConstString &name, @@ -44,7 +52,7 @@ EncodingDataType encoding_type, const Declaration& decl, lldb::clang_type_t clang_qual_type, - bool is_forward_decl); + ResolveState clang_type_resolve_state); // This makes an invalid type. Used for functions that return a Type when they // get an error. @@ -177,6 +185,12 @@ lldb::clang_type_t GetClangType (); + // Get the clang type, and resolve definitions enough so that the type could + // have layout performed. This allows ptrs and refs to class/struct/union/enum + // types remain forward declarations. + lldb::clang_type_t + GetClangLayoutType (); + // Get the clang type and leave class/struct/union/enum types as forward // declarations if they haven't already been fully defined. lldb::clang_type_t @@ -203,6 +217,12 @@ static int Compare(const Type &a, const Type &b); + void + SetEncodingType (Type *encoding_type) + { + m_encoding_type = encoding_type; + } + protected: ConstString m_name; SymbolFile *m_symbol_file; @@ -213,14 +233,12 @@ uint32_t m_byte_size; Declaration m_decl; lldb::clang_type_t m_clang_type; - bool m_is_forward_decl:1, - m_encoding_type_forward_decl_resolved:1, - m_encoding_type_decl_resolved:1; + ResolveState m_clang_type_resolve_state; Type * GetEncodingType (); - bool ResolveClangType(bool forward_decl_is_ok = false); + bool ResolveClangType (ResolveState clang_type_resolve_state); }; } // namespace lldb_private Modified: lldb/trunk/include/lldb/lldb-forward.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/lldb-forward.h?rev=118976&r1=118975&r2=118976&view=diff ============================================================================== --- lldb/trunk/include/lldb/lldb-forward.h (original) +++ lldb/trunk/include/lldb/lldb-forward.h Fri Nov 12 21:52:47 2010 @@ -41,6 +41,8 @@ class Broadcaster; class CPPLanguageRuntime; class ClangASTContext; +class ClangASTType; +class ClangNamespaceDecl; class ClangExpression; class ClangExpressionDeclMap; class ClangExpressionVariable; Modified: lldb/trunk/lldb.xcodeproj/project.pbxproj URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/lldb.xcodeproj/project.pbxproj?rev=118976&r1=118975&r2=118976&view=diff ============================================================================== --- lldb/trunk/lldb.xcodeproj/project.pbxproj (original) +++ lldb/trunk/lldb.xcodeproj/project.pbxproj Fri Nov 12 21:52:47 2010 @@ -63,6 +63,8 @@ 26680336116005EF008E1FE4 /* SBBreakpointLocation.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9AF16CC7114086A1007A7B3F /* SBBreakpointLocation.cpp */; }; 26680337116005F1008E1FE4 /* SBBreakpoint.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9AF16A9C11402D5B007A7B3F /* SBBreakpoint.cpp */; }; 2668035C11601108008E1FE4 /* LLDB.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 26680207115FD0ED008E1FE4 /* LLDB.framework */; }; + 266A42D6128E3FFB0090CF7C /* ClangNamespaceDecl.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 266A42D5128E3FFB0090CF7C /* ClangNamespaceDecl.cpp */; }; + 266A42D8128E40040090CF7C /* ClangNamespaceDecl.h in Headers */ = {isa = PBXBuildFile; fileRef = 266A42D7128E40040090CF7C /* ClangNamespaceDecl.h */; }; 268F9D53123AA15200B91E9B /* SBSymbolContextList.h in Headers */ = {isa = PBXBuildFile; fileRef = 268F9D52123AA15200B91E9B /* SBSymbolContextList.h */; settings = {ATTRIBUTES = (Public, ); }; }; 268F9D55123AA16600B91E9B /* SBSymbolContextList.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 268F9D54123AA16600B91E9B /* SBSymbolContextList.cpp */; }; 26B42B1F1187A92B0079C8C8 /* lldb-include.h in Headers */ = {isa = PBXBuildFile; fileRef = 26B42B1E1187A92B0079C8C8 /* lldb-include.h */; settings = {ATTRIBUTES = (Public, ); }; }; @@ -567,6 +569,8 @@ 266960611199F4230075C61A /* edit-swig-python-wrapper-file.py */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.script.python; path = "edit-swig-python-wrapper-file.py"; sourceTree = ""; }; 266960621199F4230075C61A /* finish-swig-Python-lldb.sh */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.script.sh; path = "finish-swig-Python-lldb.sh"; sourceTree = ""; }; 266960631199F4230075C61A /* sed-sources */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.script.perl; path = "sed-sources"; sourceTree = ""; }; + 266A42D5128E3FFB0090CF7C /* ClangNamespaceDecl.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = ClangNamespaceDecl.cpp; path = source/Symbol/ClangNamespaceDecl.cpp; sourceTree = ""; }; + 266A42D7128E40040090CF7C /* ClangNamespaceDecl.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ClangNamespaceDecl.h; path = include/lldb/Symbol/ClangNamespaceDecl.h; sourceTree = ""; }; 2672D8461189055500FF4019 /* CommandObjectFrame.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = CommandObjectFrame.cpp; path = source/Commands/CommandObjectFrame.cpp; sourceTree = ""; }; 2672D8471189055500FF4019 /* CommandObjectFrame.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CommandObjectFrame.h; path = source/Commands/CommandObjectFrame.h; sourceTree = ""; }; 2676A093119C93C8008A98EF /* StringExtractorGDBRemote.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = StringExtractorGDBRemote.cpp; path = source/Utility/StringExtractorGDBRemote.cpp; sourceTree = ""; }; @@ -1783,6 +1787,8 @@ 26BC7F1410F1B8EC00F91463 /* ClangASTContext.cpp */, 49E45FA911F660DC008F7B28 /* ClangASTType.h */, 49E45FAD11F660FE008F7B28 /* ClangASTType.cpp */, + 266A42D7128E40040090CF7C /* ClangNamespaceDecl.h */, + 266A42D5128E3FFB0090CF7C /* ClangNamespaceDecl.cpp */, 26BC7C5710F1B6E900F91463 /* CompileUnit.h */, 26BC7F1510F1B8EC00F91463 /* CompileUnit.cpp */, 26BC7C5810F1B6E900F91463 /* Declaration.h */, @@ -2374,6 +2380,7 @@ 4C61978D12823D4300FAFFCC /* AppleObjCRuntime.h in Headers */, 4C61978F12823D4300FAFFCC /* AppleObjCRuntimeV1.h in Headers */, 4CC2A14D128C7409001531C4 /* ThreadPlanTracer.h in Headers */, + 266A42D8128E40040090CF7C /* ClangNamespaceDecl.h in Headers */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -2445,6 +2452,7 @@ isa = PBXProject; buildConfigurationList = 1DEB91EF08733DB70010E9CD /* Build configuration list for PBXProject "lldb" */; compatibilityVersion = "Xcode 3.1"; + developmentRegion = English; hasScannedForEncodings = 1; knownRegions = ( en, @@ -2876,6 +2884,7 @@ 4C61978C12823D4300FAFFCC /* AppleObjCRuntime.cpp in Sources */, 4C61978E12823D4300FAFFCC /* AppleObjCRuntimeV1.cpp in Sources */, 4CC2A149128C73ED001531C4 /* ThreadPlanTracer.cpp in Sources */, + 266A42D6128E3FFB0090CF7C /* ClangNamespaceDecl.cpp in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -2933,7 +2942,6 @@ GCC_WARN_ABOUT_RETURN_TYPE = YES; GCC_WARN_HIDDEN_VIRTUAL_FUNCTIONS = YES; GCC_WARN_UNUSED_VARIABLE = YES; - ONLY_ACTIVE_ARCH = YES; PREBINDING = NO; VALID_ARCHS = "x86_64 i386"; }; @@ -2964,7 +2972,6 @@ 26579F6A126A25920007C5CB /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { - ALWAYS_SEARCH_USER_PATHS = NO; COPY_PHASE_STRIP = NO; GCC_DYNAMIC_NO_PIC = NO; GCC_ENABLE_FIX_AND_CONTINUE = YES; Modified: lldb/trunk/source/Commands/CommandObjectArgs.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectArgs.cpp?rev=118976&r1=118975&r2=118976&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectArgs.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectArgs.cpp Fri Nov 12 21:52:47 2010 @@ -249,7 +249,7 @@ return false; } - value.SetContext (Value::eContextTypeOpaqueClangQualType, type); + value.SetContext (Value::eContextTypeClangType, type); value_list.PushValue(value); } Modified: lldb/trunk/source/Commands/CommandObjectCall.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectCall.cpp?rev=118976&r1=118975&r2=118976&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectCall.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectCall.cpp Fri Nov 12 21:52:47 2010 @@ -257,7 +257,7 @@ void *cstr_type = exe_ctx.target->GetScratchClangASTContext()->GetCStringType(true); - val.SetContext (Value::eContextTypeOpaqueClangQualType, cstr_type); + val.SetContext (Value::eContextTypeClangType, cstr_type); value_list.PushValue(val); success = true; Modified: lldb/trunk/source/Core/Value.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/Value.cpp?rev=118976&r1=118975&r2=118976&view=diff ============================================================================== --- lldb/trunk/source/Core/Value.cpp (original) +++ lldb/trunk/source/Core/Value.cpp Fri Nov 12 21:52:47 2010 @@ -287,7 +287,7 @@ if (m_context_type == eContextTypeValue) return ((Value*)m_context)->GetRegisterInfo(); - if (m_context_type == eContextTypeDCRegisterInfo) + if (m_context_type == eContextTypeRegisterInfo) return static_cast (m_context); return NULL; } @@ -298,7 +298,7 @@ if (m_context_type == eContextTypeValue) return ((Value*)m_context)->GetType(); - if (m_context_type == eContextTypeDCType) + if (m_context_type == eContextTypeLLDBType) return static_cast (m_context); return NULL; } @@ -336,12 +336,12 @@ { default: case eContextTypeInvalid: - case eContextTypeOpaqueClangQualType: // clang::Type * - case eContextTypeDCRegisterInfo: // RegisterInfo * - case eContextTypeDCType: // Type * + case eContextTypeClangType: // clang::Type * + case eContextTypeRegisterInfo: // RegisterInfo * + case eContextTypeLLDBType: // Type * break; - case eContextTypeDCVariable: // Variable * + case eContextTypeVariable: // Variable * ResolveValue(exe_ctx, ast_context); return true; } @@ -365,7 +365,7 @@ error_ptr->SetErrorString ("Invalid context type, there is no way to know how much memory to read."); break; - case eContextTypeOpaqueClangQualType: + case eContextTypeClangType: if (ast_context == NULL) { if (error_ptr) @@ -378,7 +378,7 @@ } break; - case eContextTypeDCRegisterInfo: // RegisterInfo * + case eContextTypeRegisterInfo: // RegisterInfo * if (GetRegisterInfo()) byte_size = GetRegisterInfo()->byte_size; else if (error_ptr) @@ -386,14 +386,14 @@ break; - case eContextTypeDCType: // Type * + case eContextTypeLLDBType: // Type * if (GetType()) byte_size = GetType()->GetByteSize(); else if (error_ptr) error_ptr->SetErrorString ("Can't determine byte size with NULL Type *."); break; - case eContextTypeDCVariable: // Variable * + case eContextTypeVariable: // Variable * if (GetVariable()) byte_size = GetVariable()->GetType()->GetByteSize(); else if (error_ptr) @@ -428,18 +428,18 @@ case eContextTypeInvalid: break; - case eContextTypeOpaqueClangQualType: + case eContextTypeClangType: return m_context; - case eContextTypeDCRegisterInfo: + case eContextTypeRegisterInfo: break; // TODO: Eventually convert into a clang type? - case eContextTypeDCType: + case eContextTypeLLDBType: if (GetType()) return GetType()->GetClangType(); break; - case eContextTypeDCVariable: + case eContextTypeVariable: if (GetVariable()) return GetVariable()->GetType()->GetClangType(); break; @@ -460,20 +460,20 @@ case eContextTypeInvalid: break; - case eContextTypeOpaqueClangQualType: + case eContextTypeClangType: return ClangASTType::GetFormat (m_context); - case eContextTypeDCRegisterInfo: + case eContextTypeRegisterInfo: if (GetRegisterInfo()) return GetRegisterInfo()->format; break; - case eContextTypeDCType: + case eContextTypeLLDBType: if (GetType()) return GetType()->GetFormat(); break; - case eContextTypeDCVariable: + case eContextTypeVariable: if (GetVariable()) return GetVariable()->GetType()->GetFormat(); break; @@ -669,7 +669,7 @@ } } - if (m_context_type == eContextTypeOpaqueClangQualType) + if (m_context_type == eContextTypeClangType) { void *opaque_clang_qual_type = GetClangType(); switch (m_value_type) @@ -731,7 +731,7 @@ if (m_context_type == eContextTypeValue) return ((Value*)m_context)->GetVariable(); - if (m_context_type == eContextTypeDCVariable) + if (m_context_type == eContextTypeVariable) return static_cast (m_context); return NULL; } @@ -757,10 +757,10 @@ switch (context_type) { case eContextTypeInvalid: return "invalid"; - case eContextTypeOpaqueClangQualType: return "clang::Type *"; - case eContextTypeDCRegisterInfo: return "RegisterInfo *"; - case eContextTypeDCType: return "Type *"; - case eContextTypeDCVariable: return "Variable *"; + case eContextTypeClangType: return "clang::Type *"; + case eContextTypeRegisterInfo: return "RegisterInfo *"; + case eContextTypeLLDBType: return "Type *"; + case eContextTypeVariable: return "Variable *"; case eContextTypeValue: return "Value"; // TODO: Sean, more description here? }; return "???"; Modified: lldb/trunk/source/Core/ValueObject.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/ValueObject.cpp?rev=118976&r1=118975&r2=118976&view=diff ============================================================================== --- lldb/trunk/source/Core/ValueObject.cpp (original) +++ lldb/trunk/source/Core/ValueObject.cpp Fri Nov 12 21:52:47 2010 @@ -179,7 +179,7 @@ break; case Value::eValueTypeScalar: - if (m_value.GetContextType() == Value::eContextTypeDCRegisterInfo) + if (m_value.GetContextType() == Value::eContextTypeRegisterInfo) { RegisterInfo *reg_info = m_value.GetRegisterInfo(); if (reg_info) @@ -611,9 +611,9 @@ switch (context_type) { - case Value::eContextTypeOpaqueClangQualType: - case Value::eContextTypeDCType: - case Value::eContextTypeDCVariable: + case Value::eContextTypeClangType: + case Value::eContextTypeLLDBType: + case Value::eContextTypeVariable: { clang_type_t clang_type = GetClangType (); if (clang_type) @@ -638,7 +638,7 @@ } break; - case Value::eContextTypeDCRegisterInfo: + case Value::eContextTypeRegisterInfo: { const RegisterInfo *reg_info = m_value.GetRegisterInfo(); if (reg_info) Modified: lldb/trunk/source/Core/ValueObjectChild.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/ValueObjectChild.cpp?rev=118976&r1=118975&r2=118976&view=diff ============================================================================== --- lldb/trunk/source/Core/ValueObjectChild.cpp (original) +++ lldb/trunk/source/Core/ValueObjectChild.cpp Fri Nov 12 21:52:47 2010 @@ -135,7 +135,7 @@ { if (parent->UpdateValueIfNeeded(exe_scope)) { - m_value.SetContext(Value::eContextTypeOpaqueClangQualType, m_clang_type); + m_value.SetContext(Value::eContextTypeClangType, m_clang_type); // Copy the parent scalar value and the scalar value type m_value.GetScalar() = parent->GetValue().GetScalar(); Modified: lldb/trunk/source/Core/ValueObjectConstResult.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/ValueObjectConstResult.cpp?rev=118976&r1=118975&r2=118976&view=diff ============================================================================== --- lldb/trunk/source/Core/ValueObjectConstResult.cpp (original) +++ lldb/trunk/source/Core/ValueObjectConstResult.cpp Fri Nov 12 21:52:47 2010 @@ -44,7 +44,7 @@ m_data.SetData(data_sp); m_value.GetScalar() = (uintptr_t)data_sp->GetBytes(); m_value.SetValueType(Value::eValueTypeHostAddress); - m_value.SetContext(Value::eContextTypeOpaqueClangQualType, clang_type); + m_value.SetContext(Value::eContextTypeClangType, clang_type); m_name = name; SetIsConstant (); SetValueIsValid(true); Modified: lldb/trunk/source/Core/ValueObjectRegister.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/ValueObjectRegister.cpp?rev=118976&r1=118975&r2=118976&view=diff ============================================================================== --- lldb/trunk/source/Core/ValueObjectRegister.cpp (original) +++ lldb/trunk/source/Core/ValueObjectRegister.cpp Fri Nov 12 21:52:47 2010 @@ -319,7 +319,7 @@ { if (m_reg_ctx->ReadRegisterBytes (m_reg_num, m_data)) { - m_value.SetContext(Value::eContextTypeDCRegisterInfo, (void *)m_reg_info); + m_value.SetContext(Value::eContextTypeRegisterInfo, (void *)m_reg_info); m_value.SetValueType(Value::eValueTypeHostAddress); m_value.GetScalar() = (uintptr_t)m_data.GetDataStart(); SetValueIsValid (true); Modified: lldb/trunk/source/Core/ValueObjectVariable.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/ValueObjectVariable.cpp?rev=118976&r1=118975&r2=118976&view=diff ============================================================================== --- lldb/trunk/source/Core/ValueObjectVariable.cpp (original) +++ lldb/trunk/source/Core/ValueObjectVariable.cpp Fri Nov 12 21:52:47 2010 @@ -120,7 +120,7 @@ Value old_value(m_value); if (expr.Evaluate (&exe_ctx, GetClangAST(), loclist_base_load_addr, NULL, m_value, &m_error)) { - m_value.SetContext(Value::eContextTypeDCVariable, variable); + m_value.SetContext(Value::eContextTypeVariable, variable); Value::ValueType value_type = m_value.GetValueType(); @@ -184,7 +184,7 @@ // Copy the Value and set the context to use our Variable // so it can extract read its value into m_data appropriately Value value(m_value); - value.SetContext(Value::eContextTypeDCVariable, variable); + value.SetContext(Value::eContextTypeVariable, variable); m_error = value.GetValueAsData(&exe_ctx, GetClangAST(), m_data, 0); } break; Modified: lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp?rev=118976&r1=118975&r2=118976&view=diff ============================================================================== --- lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp (original) +++ lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp Fri Nov 12 21:52:47 2010 @@ -23,6 +23,7 @@ #include "lldb/Expression/ClangASTSource.h" #include "lldb/Expression/ClangPersistentVariables.h" #include "lldb/Symbol/ClangASTContext.h" +#include "lldb/Symbol/ClangNamespaceDecl.h" #include "lldb/Symbol/CompileUnit.h" #include "lldb/Symbol/Function.h" #include "lldb/Symbol/ObjectFile.h" @@ -760,7 +761,7 @@ break; case Value::eValueTypeScalar: { - if (location_value->GetContextType() != Value::eContextTypeDCRegisterInfo) + if (location_value->GetContextType() != Value::eContextTypeRegisterInfo) { StreamString ss; @@ -1019,6 +1020,18 @@ else if (non_extern_symbol) AddOneFunction(context, NULL, non_extern_symbol); } + + ClangNamespaceDecl namespace_decl (m_sym_ctx.FindNamespace(name)); + if (namespace_decl) + { +// clang::NamespaceDecl *clang_namespace_decl = AddNamespace(context, namespace_decl); +// if (clang_namespace_decl) +// { +// // TODO: is this how we get the decl lookups to be called for +// // this namespace?? +// clang_namespace_decl->setHasExternalLexicalStorage(); +// } + } } } else @@ -1179,7 +1192,7 @@ type_to_use = var_opaque_type; if (var_location.get()->GetContextType() == Value::eContextTypeInvalid) - var_location.get()->SetContext(Value::eContextTypeOpaqueClangQualType, type_to_use); + var_location.get()->SetContext(Value::eContextTypeClangType, type_to_use); if (var_location.get()->GetValueType() == Value::eValueTypeFileAddress) { @@ -1279,6 +1292,19 @@ } } +clang::NamespaceDecl * +ClangExpressionDeclMap::AddNamespace (NameSearchContext &context, const ClangNamespaceDecl &namespace_decl) +{ + lldb::LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS)); + + + clang::Decl *copied_decl = ClangASTContext::CopyDecl (context.GetASTContext(), + namespace_decl.GetASTContext(), + namespace_decl.GetNamespaceDecl()); + + return dyn_cast(copied_decl); +} + void ClangExpressionDeclMap::AddOneFunction(NameSearchContext &context, Function* fun, Modified: lldb/trunk/source/Expression/ClangExpressionVariable.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/ClangExpressionVariable.cpp?rev=118976&r1=118975&r2=118976&view=diff ============================================================================== --- lldb/trunk/source/Expression/ClangExpressionVariable.cpp (original) +++ lldb/trunk/source/Expression/ClangExpressionVariable.cpp Fri Nov 12 21:52:47 2010 @@ -83,7 +83,7 @@ if (m_data_sp.get() == NULL) return false; - value.SetContext(Value::eContextTypeOpaqueClangQualType, m_user_type.GetOpaqueQualType()); + value.SetContext(Value::eContextTypeClangType, m_user_type.GetOpaqueQualType()); value.SetValueType(Value::eValueTypeHostAddress); value.GetScalar() = (uintptr_t)m_data_sp->GetBytes(); clang::ASTContext *ast_context = m_user_type.GetASTContext(); Modified: lldb/trunk/source/Expression/ClangFunction.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/ClangFunction.cpp?rev=118976&r1=118975&r2=118976&view=diff ============================================================================== --- lldb/trunk/source/Expression/ClangFunction.cpp (original) +++ lldb/trunk/source/Expression/ClangFunction.cpp Fri Nov 12 21:52:47 2010 @@ -327,7 +327,7 @@ // Special case: if it's a pointer, don't do anything (the ABI supports passing cstrings) if (arg_value->GetValueType() == Value::eValueTypeHostAddress && - arg_value->GetContextType() == Value::eContextTypeOpaqueClangQualType && + arg_value->GetContextType() == Value::eContextTypeClangType && ClangASTContext::IsPointerType(arg_value->GetClangType())) continue; @@ -421,7 +421,7 @@ uint32_t offset = 0; uint64_t return_integer = data.GetMaxU64(&offset, m_return_size); - ret_value.SetContext (Value::eContextTypeOpaqueClangQualType, m_function_return_qual_type); + ret_value.SetContext (Value::eContextTypeClangType, m_function_return_qual_type); ret_value.SetValueType(Value::eValueTypeScalar); ret_value.GetScalar() = return_integer; return true; Modified: lldb/trunk/source/Expression/DWARFExpression.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/DWARFExpression.cpp?rev=118976&r1=118975&r2=118976&view=diff ============================================================================== --- lldb/trunk/source/Expression/DWARFExpression.cpp (original) +++ lldb/trunk/source/Expression/DWARFExpression.cpp Fri Nov 12 21:52:47 2010 @@ -658,7 +658,7 @@ else { value.SetValueType (Value::eValueTypeScalar); - value.SetContext (Value::eContextTypeDCRegisterInfo, const_cast(reg_context->GetRegisterInfoAtIndex(native_reg))); + value.SetContext (Value::eContextTypeRegisterInfo, const_cast(reg_context->GetRegisterInfoAtIndex(native_reg))); if (reg_context->ReadRegisterValue (native_reg, value.GetScalar())) return true; @@ -2121,7 +2121,7 @@ return false; } - if (array_val.GetContextType() != Value::eContextTypeOpaqueClangQualType) + if (array_val.GetContextType() != Value::eContextTypeClangType) { if (error_ptr) error_ptr->SetErrorString("Arrays without Clang types are unhandled at this time."); @@ -2169,7 +2169,7 @@ Value member; - member.SetContext(Value::eContextTypeOpaqueClangQualType, member_type); + member.SetContext(Value::eContextTypeClangType, member_type); member.SetValueType(array_val.GetValueType()); addr_t array_base = (addr_t)array_val.GetScalar().ULongLong(LLDB_INVALID_ADDRESS); @@ -2212,7 +2212,7 @@ StreamString new_value(Stream::eBinary, 4, eByteOrderHost); switch (context_type) { - case Value::eContextTypeOpaqueClangQualType: + case Value::eContextTypeClangType: { void *clang_type = stack.back().GetClangType(); @@ -2427,7 +2427,7 @@ tmp = stack.back(); stack.pop_back(); - if (tmp.GetContextType() != Value::eContextTypeOpaqueClangQualType) + if (tmp.GetContextType() != Value::eContextTypeClangType) { if (error_ptr) error_ptr->SetErrorString("Item at top of expression stack must have a Clang type"); @@ -2450,7 +2450,7 @@ tmp.ResolveValue(exe_ctx, ast_context); tmp.SetValueType(value_type); - tmp.SetContext(Value::eContextTypeOpaqueClangQualType, target_type); + tmp.SetContext(Value::eContextTypeClangType, target_type); stack.push_back(tmp); } @@ -2483,7 +2483,7 @@ Value *proxy = expr_local_variable->CreateProxy(); stack.push_back(*proxy); delete proxy; - //stack.back().SetContext (Value::eContextTypeOpaqueClangQualType, expr_local_variable->GetClangType()); + //stack.back().SetContext (Value::eContextTypeClangType, expr_local_variable->GetClangType()); */ } break; @@ -2548,7 +2548,7 @@ else { void *clang_type = (void *)opcodes.GetMaxU64(&offset, sizeof(void*)); - stack.back().SetContext (Value::eContextTypeOpaqueClangQualType, clang_type); + stack.back().SetContext (Value::eContextTypeClangType, clang_type); } break; //---------------------------------------------------------------------- Modified: lldb/trunk/source/Plugins/ABI/MacOSX-i386/ABIMacOSX_i386.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ABI/MacOSX-i386/ABIMacOSX_i386.cpp?rev=118976&r1=118975&r2=118976&view=diff ============================================================================== --- lldb/trunk/source/Plugins/ABI/MacOSX-i386/ABIMacOSX_i386.cpp (original) +++ lldb/trunk/source/Plugins/ABI/MacOSX-i386/ABIMacOSX_i386.cpp Fri Nov 12 21:52:47 2010 @@ -234,7 +234,7 @@ { default: return false; - case Value::eContextTypeOpaqueClangQualType: + case Value::eContextTypeClangType: { void *val_type = val->GetClangType(); uint32_t cstr_length; @@ -433,7 +433,7 @@ { default: return false; - case Value::eContextTypeOpaqueClangQualType: + case Value::eContextTypeClangType: { void *value_type = value->GetClangType(); bool is_signed; @@ -472,7 +472,7 @@ { default: return false; - case Value::eContextTypeOpaqueClangQualType: + case Value::eContextTypeClangType: { // Extract the Clang AST context from the PC so that we can figure out type // sizes Modified: lldb/trunk/source/Plugins/ABI/SysV-x86_64/ABISysV_x86_64.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ABI/SysV-x86_64/ABISysV_x86_64.cpp?rev=118976&r1=118975&r2=118976&view=diff ============================================================================== --- lldb/trunk/source/Plugins/ABI/SysV-x86_64/ABISysV_x86_64.cpp (original) +++ lldb/trunk/source/Plugins/ABI/SysV-x86_64/ABISysV_x86_64.cpp Fri Nov 12 21:52:47 2010 @@ -304,7 +304,7 @@ { default: return false; - case Value::eContextTypeOpaqueClangQualType: + case Value::eContextTypeClangType: { void *value_type = value->GetClangType(); bool is_signed; @@ -347,7 +347,7 @@ { default: return false; - case Value::eContextTypeOpaqueClangQualType: + case Value::eContextTypeClangType: { void *value_type = value.GetClangType(); bool is_signed; Modified: lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.cpp?rev=118976&r1=118975&r2=118976&view=diff ============================================================================== --- lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.cpp (original) +++ lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.cpp Fri Nov 12 21:52:47 2010 @@ -97,7 +97,7 @@ void *opaque_type_ptr = ast_context->GetBuiltInType_objc_id(); if (opaque_type_ptr == NULL) opaque_type_ptr = ast_context->GetVoidPtrType(false); - value.SetContext(Value::eContextTypeOpaqueClangQualType, opaque_type_ptr); + value.SetContext(Value::eContextTypeClangType, opaque_type_ptr); } ValueList arg_value_list; @@ -109,7 +109,7 @@ void *return_qualtype = ast_context->GetCStringType(true); Value ret; - ret.SetContext(Value::eContextTypeOpaqueClangQualType, return_qualtype); + ret.SetContext(Value::eContextTypeClangType, return_qualtype); // Now we're ready to call the function: ClangFunction func(target_triple, ast_context, return_qualtype, *function_address, arg_value_list); Modified: lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTrampolineHandler.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTrampolineHandler.cpp?rev=118976&r1=118975&r2=118976&view=diff ============================================================================== --- lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTrampolineHandler.cpp (original) +++ lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTrampolineHandler.cpp Fri Nov 12 21:52:47 2010 @@ -74,15 +74,15 @@ } uint32_t offset_ptr = 0; - uint16_t header_size = data.GetU16(&offset_ptr); - uint16_t descriptor_size = data.GetU16(&offset_ptr); - size_t num_descriptors = data.GetU32(&offset_ptr); + const uint16_t header_size = data.GetU16(&offset_ptr); + const uint16_t descriptor_size = data.GetU16(&offset_ptr); + const size_t num_descriptors = data.GetU32(&offset_ptr); m_next_region = data.GetPointer(&offset_ptr); // If the header size is 0, that means we've come in too early before this data is set up. // Set ourselves as not valid, and continue. - if (header_size == 0) + if (header_size == 0 || num_descriptors == 0) { m_valid = false; return; @@ -100,8 +100,8 @@ // to compute it over and over. // Ingest the whole descriptor array: - lldb::addr_t desc_ptr = m_header_addr + header_size; - size_t desc_array_size = num_descriptors * descriptor_size; + const lldb::addr_t desc_ptr = m_header_addr + header_size; + const size_t desc_array_size = num_descriptors * descriptor_size; DataBufferSP data_sp(new DataBufferHeap (desc_array_size, '\0')); uint8_t* dst = (uint8_t*)data_sp->GetBytes(); @@ -291,7 +291,7 @@ Value input_value; void *clang_void_ptr_type = clang_ast_context->GetVoidPtrType(false); input_value.SetValueType (Value::eValueTypeScalar); - input_value.SetContext (Value::eContextTypeOpaqueClangQualType, clang_void_ptr_type); + input_value.SetContext (Value::eContextTypeClangType, clang_void_ptr_type); argument_values.PushValue(input_value); bool success = abi->GetArgumentValues (*(context->exe_ctx.thread), argument_values); @@ -515,7 +515,7 @@ Value input_value; void *clang_void_ptr_type = clang_ast_context->GetVoidPtrType(false); input_value.SetValueType (Value::eValueTypeScalar); - input_value.SetContext (Value::eContextTypeOpaqueClangQualType, clang_void_ptr_type); + input_value.SetContext (Value::eContextTypeClangType, clang_void_ptr_type); int obj_index; int sel_index; 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=118976&r1=118975&r2=118976&view=diff ============================================================================== --- lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp (original) +++ lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp Fri Nov 12 21:52:47 2010 @@ -1158,7 +1158,7 @@ accessibility = default_accessibility; member_accessibilities.push_back(accessibility); - GetClangASTContext().AddFieldToRecordType (class_clang_type, name, member_type->GetClangType(), accessibility, bit_size); + GetClangASTContext().AddFieldToRecordType (class_clang_type, name, member_type->GetClangLayoutType(), accessibility, bit_size); } } } @@ -1226,16 +1226,16 @@ } } - Type *base_class_dctype = ResolveTypeUID(encoding_uid); - assert(base_class_dctype); + Type *base_class_type = ResolveTypeUID(encoding_uid); + assert(base_class_type); if (class_language == eLanguageTypeObjC) { - GetClangASTContext().SetObjCSuperClass(class_clang_type, base_class_dctype->GetClangType()); + GetClangASTContext().SetObjCSuperClass(class_clang_type, base_class_type->GetClangType()); } else { - base_classes.push_back (GetClangASTContext().CreateBaseClassSpecifier (base_class_dctype->GetClangType(), accessibility, is_virtual, is_base_of_class)); + base_classes.push_back (GetClangASTContext().CreateBaseClassSpecifier (base_class_type->GetClangType(), accessibility, is_virtual, is_base_of_class)); assert(base_classes.back()); } } @@ -2100,36 +2100,42 @@ } -clang::NamespaceDecl * +ClangNamespaceDecl SymbolFileDWARF::FindNamespace (const SymbolContext& sc, const ConstString &name) { + ClangNamespaceDecl namespace_decl; DWARFDebugInfo* info = DebugInfo(); - if (info == NULL) - return 0; - - // Index if we already haven't to make sure the compile units - // get indexed and make their global DIE index list - if (!m_indexed) - Index (); - - DWARFCompileUnit* curr_cu = NULL; - DWARFCompileUnit* prev_cu = NULL; - const DWARFDebugInfoEntry* die = NULL; - std::vector die_info_array; - const size_t num_matches = m_namespace_index.Find (name, die_info_array); - for (size_t i=0; iGetCompileUnitAtIndex(die_info_array[i].cu_idx); - - if (curr_cu != prev_cu) - curr_cu->ExtractDIEsIfNeeded (false); + // Index if we already haven't to make sure the compile units + // get indexed and make their global DIE index list + if (!m_indexed) + Index (); + + DWARFCompileUnit* curr_cu = NULL; + DWARFCompileUnit* prev_cu = NULL; + const DWARFDebugInfoEntry* die = NULL; + std::vector die_info_array; + const size_t num_matches = m_namespace_index.Find (name, die_info_array); + for (size_t i=0; iGetCompileUnitAtIndex(die_info_array[i].cu_idx); + + if (curr_cu != prev_cu) + curr_cu->ExtractDIEsIfNeeded (false); - die = curr_cu->GetDIEAtIndexUnchecked(die_info_array[i].die_idx); + die = curr_cu->GetDIEAtIndexUnchecked(die_info_array[i].die_idx); - return ResolveNamespaceDIE (curr_cu, die); + clang::NamespaceDecl *clang_namespace_decl = ResolveNamespaceDIE (curr_cu, die); + if (clang_namespace_decl) + { + namespace_decl.SetASTContext (GetClangASTContext().getASTContext()); + namespace_decl.SetNamespaceDecl (clang_namespace_decl); + } + } } - return NULL; + return namespace_decl; } uint32_t @@ -2700,6 +2706,10 @@ DWARFDebugInfoEntry::Attributes attributes; const char *type_name_cstr = NULL; ConstString type_name_const_str; + Type::ResolveState resolve_state = Type::eResolveStateUnresolved; + size_t byte_size = 0; + Declaration decl; + Type::EncodingDataType encoding_data_type = Type::eEncodingIsUID; clang_type_t clang_type = NULL; @@ -2719,9 +2729,7 @@ m_die_to_type[die] = DIE_IS_BEING_PARSED; const size_t num_attributes = die->GetAttributes(this, dwarf_cu, NULL, attributes); - Declaration decl; uint32_t encoding = 0; - size_t byte_size = 0; lldb::user_id_t encoding_uid = LLDB_INVALID_UID; if (num_attributes > 0) @@ -2758,47 +2766,21 @@ switch (tag) { default: + break; + case DW_TAG_base_type: + resolve_state = Type::eResolveStateFull; clang_type = ast.GetBuiltinTypeForDWARFEncodingAndBitSize (type_name_cstr, encoding, byte_size * 8); break; - case DW_TAG_pointer_type: - // The encoding_uid will be embedded into the - // Type object and will be looked up when the Type::GetClangType() - encoding_data_type = Type::eEncodingIsPointerUID; - break; - - case DW_TAG_reference_type: - // The encoding_uid will be embedded into the - // Type object and will be looked up when the Type::GetClangType() - encoding_data_type = Type::eEncodingIsLValueReferenceUID; - break; - - case DW_TAG_typedef: - // The encoding_uid will be embedded into the - // Type object and will be looked up when the Type::GetClangType() - encoding_data_type = Type::eEncodingIsTypedefUID; - break; - - case DW_TAG_const_type: - // The encoding_uid will be embedded into the - // Type object and will be looked up when the Type::GetClangType() - encoding_data_type = Type::eEncodingIsConstUID; //ClangASTContext::AddConstModifier (clang_type); - break; - - case DW_TAG_restrict_type: - // The encoding_uid will be embedded into the - // Type object and will be looked up when the Type::GetClangType() - encoding_data_type = Type::eEncodingIsRestrictUID; //ClangASTContext::AddRestrictModifier (clang_type); - break; - - case DW_TAG_volatile_type: - // The encoding_uid will be embedded into the - // Type object and will be looked up when the Type::GetClangType() - encoding_data_type = Type::eEncodingIsVolatileUID; //ClangASTContext::AddVolatileModifier (clang_type); - break; + case DW_TAG_pointer_type: encoding_data_type = Type::eEncodingIsPointerUID; break; + case DW_TAG_reference_type: encoding_data_type = Type::eEncodingIsLValueReferenceUID; break; + case DW_TAG_typedef: encoding_data_type = Type::eEncodingIsTypedefUID; break; + case DW_TAG_const_type: encoding_data_type = Type::eEncodingIsConstUID; break; + case DW_TAG_restrict_type: encoding_data_type = Type::eEncodingIsRestrictUID; break; + case DW_TAG_volatile_type: encoding_data_type = Type::eEncodingIsVolatileUID; break; } if (type_name_cstr != NULL && sc.comp_unit != NULL && @@ -2811,14 +2793,18 @@ if (type_name_const_str == g_objc_type_name_id) { clang_type = ast.GetBuiltInType_objc_id(); + resolve_state = Type::eResolveStateFull; + } else if (type_name_const_str == g_objc_type_name_Class) { clang_type = ast.GetBuiltInType_objc_Class(); + resolve_state = Type::eResolveStateFull; } else if (type_name_const_str == g_objc_type_name_selector) { clang_type = ast.GetBuiltInType_objc_selector(); + resolve_state = Type::eResolveStateFull; } } @@ -2831,7 +2817,7 @@ encoding_data_type, &decl, clang_type, - clang_type == NULL)); + resolve_state)); m_die_to_type[die] = type_sp.get(); @@ -2853,10 +2839,8 @@ // Set a bit that lets us know that we are currently parsing this m_die_to_type[die] = DIE_IS_BEING_PARSED; - size_t byte_size = 0; LanguageType class_language = eLanguageTypeUnknown; //bool struct_is_class = false; - Declaration decl; const size_t num_attributes = die->GetAttributes(this, dwarf_cu, NULL, attributes); if (num_attributes > 0) { @@ -2974,7 +2958,6 @@ // parameters in any class methods need it for the clang // types for function prototypes. m_die_to_decl_ctx[die] = ClangASTContext::GetDeclContextForType (clang_type); - const bool is_forward_decl = die->HasChildren(); type_sp.reset (new Type (die->GetOffset(), this, type_name_const_str, @@ -2984,7 +2967,7 @@ Type::eEncodingIsUID, &decl, clang_type, - is_forward_decl)); + Type::eResolveStateForward)); m_die_to_type[die] = type_sp.get(); @@ -3013,9 +2996,7 @@ // Set a bit that lets us know that we are currently parsing this m_die_to_type[die] = DIE_IS_BEING_PARSED; - size_t byte_size = 0; lldb::user_id_t encoding_uid = DW_INVALID_OFFSET; - Declaration decl; const size_t num_attributes = die->GetAttributes(this, dwarf_cu, NULL, attributes); if (num_attributes > 0) @@ -3086,7 +3067,7 @@ Type::eEncodingIsUID, &decl, clang_type, - true)); + Type::eResolveStateForward)); m_die_to_type[die] = type_sp.get(); @@ -3111,7 +3092,6 @@ const char *mangled = NULL; dw_offset_t type_die_offset = DW_INVALID_OFFSET; - Declaration decl; bool is_variadic = false; bool is_inline = false; bool is_static = false; @@ -3202,7 +3182,7 @@ func_type = ResolveTypeUID(type_die_offset); if (func_type) - return_clang_type = func_type->GetClangForwardType(); + return_clang_type = func_type->GetClangLayoutType(); else return_clang_type = ast.GetBuiltInType_void(); @@ -3339,7 +3319,7 @@ Type::eEncodingIsUID, &decl, clang_type, - false)); + Type::eResolveStateFull)); m_die_to_type[die] = type_sp.get(); assert(type_sp.get()); @@ -3351,9 +3331,7 @@ // Set a bit that lets us know that we are currently parsing this m_die_to_type[die] = DIE_IS_BEING_PARSED; - size_t byte_size = 0; lldb::user_id_t type_die_offset = DW_INVALID_OFFSET; - Declaration decl; int64_t first_index = 0; uint32_t byte_stride = 0; uint32_t bit_stride = 0; @@ -3432,11 +3410,12 @@ empty_name, array_element_bit_stride / 8, NULL, - LLDB_INVALID_UID, + type_die_offset, Type::eEncodingIsUID, &decl, clang_type, - false)); + Type::eResolveStateFull)); + type_sp->SetEncodingType (element_type); m_die_to_type[die] = type_sp.get(); } } @@ -3471,14 +3450,14 @@ Type *pointee_type = ResolveTypeUID(type_die_offset); Type *class_type = ResolveTypeUID(containing_type_die_offset); - clang_type_t pointee_clang_type = pointee_type->GetClangType(); - clang_type_t class_clang_type = class_type->GetClangType(); + clang_type_t pointee_clang_type = pointee_type->GetClangForwardType(); + clang_type_t class_clang_type = class_type->GetClangLayoutType(); clang_type = ast.CreateMemberPointerType(pointee_clang_type, class_clang_type); - size_t byte_size = ClangASTType::GetClangTypeBitWidth (ast.getASTContext(), - clang_type) / 8; + byte_size = ClangASTType::GetClangTypeBitWidth (ast.getASTContext(), + clang_type) / 8; type_sp.reset( new Type (die->GetOffset(), this, @@ -3489,7 +3468,7 @@ Type::eEncodingIsUID, NULL, clang_type, - false)); + Type::eResolveStateForward)); m_die_to_type[die] = type_sp.get(); } 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=118976&r1=118975&r2=118976&view=diff ============================================================================== --- lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h (original) +++ lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h Fri Nov 12 21:52:47 2010 @@ -110,7 +110,7 @@ virtual uint32_t FindTypes (const lldb_private::SymbolContext& sc, const lldb_private::ConstString &name, bool append, uint32_t max_matches, lldb_private::TypeList& types); // virtual uint32_t FindTypes(const lldb_private::SymbolContext& sc, const lldb_private::RegularExpression& regex, bool append, uint32_t max_matches, lldb::Type::Encoding encoding, lldb::user_id_t udt_uid, lldb_private::TypeList& types); virtual lldb_private::TypeList *GetTypeList (); - virtual clang::NamespaceDecl * + virtual lldb_private::ClangNamespaceDecl FindNamespace (const lldb_private::SymbolContext& sc, const lldb_private::ConstString &name); Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp?rev=118976&r1=118975&r2=118976&view=diff ============================================================================== --- lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp (original) +++ lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp Fri Nov 12 21:52:47 2010 @@ -953,11 +953,11 @@ //} -clang::NamespaceDecl * +ClangNamespaceDecl SymbolFileDWARFDebugMap::FindNamespace (const lldb_private::SymbolContext& sc, const lldb_private::ConstString &name) { - clang::NamespaceDecl *matching_namespace = NULL; + ClangNamespaceDecl matching_namespace; SymbolFileDWARF *oso_dwarf; if (sc.comp_unit) Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h?rev=118976&r1=118975&r2=118976&view=diff ============================================================================== --- lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h (original) +++ lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h Fri Nov 12 21:52:47 2010 @@ -71,7 +71,7 @@ virtual uint32_t FindFunctions (const lldb_private::RegularExpression& regex, bool append, lldb_private::SymbolContextList& sc_list); virtual uint32_t FindTypes (const lldb_private::SymbolContext& sc, const lldb_private::ConstString &name, bool append, uint32_t max_matches, lldb_private::TypeList& types); // virtual uint32_t FindTypes (const lldb_private::SymbolContext& sc, const RegularExpression& regex, bool append, uint32_t max_matches, Type::Encoding encoding, lldb::user_id_t udt_uid, TypeList& types); - virtual clang::NamespaceDecl * + virtual lldb_private::ClangNamespaceDecl FindNamespace (const lldb_private::SymbolContext& sc, const lldb_private::ConstString &name); Modified: lldb/trunk/source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.cpp?rev=118976&r1=118975&r2=118976&view=diff ============================================================================== --- lldb/trunk/source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.cpp (original) +++ lldb/trunk/source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.cpp Fri Nov 12 21:52:47 2010 @@ -277,10 +277,10 @@ return NULL; } -clang::NamespaceDecl * +ClangNamespaceDecl SymbolFileSymtab::FindNamespace (const SymbolContext& sc, const ConstString &name) { - return NULL; + return ClangNamespaceDecl(); } uint32_t Modified: lldb/trunk/source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.h?rev=118976&r1=118975&r2=118976&view=diff ============================================================================== --- lldb/trunk/source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.h (original) +++ lldb/trunk/source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.h Fri Nov 12 21:52:47 2010 @@ -101,7 +101,7 @@ // virtual uint32_t // FindTypes(const lldb_private::SymbolContext& sc, const lldb_private::RegularExpression& regex, bool append, uint32_t max_matches, lldb_private::TypeList& types); - virtual clang::NamespaceDecl * + virtual lldb_private::ClangNamespaceDecl FindNamespace (const lldb_private::SymbolContext& sc, const lldb_private::ConstString &name); Modified: lldb/trunk/source/Symbol/ClangASTContext.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/ClangASTContext.cpp?rev=118976&r1=118975&r2=118976&view=diff ============================================================================== --- lldb/trunk/source/Symbol/ClangASTContext.cpp (original) +++ lldb/trunk/source/Symbol/ClangASTContext.cpp Fri Nov 12 21:52:47 2010 @@ -740,6 +740,23 @@ return dst.getAsOpaquePtr(); } + +clang::Decl * +ClangASTContext::CopyDecl (ASTContext *dest_context, + ASTContext *source_context, + clang::Decl *source_decl) +{ + // null_client's ownership is transferred to diagnostics + NullDiagnosticClient *null_client = new NullDiagnosticClient; + Diagnostic diagnostics(null_client); + FileManager file_manager; + ASTImporter importer(diagnostics, + *dest_context, file_manager, + *source_context, file_manager); + + return importer.Import(source_decl); +} + bool ClangASTContext::AreTypesSame(ASTContext *ast_context, clang_type_t type1, Added: lldb/trunk/source/Symbol/ClangNamespaceDecl.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/ClangNamespaceDecl.cpp?rev=118976&view=auto ============================================================================== --- lldb/trunk/source/Symbol/ClangNamespaceDecl.cpp (added) +++ lldb/trunk/source/Symbol/ClangNamespaceDecl.cpp Fri Nov 12 21:52:47 2010 @@ -0,0 +1,11 @@ +//===-- ClangNamespaceDecl.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/ClangNamespaceDecl.h" + Modified: lldb/trunk/source/Symbol/Function.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/Function.cpp?rev=118976&r1=118975&r2=118976&view=diff ============================================================================== --- lldb/trunk/source/Symbol/Function.cpp (original) +++ lldb/trunk/source/Symbol/Function.cpp Fri Nov 12 21:52:47 2010 @@ -413,8 +413,18 @@ CalculateSymbolContext (&sc); // Null out everything below the CompUnit 'cause we don't actually know these. - size_t bit_size = ClangASTType::GetClangTypeBitWidth ((GetType()->GetClangASTContext().getASTContext()), fun_return_qualtype.getAsOpaquePtr()); - Type return_type (0, GetType()->GetSymbolFile(), fun_return_name, bit_size, sc.comp_unit, 0, Type::eEncodingIsSyntheticUID, Declaration(), fun_return_qualtype.getAsOpaquePtr(), false); + size_t bit_size = ClangASTType::GetClangTypeBitWidth (GetType()->GetClangASTContext().getASTContext(), + fun_return_qualtype.getAsOpaquePtr()); + Type return_type (0, + GetType()->GetSymbolFile(), + fun_return_name, + bit_size, + sc.comp_unit, + 0, + Type::eEncodingIsSyntheticUID, + Declaration(), + fun_return_qualtype.getAsOpaquePtr(), + Type::eResolveStateFull); return return_type; } @@ -455,7 +465,16 @@ // Null out everything below the CompUnit 'cause we don't actually know these. size_t bit_size = ClangASTType::GetClangTypeBitWidth ((GetType()->GetClangASTContext().getASTContext()), arg_qualtype.getAsOpaquePtr()); - Type arg_type (0, GetType()->GetSymbolFile(), arg_return_name, bit_size, sc.comp_unit, 0, Type::eEncodingIsSyntheticUID, Declaration(), arg_qualtype.getAsOpaquePtr(), false); + Type arg_type (0, + GetType()->GetSymbolFile(), + arg_return_name, + bit_size, + sc.comp_unit, + 0, + Type::eEncodingIsSyntheticUID, + Declaration(), + arg_qualtype.getAsOpaquePtr(), + Type::eResolveStateFull); return arg_type; } Modified: lldb/trunk/source/Symbol/SymbolContext.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/SymbolContext.cpp?rev=118976&r1=118975&r2=118976&view=diff ============================================================================== --- lldb/trunk/source/Symbol/SymbolContext.cpp (original) +++ lldb/trunk/source/Symbol/SymbolContext.cpp Fri Nov 12 21:52:47 2010 @@ -400,6 +400,14 @@ return false; } +ClangNamespaceDecl +SymbolContext::FindNamespace (const ConstString &name) const +{ + ClangNamespaceDecl namespace_decl; + if (module_sp) + namespace_decl = module_sp->GetSymbolVendor()->FindNamespace (*this, name); + return namespace_decl; +} size_t SymbolContext::FindFunctionsByName (const ConstString &name, bool append, SymbolContextList &sc_list) const @@ -422,12 +430,12 @@ return sc_list.GetSize(); } -lldb::VariableSP -SymbolContext::FindVariableByName (const char *name) const -{ - lldb::VariableSP return_value; - return return_value; -} +//lldb::VariableSP +//SymbolContext::FindVariableByName (const char *name) const +//{ +// lldb::VariableSP return_value; +// return return_value; +//} lldb::TypeSP SymbolContext::FindTypeByName (const ConstString &name) const Modified: lldb/trunk/source/Symbol/SymbolVendor.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/SymbolVendor.cpp?rev=118976&r1=118975&r2=118976&view=diff ============================================================================== --- lldb/trunk/source/Symbol/SymbolVendor.cpp (original) +++ lldb/trunk/source/Symbol/SymbolVendor.cpp Fri Nov 12 21:52:47 2010 @@ -261,22 +261,16 @@ types.Clear(); return 0; } -// -//uint32_t -//SymbolVendor::FindTypes(const SymbolContext& sc, const RegularExpression& regex, bool append, uint32_t max_matches, Type::Encoding encoding, const char *udt_name, TypeList& types) -//{ -// Mutex::Locker locker(m_mutex); -// if (m_sym_file_ap.get()) -// { -// lldb::user_id_t udt_uid = LLDB_INVALID_UID; -// -// if (encoding == Type::user_defined_type) -// udt_uid = UserDefType::GetUserDefTypeUID(udt_name); -// -// return m_sym_file_ap->FindTypes(sc, regex, append, max_matches, encoding, udt_uid, types); -// } -// return 0; -//} + +ClangNamespaceDecl +SymbolVendor::FindNamespace(const SymbolContext& sc, const ConstString &name) +{ + Mutex::Locker locker(m_mutex); + ClangNamespaceDecl namespace_decl; + if (m_sym_file_ap.get()) + namespace_decl = m_sym_file_ap->FindNamespace (sc, name); + return namespace_decl; +} void SymbolVendor::Dump(Stream *s) Modified: lldb/trunk/source/Symbol/Type.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/Type.cpp?rev=118976&r1=118975&r2=118976&view=diff ============================================================================== --- lldb/trunk/source/Symbol/Type.cpp (original) +++ lldb/trunk/source/Symbol/Type.cpp Fri Nov 12 21:52:47 2010 @@ -39,7 +39,7 @@ EncodingDataType encoding_data_type, const Declaration& decl, clang_type_t clang_type, - bool is_forward_decl + ResolveState clang_type_resolve_state ) : UserID (uid), m_name (name), @@ -51,9 +51,7 @@ m_byte_size (byte_size), m_decl (decl), m_clang_type (clang_type), - m_is_forward_decl (is_forward_decl), - m_encoding_type_forward_decl_resolved (false), - m_encoding_type_decl_resolved (false) + m_clang_type_resolve_state (clang_type ? clang_type_resolve_state : eResolveStateUnresolved) { } @@ -66,9 +64,9 @@ m_encoding_uid_type (eEncodingInvalid), m_encoding_uid (0), m_byte_size (0), - m_is_forward_decl (false), m_decl (), - m_clang_type (NULL) + m_clang_type (NULL), + m_clang_type_resolve_state (eResolveStateUnresolved) { } @@ -86,9 +84,9 @@ m_encoding_uid_type = rhs.m_encoding_uid_type; m_encoding_uid = rhs.m_encoding_uid; m_byte_size = rhs.m_byte_size; - m_is_forward_decl = rhs.m_is_forward_decl; m_decl = rhs.m_decl; m_clang_type = rhs.m_clang_type; + m_clang_type_resolve_state = rhs.m_clang_type_resolve_state; } return *this; } @@ -190,7 +188,7 @@ { if (!(m_name)) { - if (ResolveClangType(true)) + if (ResolveClangType(eResolveStateForward)) { std::string type_name = ClangASTContext::GetTypeName (m_clang_type); if (!type_name.empty()) @@ -220,7 +218,7 @@ lldb::Format format ) { - if (ResolveClangType(true)) + if (ResolveClangType(eResolveStateForward)) { if (show_types) { @@ -251,11 +249,8 @@ lldb_private::Type * lldb_private::Type::GetEncodingType () { - if (m_encoding_type == NULL) - { - if (m_encoding_uid != LLDB_INVALID_UID) - m_encoding_type = m_symbol_file->ResolveTypeUID(m_encoding_uid); - } + if (m_encoding_type == NULL && m_encoding_uid != LLDB_INVALID_UID) + m_encoding_type = m_symbol_file->ResolveTypeUID(m_encoding_uid); return m_encoding_type; } @@ -279,7 +274,7 @@ m_byte_size = encoding_type->GetByteSize(); if (m_byte_size == 0) { - uint64_t bit_width = ClangASTType::GetClangTypeBitWidth (GetClangAST(), GetClangType()); + uint64_t bit_width = ClangASTType::GetClangTypeBitWidth (GetClangAST(), GetClangLayoutType()); m_byte_size = (bit_width + 7 ) / 8; } } @@ -300,7 +295,7 @@ uint32_t lldb_private::Type::GetNumChildren (bool omit_empty_base_classes) { - if (!ResolveClangType()) + if (!ResolveClangType(eResolveStateFull)) return 0; return ClangASTContext::GetNumChildren (m_clang_type, omit_empty_base_classes); @@ -309,7 +304,7 @@ bool lldb_private::Type::IsAggregateType () { - if (ResolveClangType()) + if (ResolveClangType(eResolveStateForward)) return ClangASTContext::IsAggregateType (m_clang_type); return false; } @@ -318,7 +313,7 @@ lldb_private::Type::GetFormat () { // Make sure we resolve our type if it already hasn't been. - if (!ResolveClangType()) + if (!ResolveClangType(eResolveStateForward)) return lldb::eFormatInvalid; return lldb_private::ClangASTType::GetFormat (m_clang_type); } @@ -329,7 +324,7 @@ lldb_private::Type::GetEncoding (uint32_t &count) { // Make sure we resolve our type if it already hasn't been. - if (!ResolveClangType()) + if (!ResolveClangType(eResolveStateForward)) return lldb::eEncodingInvalid; return lldb_private::ClangASTType::GetEncoding (m_clang_type, count); @@ -422,18 +417,23 @@ } bool -lldb_private::Type::ResolveClangType (bool forward_decl_is_ok) +lldb_private::Type::ResolveClangType (ResolveState clang_type_resolve_state) { + Type *encoding_type = NULL; if (m_clang_type == NULL) { TypeList *type_list = GetTypeList(); - Type *encoding_type = GetEncodingType(); + encoding_type = GetEncodingType(); if (encoding_type) { switch (m_encoding_uid_type) { case eEncodingIsUID: - m_clang_type = encoding_type->GetClangType(); + if (encoding_type->ResolveClangType(clang_type_resolve_state)) + { + m_clang_type = encoding_type->m_clang_type; + m_clang_type_resolve_state = encoding_type->m_clang_type_resolve_state; + } break; case eEncodingIsConstUID: @@ -518,11 +518,9 @@ } // Check if we have a forward reference to a class/struct/union/enum? - if (m_clang_type != NULL && - m_is_forward_decl == true && - forward_decl_is_ok == false) + if (m_clang_type && m_clang_type_resolve_state < clang_type_resolve_state) { - m_is_forward_decl = false; + m_clang_type_resolve_state = eResolveStateFull; if (!ClangASTType::IsDefined (m_clang_type)) { // We have a forward declaration, we need to resolve it to a complete @@ -533,45 +531,25 @@ // If we have an encoding type, then we need to make sure it is // resolved appropriately. - if (m_encoding_type_decl_resolved == false) + if (m_encoding_uid != LLDB_INVALID_UID) { - if ((forward_decl_is_ok == true && !m_encoding_type_forward_decl_resolved) || - (forward_decl_is_ok == false)) + if (encoding_type == NULL) + encoding_type = GetEncodingType(); + if (encoding_type) { - Type *encoding_type = GetEncodingType (); - if (encoding_type != NULL) - { - bool forward_decl_is_ok_for_encoding = forward_decl_is_ok; -// switch (m_encoding_uid_type) -// { -// case eEncodingIsPointerUID: -// case eEncodingIsLValueReferenceUID: -// case eEncodingIsRValueReferenceUID: -// forward_decl_is_ok_for_encoding = true; -// break; -// default: -// break; -// } - - if (encoding_type->ResolveClangType (forward_decl_is_ok_for_encoding)) - { - // We have at least resolve the forward declaration for our - // encoding type... - m_encoding_type_forward_decl_resolved = true; - - // Check if we fully resolved our encoding type, and if so - // mark it as having been completely resolved. - if (forward_decl_is_ok_for_encoding == false) - m_encoding_type_decl_resolved = true; - } - } - else + ResolveState encoding_clang_type_resolve_state = eResolveStateFull; + switch (m_encoding_uid_type) { - // We don't have an encoding type, so mark everything as being - // resolved so we don't get into this if statement again - m_encoding_type_decl_resolved = true; - m_encoding_type_forward_decl_resolved = true; + case eEncodingIsPointerUID: + case eEncodingIsLValueReferenceUID: + case eEncodingIsRValueReferenceUID: + if (clang_type_resolve_state == eResolveStateLayout) + encoding_clang_type_resolve_state = eResolveStateForward; + break; + default: + break; } + encoding_type->ResolveClangType (encoding_clang_type_resolve_state); } } return m_clang_type != NULL; @@ -592,29 +570,30 @@ bool &child_is_base_class ) { - if (!ResolveClangType()) - return NULL; - - std::string name_str; - clang_type_t child_qual_type = GetClangASTContext().GetChildClangTypeAtIndex ( - parent_name, - m_clang_type, - idx, - transparent_pointers, - omit_empty_base_classes, - name_str, - child_byte_size, - child_byte_offset, - child_bitfield_bit_size, - child_bitfield_bit_offset, - child_is_base_class); - - if (child_qual_type) + clang_type_t child_qual_type = NULL; + + if (GetClangType()) { - if (!name_str.empty()) - name.SetCString(name_str.c_str()); - else - name.Clear(); + std::string name_str; + child_qual_type = GetClangASTContext().GetChildClangTypeAtIndex (parent_name, + m_clang_type, + idx, + transparent_pointers, + omit_empty_base_classes, + name_str, + child_byte_size, + child_byte_offset, + child_bitfield_bit_size, + child_bitfield_bit_offset, + child_is_base_class); + + if (child_qual_type) + { + if (!name_str.empty()) + name.SetCString(name_str.c_str()); + else + name.Clear(); + } } return child_qual_type; } @@ -623,16 +602,21 @@ clang_type_t lldb_private::Type::GetClangType () { - const bool forward_decl_is_ok = false; - ResolveClangType(forward_decl_is_ok); + ResolveClangType(eResolveStateFull); + return m_clang_type; +} + +clang_type_t +lldb_private::Type::GetClangLayoutType () +{ + ResolveClangType(eResolveStateLayout); return m_clang_type; } clang_type_t lldb_private::Type::GetClangForwardType () { - const bool forward_decl_is_ok = true; - ResolveClangType (forward_decl_is_ok); + ResolveClangType (eResolveStateForward); return m_clang_type; } Modified: lldb/trunk/source/Target/ThreadPlanTracer.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/ThreadPlanTracer.cpp?rev=118976&r1=118975&r2=118976&view=diff ============================================================================== --- lldb/trunk/source/Target/ThreadPlanTracer.cpp (original) +++ lldb/trunk/source/Target/ThreadPlanTracer.cpp Fri Nov 12 21:52:47 2010 @@ -245,7 +245,7 @@ { Value value; value.SetValueType (Value::eValueTypeScalar); - value.SetContext (Value::eContextTypeOpaqueClangQualType, m_intptr_type.GetOpaqueQualType()); + value.SetContext (Value::eContextTypeClangType, m_intptr_type.GetOpaqueQualType()); value_list.PushValue (value); } From gclayton at apple.com Fri Nov 12 22:18:24 2010 From: gclayton at apple.com (Greg Clayton) Date: Sat, 13 Nov 2010 04:18:24 -0000 Subject: [Lldb-commits] [lldb] r118979 - in /lldb/trunk: include/lldb/Expression/ClangASTSource.h source/Expression/ClangASTSource.cpp source/Expression/ClangExpressionDeclMap.cpp Message-ID: <20101113041824.511602A6C12C@llvm.org> Author: gclayton Date: Fri Nov 12 22:18:24 2010 New Revision: 118979 URL: http://llvm.org/viewvc/llvm-project?rev=118979&view=rev Log: Got namespace lookup working and was able to print a complex "this" as an expression. This currently takes waaaayyyyy too much time to evaluate. We will need to look at the expression parser and find ways to optimize the info we provide and get this to evaluate quicker. I believe the performance issue is currently related to us always providing a complete C++ class type when asked about a C++ class which can cause a lot of information to be pulled since all classes will be fully created (methods, base classes, members, all their types). We will need to give the classes back the parser and mark them as having external sources and get parser (Sema) to query us when it needs more info. This should bring things up to an acceptable level. Modified: lldb/trunk/include/lldb/Expression/ClangASTSource.h lldb/trunk/source/Expression/ClangASTSource.cpp lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp Modified: lldb/trunk/include/lldb/Expression/ClangASTSource.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Expression/ClangASTSource.h?rev=118979&r1=118978&r2=118979&view=diff ============================================================================== --- lldb/trunk/include/lldb/Expression/ClangASTSource.h (original) +++ lldb/trunk/include/lldb/Expression/ClangASTSource.h Fri Nov 12 22:18:24 2010 @@ -10,6 +10,8 @@ #ifndef liblldb_ClangASTSource_h_ #define liblldb_ClangASTSource_h_ +#include + #include "clang/Basic/IdentifierTable.h" #include "clang/Sema/ExternalSemaSource.h" @@ -44,8 +46,9 @@ //------------------------------------------------------------------ ClangASTSource(clang::ASTContext &context, ClangExpressionDeclMap &decl_map) : - m_ast_context(context), - m_decl_map(decl_map) + m_ast_context (context), + m_decl_map (decl_map), + m_active_lookups () { } @@ -119,6 +122,7 @@ clang::ASTContext &m_ast_context; ///< The parser's AST context, for copying types into ClangExpressionDeclMap &m_decl_map; ///< The object that looks up named entities in LLDB + std::set m_active_lookups; }; //---------------------------------------------------------------------- Modified: lldb/trunk/source/Expression/ClangASTSource.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/ClangASTSource.cpp?rev=118979&r1=118978&r2=118979&view=diff ============================================================================== --- lldb/trunk/source/Expression/ClangASTSource.cpp (original) +++ lldb/trunk/source/Expression/ClangASTSource.cpp Fri Nov 12 22:18:24 2010 @@ -90,12 +90,21 @@ } } - llvm::SmallVector name_decls; + ConstString const_decl_name(decl_name.c_str()); + const char *uniqued_const_decl_name = const_decl_name.GetCString(); + if (m_active_lookups.find (uniqued_const_decl_name) != m_active_lookups.end()) + { + // We are currently looking up this name... + return DeclContext::lookup_result(); + } + m_active_lookups.insert(uniqued_const_decl_name); + llvm::SmallVector name_decls; NameSearchContext name_search_context(*this, name_decls, clang_decl_name, decl_ctx); - ConstString const_decl_name(decl_name.c_str()); m_decl_map.GetDecls(name_search_context, const_decl_name); - return SetExternalVisibleDeclsForName (decl_ctx, clang_decl_name, name_decls); + DeclContext::lookup_result result (SetExternalVisibleDeclsForName (decl_ctx, clang_decl_name, name_decls)); + m_active_lookups.erase (uniqued_const_decl_name); + return result; } void ClangASTSource::MaterializeVisibleDecls(const DeclContext *DC) Modified: lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp?rev=118979&r1=118978&r2=118979&view=diff ============================================================================== --- lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp (original) +++ lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp Fri Nov 12 22:18:24 2010 @@ -1024,13 +1024,13 @@ ClangNamespaceDecl namespace_decl (m_sym_ctx.FindNamespace(name)); if (namespace_decl) { -// clang::NamespaceDecl *clang_namespace_decl = AddNamespace(context, namespace_decl); -// if (clang_namespace_decl) -// { -// // TODO: is this how we get the decl lookups to be called for -// // this namespace?? -// clang_namespace_decl->setHasExternalLexicalStorage(); -// } + clang::NamespaceDecl *clang_namespace_decl = AddNamespace(context, namespace_decl); + if (clang_namespace_decl) + { + // TODO: is this how we get the decl lookups to be called for + // this namespace?? + clang_namespace_decl->setHasExternalLexicalStorage(); + } } } } From gclayton at apple.com Sat Nov 13 16:57:37 2010 From: gclayton at apple.com (Greg Clayton) Date: Sat, 13 Nov 2010 22:57:37 -0000 Subject: [Lldb-commits] [lldb] r119012 - in /lldb/trunk: lldb.xcodeproj/project.pbxproj source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp Message-ID: <20101113225737.D7D792A6C12C@llvm.org> Author: gclayton Date: Sat Nov 13 16:57:37 2010 New Revision: 119012 URL: http://llvm.org/viewvc/llvm-project?rev=119012&view=rev Log: Fixed an issue where we might not find global variables by name when we have a debug map with DWARF in the .o files due to the attemted shortcut that was being taken where the global variables were being searched for by looking in the symbol table. The problem with the symbols in the symbol table is we don't break apart the symbol names for symbols when they are mangled into basename and the fully mangled name since this would take a lot of CPU time to chop up the mangled names and try and find the basenames. The DWARF info typically has this broken up for us where the basename of the variable is in a the DW_AT_name attribute, and the mangled name is in the DW_AT_MIPS_linkage_name attribute. Now we correctly find globals by searching all OSO's for the information so we can take advantage of this split information. Modified: lldb/trunk/lldb.xcodeproj/project.pbxproj lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp Modified: lldb/trunk/lldb.xcodeproj/project.pbxproj URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/lldb.xcodeproj/project.pbxproj?rev=119012&r1=119011&r2=119012&view=diff ============================================================================== --- lldb/trunk/lldb.xcodeproj/project.pbxproj (original) +++ lldb/trunk/lldb.xcodeproj/project.pbxproj Sat Nov 13 16:57:37 2010 @@ -2452,7 +2452,6 @@ isa = PBXProject; buildConfigurationList = 1DEB91EF08733DB70010E9CD /* Build configuration list for PBXProject "lldb" */; compatibilityVersion = "Xcode 3.1"; - developmentRegion = English; hasScannedForEncodings = 1; knownRegions = ( en, Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp?rev=119012&r1=119011&r2=119012&view=diff ============================================================================== --- lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp (original) +++ lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp Sat Nov 13 16:57:37 2010 @@ -1086,7 +1086,10 @@ case DW_TAG_member: { DWARFDebugInfoEntry::Attributes attributes; - const size_t num_attributes = die->GetAttributes(this, dwarf_cu, fixed_form_sizes, attributes); + const size_t num_attributes = die->GetAttributes (this, + dwarf_cu, + fixed_form_sizes, + attributes); if (num_attributes > 0) { Declaration decl; @@ -1158,7 +1161,11 @@ accessibility = default_accessibility; member_accessibilities.push_back(accessibility); - GetClangASTContext().AddFieldToRecordType (class_clang_type, name, member_type->GetClangLayoutType(), accessibility, bit_size); + GetClangASTContext().AddFieldToRecordType (class_clang_type, + name, + member_type->GetClangLayoutType(), + accessibility, + bit_size); } } } @@ -1176,7 +1183,10 @@ default_accessibility = eAccessPrivate; // TODO: implement DW_TAG_inheritance type parsing DWARFDebugInfoEntry::Attributes attributes; - const size_t num_attributes = die->GetAttributes(this, dwarf_cu, fixed_form_sizes, attributes); + const size_t num_attributes = die->GetAttributes (this, + dwarf_cu, + fixed_form_sizes, + attributes); if (num_attributes > 0) { Declaration decl; @@ -1207,7 +1217,17 @@ const DataExtractor& debug_info_data = get_debug_info_data(); uint32_t block_length = form_value.Unsigned(); uint32_t block_offset = form_value.BlockData() - debug_info_data.GetDataStart(); - if (DWARFExpression::Evaluate(NULL, NULL, debug_info_data, NULL, NULL, block_offset, block_length, eRegisterKindDWARF, &initialValue, memberOffset, NULL)) + if (DWARFExpression::Evaluate (NULL, + NULL, + debug_info_data, + NULL, + NULL, + block_offset, + block_length, + eRegisterKindDWARF, + &initialValue, + memberOffset, + NULL)) { member_offset = memberOffset.ResolveValue(NULL, NULL).UInt(); } @@ -1235,7 +1255,10 @@ } else { - base_classes.push_back (GetClangASTContext().CreateBaseClassSpecifier (base_class_type->GetClangType(), accessibility, is_virtual, is_base_of_class)); + base_classes.push_back (GetClangASTContext().CreateBaseClassSpecifier (base_class_type->GetClangType(), + accessibility, + is_virtual, + is_base_of_class)); assert(base_classes.back()); } } @@ -1776,15 +1799,14 @@ GetObjectFile()->GetModule()->GetArchitecture().AsCString(), GetObjectFile()->GetFileSpec().GetDirectory().AsCString(), GetObjectFile()->GetFileSpec().GetFilename().AsCString()); -// s.Printf("\nFunction basenames:\n"); m_function_basename_index.Dump (&s); -// s.Printf("\nFunction fullnames:\n"); m_function_fullname_index.Dump (&s); -// s.Printf("\nFunction methods:\n"); m_function_method_index.Dump (&s); -// s.Printf("\nFunction selectors:\n"); m_function_selector_index.Dump (&s); -// s.Printf("\nObjective C class selectors:\n"); m_objc_class_selectors_index.Dump (&s); -// s.Printf("\nGlobals and statics:\n"); m_global_index.Dump (&s); + s.Printf("\nFunction basenames:\n"); m_function_basename_index.Dump (&s); + s.Printf("\nFunction fullnames:\n"); m_function_fullname_index.Dump (&s); + s.Printf("\nFunction methods:\n"); m_function_method_index.Dump (&s); + s.Printf("\nFunction selectors:\n"); m_function_selector_index.Dump (&s); + s.Printf("\nObjective C class selectors:\n"); m_objc_class_selectors_index.Dump (&s); + s.Printf("\nGlobals and statics:\n"); m_global_index.Dump (&s); s.Printf("\nTypes:\n"); m_type_index.Dump (&s); -// s.Printf("\nNamepaces:\n"); m_namespace_index.Dump (&s); - + s.Printf("\nNamepaces:\n"); m_namespace_index.Dump (&s); #endif } } Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp?rev=119012&r1=119011&r2=119012&view=diff ============================================================================== --- lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp (original) +++ lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp Sat Nov 13 16:57:37 2010 @@ -716,14 +716,29 @@ // we are appending the results to a variable list. const uint32_t original_size = variables.GetSize(); - Symtab* symtab = m_obj_file->GetSymtab(); - if (symtab) + uint32_t total_matches = 0; + SymbolFileDWARF *oso_dwarf; + for (uint32_t oso_idx = 0; ((oso_dwarf = GetSymbolFileByOSOIndex (oso_idx)) != NULL); ++oso_idx) { - std::vector indexes; - const size_t match_count = m_obj_file->GetSymtab()->FindAllSymbolsWithNameAndType (name, eSymbolTypeData, Symtab::eDebugYes, Symtab::eVisibilityAny, indexes); - if (match_count) + const uint32_t oso_matches = oso_dwarf->FindGlobalVariables (name, + true, + max_matches, + variables); + if (oso_matches > 0) { - PrivateFindGlobalVariables (name, indexes, max_matches, variables); + total_matches += oso_matches; + + // Are we getting all matches? + if (max_matches == UINT32_MAX) + continue; // Yep, continue getting everything + + // If we have found enough matches, lets get out + if (max_matches >= total_matches) + break; + + // Update the max matches for any subsequent calls to find globals + // in any other object files with DWARF + max_matches -= oso_matches; } } // Return the number of variable that were appended to the list @@ -734,7 +749,41 @@ uint32_t SymbolFileDWARFDebugMap::FindGlobalVariables (const RegularExpression& regex, bool append, uint32_t max_matches, VariableList& variables) { - return 0; + // If we aren't appending the results to this list, then clear the list + if (!append) + variables.Clear(); + + // Remember how many variables are in the list before we search in case + // we are appending the results to a variable list. + const uint32_t original_size = variables.GetSize(); + + uint32_t total_matches = 0; + SymbolFileDWARF *oso_dwarf; + for (uint32_t oso_idx = 0; ((oso_dwarf = GetSymbolFileByOSOIndex (oso_idx)) != NULL); ++oso_idx) + { + const uint32_t oso_matches = oso_dwarf->FindGlobalVariables (regex, + true, + max_matches, + variables); + if (oso_matches > 0) + { + total_matches += oso_matches; + + // Are we getting all matches? + if (max_matches == UINT32_MAX) + continue; // Yep, continue getting everything + + // If we have found enough matches, lets get out + if (max_matches >= total_matches) + break; + + // Update the max matches for any subsequent calls to find globals + // in any other object files with DWARF + max_matches -= oso_matches; + } + } + // Return the number of variable that were appended to the list + return variables.GetSize() - original_size; } From gclayton at apple.com Sat Nov 13 18:22:48 2010 From: gclayton at apple.com (Greg Clayton) Date: Sun, 14 Nov 2010 00:22:48 -0000 Subject: [Lldb-commits] [lldb] r119017 - in /lldb/trunk: include/lldb/Symbol/Block.h lldb.xcodeproj/project.pbxproj source/Breakpoint/BreakpointResolverName.cpp source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp source/Symbol/Block.cpp Message-ID: <20101114002248.A9B8A2A6C12C@llvm.org> Author: gclayton Date: Sat Nov 13 18:22:48 2010 New Revision: 119017 URL: http://llvm.org/viewvc/llvm-project?rev=119017&view=rev Log: Fixed a crasher (an assert was firing in the DWARF parser) when setting breakpoints on inlined functions by name. This involved fixing the DWARF parser to correctly back up and parse the concrete function when we find inlined functions by name, then grabbing any appropriate inlined blocks and returning symbol contexts with the block filled in. After this was fixed, the breakpoint by name resolver needed to correctly deal with symbol contexts that had the inlined block filled in in the symbol contexts. Modified: lldb/trunk/include/lldb/Symbol/Block.h lldb/trunk/lldb.xcodeproj/project.pbxproj lldb/trunk/source/Breakpoint/BreakpointResolverName.cpp lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp lldb/trunk/source/Symbol/Block.cpp Modified: lldb/trunk/include/lldb/Symbol/Block.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Symbol/Block.h?rev=119017&r1=119016&r2=119017&view=diff ============================================================================== --- lldb/trunk/include/lldb/Symbol/Block.h (original) +++ lldb/trunk/include/lldb/Symbol/Block.h Sat Nov 13 18:22:48 2010 @@ -420,6 +420,8 @@ bool GetRangeContainingAddress (const Address& addr, AddressRange &range); + bool + GetStartAddress (Address &addr); protected: typedef std::vector collection; Modified: lldb/trunk/lldb.xcodeproj/project.pbxproj URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/lldb.xcodeproj/project.pbxproj?rev=119017&r1=119016&r2=119017&view=diff ============================================================================== --- lldb/trunk/lldb.xcodeproj/project.pbxproj (original) +++ lldb/trunk/lldb.xcodeproj/project.pbxproj Sat Nov 13 18:22:48 2010 @@ -2941,6 +2941,7 @@ GCC_WARN_ABOUT_RETURN_TYPE = YES; GCC_WARN_HIDDEN_VIRTUAL_FUNCTIONS = YES; GCC_WARN_UNUSED_VARIABLE = YES; + ONLY_ACTIVE_ARCH = YES; PREBINDING = NO; VALID_ARCHS = "x86_64 i386"; }; Modified: lldb/trunk/source/Breakpoint/BreakpointResolverName.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Breakpoint/BreakpointResolverName.cpp?rev=119017&r1=119016&r2=119017&view=diff ============================================================================== --- lldb/trunk/source/Breakpoint/BreakpointResolverName.cpp (original) +++ lldb/trunk/source/Breakpoint/BreakpointResolverName.cpp Sat Nov 13 18:22:48 2010 @@ -191,8 +191,21 @@ remove = true; else if (sc.function == NULL) remove = true; - else if (::strstr (sc.function->GetName().AsCString(), basename_filter) == NULL) - remove = true; + else + { + const InlineFunctionInfo* inlined_info = NULL; + + if (sc.block) + inlined_info = sc.block->GetInlinedFunctionInfo(); + + if (inlined_info) + { + if (::strstr (inlined_info->GetName().AsCString(), basename_filter) == NULL) + remove = true; + } + else if (::strstr (sc.function->GetName().AsCString(), basename_filter) == NULL) + remove = true; + } if (remove) { @@ -259,16 +272,27 @@ { if (func_list.GetContextAtIndex(i, sc)) { - if (sc.function) + if (sc.block && sc.block->GetInlinedFunctionInfo()) + { + if (!sc.block->GetStartAddress(break_addr)) + break_addr.Clear(); + } + else if (sc.function) { break_addr = sc.function->GetAddressRange().GetBaseAddress(); if (skip_prologue) { - const uint32_t prologue_byte_size = sc.function->GetPrologueByteSize(); - if (prologue_byte_size) - break_addr.SetOffset(break_addr.GetOffset() + prologue_byte_size); + if (break_addr.IsValid()) + { + const uint32_t prologue_byte_size = sc.function->GetPrologueByteSize(); + if (prologue_byte_size) + break_addr.SetOffset(break_addr.GetOffset() + prologue_byte_size); + } } - + } + + if (break_addr.IsValid()) + { if (filter.AddressPasses(break_addr)) { BreakpointLocationSP bp_loc_sp (m_breakpoint->AddLocation(break_addr, &new_location)); 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=119017&r1=119016&r2=119017&view=diff ============================================================================== --- lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp (original) +++ lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp Sat Nov 13 18:22:48 2010 @@ -659,7 +659,9 @@ FunctionSP func_sp; std::auto_ptr decl_ap; if (decl_file != 0 || decl_line != 0 || decl_column != 0) - decl_ap.reset(new Declaration(sc.comp_unit->GetSupportFiles().GetFileSpecAtIndex(decl_file), decl_line, decl_column)); + decl_ap.reset(new Declaration (sc.comp_unit->GetSupportFiles().GetFileSpecAtIndex(decl_file), + decl_line, + decl_column)); Type *func_type = m_die_to_type.lookup (die); @@ -1932,7 +1934,7 @@ DWARFCompileUnit* prev_cu = NULL; const DWARFDebugInfoEntry* die = NULL; std::vector die_info_array; - const size_t num_matches = name_to_die.Find(name, die_info_array); + const size_t num_matches = name_to_die.Find (name, die_info_array); for (size_t i=0; iGetCompileUnitAtIndex(die_info_array[i].cu_idx); @@ -1941,20 +1943,52 @@ curr_cu->ExtractDIEsIfNeeded (false); die = curr_cu->GetDIEAtIndexUnchecked(die_info_array[i].die_idx); + + const DWARFDebugInfoEntry* inlined_die = NULL; + if (die->Tag() == DW_TAG_inlined_subroutine) + { + inlined_die = die; + + while ((die = die->GetParent()) != NULL) + { + if (die->Tag() == DW_TAG_subprogram) + break; + } + } + assert (die->Tag() == DW_TAG_subprogram); if (GetFunction (curr_cu, die, sc)) { - // We found the function, so we should find the line table - // and line table entry as well - LineTable *line_table = sc.comp_unit->GetLineTable(); - if (line_table == NULL) + Address addr; + // Parse all blocks if needed + if (inlined_die) { - if (ParseCompileUnitLineTable(sc)) - line_table = sc.comp_unit->GetLineTable(); + sc.block = sc.function->GetBlock (true).FindBlockByID (inlined_die->GetOffset()); + assert (sc.block != NULL); + if (sc.block->GetStartAddress (addr) == false) + addr.Clear(); + } + else + { + sc.block = NULL; + addr = sc.function->GetAddressRange().GetBaseAddress(); } - if (line_table != NULL) - line_table->FindLineEntryByAddress (sc.function->GetAddressRange().GetBaseAddress(), sc.line_entry); - sc_list.Append(sc); + if (addr.IsValid()) + { + + // We found the function, so we should find the line table + // and line table entry as well + LineTable *line_table = sc.comp_unit->GetLineTable(); + if (line_table == NULL) + { + if (ParseCompileUnitLineTable(sc)) + line_table = sc.comp_unit->GetLineTable(); + } + if (line_table != NULL) + line_table->FindLineEntryByAddress (addr, sc.line_entry); + + sc_list.Append(sc); + } } } } Modified: lldb/trunk/source/Symbol/Block.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/Block.cpp?rev=119017&r1=119016&r2=119017&view=diff ============================================================================== --- lldb/trunk/source/Symbol/Block.cpp (original) +++ lldb/trunk/source/Symbol/Block.cpp Sat Nov 13 18:22:48 2010 @@ -358,6 +358,24 @@ return false; } + +bool +Block::GetStartAddress (Address &addr) +{ + if (m_ranges.empty()) + return false; + + SymbolContext sc; + CalculateSymbolContext(&sc); + if (sc.function) + { + addr = sc.function->GetAddressRange().GetBaseAddress(); + addr.Slide(m_ranges.front().GetBaseAddress ()); + return true; + } + return false; +} + void Block::AddRange(addr_t start_offset, addr_t end_offset) { From gclayton at apple.com Sat Nov 13 19:03:55 2010 From: gclayton at apple.com (Greg Clayton) Date: Sun, 14 Nov 2010 01:03:55 -0000 Subject: [Lldb-commits] [lldb] r119020 - /lldb/trunk/source/Symbol/Type.cpp Message-ID: <20101114010355.88EFC2A6C12C@llvm.org> Author: gclayton Date: Sat Nov 13 19:03:55 2010 New Revision: 119020 URL: http://llvm.org/viewvc/llvm-project?rev=119020&view=rev Log: Fixed an issue where we were trying to resolve lldb_private::Type encoding types to their full definitions more than we needed to. This caused an assertion in the DWARF parser to fire -- which is an indication that we are parsing too much. Modified: lldb/trunk/source/Symbol/Type.cpp Modified: lldb/trunk/source/Symbol/Type.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/Type.cpp?rev=119020&r1=119019&r2=119020&view=diff ============================================================================== --- lldb/trunk/source/Symbol/Type.cpp (original) +++ lldb/trunk/source/Symbol/Type.cpp Sat Nov 13 19:03:55 2010 @@ -537,17 +537,20 @@ encoding_type = GetEncodingType(); if (encoding_type) { - ResolveState encoding_clang_type_resolve_state = eResolveStateFull; - switch (m_encoding_uid_type) + ResolveState encoding_clang_type_resolve_state = clang_type_resolve_state; + + if (clang_type_resolve_state == eResolveStateLayout) { - case eEncodingIsPointerUID: - case eEncodingIsLValueReferenceUID: - case eEncodingIsRValueReferenceUID: - if (clang_type_resolve_state == eResolveStateLayout) + switch (m_encoding_uid_type) + { + case eEncodingIsPointerUID: + case eEncodingIsLValueReferenceUID: + case eEncodingIsRValueReferenceUID: encoding_clang_type_resolve_state = eResolveStateForward; - break; - default: - break; + break; + default: + break; + } } encoding_type->ResolveClangType (encoding_clang_type_resolve_state); } From gclayton at apple.com Sun Nov 14 16:13:40 2010 From: gclayton at apple.com (Greg Clayton) Date: Sun, 14 Nov 2010 22:13:40 -0000 Subject: [Lldb-commits] [lldb] r119085 - in /lldb/trunk: include/lldb/Core/Mangled.h include/lldb/Symbol/Variable.h lldb.xcodeproj/project.pbxproj source/Commands/CommandObjectFrame.cpp source/Core/Mangled.cpp source/Expression/ClangExpressionDeclMap.cpp source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp source/Symbol/Variable.cpp source/Symbol/VariableList.cpp Message-ID: <20101114221340.D776E2A6C12C@llvm.org> Author: gclayton Date: Sun Nov 14 16:13:40 2010 New Revision: 119085 URL: http://llvm.org/viewvc/llvm-project?rev=119085&view=rev Log: Just like functions can have a basename and a mangled/demangled name, variable can too. So now the lldb_private::Variable class has support for this. Variables now have support for having a basename ("i"), and a mangled name ("_ZN12_GLOBAL__N_11iE"), and a demangled name ("(anonymous namespace)::i"). Nowwhen searching for a variable by name, users might enter the fully qualified name, or just the basename. So new test functions were added to the Variable and Mangled classes as: bool NameMatches (const ConstString &name); bool NameMatches (const RegularExpression ®ex); I also modified "ClangExpressionDeclMap::FindVariableInScope" to also search for global variables that are not in the current file scope by first starting with the current module, then moving on to all modules. Fixed an issue in the DWARF parser that could cause a varaible to get parsed more than once. Now, once we have parsed a VariableSP for a DIE, we cache the result even if a variable wasn't made so we don't do any re-parsing. Some DW_TAG_variable DIEs don't have locations, or are missing vital info that stops a debugger from being able to display anything for it, we parse a NULL variable shared pointer for these DIEs so we don't keep trying to reparse it. Modified: lldb/trunk/include/lldb/Core/Mangled.h lldb/trunk/include/lldb/Symbol/Variable.h lldb/trunk/lldb.xcodeproj/project.pbxproj lldb/trunk/source/Commands/CommandObjectFrame.cpp lldb/trunk/source/Core/Mangled.cpp lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp lldb/trunk/source/Symbol/Variable.cpp lldb/trunk/source/Symbol/VariableList.cpp Modified: lldb/trunk/include/lldb/Core/Mangled.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/Mangled.h?rev=119085&r1=119084&r2=119085&view=diff ============================================================================== --- lldb/trunk/include/lldb/Core/Mangled.h (original) +++ lldb/trunk/include/lldb/Core/Mangled.h Sun Nov 14 16:13:40 2010 @@ -433,6 +433,26 @@ GetName (NamePreference preference = ePreferDemangled) const; //---------------------------------------------------------------------- + /// Check if "name" matches either the mangled or demangled name. + /// + /// @param[in] name + /// A name to match against both strings. + /// + /// @return + /// \b True if \a name matches either name, \b false otherwise. + //---------------------------------------------------------------------- + bool + NameMatches (const ConstString &name) const + { + if (m_mangled == name) + return true; + return GetDemangledName () == name; + } + + bool + NameMatches (const RegularExpression& regex) const; + + //---------------------------------------------------------------------- /// Generate the tokens from the demangled name. /// /// @param[out] tokens Modified: lldb/trunk/include/lldb/Symbol/Variable.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Symbol/Variable.h?rev=119085&r1=119084&r2=119085&view=diff ============================================================================== --- lldb/trunk/include/lldb/Symbol/Variable.h (original) +++ lldb/trunk/include/lldb/Symbol/Variable.h Sun Nov 14 16:13:40 2010 @@ -14,9 +14,10 @@ #include "lldb/lldb-private.h" #include "lldb/lldb-enumerations.h" +#include "lldb/Core/Mangled.h" +#include "lldb/Core/UserID.h" #include "lldb/Expression/DWARFExpression.h" #include "lldb/Symbol/Declaration.h" -#include "lldb/Core/UserID.h" namespace lldb_private { @@ -26,14 +27,16 @@ //------------------------------------------------------------------ // Constructors and Destructors //------------------------------------------------------------------ - Variable(lldb::user_id_t uid, - const ConstString& name, Type *type, - lldb::ValueType scope, - SymbolContextScope *owner_scope, - Declaration* decl, - const DWARFExpression& location, - bool external, - bool artificial); + Variable (lldb::user_id_t uid, + const char *name, + const char *mangled, // The mangled variable name for variables in namespaces + Type *type, + lldb::ValueType scope, + SymbolContextScope *owner_scope, + Declaration* decl, + const DWARFExpression& location, + bool external, + bool artificial); virtual ~Variable(); @@ -48,11 +51,24 @@ } const ConstString& - GetName() const + GetName() const; + + // Since a variable can have a basename "i" and also a mangled + // named "_ZN12_GLOBAL__N_11iE" and a demangled mangled name + // "(anonymous namespace)::i", this function will allow a generic match + // function that can be called by commands and expression parsers to make + // sure we match anything we come across. + bool + NameMatches (const ConstString &name) const { - return m_name; + if (m_name == name) + return true; + return m_mangled.NameMatches (name); } + bool + NameMatches (const RegularExpression& regex) const; + Type * GetType() { @@ -105,7 +121,8 @@ IsInScope (StackFrame *frame); protected: - ConstString m_name; // Name of the variable + ConstString m_name; // The basename of the variable (no namespaces) + Mangled m_mangled; // The mangled name of hte variable Type *m_type; // The type pointer of the variable (int, struct, class, etc) lldb::ValueType m_scope; // global, parameter, local SymbolContextScope *m_owner_scope; // The symbol file scope that this variable was defined in Modified: lldb/trunk/lldb.xcodeproj/project.pbxproj URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/lldb.xcodeproj/project.pbxproj?rev=119085&r1=119084&r2=119085&view=diff ============================================================================== --- lldb/trunk/lldb.xcodeproj/project.pbxproj (original) +++ lldb/trunk/lldb.xcodeproj/project.pbxproj Sun Nov 14 16:13:40 2010 @@ -2452,6 +2452,7 @@ isa = PBXProject; buildConfigurationList = 1DEB91EF08733DB70010E9CD /* Build configuration list for PBXProject "lldb" */; compatibilityVersion = "Xcode 3.1"; + developmentRegion = English; hasScannedForEncodings = 1; knownRegions = ( en, Modified: lldb/trunk/source/Commands/CommandObjectFrame.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectFrame.cpp?rev=119085&r1=119084&r2=119085&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectFrame.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectFrame.cpp Sun Nov 14 16:13:40 2010 @@ -727,7 +727,7 @@ ValueObject::DumpValueObject (result.GetOutputStream(), exe_ctx.frame, valobj_sp.get(), - name_cstr, + valobj_sp->GetParent() ? name_cstr : NULL, ptr_depth, 0, m_options.max_depth, Modified: lldb/trunk/source/Core/Mangled.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/Mangled.cpp?rev=119085&r1=119084&r2=119085&view=diff ============================================================================== --- lldb/trunk/source/Core/Mangled.cpp (original) +++ lldb/trunk/source/Core/Mangled.cpp Sun Nov 14 16:13:40 2010 @@ -13,6 +13,7 @@ #include "lldb/Core/ConstString.h" #include "lldb/Core/Mangled.h" +#include "lldb/Core/RegularExpression.h" #include "lldb/Core/Stream.h" #include "lldb/Core/Timer.h" #include @@ -192,6 +193,19 @@ return m_demangled; } + +bool +Mangled::NameMatches (const RegularExpression& regex) const +{ + if (m_mangled && regex.Execute (m_mangled.AsCString())) + return true; + + if (GetDemangledName() && regex.Execute (m_demangled.AsCString())) + return true; + return false; +} + + //---------------------------------------------------------------------- // Mangled name get accessor //---------------------------------------------------------------------- Modified: lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp?rev=119085&r1=119084&r2=119085&view=diff ============================================================================== --- lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp (original) +++ lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp Sun Nov 14 16:13:40 2010 @@ -39,6 +39,7 @@ #include "lldb/Target/Target.h" #include "llvm/Support/raw_ostream.h" +using namespace lldb; using namespace lldb_private; using namespace clang; @@ -364,8 +365,8 @@ return false; } - static ConstString g_this_cs ("this"); - Variable *object_ptr_var = FindVariableInScope(*exe_ctx->frame, g_this_cs, &m_object_pointer_type); + static ConstString g_this_const_str ("this"); + Variable *object_ptr_var = FindVariableInScope (*exe_ctx->frame, g_this_const_str, &m_object_pointer_type); if (!object_ptr_var) { @@ -681,7 +682,7 @@ if (!exe_ctx.frame || !exe_ctx.process) return false; - Variable *var = FindVariableInScope(*exe_ctx.frame, name, &type); + Variable *var = FindVariableInScope (*exe_ctx.frame, name, &type); if (!var) { @@ -931,27 +932,50 @@ if (!var_list) return NULL; - lldb::VariableSP var = var_list->FindVariable(name); - - if (!var) - return NULL; - - if (!type) - return var.get(); - - if (type->GetASTContext() == var->GetType()->GetClangAST()) + lldb::VariableSP var_sp (var_list->FindVariable(name)); + + const bool append = true; + const uint32_t max_matches = 1; + if (!var_sp) + { + // Look for globals elsewhere in the module for the frame + ModuleSP module_sp (m_exe_ctx.frame->GetSymbolContext(eSymbolContextModule).module_sp); + if (module_sp) + { + VariableList module_globals; + if (module_sp->FindGlobalVariables (name, append, max_matches, module_globals)) + var_sp = module_globals.GetVariableAtIndex (0); + } + } + + if (!var_sp) { - if (!ClangASTContext::AreTypesSame(type->GetASTContext(), type->GetOpaqueQualType(), var->GetType()->GetClangType())) - return NULL; + // Look for globals elsewhere in the program (all images) + TargetSP target_sp (m_exe_ctx.frame->GetSymbolContext(eSymbolContextTarget).target_sp); + if (target_sp) + { + VariableList program_globals; + if (target_sp->GetImages().FindGlobalVariables (name, append, max_matches, program_globals)) + var_sp = program_globals.GetVariableAtIndex (0); + } } - else + + if (var_sp && type) { - if (log) - log->PutCString("Skipping a candidate variable because of different AST contexts"); - return NULL; + if (type->GetASTContext() == var_sp->GetType()->GetClangAST()) + { + if (!ClangASTContext::AreTypesSame(type->GetASTContext(), type->GetOpaqueQualType(), var_sp->GetType()->GetClangType())) + return NULL; + } + else + { + if (log) + log->PutCString("Skipping a candidate variable because of different AST contexts"); + return NULL; + } } - - return var.get(); + + return var_sp.get(); } // Interface for ClangASTSource @@ -969,9 +993,14 @@ SymbolContextList sc_list; + const char *name_unique_cstr = name.GetCString(); + + if (name_unique_cstr == NULL) + return; + // Only look for functions by name out in our symbols if the function // doesn't start with our phony prefix of '$' - if (name.GetCString()[0] != '$') + if (name_unique_cstr[0] != '$') { Variable *var = FindVariableInScope(*m_exe_ctx.frame, name); @@ -1084,13 +1113,11 @@ // See information on gating of this operation next to the definition for // m_lookedup_types. - - const char *name_uniq = name.GetCString(); - - if (m_lookedup_types.find(name_uniq) == m_lookedup_types.end()) + + if (m_lookedup_types.find(name_unique_cstr) == m_lookedup_types.end()) { // 1 The name is added to m_lookedup_types. - m_lookedup_types.insert(std::pair(name_uniq, true)); + m_lookedup_types.insert(std::pair(name_unique_cstr, true)); // 2 The type is looked up and added, potentially causing more type loookups. lldb::TypeSP type = m_sym_ctx.FindTypeByName (name); @@ -1104,7 +1131,7 @@ } // 3 The name is removed from m_lookedup_types. - m_lookedup_types.erase(name_uniq); + m_lookedup_types.erase(name_unique_cstr); } } Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp?rev=119085&r1=119084&r2=119085&view=diff ============================================================================== --- lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp (original) +++ lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp Sun Nov 14 16:13:40 2010 @@ -883,6 +883,14 @@ if (name && has_location && is_global_or_static_variable) { globals.Insert (ConstString(name), die_info); + // Be sure to include variables by their mangled and demangled + // names if they have any since a variable can have a basename + // "i", a mangled named "_ZN12_GLOBAL__N_11iE" and a demangled + // mangled name "(anonymous namespace)::i"... + if (mangled.GetMangledName()) + globals.Insert (mangled.GetMangledName(), die_info); + if (mangled.GetDemangledName()) + globals.Insert (mangled.GetDemangledName(), die_info); } break; 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=119085&r1=119084&r2=119085&view=diff ============================================================================== --- lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp (original) +++ lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp Sun Nov 14 16:13:40 2010 @@ -1776,16 +1776,16 @@ bool clear_dies = curr_cu->ExtractDIEsIfNeeded (false) > 1; curr_cu->Index (cu_idx, - m_function_basename_index, - m_function_fullname_index, - m_function_method_index, - m_function_selector_index, - m_objc_class_selectors_index, - m_global_index, - m_type_index, - m_namespace_index, - DebugRanges(), - m_aranges.get()); + m_function_basename_index, + m_function_fullname_index, + m_function_method_index, + m_function_selector_index, + m_objc_class_selectors_index, + m_global_index, + m_type_index, + m_namespace_index, + DebugRanges(), + m_aranges.get()); // Keep memory down by clearing DIEs if this generate function // caused them to be parsed @@ -3719,7 +3719,7 @@ VariableSP var_sp (ParseVariableDIE(sc, dwarf_cu, dwarf_cu->GetDIEAtIndexUnchecked(global_die_info_array[idx].die_idx), LLDB_INVALID_ADDRESS)); if (var_sp) { - variables->AddVariable(var_sp); + variables->AddVariableIfUnique (var_sp); ++vars_added; } } @@ -3741,7 +3741,9 @@ ) { - VariableSP var_sp; + VariableSP var_sp (m_die_to_variable_sp[die]); + if (var_sp) + return var_sp; // Already been parsed! const dw_tag_t tag = die->Tag(); DWARFDebugInfoEntry::Attributes attributes; @@ -3821,18 +3823,6 @@ { assert(var_type != DIE_IS_BEING_PARSED); - ConstString var_name; - if (mangled) - { - Mangled mangled_var_name (mangled, true); - var_name = mangled_var_name.GetDemangledName(); - } - - if (!var_name && name) - { - var_name.SetCString(name); - } - ValueType scope = eValueTypeInvalid; const DWARFDebugInfoEntry *sc_parent_die = GetParentSymbolContextDIE(die); @@ -3859,7 +3849,8 @@ assert(symbol_context_scope != NULL); var_sp.reset (new Variable(die->GetOffset(), - var_name, + name, + mangled, var_type, scope, symbol_context_scope, @@ -3868,9 +3859,13 @@ is_external, is_artificial)); - m_die_to_variable_sp[die] = var_sp; } } + // Cache var_sp even if NULL (the variable was just a specification or + // was missing vital information to be able to be displayed in the debugger + // (missing location due to optimization, etc)) so we don't re-parse + // this DIE over and over later... + m_die_to_variable_sp[die] = var_sp; return var_sp; } @@ -3952,7 +3947,7 @@ if (m_die_to_variable_sp[die]) { if (cc_variable_list) - cc_variable_list->AddVariable (m_die_to_variable_sp[die]); + cc_variable_list->AddVariableIfUnique (m_die_to_variable_sp[die]); } else { @@ -3964,9 +3959,9 @@ VariableSP var_sp (ParseVariableDIE(sc, dwarf_cu, die, func_low_pc)); if (var_sp) { - variables->AddVariable(var_sp); + variables->AddVariableIfUnique (var_sp); if (cc_variable_list) - cc_variable_list->AddVariable (var_sp); + cc_variable_list->AddVariableIfUnique (var_sp); ++vars_added; } } Modified: lldb/trunk/source/Symbol/Variable.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/Variable.cpp?rev=119085&r1=119084&r2=119085&view=diff ============================================================================== --- lldb/trunk/source/Symbol/Variable.cpp (original) +++ lldb/trunk/source/Symbol/Variable.cpp Sun Nov 14 16:13:40 2010 @@ -10,6 +10,7 @@ #include "lldb/Symbol/Variable.h" #include "lldb/Core/Stream.h" +#include "lldb/Core/RegularExpression.h" #include "lldb/Symbol/Block.h" #include "lldb/Symbol/Function.h" #include "lldb/Symbol/SymbolContext.h" @@ -26,17 +27,22 @@ //---------------------------------------------------------------------- // Variable constructor //---------------------------------------------------------------------- -Variable::Variable(lldb::user_id_t uid, - const ConstString& name, - Type *type, - ValueType scope, - SymbolContextScope *context, - Declaration* decl_ptr, - const DWARFExpression& location, - bool external, - bool artificial) : +Variable::Variable +( + lldb::user_id_t uid, + const char *name, + const char *mangled, // The mangled variable name for variables in namespaces + Type *type, + ValueType scope, + SymbolContextScope *context, + Declaration* decl_ptr, + const DWARFExpression& location, + bool external, + bool artificial +) : UserID(uid), m_name(name), + m_mangled (mangled, true), m_type(type), m_scope(scope), m_owner_scope(context), @@ -55,6 +61,22 @@ } +const ConstString& +Variable::GetName() const +{ + if (m_mangled) + return m_mangled.GetName(); + return m_name; +} + +bool +Variable::NameMatches (const RegularExpression& regex) const +{ + if (regex.Execute (m_name.AsCString())) + return true; + return m_mangled.NameMatches (regex); +} + void Variable::Dump(Stream *s, bool show_context) const { Modified: lldb/trunk/source/Symbol/VariableList.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/VariableList.cpp?rev=119085&r1=119084&r2=119085&view=diff ============================================================================== --- lldb/trunk/source/Symbol/VariableList.cpp (original) +++ lldb/trunk/source/Symbol/VariableList.cpp Sun Nov 14 16:13:40 2010 @@ -91,7 +91,7 @@ iterator pos, end = m_variables.end(); for (pos = m_variables.begin(); pos != end; ++pos) { - if ((*pos)->GetName() == name) + if ((*pos)->NameMatches(name)) { var_sp = (*pos); break; @@ -107,7 +107,7 @@ iterator pos, end = m_variables.end(); for (pos = m_variables.begin(); pos != end; ++pos) { - if (regex.Execute ((*pos)->GetName().AsCString())) + if ((*pos)->NameMatches (regex)) { // Note the total matches found total_matches++; From gclayton at apple.com Sun Nov 14 17:12:29 2010 From: gclayton at apple.com (Greg Clayton) Date: Sun, 14 Nov 2010 23:12:29 -0000 Subject: [Lldb-commits] [lldb] r119091 - /lldb/trunk/test/foundation/main.m Message-ID: <20101114231229.68C212A6C12C@llvm.org> Author: gclayton Date: Sun Nov 14 17:12:29 2010 New Revision: 119091 URL: http://llvm.org/viewvc/llvm-project?rev=119091&view=rev Log: Fixed the initWithNSString: function to properly initialize self. Modified: lldb/trunk/test/foundation/main.m Modified: lldb/trunk/test/foundation/main.m URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/foundation/main.m?rev=119091&r1=119090&r2=119091&view=diff ============================================================================== --- lldb/trunk/test/foundation/main.m (original) +++ lldb/trunk/test/foundation/main.m Sun Nov 14 17:12:29 2010 @@ -10,9 +10,11 @@ @implementation MyString - (id)initWithNSString:(NSString *)string { - [super init]; - str = [NSString stringWithString:string]; - date = [NSDate date]; + if (self = [super init]) + { + str = [NSString stringWithString:string]; + date = [NSDate date]; + } return self; } From gclayton at apple.com Sun Nov 14 19:32:26 2010 From: gclayton at apple.com (Greg Clayton) Date: Mon, 15 Nov 2010 01:32:26 -0000 Subject: [Lldb-commits] [lldb] r119100 - /lldb/trunk/source/Commands/CommandObjectFrame.cpp Message-ID: <20101115013226.59D482A6C12C@llvm.org> Author: gclayton Date: Sun Nov 14 19:32:26 2010 New Revision: 119100 URL: http://llvm.org/viewvc/llvm-project?rev=119100&view=rev Log: Added the address of operator for the "frame variable" command. Modified: lldb/trunk/source/Commands/CommandObjectFrame.cpp Modified: lldb/trunk/source/Commands/CommandObjectFrame.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectFrame.cpp?rev=119100&r1=119099&r2=119100&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectFrame.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectFrame.cpp Sun Nov 14 19:32:26 2010 @@ -586,12 +586,18 @@ } else { + bool address_of = false; // If first character is a '*', then show pointer contents if (name_cstr[0] == '*') { ++ptr_depth; name_cstr++; // Skip the '*' } + else if (name_cstr[0] == '&') + { + address_of = true; + name_cstr++; // Skip the '&' + } std::string var_path (name_cstr); size_t separator_idx = var_path.find_first_of(".-["); @@ -724,18 +730,25 @@ } - ValueObject::DumpValueObject (result.GetOutputStream(), - exe_ctx.frame, - valobj_sp.get(), - valobj_sp->GetParent() ? name_cstr : NULL, - ptr_depth, - 0, - m_options.max_depth, - m_options.show_types, - m_options.show_location, - m_options.use_objc, - false, - m_options.flat_output); + if (address_of) + { + s.Printf("&%s = %s\n", name_cstr, valobj_sp->GetLocationAsCString (exe_ctx.frame)); + } + else + { + ValueObject::DumpValueObject (result.GetOutputStream(), + exe_ctx.frame, + valobj_sp.get(), + valobj_sp->GetParent() ? name_cstr : NULL, + ptr_depth, + 0, + m_options.max_depth, + m_options.show_types, + m_options.show_location, + m_options.use_objc, + false, + m_options.flat_output); + } } } else From gclayton at apple.com Sun Nov 14 19:34:18 2010 From: gclayton at apple.com (Greg Clayton) Date: Mon, 15 Nov 2010 01:34:18 -0000 Subject: [Lldb-commits] [lldb] r119101 - /lldb/trunk/source/Expression/ClangASTSource.cpp Message-ID: <20101115013418.456432A6C12C@llvm.org> Author: gclayton Date: Sun Nov 14 19:34:18 2010 New Revision: 119101 URL: http://llvm.org/viewvc/llvm-project?rev=119101&view=rev Log: Added recursive name lookup logging with depth which is commented out and is currently only enabled when we blow the stack. Modified: lldb/trunk/source/Expression/ClangASTSource.cpp Modified: lldb/trunk/source/Expression/ClangASTSource.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/ClangASTSource.cpp?rev=119101&r1=119100&r2=119101&view=diff ============================================================================== --- lldb/trunk/source/Expression/ClangASTSource.cpp (original) +++ lldb/trunk/source/Expression/ClangASTSource.cpp Sun Nov 14 19:34:18 2010 @@ -99,10 +99,14 @@ return DeclContext::lookup_result(); } m_active_lookups.insert(uniqued_const_decl_name); +// static uint32_t g_depth = 0; +// ++g_depth; +// printf("[%5u] FindExternalVisibleDeclsByName() \"%s\"\n", g_depth, uniqued_const_decl_name); llvm::SmallVector name_decls; NameSearchContext name_search_context(*this, name_decls, clang_decl_name, decl_ctx); m_decl_map.GetDecls(name_search_context, const_decl_name); DeclContext::lookup_result result (SetExternalVisibleDeclsForName (decl_ctx, clang_decl_name, name_decls)); +// --g_depth; m_active_lookups.erase (uniqued_const_decl_name); return result; } From gclayton at apple.com Sun Nov 14 19:47:11 2010 From: gclayton at apple.com (Greg Clayton) Date: Mon, 15 Nov 2010 01:47:11 -0000 Subject: [Lldb-commits] [lldb] r119103 - in /lldb/trunk: lldb.xcodeproj/project.pbxproj source/Expression/IRForTarget.cpp test/objc/main.m Message-ID: <20101115014712.0D7CC2A6C12C@llvm.org> Author: gclayton Date: Sun Nov 14 19:47:11 2010 New Revision: 119103 URL: http://llvm.org/viewvc/llvm-project?rev=119103&view=rev Log: Added quotes around names that are being lookup up or inspected in the expression logging. Added some properties to the "objc" test. The expression parser can currently display properties that are backed by the default functions "expr myStr.string" will work. But it won't currently work when the property is backed by a different function such as "expr myStr.date". Modified: lldb/trunk/lldb.xcodeproj/project.pbxproj lldb/trunk/source/Expression/IRForTarget.cpp lldb/trunk/test/objc/main.m Modified: lldb/trunk/lldb.xcodeproj/project.pbxproj URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/lldb.xcodeproj/project.pbxproj?rev=119103&r1=119102&r2=119103&view=diff ============================================================================== --- lldb/trunk/lldb.xcodeproj/project.pbxproj (original) +++ lldb/trunk/lldb.xcodeproj/project.pbxproj Sun Nov 14 19:47:11 2010 @@ -2942,7 +2942,7 @@ GCC_WARN_ABOUT_RETURN_TYPE = YES; GCC_WARN_HIDDEN_VIRTUAL_FUNCTIONS = YES; GCC_WARN_UNUSED_VARIABLE = YES; - ONLY_ACTIVE_ARCH = YES; + ONLY_ACTIVE_ARCH = NO; PREBINDING = NO; VALID_ARCHS = "x86_64 i386"; }; Modified: lldb/trunk/source/Expression/IRForTarget.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/IRForTarget.cpp?rev=119103&r1=119102&r2=119103&view=diff ============================================================================== --- lldb/trunk/source/Expression/IRForTarget.cpp (original) +++ lldb/trunk/source/Expression/IRForTarget.cpp Sun Nov 14 19:47:11 2010 @@ -108,7 +108,7 @@ } if (log) - log->Printf("Result name: %s", result_name); + log->Printf("Result name: \"%s\"", result_name); Value *result_value = llvm_module.getNamedValue(result_name); @@ -121,7 +121,7 @@ } if (log) - log->Printf("Found result in the IR: %s", PrintValue(result_value, false).c_str()); + log->Printf("Found result in the IR: \"%s\"", PrintValue(result_value, false).c_str()); GlobalVariable *result_global = dyn_cast(result_value); @@ -171,7 +171,7 @@ ConstantInt *constant_int = dyn_cast(metadata_node->getOperand(1)); - uint64_t result_decl_intptr = constant_int->getZExtValue(); + lldb::addr_t result_decl_intptr = constant_int->getZExtValue(); clang::VarDecl *result_decl = reinterpret_cast(result_decl_intptr); @@ -185,7 +185,7 @@ m_decl_map->AddPersistentVariable(result_decl, new_result_name, result_decl_type); if (log) - log->Printf("Creating a new result global: %s", new_result_name.GetCString()); + log->Printf("Creating a new result global: \"%s\"", new_result_name.GetCString()); // Construct a new result global and set up its metadata @@ -215,7 +215,7 @@ named_metadata->addOperand(persistent_global_md); if (log) - log->Printf("Replacing %s with %s", + log->Printf("Replacing \"%s\" with \"%s\"", PrintValue(result_global).c_str(), PrintValue(new_result_global).c_str()); @@ -244,7 +244,7 @@ first_entry_instruction); if (log) - log->Printf("Synthesized result store %s\n", PrintValue(synthesized_store).c_str()); + log->Printf("Synthesized result store \"%s\"\n", PrintValue(synthesized_store).c_str()); } else { @@ -323,20 +323,20 @@ std::string omvn_initializer_string = omvn_initializer_array->getAsString(); if (log) - log->Printf("Found Objective-C selector reference %s", omvn_initializer_string.c_str()); + log->Printf("Found Objective-C selector reference \"%s\"", omvn_initializer_string.c_str()); // Construct a call to sel_registerName if (!m_sel_registerName) { - uint64_t srN_addr; + lldb::addr_t sel_registerName_addr; static lldb_private::ConstString g_sel_registerName_str ("sel_registerName"); - if (!m_decl_map->GetFunctionAddress (g_sel_registerName_str, srN_addr)) + if (!m_decl_map->GetFunctionAddress (g_sel_registerName_str, sel_registerName_addr)) return false; if (log) - log->Printf("Found sel_registerName at 0x%llx", srN_addr); + log->Printf("Found sel_registerName at 0x%llx", sel_registerName_addr); // Build the function type: struct objc_selector *sel_registerName(uint8_t*) @@ -353,7 +353,7 @@ const IntegerType *intptr_ty = Type::getIntNTy(M.getContext(), (M.getPointerSize() == Module::Pointer64) ? 64 : 32); PointerType *srN_ptr_ty = PointerType::getUnqual(srN_type); - Constant *srN_addr_int = ConstantInt::get(intptr_ty, srN_addr, false); + Constant *srN_addr_int = ConstantInt::get(intptr_ty, sel_registerName_addr, false); m_sel_registerName = ConstantExpr::getIntToPtr(srN_addr_int, srN_ptr_ty); } @@ -590,7 +590,7 @@ return true; if (log) - log->Printf("Found global variable %s without metadata", global_variable->getName().str().c_str()); + log->Printf("Found global variable \"%s\" without metadata", global_variable->getName().str().c_str()); return false; } @@ -617,7 +617,7 @@ off_t value_alignment = (ast_context->getTypeAlign(qual_type) + 7) / 8; if (log) - log->Printf("Type of %s is [clang %s, lldb %s] [size %d, align %d]", + log->Printf("Type of \"%s\" is [clang \"%s\", lldb \"%s\"] [size %d, align %d]", name.c_str(), qual_type.getAsString().c_str(), PrintType(value_type).c_str(), @@ -688,7 +688,7 @@ { default: if (log) - log->Printf("Unresolved intrinsic %s", Intrinsic::getName(intrinsic_id).c_str()); + log->Printf("Unresolved intrinsic \"%s\"", Intrinsic::getName(intrinsic_id).c_str()); return false; case Intrinsic::memcpy: { @@ -699,7 +699,7 @@ } if (log && str) - log->Printf("Resolved intrinsic name %s", str.GetCString()); + log->Printf("Resolved intrinsic name \"%s\"", str.GetCString()); } else { @@ -707,7 +707,7 @@ } clang::NamedDecl *fun_decl = DeclForGlobalValue (llvm_module, fun); - uint64_t fun_addr; + lldb::addr_t fun_addr = LLDB_INVALID_ADDRESS; Value **fun_value_ptr = NULL; if (fun_decl) @@ -719,7 +719,7 @@ if (!m_decl_map->GetFunctionAddress (str, fun_addr)) { if (log) - log->Printf("Function %s had no address", str.GetCString()); + log->Printf("Function \"%s\" had no address", str.GetCString()); return false; } @@ -730,12 +730,12 @@ if (!m_decl_map->GetFunctionAddress (str, fun_addr)) { if (log) - log->Printf ("Metadataless function %s had no address", str.GetCString()); + log->Printf ("Metadataless function \"%s\" had no address", str.GetCString()); } } if (log) - log->Printf("Found %s at %llx", str.GetCString(), fun_addr); + log->Printf("Found \"%s\" at 0x%llx", str.GetCString(), fun_addr); Value *fun_addr_ptr; @@ -766,7 +766,7 @@ llvm_call_inst->setMetadata("lldb.call.realName", func_metadata); if (log) - log->Printf("Set metadata for %p [%d, %s]", llvm_call_inst, func_name->isString(), func_name->getAsString().c_str()); + log->Printf("Set metadata for %p [%d, \"%s\"]", llvm_call_inst, func_name->isString(), func_name->getAsString().c_str()); return true; } @@ -952,7 +952,7 @@ { default: if (log) - log->Printf("Unhandled constant expression type: %s", PrintValue(constant_expr).c_str()); + log->Printf("Unhandled constant expression type: \"%s\"", PrintValue(constant_expr).c_str()); return false; case Instruction::BitCast: { @@ -1007,7 +1007,7 @@ else { if (log) - log->Printf("Unhandled constant type: %s", PrintValue(constant).c_str()); + log->Printf("Unhandled constant type: \"%s\"", PrintValue(constant).c_str()); return false; } } @@ -1064,7 +1064,7 @@ return false; if (log) - log->Printf("Arg: %s", PrintValue(argument).c_str()); + log->Printf("Arg: \"%s\"", PrintValue(argument).c_str()); BasicBlock &entry_block(F.getEntryBlock()); Instruction *first_entry_instruction(entry_block.getFirstNonPHIOrDbg()); @@ -1089,7 +1089,7 @@ return false; if (log) - log->Printf(" %s [%s] (%s) placed at %d", + log->Printf(" \"%s\" [\"%s\"] (\"%s\") placed at %d", value->getName().str().c_str(), name.GetCString(), PrintValue(value, true).c_str(), @@ -1124,7 +1124,7 @@ if (!function) { if (log) - log->Printf("Couldn't find %s() in the module", m_func_name.c_str()); + log->Printf("Couldn't find \"%s()\" in the module", m_func_name.c_str()); return false; } @@ -1178,7 +1178,7 @@ oss.flush(); - log->Printf("Module after preparing for execution: \n%s", s.c_str()); + log->Printf("Module after preparing for execution: \n\"%s\"", s.c_str()); } return true; Modified: lldb/trunk/test/objc/main.m URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/objc/main.m?rev=119103&r1=119102&r2=119103&view=diff ============================================================================== --- lldb/trunk/test/objc/main.m (original) +++ lldb/trunk/test/objc/main.m Sun Nov 14 19:47:11 2010 @@ -1,11 +1,58 @@ #import + at interface MyString : NSObject { + NSString *_string; + NSDate *_date; +} +- (id)initWithNSString:(NSString *)string; + + at property (copy) NSString *string; + at property (readonly,getter=getTheDate) NSDate *date; + +- (NSDate *) getTheDate; + at end + + at implementation MyString + + at synthesize string = _string; + at synthesize date = _date; + +- (id)initWithNSString:(NSString *)string +{ + if (self = [super init]) + { + _string = [NSString stringWithString:string]; + _date = [NSDate date]; + } + return self; +} + +- (void) dealloc +{ + [_date release]; + [_string release]; + [super dealloc]; +} + +- (NSDate *) getTheDate +{ + return _date; +} + +- (NSString *)description +{ + return [_string stringByAppendingFormat:@" with timestamp: %@", _date]; +} + at end + int main (int argc, char const *argv[]) { NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init]; static NSString *g_global_nsstr = @"Howdy"; - NSString *str1 = [NSString stringWithFormat:@"string %i", 1]; + + MyString *myStr = [[MyString alloc] initWithNSString: [NSString stringWithFormat:@"string %i", 1]]; + NSString *str1 = myStr.string; NSString *str2 = [NSString stringWithFormat:@"string %i", 2]; NSString *str3 = [NSString stringWithFormat:@"string %i", 3]; NSArray *array = [NSArray arrayWithObjects: str1, str2, str3, nil]; @@ -13,6 +60,7 @@ str1, @"1", str2, @"2", str3, @"3", + myStr.date, @"date", nil]; id str_id = str1;