From gclayton at apple.com Mon Dec 13 12:11:18 2010 From: gclayton at apple.com (Greg Clayton) Date: Mon, 13 Dec 2010 18:11:18 -0000 Subject: [Lldb-commits] [lldb] r121704 - /lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp Message-ID: <20101213181118.730BD2A6C12C@llvm.org> Author: gclayton Date: Mon Dec 13 12:11:18 2010 New Revision: 121704 URL: http://llvm.org/viewvc/llvm-project?rev=121704&view=rev Log: Fixed a crasher where when a ProcessGDBRemote class was being destroyed, it would eventually destroy the dynamic loader (when the lldb_private::Process::m_dynamic_loader_ap destroys itself in the object member destructor chain). The dynamic loader was calling a pure virtual method in Process which was causing a crash. The quick fix is to reset the auto pointer in the ProcessGDBRemote destructor when ProcessGDBRemote is still a valid object with all its pure virtual functions intact. Modified: lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp Modified: lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp?rev=121704&r1=121703&r2=121704&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp (original) +++ lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp Mon Dec 13 12:11:18 2010 @@ -131,6 +131,8 @@ //---------------------------------------------------------------------- ProcessGDBRemote::~ProcessGDBRemote() { + m_dynamic_loader_ap.reset(); + if (m_debugserver_thread != LLDB_INVALID_HOST_THREAD) { Host::ThreadCancel (m_debugserver_thread, NULL); From johnny.chen at apple.com Mon Dec 13 12:59:27 2010 From: johnny.chen at apple.com (Johnny Chen) Date: Mon, 13 Dec 2010 18:59:27 -0000 Subject: [Lldb-commits] [lldb] r121706 - /lldb/trunk/test/source-manager/TestSourceManager.py Message-ID: <20101213185927.5E2E12A6C12C@llvm.org> Author: johnny Date: Mon Dec 13 12:59:27 2010 New Revision: 121706 URL: http://llvm.org/viewvc/llvm-project?rev=121706&view=rev Log: Make the test case SourceManagerTestCase.display_source_python stronger by also matching the source line number displayed. Modified: lldb/trunk/test/source-manager/TestSourceManager.py Modified: lldb/trunk/test/source-manager/TestSourceManager.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/source-manager/TestSourceManager.py?rev=121706&r1=121705&r2=121706&view=diff ============================================================================== --- lldb/trunk/test/source-manager/TestSourceManager.py (original) +++ lldb/trunk/test/source-manager/TestSourceManager.py Mon Dec 13 12:59:27 2010 @@ -68,7 +68,7 @@ # 6 } self.expect(stream.GetData(), "Source code displayed correctly", exe=False, - patterns = ['=>.*Hello world']) + patterns = ['%d =>.*Hello world' % self.line]) def modify_source_file_while_debugging(self): """Modify a source file while debugging the executable.""" From ctice at apple.com Mon Dec 13 14:05:03 2010 From: ctice at apple.com (Caroline Tice) Date: Mon, 13 Dec 2010 20:05:03 -0000 Subject: [Lldb-commits] [lldb] r121712 - /lldb/trunk/source/Core/ConnectionFileDescriptor.cpp Message-ID: <20101213200503.9AF982A6C12C@llvm.org> Author: ctice Date: Mon Dec 13 14:05:03 2010 New Revision: 121712 URL: http://llvm.org/viewvc/llvm-project?rev=121712&view=rev Log: Revert a small but important part of the EOF handling code that Greg missed in his previous revert. Modified: lldb/trunk/source/Core/ConnectionFileDescriptor.cpp Modified: lldb/trunk/source/Core/ConnectionFileDescriptor.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/ConnectionFileDescriptor.cpp?rev=121712&r1=121711&r2=121712&view=diff ============================================================================== --- lldb/trunk/source/Core/ConnectionFileDescriptor.cpp (original) +++ lldb/trunk/source/Core/ConnectionFileDescriptor.cpp Mon Dec 13 14:05:03 2010 @@ -155,9 +155,13 @@ Error error; ssize_t bytes_read = ::read (m_fd, dst, dst_len); if (bytes_read == 0) +// Disable the end-of-file special handling stuff for now. Hopefully re-instate it (properly fixed) at a +// later date: { - error.Clear(); // End-of-file. Do not automatically close; pass along for the end-of-file handlers. - status = eConnectionStatusEndOfFile; +// error.Clear(); // End-of-file. Do not automatically close; pass along for the end-of-file handlers. +// status = eConnectionStatusEndOfFile; + error.SetErrorStringWithFormat("End-of-file.\n"); + status = eConnectionStatusLostConnection; } else if (bytes_read < 0) { From johnny.chen at apple.com Mon Dec 13 15:49:58 2010 From: johnny.chen at apple.com (Johnny Chen) Date: Mon, 13 Dec 2010 21:49:58 -0000 Subject: [Lldb-commits] [lldb] r121717 - in /lldb/trunk/test: breakpoint_ignore_count/ breakpoint_ignore_count/Makefile breakpoint_ignore_count/TestBreakpointIgnoreCount.py breakpoint_ignore_count/main.c lldbtest.py Message-ID: <20101213214958.466CB2A6C12C@llvm.org> Author: johnny Date: Mon Dec 13 15:49:58 2010 New Revision: 121717 URL: http://llvm.org/viewvc/llvm-project?rev=121717&view=rev Log: Add TestBreakpointIgnoreCount.py to exercise the breakpoint ignore count features, with both command line and Python API tests. Added: lldb/trunk/test/breakpoint_ignore_count/ lldb/trunk/test/breakpoint_ignore_count/Makefile lldb/trunk/test/breakpoint_ignore_count/TestBreakpointIgnoreCount.py lldb/trunk/test/breakpoint_ignore_count/main.c Modified: lldb/trunk/test/lldbtest.py Added: lldb/trunk/test/breakpoint_ignore_count/Makefile URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/breakpoint_ignore_count/Makefile?rev=121717&view=auto ============================================================================== --- lldb/trunk/test/breakpoint_ignore_count/Makefile (added) +++ lldb/trunk/test/breakpoint_ignore_count/Makefile Mon Dec 13 15:49:58 2010 @@ -0,0 +1,5 @@ +LEVEL = ../make + +C_SOURCES := main.c + +include $(LEVEL)/Makefile.rules Added: lldb/trunk/test/breakpoint_ignore_count/TestBreakpointIgnoreCount.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/breakpoint_ignore_count/TestBreakpointIgnoreCount.py?rev=121717&view=auto ============================================================================== --- lldb/trunk/test/breakpoint_ignore_count/TestBreakpointIgnoreCount.py (added) +++ lldb/trunk/test/breakpoint_ignore_count/TestBreakpointIgnoreCount.py Mon Dec 13 15:49:58 2010 @@ -0,0 +1,130 @@ +""" +Test breakpoint ignore count features. +""" + +import os, time +import re +import unittest2 +import lldb, lldbutil +from lldbtest import * + +class BreakpointIgnoreCountTestCase(TestBase): + + mydir = "breakpoint_ignore_count" + + @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin") + def test_with_dsym_and_run_command(self): + """Exercise breakpoint ignore count with 'breakpoint set -i '.""" + self.buildDsym() + self.breakpoint_ignore_count() + + @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin") + @python_api_test + def test_with_dsym_and_python_api(self): + """Use Python APIs to set breakpoint ignore count.""" + self.buildDsym() + self.breakpoint_ignore_count_python() + + def test_with_dwarf_and_run_command(self): + """Exercise breakpoint ignore count with 'breakpoint set -i '.""" + self.buildDwarf() + self.breakpoint_ignore_count() + + @python_api_test + def test_with_dwarf_and_python_api(self): + """Use Python APIs to set breakpoint ignore count.""" + self.buildDwarf() + self.breakpoint_ignore_count_python() + + def setUp(self): + # Call super's setUp(). + TestBase.setUp(self) + # Find the line number to of function 'c'. + self.line1 = line_number('main.c', '// Find the line number of function "c" here.') + self.line2 = line_number('main.c', '// b(2) -> c(2) Find the call site of b(2).') + self.line3 = line_number('main.c', '// a(3) -> c(3) Find the call site of c(3).') + self.line4 = line_number('main.c', '// a(3) -> c(3) Find the call site of a(3).') + + def breakpoint_ignore_count(self): + """Exercise breakpoint ignore count with 'breakpoint set -i '.""" + exe = os.path.join(os.getcwd(), "a.out") + self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) + + # Create a breakpoint by function name 'c'. + self.expect("breakpoint set -i 1 -f main.c -l %d" % self.line1, BREAKPOINT_CREATED, + startstr = "Breakpoint created: 1: file ='main.c', line = %d, locations = 1" % + self.line1) + + # Now run the program. + self.runCmd("run", RUN_SUCCEEDED) + + # The process should be stopped at this point. + self.expect("process status", PROCESS_STOPPED, + patterns = ['Process .* stopped']) + + # Also check the hit count, which should be 2, due to ignore count of 1. + self.expect("breakpoint list", BREAKPOINT_HIT_THRICE, + substrs = ["resolved = 1", + "hit count = 2"]) + + # The frame #0 should correspond to main.c:37, the executable statement + # in function name 'c'. And frame #2 should point to main.c:45. + self.expect("thread backtrace", STOPPED_DUE_TO_BREAKPOINT_IGNORE_COUNT, + #substrs = ["stop reason = breakpoint"], + patterns = ["frame #0.*main.c:%d" % self.line1, + "frame #2.*main.c:%d" % self.line2]) + + def breakpoint_ignore_count_python(self): + """Use Python APIs to set breakpoint ignore count.""" + exe = os.path.join(os.getcwd(), "a.out") + + # Create a target by the debugger. + target = self.dbg.CreateTarget(exe) + self.assertTrue(target.IsValid(), VALID_TARGET) + + # Now create a breakpoint on main.c by name 'c'. + breakpoint = target.BreakpointCreateByName('c', 'a.out') + self.assertTrue(breakpoint.IsValid() and + breakpoint.GetNumLocations() == 1, + VALID_BREAKPOINT) + + # Get the breakpoint location from breakpoint after we verified that, + # indeed, it has one location. + location = breakpoint.GetLocationAtIndex(0) + self.assertTrue(location.IsValid() and + location.IsEnabled(), + VALID_BREAKPOINT_LOCATION) + + # Set the ignore count on the breakpoint location. + location.SetIgnoreCount(2) + self.assertTrue(location.GetIgnoreCount() == 2, + "SetIgnoreCount() works correctly") + + # Now launch the process, and do not stop at entry point. + self.process = target.LaunchProcess([''], [''], os.ctermid(), 0, False) + + self.process = target.GetProcess() + self.assertTrue(self.process.IsValid(), PROCESS_IS_VALID) + + # Frame#0 should be on main.c:37, frame#1 should be on main.c:25, and + # frame#2 should be on main.c:48. + #lldbutil.PrintStackTraces(self.process) + frame0 = self.process.GetThreadAtIndex(0).GetFrameAtIndex(0) + frame1 = self.process.GetThreadAtIndex(0).GetFrameAtIndex(1) + frame2 = self.process.GetThreadAtIndex(0).GetFrameAtIndex(2) + self.assertTrue(frame0.GetLineEntry().GetLine() == self.line1 and + frame1.GetLineEntry().GetLine() == self.line3 and + frame2.GetLineEntry().GetLine() == self.line4, + STOPPED_DUE_TO_BREAKPOINT_IGNORE_COUNT) + + # The hit count for the breakpoint should be 3. + self.assertTrue(breakpoint.GetHitCount() == 3) + + self.process.Continue() + + +if __name__ == '__main__': + import atexit + lldb.SBDebugger.Initialize() + atexit.register(lambda: lldb.SBDebugger.Terminate()) + unittest2.main() Added: lldb/trunk/test/breakpoint_ignore_count/main.c URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/breakpoint_ignore_count/main.c?rev=121717&view=auto ============================================================================== --- lldb/trunk/test/breakpoint_ignore_count/main.c (added) +++ lldb/trunk/test/breakpoint_ignore_count/main.c Mon Dec 13 15:49:58 2010 @@ -0,0 +1,52 @@ +//===-- 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 modify -i breakpt-id" to set the number of times a +// breakpoint is skipped before stopping. Ignore count can also be set upon +// breakpoint creation by 'breakpoint set ... -i '. + +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); // a(3) -> c(3) Find the call site of c(3). + + return val; +} + +int b(int val) +{ + return c(val); +} + +int c(int val) +{ + return val + 3; // Find the line number of function "c" here. +} + +int main (int argc, char const *argv[]) +{ + int A1 = a(1); // a(1) -> b(1) -> c(1) + printf("a(1) returns %d\n", A1); + + int B2 = b(2); // b(2) -> c(2) Find the call site of b(2). + printf("b(2) returns %d\n", B2); + + int A3 = a(3); // a(3) -> c(3) Find the call site of a(3). + printf("a(3) returns %d\n", A3); + + return 0; +} Modified: lldb/trunk/test/lldbtest.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/lldbtest.py?rev=121717&r1=121716&r2=121717&view=diff ============================================================================== --- lldb/trunk/test/lldbtest.py (original) +++ lldb/trunk/test/lldbtest.py Mon Dec 13 15:49:58 2010 @@ -164,6 +164,8 @@ STOPPED_DUE_TO_BREAKPOINT_CONDITION = "Stopped due to breakpoint condition" +STOPPED_DUE_TO_BREAKPOINT_IGNORE_COUNT = "Stopped due to breakpoint and ignore count" + STOPPED_DUE_TO_SIGNAL = "Process state is stopped due to signal" STOPPED_DUE_TO_STEP_IN = "Process state is stopped due to step in" From scallanan at apple.com Mon Dec 13 16:46:15 2010 From: scallanan at apple.com (Sean Callanan) Date: Mon, 13 Dec 2010 22:46:15 -0000 Subject: [Lldb-commits] [lldb] r121722 - in /lldb/trunk: include/lldb/Core/ include/lldb/Expression/ include/lldb/Symbol/ include/lldb/Target/ source/Expression/ source/Plugins/ABI/MacOSX-i386/ source/Plugins/ABI/SysV-x86_64/ source/Symbol/ source/Target/ Message-ID: <20101213224615.960C12A6C12C@llvm.org> Author: spyffe Date: Mon Dec 13 16:46:15 2010 New Revision: 121722 URL: http://llvm.org/viewvc/llvm-project?rev=121722&view=rev Log: Added support for generating expressions that have access to the members of the Objective-C self object. The approach we take is to generate the method as a @category on top of the self object, and to pass the "self" pointer to it. (_cmd is currently NULL.) Most changes are in ClangExpressionDeclMap, but the change that adds support to the ABIs to pass _cmd touches a fair amount of code. Modified: lldb/trunk/include/lldb/Core/ClangForward.h lldb/trunk/include/lldb/Expression/ASTResultSynthesizer.h lldb/trunk/include/lldb/Expression/ClangExpressionDeclMap.h lldb/trunk/include/lldb/Expression/ClangFunction.h lldb/trunk/include/lldb/Symbol/ClangASTType.h lldb/trunk/include/lldb/Target/ABI.h lldb/trunk/include/lldb/Target/ThreadPlanCallFunction.h lldb/trunk/include/lldb/Target/ThreadPlanCallUserExpression.h lldb/trunk/source/Expression/ASTResultSynthesizer.cpp lldb/trunk/source/Expression/ClangASTSource.cpp lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp lldb/trunk/source/Expression/ClangFunction.cpp lldb/trunk/source/Expression/ClangUserExpression.cpp lldb/trunk/source/Expression/IRForTarget.cpp lldb/trunk/source/Plugins/ABI/MacOSX-i386/ABIMacOSX_i386.cpp lldb/trunk/source/Plugins/ABI/MacOSX-i386/ABIMacOSX_i386.h lldb/trunk/source/Plugins/ABI/SysV-x86_64/ABISysV_x86_64.cpp lldb/trunk/source/Plugins/ABI/SysV-x86_64/ABISysV_x86_64.h lldb/trunk/source/Symbol/ClangASTType.cpp lldb/trunk/source/Target/ThreadPlanCallFunction.cpp lldb/trunk/source/Target/ThreadPlanCallUserExpression.cpp Modified: lldb/trunk/include/lldb/Core/ClangForward.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/ClangForward.h?rev=121722&r1=121721&r2=121722&view=diff ============================================================================== --- lldb/trunk/include/lldb/Core/ClangForward.h (original) +++ lldb/trunk/include/lldb/Core/ClangForward.h Mon Dec 13 16:46:15 2010 @@ -34,6 +34,7 @@ class CodeGenOptions; class CodeGenerator; class CompilerInstance; + class CompoundStmt; class CXXBaseSpecifier; class CXXBoolLiteralExpr; class CXXFunctionalCastExpr; Modified: lldb/trunk/include/lldb/Expression/ASTResultSynthesizer.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Expression/ASTResultSynthesizer.h?rev=121722&r1=121721&r2=121722&view=diff ============================================================================== --- lldb/trunk/include/lldb/Expression/ASTResultSynthesizer.h (original) +++ lldb/trunk/include/lldb/Expression/ASTResultSynthesizer.h Mon Dec 13 16:46:15 2010 @@ -123,12 +123,31 @@ void TransformTopLevelDecl(clang::Decl *D); //---------------------------------------------------------------------- + /// Process an Objective-C method and produce the result variable and + /// initialization + /// + /// @param[in] MethodDecl + /// The method to process. + //---------------------------------------------------------------------- + bool SynthesizeObjCMethodResult(clang::ObjCMethodDecl *MethodDecl); + + //---------------------------------------------------------------------- /// Process a function and produce the result variable and initialization /// /// @param[in] FunDecl /// The function to process. //---------------------------------------------------------------------- - bool SynthesizeResult(clang::FunctionDecl *FunDecl); + bool SynthesizeFunctionResult(clang::FunctionDecl *FunDecl); + + //---------------------------------------------------------------------- + /// Process a functionbody and produce the result variable and + /// initialization + /// + /// @param[in] Body + /// The body of the function. + //---------------------------------------------------------------------- + bool SynthesizeBodyResult(clang::CompoundStmt *Body, + clang::DeclContext *DC); clang::ASTContext *m_ast_context; ///< The AST context to use for identifiers and types. clang::ASTConsumer *m_passthrough; ///< The ASTConsumer down the chain, for passthrough. NULL if it's a SemaConsumer. Modified: lldb/trunk/include/lldb/Expression/ClangExpressionDeclMap.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Expression/ClangExpressionDeclMap.h?rev=121722&r1=121721&r2=121722&view=diff ============================================================================== --- lldb/trunk/include/lldb/Expression/ClangExpressionDeclMap.h (original) +++ lldb/trunk/include/lldb/Expression/ClangExpressionDeclMap.h Mon Dec 13 16:46:15 2010 @@ -291,6 +291,10 @@ /// @param[out] object_ptr /// The this pointer. /// + /// @param[in] object_name + /// The name of the object pointer -- "this," "self," or similar + /// depending on language + /// /// @param[in] exe_ctx /// The execution context at which to dump the struct. /// @@ -302,6 +306,7 @@ /// True on success; false otherwise. //------------------------------------------------------------------ bool GetObjectPointer(lldb::addr_t &object_ptr, + ConstString &object_name, ExecutionContext &exe_ctx, Error &error); Modified: lldb/trunk/include/lldb/Expression/ClangFunction.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Expression/ClangFunction.h?rev=121722&r1=121721&r2=121722&view=diff ============================================================================== --- lldb/trunk/include/lldb/Expression/ClangFunction.h (original) +++ lldb/trunk/include/lldb/Expression/ClangFunction.h Mon Dec 13 16:46:15 2010 @@ -423,8 +423,13 @@ /// True if the thread plan may simply be discarded if an error occurs. /// /// @param[in] this_arg - /// If non-NULL, the function is invoked like a C++ method, with the - /// value pointed to by the pointer as its 'this' argument. + /// If non-NULL (and cmd_arg is NULL), the function is invoked like a C++ + /// method, with the value pointed to by the pointer as its 'this' + /// argument. + /// + /// @param[in] cmd_arg + /// If non-NULL, the function is invoked like an Objective-C method, with + /// this_arg in the 'self' slot and cmd_arg in the '_cmd' slot /// /// @return /// A ThreadPlan for executing the function. @@ -436,7 +441,8 @@ Stream &errors, bool stop_others, bool discard_on_error, - lldb::addr_t *this_arg = 0); + lldb::addr_t *this_arg = 0, + lldb::addr_t *cmd_arg = 0); //------------------------------------------------------------------ /// Get a thread plan to run the function this ClangFunction was created with. Modified: lldb/trunk/include/lldb/Symbol/ClangASTType.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Symbol/ClangASTType.h?rev=121722&r1=121721&r2=121722&view=diff ============================================================================== --- lldb/trunk/include/lldb/Symbol/ClangASTType.h (original) +++ lldb/trunk/include/lldb/Symbol/ClangASTType.h Mon Dec 13 16:46:15 2010 @@ -162,6 +162,12 @@ DumpTypeDescription (clang::ASTContext *ast_context, lldb::clang_type_t opaque_clang_qual_type, Stream *s); + + void DumpTypeCode (Stream *s); + + static void + DumpTypeCode (void *type, + Stream *s); lldb::Encoding GetEncoding (uint32_t &count); Modified: lldb/trunk/include/lldb/Target/ABI.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/ABI.h?rev=121722&r1=121721&r2=121722&view=diff ============================================================================== --- lldb/trunk/include/lldb/Target/ABI.h (original) +++ lldb/trunk/include/lldb/Target/ABI.h Mon Dec 13 16:46:15 2010 @@ -35,7 +35,8 @@ lldb::addr_t functionAddress, lldb::addr_t returnAddress, lldb::addr_t arg, - lldb::addr_t *this_arg) const = 0; + lldb::addr_t *this_arg, + lldb::addr_t *cmd_arg) const = 0; virtual bool GetArgumentValues (Thread &thread, Modified: lldb/trunk/include/lldb/Target/ThreadPlanCallFunction.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/ThreadPlanCallFunction.h?rev=121722&r1=121721&r2=121722&view=diff ============================================================================== --- lldb/trunk/include/lldb/Target/ThreadPlanCallFunction.h (original) +++ lldb/trunk/include/lldb/Target/ThreadPlanCallFunction.h Mon Dec 13 16:46:15 2010 @@ -28,7 +28,8 @@ lldb::addr_t arg, bool stop_other_threads, bool discard_on_error = true, - lldb::addr_t *this_arg = 0); + lldb::addr_t *this_arg = 0, + lldb::addr_t *cmd_arg = 0); virtual ~ThreadPlanCallFunction (); Modified: lldb/trunk/include/lldb/Target/ThreadPlanCallUserExpression.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/ThreadPlanCallUserExpression.h?rev=121722&r1=121721&r2=121722&view=diff ============================================================================== --- lldb/trunk/include/lldb/Target/ThreadPlanCallUserExpression.h (original) +++ lldb/trunk/include/lldb/Target/ThreadPlanCallUserExpression.h Mon Dec 13 16:46:15 2010 @@ -31,6 +31,7 @@ bool stop_other_threads, bool discard_on_error, lldb::addr_t *this_arg, + lldb::addr_t *cmd_arg, ClangUserExpression::ClangUserExpressionSP &user_expression_sp); virtual Modified: lldb/trunk/source/Expression/ASTResultSynthesizer.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/ASTResultSynthesizer.cpp?rev=121722&r1=121721&r2=121722&view=diff ============================================================================== --- lldb/trunk/source/Expression/ASTResultSynthesizer.cpp (original) +++ lldb/trunk/source/Expression/ASTResultSynthesizer.cpp Mon Dec 13 16:46:15 2010 @@ -12,6 +12,7 @@ #include "clang/AST/Decl.h" #include "clang/AST/DeclCXX.h" #include "clang/AST/DeclGroup.h" +#include "clang/AST/DeclObjC.h" #include "clang/AST/Expr.h" #include "clang/AST/Stmt.h" #include "clang/Parse/Parser.h" @@ -54,9 +55,23 @@ void ASTResultSynthesizer::TransformTopLevelDecl(Decl* D) { - LinkageSpecDecl *linkage_spec_decl = dyn_cast(D); + lldb::LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS)); + + if (NamedDecl *named_decl = dyn_cast(D)) + { + if (log) + { + if (named_decl->getIdentifier()) + log->Printf("TransformTopLevelDecl(%s)", named_decl->getIdentifier()->getNameStart()); + else if (ObjCMethodDecl *method_decl = dyn_cast(D)) + log->Printf("TransformTopLevelDecl(%s)", method_decl->getSelector().getAsString().c_str()); + else + log->Printf("TransformTopLevelDecl()"); + } + + } - if (linkage_spec_decl) + if (LinkageSpecDecl *linkage_spec_decl = dyn_cast(D)) { RecordDecl::decl_iterator decl_iterator; @@ -67,14 +82,21 @@ TransformTopLevelDecl(*decl_iterator); } } - - FunctionDecl *function_decl = dyn_cast(D); - - if (m_ast_context && - function_decl && - !function_decl->getNameInfo().getAsString().compare("$__lldb_expr")) + else if (ObjCMethodDecl *method_decl = dyn_cast(D)) { - SynthesizeResult(function_decl); + if (m_ast_context && + !method_decl->getSelector().getAsString().compare("$__lldb_expr:")) + { + SynthesizeObjCMethodResult(method_decl); + } + } + else if (FunctionDecl *function_decl = dyn_cast(D)) + { + if (m_ast_context && + !function_decl->getNameInfo().getAsString().compare("$__lldb_expr")) + { + SynthesizeFunctionResult(function_decl); + } } } @@ -97,15 +119,15 @@ } bool -ASTResultSynthesizer::SynthesizeResult (FunctionDecl *FunDecl) +ASTResultSynthesizer::SynthesizeFunctionResult (FunctionDecl *FunDecl) { - ASTContext &Ctx(*m_ast_context); - lldb::LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS)); + ASTContext &Ctx(*m_ast_context); + if (!m_sema) return false; - + FunctionDecl *function_decl = FunDecl; if (!function_decl) @@ -126,6 +148,80 @@ Stmt *function_body = function_decl->getBody(); CompoundStmt *compound_stmt = dyn_cast(function_body); + bool ret = SynthesizeBodyResult (compound_stmt, + function_decl); + + if (log) + { + std::string s; + raw_string_ostream os(s); + + function_decl->print(os); + + os.flush(); + + log->Printf("Transformed function AST:\n%s", s.c_str()); + } + + return ret; +} + +bool +ASTResultSynthesizer::SynthesizeObjCMethodResult (ObjCMethodDecl *MethodDecl) +{ + lldb::LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS)); + + ASTContext &Ctx(*m_ast_context); + + if (!m_sema) + return false; + + if (!MethodDecl) + return false; + + if (log) + { + std::string s; + raw_string_ostream os(s); + + Ctx.getTranslationUnitDecl()->print(os); + + os.flush(); + + log->Printf("AST context before transforming:\n%s", s.c_str()); + } + + Stmt *method_body = MethodDecl->getBody(); + CompoundStmt *compound_stmt = dyn_cast(method_body); + + bool ret = SynthesizeBodyResult (compound_stmt, + MethodDecl); + + if (log) + { + std::string s; + raw_string_ostream os(s); + + MethodDecl->print(os); + + os.flush(); + + log->Printf("Transformed function AST:\n%s", s.c_str()); + } + + return ret; +} + +bool +ASTResultSynthesizer::SynthesizeBodyResult (CompoundStmt *Body, + DeclContext *DC) +{ + lldb::LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS)); + + ASTContext &Ctx(*m_ast_context); + + CompoundStmt *compound_stmt = dyn_cast(Body); + if (!compound_stmt) return false; @@ -169,7 +265,7 @@ IdentifierInfo &result_id = Ctx.Idents.get("$__lldb_expr_result"); clang::VarDecl *result_decl = VarDecl::Create(Ctx, - function_decl, + DC, SourceLocation(), &result_id, expr_qual_type, @@ -180,7 +276,7 @@ if (!result_decl) return false; - function_decl->addDecl(result_decl); + DC->addDecl(result_decl); /////////////////////////////// // call AddInitializerToDecl @@ -210,18 +306,6 @@ *last_stmt_ptr = reinterpret_cast(result_initialization_stmt_result.take()); - if (log) - { - std::string s; - raw_string_ostream os(s); - - function_decl->print(os); - - os.flush(); - - log->Printf("Transformed function AST:\n%s", s.c_str()); - } - return true; } Modified: lldb/trunk/source/Expression/ClangASTSource.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/ClangASTSource.cpp?rev=121722&r1=121721&r2=121722&view=diff ============================================================================== --- lldb/trunk/source/Expression/ClangASTSource.cpp (original) +++ lldb/trunk/source/Expression/ClangASTSource.cpp Mon Dec 13 16:46:15 2010 @@ -227,6 +227,14 @@ return tag_decl; } + else if (ObjCObjectType *objc_object_type = dyn_cast(qual_type)) + { + ObjCInterfaceDecl *interface_decl = objc_object_type->getInterface(); + + m_decls.push_back((NamedDecl*)interface_decl); + + return (NamedDecl*)interface_decl; + } else { return NULL; Modified: lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp?rev=121722&r1=121721&r2=121722&view=diff ============================================================================== --- lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp (original) +++ lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp Mon Dec 13 16:46:15 2010 @@ -371,6 +371,7 @@ ClangExpressionDeclMap::GetObjectPointer ( lldb::addr_t &object_ptr, + ConstString &object_name, ExecutionContext &exe_ctx, Error &err ) @@ -389,12 +390,11 @@ return false; } - static ConstString g_this_const_str ("this"); - Variable *object_ptr_var = FindVariableInScope (*exe_ctx.frame, g_this_const_str, &m_struct_vars->m_object_pointer_type); + Variable *object_ptr_var = FindVariableInScope (*exe_ctx.frame, object_name, &m_struct_vars->m_object_pointer_type); if (!object_ptr_var) { - err.SetErrorString("Couldn't find 'this' with appropriate type in scope"); + err.SetErrorStringWithFormat("Couldn't find '%s' with appropriate type in scope", object_name.GetCString()); return false; } @@ -404,7 +404,7 @@ if (!location_value.get()) { - err.SetErrorString("Couldn't get the location for 'this'"); + err.SetErrorStringWithFormat("Couldn't get the location for '%s'", object_name.GetCString()); return false; } @@ -417,7 +417,7 @@ if (ClangASTType::GetClangTypeBitWidth(m_struct_vars->m_object_pointer_type.GetASTContext(), m_struct_vars->m_object_pointer_type.GetOpaqueQualType()) != address_byte_size * 8) { - err.SetErrorStringWithFormat("'this' is not of an expected pointer size"); + err.SetErrorStringWithFormat("'%s' is not of an expected pointer size", object_name.GetCString()); return false; } @@ -427,7 +427,7 @@ if (exe_ctx.process->ReadMemory (value_addr, data.GetBytes(), address_byte_size, read_error) != address_byte_size) { - err.SetErrorStringWithFormat("Coldn't read 'this' from the target: %s", read_error.AsCString()); + err.SetErrorStringWithFormat("Coldn't read '%s' from the target: %s", object_name.GetCString(), read_error.AsCString()); return false; } @@ -441,7 +441,7 @@ } else { - err.SetErrorString("'this' is not in memory; LLDB must be extended to handle registers"); + err.SetErrorStringWithFormat("'%s' is not in memory; LLDB must be extended to handle registers", object_name.GetCString()); return false; } } @@ -1250,11 +1250,66 @@ TypeFromUser class_user_type(pointer_target_type, this_type->GetClangAST()); + if (log) + { + StreamString type_stream; + class_user_type.DumpTypeCode(&type_stream); + type_stream.Flush(); + log->Printf("Adding type for $__lldb_class: %s", type_stream.GetString().c_str()); + } + AddOneType(context, class_user_type, true); return; } + static ConstString g_lldb_objc_class_name ("$__lldb_objc_class"); + if (name == g_lldb_objc_class_name) + { + // Clang is looking for the type of "*self" + + VariableList *vars = m_parser_vars->m_exe_ctx->frame->GetVariableList(false); + + if (!vars) + return; + + lldb::VariableSP self_var = vars->FindVariable(ConstString("self")); + + if (!self_var) + return; + + Type *self_type = self_var->GetType(); + + if (!self_type) + return; + + TypeFromUser self_user_type(self_type->GetClangType(), + self_type->GetClangAST()); + + m_struct_vars->m_object_pointer_type = self_user_type; + + void *pointer_target_type; + + if (!ClangASTContext::IsPointerType(self_user_type.GetOpaqueQualType(), + &pointer_target_type)) + return; + + TypeFromUser class_user_type(pointer_target_type, + self_type->GetClangAST()); + + if (log) + { + StreamString type_stream; + class_user_type.DumpTypeCode(&type_stream); + type_stream.Flush(); + log->Printf("Adding type for $__lldb_objc_class: %s", type_stream.GetString().c_str()); + } + + AddOneType(context, class_user_type, false); + + return; + } + ClangExpressionVariable *pvar(m_parser_vars->m_persistent_vars->GetVariable(name)); if (pvar) Modified: lldb/trunk/source/Expression/ClangFunction.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/ClangFunction.cpp?rev=121722&r1=121721&r2=121722&view=diff ============================================================================== --- lldb/trunk/source/Expression/ClangFunction.cpp (original) +++ lldb/trunk/source/Expression/ClangFunction.cpp Mon Dec 13 16:46:15 2010 @@ -372,7 +372,8 @@ Stream &errors, bool stop_others, bool discard_on_error, - lldb::addr_t *this_arg) + lldb::addr_t *this_arg, + lldb::addr_t *cmd_arg) { // FIXME: Use the errors Stream for better error reporting. @@ -388,11 +389,12 @@ Address wrapper_address (NULL, func_addr); ThreadPlan *new_plan = new ThreadPlanCallFunction (*exe_ctx.thread, - wrapper_address, - args_addr, - stop_others, - discard_on_error, - this_arg); + wrapper_address, + args_addr, + stop_others, + discard_on_error, + this_arg, + cmd_arg); return new_plan; } Modified: lldb/trunk/source/Expression/ClangUserExpression.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/ClangUserExpression.cpp?rev=121722&r1=121721&r2=121722&view=diff ============================================================================== --- lldb/trunk/source/Expression/ClangUserExpression.cpp (original) +++ lldb/trunk/source/Expression/ClangUserExpression.cpp Mon Dec 13 16:46:15 2010 @@ -174,6 +174,27 @@ m_needs_object_ptr = true; } + else if(m_objectivec) + { + const char *function_name = FunctionName(); + + m_transformed_stream.Printf("%s \n" + "@interface $__lldb_objc_class ($__lldb_category) \n" + "-(void)%s:(void *)$__lldb_arg; \n" + "@end \n" + "@implementation $__lldb_objc_class ($__lldb_category) \n" + "-(void)%s:(void *)$__lldb_arg \n" + "{ \n" + " %s; \n" + "} \n" + "@end \n", + m_expr_prefix.c_str(), + function_name, + function_name, + m_expr_text.c_str()); + + m_needs_object_ptr = true; + } else { m_transformed_stream.Printf("%s \n" @@ -297,14 +318,31 @@ if (m_jit_addr != LLDB_INVALID_ADDRESS) { - Error materialize_error; - - if (m_needs_object_ptr && !(m_expr_decl_map->GetObjectPointer(object_ptr, exe_ctx, materialize_error))) + if (m_needs_object_ptr) { - error_stream.Printf("Couldn't get required object pointer: %s\n", materialize_error.AsCString()); - return false; + ConstString object_name; + + if (m_cplusplus) + { + object_name.SetCString("this"); + } + else if (m_objectivec) + { + object_name.SetCString("self"); + } + else + { + error_stream.Printf("Need object pointer but don't know the language\n"); + return false; + } + + if (!(m_expr_decl_map->GetObjectPointer(object_ptr, object_name, exe_ctx, materialize_error))) + { + error_stream.Printf("Couldn't get required object pointer: %s\n", materialize_error.AsCString()); + return false; + } } if (!m_expr_decl_map->Materialize(exe_ctx, struct_address, materialize_error)) @@ -351,19 +389,22 @@ lldb::addr_t struct_address; lldb::addr_t object_ptr = NULL; + lldb::addr_t cmd_ptr = NULL; PrepareToExecuteJITExpression (error_stream, exe_ctx, struct_address, object_ptr); // FIXME: This should really return a ThreadPlanCallUserExpression, in order to make sure that we don't release the // ClangUserExpression resources before the thread plan finishes execution in the target. But because we are - // forcing unwind_on_error to be true here, in practical terms that can't happen. + // forcing unwind_on_error to be true here, in practical terms that can't happen. + return ClangFunction::GetThreadPlanToCallFunction (exe_ctx, m_jit_addr, struct_address, error_stream, true, true, - (m_needs_object_ptr ? &object_ptr : NULL)); + (m_needs_object_ptr ? &object_ptr : NULL), + (m_needs_object_ptr && m_objectivec) ? &cmd_ptr : NULL); } bool @@ -423,17 +464,24 @@ lldb::addr_t struct_address; lldb::addr_t object_ptr = NULL; + lldb::addr_t cmd_ptr = NULL; - PrepareToExecuteJITExpression (error_stream, exe_ctx, struct_address, object_ptr); + if (!PrepareToExecuteJITExpression (error_stream, exe_ctx, struct_address, object_ptr)) + return Process::eExecutionSetupError; const bool stop_others = true; const bool try_all_threads = true; Address wrapper_address (NULL, m_jit_addr); - lldb::ThreadPlanSP call_plan_sp(new ThreadPlanCallUserExpression (*(exe_ctx.thread), wrapper_address, struct_address, - stop_others, discard_on_error, - (m_needs_object_ptr ? &object_ptr : NULL), - shared_ptr_to_me)); + lldb::ThreadPlanSP call_plan_sp(new ThreadPlanCallUserExpression (*(exe_ctx.thread), + wrapper_address, + struct_address, + stop_others, + discard_on_error, + (m_needs_object_ptr ? &object_ptr : NULL), + ((m_needs_object_ptr && m_objectivec) ? &cmd_ptr : NULL), + shared_ptr_to_me)); + if (call_plan_sp == NULL || !call_plan_sp->ValidatePlan (NULL)) return Process::eExecutionSetupError; Modified: lldb/trunk/source/Expression/IRForTarget.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/IRForTarget.cpp?rev=121722&r1=121721&r2=121722&view=diff ============================================================================== --- lldb/trunk/source/Expression/IRForTarget.cpp (original) +++ lldb/trunk/source/Expression/IRForTarget.cpp Mon Dec 13 16:46:15 2010 @@ -899,7 +899,7 @@ size_t value_size = (ast_context->getTypeSize(qual_type) + 7) / 8; 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]", name.c_str(), @@ -907,7 +907,7 @@ PrintType(value_type).c_str(), value_size, value_alignment); - + if (named_decl && !m_decl_map->AddValueToStruct(named_decl, lldb_private::ConstString (name.c_str()), @@ -1353,6 +1353,23 @@ argument = iter; } + else if (argument->getName().equals("self")) + { + ++iter; + + if (iter == llvm_function.getArgumentList().end()) + return false; + + if (!iter->getName().equals("_cmd")) + return false; + + ++iter; + + if (iter == llvm_function.getArgumentList().end()) + return false; + + argument = iter; + } if (!argument->getName().equals("$__lldb_arg")) return false; @@ -1430,7 +1447,11 @@ // if (!CreateResultVariable(llvm_module, *function)) + { + if (log) + log->Printf("CreateResultVariable() failed"); return false; + } /////////////////////////////////////////////////////////////////////////////// // Fix all Objective-C constant strings to use NSStringWithCString:encoding: @@ -1449,7 +1470,11 @@ } if (!RewriteObjCConstStrings(llvm_module, *function)) + { + if (log) + log->Printf("RewriteObjCConstStrings() failed"); return false; + } if (log) { @@ -1472,16 +1497,32 @@ ++bbi) { if (!RemoveGuards(llvm_module, *bbi)) + { + if (log) + log->Printf("RemoveGuards() failed"); return false; + } if (!RewritePersistentAllocs(llvm_module, *bbi)) + { + if (log) + log->Printf("RewritePersistentAllocs() failed"); return false; + } if (!RewriteObjCSelectors(llvm_module, *bbi)) + { + if (log) + log->Printf("RewriteObjCSelectors() failed"); return false; + } if (!ResolveCalls(llvm_module, *bbi)) + { + if (log) + log->Printf("ResolveCalls() failed"); return false; + } } /////////////////////////////// @@ -1489,10 +1530,18 @@ // if (!ResolveExternals(llvm_module, *function)) + { + if (log) + log->Printf("ResolveExternals() failed"); return false; + } if (!ReplaceVariables(llvm_module, *function)) + { + if (log) + log->Printf("ReplaceVariables() failed"); return false; + } if (log) { 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=121722&r1=121721&r2=121722&view=diff ============================================================================== --- lldb/trunk/source/Plugins/ABI/MacOSX-i386/ABIMacOSX_i386.cpp (original) +++ lldb/trunk/source/Plugins/ABI/MacOSX-i386/ABIMacOSX_i386.cpp Mon Dec 13 16:46:15 2010 @@ -58,7 +58,8 @@ lldb::addr_t functionAddress, lldb::addr_t returnAddress, lldb::addr_t arg, - lldb::addr_t *this_arg) const + lldb::addr_t *this_arg, + lldb::addr_t *cmd_arg) const { RegisterContext *reg_ctx = thread.GetRegisterContext(); if (!reg_ctx) @@ -73,7 +74,9 @@ // Make room for the argument(s) on the stack - if (this_arg) + if (this_arg && cmd_arg) + sp -= 12; + else if (this_arg) sp -= 8; else sp -= 4; @@ -86,6 +89,19 @@ Error error; + if (this_arg && cmd_arg) + { + uint32_t cmd_argU32 = *cmd_arg & 0xffffffffull; + uint32_t this_argU32 = *this_arg & 0xffffffffull; + uint32_t argU32 = arg & 0xffffffffull; + + if (thread.GetProcess().WriteMemory(sp, &this_argU32, sizeof(this_argU32), error) != sizeof(this_argU32)) + return false; + if (thread.GetProcess().WriteMemory(sp, &cmd_argU32, sizeof(cmd_argU32), error) != sizeof(cmd_argU32)) + return false; + if (thread.GetProcess().WriteMemory(sp + 4, &argU32, sizeof(argU32), error) != sizeof(argU32)) + return false; + } if (this_arg) { uint32_t this_argU32 = *this_arg & 0xffffffffull; Modified: lldb/trunk/source/Plugins/ABI/MacOSX-i386/ABIMacOSX_i386.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ABI/MacOSX-i386/ABIMacOSX_i386.h?rev=121722&r1=121721&r2=121722&view=diff ============================================================================== --- lldb/trunk/source/Plugins/ABI/MacOSX-i386/ABIMacOSX_i386.h (original) +++ lldb/trunk/source/Plugins/ABI/MacOSX-i386/ABIMacOSX_i386.h Mon Dec 13 16:46:15 2010 @@ -35,7 +35,8 @@ lldb::addr_t functionAddress, lldb::addr_t returnAddress, lldb::addr_t arg, - lldb::addr_t *this_arg) const; + lldb::addr_t *this_arg, + lldb::addr_t *cmd_arg) const; virtual bool PrepareNormalCall (Thread &thread, 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=121722&r1=121721&r2=121722&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 Mon Dec 13 16:46:15 2010 @@ -59,18 +59,22 @@ lldb::addr_t functionAddress, lldb::addr_t returnAddress, lldb::addr_t arg, - lldb::addr_t *this_arg) const + lldb::addr_t *this_arg, + lldb::addr_t *cmd_arg) const { LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS)); if (log) - log->Printf("ABISysV_x86_64::PrepareTrivialCall\n(\n thread = %p\n sp = 0x%llx\n functionAddress = 0x%llx\n returnAddress = 0x%llx\n arg = 0x%llx\n this_arg = %p(0x%llx)\n)", + log->Printf("ABISysV_x86_64::PrepareTrivialCall\n(\n thread = %p\n sp = 0x%llx\n functionAddress = 0x%llx\n returnAddress = 0x%llx\n arg = 0x%llx\n this_arg = %p(0x%llx)\n cmd_arg = %p(0x%llx)\n)", (void*)&thread, (uint64_t)sp, (uint64_t)functionAddress, (uint64_t)returnAddress, (void*)arg, - this_arg ? (uint64_t)*this_arg : (uint64_t)0); + this_arg, + this_arg ? (uint64_t)*this_arg : (uint64_t)0, + cmd_arg, + cmd_arg ? (uint64_t)*cmd_arg : (uint64_t)0); RegisterContext *reg_ctx = thread.GetRegisterContext(); if (!reg_ctx) @@ -88,6 +92,31 @@ // The argument is in %rdi, and not on the stack. + if (cmd_arg) + { + if (log) + log->PutCString("The trivial call has a self and a _cmd pointer"); + + uint32_t rsiID = reg_ctx->GetRegisterInfoByName("rsi", 0)->kinds[eRegisterKindLLDB]; + uint32_t rdxID = reg_ctx->GetRegisterInfoByName("rdx", 0)->kinds[eRegisterKindLLDB]; + + if (log) + log->Printf("About to write 'self' (0x%llx) into RDI", (uint64_t)*this_arg); + + if (!reg_ctx->WriteRegisterFromUnsigned(rdiID, *this_arg)) + return false; + + if (log) + log->Printf("About to write '_cmd' (0x%llx) into RSI", (uint64_t)*cmd_arg); + + if (!reg_ctx->WriteRegisterFromUnsigned(rsiID, *this_arg)) + return false; + + if (log) + log->Printf("About to write the argument (0x%llx) into RDX", (uint64_t)arg); + + if (!reg_ctx->WriteRegisterFromUnsigned(rdxID, arg)) + return false; } if (this_arg) { if (log) Modified: lldb/trunk/source/Plugins/ABI/SysV-x86_64/ABISysV_x86_64.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ABI/SysV-x86_64/ABISysV_x86_64.h?rev=121722&r1=121721&r2=121722&view=diff ============================================================================== --- lldb/trunk/source/Plugins/ABI/SysV-x86_64/ABISysV_x86_64.h (original) +++ lldb/trunk/source/Plugins/ABI/SysV-x86_64/ABISysV_x86_64.h Mon Dec 13 16:46:15 2010 @@ -34,7 +34,8 @@ lldb::addr_t functionAddress, lldb::addr_t returnAddress, lldb::addr_t arg, - lldb::addr_t *this_arg) const; + lldb::addr_t *this_arg, + lldb::addr_t *cmd_arg) const; virtual bool PrepareNormalCall (Thread &thread, Modified: lldb/trunk/source/Symbol/ClangASTType.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/ClangASTType.cpp?rev=121722&r1=121721&r2=121722&view=diff ============================================================================== --- lldb/trunk/source/Symbol/ClangASTType.cpp (original) +++ lldb/trunk/source/Symbol/ClangASTType.cpp Mon Dec 13 16:46:15 2010 @@ -928,6 +928,20 @@ } } +void +ClangASTType::DumpTypeCode (Stream *s) +{ + DumpTypeCode(m_type, s); +} + +void +ClangASTType::DumpTypeCode (void *type, + Stream *s) +{ + clang::QualType qual_type(clang::QualType::getFromOpaquePtr(type)); + s->PutCString(qual_type.getAsString().c_str()); +} + bool ClangASTType::GetValueAsScalar ( Modified: lldb/trunk/source/Target/ThreadPlanCallFunction.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/ThreadPlanCallFunction.cpp?rev=121722&r1=121721&r2=121722&view=diff ============================================================================== --- lldb/trunk/source/Target/ThreadPlanCallFunction.cpp (original) +++ lldb/trunk/source/Target/ThreadPlanCallFunction.cpp Mon Dec 13 16:46:15 2010 @@ -40,7 +40,8 @@ lldb::addr_t arg, bool stop_other_threads, bool discard_on_error, - lldb::addr_t *this_arg) : + lldb::addr_t *this_arg, + lldb::addr_t *cmd_arg) : ThreadPlan (ThreadPlan::eKindCallFunction, "Call function plan", thread, eVoteNoOpinion, eVoteNoOpinion), m_valid (false), m_stop_other_threads (stop_other_threads), @@ -86,7 +87,8 @@ FunctionLoadAddr, StartLoadAddr, m_arg_addr, - this_arg)) + this_arg, + cmd_arg)) return; LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_STEP)); Modified: lldb/trunk/source/Target/ThreadPlanCallUserExpression.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/ThreadPlanCallUserExpression.cpp?rev=121722&r1=121721&r2=121722&view=diff ============================================================================== --- lldb/trunk/source/Target/ThreadPlanCallUserExpression.cpp (original) +++ lldb/trunk/source/Target/ThreadPlanCallUserExpression.cpp Mon Dec 13 16:46:15 2010 @@ -42,8 +42,9 @@ bool stop_other_threads, bool discard_on_error, lldb::addr_t *this_arg, + lldb::addr_t *cmd_arg, ClangUserExpression::ClangUserExpressionSP &user_expression_sp) : - ThreadPlanCallFunction (thread, function, arg, stop_other_threads, discard_on_error, this_arg), + ThreadPlanCallFunction (thread, function, arg, stop_other_threads, discard_on_error, this_arg, cmd_arg), m_user_expression_sp (user_expression_sp) { } From scallanan at apple.com Mon Dec 13 18:42:36 2010 From: scallanan at apple.com (Sean Callanan) Date: Tue, 14 Dec 2010 00:42:36 -0000 Subject: [Lldb-commits] [lldb] r121739 - in /lldb/trunk: include/lldb/Expression/ClangExpressionDeclMap.h include/lldb/Expression/ClangUserExpression.h source/Expression/ClangExpressionDeclMap.cpp source/Expression/ClangUserExpression.cpp source/Plugins/ABI/MacOSX-i386/ABIMacOSX_i386.cpp source/Plugins/ABI/SysV-x86_64/ABISysV_x86_64.cpp Message-ID: <20101214004236.8E82F2A6C12C@llvm.org> Author: spyffe Date: Mon Dec 13 18:42:36 2010 New Revision: 121739 URL: http://llvm.org/viewvc/llvm-project?rev=121739&view=rev Log: Bugfixes for the new "self" pointer handling. Specifically, the code to pass the _cmd pointer has been improved, and _cmd is now set to the value of _cmd for the current context, as opposed to being simply NULL. Modified: lldb/trunk/include/lldb/Expression/ClangExpressionDeclMap.h lldb/trunk/include/lldb/Expression/ClangUserExpression.h lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp lldb/trunk/source/Expression/ClangUserExpression.cpp lldb/trunk/source/Plugins/ABI/MacOSX-i386/ABIMacOSX_i386.cpp lldb/trunk/source/Plugins/ABI/SysV-x86_64/ABISysV_x86_64.cpp Modified: lldb/trunk/include/lldb/Expression/ClangExpressionDeclMap.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Expression/ClangExpressionDeclMap.h?rev=121739&r1=121738&r2=121739&view=diff ============================================================================== --- lldb/trunk/include/lldb/Expression/ClangExpressionDeclMap.h (original) +++ lldb/trunk/include/lldb/Expression/ClangExpressionDeclMap.h Mon Dec 13 18:42:36 2010 @@ -302,13 +302,17 @@ /// An Error to populate with any messages related to /// finding the "this" pointer. /// + /// @param[in] suppress_type_check + /// True if the type is not needed. + /// /// @return /// True on success; false otherwise. //------------------------------------------------------------------ bool GetObjectPointer(lldb::addr_t &object_ptr, ConstString &object_name, ExecutionContext &exe_ctx, - Error &error); + Error &error, + bool suppress_type_check = false); //------------------------------------------------------------------ /// [Used by CommandObjectExpression] Pretty-print a materialized Modified: lldb/trunk/include/lldb/Expression/ClangUserExpression.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Expression/ClangUserExpression.h?rev=121739&r1=121738&r2=121739&view=diff ============================================================================== --- lldb/trunk/include/lldb/Expression/ClangUserExpression.h (original) +++ lldb/trunk/include/lldb/Expression/ClangUserExpression.h Mon Dec 13 18:42:36 2010 @@ -257,7 +257,8 @@ PrepareToExecuteJITExpression (Stream &error_stream, ExecutionContext &exe_ctx, lldb::addr_t &struct_address, - lldb::addr_t &object_ptr); + lldb::addr_t &object_ptr, + lldb::addr_t &cmd_ptr); std::string m_expr_text; ///< The text of the expression, as typed by the user std::string m_expr_prefix; ///< The text of the translation-level definitions, as provided by the user Modified: lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp?rev=121739&r1=121738&r2=121739&view=diff ============================================================================== --- lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp (original) +++ lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp Mon Dec 13 18:42:36 2010 @@ -373,7 +373,8 @@ lldb::addr_t &object_ptr, ConstString &object_name, ExecutionContext &exe_ctx, - Error &err + Error &err, + bool suppress_type_check ) { assert (m_struct_vars.get()); @@ -390,7 +391,9 @@ return false; } - Variable *object_ptr_var = FindVariableInScope (*exe_ctx.frame, object_name, &m_struct_vars->m_object_pointer_type); + Variable *object_ptr_var = FindVariableInScope (*exe_ctx.frame, + object_name, + (suppress_type_check ? NULL : &m_struct_vars->m_object_pointer_type)); if (!object_ptr_var) { Modified: lldb/trunk/source/Expression/ClangUserExpression.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/ClangUserExpression.cpp?rev=121739&r1=121738&r2=121739&view=diff ============================================================================== --- lldb/trunk/source/Expression/ClangUserExpression.cpp (original) +++ lldb/trunk/source/Expression/ClangUserExpression.cpp Mon Dec 13 18:42:36 2010 @@ -312,7 +312,8 @@ ClangUserExpression::PrepareToExecuteJITExpression (Stream &error_stream, ExecutionContext &exe_ctx, lldb::addr_t &struct_address, - lldb::addr_t &object_ptr) + lldb::addr_t &object_ptr, + lldb::addr_t &cmd_ptr) { lldb::LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS)); @@ -343,6 +344,17 @@ error_stream.Printf("Couldn't get required object pointer: %s\n", materialize_error.AsCString()); return false; } + + if (m_objectivec) + { + ConstString cmd_name("_cmd"); + + if (!(m_expr_decl_map->GetObjectPointer(cmd_ptr, cmd_name, exe_ctx, materialize_error, true))) + { + error_stream.Printf("Couldn't get required object pointer: %s\n", materialize_error.AsCString()); + return false; + } + } } if (!m_expr_decl_map->Materialize(exe_ctx, struct_address, materialize_error)) @@ -391,7 +403,7 @@ lldb::addr_t object_ptr = NULL; lldb::addr_t cmd_ptr = NULL; - PrepareToExecuteJITExpression (error_stream, exe_ctx, struct_address, object_ptr); + PrepareToExecuteJITExpression (error_stream, exe_ctx, struct_address, object_ptr, cmd_ptr); // FIXME: This should really return a ThreadPlanCallUserExpression, in order to make sure that we don't release the // ClangUserExpression resources before the thread plan finishes execution in the target. But because we are @@ -466,7 +478,7 @@ lldb::addr_t object_ptr = NULL; lldb::addr_t cmd_ptr = NULL; - if (!PrepareToExecuteJITExpression (error_stream, exe_ctx, struct_address, object_ptr)) + if (!PrepareToExecuteJITExpression (error_stream, exe_ctx, struct_address, object_ptr, cmd_ptr)) return Process::eExecutionSetupError; const bool stop_others = true; 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=121739&r1=121738&r2=121739&view=diff ============================================================================== --- lldb/trunk/source/Plugins/ABI/MacOSX-i386/ABIMacOSX_i386.cpp (original) +++ lldb/trunk/source/Plugins/ABI/MacOSX-i386/ABIMacOSX_i386.cpp Mon Dec 13 18:42:36 2010 @@ -102,7 +102,7 @@ if (thread.GetProcess().WriteMemory(sp + 4, &argU32, sizeof(argU32), error) != sizeof(argU32)) return false; } - if (this_arg) + else if (this_arg) { uint32_t this_argU32 = *this_arg & 0xffffffffull; uint32_t argU32 = arg & 0xffffffffull; 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=121739&r1=121738&r2=121739&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 Mon Dec 13 18:42:36 2010 @@ -109,15 +109,16 @@ if (log) log->Printf("About to write '_cmd' (0x%llx) into RSI", (uint64_t)*cmd_arg); - if (!reg_ctx->WriteRegisterFromUnsigned(rsiID, *this_arg)) + if (!reg_ctx->WriteRegisterFromUnsigned(rsiID, *cmd_arg)) return false; if (log) log->Printf("About to write the argument (0x%llx) into RDX", (uint64_t)arg); if (!reg_ctx->WriteRegisterFromUnsigned(rdxID, arg)) - return false; } - if (this_arg) + return false; + } + else if (this_arg) { if (log) log->PutCString("The trivial call has a this pointer"); From gclayton at apple.com Mon Dec 13 20:59:59 2010 From: gclayton at apple.com (Greg Clayton) Date: Tue, 14 Dec 2010 02:59:59 -0000 Subject: [Lldb-commits] [lldb] r121745 - in /lldb/trunk: include/lldb/ include/lldb/Core/ include/lldb/Expression/ include/lldb/Symbol/ include/lldb/Target/ source/API/ source/Commands/ source/Core/ source/Expression/ source/Plugins/DynamicLoader/MacOSX-DYLD/ source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/ source/Symbol/ source/Target/ test/load_unload/ Message-ID: <20101214025959.F2A9A2A6C12C@llvm.org> Author: gclayton Date: Mon Dec 13 20:59:59 2010 New Revision: 121745 URL: http://llvm.org/viewvc/llvm-project?rev=121745&view=rev Log: Modified LLDB expressions to not have to JIT and run code just to see variable values or persistent expression variables. Now if an expression consists of a value that is a child of a variable, or of a persistent variable only, we will create a value object for it and make a ValueObjectConstResult from it to freeze the value (for program variables only, not persistent variables) and avoid running JITed code. For everything else we still parse up and JIT code and run it in the inferior. There was also a lot of clean up in the expression code. I made the ClangExpressionVariables be stored in collections of shared pointers instead of in collections of objects. This will help stop a lot of copy constructors on these large objects and also cleans up the code considerably. The persistent clang expression variables were moved over to the Target to ensure they persist across process executions. Added the ability for lldb_private::Target objects to evaluate expressions. We want to evaluate expressions at the target level in case we aren't running yet, or we have just completed running. We still want to be able to access the persistent expression variables between runs, and also evaluate constant expressions. Added extra logging to the dynamic loader plug-in for MacOSX. ModuleList objects can now dump their contents with the UUID, arch and full paths being logged with appropriate prefix values. Thread hardened the Communication class a bit by making the connection auto_ptr member into a shared pointer member and then making a local copy of the shared pointer in each method that uses it to make sure another thread can't nuke the connection object while it is being used by another thread. Added a new file to the lldb/test/load_unload test that causes the test a.out file to link to the libd.dylib file all the time. This will allow us to test using the DYLD_LIBRARY_PATH environment variable after moving libd.dylib somewhere else. Added: lldb/trunk/test/load_unload/d.c Modified: lldb/trunk/include/lldb/Core/Communication.h lldb/trunk/include/lldb/Core/ModuleList.h lldb/trunk/include/lldb/Core/Value.h lldb/trunk/include/lldb/Core/ValueObject.h lldb/trunk/include/lldb/Core/ValueObjectConstResult.h lldb/trunk/include/lldb/Expression/ClangExpression.h lldb/trunk/include/lldb/Expression/ClangExpressionDeclMap.h lldb/trunk/include/lldb/Expression/ClangExpressionVariable.h lldb/trunk/include/lldb/Expression/ClangFunction.h lldb/trunk/include/lldb/Expression/ClangPersistentVariables.h lldb/trunk/include/lldb/Expression/ClangUserExpression.h lldb/trunk/include/lldb/Expression/ClangUtilityFunction.h lldb/trunk/include/lldb/Expression/IRToDWARF.h lldb/trunk/include/lldb/Symbol/ClangASTContext.h lldb/trunk/include/lldb/Target/Process.h lldb/trunk/include/lldb/Target/StackFrame.h lldb/trunk/include/lldb/Target/Target.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/source/API/SBFrame.cpp lldb/trunk/source/Commands/CommandObjectExpression.cpp lldb/trunk/source/Core/Communication.cpp lldb/trunk/source/Core/ModuleList.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/Expression/ClangExpressionDeclMap.cpp lldb/trunk/source/Expression/ClangExpressionParser.cpp lldb/trunk/source/Expression/ClangExpressionVariable.cpp lldb/trunk/source/Expression/ClangFunction.cpp lldb/trunk/source/Expression/ClangPersistentVariables.cpp lldb/trunk/source/Expression/ClangUserExpression.cpp lldb/trunk/source/Expression/IRToDWARF.cpp lldb/trunk/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.cpp lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.cpp lldb/trunk/source/Symbol/ClangASTContext.cpp lldb/trunk/source/Symbol/ClangASTType.cpp lldb/trunk/source/Target/Process.cpp lldb/trunk/source/Target/SectionLoadList.cpp lldb/trunk/source/Target/StackFrame.cpp lldb/trunk/source/Target/Target.cpp lldb/trunk/source/Target/ThreadPlanTestCondition.cpp lldb/trunk/test/load_unload/Makefile Modified: lldb/trunk/include/lldb/Core/Communication.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/Communication.h?rev=121745&r1=121744&r2=121745&view=diff ============================================================================== --- lldb/trunk/include/lldb/Core/Communication.h (original) +++ lldb/trunk/include/lldb/Core/Communication.h Mon Dec 13 20:59:59 2010 @@ -354,7 +354,7 @@ protected: - std::auto_ptr m_connection_ap; ///< The connection that is current in use by this communications class. + lldb::ConnectionSP m_connection_sp; ///< The connection that is current in use by this communications class. lldb::thread_t m_read_thread; ///< The read thread handle in case we need to cancel the thread. bool m_read_thread_enabled; std::string m_bytes; ///< A buffer to cache bytes read in the ReadThread function. Modified: lldb/trunk/include/lldb/Core/ModuleList.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/ModuleList.h?rev=121745&r1=121744&r2=121745&view=diff ============================================================================== --- lldb/trunk/include/lldb/Core/ModuleList.h (original) +++ lldb/trunk/include/lldb/Core/ModuleList.h Mon Dec 13 20:59:59 2010 @@ -102,6 +102,10 @@ void Dump (Stream *s) const; + void + LogUUIDAndPaths (lldb::LogSP &log_sp, + const char *prefix_cstr); + uint32_t GetIndexForModule (const Module *module) const; Modified: lldb/trunk/include/lldb/Core/Value.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/Value.h?rev=121745&r1=121744&r2=121745&view=diff ============================================================================== --- lldb/trunk/include/lldb/Core/Value.h (original) +++ lldb/trunk/include/lldb/Core/Value.h Mon Dec 13 20:59:59 2010 @@ -131,6 +131,9 @@ static const char * GetContextTypeAsCString (ContextType context_type); + bool + GetData (DataExtractor &data); + protected: Scalar m_value; ValueType m_value_type; Modified: lldb/trunk/include/lldb/Core/ValueObject.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/ValueObject.h?rev=121745&r1=121744&r2=121745&view=diff ============================================================================== --- lldb/trunk/include/lldb/Core/ValueObject.h (original) +++ lldb/trunk/include/lldb/Core/ValueObject.h Mon Dec 13 20:59:59 2010 @@ -113,6 +113,12 @@ { return 0; } + + virtual bool + SetClangAST (clang::ASTContext *ast) + { + return false; + } virtual const char * GetValueAsCString (ExecutionContextScope *exe_scope); @@ -197,6 +203,25 @@ return m_dynamic_value_sp; } + virtual lldb::ValueObjectSP + CreateConstantValue (ExecutionContextScope *exe_scope, const ConstString &name); + + virtual lldb::ValueObjectSP + Dereference (ExecutionContextScope *exe_scope, Error *error_ptr); + + virtual lldb::ValueObjectSP + AddressOf (); + + // The backing bits of this value object were updated, clear any value + // values, summaries or descriptions so we refetch them. + virtual void + ValueUpdated () + { + m_value_str.clear(); + m_summary_str.clear(); + m_object_desc_str.clear(); + } + bool SetDynamicValue (); @@ -249,6 +274,13 @@ { return m_parent; } + + void + SetPointersPointToLoadAddrs (bool b) + { + m_pointers_point_to_load_addrs = b; + } + protected: //------------------------------------------------------------------ // Classes that inherit from ValueObject can see and modify these @@ -277,8 +309,12 @@ bool m_value_is_valid:1, m_value_did_change:1, m_children_count_valid:1, - m_old_value_valid:1; - + m_old_value_valid:1, + m_pointers_point_to_load_addrs:1; + + friend class CommandObjectExpression; + friend class ClangExpressionVariable; + friend class Target; //------------------------------------------------------------------ // Constructors and Destructors //------------------------------------------------------------------ Modified: lldb/trunk/include/lldb/Core/ValueObjectConstResult.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/ValueObjectConstResult.h?rev=121745&r1=121744&r2=121745&view=diff ============================================================================== --- lldb/trunk/include/lldb/Core/ValueObjectConstResult.h (original) +++ lldb/trunk/include/lldb/Core/ValueObjectConstResult.h Mon Dec 13 20:59:59 2010 @@ -7,8 +7,8 @@ // //===----------------------------------------------------------------------===// -#ifndef liblldb_ValueObjectChild_h_ -#define liblldb_ValueObjectChild_h_ +#ifndef liblldb_ValueObjectConstResult_h_ +#define liblldb_ValueObjectConstResult_h_ // C Includes // C++ Includes @@ -24,6 +24,14 @@ class ValueObjectConstResult : public ValueObject { public: + ValueObjectConstResult (lldb::ByteOrder byte_order, + uint32_t addr_byte_size); + + ValueObjectConstResult (clang::ASTContext *clang_ast, + void *clang_type, + const ConstString &name, + const DataExtractor &data); + ValueObjectConstResult (clang::ASTContext *clang_ast, void *clang_type, const ConstString &name, @@ -31,6 +39,12 @@ lldb::ByteOrder byte_order, uint8_t addr_size); + ValueObjectConstResult (clang::ASTContext *clang_ast, + void *clang_type, + const ConstString &name, + lldb::addr_t address, + lldb::AddressType address_type, + uint8_t addr_byte_size); // When an expression fails to evaluate, we return an error ValueObjectConstResult (const Error& error); @@ -61,9 +75,20 @@ virtual bool IsInScope (StackFrame *frame); + virtual bool + SetClangAST (clang::ASTContext *ast) + { + m_clang_ast = ast; + return true; + } + + void + SetByteSize (size_t size); + protected: clang::ASTContext *m_clang_ast; // The clang AST that the clang type comes from ConstString m_type_name; + uint32_t m_byte_size; private: DISALLOW_COPY_AND_ASSIGN (ValueObjectConstResult); @@ -71,4 +96,4 @@ } // namespace lldb_private -#endif // liblldb_ValueObjectChild_h_ +#endif // liblldb_ValueObjectConstResult_h_ Modified: lldb/trunk/include/lldb/Expression/ClangExpression.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Expression/ClangExpression.h?rev=121745&r1=121744&r2=121745&view=diff ============================================================================== --- lldb/trunk/include/lldb/Expression/ClangExpression.h (original) +++ lldb/trunk/include/lldb/Expression/ClangExpression.h Mon Dec 13 20:59:59 2010 @@ -74,7 +74,7 @@ /// Return the object that the parser should use when registering /// local variables. May be NULL if the Expression doesn't care. //------------------------------------------------------------------ - virtual ClangExpressionVariableStore * + virtual ClangExpressionVariableList * LocalVariables () = 0; //------------------------------------------------------------------ Modified: lldb/trunk/include/lldb/Expression/ClangExpressionDeclMap.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Expression/ClangExpressionDeclMap.h?rev=121745&r1=121744&r2=121745&view=diff ============================================================================== --- lldb/trunk/include/lldb/Expression/ClangExpressionDeclMap.h (original) +++ lldb/trunk/include/lldb/Expression/ClangExpressionDeclMap.h Mon Dec 13 20:59:59 2010 @@ -72,12 +72,12 @@ /// /// Initializes class variabes. //------------------------------------------------------------------ - ClangExpressionDeclMap(); + ClangExpressionDeclMap (); //------------------------------------------------------------------ /// Destructor //------------------------------------------------------------------ - ~ClangExpressionDeclMap(); + ~ClangExpressionDeclMap (); //------------------------------------------------------------------ /// Enable the state needed for parsing and IR transformation. @@ -86,12 +86,14 @@ /// The execution context to use when finding types for variables. /// Also used to find a "scratch" AST context to store result types. //------------------------------------------------------------------ - void WillParse(ExecutionContext &exe_ctx); + void + WillParse (ExecutionContext &exe_ctx); //------------------------------------------------------------------ /// Disable the state needed for parsing and IR transformation. //------------------------------------------------------------------ - void DidParse(); + void + DidParse (); //------------------------------------------------------------------ /// [Used by IRForTarget] Get a new result variable name of the form @@ -124,9 +126,10 @@ /// @return /// True on success; false otherwise. //------------------------------------------------------------------ - bool AddPersistentVariable (const clang::NamedDecl *decl, - const ConstString &name, - TypeFromParser type); + bool + AddPersistentVariable (const clang::NamedDecl *decl, + const ConstString &name, + TypeFromParser type); //------------------------------------------------------------------ /// [Used by IRForTarget] Add a variable to the struct that needs to @@ -150,11 +153,12 @@ /// @return /// True on success; false otherwise. //------------------------------------------------------------------ - bool AddValueToStruct (const clang::NamedDecl *decl, - const ConstString &name, - llvm::Value *value, - size_t size, - off_t alignment); + bool + AddValueToStruct (const clang::NamedDecl *decl, + const ConstString &name, + llvm::Value *value, + size_t size, + off_t alignment); //------------------------------------------------------------------ /// [Used by IRForTarget] Finalize the struct, laying out the position @@ -163,7 +167,8 @@ /// @return /// True on success; false otherwise. //------------------------------------------------------------------ - bool DoStructLayout (); + bool + DoStructLayout (); //------------------------------------------------------------------ /// [Used by IRForTarget] Get general information about the laid-out @@ -181,9 +186,10 @@ /// @return /// True if the information could be retrieved; false otherwise. //------------------------------------------------------------------ - bool GetStructInfo (uint32_t &num_elements, - size_t &size, - off_t &alignment); + bool + GetStructInfo (uint32_t &num_elements, + size_t &size, + off_t &alignment); //------------------------------------------------------------------ /// [Used by IRForTarget] Get specific information about one field @@ -216,11 +222,12 @@ /// @return /// True if the information could be retrieved; false otherwise. //------------------------------------------------------------------ - bool GetStructElement (const clang::NamedDecl *&decl, - llvm::Value *&value, - off_t &offset, - ConstString &name, - uint32_t index); + bool + GetStructElement (const clang::NamedDecl *&decl, + llvm::Value *&value, + off_t &offset, + ConstString &name, + uint32_t index); //------------------------------------------------------------------ /// [Used by IRForTarget] Get information about a function given its @@ -240,9 +247,10 @@ /// @return /// True if the information could be retrieved; false otherwise. //------------------------------------------------------------------ - bool GetFunctionInfo (const clang::NamedDecl *decl, - llvm::Value**& value, - uint64_t &ptr); + bool + GetFunctionInfo (const clang::NamedDecl *decl, + llvm::Value**& value, + uint64_t &ptr); //------------------------------------------------------------------ /// [Used by IRForTarget] Get the address of a function given nothing @@ -259,8 +267,9 @@ /// @return /// True if the address could be retrieved; false otherwise. //------------------------------------------------------------------ - bool GetFunctionAddress (const ConstString &name, - uint64_t &ptr); + bool + GetFunctionAddress (const ConstString &name, + uint64_t &ptr); //------------------------------------------------------------------ /// [Used by CommandObjectExpression] Materialize the entire struct @@ -280,9 +289,10 @@ /// @return /// True on success; false otherwise. //------------------------------------------------------------------ - bool Materialize(ExecutionContext &exe_ctx, - lldb::addr_t &struct_address, - Error &error); + bool + Materialize (ExecutionContext &exe_ctx, + lldb::addr_t &struct_address, + Error &error); //------------------------------------------------------------------ /// [Used by CommandObjectExpression] Get the "this" pointer @@ -308,11 +318,12 @@ /// @return /// True on success; false otherwise. //------------------------------------------------------------------ - bool GetObjectPointer(lldb::addr_t &object_ptr, - ConstString &object_name, - ExecutionContext &exe_ctx, - Error &error, - bool suppress_type_check = false); + bool + GetObjectPointer (lldb::addr_t &object_ptr, + ConstString &object_name, + ExecutionContext &exe_ctx, + Error &error, + bool suppress_type_check = false); //------------------------------------------------------------------ /// [Used by CommandObjectExpression] Pretty-print a materialized @@ -332,9 +343,10 @@ /// @return /// True on success; false otherwise. //------------------------------------------------------------------ - bool DumpMaterializedStruct(ExecutionContext &exe_ctx, - Stream &s, - Error &error); + bool + DumpMaterializedStruct (ExecutionContext &exe_ctx, + Stream &s, + Error &error); //------------------------------------------------------------------ /// [Used by CommandObjectExpression] Deaterialize the entire struct. @@ -353,9 +365,10 @@ /// @return /// True on success; false otherwise. //------------------------------------------------------------------ - bool Dematerialize(ExecutionContext &exe_ctx, - ClangExpressionVariable *&result, - Error &error); + bool + Dematerialize (ExecutionContext &exe_ctx, + lldb::ClangExpressionVariableSP &result_sp, + Error &error); //------------------------------------------------------------------ /// [Used by ClangASTSource] Find all entities matching a given name, @@ -373,8 +386,9 @@ /// @return /// True on success; false otherwise. //------------------------------------------------------------------ - void GetDecls (NameSearchContext &context, - const ConstString &name); + void + GetDecls (NameSearchContext &context, + const ConstString &name); //------------------------------------------------------------------ /// [Used by ClangASTSource] Report whether a $__lldb variable has @@ -405,8 +419,8 @@ } private: - ClangExpressionVariableStore m_found_entities; ///< All entities that were looked up for the parser. - ClangExpressionVariableList m_struct_members; ///< All entities that need to be placed in the struct. + ClangExpressionVariableList m_found_entities; ///< All entities that were looked up for the parser. + ClangExpressionVariableList m_struct_members; ///< All entities that need to be placed in the struct. //---------------------------------------------------------------------- /// The following values should not live beyond parsing @@ -421,6 +435,15 @@ { } + Target * + GetTarget() + { + if (m_exe_ctx && m_exe_ctx->target) + return m_exe_ctx->target; + else if (m_sym_ctx.target_sp) + m_sym_ctx.target_sp.get(); + return NULL; + } ExecutionContext *m_exe_ctx; ///< The execution context to use when parsing. SymbolContext m_sym_ctx; ///< The symbol context to use in finding variables and types. ClangPersistentVariables *m_persistent_vars; ///< The persistent variables for the process. @@ -433,7 +456,8 @@ //---------------------------------------------------------------------- /// Activate parser-specific variables //---------------------------------------------------------------------- - void EnableParserVars() + void + EnableParserVars() { if (!m_parser_vars.get()) m_parser_vars.reset(new struct ParserVars); @@ -442,7 +466,8 @@ //---------------------------------------------------------------------- /// Deallocate parser-specific variables //---------------------------------------------------------------------- - void DisableParserVars() + void + DisableParserVars() { m_parser_vars.reset(); } @@ -473,7 +498,8 @@ //---------------------------------------------------------------------- /// Activate struct variables //---------------------------------------------------------------------- - void EnableStructVars() + void + EnableStructVars() { if (!m_struct_vars.get()) m_struct_vars.reset(new struct StructVars); @@ -482,7 +508,8 @@ //---------------------------------------------------------------------- /// Deallocate struct variables //---------------------------------------------------------------------- - void DisableStructVars() + void + DisableStructVars() { m_struct_vars.reset(); } @@ -508,7 +535,8 @@ //---------------------------------------------------------------------- /// Activate materialization-specific variables //---------------------------------------------------------------------- - void EnableMaterialVars() + void + EnableMaterialVars() { if (!m_material_vars.get()) m_material_vars.reset(new struct MaterialVars); @@ -517,7 +545,8 @@ //---------------------------------------------------------------------- /// Deallocate materialization-specific variables //---------------------------------------------------------------------- - void DisableMaterialVars() + void + DisableMaterialVars() { m_material_vars.reset(); } @@ -542,9 +571,10 @@ /// @return /// The LLDB Variable found, or NULL if none was found. //------------------------------------------------------------------ - Variable *FindVariableInScope(StackFrame &frame, - const ConstString &name, - TypeFromUser *type = NULL); + Variable * + FindVariableInScope (StackFrame &frame, + const ConstString &name, + TypeFromUser *type = NULL); //------------------------------------------------------------------ /// Get the value of a variable in a given execution context and return @@ -575,11 +605,12 @@ /// @return /// The LLDB Value for the variable. //------------------------------------------------------------------ - Value *GetVariableValue(ExecutionContext &exe_ctx, - Variable *var, - clang::ASTContext *parser_ast_context, - TypeFromUser *found_type = NULL, - TypeFromParser *parser_type = NULL); + Value * + GetVariableValue (ExecutionContext &exe_ctx, + Variable *var, + clang::ASTContext *parser_ast_context, + TypeFromUser *found_type = NULL, + TypeFromParser *parser_type = NULL); //------------------------------------------------------------------ /// Use the NameSearchContext to generate a Decl for the given LLDB @@ -591,8 +622,9 @@ /// @param[in] var /// The LLDB Variable that needs a Decl. //------------------------------------------------------------------ - void AddOneVariable(NameSearchContext &context, - Variable *var); + void + AddOneVariable (NameSearchContext &context, + Variable *var); //------------------------------------------------------------------ /// Use the NameSearchContext to generate a Decl for the given @@ -604,7 +636,9 @@ /// @param[in] pvar /// The persistent variable that needs a Decl. //------------------------------------------------------------------ - void AddOneVariable(NameSearchContext &context, ClangExpressionVariable *pvar); + void + AddOneVariable (NameSearchContext &context, + lldb::ClangExpressionVariableSP &pvar_sp); //------------------------------------------------------------------ /// Use the NameSearchContext to generate a Decl for the given @@ -622,7 +656,10 @@ /// The Symbol that corresponds to a function that needs to be /// created with generic type (unitptr_t foo(...)). //------------------------------------------------------------------ - void AddOneFunction(NameSearchContext &context, Function *fun, Symbol *sym); + void + AddOneFunction (NameSearchContext &context, + Function *fun, + Symbol *sym); //------------------------------------------------------------------ /// Use the NameSearchContext to generate a Decl for the given @@ -634,7 +671,9 @@ /// @param[in] reg_info /// The information corresponding to that register. //------------------------------------------------------------------ - void AddOneRegister(NameSearchContext &context, const lldb::RegisterInfo *reg_info); + void + AddOneRegister (NameSearchContext &context, + const lldb::RegisterInfo *reg_info); //------------------------------------------------------------------ /// Use the NameSearchContext to generate a Decl for the given @@ -650,9 +689,10 @@ /// True if a method with signature void $__lldb_expr(void*) /// should be added to the C++ class type passed in //------------------------------------------------------------------ - void AddOneType(NameSearchContext &context, - TypeFromUser &type, - bool add_method = false); + void + AddOneType (NameSearchContext &context, + TypeFromUser &type, + bool add_method = false); //------------------------------------------------------------------ /// Actually do the task of materializing or dematerializing the struct. @@ -678,15 +718,17 @@ /// @return /// True on success; false otherwise. //------------------------------------------------------------------ - bool DoMaterialize (bool dematerialize, - ExecutionContext &exe_ctx, - ClangExpressionVariable **result, - Error &err); + bool + DoMaterialize (bool dematerialize, + ExecutionContext &exe_ctx, + lldb::ClangExpressionVariableSP *result_sp_ptr, + Error &err); //------------------------------------------------------------------ /// Clean up the state required to dematerialize the variable. //------------------------------------------------------------------ - void DidDematerialize (); + void + DidDematerialize (); //------------------------------------------------------------------ /// Actually do the task of materializing or dematerializing a persistent @@ -699,8 +741,8 @@ /// @param[in] exe_ctx /// The execution context to use. /// - /// @param[in] name - /// The name of the persistent variable. + /// @param[in] var_sp + /// The persistent variable to materialize /// /// @param[in] addr /// The address at which to materialize the variable. @@ -712,11 +754,12 @@ /// @return /// True on success; false otherwise. //------------------------------------------------------------------ - bool DoMaterializeOnePersistentVariable(bool dematerialize, - ExecutionContext &exe_ctx, - const ConstString &name, - lldb::addr_t addr, - Error &err); + bool + DoMaterializeOnePersistentVariable (bool dematerialize, + ExecutionContext &exe_ctx, + lldb::ClangExpressionVariableSP &var_sp, + lldb::addr_t addr, + Error &err); //------------------------------------------------------------------ /// Actually do the task of materializing or dematerializing a @@ -748,13 +791,14 @@ /// @return /// True on success; false otherwise. //------------------------------------------------------------------ - bool DoMaterializeOneVariable(bool dematerialize, - ExecutionContext &exe_ctx, - const SymbolContext &sym_ctx, - const ConstString &name, - TypeFromUser type, - lldb::addr_t addr, - Error &err); + bool + DoMaterializeOneVariable (bool dematerialize, + ExecutionContext &exe_ctx, + const SymbolContext &sym_ctx, + const ConstString &name, + TypeFromUser type, + lldb::addr_t addr, + Error &err); //------------------------------------------------------------------ /// Actually do the task of materializing or dematerializing a @@ -783,12 +827,13 @@ /// @return /// True on success; false otherwise. //------------------------------------------------------------------ - bool DoMaterializeOneRegister(bool dematerialize, - ExecutionContext &exe_ctx, - RegisterContext ®_ctx, - const lldb::RegisterInfo ®_info, - lldb::addr_t addr, - Error &err); + bool + DoMaterializeOneRegister (bool dematerialize, + ExecutionContext &exe_ctx, + RegisterContext ®_ctx, + const lldb::RegisterInfo ®_info, + lldb::addr_t addr, + Error &err); //------------------------------------------------------------------ /// A wrapper for ClangASTContext::CopyType that sets a flag that @@ -807,9 +852,10 @@ /// @return /// The imported type. //------------------------------------------------------------------ - void *GuardedCopyType (clang::ASTContext *dest_context, - clang::ASTContext *source_context, - void *clang_type); + void * + GuardedCopyType (clang::ASTContext *dest_context, + clang::ASTContext *source_context, + void *clang_type); }; } // namespace lldb_private Modified: lldb/trunk/include/lldb/Expression/ClangExpressionVariable.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Expression/ClangExpressionVariable.h?rev=121745&r1=121744&r2=121745&view=diff ============================================================================== --- lldb/trunk/include/lldb/Expression/ClangExpressionVariable.h (original) +++ lldb/trunk/include/lldb/Expression/ClangExpressionVariable.h Mon Dec 13 20:59:59 2010 @@ -20,7 +20,7 @@ // Other libraries and framework includes // Project includes -#include "lldb/lldb-types.h" +#include "lldb/lldb-include.h" #include "lldb/Core/ClangForward.h" #include "lldb/Core/ConstString.h" #include "lldb/Symbol/TaggedASTType.h" @@ -31,11 +31,8 @@ namespace lldb_private { -class ClangExpressionVariableStore; -class DataBufferHeap; -class ExecutionContext; -class Stream; -class Value; +class ClangExpressionVariableList; +class ValueObjectConstResult; //---------------------------------------------------------------------- /// @class ClangExpressionVariable ClangExpressionVariable.h "lldb/Expression/ClangExpressionVariable.h" @@ -60,12 +57,13 @@ /// polymorphism, and provides necessary support methods. Its interface /// is RTTI-neutral. //---------------------------------------------------------------------- -struct ClangExpressionVariable +class ClangExpressionVariable { - ClangExpressionVariable(); - - ClangExpressionVariable(const ClangExpressionVariable &cev); - +public: + ClangExpressionVariable(lldb::ByteOrder byte_order, uint32_t addr_byte_size); + + ClangExpressionVariable(const lldb::ValueObjectSP &valobj_sp); + //---------------------------------------------------------------------- /// If the variable contains its own data, make a Value point at it. /// If \a exe_ctx in not NULL, the value will be resolved in with @@ -85,24 +83,9 @@ PointValueAtData(Value &value, ExecutionContext *exe_ctx); lldb::ValueObjectSP - GetExpressionResult (ExecutionContext *exe_ctx); + GetValueObject(); //---------------------------------------------------------------------- - /// The following values should stay valid for the life of the variable - //---------------------------------------------------------------------- - ConstString m_name; ///< The name of the variable - TypeFromUser m_user_type; ///< The type of the variable according to some LLDB context; - ///< NULL if the type hasn't yet been migrated to one - - const lldb::RegisterInfo *m_register_info; ///< if non-NULL, LLDB's information for the register this value is stored in. Only used for register values - - //---------------------------------------------------------------------- - /// The following values indicate where the variable originally came from - //---------------------------------------------------------------------- - ClangExpressionVariableStore *m_store; ///< The store containing the variable - uint64_t m_index; ///< The index of the variable in the store - - //---------------------------------------------------------------------- /// The following values should not live beyond parsing //---------------------------------------------------------------------- struct ParserVars { @@ -120,13 +103,12 @@ llvm::Value *m_llvm_value; ///< The IR value corresponding to this variable; usually a GlobalValue lldb_private::Value *m_lldb_value; ///< The value found in LLDB for this variable }; - std::auto_ptr m_parser_vars; - //---------------------------------------------------------------------- /// Make this variable usable by the parser by allocating space for /// parser-specific variables //---------------------------------------------------------------------- - void EnableParserVars() + void + EnableParserVars() { if (!m_parser_vars.get()) m_parser_vars.reset(new struct ParserVars); @@ -135,7 +117,8 @@ //---------------------------------------------------------------------- /// Deallocate parser-specific variables //---------------------------------------------------------------------- - void DisableParserVars() + void + DisableParserVars() { m_parser_vars.reset(); } @@ -155,13 +138,13 @@ size_t m_size; ///< The space required for the variable, in bytes off_t m_offset; ///< The offset of the variable in the struct, in bytes }; - std::auto_ptr m_jit_vars; - + //---------------------------------------------------------------------- /// Make this variable usable for materializing for the JIT by allocating /// space for JIT-specific variables //---------------------------------------------------------------------- - void EnableJITVars() + void + EnableJITVars() { if (!m_jit_vars.get()) m_jit_vars.reset(new struct JITVars); @@ -170,62 +153,100 @@ //---------------------------------------------------------------------- /// Deallocate JIT-specific variables //---------------------------------------------------------------------- - void DisableJITVars() + void + DisableJITVars() { m_jit_vars.reset(); } - - lldb::DataBufferSP m_data_sp; - + //---------------------------------------------------------------------- - /// Make this variable usable for storing its data internally by - /// allocating data-specific variables + /// Return the variable's size in bytes //---------------------------------------------------------------------- - void - EnableDataVars(); + size_t + GetByteSize (); - //---------------------------------------------------------------------- - /// Deallocate data-specific variables - //---------------------------------------------------------------------- - void DisableDataVars(); + const ConstString & + GetName(); + + lldb::RegisterInfo * + GetRegisterInfo(); + void + SetRegisterInfo (const lldb::RegisterInfo *reg_info); + + lldb::clang_type_t + GetClangType (); + + void + SetClangType (lldb::clang_type_t); + + clang::ASTContext * + GetClangAST (); + + void + SetClangAST (clang::ASTContext *ast); + + TypeFromUser + GetTypeFromUser (); + + uint8_t * + GetValueBytes (); + + void + SetName (const ConstString &name); + + void + ValueUpdated (); + + + typedef lldb::SharedPtr::Type ValueObjectConstResultSP; + //---------------------------------------------------------------------- - /// Return the variable's size in bytes + /// Members //---------------------------------------------------------------------- - size_t Size () - { - return (m_user_type.GetClangTypeBitWidth () + 7) / 8; - } + std::auto_ptr m_parser_vars; + std::auto_ptr m_jit_vars; + //ValueObjectConstResultSP m_valojb_sp; + lldb::ValueObjectSP m_valojb_sp; + +private: + DISALLOW_COPY_AND_ASSIGN (ClangExpressionVariable); }; //---------------------------------------------------------------------- /// @class ClangExpressionVariableListBase ClangExpressionVariable.h "lldb/Expression/ClangExpressionVariable.h" -/// @brief Manages variables that the expression parser uses. +/// @brief A list of variable references. /// -/// The expression parser uses variable lists in various contexts, as -/// discuessed at ClangExpressionVariable. This abstract class contains -/// the basic functions for managing a list of variables. Its subclasses -/// store pointers to variables or variables, depending on whether they -/// are backing stores or merely transient repositories. +/// This class stores variables internally, acting as the permanent store. //---------------------------------------------------------------------- -class ClangExpressionVariableListBase +class ClangExpressionVariableList { public: //---------------------------------------------------------------------- - /// Return the number of variables in the list - //---------------------------------------------------------------------- - virtual uint64_t Size() = 0; - - //---------------------------------------------------------------------- - /// Return the variable at the given index in the list + /// Implementation of methods in ClangExpressionVariableListBase //---------------------------------------------------------------------- - virtual ClangExpressionVariable &VariableAtIndex(uint64_t index) = 0; + virtual size_t + GetSize() + { + return m_variables.size(); + } - //---------------------------------------------------------------------- - /// Add a new variable and return its index - //---------------------------------------------------------------------- - virtual uint64_t AddVariable(ClangExpressionVariable& var) = 0; + virtual lldb::ClangExpressionVariableSP + GetVariableAtIndex(size_t index) + { + lldb::ClangExpressionVariableSP var_sp; + if (index < m_variables.size()) + var_sp = m_variables[index]; + return var_sp; + } + virtual size_t + AddVariable (const lldb::ClangExpressionVariableSP &var_sp) + { + m_variables.push_back(var_sp); + return m_variables.size() - 1; + } + //---------------------------------------------------------------------- /// Finds a variable by name in the list. /// @@ -235,15 +256,36 @@ /// @return /// The variable requested, or NULL if that variable is not in the list. //---------------------------------------------------------------------- - ClangExpressionVariable *GetVariable (const ConstString &name) + lldb::ClangExpressionVariableSP + GetVariable (const ConstString &name) { - for (uint64_t index = 0, size = Size(); index < size; ++index) + lldb::ClangExpressionVariableSP var_sp; + for (size_t index = 0, size = GetSize(); index < size; ++index) { - ClangExpressionVariable &candidate (VariableAtIndex(index)); - if (candidate.m_name == name) - return &candidate; + var_sp = GetVariableAtIndex(index); + if (var_sp->GetName() == name) + return var_sp; } - return NULL; + var_sp.reset(); + return var_sp; + } + + lldb::ClangExpressionVariableSP + GetVariable (const char *name) + { + lldb::ClangExpressionVariableSP var_sp; + if (name && name[0]) + { + for (size_t index = 0, size = GetSize(); index < size; ++index) + { + var_sp = GetVariableAtIndex(index); + const char *var_name_cstr = var_sp->GetName().GetCString(); + if (::strcmp (var_name_cstr, name) == 0) + return var_sp; + } + var_sp.reset(); + } + return var_sp; } //---------------------------------------------------------------------- @@ -255,98 +297,60 @@ /// @return /// The variable requested, or NULL if that variable is not in the list. //---------------------------------------------------------------------- - ClangExpressionVariable *GetVariable (const clang::NamedDecl *decl) + lldb::ClangExpressionVariableSP + GetVariable (const clang::NamedDecl *decl) { - for (uint64_t index = 0, size = Size(); index < size; ++index) + lldb::ClangExpressionVariableSP var_sp; + for (size_t index = 0, size = GetSize(); index < size; ++index) { - ClangExpressionVariable &candidate (VariableAtIndex(index)); - if (candidate.m_parser_vars.get() && - candidate.m_parser_vars->m_named_decl == decl) - return &candidate; + var_sp = GetVariableAtIndex(index); + if (var_sp->m_parser_vars.get() && var_sp->m_parser_vars->m_named_decl == decl) + return var_sp; } - return NULL; - } -}; - -//---------------------------------------------------------------------- -/// @class ClangExpressionVariableListBase ClangExpressionVariable.h "lldb/Expression/ClangExpressionVariable.h" -/// @brief A list of variable references. -/// -/// This class stores variables internally, acting as the permanent store. -//---------------------------------------------------------------------- -class ClangExpressionVariableStore : public ClangExpressionVariableListBase -{ -public: - //---------------------------------------------------------------------- - /// Implementation of methods in ClangExpressionVariableListBase - //---------------------------------------------------------------------- - uint64_t Size() - { - return m_variables.size(); - } - - ClangExpressionVariable &VariableAtIndex(uint64_t index) - { - return m_variables[index]; + var_sp.reset(); + return var_sp; } - - uint64_t AddVariable(ClangExpressionVariable &var) - { - m_variables.push_back(var); - return m_variables.size() - 1; - } - + //---------------------------------------------------------------------- /// Create a new variable in the list and return its index //---------------------------------------------------------------------- - uint64_t CreateVariable() + lldb::ClangExpressionVariableSP + CreateVariable (lldb::ByteOrder byte_order, uint32_t addr_byte_size) { - uint64_t index = m_variables.size(); - - m_variables.push_back(ClangExpressionVariable()); - m_variables[index].m_store = this; - m_variables[index].m_index = index; - - return index; + lldb::ClangExpressionVariableSP var_sp(new ClangExpressionVariable(byte_order, addr_byte_size)); + m_variables.push_back(var_sp); + return var_sp; } -private: - std::vector m_variables; -}; - -//---------------------------------------------------------------------- -/// @class ClangExpressionVariableListBase ClangExpressionVariable.h "lldb/Expression/ClangExpressionVariable.h" -/// @brief A list of variable references. -/// -/// This class stores references to variables stored elsewhere. -//---------------------------------------------------------------------- -class ClangExpressionVariableList : public ClangExpressionVariableListBase -{ -public: - //---------------------------------------------------------------------- - /// Implementation of methods in ClangExpressionVariableListBase - //---------------------------------------------------------------------- - uint64_t Size() + + lldb::ClangExpressionVariableSP + CreateVariable(const lldb::ValueObjectSP &valobj_sp) { - return m_references.size(); + lldb::ClangExpressionVariableSP var_sp(new ClangExpressionVariable(valobj_sp)); + m_variables.push_back(var_sp); + return var_sp; } - ClangExpressionVariable &VariableAtIndex(uint64_t index) - { - return m_references[index].first->VariableAtIndex(m_references[index].second); - } - uint64_t AddVariable(ClangExpressionVariable &var) + + lldb::ClangExpressionVariableSP + CreateVariable (const ConstString &name, + const TypeFromUser& user_type, + lldb::ByteOrder byte_order, + uint32_t addr_byte_size) { - m_references.push_back(ClangExpressionVariableRef(var.m_store, var.m_index)); - return m_references.size() - 1; + lldb::ClangExpressionVariableSP var_sp(new ClangExpressionVariable(byte_order, addr_byte_size)); + var_sp->SetName (name); + var_sp->SetClangType (user_type.GetOpaqueQualType()); + var_sp->SetClangAST (user_type.GetASTContext()); + m_variables.push_back(var_sp); + return var_sp; } -private: - typedef std::pair - ClangExpressionVariableRef; - std::vector m_references; +private: + std::vector m_variables; }; + } // namespace lldb_private #endif // liblldb_ClangExpressionVariable_h_ Modified: lldb/trunk/include/lldb/Expression/ClangFunction.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Expression/ClangFunction.h?rev=121745&r1=121744&r2=121745&view=diff ============================================================================== --- lldb/trunk/include/lldb/Expression/ClangFunction.h (original) +++ lldb/trunk/include/lldb/Expression/ClangFunction.h Mon Dec 13 20:59:59 2010 @@ -264,7 +264,7 @@ /// @return /// Returns one of the ExecutionResults enum indicating function call status. //------------------------------------------------------------------ - static Process::ExecutionResults + static lldb::ExecutionResults ExecuteFunction (ExecutionContext &exe_ctx, lldb::addr_t function_address, lldb::addr_t &void_arg, @@ -294,7 +294,7 @@ /// @return /// Returns one of the ExecutionResults enum indicating function call status. //------------------------------------------------------------------ - Process::ExecutionResults + lldb::ExecutionResults ExecuteFunction(ExecutionContext &exe_ctx, Stream &errors, Value &results); @@ -320,7 +320,7 @@ /// @return /// Returns one of the ExecutionResults enum indicating function call status. //------------------------------------------------------------------ - Process::ExecutionResults + lldb::ExecutionResults ExecuteFunction(ExecutionContext &exe_ctx, Stream &errors, bool stop_others, Value &results); @@ -350,7 +350,7 @@ /// @return /// Returns one of the ExecutionResults enum indicating function call status. //------------------------------------------------------------------ - Process::ExecutionResults + lldb::ExecutionResults ExecuteFunction(ExecutionContext &exe_ctx, Stream &errors, uint32_t single_thread_timeout_usec, @@ -390,7 +390,7 @@ /// @return /// Returns one of the ExecutionResults enum indicating function call status. //------------------------------------------------------------------ - Process::ExecutionResults + lldb::ExecutionResults ExecuteFunction(ExecutionContext &exe_ctx, lldb::addr_t *args_addr_ptr, Stream &errors, @@ -555,7 +555,7 @@ /// Return the object that the parser should use when registering /// local variables. May be NULL if the Expression doesn't care. //------------------------------------------------------------------ - ClangExpressionVariableStore * + ClangExpressionVariableList * LocalVariables () { return NULL; Modified: lldb/trunk/include/lldb/Expression/ClangPersistentVariables.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Expression/ClangPersistentVariables.h?rev=121745&r1=121744&r2=121745&view=diff ============================================================================== --- lldb/trunk/include/lldb/Expression/ClangPersistentVariables.h (original) +++ lldb/trunk/include/lldb/Expression/ClangPersistentVariables.h Mon Dec 13 20:59:59 2010 @@ -23,29 +23,36 @@ /// ClangPersistentVariable for more discussion. Also provides an increasing, /// 0-based counter for naming result variables. //---------------------------------------------------------------------- -class ClangPersistentVariables : public ClangExpressionVariableStore +class ClangPersistentVariables : public ClangExpressionVariableList { public: - //---------------------------------------------------------------------- - /// Return the next entry in the sequence of strings "$0", "$1", ... for use - /// naming result variables. - /// - /// @param[in] name - /// A string to place the variable name in. - //---------------------------------------------------------------------- - void - GetNextResultName (ConstString &name); //---------------------------------------------------------------------- /// Constructor //---------------------------------------------------------------------- ClangPersistentVariables (); - bool - CreatePersistentVariable (const ConstString &name, - TypeFromUser user_type); + lldb::ClangExpressionVariableSP + CreatePersistentVariable (const lldb::ValueObjectSP &valobj_sp); + + lldb::ClangExpressionVariableSP + CreatePersistentVariable (const ConstString &name, + const TypeFromUser& user_type, + lldb::ByteOrder byte_order, + uint32_t addr_byte_size); + + //---------------------------------------------------------------------- + /// Return the next entry in the sequence of strings "$0", "$1", ... for + /// use naming persistent expression convenience variables. + /// + /// @return + /// A string that contains the next persistent variable name. + //---------------------------------------------------------------------- + ConstString + GetNextPersistentVariableName (); + private: - uint64_t m_result_counter; ///< The counter used by GetNextResultName(). + uint32_t m_next_persistent_variable_id; ///< The counter used by GetNextResultName(). }; } Modified: lldb/trunk/include/lldb/Expression/ClangUserExpression.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Expression/ClangUserExpression.h?rev=121745&r1=121744&r2=121745&view=diff ============================================================================== --- lldb/trunk/include/lldb/Expression/ClangUserExpression.h (original) +++ lldb/trunk/include/lldb/Expression/ClangUserExpression.h Mon Dec 13 20:59:59 2010 @@ -117,12 +117,12 @@ /// @return /// A Process::Execution results value. //------------------------------------------------------------------ - Process::ExecutionResults + lldb::ExecutionResults Execute (Stream &error_stream, ExecutionContext &exe_ctx, bool discard_on_error, ClangUserExpressionSP &shared_ptr_to_me, - ClangExpressionVariable *&result); + lldb::ClangExpressionVariableSP &result); ThreadPlan * GetThreadPlanToExecuteJITExpression (Stream &error_stream, @@ -130,7 +130,7 @@ bool FinalizeJITExecution (Stream &error_stream, ExecutionContext &exe_ctx, - ClangExpressionVariable *&result); + lldb::ClangExpressionVariableSP &result); //------------------------------------------------------------------ /// Return the string that the parser should parse. Must be a full @@ -176,7 +176,7 @@ /// Return the object that the parser should use when registering /// local variables. May be NULL if the Expression doesn't care. //------------------------------------------------------------------ - ClangExpressionVariableStore * + ClangExpressionVariableList * LocalVariables () { return m_local_variables.get(); @@ -239,7 +239,7 @@ /// @result /// A Process::ExecutionResults value. eExecutionCompleted for success. //------------------------------------------------------------------ - static Process::ExecutionResults + static lldb::ExecutionResults Evaluate (ExecutionContext &exe_ctx, bool discard_on_error, const char *expr_cstr, @@ -266,7 +266,7 @@ TypeFromUser m_desired_type; ///< The type to coerce the expression's result to. If NULL, inferred from the expression. std::auto_ptr m_expr_decl_map; ///< The map to use when parsing and materializing the expression. - std::auto_ptr m_local_variables; ///< The local expression variables, if the expression is DWARF. + std::auto_ptr m_local_variables; ///< The local expression variables, if the expression is DWARF. std::auto_ptr m_dwarf_opcodes; ///< The DWARF opcodes for the expression. May be NULL. lldb::addr_t m_jit_addr; ///< The address of the JITted code. LLDB_INVALID_ADDRESS if invalid. Modified: lldb/trunk/include/lldb/Expression/ClangUtilityFunction.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Expression/ClangUtilityFunction.h?rev=121745&r1=121744&r2=121745&view=diff ============================================================================== --- lldb/trunk/include/lldb/Expression/ClangUtilityFunction.h (original) +++ lldb/trunk/include/lldb/Expression/ClangUtilityFunction.h Mon Dec 13 20:59:59 2010 @@ -136,7 +136,7 @@ /// Return the object that the parser should use when registering /// local variables. May be NULL if the Expression doesn't care. //------------------------------------------------------------------ - ClangExpressionVariableStore * + ClangExpressionVariableList * LocalVariables () { return NULL; Modified: lldb/trunk/include/lldb/Expression/IRToDWARF.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Expression/IRToDWARF.h?rev=121745&r1=121744&r2=121745&view=diff ============================================================================== --- lldb/trunk/include/lldb/Expression/IRToDWARF.h (original) +++ lldb/trunk/include/lldb/Expression/IRToDWARF.h Mon Dec 13 20:59:59 2010 @@ -13,19 +13,9 @@ #include "llvm/Pass.h" #include "llvm/PassManager.h" -namespace llvm { - class BasicBlock; - class Module; -} - -namespace lldb_private { - class ClangExpressionVariableStore; - class ClangExpressionDeclMap; - class StreamString; -} +#include "lldb/lldb-include.h" class Relocator; - //---------------------------------------------------------------------- /// @class IRToDWARF IRToDWARF.h "lldb/Expression/IRToDWARF.h" /// @brief Transforms the IR for a function into a DWARF location expression @@ -64,7 +54,7 @@ /// @param[in] func_name /// The name of the function to translate to DWARF. //------------------------------------------------------------------ - IRToDWARF(lldb_private::ClangExpressionVariableStore &local_vars, + IRToDWARF(lldb_private::ClangExpressionVariableList &local_vars, lldb_private::ClangExpressionDeclMap *decl_map, lldb_private::StreamString &strm, const char* func_name = "$__lldb_expr"); @@ -113,7 +103,7 @@ bool runOnBasicBlock(llvm::BasicBlock &BB, Relocator &Relocator); std::string m_func_name; ///< The name of the function to translate - lldb_private::ClangExpressionVariableStore &m_local_vars; ///< The list of local variables to populate while transforming + lldb_private::ClangExpressionVariableList &m_local_vars; ///< The list of local variables to populate while transforming lldb_private::ClangExpressionDeclMap *m_decl_map; ///< The list of external variables lldb_private::StreamString &m_strm; ///< The stream to write bytecode to }; Modified: lldb/trunk/include/lldb/Symbol/ClangASTContext.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Symbol/ClangASTContext.h?rev=121745&r1=121744&r2=121745&view=diff ============================================================================== --- lldb/trunk/include/lldb/Symbol/ClangASTContext.h (original) +++ lldb/trunk/include/lldb/Symbol/ClangASTContext.h Mon Dec 13 20:59:59 2010 @@ -522,6 +522,10 @@ lldb::clang_type_t CreatePointerType (lldb::clang_type_t clang_type); + static lldb::clang_type_t + CreatePointerType (clang::ASTContext *ast, + lldb::clang_type_t clang_type); + lldb::clang_type_t CreateLValueReferenceType (lldb::clang_type_t clang_type); Modified: lldb/trunk/include/lldb/Target/Process.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/Process.h?rev=121745&r1=121744&r2=121745&view=diff ============================================================================== --- lldb/trunk/include/lldb/Target/Process.h (original) +++ lldb/trunk/include/lldb/Target/Process.h Mon Dec 13 20:59:59 2010 @@ -266,17 +266,6 @@ eBroadcastInternalStateControlPause = (1<<1), eBroadcastInternalStateControlResume = (1<<2) }; - - // We can execute Thread Plans on one thread with various fall-back modes (try other threads after timeout, etc.) - // This enum gives the result of thread plan executions. - typedef enum ExecutionResults - { - eExecutionSetupError, - eExecutionCompleted, - eExecutionDiscarded, - eExecutionInterrupted, - eExecutionTimedOut - } ExecutionResults; //------------------------------------------------------------------ /// A notification structure that can be used by clients to listen @@ -1195,7 +1184,7 @@ lldb::StateType GetState (); - ExecutionResults + lldb::ExecutionResults RunThreadPlan (ExecutionContext &exe_ctx, lldb::ThreadPlanSP &thread_plan_sp, bool stop_others, @@ -1205,7 +1194,7 @@ Stream &errors); static const char * - ExecutionResultAsCString (ExecutionResults result); + ExecutionResultAsCString (lldb::ExecutionResults result); protected: friend class CommandObjectProcessLaunch; @@ -1751,9 +1740,6 @@ lldb::ProcessSP GetSP (); - ClangPersistentVariables & - GetPersistentVariables(); - protected: //------------------------------------------------------------------ // Member variables @@ -1776,7 +1762,6 @@ Listener &m_listener; BreakpointSiteList m_breakpoint_site_list; ///< This is the list of breakpoint locations we intend ///< to insert in the target. - ClangPersistentVariables m_persistent_vars; ///< These are the persistent variables associated with this process for the expression parser. std::auto_ptr m_dynamic_checkers_ap; ///< The functions used by the expression parser to validate data that expressions use. UnixSignals m_unix_signals; /// This is the current signal set for this process. ConstString m_target_triple; Modified: lldb/trunk/include/lldb/Target/StackFrame.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/StackFrame.h?rev=121745&r1=121744&r2=121745&view=diff ============================================================================== --- lldb/trunk/include/lldb/Target/StackFrame.h (original) +++ lldb/trunk/include/lldb/Target/StackFrame.h Mon Dec 13 20:59:59 2010 @@ -96,6 +96,9 @@ VariableList * GetVariableList (bool get_file_globals); + lldb::ValueObjectSP + GetValueForVariableExpressionPath (const char *var_expr); + bool HasDebugInformation (); Modified: lldb/trunk/include/lldb/Target/Target.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/Target.h?rev=121745&r1=121744&r2=121745&view=diff ============================================================================== --- lldb/trunk/include/lldb/Target/Target.h (original) +++ lldb/trunk/include/lldb/Target/Target.h Mon Dec 13 20:59:59 2010 @@ -446,6 +446,25 @@ const char * GetExpressionPrefixContentsAsCString (); + // Since expressions results can persist beyond the lifetime of a process, + // and the const expression results are available after a process is gone, + // we provide a way for expressions to be evaluated from the Target itself. + // If an expression is going to be run, then it should have a frame filled + // in in th execution context. + lldb::ExecutionResults + EvaluateExpression (const char *expression, + StackFrame *frame, + bool unwind_on_error, + lldb::ValueObjectSP &result_valobj_sp); + + ClangPersistentVariables & + GetPersistentVariables() + { + return m_persistent_variables; + } + + + protected: friend class lldb::SBTarget; @@ -467,6 +486,8 @@ lldb::SearchFilterSP m_search_filter_sp; PathMappingList m_image_search_paths; std::auto_ptr m_scratch_ast_context_ap; + ClangPersistentVariables m_persistent_variables; ///< These are the persistent variables associated with this process for the expression parser. + //------------------------------------------------------------------ // Methods. //------------------------------------------------------------------ Modified: lldb/trunk/include/lldb/lldb-enumerations.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/lldb-enumerations.h?rev=121745&r1=121744&r2=121745&view=diff ============================================================================== --- lldb/trunk/include/lldb/lldb-enumerations.h (original) +++ lldb/trunk/include/lldb/lldb-enumerations.h Mon Dec 13 20:59:59 2010 @@ -615,6 +615,21 @@ ePathTypePythonDir // Find Python modules (PYTHONPATH) directory } PathType; + +//---------------------------------------------------------------------- +// We can execute ThreadPlans on one thread with various fall-back modes +// (try other threads after timeout, etc.) This enum gives the result of +// thread plan executions. +//---------------------------------------------------------------------- +typedef enum ExecutionResults +{ + eExecutionSetupError, + eExecutionCompleted, + eExecutionDiscarded, + eExecutionInterrupted, + eExecutionTimedOut +} ExecutionResults; + } // namespace lldb 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=121745&r1=121744&r2=121745&view=diff ============================================================================== --- lldb/trunk/include/lldb/lldb-forward-rtti.h (original) +++ lldb/trunk/include/lldb/lldb-forward-rtti.h Mon Dec 13 20:59:59 2010 @@ -29,8 +29,10 @@ typedef SharedPtr::Type BreakpointLocationSP; typedef SharedPtr::Type BreakpointResolverSP; typedef SharedPtr::Type BroadcasterSP; + typedef SharedPtr::Type ClangExpressionVariableSP; typedef SharedPtr::Type CommandObjectSP; typedef SharedPtr::Type CommunicationSP; + typedef SharedPtr::Type ConnectionSP; typedef SharedPtr::Type CompUnitSP; typedef SharedPtr::Type DataBufferSP; typedef SharedPtr::Type DebuggerSP; Modified: lldb/trunk/include/lldb/lldb-forward.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/lldb-forward.h?rev=121745&r1=121744&r2=121745&view=diff ============================================================================== --- lldb/trunk/include/lldb/lldb-forward.h (original) +++ lldb/trunk/include/lldb/lldb-forward.h Mon Dec 13 20:59:59 2010 @@ -47,7 +47,7 @@ class ClangExpressionDeclMap; class ClangExpressionVariable; class ClangExpressionVariableList; -class ClangExpressionVariableStore; +class ClangExpressionVariableList; class CommandInterpreter; class CommandObject; class CommandReturnObject; Modified: lldb/trunk/source/API/SBFrame.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBFrame.cpp?rev=121745&r1=121744&r2=121745&view=diff ============================================================================== --- lldb/trunk/source/API/SBFrame.cpp (original) +++ lldb/trunk/source/API/SBFrame.cpp Mon Dec 13 20:59:59 2010 @@ -570,16 +570,10 @@ if (m_opaque_sp) { - ExecutionContext exe_ctx; - m_opaque_sp->CalculateExecutionContext (exe_ctx); - - const char *prefix = NULL; - const bool discard_on_error = true; - - if (exe_ctx.target) - prefix = exe_ctx.target->GetExpressionPrefixContentsAsCString(); - - ClangUserExpression::Evaluate (exe_ctx, discard_on_error, expr, prefix, *expr_result); + lldb::ExecutionResults exe_results; + const bool unwind_on_error = true; + + exe_results = m_opaque_sp->GetThread().GetProcess().GetTarget().EvaluateExpression(expr, m_opaque_sp.get(), unwind_on_error, *expr_result); } if (expr_log) Modified: lldb/trunk/source/Commands/CommandObjectExpression.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectExpression.cpp?rev=121745&r1=121744&r2=121745&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectExpression.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectExpression.cpp Mon Dec 13 20:59:59 2010 @@ -232,55 +232,55 @@ CommandReturnObject *result ) { - if (!m_exe_ctx.process) - { - error_stream.Printf ("Execution context doesn't contain a process\n"); - return false; - } - - const char *prefix = NULL; - if (m_exe_ctx.target) - prefix = m_exe_ctx.target->GetExpressionPrefixContentsAsCString(); - - lldb::ValueObjectSP result_valobj_sp; - Process::ExecutionResults execution_results = ClangUserExpression::Evaluate (m_exe_ctx, m_options.unwind_on_error, expr, prefix, result_valobj_sp); - assert (result_valobj_sp.get()); - if (result_valobj_sp->GetError().Success()) { - if (m_options.format != eFormatDefault) - result_valobj_sp->SetFormat (m_options.format); + lldb::ValueObjectSP result_valobj_sp; - ValueObject::DumpValueObject (output_stream, - m_exe_ctx.GetBestExecutionContextScope(), - result_valobj_sp.get(), // Variable object to dump - result_valobj_sp->GetName().AsCString(),// Root object name - 0, // Pointer depth to traverse (zero means stop at pointers) - 0, // Current depth, this is the top most, so zero... - UINT32_MAX, // Max depth to go when dumping concrete types, dump everything... - m_options.show_types, // Show types when dumping? - false, // Show locations of variables, no since this is a host address which we don't care to see - m_options.print_object, // Print the objective C object? - true, // Scope is already checked. Const results are always in scope. - false); // Don't flatten output - if (result) - result->SetStatus (eReturnStatusSuccessFinishResult); - } - else - { - error_stream.PutCString(result_valobj_sp->GetError().AsCString()); - // If we've been interrupted, display state information. - if (execution_results == Process::eExecutionInterrupted && !m_options.unwind_on_error) + lldb::ExecutionResults exe_results; + exe_results = m_exe_ctx.target->EvaluateExpression(expr, m_exe_ctx.frame, m_options.unwind_on_error, result_valobj_sp); + + if (exe_results == eExecutionInterrupted && !m_options.unwind_on_error) { if (m_exe_ctx.thread) lldb_private::DisplayThreadInfo (m_interpreter, result->GetOutputStream(), m_exe_ctx.thread, false, true); else - { lldb_private::DisplayThreadsInfo (m_interpreter, &m_exe_ctx, *result, true, true); + } + + if (result_valobj_sp) + { + if (result_valobj_sp->GetError().Success()) + { + if (m_options.format != eFormatDefault) + result_valobj_sp->SetFormat (m_options.format); + + ValueObject::DumpValueObject (output_stream, + m_exe_ctx.GetBestExecutionContextScope(), + result_valobj_sp.get(), // Variable object to dump + result_valobj_sp->GetName().GetCString(),// Root object name + 0, // Pointer depth to traverse (zero means stop at pointers) + 0, // Current depth, this is the top most, so zero... + UINT32_MAX, // Max depth to go when dumping concrete types, dump everything... + m_options.show_types, // Show types when dumping? + false, // Show locations of variables, no since this is a host address which we don't care to see + m_options.print_object, // Print the objective C object? + true, // Scope is already checked. Const results are always in scope. + false); // Don't flatten output + if (result) + result->SetStatus (eReturnStatusSuccessFinishResult); + } + else + { + error_stream.PutCString(result_valobj_sp->GetError().AsCString()); + if (result) + result->SetStatus (eReturnStatusFailed); } } - if (result) - result->SetStatus (eReturnStatusFailed); + } + else + { + error_stream.Printf ("error: invalid execution context for expression\n"); + return false; } return true; Modified: lldb/trunk/source/Core/Communication.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/Communication.cpp?rev=121745&r1=121744&r2=121745&view=diff ============================================================================== --- lldb/trunk/source/Core/Communication.cpp (original) +++ lldb/trunk/source/Core/Communication.cpp Mon Dec 13 20:59:59 2010 @@ -27,7 +27,7 @@ //---------------------------------------------------------------------- Communication::Communication(const char *name) : Broadcaster (name), - m_connection_ap (), + m_connection_sp (), m_read_thread (LLDB_INVALID_HOST_THREAD), m_read_thread_enabled (false), m_bytes(), @@ -65,8 +65,9 @@ { lldb_private::LogIfAnyCategoriesSet (LIBLLDB_LOG_COMMUNICATION, "%p Communication::BytesAvailable (timeout_usec = %u)", this, timeout_usec); - if (m_connection_ap.get()) - return m_connection_ap->BytesAvailable (timeout_usec, error_ptr); + lldb::ConnectionSP connection_sp (m_connection_sp); + if (connection_sp.get()) + return connection_sp->BytesAvailable (timeout_usec, error_ptr); if (error_ptr) error_ptr->SetErrorString("Invalid connection."); return eConnectionStatusNoConnection; @@ -79,8 +80,9 @@ lldb_private::LogIfAnyCategoriesSet (LIBLLDB_LOG_COMMUNICATION, "%p Communication::Connect (url = %s)", this, url); - if (m_connection_ap.get()) - return m_connection_ap->Connect (url, error_ptr); + lldb::ConnectionSP connection_sp (m_connection_sp); + if (connection_sp.get()) + return connection_sp->Connect (url, error_ptr); if (error_ptr) error_ptr->SetErrorString("Invalid connection."); return eConnectionStatusNoConnection; @@ -91,10 +93,11 @@ { lldb_private::LogIfAnyCategoriesSet (LIBLLDB_LOG_COMMUNICATION, "%p Communication::Disconnect ()", this); - if (m_connection_ap.get()) + lldb::ConnectionSP connection_sp (m_connection_sp); + if (connection_sp.get()) { - ConnectionStatus status = m_connection_ap->Disconnect (error_ptr); - // We currently don't protect m_connection_ap with any mutex for + ConnectionStatus status = connection_sp->Disconnect (error_ptr); + // We currently don't protect connection_sp with any mutex for // multi-threaded environments. So lets not nuke our connection class // without putting some multi-threaded protections in. We also probably // don't want to pay for the overhead it might cause if every time we @@ -103,7 +106,7 @@ // This auto_ptr will cleanup after itself when this object goes away, // so there is no need to currently have it destroy itself immediately // upon disconnnect. - //m_connection_ap.reset(); + //connection_sp.reset(); return status; } return eConnectionStatusNoConnection; @@ -112,23 +115,28 @@ bool Communication::IsConnected () const { - if (m_connection_ap.get()) - return m_connection_ap->IsConnected (); + lldb::ConnectionSP connection_sp (m_connection_sp); + if (connection_sp.get()) + return connection_sp->IsConnected (); return false; } bool Communication::HasConnection () const { - return m_connection_ap.get() != NULL; + return m_connection_sp.get() != NULL; } size_t Communication::Read (void *dst, size_t dst_len, uint32_t timeout_usec, ConnectionStatus &status, Error *error_ptr) { lldb_private::LogIfAnyCategoriesSet (LIBLLDB_LOG_COMMUNICATION, - "%p Communication::Write (dst = %p, dst_len = %zu, timeout_usec = %u) connection = %p", - this, dst, dst_len, timeout_usec, m_connection_ap.get()); + "%p Communication::Read (dst = %p, dst_len = %zu, timeout_usec = %u) connection = %p", + this, + dst, + dst_len, + timeout_usec, + m_connection_sp.get()); if (m_read_thread != LLDB_INVALID_HOST_THREAD) { @@ -140,7 +148,7 @@ return cached_bytes; } - if (m_connection_ap.get() == NULL) + if (m_connection_sp.get() == NULL) { if (error_ptr) error_ptr->SetErrorString("Invalid connection."); @@ -177,11 +185,12 @@ // We aren't using a read thread, just read the data synchronously in this // thread. - if (m_connection_ap.get()) + lldb::ConnectionSP connection_sp (m_connection_sp); + if (connection_sp.get()) { - status = m_connection_ap->BytesAvailable (timeout_usec, error_ptr); + status = connection_sp->BytesAvailable (timeout_usec, error_ptr); if (status == eConnectionStatusSuccess) - return m_connection_ap->Read (dst, dst_len, status, error_ptr); + return connection_sp->Read (dst, dst_len, status, error_ptr); } if (error_ptr) @@ -194,12 +203,17 @@ size_t Communication::Write (const void *src, size_t src_len, ConnectionStatus &status, Error *error_ptr) { + lldb::ConnectionSP connection_sp (m_connection_sp); + lldb_private::LogIfAnyCategoriesSet (LIBLLDB_LOG_COMMUNICATION, - "%p Communication::Write (src = %p, src_len = %zu) connection = %p", - this, src, src_len, m_connection_ap.get()); + "%p Communication::Write (src = %p, src_len = %zu) connection = %p", + this, + src, + src_len, + connection_sp.get()); - if (m_connection_ap.get()) - return m_connection_ap->Write (src, src_len, status, error_ptr); + if (connection_sp.get()) + return connection_sp->Write (src, src_len, status, error_ptr); if (error_ptr) error_ptr->SetErrorString("Invalid connection."); @@ -294,8 +308,9 @@ size_t Communication::ReadFromConnection (void *dst, size_t dst_len, ConnectionStatus &status, Error *error_ptr) { - if (m_connection_ap.get()) - return m_connection_ap->Read (dst, dst_len, status, error_ptr); + lldb::ConnectionSP connection_sp (m_connection_sp); + if (connection_sp.get()) + return connection_sp->Read (dst, dst_len, status, error_ptr); return 0; } @@ -376,7 +391,7 @@ { StopReadThread(NULL); Disconnect (NULL); - m_connection_ap.reset(connection); + m_connection_sp.reset(connection); } const char * Modified: lldb/trunk/source/Core/ModuleList.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/ModuleList.cpp?rev=121745&r1=121744&r2=121745&view=diff ============================================================================== --- lldb/trunk/source/Core/ModuleList.cpp (original) +++ lldb/trunk/source/Core/ModuleList.cpp Mon Dec 13 20:59:59 2010 @@ -13,6 +13,7 @@ // C++ Includes // Other libraries and framework includes // Project includes +#include "lldb/Core/Log.h" #include "lldb/Core/Module.h" #include "lldb/Host/Symbols.h" #include "lldb/Symbol/ObjectFile.h" @@ -374,6 +375,29 @@ } } +void +ModuleList::LogUUIDAndPaths (LogSP &log_sp, const char *prefix_cstr) +{ + if (log_sp) + { + Mutex::Locker locker(m_modules_mutex); + char uuid_cstr[256]; + collection::const_iterator pos, begin = m_modules.begin(), end = m_modules.end(); + for (pos = begin; pos != end; ++pos) + { + Module *module = pos->get(); + module->GetUUID().GetAsCString (uuid_cstr, sizeof(uuid_cstr)); + const FileSpec &module_file_spec = module->GetFileSpec(); + log_sp->Printf ("%s[%u] %s (%s) \"%s/%s\"", + prefix_cstr ? prefix_cstr : "", + (uint32_t)std::distance (begin, pos), + uuid_cstr, + module->GetArchitecture().AsCString(), + module_file_spec.GetDirectory().GetCString(), + module_file_spec.GetFilename().GetCString()); + } + } +} bool ModuleList::ResolveFileAddress (lldb::addr_t vm_addr, Address& so_addr) Modified: lldb/trunk/source/Core/Value.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/Value.cpp?rev=121745&r1=121744&r2=121745&view=diff ============================================================================== --- lldb/trunk/source/Core/Value.cpp (original) +++ lldb/trunk/source/Core/Value.cpp Mon Dec 13 20:59:59 2010 @@ -162,34 +162,6 @@ return NULL; } -//#include "clang/Lex/LiteralSupport.h" -//#include "clang/AST/ASTContext.h" -//#include "clang/Frontend/CompilerInstance.h" -// -//Value::Value (const char *data, llvm::CompilerInstance *compiler) -//{ -// clang::NumericLiteralParser parser(data, data + strlen(data), clang::SourceLocation(), -// compiler->getPreprocessor()); -// if (parser.had_error) -// { -// } -// else if (parser.isBool) -// { -// APInt value; -// parser.GetIntegerValue(value); -// } -// else if (parser.isLong) -// { -// } -// else if (parser.isLongLong) -// { -// } -// else if (parser.isFloat) -// { -// } -// -//} -// void Value::Dump (Stream* strm) { @@ -484,6 +456,34 @@ return eFormatHex; } +bool +Value::GetData (DataExtractor &data) +{ + switch (m_value_type) + { + default: + break; + + case eValueTypeScalar: + if (m_value.GetData (data)) + return true; + break; + + case eValueTypeLoadAddress: + case eValueTypeFileAddress: + case eValueTypeHostAddress: + if (m_data_buffer.GetByteSize()) + { + data.SetData(m_data_buffer.GetBytes(), m_data_buffer.GetByteSize(), data.GetByteOrder()); + return true; + } + break; + } + + return false; + +} + Error Value::GetValueAsData (ExecutionContext *exe_ctx, clang::ASTContext *ast_context, DataExtractor &data, uint32_t data_offset) { Modified: lldb/trunk/source/Core/ValueObject.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/ValueObject.cpp?rev=121745&r1=121744&r2=121745&view=diff ============================================================================== --- lldb/trunk/source/Core/ValueObject.cpp (original) +++ lldb/trunk/source/Core/ValueObject.cpp Mon Dec 13 20:59:59 2010 @@ -21,6 +21,7 @@ #include "lldb/Core/DataBufferHeap.h" #include "lldb/Core/StreamString.h" #include "lldb/Core/ValueObjectChild.h" +#include "lldb/Core/ValueObjectConstResult.h" #include "lldb/Core/ValueObjectList.h" #include "lldb/Symbol/ClangASTType.h" @@ -62,7 +63,8 @@ m_value_is_valid (false), m_value_did_change (false), m_children_count_valid (false), - m_old_value_valid (false) + m_old_value_valid (false), + m_pointers_point_to_load_addrs (false) { } @@ -281,7 +283,7 @@ bool omit_empty_base_classes = true; return ClangASTContext::GetIndexOfChildWithName (GetClangAST(), GetClangType(), - name.AsCString(), + name.GetCString(), omit_empty_base_classes); } @@ -297,7 +299,7 @@ bool omit_empty_base_classes = true; const size_t num_child_indexes = ClangASTContext::GetIndexOfChildMemberWithName (clang_ast, clang_type, - name.AsCString(), + name.GetCString(), omit_empty_base_classes, child_indexes); ValueObjectSP child_sp; @@ -370,7 +372,7 @@ clang_type_t clang_type = GetClangType(); clang_type_t child_clang_type; child_clang_type = ClangASTContext::GetChildClangTypeAtIndex (clang_ast, - GetName().AsCString(), + GetName().GetCString(), clang_type, idx, transparent_pointers, @@ -399,6 +401,8 @@ child_bitfield_bit_size, child_bitfield_bit_offset, child_is_base_class)); + if (m_pointers_point_to_load_addrs) + valobj_sp->SetPointersPointToLoadAddrs (m_pointers_point_to_load_addrs); } return valobj_sp; } @@ -418,8 +422,8 @@ StreamString sstr; clang_type_t elem_or_pointee_clang_type; const Flags type_flags (ClangASTContext::GetTypeInfo (clang_type, - GetClangAST(), - &elem_or_pointee_clang_type)); + GetClangAST(), + &elem_or_pointee_clang_type)); if (type_flags.AnySet (ClangASTContext::eTypeIsArray | ClangASTContext::eTypeIsPointer) && ClangASTContext::IsCharType (elem_or_pointee_clang_type)) @@ -721,6 +725,10 @@ } break; } + + if (m_pointers_point_to_load_addrs) + address_type = eAddressTypeLoad; + return address; } @@ -956,7 +964,7 @@ } else { - const char *name = GetName().AsCString(); + const char *name = GetName().GetCString(); if (name) s.PutCString(name); } @@ -1001,7 +1009,7 @@ // Always show the type for the top level items. if (show_types || curr_depth == 0) - s.Printf("(%s) ", valobj->GetTypeName().AsCString()); + s.Printf("(%s) ", valobj->GetTypeName().AsCString("")); if (flat_output) @@ -1163,3 +1171,197 @@ } } + +ValueObjectSP +ValueObject::CreateConstantValue (ExecutionContextScope *exe_scope, const ConstString &name) +{ + ValueObjectSP valobj_sp; + + if (UpdateValueIfNeeded(exe_scope) && m_error.Success()) + { + ExecutionContext exe_ctx; + exe_scope->CalculateExecutionContext(exe_ctx); + + clang::ASTContext *ast = GetClangAST (); + + DataExtractor data; + data.SetByteOrder (m_data.GetByteOrder()); + data.SetAddressByteSize(m_data.GetAddressByteSize()); + + m_error = m_value.GetValueAsData (&exe_ctx, ast, data, 0); + + valobj_sp.reset (new ValueObjectConstResult (ast, + GetClangType(), + name, + data)); + } + else + { + valobj_sp.reset (new ValueObjectConstResult (m_error)); + } + return valobj_sp; +} + +lldb::ValueObjectSP +ValueObject::Dereference (ExecutionContextScope *exe_scope, Error *error_ptr) +{ + lldb::ValueObjectSP valobj_sp; + if (IsPointerType()) + { + bool omit_empty_base_classes = true; + + std::string child_name_str; + uint32_t child_byte_size = 0; + int32_t child_byte_offset = 0; + uint32_t child_bitfield_bit_size = 0; + uint32_t child_bitfield_bit_offset = 0; + bool child_is_base_class = false; + const bool transparent_pointers = false; + clang::ASTContext *clang_ast = GetClangAST(); + clang_type_t clang_type = GetClangType(); + clang_type_t child_clang_type; + child_clang_type = ClangASTContext::GetChildClangTypeAtIndex (clang_ast, + GetName().GetCString(), + clang_type, + 0, + transparent_pointers, + omit_empty_base_classes, + child_name_str, + child_byte_size, + child_byte_offset, + child_bitfield_bit_size, + child_bitfield_bit_offset, + child_is_base_class); + if (child_clang_type) + { + ConstString child_name; + if (!child_name_str.empty()) + child_name.SetCString (child_name_str.c_str()); + + valobj_sp.reset (new ValueObjectChild (this, + clang_ast, + child_clang_type, + child_name, + child_byte_size, + child_byte_offset, + child_bitfield_bit_size, + child_bitfield_bit_offset, + child_is_base_class)); + } + } + else + { + if (error_ptr) + error_ptr->SetErrorString("can't dereference a non-pointer value"); + } + + return valobj_sp; +} + + + +//lldb::ValueObjectSP +//ValueObject::Dereference (ExecutionContextScope *exe_scope, Error *error_ptr) +//{ +// lldb::ValueObjectSP valobj_sp; +// if (IsPointerType()) +// { +// UpdateValueIfNeeded(exe_scope); +// if (m_error.Success()) +// { +// lldb::AddressType address_type = eAddressTypeInvalid; +// const bool scalar_is_load_address = true; +// lldb::addr_t addr = GetPointerValue (address_type, scalar_is_load_address); +// if (addr != LLDB_INVALID_ADDRESS) +// { +// switch (address_type) +// { +// case eAddressTypeInvalid: +// if (error_ptr) +// error_ptr->SetErrorString("value is not in memory"); +// break; +// case eAddressTypeFile: +// case eAddressTypeLoad: +// case eAddressTypeHost: +// { +// clang::ASTContext *ast = GetClangAST(); +// clang_type_t clang_type = ClangASTType::GetPointeeType (GetClangType()); +// if (ast && clang_type) +// { +// std::string name (1, '*'); +// name.append (m_name.AsCString("")); +// valobj_sp.reset (new ValueObjectConstResult (ast, +// ClangASTContext::CreatePointerType (ast, clang_type), +// ConstString (name.c_str()), +// addr, +// address_type, +// m_data.GetAddressByteSize())); +// } +// else +// { +// if (error_ptr) +// error_ptr->SetErrorString("invalid clang type info"); +// } +// } +// break; +// } +// } +// else +// { +// if (error_ptr) +// error_ptr->SetErrorString("failed to extract pointer value"); +// } +// } +// else +// { +// if (error_ptr) +// *error_ptr = m_error; +// } +// } +// else +// { +// if (error_ptr) +// error_ptr->SetErrorString("can't dereference a non-pointer value"); +// } +// +// return valobj_sp; +//} + +lldb::ValueObjectSP +ValueObject::AddressOf () +{ + lldb::ValueObjectSP valobj_sp; + + lldb::AddressType address_type = eAddressTypeInvalid; + const bool scalar_is_load_address = false; + lldb::addr_t addr = GetAddressOf (address_type, scalar_is_load_address); + if (addr != LLDB_INVALID_ADDRESS) + { + switch (address_type) + { + case eAddressTypeInvalid: + break; + case eAddressTypeFile: + case eAddressTypeLoad: + case eAddressTypeHost: + { + clang::ASTContext *ast = GetClangAST(); + clang_type_t clang_type = GetClangType(); + if (ast && clang_type) + { + std::string name (1, '&'); + name.append (m_name.AsCString("")); + valobj_sp.reset (new ValueObjectConstResult (ast, + ClangASTContext::CreatePointerType (ast, clang_type), + ConstString (name.c_str()), + addr, + address_type, + m_data.GetAddressByteSize())); + } + } + break; + } + } + return valobj_sp; +} + Modified: lldb/trunk/source/Core/ValueObjectChild.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/ValueObjectChild.cpp?rev=121745&r1=121744&r2=121745&view=diff ============================================================================== --- lldb/trunk/source/Core/ValueObjectChild.cpp (original) +++ lldb/trunk/source/Core/ValueObjectChild.cpp Mon Dec 13 20:59:59 2010 @@ -125,7 +125,8 @@ else { m_value.GetScalar() += m_byte_offset; - if (value_type == Value::eValueTypeScalar || + if (m_pointers_point_to_load_addrs || + value_type == Value::eValueTypeScalar || value_type == Value::eValueTypeFileAddress) m_value.SetValueType (Value::eValueTypeLoadAddress); } Modified: lldb/trunk/source/Core/ValueObjectConstResult.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/ValueObjectConstResult.cpp?rev=121745&r1=121744&r2=121745&view=diff ============================================================================== --- lldb/trunk/source/Core/ValueObjectConstResult.cpp (original) +++ lldb/trunk/source/Core/ValueObjectConstResult.cpp Mon Dec 13 20:59:59 2010 @@ -28,6 +28,45 @@ ValueObjectConstResult::ValueObjectConstResult ( + ByteOrder byte_order, + uint32_t addr_byte_size +) : + ValueObject (NULL), + m_clang_ast (NULL), + m_type_name (), + m_byte_size (0) +{ + SetIsConstant (); + SetValueIsValid(true); + m_data.SetByteOrder(byte_order); + m_data.SetAddressByteSize(addr_byte_size); + m_pointers_point_to_load_addrs = true; +} + +ValueObjectConstResult::ValueObjectConstResult +( + clang::ASTContext *clang_ast, + void *clang_type, + const ConstString &name, + const DataExtractor &data +) : + ValueObject (NULL), + m_clang_ast (clang_ast), + m_type_name (), + m_byte_size (0) +{ + m_data = data; + m_value.GetScalar() = (uintptr_t)m_data.GetDataStart(); + m_value.SetValueType(Value::eValueTypeHostAddress); + m_value.SetContext(Value::eContextTypeClangType, clang_type); + m_name = name; + SetIsConstant (); + SetValueIsValid(true); + m_pointers_point_to_load_addrs = true; +} + +ValueObjectConstResult::ValueObjectConstResult +( clang::ASTContext *clang_ast, void *clang_type, const ConstString &name, @@ -37,7 +76,8 @@ ) : ValueObject (NULL), m_clang_ast (clang_ast), - m_type_name () + m_type_name (), + m_byte_size (0) { m_data.SetByteOrder(data_byte_order); m_data.SetAddressByteSize(data_addr_size); @@ -48,15 +88,51 @@ m_name = name; SetIsConstant (); SetValueIsValid(true); + m_pointers_point_to_load_addrs = true; +} + +ValueObjectConstResult::ValueObjectConstResult +( + clang::ASTContext *clang_ast, + void *clang_type, + const ConstString &name, + lldb::addr_t address, + lldb::AddressType address_type, + uint8_t addr_byte_size +) : + ValueObject (NULL), + m_clang_ast (clang_ast), + m_type_name (), + m_byte_size (0) +{ + m_value.GetScalar() = address; + m_data.SetAddressByteSize(addr_byte_size); + m_value.GetScalar().GetData (m_data, addr_byte_size); + //m_value.SetValueType(Value::eValueTypeHostAddress); + switch (address_type) + { + default: + case eAddressTypeInvalid: m_value.SetValueType(Value::eValueTypeScalar); break; + case eAddressTypeFile: m_value.SetValueType(Value::eValueTypeFileAddress); break; + case eAddressTypeLoad: m_value.SetValueType(Value::eValueTypeLoadAddress); break; + case eAddressTypeHost: m_value.SetValueType(Value::eValueTypeHostAddress); break; + } + m_value.SetContext(Value::eContextTypeClangType, clang_type); + m_name = name; + SetIsConstant (); + SetValueIsValid(true); + m_pointers_point_to_load_addrs = true; } ValueObjectConstResult::ValueObjectConstResult (const Error& error) : ValueObject (NULL), m_clang_ast (NULL), - m_type_name () + m_type_name (), + m_byte_size (0) { m_error = error; SetIsConstant (); + m_pointers_point_to_load_addrs = true; } ValueObjectConstResult::~ValueObjectConstResult() @@ -78,8 +154,18 @@ size_t ValueObjectConstResult::GetByteSize() { - // We stored all the data for this const object in our data - return m_data.GetByteSize(); + if (m_byte_size == 0) + { + uint64_t bit_width = ClangASTType::GetClangTypeBitWidth (GetClangAST(), GetClangType()); + m_byte_size = (bit_width + 7 ) / 8; + } + return m_byte_size; +} + +void +ValueObjectConstResult::SetByteSize (size_t size) +{ + m_byte_size = size; } uint32_t @@ -105,7 +191,6 @@ void ValueObjectConstResult::UpdateValue (ExecutionContextScope *exe_scope) { - m_error.Clear(); // Const value is always valid SetValueIsValid (true); } Modified: lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp?rev=121745&r1=121744&r2=121745&view=diff ============================================================================== --- lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp (original) +++ lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp Mon Dec 13 20:59:59 2010 @@ -59,7 +59,8 @@ DisableStructVars(); } -void ClangExpressionDeclMap::WillParse(ExecutionContext &exe_ctx) +void +ClangExpressionDeclMap::WillParse(ExecutionContext &exe_ctx) { EnableParserVars(); m_parser_vars->m_exe_ctx = &exe_ctx; @@ -69,32 +70,35 @@ else if (exe_ctx.thread) m_parser_vars->m_sym_ctx = exe_ctx.thread->GetStackFrameAtIndex(0)->GetSymbolContext(lldb::eSymbolContextEverything); - if (exe_ctx.process) - m_parser_vars->m_persistent_vars = &exe_ctx.process->GetPersistentVariables(); + if (exe_ctx.target) + m_parser_vars->m_persistent_vars = &exe_ctx.target->GetPersistentVariables(); } -void ClangExpressionDeclMap::DidParse() +void +ClangExpressionDeclMap::DidParse() { if (m_parser_vars.get()) { - for (uint64_t entity_index = 0, num_entities = m_found_entities.Size(); + for (size_t entity_index = 0, num_entities = m_found_entities.GetSize(); entity_index < num_entities; ++entity_index) { - ClangExpressionVariable &entity(m_found_entities.VariableAtIndex(entity_index)); - if (entity.m_parser_vars.get() && - entity.m_parser_vars->m_lldb_value) - delete entity.m_parser_vars->m_lldb_value; + ClangExpressionVariableSP var_sp(m_found_entities.GetVariableAtIndex(entity_index)); + if (var_sp && + var_sp->m_parser_vars.get() && + var_sp->m_parser_vars->m_lldb_value) + delete var_sp->m_parser_vars->m_lldb_value; - entity.DisableParserVars(); + var_sp->DisableParserVars(); } - for (uint64_t pvar_index = 0, num_pvars = m_parser_vars->m_persistent_vars->Size(); + for (size_t pvar_index = 0, num_pvars = m_parser_vars->m_persistent_vars->GetSize(); pvar_index < num_pvars; ++pvar_index) { - ClangExpressionVariable &pvar(m_parser_vars->m_persistent_vars->VariableAtIndex(pvar_index)); - pvar.DisableParserVars(); + ClangExpressionVariableSP pvar_sp(m_parser_vars->m_persistent_vars->GetVariableAtIndex(pvar_index)); + if (pvar_sp) + pvar_sp->DisableParserVars(); } DisableParserVars(); @@ -108,10 +112,12 @@ { assert (m_struct_vars.get()); assert (m_parser_vars.get()); - if (!m_struct_vars->m_result_name) - m_parser_vars->m_persistent_vars->GetNextResultName(m_struct_vars->m_result_name); - + { + Target *target = m_parser_vars->GetTarget(); + assert (target); + m_struct_vars->m_result_name = target->GetPersistentVariables().GetNextPersistentVariableName(); + } return m_struct_vars->m_result_name; } @@ -132,18 +138,21 @@ parser_type.GetOpaqueQualType()), context); - if (!m_parser_vars->m_persistent_vars->CreatePersistentVariable (name, user_type)) + if (!m_parser_vars->m_persistent_vars->CreatePersistentVariable (name, + user_type, + m_parser_vars->m_exe_ctx->process->GetByteOrder(), + m_parser_vars->m_exe_ctx->process->GetAddressByteSize())) return false; - ClangExpressionVariable *var = m_parser_vars->m_persistent_vars->GetVariable(name); + ClangExpressionVariableSP var_sp (m_parser_vars->m_persistent_vars->GetVariable(name)); - if (!var) + if (!var_sp) return false; - var->EnableParserVars(); + var_sp->EnableParserVars(); - var->m_parser_vars->m_named_decl = decl; - var->m_parser_vars->m_parser_type = parser_type; + var_sp->m_parser_vars->m_named_decl = decl; + var_sp->m_parser_vars->m_parser_type = parser_type; return true; } @@ -168,29 +177,29 @@ if (m_struct_members.GetVariable(decl)) return true; - ClangExpressionVariable *var = m_found_entities.GetVariable(decl); + ClangExpressionVariableSP var_sp (m_found_entities.GetVariable(decl)); - if (!var) - var = m_parser_vars->m_persistent_vars->GetVariable(decl); + if (!var_sp) + var_sp = m_parser_vars->m_persistent_vars->GetVariable(decl); - if (!var) + if (!var_sp) return false; if (log) log->Printf("Adding value for decl %p [%s - %s] to the structure", decl, name.GetCString(), - var->m_name.GetCString()); + var_sp->GetName().GetCString()); // We know entity->m_parser_vars is valid because we used a parser variable // to find it - var->m_parser_vars->m_llvm_value = value; + var_sp->m_parser_vars->m_llvm_value = value; - var->EnableJITVars(); - var->m_jit_vars->m_alignment = alignment; - var->m_jit_vars->m_size = size; + var_sp->EnableJITVars(); + var_sp->m_jit_vars->m_alignment = alignment; + var_sp->m_jit_vars->m_size = size; - m_struct_members.AddVariable(*var); + m_struct_members.AddVariable(var_sp); return true; } @@ -208,23 +217,25 @@ m_struct_vars->m_struct_alignment = 0; m_struct_vars->m_struct_size = 0; - for (uint64_t member_index = 0, num_members = m_struct_members.Size(); + for (size_t member_index = 0, num_members = m_struct_members.GetSize(); member_index < num_members; ++member_index) { - ClangExpressionVariable &member(m_struct_members.VariableAtIndex(member_index)); - - if (!member.m_jit_vars.get()) + ClangExpressionVariableSP member_sp(m_struct_members.GetVariableAtIndex(member_index)); + if (!member_sp) + return false; + + if (!member_sp->m_jit_vars.get()) return false; if (member_index == 0) - m_struct_vars->m_struct_alignment = member.m_jit_vars->m_alignment; + m_struct_vars->m_struct_alignment = member_sp->m_jit_vars->m_alignment; - if (cursor % member.m_jit_vars->m_alignment) - cursor += (member.m_jit_vars->m_alignment - (cursor % member.m_jit_vars->m_alignment)); + if (cursor % member_sp->m_jit_vars->m_alignment) + cursor += (member_sp->m_jit_vars->m_alignment - (cursor % member_sp->m_jit_vars->m_alignment)); - member.m_jit_vars->m_offset = cursor; - cursor += member.m_jit_vars->m_size; + member_sp->m_jit_vars->m_offset = cursor; + cursor += member_sp->m_jit_vars->m_size; } m_struct_vars->m_struct_size = cursor; @@ -245,7 +256,7 @@ if (!m_struct_vars->m_struct_laid_out) return false; - num_elements = m_struct_members.Size(); + num_elements = m_struct_members.GetSize(); size = m_struct_vars->m_struct_size; alignment = m_struct_vars->m_struct_alignment; @@ -267,19 +278,20 @@ if (!m_struct_vars->m_struct_laid_out) return false; - if (index >= m_struct_members.Size()) + if (index >= m_struct_members.GetSize()) return false; - ClangExpressionVariable &member(m_struct_members.VariableAtIndex(index)); + ClangExpressionVariableSP member_sp(m_struct_members.GetVariableAtIndex(index)); - if (!member.m_parser_vars.get() || - !member.m_jit_vars.get()) + if (!member_sp || + !member_sp->m_parser_vars.get() || + !member_sp->m_jit_vars.get()) return false; - decl = member.m_parser_vars->m_named_decl; - value = member.m_parser_vars->m_llvm_value; - offset = member.m_jit_vars->m_offset; - name = member.m_name; + decl = member_sp->m_parser_vars->m_named_decl; + value = member_sp->m_parser_vars->m_llvm_value; + offset = member_sp->m_jit_vars->m_offset; + name = member_sp->GetName(); return true; } @@ -292,16 +304,16 @@ uint64_t &ptr ) { - ClangExpressionVariable *entity = m_found_entities.GetVariable(decl); + ClangExpressionVariableSP entity_sp(m_found_entities.GetVariable(decl)); - if (!entity) + if (!entity_sp) return false; // We know m_parser_vars is valid since we searched for the variable by // its NamedDecl - value = &entity->m_parser_vars->m_llvm_value; - ptr = entity->m_parser_vars->m_lldb_value->GetScalar().ULongLong(); + value = &entity_sp->m_parser_vars->m_llvm_value; + ptr = entity_sp->m_parser_vars->m_lldb_value->GetScalar().ULongLong(); return true; } @@ -453,11 +465,11 @@ ClangExpressionDeclMap::Dematerialize ( ExecutionContext &exe_ctx, - ClangExpressionVariable *&result, + ClangExpressionVariableSP &result_sp, Error &err ) { - return DoMaterialize(true, exe_ctx, &result, err); + return DoMaterialize(true, exe_ctx, &result_sp, err); DidDematerialize(); } @@ -527,26 +539,29 @@ DataExtractor extractor(data, exe_ctx.process->GetByteOrder(), exe_ctx.target->GetArchitecture().GetAddressByteSize()); - for (uint64_t member_index = 0, num_members = m_struct_members.Size(); - member_index < num_members; - ++member_index) + for (size_t member_idx = 0, num_members = m_struct_members.GetSize(); + member_idx < num_members; + ++member_idx) { - ClangExpressionVariable &member (m_struct_members.VariableAtIndex(member_index)); + ClangExpressionVariableSP member_sp(m_struct_members.GetVariableAtIndex(member_idx)); - s.Printf("[%s]\n", member.m_name.GetCString()); + if (!member_sp) + return false; + + s.Printf("[%s]\n", member_sp->GetName().GetCString()); - if (!member.m_jit_vars.get()) + if (!member_sp->m_jit_vars.get()) return false; - extractor.Dump(&s, // stream - member.m_jit_vars->m_offset, // offset - lldb::eFormatBytesWithASCII, // format - 1, // byte size of individual entries - member.m_jit_vars->m_size, // number of entries - 16, // entries per line - m_material_vars->m_materialized_location + member.m_jit_vars->m_offset, // address to print - 0, // bit size (bitfields only; 0 means ignore) - 0); // bit alignment (bitfields only; 0 means ignore) + extractor.Dump (&s, // stream + member_sp->m_jit_vars->m_offset, // offset + lldb::eFormatBytesWithASCII, // format + 1, // byte size of individual entries + member_sp->m_jit_vars->m_size, // number of entries + 16, // entries per line + m_material_vars->m_materialized_location + member_sp->m_jit_vars->m_offset, // address to print + 0, // bit size (bitfields only; 0 means ignore) + 0); // bit alignment (bitfields only; 0 means ignore) s.PutChar('\n'); } @@ -559,10 +574,13 @@ ( bool dematerialize, ExecutionContext &exe_ctx, - ClangExpressionVariable **result, + lldb::ClangExpressionVariableSP *result_sp_ptr, Error &err ) { + if (result_sp_ptr) + result_sp_ptr->reset(); + assert (m_struct_vars.get()); lldb::LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS)); @@ -579,7 +597,7 @@ return LLDB_INVALID_ADDRESS; } - ClangPersistentVariables &persistent_vars = exe_ctx.process->GetPersistentVariables(); + ClangPersistentVariables &persistent_vars = exe_ctx.target->GetPersistentVariables(); if (!m_struct_vars->m_struct_size) { @@ -619,26 +637,20 @@ if (m_material_vars->m_materialized_location % m_struct_vars->m_struct_alignment) m_material_vars->m_materialized_location += (m_struct_vars->m_struct_alignment - (m_material_vars->m_materialized_location % m_struct_vars->m_struct_alignment)); - for (uint64_t member_index = 0, num_members = m_struct_members.Size(); + for (uint64_t member_index = 0, num_members = m_struct_members.GetSize(); member_index < num_members; ++member_index) { - ClangExpressionVariable &member (m_struct_members.VariableAtIndex(member_index)); - - ClangExpressionVariable *entity = NULL; + ClangExpressionVariableSP member_sp(m_struct_members.GetVariableAtIndex(member_index)); - /* - if (member.m_parser_vars.get()) - entity = m_found_entities.GetVariable(member.m_parser_vars->m_named_decl); - */ - - entity = m_found_entities.GetVariable(member.m_name); + ClangExpressionVariableSP entity_sp (m_found_entities.GetVariable(member_sp->GetName())); - ClangExpressionVariable *persistent_variable = persistent_vars.GetVariable(member.m_name); + ClangExpressionVariableSP persistent_var_sp (persistent_vars.GetVariable(member_sp->GetName())); - if (entity) + if (entity_sp) { - if (entity->m_register_info) + RegisterInfo *reg_info = entity_sp->GetRegisterInfo (); + if (reg_info) { // This is a register variable @@ -647,21 +659,32 @@ if (!reg_ctx) return false; - if (!DoMaterializeOneRegister(dematerialize, exe_ctx, *reg_ctx, *entity->m_register_info, m_material_vars->m_materialized_location + member.m_jit_vars->m_offset, err)) + if (!DoMaterializeOneRegister (dematerialize, + exe_ctx, + *reg_ctx, + *reg_info, + m_material_vars->m_materialized_location + member_sp->m_jit_vars->m_offset, + err)) return false; } else { - if (!member.m_jit_vars.get()) + if (!member_sp->m_jit_vars.get()) return false; - if (!DoMaterializeOneVariable(dematerialize, exe_ctx, sym_ctx, member.m_name, member.m_user_type, m_material_vars->m_materialized_location + member.m_jit_vars->m_offset, err)) + if (!DoMaterializeOneVariable (dematerialize, + exe_ctx, + sym_ctx, + member_sp->GetName(), + member_sp->GetTypeFromUser(), + m_material_vars->m_materialized_location + member_sp->m_jit_vars->m_offset, + err)) return false; } } - else if (persistent_variable) + else if (persistent_var_sp) { - if (member.m_name == m_struct_vars->m_result_name) + if (member_sp->GetName() == m_struct_vars->m_result_name) { if (!dematerialize) continue; @@ -669,18 +692,23 @@ if (log) log->PutCString("Found result member in the struct"); - *result = &member; + if (result_sp_ptr) + *result_sp_ptr = member_sp; } if (log) - log->Printf("Searched for persistent variable %s and found %s", member.m_name.GetCString(), persistent_variable->m_name.GetCString()); + log->Printf("Searched for persistent variable %s and found %s", member_sp->GetName().GetCString(), persistent_var_sp->GetName().GetCString()); - if (!DoMaterializeOnePersistentVariable(dematerialize, exe_ctx, persistent_variable->m_name, m_material_vars->m_materialized_location + member.m_jit_vars->m_offset, err)) + if (!DoMaterializeOnePersistentVariable (dematerialize, + exe_ctx, + persistent_var_sp, + m_material_vars->m_materialized_location + member_sp->m_jit_vars->m_offset, + err)) return false; } else { - err.SetErrorStringWithFormat("Unexpected variable %s", member.m_name.GetCString()); + err.SetErrorStringWithFormat("Unexpected variable %s", member_sp->GetName().GetCString()); return false; } } @@ -693,32 +721,29 @@ ( bool dematerialize, ExecutionContext &exe_ctx, - const ConstString &name, + ClangExpressionVariableSP &var_sp, lldb::addr_t addr, Error &err ) { - ClangPersistentVariables &persistent_vars = exe_ctx.process->GetPersistentVariables(); - - ClangExpressionVariable *pvar(persistent_vars.GetVariable(name)); - - if (!pvar) + if (!var_sp) { - err.SetErrorStringWithFormat("Undefined persistent variable %s", name.GetCString()); + err.SetErrorString("Invalid persistent variable"); return LLDB_INVALID_ADDRESS; } - size_t pvar_size = pvar->Size(); + const size_t pvar_byte_size = var_sp->GetByteSize(); - if (!pvar->m_data_sp.get()) + uint8_t *pvar_data = var_sp->GetValueBytes(); + if (pvar_data == NULL) return false; - uint8_t *pvar_data = pvar->m_data_sp->GetBytes(); Error error; if (dematerialize) { - if (exe_ctx.process->ReadMemory (addr, pvar_data, pvar_size, error) != pvar_size) + var_sp->ValueUpdated (); + if (exe_ctx.process->ReadMemory (addr, pvar_data, pvar_byte_size, error) != pvar_byte_size) { err.SetErrorStringWithFormat ("Couldn't read a composite type from the target: %s", error.AsCString()); return false; @@ -726,7 +751,7 @@ } else { - if (exe_ctx.process->WriteMemory (addr, pvar_data, pvar_size, error) != pvar_size) + if (exe_ctx.process->WriteMemory (addr, pvar_data, pvar_byte_size, error) != pvar_byte_size) { err.SetErrorStringWithFormat ("Couldn't write a composite type to the target: %s", error.AsCString()); return false; @@ -1201,11 +1226,7 @@ { 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(); - } } } } @@ -1312,12 +1333,12 @@ return; } - - ClangExpressionVariable *pvar(m_parser_vars->m_persistent_vars->GetVariable(name)); + + ClangExpressionVariableSP pvar_sp(m_parser_vars->m_persistent_vars->GetVariable(name)); - if (pvar) + if (pvar_sp) { - AddOneVariable(context, pvar); + AddOneVariable(context, pvar_sp); return; } @@ -1493,17 +1514,18 @@ return; NamedDecl *var_decl = context.AddVarDecl(pt.GetOpaqueQualType()); - - ClangExpressionVariable &entity(m_found_entities.VariableAtIndex(m_found_entities.CreateVariable())); std::string decl_name(context.m_decl_name.getAsString()); - entity.m_name.SetCString (decl_name.c_str()); - entity.m_user_type = ut; - - entity.EnableParserVars(); - entity.m_parser_vars->m_parser_type = pt; - entity.m_parser_vars->m_named_decl = var_decl; - entity.m_parser_vars->m_llvm_value = NULL; - entity.m_parser_vars->m_lldb_value = var_location; + ConstString entity_name(decl_name.c_str()); + ClangExpressionVariableSP entity(m_found_entities.CreateVariable (entity_name, + ut, + m_parser_vars->m_exe_ctx->process->GetByteOrder(), + m_parser_vars->m_exe_ctx->process->GetAddressByteSize())); + assert (entity.get()); + entity->EnableParserVars(); + entity->m_parser_vars->m_parser_type = pt; + entity->m_parser_vars->m_named_decl = var_decl; + entity->m_parser_vars->m_llvm_value = NULL; + entity->m_parser_vars->m_lldb_value = var_location; if (log) { @@ -1518,24 +1540,24 @@ void ClangExpressionDeclMap::AddOneVariable(NameSearchContext &context, - ClangExpressionVariable *pvar) + ClangExpressionVariableSP &pvar_sp) { lldb::LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS)); - TypeFromUser user_type = pvar->m_user_type; + TypeFromUser user_type (pvar_sp->GetTypeFromUser()); - TypeFromParser parser_type(GuardedCopyType(context.GetASTContext(), - user_type.GetASTContext(), - user_type.GetOpaqueQualType()), - context.GetASTContext()); + TypeFromParser parser_type (GuardedCopyType(context.GetASTContext(), + user_type.GetASTContext(), + user_type.GetOpaqueQualType()), + context.GetASTContext()); NamedDecl *var_decl = context.AddVarDecl(parser_type.GetOpaqueQualType()); - pvar->EnableParserVars(); - pvar->m_parser_vars->m_parser_type = parser_type; - pvar->m_parser_vars->m_named_decl = var_decl; - pvar->m_parser_vars->m_llvm_value = NULL; - pvar->m_parser_vars->m_lldb_value = NULL; + pvar_sp->EnableParserVars(); + pvar_sp->m_parser_vars->m_parser_type = parser_type; + pvar_sp->m_parser_vars->m_named_decl = var_decl; + pvar_sp->m_parser_vars->m_llvm_value = NULL; + pvar_sp->m_parser_vars->m_lldb_value = NULL; if (log) { @@ -1544,13 +1566,13 @@ var_decl->print(var_decl_print_stream); var_decl_print_stream.flush(); - log->Printf("Added pvar %s, returned %s", pvar->m_name.GetCString(), var_decl_print_string.c_str()); + log->Printf("Added pvar %s, returned %s", pvar_sp->GetName().GetCString(), var_decl_print_string.c_str()); } } void -ClangExpressionDeclMap::AddOneRegister(NameSearchContext &context, - const RegisterInfo *reg_info) +ClangExpressionDeclMap::AddOneRegister (NameSearchContext &context, + const RegisterInfo *reg_info) { lldb::LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS)); @@ -1564,21 +1586,22 @@ return; } - TypeFromParser parser_type(ast_type, - context.GetASTContext()); + TypeFromParser parser_type (ast_type, + context.GetASTContext()); NamedDecl *var_decl = context.AddVarDecl(parser_type.GetOpaqueQualType()); - ClangExpressionVariable &entity(m_found_entities.VariableAtIndex(m_found_entities.CreateVariable())); + ClangExpressionVariableSP entity(m_found_entities.CreateVariable (m_parser_vars->m_exe_ctx->process->GetByteOrder(), + m_parser_vars->m_exe_ctx->process->GetAddressByteSize())); + assert (entity.get()); std::string decl_name(context.m_decl_name.getAsString()); - entity.m_name.SetCString (decl_name.c_str()); - entity.m_register_info = reg_info; - - entity.EnableParserVars(); - entity.m_parser_vars->m_parser_type = parser_type; - entity.m_parser_vars->m_named_decl = var_decl; - entity.m_parser_vars->m_llvm_value = NULL; - entity.m_parser_vars->m_lldb_value = NULL; + entity->SetName (ConstString (decl_name.c_str())); + entity->SetRegisterInfo (reg_info); + entity->EnableParserVars(); + entity->m_parser_vars->m_parser_type = parser_type; + entity->m_parser_vars->m_named_decl = var_decl; + entity->m_parser_vars->m_llvm_value = NULL; + entity->m_parser_vars->m_lldb_value = NULL; if (log) { @@ -1666,15 +1689,18 @@ fun_location->SetValueType(Value::eValueTypeLoadAddress); fun_location->GetScalar() = load_addr; - ClangExpressionVariable &entity(m_found_entities.VariableAtIndex(m_found_entities.CreateVariable())); + ClangExpressionVariableSP entity(m_found_entities.CreateVariable (m_parser_vars->m_exe_ctx->process->GetByteOrder(), + m_parser_vars->m_exe_ctx->process->GetAddressByteSize())); + assert (entity.get()); std::string decl_name(context.m_decl_name.getAsString()); - entity.m_name.SetCString(decl_name.c_str()); - entity.m_user_type = TypeFromUser(fun_opaque_type, fun_ast_context);; - - entity.EnableParserVars(); - entity.m_parser_vars->m_named_decl = fun_decl; - entity.m_parser_vars->m_llvm_value = NULL; - entity.m_parser_vars->m_lldb_value = fun_location.release(); + entity->SetName(ConstString(decl_name.c_str())); + entity->SetClangType (fun_opaque_type); + entity->SetClangAST (fun_ast_context); + + entity->EnableParserVars(); + entity->m_parser_vars->m_named_decl = fun_decl; + entity->m_parser_vars->m_llvm_value = NULL; + entity->m_parser_vars->m_lldb_value = fun_location.release(); if (log) { Modified: lldb/trunk/source/Expression/ClangExpressionParser.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/ClangExpressionParser.cpp?rev=121745&r1=121744&r2=121745&view=diff ============================================================================== --- lldb/trunk/source/Expression/ClangExpressionParser.cpp (original) +++ lldb/trunk/source/Expression/ClangExpressionParser.cpp Mon Dec 13 20:59:59 2010 @@ -367,7 +367,7 @@ return err; } - ClangExpressionVariableStore *local_variables = m_expr.LocalVariables(); + ClangExpressionVariableList *local_variables = m_expr.LocalVariables(); ClangExpressionDeclMap *decl_map = m_expr.DeclMap(); if (!local_variables) Modified: lldb/trunk/source/Expression/ClangExpressionVariable.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/ClangExpressionVariable.cpp?rev=121745&r1=121744&r2=121745&view=diff ============================================================================== --- lldb/trunk/source/Expression/ClangExpressionVariable.cpp (original) +++ lldb/trunk/source/Expression/ClangExpressionVariable.cpp Mon Dec 13 20:59:59 2010 @@ -25,116 +25,109 @@ using namespace lldb_private; using namespace clang; -ClangExpressionVariable::ClangExpressionVariable() : - m_name(), - m_user_type (TypeFromUser(NULL, NULL)), - m_store (NULL), - m_register_info (NULL), - m_index (0), +ClangExpressionVariable::ClangExpressionVariable(lldb::ByteOrder byte_order, uint32_t addr_byte_size) : m_parser_vars(), m_jit_vars (), - m_data_sp () + m_valojb_sp (new ValueObjectConstResult(byte_order, addr_byte_size)) { } -void -ClangExpressionVariable::DisableDataVars() +ClangExpressionVariable::ClangExpressionVariable (const lldb::ValueObjectSP &valobj_sp) : + m_parser_vars(), + m_jit_vars (), + m_valojb_sp (valobj_sp) { - m_data_sp.reset(); } +//---------------------------------------------------------------------- +/// Return the variable's size in bytes +//---------------------------------------------------------------------- +size_t +ClangExpressionVariable::GetByteSize () +{ + return m_valojb_sp->GetByteSize(); +} -ClangExpressionVariable::ClangExpressionVariable(const ClangExpressionVariable &rhs) : - m_name(rhs.m_name), - m_user_type(rhs.m_user_type), - m_store(rhs.m_store), - m_register_info(rhs.m_register_info), - m_index(rhs.m_index) +const ConstString & +ClangExpressionVariable::GetName () { - if (rhs.m_parser_vars.get()) - { - // TODO: Sean, can m_parser_vars be a shared pointer??? We are copy - // constructing it here. That is ok if we need to, but do we really - // need to? - m_parser_vars.reset(new struct ParserVars); - *m_parser_vars.get() = *rhs.m_parser_vars.get(); - } - - if (rhs.m_jit_vars.get()) - { - // TODO: Sean, can m_jit_vars be a shared pointer??? We are copy - // constructing it here. That is ok if we need to, but do we really - // need to? - m_jit_vars.reset(new struct JITVars); - *m_jit_vars.get() = *rhs.m_jit_vars.get(); - } - - if (rhs.m_data_sp) - { - // TODO: Sean, does m_data_sp need to be copy constructed? Or can it - // shared the data? - - m_data_sp.reset(new DataBufferHeap (rhs.m_data_sp->GetBytes(), - rhs.m_data_sp->GetByteSize())); - } + return m_valojb_sp->GetName(); +} + +lldb::ValueObjectSP +ClangExpressionVariable::GetValueObject() +{ + return m_valojb_sp; } -bool -ClangExpressionVariable::PointValueAtData(Value &value, ExecutionContext *exe_ctx) +lldb::RegisterInfo * +ClangExpressionVariable::GetRegisterInfo() { - if (m_data_sp.get() == NULL) - return false; - - 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(); - - if (exe_ctx) - value.ResolveValue (exe_ctx, ast_context); - - return true; + return m_valojb_sp->GetValue().GetRegisterInfo(); } -void -ClangExpressionVariable::EnableDataVars() +void +ClangExpressionVariable::SetRegisterInfo (const lldb::RegisterInfo *reg_info) { - if (!m_data_sp.get()) - m_data_sp.reset(new DataBufferHeap); + return m_valojb_sp->GetValue().SetContext (Value::eContextTypeRegisterInfo, const_cast(reg_info)); } -lldb::ValueObjectSP -ClangExpressionVariable::GetExpressionResult (ExecutionContext *exe_ctx) +lldb::clang_type_t +ClangExpressionVariable::GetClangType() +{ + return m_valojb_sp->GetClangType(); +} + +void +ClangExpressionVariable::SetClangType(lldb::clang_type_t clang_type) +{ + m_valojb_sp->GetValue().SetContext(Value::eContextTypeClangType, clang_type); +} + +clang::ASTContext * +ClangExpressionVariable::GetClangAST() +{ + return m_valojb_sp->GetClangAST(); +} + +void +ClangExpressionVariable::SetClangAST (clang::ASTContext *ast) +{ + m_valojb_sp->SetClangAST (ast); +} + +TypeFromUser +ClangExpressionVariable::GetTypeFromUser() +{ + TypeFromUser tfu (m_valojb_sp->GetClangType(), m_valojb_sp->GetClangAST()); + return tfu; +} + +uint8_t * +ClangExpressionVariable::GetValueBytes() { - lldb::ValueObjectSP result_sp; - if (m_data_sp) + const size_t byte_size = m_valojb_sp->GetByteSize(); + if (byte_size > 0) { - Target * target = NULL; - Process *process = NULL; - if (exe_ctx) + if (m_valojb_sp->GetDataExtractor().GetByteSize() < byte_size) { - target = exe_ctx->target; - process = exe_ctx->process; - } - - Value value; - if (PointValueAtData(value, exe_ctx)) - { - lldb::ByteOrder byte_order = lldb::eByteOrderHost; - uint32_t addr_byte_size = 4; - if (process) - { - byte_order = process->GetByteOrder(); - addr_byte_size = process->GetAddressByteSize(); - } - result_sp.reset (new ValueObjectConstResult (m_user_type.GetASTContext(), - m_user_type.GetOpaqueQualType(), - m_name, - m_data_sp,// TODO: sean can you get this to be valid? - byte_order, - addr_byte_size)); + m_valojb_sp->GetValue().ResizeData(byte_size); + m_valojb_sp->GetValue().GetData (m_valojb_sp->GetDataExtractor()); } + return const_cast(m_valojb_sp->GetDataExtractor().GetDataStart()); } - return result_sp; + return NULL; +} + +void +ClangExpressionVariable::SetName (const ConstString &name) +{ + m_valojb_sp->SetName (name); +} + +void +ClangExpressionVariable::ValueUpdated () +{ + m_valojb_sp->ValueUpdated (); } Modified: lldb/trunk/source/Expression/ClangFunction.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/ClangFunction.cpp?rev=121745&r1=121744&r2=121745&view=diff ============================================================================== --- lldb/trunk/source/Expression/ClangFunction.cpp (original) +++ lldb/trunk/source/Expression/ClangFunction.cpp Mon Dec 13 20:59:59 2010 @@ -275,7 +275,7 @@ Error error; using namespace clang; - Process::ExecutionResults return_value = Process::eExecutionSetupError; + lldb::ExecutionResults return_value = lldb::eExecutionSetupError; Process *process = exe_ctx.process; @@ -441,13 +441,13 @@ exe_ctx.process->DeallocateMemory(args_addr); } -Process::ExecutionResults +lldb::ExecutionResults ClangFunction::ExecuteFunction(ExecutionContext &exe_ctx, Stream &errors, Value &results) { return ExecuteFunction (exe_ctx, errors, 1000, true, results); } -Process::ExecutionResults +lldb::ExecutionResults ClangFunction::ExecuteFunction(ExecutionContext &exe_ctx, Stream &errors, bool stop_others, Value &results) { const bool try_all_threads = false; @@ -455,7 +455,7 @@ return ExecuteFunction (exe_ctx, NULL, errors, stop_others, NULL, try_all_threads, discard_on_error, results); } -Process::ExecutionResults +lldb::ExecutionResults ClangFunction::ExecuteFunction( ExecutionContext &exe_ctx, Stream &errors, @@ -470,7 +470,7 @@ } // This is the static function -Process::ExecutionResults +lldb::ExecutionResults ClangFunction::ExecuteFunction ( ExecutionContext &exe_ctx, lldb::addr_t function_address, @@ -486,7 +486,7 @@ errors, stop_others, discard_on_error, this_arg)); if (call_plan_sp == NULL) - return Process::eExecutionSetupError; + return lldb::eExecutionSetupError; call_plan_sp->SetPrivate(true); @@ -494,7 +494,7 @@ single_thread_timeout_usec, errors); } -Process::ExecutionResults +lldb::ExecutionResults ClangFunction::ExecuteFunction( ExecutionContext &exe_ctx, lldb::addr_t *args_addr_ptr, @@ -506,7 +506,7 @@ Value &results) { using namespace clang; - Process::ExecutionResults return_value = Process::eExecutionSetupError; + lldb::ExecutionResults return_value = lldb::eExecutionSetupError; lldb::addr_t args_addr; @@ -516,12 +516,12 @@ args_addr = LLDB_INVALID_ADDRESS; if (CompileFunction(errors) != 0) - return Process::eExecutionSetupError; + return lldb::eExecutionSetupError; if (args_addr == LLDB_INVALID_ADDRESS) { if (!InsertFunction(exe_ctx, args_addr, errors)) - return Process::eExecutionSetupError; + return lldb::eExecutionSetupError; } return_value = ClangFunction::ExecuteFunction(exe_ctx, m_wrapper_function_addr, args_addr, stop_others, @@ -530,7 +530,7 @@ if (args_addr_ptr != NULL) *args_addr_ptr = args_addr; - if (return_value != Process::eExecutionCompleted) + if (return_value != lldb::eExecutionCompleted) return return_value; FetchFunctionResults(exe_ctx, args_addr, results); @@ -538,7 +538,7 @@ if (args_addr_ptr == NULL) DeallocateFunctionResults(exe_ctx, args_addr); - return Process::eExecutionCompleted; + return lldb::eExecutionCompleted; } clang::ASTConsumer * Modified: lldb/trunk/source/Expression/ClangPersistentVariables.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/ClangPersistentVariables.cpp?rev=121745&r1=121744&r2=121745&view=diff ============================================================================== --- lldb/trunk/source/Expression/ClangPersistentVariables.cpp (original) +++ lldb/trunk/source/Expression/ClangPersistentVariables.cpp Mon Dec 13 20:59:59 2010 @@ -13,38 +13,39 @@ #include "lldb/Core/StreamString.h" #include "lldb/Core/Value.h" +using namespace lldb; using namespace lldb_private; ClangPersistentVariables::ClangPersistentVariables () : - ClangExpressionVariableStore() + ClangExpressionVariableList(), + m_next_persistent_variable_id (0) { - m_result_counter = 0; } -void -ClangPersistentVariables::GetNextResultName (ConstString &name) +ClangExpressionVariableSP +ClangPersistentVariables::CreatePersistentVariable (const lldb::ValueObjectSP &valobj_sp) { - char result_name[256]; - ::snprintf (result_name, sizeof(result_name), "$%llu", m_result_counter++); - name.SetCString(result_name); + ClangExpressionVariableSP var_sp (CreateVariable(valobj_sp)); + return var_sp; } -bool -ClangPersistentVariables::CreatePersistentVariable (const ConstString &name, - TypeFromUser user_type) +ClangExpressionVariableSP +ClangPersistentVariables::CreatePersistentVariable (const ConstString &name, const TypeFromUser& user_type, lldb::ByteOrder byte_order, uint32_t addr_byte_size) { - if (GetVariable(name)) - return false; + ClangExpressionVariableSP var_sp (GetVariable(name)); + + if (!var_sp) + var_sp = CreateVariable(name, user_type, byte_order, addr_byte_size); - ClangExpressionVariable &pvar (VariableAtIndex(CreateVariable())); + return var_sp; +} - pvar.m_name = name; - pvar.m_user_type = user_type; - // TODO: Sean, why do we need to call this?, we can just make it below - // and we aren't checking the result or anything... Is this cruft left - // over from an old code re-org? - //pvar.EnableDataVars(); - pvar.m_data_sp.reset(new DataBufferHeap(pvar.Size(), 0)); - - return true; -} \ No newline at end of file + +ConstString +ClangPersistentVariables::GetNextPersistentVariableName () +{ + char name_cstr[256]; + ::snprintf (name_cstr, sizeof(name_cstr), "$%u", m_next_persistent_variable_id++); + ConstString name(name_cstr); + return name; +} Modified: lldb/trunk/source/Expression/ClangUserExpression.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/ClangUserExpression.cpp?rev=121745&r1=121744&r2=121745&view=diff ============================================================================== --- lldb/trunk/source/Expression/ClangUserExpression.cpp (original) +++ lldb/trunk/source/Expression/ClangUserExpression.cpp Mon Dec 13 20:59:59 2010 @@ -271,7 +271,7 @@ m_dwarf_opcodes->SetByteOrder (lldb::eByteOrderHost); m_dwarf_opcodes->GetFlags ().Set (Stream::eBinary); - m_local_variables.reset(new ClangExpressionVariableStore()); + m_local_variables.reset(new ClangExpressionVariableList()); Error dwarf_error = parser.MakeDWARF (); @@ -422,7 +422,7 @@ bool ClangUserExpression::FinalizeJITExecution (Stream &error_stream, ExecutionContext &exe_ctx, - ClangExpressionVariable *&result) + lldb::ClangExpressionVariableSP &result) { Error expr_error; @@ -454,12 +454,12 @@ return true; } -Process::ExecutionResults +lldb::ExecutionResults ClangUserExpression::Execute (Stream &error_stream, ExecutionContext &exe_ctx, bool discard_on_error, ClangUserExpression::ClangUserExpressionSP &shared_ptr_to_me, - ClangExpressionVariable *&result) + lldb::ClangExpressionVariableSP &result) { lldb::LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS)); @@ -469,7 +469,7 @@ error_stream.Printf("We don't currently support executing DWARF expressions"); - return Process::eExecutionSetupError; + return lldb::eExecutionSetupError; } else if (m_jit_addr != LLDB_INVALID_ADDRESS) { @@ -479,7 +479,7 @@ lldb::addr_t cmd_ptr = NULL; if (!PrepareToExecuteJITExpression (error_stream, exe_ctx, struct_address, object_ptr, cmd_ptr)) - return Process::eExecutionSetupError; + return lldb::eExecutionSetupError; const bool stop_others = true; const bool try_all_threads = true; @@ -495,7 +495,7 @@ shared_ptr_to_me)); if (call_plan_sp == NULL || !call_plan_sp->ValidatePlan (NULL)) - return Process::eExecutionSetupError; + return lldb::eExecutionSetupError; call_plan_sp->SetPrivate(true); @@ -504,14 +504,18 @@ if (log) log->Printf("-- [ClangUserExpression::Execute] Execution of expression begins --"); - Process::ExecutionResults execution_result = - exe_ctx.process->RunThreadPlan (exe_ctx, call_plan_sp, stop_others, try_all_threads, discard_on_error, - single_thread_timeout_usec, error_stream); + lldb::ExecutionResults execution_result = exe_ctx.process->RunThreadPlan (exe_ctx, + call_plan_sp, + stop_others, + try_all_threads, + discard_on_error, + single_thread_timeout_usec, + error_stream); if (log) log->Printf("-- [ClangUserExpression::Execute] Execution of expression completed --"); - if (execution_result == Process::eExecutionInterrupted) + if (execution_result == lldb::eExecutionInterrupted) { if (discard_on_error) error_stream.Printf ("Expression execution was interrupted. The process has been returned to the state before execution."); @@ -520,21 +524,21 @@ return execution_result; } - else if (execution_result != Process::eExecutionCompleted) + else if (execution_result != lldb::eExecutionCompleted) { error_stream.Printf ("Couldn't execute function; result was %s\n", Process::ExecutionResultAsCString (execution_result)); return execution_result; } if (FinalizeJITExecution (error_stream, exe_ctx, result)) - return Process::eExecutionCompleted; + return lldb::eExecutionCompleted; else - return Process::eExecutionSetupError; + return lldb::eExecutionSetupError; } else { error_stream.Printf("Expression can't be run; neither DWARF nor a JIT compiled function is present"); - return Process::eExecutionSetupError; + return lldb::eExecutionSetupError; } } @@ -547,7 +551,7 @@ return *m_dwarf_opcodes.get(); } -Process::ExecutionResults +lldb::ExecutionResults ClangUserExpression::Evaluate (ExecutionContext &exe_ctx, bool discard_on_error, const char *expr_cstr, @@ -557,14 +561,14 @@ lldb::LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS)); Error error; - Process::ExecutionResults execution_results = Process::eExecutionSetupError; + lldb::ExecutionResults execution_results = lldb::eExecutionSetupError; if (exe_ctx.process == NULL) { error.SetErrorString ("Must have a process to evaluate expressions."); result_valobj_sp.reset (new ValueObjectConstResult (error)); - return Process::eExecutionSetupError; + return lldb::eExecutionSetupError; } if (!exe_ctx.process->GetDynamicCheckers()) @@ -584,7 +588,7 @@ error.SetErrorString (install_errors.GetString().c_str()); result_valobj_sp.reset (new ValueObjectConstResult (error)); - return Process::eExecutionSetupError; + return lldb::eExecutionSetupError; } exe_ctx.process->SetDynamicCheckers(dynamic_checkers); @@ -609,7 +613,7 @@ } else { - ClangExpressionVariable *expr_result = NULL; + lldb::ClangExpressionVariableSP expr_result; error_stream.GetString().clear(); @@ -621,7 +625,7 @@ discard_on_error, user_expression_sp, expr_result); - if (execution_results != Process::eExecutionCompleted) + if (execution_results != lldb::eExecutionCompleted) { if (log) log->Printf("== [ClangUserExpression::Evaluate] Execution completed abnormally =="); @@ -633,14 +637,9 @@ } else { - // TODO: seems weird to get a pointer to a result object back from - // a function. Do we own it? Feels like we do, but from looking at the - // code we don't. Might be best to make this a reference and state - // explicitly that we don't own it when we get a reference back from - // the execute? if (expr_result) { - result_valobj_sp = expr_result->GetExpressionResult (&exe_ctx); + result_valobj_sp = expr_result->GetValueObject(); if (log) log->Printf("== [ClangUserExpression::Evaluate] Execution completed normally with result %s ==", result_valobj_sp->GetValueAsCString(exe_ctx.GetBestExecutionContextScope())); Modified: lldb/trunk/source/Expression/IRToDWARF.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/IRToDWARF.cpp?rev=121745&r1=121744&r2=121745&view=diff ============================================================================== --- lldb/trunk/source/Expression/IRToDWARF.cpp (original) +++ lldb/trunk/source/Expression/IRToDWARF.cpp Mon Dec 13 20:59:59 2010 @@ -26,7 +26,7 @@ static char ID; -IRToDWARF::IRToDWARF(lldb_private::ClangExpressionVariableStore &local_vars, +IRToDWARF::IRToDWARF(lldb_private::ClangExpressionVariableList &local_vars, lldb_private::ClangExpressionDeclMap *decl_map, lldb_private::StreamString &strm, const char *func_name) : Modified: lldb/trunk/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.cpp?rev=121745&r1=121744&r2=121745&view=diff ============================================================================== --- lldb/trunk/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.cpp (original) +++ lldb/trunk/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.cpp Mon Dec 13 20:59:59 2010 @@ -642,9 +642,6 @@ } } - if (log) - log->PutCString("Unloaded:"); - for (old_idx = 0; old_idx < old_dyld_all_image_infos.size(); ++old_idx) { if (old_dyld_all_image_infos[old_idx].address != LLDB_INVALID_ADDRESS) @@ -662,7 +659,14 @@ } if (unloaded_module_list.GetSize() > 0) + { + if (log) + { + log->PutCString("Unloaded:"); + unloaded_module_list.LogUUIDAndPaths (log, "DynamicLoaderMacOSXDYLD::ModulesDidUnload"); + } m_process->GetTarget().ModulesDidUnload (unloaded_module_list); + } } else { @@ -752,6 +756,8 @@ } } } + if (log) + loaded_module_list.LogUUIDAndPaths (log, "DynamicLoaderMacOSXDYLD::ModulesDidLoad"); m_process->GetTarget().ModulesDidLoad (loaded_module_list); } } 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=121745&r1=121744&r2=121745&view=diff ============================================================================== --- lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.cpp (original) +++ lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.cpp Mon Dec 13 20:59:59 2010 @@ -122,9 +122,15 @@ bool try_all_threads = true; bool stop_others = true; - Process::ExecutionResults results - = func.ExecuteFunction(exe_ctx, &wrapper_struct_addr, error_stream, stop_others, 1000000, try_all_threads, unwind_on_error, ret); - if (results != Process::eExecutionCompleted) + ExecutionResults results = func.ExecuteFunction (exe_ctx, + &wrapper_struct_addr, + error_stream, + stop_others, + 1000000, + try_all_threads, + unwind_on_error, + ret); + if (results != lldb::eExecutionCompleted) { str.Printf("Error evaluating Print Object function: %d.\n", results); return false; Modified: lldb/trunk/source/Symbol/ClangASTContext.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/ClangASTContext.cpp?rev=121745&r1=121744&r2=121745&view=diff ============================================================================== --- lldb/trunk/source/Symbol/ClangASTContext.cpp (original) +++ lldb/trunk/source/Symbol/ClangASTContext.cpp Mon Dec 13 20:59:59 2010 @@ -870,16 +870,17 @@ return false; #define OPERATOR_PREFIX "operator" +#define OPERATOR_PREFIX_LENGTH (sizeof (OPERATOR_PREFIX) - 1) const char *post_op_name = NULL; bool no_space = true; - if (!::strncmp(name, OPERATOR_PREFIX, sizeof(OPERATOR_PREFIX) - 1)) - post_op_name = name + sizeof(OPERATOR_PREFIX) - 1; - else + if (::strncmp(name, OPERATOR_PREFIX, OPERATOR_PREFIX_LENGTH)) return false; + post_op_name = name + OPERATOR_PREFIX_LENGTH; + if (post_op_name[0] == ' ') { post_op_name++; @@ -887,6 +888,7 @@ } #undef OPERATOR_PREFIX +#undef OPERATOR_PREFIX_LENGTH // This is an operator, set the overloaded operator kind to invalid // in case this is a conversion operator... @@ -3488,7 +3490,13 @@ clang_type_t ClangASTContext::CreatePointerType (clang_type_t clang_type) { - if (clang_type) + return CreatePointerType (getASTContext(), clang_type); +} + +clang_type_t +ClangASTContext::CreatePointerType (clang::ASTContext *ast, clang_type_t clang_type) +{ + if (ast && clang_type) { QualType qual_type (QualType::getFromOpaquePtr(clang_type)); @@ -3497,10 +3505,10 @@ { case clang::Type::ObjCObject: case clang::Type::ObjCInterface: - return getASTContext()->getObjCObjectPointerType(qual_type).getAsOpaquePtr(); + return ast->getObjCObjectPointerType(qual_type).getAsOpaquePtr(); default: - return getASTContext()->getPointerType(qual_type).getAsOpaquePtr(); + return ast->getPointerType(qual_type).getAsOpaquePtr(); } } return NULL; Modified: lldb/trunk/source/Symbol/ClangASTType.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/ClangASTType.cpp?rev=121745&r1=121744&r2=121745&view=diff ============================================================================== --- lldb/trunk/source/Symbol/ClangASTType.cpp (original) +++ lldb/trunk/source/Symbol/ClangASTType.cpp Mon Dec 13 20:59:59 2010 @@ -161,6 +161,7 @@ case clang::BuiltinType::Double: case clang::BuiltinType::LongDouble: return lldb::eEncodingIEEE754; + case clang::BuiltinType::ObjCClass: case clang::BuiltinType::ObjCId: case clang::BuiltinType::ObjCSel: return lldb::eEncodingUint; Modified: lldb/trunk/source/Target/Process.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/Process.cpp?rev=121745&r1=121744&r2=121745&view=diff ============================================================================== --- lldb/trunk/source/Target/Process.cpp (original) +++ lldb/trunk/source/Target/Process.cpp Mon Dec 13 20:59:59 2010 @@ -88,7 +88,6 @@ m_image_tokens (), m_listener (listener), m_breakpoint_site_list (), - m_persistent_vars (), m_dynamic_checkers_ap (), m_unix_signals (), m_target_triple (), @@ -2157,12 +2156,6 @@ return GetTarget().GetProcessSP(); } -ClangPersistentVariables & -Process::GetPersistentVariables() -{ - return m_persistent_vars; -} - uint32_t Process::ListProcessesMatchingName (const char *name, StringList &matches, std::vector &pids) { @@ -2334,7 +2327,7 @@ } } -Process::ExecutionResults +ExecutionResults Process::RunThreadPlan (ExecutionContext &exe_ctx, lldb::ThreadPlanSP &thread_plan_sp, bool stop_others, @@ -2375,7 +2368,7 @@ { errors.Printf("Error resuming inferior: \"%s\".\n", resume_error.AsCString()); exe_ctx.process->RestoreProcessEvents(); - return Process::eExecutionSetupError; + return lldb::eExecutionSetupError; } // We need to call the function synchronously, so spin waiting for it to return. @@ -2440,7 +2433,7 @@ { if (log) log->Printf ("Even though we timed out, the call plan was done. Exiting wait loop."); - return_value = Process::eExecutionCompleted; + return_value = lldb::eExecutionCompleted; break; } @@ -2458,7 +2451,7 @@ else { exe_ctx.process->RestoreProcessEvents (); - return Process::eExecutionInterrupted; + return lldb::eExecutionInterrupted; } } } @@ -2473,12 +2466,12 @@ if (exe_ctx.thread->IsThreadPlanDone (thread_plan_sp.get())) { - return_value = Process::eExecutionCompleted; + return_value = lldb::eExecutionCompleted; break; } else if (exe_ctx.thread->WasThreadPlanDiscarded (thread_plan_sp.get())) { - return_value = Process::eExecutionDiscarded; + return_value = lldb::eExecutionDiscarded; break; } else @@ -2557,7 +2550,7 @@ { exe_ctx.thread->DiscardThreadPlansUpToPlan (thread_plan_sp); } - return_value = Process::eExecutionInterrupted; + return_value = lldb::eExecutionInterrupted; break; } } @@ -2593,19 +2586,19 @@ switch (result) { - case Process::eExecutionCompleted: + case lldb::eExecutionCompleted: result_name = "eExecutionCompleted"; break; - case Process::eExecutionDiscarded: + case lldb::eExecutionDiscarded: result_name = "eExecutionDiscarded"; break; - case Process::eExecutionInterrupted: + case lldb::eExecutionInterrupted: result_name = "eExecutionInterrupted"; break; - case Process::eExecutionSetupError: + case lldb::eExecutionSetupError: result_name = "eExecutionSetupError"; break; - case Process::eExecutionTimedOut: + case lldb::eExecutionTimedOut: result_name = "eExecutionTimedOut"; break; } Modified: lldb/trunk/source/Target/SectionLoadList.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/SectionLoadList.cpp?rev=121745&r1=121744&r2=121745&view=diff ============================================================================== --- lldb/trunk/source/Target/SectionLoadList.cpp (original) +++ lldb/trunk/source/Target/SectionLoadList.cpp Mon Dec 13 20:59:59 2010 @@ -68,12 +68,17 @@ LogSP log(lldb_private::GetLogIfAnyCategoriesSet (LIBLLDB_LOG_DYNAMIC_LOADER | LIBLLDB_LOG_VERBOSE)); if (log) - log->Printf ("SectionLoadList::%s (section = %p (%s.%s), load_addr = 0x%16.16llx)", + { + const FileSpec &module_file_spec (section->GetModule()->GetFileSpec()); + log->Printf ("SectionLoadList::%s (section = %p (%s%s%s.%s), load_addr = 0x%16.16llx)", __FUNCTION__, section, - section->GetModule()->GetFileSpec().GetFilename().AsCString(), + module_file_spec.GetDirectory().AsCString(), + module_file_spec.GetDirectory() ? "/" : "", + module_file_spec.GetFilename().AsCString(), section->GetName().AsCString(), load_addr); + } Mutex::Locker locker(m_mutex); collection::iterator pos = m_collection.find(load_addr); @@ -97,11 +102,16 @@ LogSP log(lldb_private::GetLogIfAnyCategoriesSet (LIBLLDB_LOG_DYNAMIC_LOADER | LIBLLDB_LOG_VERBOSE)); if (log) - log->Printf ("SectionLoadList::%s (section = %p (%s.%s))", + { + const FileSpec &module_file_spec (section->GetModule()->GetFileSpec()); + log->Printf ("SectionLoadList::%s (section = %p (%s%s%s.%s))", __FUNCTION__, section, - section->GetModule()->GetFileSpec().GetFilename().AsCString(), + module_file_spec.GetDirectory().AsCString(), + module_file_spec.GetDirectory() ? "/" : "", + module_file_spec.GetFilename().AsCString(), section->GetName().AsCString()); + } size_t unload_count = 0; Mutex::Locker locker(m_mutex); @@ -128,12 +138,17 @@ LogSP log(lldb_private::GetLogIfAnyCategoriesSet (LIBLLDB_LOG_DYNAMIC_LOADER | LIBLLDB_LOG_VERBOSE)); if (log) - log->Printf ("SectionLoadList::%s (section = %p (%s.%s), load_addr = 0x%16.16llx)", + { + const FileSpec &module_file_spec (section->GetModule()->GetFileSpec()); + log->Printf ("SectionLoadList::%s (section = %p (%s%s%s.%s), load_addr = 0x%16.16llx)", __FUNCTION__, section, - section->GetModule()->GetFileSpec().GetFilename().AsCString(), + module_file_spec.GetDirectory().AsCString(), + module_file_spec.GetDirectory() ? "/" : "", + module_file_spec.GetFilename().AsCString(), section->GetName().AsCString(), load_addr); + } Mutex::Locker locker(m_mutex); return m_collection.erase (load_addr) != 0; } Modified: lldb/trunk/source/Target/StackFrame.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/StackFrame.cpp?rev=121745&r1=121744&r2=121745&view=diff ============================================================================== --- lldb/trunk/source/Target/StackFrame.cpp (original) +++ lldb/trunk/source/Target/StackFrame.cpp Mon Dec 13 20:59:59 2010 @@ -478,6 +478,159 @@ return m_variable_list_sp.get(); } +ValueObjectSP +StackFrame::GetValueForVariableExpressionPath (const char *var_expr) +{ + bool deref = false; + bool address_of = false; + ValueObjectSP valobj_sp; + const bool get_file_globals = true; + VariableList *variable_list = GetVariableList (get_file_globals); + + if (variable_list) + { + // If first character is a '*', then show pointer contents + if (var_expr[0] == '*') + { + deref = true; + var_expr++; // Skip the '*' + } + else if (var_expr[0] == '&') + { + address_of = true; + var_expr++; // Skip the '&' + } + + std::string var_path (var_expr); + size_t separator_idx = var_path.find_first_of(".-["); + + ConstString name_const_string; + if (separator_idx == std::string::npos) + name_const_string.SetCString (var_path.c_str()); + else + name_const_string.SetCStringWithLength (var_path.c_str(), separator_idx); + + VariableSP var_sp (variable_list->FindVariable(name_const_string)); + if (var_sp) + { + valobj_sp = GetValueObjectForFrameVariable (var_sp); + + var_path.erase (0, name_const_string.GetLength ()); + // We are dumping at least one child + while (separator_idx != std::string::npos) + { + // Calculate the next separator index ahead of time + ValueObjectSP child_valobj_sp; + const char separator_type = var_path[0]; + switch (separator_type) + { + + case '-': + if (var_path.size() >= 2 && var_path[1] != '>') + return ValueObjectSP(); + + var_path.erase (0, 1); // Remove the '-' + // Fall through + case '.': + { + // We either have a pointer type and need to verify + // valobj_sp is a pointer, or we have a member of a + // class/union/struct being accessed with the . syntax + // and need to verify we don't have a pointer. + const bool is_ptr = var_path[0] == '>'; + + if (valobj_sp->IsPointerType () != is_ptr) + { + // Incorrect use of "." with a pointer, or "->" with + // a class/union/struct instance or reference. + return ValueObjectSP(); + } + + var_path.erase (0, 1); // Remove the '.' or '>' + separator_idx = var_path.find_first_of(".-["); + ConstString child_name; + if (separator_idx == std::string::npos) + child_name.SetCString (var_path.c_str()); + else + child_name.SetCStringWithLength(var_path.c_str(), separator_idx); + + child_valobj_sp = valobj_sp->GetChildMemberWithName (child_name, true); + if (!child_valobj_sp) + { + // No child member with name "child_name" + return ValueObjectSP(); + } + // Remove the child name from the path + var_path.erase(0, child_name.GetLength()); + } + break; + + case '[': + // Array member access, or treating pointer as an array + if (var_path.size() > 2) // Need at least two brackets and a number + { + char *end = NULL; + int32_t child_index = ::strtol (&var_path[1], &end, 0); + if (end && *end == ']') + { + + if (valobj_sp->IsPointerType ()) + { + child_valobj_sp = valobj_sp->GetSyntheticArrayMemberFromPointer (child_index, true); + } + else + { + child_valobj_sp = valobj_sp->GetChildAtIndex (child_index, true); + } + + if (!child_valobj_sp) + { + // Invalid array index... + return ValueObjectSP(); + } + + // Erase the array member specification '[%i]' where + // %i is the array index + var_path.erase(0, (end - var_path.c_str()) + 1); + separator_idx = var_path.find_first_of(".-["); + + // Break out early from the switch since we were + // able to find the child member + break; + } + } + return ValueObjectSP(); + + default: + // Failure... + return ValueObjectSP(); + } + + if (child_valobj_sp) + valobj_sp = child_valobj_sp; + + if (var_path.empty()) + break; + + } + if (valobj_sp) + { + if (deref) + { + ValueObjectSP deref_valobj_sp (valobj_sp->Dereference(this, NULL)); + valobj_sp = deref_valobj_sp; + } + else if (address_of) + { + ValueObjectSP address_of_valobj_sp (valobj_sp->AddressOf()); + valobj_sp = address_of_valobj_sp; + } + } + return valobj_sp; + } + } + return ValueObjectSP(); +} bool StackFrame::GetFrameBaseValue (Scalar &frame_base, Error *error_ptr) Modified: lldb/trunk/source/Target/Target.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/Target.cpp?rev=121745&r1=121744&r2=121745&view=diff ============================================================================== --- lldb/trunk/source/Target/Target.cpp (original) +++ lldb/trunk/source/Target/Target.cpp Mon Dec 13 20:59:59 2010 @@ -18,15 +18,17 @@ #include "lldb/Breakpoint/BreakpointResolverFileLine.h" #include "lldb/Breakpoint/BreakpointResolverName.h" #include "lldb/Core/DataBufferMemoryMap.h" +#include "lldb/Core/Debugger.h" #include "lldb/Core/Event.h" #include "lldb/Core/Log.h" -#include "lldb/Core/Timer.h" #include "lldb/Core/StreamString.h" +#include "lldb/Core/Timer.h" +#include "lldb/Core/ValueObject.h" #include "lldb/Host/Host.h" #include "lldb/lldb-private-log.h" #include "lldb/Symbol/ObjectFile.h" #include "lldb/Target/Process.h" -#include "lldb/Core/Debugger.h" +#include "lldb/Target/StackFrame.h" using namespace lldb; using namespace lldb_private; @@ -46,7 +48,8 @@ m_triple(), m_search_filter_sp(), m_image_search_paths (ImageSearchPathsChanged, this), - m_scratch_ast_context_ap(NULL) + m_scratch_ast_context_ap (NULL), + m_persistent_variables () { SetEventName (eBroadcastBitBreakpointChanged, "breakpoint-changed"); SetEventName (eBroadcastBitModulesLoaded, "modules-loaded"); @@ -866,6 +869,81 @@ return m_expr_prefix_contents.c_str(); } +ExecutionResults +Target::EvaluateExpression +( + const char *expr_cstr, + StackFrame *frame, + bool unwind_on_error, + lldb::ValueObjectSP &result_valobj_sp +) +{ + ExecutionResults execution_results = eExecutionSetupError; + + result_valobj_sp.reset(); + + ExecutionContext exe_ctx; + if (frame) + { + frame->CalculateExecutionContext(exe_ctx); + result_valobj_sp = frame->GetValueForVariableExpressionPath (expr_cstr); + } + else if (m_process_sp) + { + m_process_sp->CalculateExecutionContext(exe_ctx); + } + else + { + CalculateExecutionContext(exe_ctx); + } + + if (result_valobj_sp) + { + execution_results = eExecutionCompleted; + // We got a result from the frame variable expression path above... + ConstString persistent_variable_name (m_persistent_variables.GetNextPersistentVariableName()); + + lldb::ValueObjectSP const_valobj_sp; + + // Check in case our value is already a constant value + if (result_valobj_sp->GetIsConstant()) + { + const_valobj_sp = result_valobj_sp; + const_valobj_sp->SetName (persistent_variable_name); + } + else + const_valobj_sp = result_valobj_sp->CreateConstantValue (exe_ctx.GetBestExecutionContextScope(), + persistent_variable_name); + + result_valobj_sp = const_valobj_sp; + + ClangExpressionVariableSP clang_expr_variable_sp(m_persistent_variables.CreatePersistentVariable(result_valobj_sp)); + assert (clang_expr_variable_sp.get()); + } + else + { + // Make sure we aren't just trying to see the value of a persistent + // variable (something like "$0") + lldb::ClangExpressionVariableSP persistent_var_sp (m_persistent_variables.GetVariable (expr_cstr)); + if (persistent_var_sp) + { + result_valobj_sp = persistent_var_sp->GetValueObject (); + execution_results = eExecutionCompleted; + } + else + { + const char *prefix = GetExpressionPrefixContentsAsCString(); + + execution_results = ClangUserExpression::Evaluate (exe_ctx, + unwind_on_error, + expr_cstr, + prefix, + result_valobj_sp); + } + } + return execution_results; +} + //-------------------------------------------------------------- // class Target::SettingsController //-------------------------------------------------------------- Modified: lldb/trunk/source/Target/ThreadPlanTestCondition.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/ThreadPlanTestCondition.cpp?rev=121745&r1=121744&r2=121745&view=diff ============================================================================== --- lldb/trunk/source/Target/ThreadPlanTestCondition.cpp (original) +++ lldb/trunk/source/Target/ThreadPlanTestCondition.cpp Mon Dec 13 20:59:59 2010 @@ -76,11 +76,11 @@ LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_STEP)); if (m_thread.IsThreadPlanDone(m_expression_plan_sp.get())) { - ClangExpressionVariable *expr_result = NULL; + lldb::ClangExpressionVariableSP expr_result; StreamString error_stream; m_expression->FinalizeJITExecution(error_stream, m_exe_ctx, expr_result); - ValueObjectSP result_sp (expr_result->GetExpressionResult(&m_exe_ctx)); + ValueObjectSP result_sp (expr_result->GetValueObject()); if (result_sp) { // FIXME: This is not the right answer, we should have a "GetValueAsBoolean..." Modified: lldb/trunk/test/load_unload/Makefile URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/load_unload/Makefile?rev=121745&r1=121744&r2=121745&view=diff ============================================================================== --- lldb/trunk/test/load_unload/Makefile (original) +++ lldb/trunk/test/load_unload/Makefile Mon Dec 13 20:59:59 2010 @@ -1,9 +1,10 @@ -all: a.out liba.dylib libb.dylib libc.dylib +all: a.out liba.dylib libb.dylib libc.dylib libd.dylib CFLAGS ?=-arch x86_64 -gdwarf-2 -O0 +CWD := $(shell pwd) -a.out: main.o - gcc $(CFLAGS) -o a.out main.o +a.out: main.o libd.dylib + gcc $(CFLAGS) -o a.out main.o -L. -ld main.o: main.c gcc $(CFLAGS) -c main.c @@ -29,5 +30,12 @@ c.o: c.c gcc $(CFLAGS) -c c.c +libd.dylib: d.o + gcc $(CFLAGS) -dynamiclib -install_name "$(CWD)/libd.dylib" -o libd.dylib d.o + dsymutil libd.dylib + +d.o: d.c + gcc $(CFLAGS) -c d.c + clean: rm -rf *.o *~ *.dylib a.out *.dSYM Added: lldb/trunk/test/load_unload/d.c URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/load_unload/d.c?rev=121745&view=auto ============================================================================== --- lldb/trunk/test/load_unload/d.c (added) +++ lldb/trunk/test/load_unload/d.c Mon Dec 13 20:59:59 2010 @@ -0,0 +1,13 @@ +//===-- c.c -----------------------------------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +int +d_function () +{ + return 700; +} From gclayton at apple.com Mon Dec 13 22:58:53 2010 From: gclayton at apple.com (Greg Clayton) Date: Tue, 14 Dec 2010 04:58:53 -0000 Subject: [Lldb-commits] [lldb] r121748 - in /lldb/trunk: include/lldb/API/SBBlock.h include/lldb/API/SBCompileUnit.h include/lldb/API/SBFunction.h include/lldb/API/SBSymbol.h lldb.xcodeproj/project.pbxproj source/API/SBBlock.cpp source/API/SBCompileUnit.cpp source/API/SBFrame.cpp source/API/SBFunction.cpp source/API/SBSymbol.cpp Message-ID: <20101214045853.874592A6C12C@llvm.org> Author: gclayton Date: Mon Dec 13 22:58:53 2010 New Revision: 121748 URL: http://llvm.org/viewvc/llvm-project?rev=121748&view=rev Log: Fixed SBFrame to properly check to make sure it has a valid m_opaque_sp object before trying to use it. Modified: lldb/trunk/include/lldb/API/SBBlock.h lldb/trunk/include/lldb/API/SBCompileUnit.h lldb/trunk/include/lldb/API/SBFunction.h lldb/trunk/include/lldb/API/SBSymbol.h lldb/trunk/lldb.xcodeproj/project.pbxproj lldb/trunk/source/API/SBBlock.cpp lldb/trunk/source/API/SBCompileUnit.cpp lldb/trunk/source/API/SBFrame.cpp lldb/trunk/source/API/SBFunction.cpp lldb/trunk/source/API/SBSymbol.cpp Modified: lldb/trunk/include/lldb/API/SBBlock.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBBlock.h?rev=121748&r1=121747&r2=121748&view=diff ============================================================================== --- lldb/trunk/include/lldb/API/SBBlock.h (original) +++ lldb/trunk/include/lldb/API/SBBlock.h Mon Dec 13 22:58:53 2010 @@ -68,6 +68,9 @@ const lldb_private::Block * get () const; + void + reset (lldb_private::Block *lldb_object_ptr); + SBBlock (lldb_private::Block *lldb_object_ptr); void Modified: lldb/trunk/include/lldb/API/SBCompileUnit.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBCompileUnit.h?rev=121748&r1=121747&r2=121748&view=diff ============================================================================== --- lldb/trunk/include/lldb/API/SBCompileUnit.h (original) +++ lldb/trunk/include/lldb/API/SBCompileUnit.h Mon Dec 13 22:58:53 2010 @@ -77,6 +77,9 @@ const lldb_private::CompileUnit * get () const; + void + reset (lldb_private::CompileUnit *lldb_object_ptr); + #endif lldb_private::CompileUnit *m_opaque_ptr; Modified: lldb/trunk/include/lldb/API/SBFunction.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBFunction.h?rev=121748&r1=121747&r2=121748&view=diff ============================================================================== --- lldb/trunk/include/lldb/API/SBFunction.h (original) +++ lldb/trunk/include/lldb/API/SBFunction.h Mon Dec 13 22:58:53 2010 @@ -56,9 +56,16 @@ protected: +#ifndef SWIG + lldb_private::Function * get (); + void + reset (lldb_private::Function *lldb_object_ptr); + +#endif + private: friend class SBFrame; friend class SBSymbolContext; Modified: lldb/trunk/include/lldb/API/SBSymbol.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBSymbol.h?rev=121748&r1=121747&r2=121748&view=diff ============================================================================== --- lldb/trunk/include/lldb/API/SBSymbol.h (original) +++ lldb/trunk/include/lldb/API/SBSymbol.h Mon Dec 13 22:58:53 2010 @@ -57,8 +57,13 @@ protected: +#ifndef SWIG lldb_private::Symbol * get (); + + void + reset (lldb_private::Symbol *); +#endif private: friend class SBFrame; Modified: lldb/trunk/lldb.xcodeproj/project.pbxproj URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/lldb.xcodeproj/project.pbxproj?rev=121748&r1=121747&r2=121748&view=diff ============================================================================== --- lldb/trunk/lldb.xcodeproj/project.pbxproj (original) +++ lldb/trunk/lldb.xcodeproj/project.pbxproj Mon Dec 13 22:58:53 2010 @@ -2459,6 +2459,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/API/SBBlock.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBBlock.cpp?rev=121748&r1=121747&r2=121748&view=diff ============================================================================== --- lldb/trunk/source/API/SBBlock.cpp (original) +++ lldb/trunk/source/API/SBBlock.cpp Mon Dec 13 22:58:53 2010 @@ -151,6 +151,11 @@ return m_opaque_ptr; } +void +SBBlock::reset (lldb_private::Block *block) +{ + m_opaque_ptr = block; +} bool SBBlock::GetDescription (SBStream &description) Modified: lldb/trunk/source/API/SBCompileUnit.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBCompileUnit.cpp?rev=121748&r1=121747&r2=121748&view=diff ============================================================================== --- lldb/trunk/source/API/SBCompileUnit.cpp (original) +++ lldb/trunk/source/API/SBCompileUnit.cpp Mon Dec 13 22:58:53 2010 @@ -170,6 +170,13 @@ { return m_opaque_ptr; } + +void +SBCompileUnit::reset (lldb_private::CompileUnit *lldb_object_ptr) +{ + m_opaque_ptr = lldb_object_ptr; +} + bool SBCompileUnit::GetDescription (SBStream &description) Modified: lldb/trunk/source/API/SBFrame.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBFrame.cpp?rev=121748&r1=121747&r2=121748&view=diff ============================================================================== --- lldb/trunk/source/API/SBFrame.cpp (original) +++ lldb/trunk/source/API/SBFrame.cpp Mon Dec 13 22:58:53 2010 @@ -122,7 +122,10 @@ SBModule SBFrame::GetModule () const { - SBModule sb_module (m_opaque_sp->GetSymbolContext (eSymbolContextModule).module_sp); + SBModule sb_module; + if (m_opaque_sp) + *sb_module = m_opaque_sp->GetSymbolContext (eSymbolContextModule).module_sp; + LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); if (log) log->Printf ("SBFrame(%p)::GetModule () => SBModule(%p)", @@ -134,8 +137,9 @@ SBCompileUnit SBFrame::GetCompileUnit () const { - SBCompileUnit sb_comp_unit(m_opaque_sp->GetSymbolContext (eSymbolContextCompUnit).comp_unit); - + SBCompileUnit sb_comp_unit; + if (m_opaque_sp) + sb_comp_unit.reset (m_opaque_sp->GetSymbolContext (eSymbolContextCompUnit).comp_unit); LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); if (log) log->Printf ("SBFrame(%p)::GetModule () => SBCompileUnit(%p)", @@ -147,8 +151,9 @@ SBFunction SBFrame::GetFunction () const { - SBFunction sb_function(m_opaque_sp->GetSymbolContext (eSymbolContextFunction).function); - + SBFunction sb_function; + if (m_opaque_sp) + sb_function.reset(m_opaque_sp->GetSymbolContext (eSymbolContextFunction).function); LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); if (log) log->Printf ("SBFrame(%p)::GetFunction () => SBFunction(%p)", @@ -160,7 +165,9 @@ SBSymbol SBFrame::GetSymbol () const { - SBSymbol sb_symbol(m_opaque_sp->GetSymbolContext (eSymbolContextSymbol).symbol); + SBSymbol sb_symbol; + if (m_opaque_sp) + sb_symbol.reset(m_opaque_sp->GetSymbolContext (eSymbolContextSymbol).symbol); LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); if (log) log->Printf ("SBFrame(%p)::GetSymbol () => SBSymbol(%p)", @@ -171,7 +178,9 @@ SBBlock SBFrame::GetBlock () const { - SBBlock sb_block(m_opaque_sp->GetSymbolContext (eSymbolContextBlock).block); + SBBlock sb_block; + if (m_opaque_sp) + sb_block.reset (m_opaque_sp->GetSymbolContext (eSymbolContextBlock).block); LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); if (log) log->Printf ("SBFrame(%p)::GetBlock () => SBBlock(%p)", @@ -182,7 +191,9 @@ SBBlock SBFrame::GetFrameBlock () const { - SBBlock sb_block(m_opaque_sp->GetFrameBlock ()); + SBBlock sb_block; + if (m_opaque_sp) + sb_block.reset(m_opaque_sp->GetFrameBlock ()); LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); if (log) log->Printf ("SBFrame(%p)::GetFrameBlock () => SBBlock(%p)", @@ -193,7 +204,9 @@ SBLineEntry SBFrame::GetLineEntry () const { - SBLineEntry sb_line_entry(&m_opaque_sp->GetSymbolContext (eSymbolContextLineEntry).line_entry); + SBLineEntry sb_line_entry; + if (m_opaque_sp) + sb_line_entry.SetLineEntry (m_opaque_sp->GetSymbolContext (eSymbolContextLineEntry).line_entry); LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); if (log) log->Printf ("SBFrame(%p)::GetLineEntry () => SBLineEntry(%p)", @@ -216,7 +229,6 @@ lldb::addr_t SBFrame::GetPC () const { - lldb::addr_t addr = LLDB_INVALID_ADDRESS; if (m_opaque_sp) addr = m_opaque_sp->GetFrameCodeAddress().GetLoadAddress (&m_opaque_sp->GetThread().GetProcess().GetTarget()); @@ -231,7 +243,6 @@ bool SBFrame::SetPC (lldb::addr_t new_pc) { - bool ret_val = false; if (m_opaque_sp) ret_val = m_opaque_sp->GetRegisterContext()->SetPC (new_pc); @@ -294,27 +305,26 @@ SBFrame::LookupVar (const char *var_name) { lldb::VariableSP var_sp; - if (IsValid ()) + if (m_opaque_sp && var_name && var_name[0]) { lldb_private::VariableList variable_list; - SBSymbolContext sc = GetSymbolContext (eSymbolContextEverything); - - SBBlock block = sc.GetBlock(); - if (block.IsValid()) - block.AppendVariables (true, true, &variable_list); - const uint32_t num_variables = variable_list.GetSize(); + SymbolContext sc (m_opaque_sp->GetSymbolContext (eSymbolContextBlock)); - bool found = false; - for (uint32_t i = 0; i < num_variables && !found; ++i) + if (sc.block) { - var_sp = variable_list.GetVariableAtIndex(i); - if (var_sp - && (var_sp.get()->GetName() == lldb_private::ConstString(var_name))) - found = true; + const bool can_create = true; + const bool get_parent_variables = true; + const bool stop_if_block_is_inlined_function = true; + + if (sc.block->AppendVariables (can_create, + get_parent_variables, + stop_if_block_is_inlined_function, + &variable_list)) + { + var_sp = variable_list.FindVariable (lldb_private::ConstString(var_name)); + } } - if (!found) - var_sp.reset(); } SBValue sb_value; @@ -334,7 +344,7 @@ SBFrame::LookupVarInScope (const char *var_name, const char *scope) { lldb::VariableSP var_sp; - if (IsValid()) + if (m_opaque_sp && var_name && var_name[0] && scope && scope[0]) { std::string scope_str = scope; lldb::ValueType var_scope = eValueTypeInvalid; @@ -350,24 +360,31 @@ if (var_scope != eValueTypeInvalid) { - lldb_private::VariableList *variable_list = m_opaque_sp->GetVariableList(true); - if (variable_list) + lldb_private::VariableList variable_list; + + SymbolContext sc (m_opaque_sp->GetSymbolContext (eSymbolContextBlock)); + + const bool can_create = true; + const bool get_parent_variables = true; + const bool stop_if_block_is_inlined_function = true; + + if (sc.block && sc.block->AppendVariables (can_create, + get_parent_variables, + stop_if_block_is_inlined_function, + &variable_list)) { - const uint32_t num_variables = variable_list->GetSize(); - bool found = false; - for (uint32_t i = 0; i < num_variables && !found; ++i) + lldb_private::ConstString const_var_name(var_name); + const uint32_t num_variables = variable_list.GetSize(); + for (uint32_t i = 0; i < num_variables; ++i) { - var_sp = variable_list->GetVariableAtIndex(i); - if (var_sp - && (var_sp.get()->GetName() == lldb_private::ConstString(var_name)) - && var_sp.get()->GetScope() == var_scope) + lldb::VariableSP curr_var_sp (variable_list.GetVariableAtIndex(i)); + if (curr_var_sp && curr_var_sp->GetScope() == var_scope && + curr_var_sp->GetName() == const_var_name) { - found = true; + var_sp = curr_var_sp; break; } } - if (!found) - var_sp.reset(); } } } @@ -415,10 +432,9 @@ { LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); - //if (log) - // log->Printf ("SBFrame::GetThread ()"); - - SBThread sb_thread (m_opaque_sp->GetThread().GetSP()); + SBThread sb_thread; + if (m_opaque_sp) + sb_thread.SetThread (m_opaque_sp->GetThread().GetSP()); if (log) { Modified: lldb/trunk/source/API/SBFunction.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBFunction.cpp?rev=121748&r1=121747&r2=121748&view=diff ============================================================================== --- lldb/trunk/source/API/SBFunction.cpp (original) +++ lldb/trunk/source/API/SBFunction.cpp Mon Dec 13 22:58:53 2010 @@ -148,3 +148,9 @@ return m_opaque_ptr; } +void +SBFunction::reset (lldb_private::Function *lldb_object_ptr) +{ + m_opaque_ptr = lldb_object_ptr; +} + Modified: lldb/trunk/source/API/SBSymbol.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBSymbol.cpp?rev=121748&r1=121747&r2=121748&view=diff ============================================================================== --- lldb/trunk/source/API/SBSymbol.cpp (original) +++ lldb/trunk/source/API/SBSymbol.cpp Mon Dec 13 22:58:53 2010 @@ -143,3 +143,9 @@ { return m_opaque_ptr; } + +void +SBSymbol::reset (lldb_private::Symbol *symbol) +{ + m_opaque_ptr = symbol; +} From johnny.chen at apple.com Tue Dec 14 11:40:04 2010 From: johnny.chen at apple.com (Johnny Chen) Date: Tue, 14 Dec 2010 17:40:04 -0000 Subject: [Lldb-commits] [lldb] r121773 - /lldb/trunk/source/API/SBFrame.cpp Message-ID: <20101214174004.4FEA12A6C12D@llvm.org> Author: johnny Date: Tue Dec 14 11:40:04 2010 New Revision: 121773 URL: http://llvm.org/viewvc/llvm-project?rev=121773&view=rev Log: Fixed rdar://problem/8767055 test suite failure TestStaticVariables.py (ToT r121745). Populate the variable list from the stack frame, first. Modified: lldb/trunk/source/API/SBFrame.cpp Modified: lldb/trunk/source/API/SBFrame.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBFrame.cpp?rev=121773&r1=121772&r2=121773&view=diff ============================================================================== --- lldb/trunk/source/API/SBFrame.cpp (original) +++ lldb/trunk/source/API/SBFrame.cpp Tue Dec 14 11:40:04 2010 @@ -360,7 +360,7 @@ if (var_scope != eValueTypeInvalid) { - lldb_private::VariableList variable_list; + lldb_private::VariableList *variable_list = m_opaque_sp->GetVariableList(true); SymbolContext sc (m_opaque_sp->GetSymbolContext (eSymbolContextBlock)); @@ -371,13 +371,13 @@ if (sc.block && sc.block->AppendVariables (can_create, get_parent_variables, stop_if_block_is_inlined_function, - &variable_list)) + variable_list)) { lldb_private::ConstString const_var_name(var_name); - const uint32_t num_variables = variable_list.GetSize(); + const uint32_t num_variables = variable_list->GetSize(); for (uint32_t i = 0; i < num_variables; ++i) { - lldb::VariableSP curr_var_sp (variable_list.GetVariableAtIndex(i)); + lldb::VariableSP curr_var_sp (variable_list->GetVariableAtIndex(i)); if (curr_var_sp && curr_var_sp->GetScope() == var_scope && curr_var_sp->GetName() == const_var_name) { From johnny.chen at apple.com Tue Dec 14 11:48:26 2010 From: johnny.chen at apple.com (Johnny Chen) Date: Tue, 14 Dec 2010 17:48:26 -0000 Subject: [Lldb-commits] [lldb] r121775 - /lldb/trunk/test/expression_command/persistent_variables/TestPersistentVariables.py Message-ID: <20101214174826.92FF62A6C12D@llvm.org> Author: johnny Date: Tue Dec 14 11:48:26 2010 New Revision: 121775 URL: http://llvm.org/viewvc/llvm-project?rev=121775&view=rev Log: Change the golden output so that merely evaluating an existing persistent variable does not result in a newly created persistent variable. The old one is returned, instead. Modified: lldb/trunk/test/expression_command/persistent_variables/TestPersistentVariables.py 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=121775&r1=121774&r2=121775&view=diff ============================================================================== --- lldb/trunk/test/expression_command/persistent_variables/TestPersistentVariables.py (original) +++ lldb/trunk/test/expression_command/persistent_variables/TestPersistentVariables.py Tue Dec 14 11:48:26 2010 @@ -34,8 +34,12 @@ # (int) $2 = 14 self.expect("expression $2", - startstr = "(int) $3 = 14") - # (int) $3 = 14 + startstr = "(int) $2 = 14") + # (int) $2 = 14 + + self.expect("expression $1", + startstr = "(int) $1 = 8") + # (int) $1 = 8 if __name__ == '__main__': From gclayton at apple.com Tue Dec 14 12:39:31 2010 From: gclayton at apple.com (Greg Clayton) Date: Tue, 14 Dec 2010 18:39:31 -0000 Subject: [Lldb-commits] [lldb] r121777 - in /lldb/trunk: include/lldb/API/SBFrame.h source/API/SBFrame.cpp Message-ID: <20101214183931.ABC7B2A6C12D@llvm.org> Author: gclayton Date: Tue Dec 14 12:39:31 2010 New Revision: 121777 URL: http://llvm.org/viewvc/llvm-project?rev=121777&view=rev Log: Changed: SBValue SBFrame::LookupVar(const char *name); To SBValue SBFrame::FindVariable (const char *name); Changed: SBValue LookupVarInScope (const char *name, const char *scope); to SBValue FindValue (const char *name, ValueType value_type); The latter makes it possible to not only find variables (params, locals, globals, and statics), but we can also now get register sets, registers and persistent variables using the frame as the context. Modified: lldb/trunk/include/lldb/API/SBFrame.h lldb/trunk/source/API/SBFrame.cpp Modified: lldb/trunk/include/lldb/API/SBFrame.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBFrame.h?rev=121777&r1=121776&r2=121777&view=diff ============================================================================== --- lldb/trunk/include/lldb/API/SBFrame.h (original) +++ lldb/trunk/include/lldb/API/SBFrame.h Tue Dec 14 12:39:31 2010 @@ -120,10 +120,12 @@ GetRegisters (); lldb::SBValue - LookupVar (const char *var_name); + FindVariable (const char *var_name); + // Find variables, register sets, registers, or persistent variables using + // the frame as the scope lldb::SBValue - LookupVarInScope (const char *var_name, const char *scope); + FindValue (const char *name, ValueType value_type); bool GetDescription (lldb::SBStream &description); Modified: lldb/trunk/source/API/SBFrame.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBFrame.cpp?rev=121777&r1=121776&r2=121777&view=diff ============================================================================== --- lldb/trunk/source/API/SBFrame.cpp (original) +++ lldb/trunk/source/API/SBFrame.cpp Tue Dec 14 12:39:31 2010 @@ -48,10 +48,10 @@ { } -SBFrame::SBFrame (const lldb::StackFrameSP &lldb_object_sp) : +SBFrame::SBFrame (const StackFrameSP &lldb_object_sp) : m_opaque_sp (lldb_object_sp) { - LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); + LogSP log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); if (log) { @@ -82,11 +82,11 @@ void -SBFrame::SetFrame (const lldb::StackFrameSP &lldb_object_sp) +SBFrame::SetFrame (const StackFrameSP &lldb_object_sp) { void *old_ptr = m_opaque_sp.get(); m_opaque_sp = lldb_object_sp; - LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); + LogSP log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); if (log) { @@ -111,7 +111,7 @@ if (m_opaque_sp) sb_sym_ctx.SetSymbolContext(&m_opaque_sp->GetSymbolContext (resolve_scope)); - LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); + LogSP log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); if (log) log->Printf ("SBFrame(%p)::GetSymbolContext (resolve_scope=0x%8.8x) => SBSymbolContext(%p)", m_opaque_sp.get(), resolve_scope, sb_sym_ctx.get()); @@ -126,7 +126,7 @@ if (m_opaque_sp) *sb_module = m_opaque_sp->GetSymbolContext (eSymbolContextModule).module_sp; - LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); + LogSP log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); if (log) log->Printf ("SBFrame(%p)::GetModule () => SBModule(%p)", m_opaque_sp.get(), sb_module.get()); @@ -140,7 +140,7 @@ SBCompileUnit sb_comp_unit; if (m_opaque_sp) sb_comp_unit.reset (m_opaque_sp->GetSymbolContext (eSymbolContextCompUnit).comp_unit); - LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); + LogSP log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); if (log) log->Printf ("SBFrame(%p)::GetModule () => SBCompileUnit(%p)", m_opaque_sp.get(), sb_comp_unit.get()); @@ -154,7 +154,7 @@ SBFunction sb_function; if (m_opaque_sp) sb_function.reset(m_opaque_sp->GetSymbolContext (eSymbolContextFunction).function); - LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); + LogSP log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); if (log) log->Printf ("SBFrame(%p)::GetFunction () => SBFunction(%p)", m_opaque_sp.get(), sb_function.get()); @@ -168,7 +168,7 @@ SBSymbol sb_symbol; if (m_opaque_sp) sb_symbol.reset(m_opaque_sp->GetSymbolContext (eSymbolContextSymbol).symbol); - LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); + LogSP log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); if (log) log->Printf ("SBFrame(%p)::GetSymbol () => SBSymbol(%p)", m_opaque_sp.get(), sb_symbol.get()); @@ -181,7 +181,7 @@ SBBlock sb_block; if (m_opaque_sp) sb_block.reset (m_opaque_sp->GetSymbolContext (eSymbolContextBlock).block); - LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); + LogSP log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); if (log) log->Printf ("SBFrame(%p)::GetBlock () => SBBlock(%p)", m_opaque_sp.get(), sb_block.get()); @@ -194,7 +194,7 @@ SBBlock sb_block; if (m_opaque_sp) sb_block.reset(m_opaque_sp->GetFrameBlock ()); - LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); + LogSP log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); if (log) log->Printf ("SBFrame(%p)::GetFrameBlock () => SBBlock(%p)", m_opaque_sp.get(), sb_block.get()); @@ -207,7 +207,7 @@ SBLineEntry sb_line_entry; if (m_opaque_sp) sb_line_entry.SetLineEntry (m_opaque_sp->GetSymbolContext (eSymbolContextLineEntry).line_entry); - LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); + LogSP log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); if (log) log->Printf ("SBFrame(%p)::GetLineEntry () => SBLineEntry(%p)", m_opaque_sp.get(), sb_line_entry.get()); @@ -219,21 +219,21 @@ { uint32_t frame_idx = m_opaque_sp ? m_opaque_sp->GetFrameIndex () : UINT32_MAX; - LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); + LogSP log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); if (log) log->Printf ("SBFrame(%p)::GetFrameID () => %u", m_opaque_sp.get(), frame_idx); return frame_idx; } -lldb::addr_t +addr_t SBFrame::GetPC () const { - lldb::addr_t addr = LLDB_INVALID_ADDRESS; + addr_t addr = LLDB_INVALID_ADDRESS; if (m_opaque_sp) addr = m_opaque_sp->GetFrameCodeAddress().GetLoadAddress (&m_opaque_sp->GetThread().GetProcess().GetTarget()); - LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); + LogSP log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); if (log) log->Printf ("SBFrame(%p)::GetPC () => 0x%llx", m_opaque_sp.get(), addr); @@ -241,13 +241,13 @@ } bool -SBFrame::SetPC (lldb::addr_t new_pc) +SBFrame::SetPC (addr_t new_pc) { bool ret_val = false; if (m_opaque_sp) ret_val = m_opaque_sp->GetRegisterContext()->SetPC (new_pc); - LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); + LogSP log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); if (log) log->Printf ("SBFrame(%p)::SetPC (new_pc=0x%llx) => %i", m_opaque_sp.get(), new_pc, ret_val); @@ -255,13 +255,13 @@ return ret_val; } -lldb::addr_t +addr_t SBFrame::GetSP () const { addr_t addr = LLDB_INVALID_ADDRESS; if (m_opaque_sp) addr = m_opaque_sp->GetRegisterContext()->GetSP(); - LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); + LogSP log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); if (log) log->Printf ("SBFrame(%p)::GetSP () => 0x%llx", m_opaque_sp.get(), addr); @@ -269,14 +269,14 @@ } -lldb::addr_t +addr_t SBFrame::GetFP () const { - lldb::addr_t addr = LLDB_INVALID_ADDRESS; + addr_t addr = LLDB_INVALID_ADDRESS; if (m_opaque_sp) addr = m_opaque_sp->GetRegisterContext()->GetFP(); - LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); + LogSP log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); if (log) log->Printf ("SBFrame(%p)::GetFP () => 0x%llx", m_opaque_sp.get(), addr); return addr; @@ -289,7 +289,7 @@ SBAddress sb_addr; if (m_opaque_sp) sb_addr.SetAddress (&m_opaque_sp->GetFrameCodeAddress()); - LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); + LogSP log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); if (log) log->Printf ("SBFrame(%p)::GetPCAddress () => SBAddress(%p)", m_opaque_sp.get(), sb_addr.get()); return sb_addr; @@ -302,12 +302,12 @@ } SBValue -SBFrame::LookupVar (const char *var_name) +SBFrame::FindVariable (const char *name) { - lldb::VariableSP var_sp; - if (m_opaque_sp && var_name && var_name[0]) + VariableSP var_sp; + if (m_opaque_sp && name && name[0]) { - lldb_private::VariableList variable_list; + VariableList variable_list; SymbolContext sc (m_opaque_sp->GetSymbolContext (eSymbolContextBlock)); @@ -322,7 +322,7 @@ stop_if_block_is_inlined_function, &variable_list)) { - var_sp = variable_list.FindVariable (lldb_private::ConstString(var_name)); + var_sp = variable_list.FindVariable (ConstString(name)); } } } @@ -332,71 +332,116 @@ if (var_sp) *sb_value = ValueObjectSP (new ValueObjectVariable (var_sp)); - LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); + LogSP log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); if (log) - log->Printf ("SBFrame(%p)::LookupVar (name=\"%s\") => SBValue(%p)", - m_opaque_sp.get(), var_name, sb_value.get()); + log->Printf ("SBFrame(%p)::FindVariable (name=\"%s\") => SBValue(%p)", + m_opaque_sp.get(), name, sb_value.get()); return sb_value; } SBValue -SBFrame::LookupVarInScope (const char *var_name, const char *scope) +SBFrame::FindValue (const char *name, ValueType value_type) { - lldb::VariableSP var_sp; - if (m_opaque_sp && var_name && var_name[0] && scope && scope[0]) + SBValue sb_value; + if (m_opaque_sp && name && name[0]) { - std::string scope_str = scope; - lldb::ValueType var_scope = eValueTypeInvalid; - // Convert scope_str to be all lowercase; - std::transform (scope_str.begin(), scope_str.end(), scope_str.begin(), ::tolower); - - if (scope_str.compare ("global") == 0) - var_scope = eValueTypeVariableGlobal; - else if (scope_str.compare ("local") == 0) - var_scope = eValueTypeVariableLocal; - else if (scope_str.compare ("parameter") == 0) - var_scope = eValueTypeVariableArgument; - - if (var_scope != eValueTypeInvalid) + + switch (value_type) { - lldb_private::VariableList *variable_list = m_opaque_sp->GetVariableList(true); + case eValueTypeVariableGlobal: // global variable + case eValueTypeVariableStatic: // static variable + case eValueTypeVariableArgument: // function argument variables + case eValueTypeVariableLocal: // function local variables + { + VariableList *variable_list = m_opaque_sp->GetVariableList(true); - SymbolContext sc (m_opaque_sp->GetSymbolContext (eSymbolContextBlock)); + SymbolContext sc (m_opaque_sp->GetSymbolContext (eSymbolContextBlock)); - const bool can_create = true; - const bool get_parent_variables = true; - const bool stop_if_block_is_inlined_function = true; + const bool can_create = true; + const bool get_parent_variables = true; + const bool stop_if_block_is_inlined_function = true; + + if (sc.block && sc.block->AppendVariables (can_create, + get_parent_variables, + stop_if_block_is_inlined_function, + variable_list)) + { + ConstString const_name(name); + const uint32_t num_variables = variable_list->GetSize(); + for (uint32_t i = 0; i < num_variables; ++i) + { + VariableSP variable_sp (variable_list->GetVariableAtIndex(i)); + if (variable_sp && + variable_sp->GetScope() == value_type && + variable_sp->GetName() == const_name) + { + *sb_value = ValueObjectSP (new ValueObjectVariable (variable_sp)); + break; + } + } + } + } + break; + + case eValueTypeRegister: // stack frame register value + { + RegisterContext *reg_ctx = m_opaque_sp->GetRegisterContext(); + if (reg_ctx) + { + const uint32_t num_regs = reg_ctx->GetRegisterCount(); + for (uint32_t reg_idx = 0; reg_idx < num_regs; ++reg_idx) + { + const RegisterInfo *reg_info = reg_ctx->GetRegisterInfoAtIndex (reg_idx); + if (reg_info && + ((reg_info->name && strcasecmp (reg_info->name, name) == 0) || + (reg_info->alt_name && strcasecmp (reg_info->alt_name, name) == 0))) + { + *sb_value = ValueObjectSP (new ValueObjectRegister (NULL, reg_ctx, reg_idx)); + } + } + } + } + break; - if (sc.block && sc.block->AppendVariables (can_create, - get_parent_variables, - stop_if_block_is_inlined_function, - variable_list)) + case eValueTypeRegisterSet: // A collection of stack frame register values { - lldb_private::ConstString const_var_name(var_name); - const uint32_t num_variables = variable_list->GetSize(); - for (uint32_t i = 0; i < num_variables; ++i) + RegisterContext *reg_ctx = m_opaque_sp->GetRegisterContext(); + if (reg_ctx) { - lldb::VariableSP curr_var_sp (variable_list->GetVariableAtIndex(i)); - if (curr_var_sp && curr_var_sp->GetScope() == var_scope && - curr_var_sp->GetName() == const_var_name) + const uint32_t num_sets = reg_ctx->GetRegisterSetCount(); + for (uint32_t set_idx = 0; set_idx < num_sets; ++set_idx) { - var_sp = curr_var_sp; - break; + const RegisterSet *reg_set = reg_ctx->GetRegisterSet (set_idx); + if (reg_set && + ((reg_set->name && strcasecmp (reg_set->name, name) == 0) || + (reg_set->short_name && strcasecmp (reg_set->short_name, name) == 0))) + { + *sb_value = ValueObjectSP (new ValueObjectRegisterSet (NULL, reg_ctx, set_idx)); + } } } } + break; + + case eValueTypeConstResult: // constant result variables + { + ConstString const_name(name); + ClangExpressionVariableSP expr_var_sp (m_opaque_sp->GetThread().GetProcess().GetTarget().GetPersistentVariables().GetVariable (const_name)); + if (expr_var_sp) + *sb_value = expr_var_sp->GetValueObject(); + } + break; + + default: + break; } } - SBValue sb_value; - if (var_sp) - *sb_value = ValueObjectSP (new ValueObjectVariable (var_sp)); - - LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); + LogSP log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); if (log) - log->Printf ("SBFrame(%p)::LookupVarInScope (name=\"%s\", scope=%s) => SBValue(%p)", - m_opaque_sp.get(), var_name, scope, sb_value.get()); + log->Printf ("SBFrame(%p)::FindVariableInScope (name=\"%s\", value_type=%i) => SBValue(%p)", + m_opaque_sp.get(), name, value_type, sb_value.get()); return sb_value; @@ -430,7 +475,7 @@ SBThread SBFrame::GetThread () const { - LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); + LogSP log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); SBThread sb_thread; if (m_opaque_sp) @@ -453,7 +498,7 @@ const char *disassembly = NULL; if (m_opaque_sp) disassembly = m_opaque_sp->Disassemble(); - LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); + LogSP log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); if (log) log->Printf ("SBFrame(%p)::Disassemble () => %s", m_opaque_sp.get(), disassembly); @@ -468,7 +513,7 @@ bool statics, bool in_scope_only) { - LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); + LogSP log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); if (log) log->Printf ("SBFrame(%p)::GetVariables (arguments=%i, locals=%i, statics=%i, in_scope_only=%i)", @@ -534,10 +579,10 @@ return value_list; } -lldb::SBValueList +SBValueList SBFrame::GetRegisters () { - LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); + LogSP log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); SBValueList value_list; if (m_opaque_sp) @@ -573,20 +618,20 @@ return true; } -lldb::SBValue +SBValue SBFrame::EvaluateExpression (const char *expr) { - LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); + LogSP log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); - LogSP expr_log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS)); + LogSP expr_log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS)); - lldb::SBValue expr_result; + SBValue expr_result; if (log) log->Printf ("SBFrame(%p)::EvaluateExpression (expr=\"%s\")...", m_opaque_sp.get(), expr); if (m_opaque_sp) { - lldb::ExecutionResults exe_results; + ExecutionResults exe_results; const bool unwind_on_error = true; exe_results = m_opaque_sp->GetThread().GetProcess().GetTarget().EvaluateExpression(expr, m_opaque_sp.get(), unwind_on_error, *expr_result); From ctice at apple.com Tue Dec 14 12:51:39 2010 From: ctice at apple.com (Caroline Tice) Date: Tue, 14 Dec 2010 18:51:39 -0000 Subject: [Lldb-commits] [lldb] r121779 - in /lldb/trunk/source: Commands/CommandObjectCommands.cpp Interpreter/CommandInterpreter.cpp Message-ID: <20101214185139.4F3992A6C12D@llvm.org> Author: ctice Date: Tue Dec 14 12:51:39 2010 New Revision: 121779 URL: http://llvm.org/viewvc/llvm-project?rev=121779&view=rev Log: Fix small bugs: - Make sure cmd_obj & cmd_obj_sp contain a valid objects before attempting to dereference, in CommandObjectCommandsAlias::Execute and CommandInterpreter::HandleCommand. - Modify CommandInterpreter::GetCommandSPExact to properly handle multi-word command inputs. Modified: lldb/trunk/source/Commands/CommandObjectCommands.cpp lldb/trunk/source/Interpreter/CommandInterpreter.cpp Modified: lldb/trunk/source/Commands/CommandObjectCommands.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectCommands.cpp?rev=121779&r1=121778&r2=121779&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectCommands.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectCommands.cpp Tue Dec 14 12:51:39 2010 @@ -359,10 +359,18 @@ } CommandObjectSP cmd_obj_sp = m_interpreter.GetCommandSPExact (cmd_obj->GetCommandName(), false); - m_interpreter.AddAlias (alias_command.c_str(), cmd_obj_sp); - if (option_arg_vector->size() > 0) - m_interpreter.AddOrReplaceAliasOptions (alias_command.c_str(), option_arg_vector_sp); - result.SetStatus (eReturnStatusSuccessFinishNoResult); + if (cmd_obj_sp) + { + m_interpreter.AddAlias (alias_command.c_str(), cmd_obj_sp); + if (option_arg_vector->size() > 0) + m_interpreter.AddOrReplaceAliasOptions (alias_command.c_str(), option_arg_vector_sp); + result.SetStatus (eReturnStatusSuccessFinishNoResult); + } + else + { + result.AppendError ("Unable to create requested alias.\n"); + result.SetStatus (eReturnStatusFailed); + } } return result.Succeeded(); } Modified: lldb/trunk/source/Interpreter/CommandInterpreter.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Interpreter/CommandInterpreter.cpp?rev=121779&r1=121778&r2=121779&view=diff ============================================================================== --- lldb/trunk/source/Interpreter/CommandInterpreter.cpp (original) +++ lldb/trunk/source/Interpreter/CommandInterpreter.cpp Tue Dec 14 12:51:39 2010 @@ -314,7 +314,45 @@ CommandObjectSP CommandInterpreter::GetCommandSPExact (const char *cmd_cstr, bool include_aliases) { - return GetCommandSP(cmd_cstr, include_aliases, true, NULL); + Args cmd_words (cmd_cstr); // Break up the command string into words, in case it's a multi-word command. + CommandObjectSP ret_val; // Possibly empty return value. + + if (cmd_cstr == NULL) + return ret_val; + + if (cmd_words.GetArgumentCount() == 1) + return GetCommandSP(cmd_cstr, include_aliases, true, NULL); + else + { + // We have a multi-word command (seemingly), so we need to do more work. + // First, get the cmd_obj_sp for the first word in the command. + CommandObjectSP cmd_obj_sp = GetCommandSP (cmd_words.GetArgumentAtIndex (0), include_aliases, true, NULL); + if (cmd_obj_sp.get() != NULL) + { + // Loop through the rest of the words in the command (everything passed in was supposed to be part of a + // command name), and find the appropriate sub-command SP for each command word.... + size_t end = cmd_words.GetArgumentCount(); + for (size_t j= 1; j < end; ++j) + { + if (cmd_obj_sp->IsMultiwordObject()) + { + cmd_obj_sp = ((CommandObjectMultiword *) cmd_obj_sp.get())->GetSubcommandSP + (cmd_words.GetArgumentAtIndex (j)); + if (cmd_obj_sp.get() == NULL) + // The sub-command name was invalid. Fail and return the empty 'ret_val'. + return ret_val; + } + else + // We have more words in the command name, but we don't have a multiword object. Fail and return + // empty 'ret_val'. + return ret_val; + } + // We successfully looped through all the command words and got valid command objects for them. Assign the + // last object retrieved to 'ret_val'. + ret_val = cmd_obj_sp; + } + } + return ret_val; } CommandObject * @@ -720,8 +758,10 @@ BuildAliasResult (next_word.c_str(), command_string, alias_result, cmd_obj, result); revised_command_line.Printf ("%s", alias_result.c_str()); if (cmd_obj) + { wants_raw_input = cmd_obj->WantsRawCommandString (); - actual_cmd_name_len = strlen (cmd_obj->GetCommandName()); + actual_cmd_name_len = strlen (cmd_obj->GetCommandName()); + } } else if (!cmd_obj) { From johnny.chen at apple.com Tue Dec 14 12:59:15 2010 From: johnny.chen at apple.com (Johnny Chen) Date: Tue, 14 Dec 2010 18:59:15 -0000 Subject: [Lldb-commits] [lldb] r121782 - in /lldb/trunk/test: array_types/TestArrayTypes.py bitfields/TestBitfields.py breakpoint_conditions/TestBreakpointConditions.py class_static/TestStaticVariables.py conditional_break/TestConditionalBreak.py objc-stepping/TestObjCStepping.py Message-ID: <20101214185915.CE2492A6C12D@llvm.org> Author: johnny Date: Tue Dec 14 12:59:15 2010 New Revision: 121782 URL: http://llvm.org/viewvc/llvm-project?rev=121782&view=rev Log: Modify test cases to accomodate Python API change: o SBFrame.LookupVar -> FindVariable o SBFrame.LookupVarInScope -> FindValue Modified: lldb/trunk/test/array_types/TestArrayTypes.py lldb/trunk/test/bitfields/TestBitfields.py lldb/trunk/test/breakpoint_conditions/TestBreakpointConditions.py lldb/trunk/test/class_static/TestStaticVariables.py lldb/trunk/test/conditional_break/TestConditionalBreak.py lldb/trunk/test/objc-stepping/TestObjCStepping.py Modified: lldb/trunk/test/array_types/TestArrayTypes.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/array_types/TestArrayTypes.py?rev=121782&r1=121781&r2=121782&view=diff ============================================================================== --- lldb/trunk/test/array_types/TestArrayTypes.py (original) +++ lldb/trunk/test/array_types/TestArrayTypes.py Tue Dec 14 12:59:15 2010 @@ -153,7 +153,7 @@ # Lookup the "strings" string array variable and sanity check its print # representation. - variable = frame.LookupVar("strings") + variable = frame.FindVariable("strings") var = repr(variable) self.expect(var, "Variable for 'strings' looks good with correct name", exe=False, substrs = ["name: '%s'" % variable.GetName()]) @@ -167,7 +167,7 @@ 'strings[3] == "Guten Tag"') # Lookup the "char_16" char array variable. - variable = frame.LookupVar("char_16") + variable = frame.FindVariable("char_16") self.DebugSBValue(frame, variable) self.assertTrue(variable.GetNumChildren() == 16, "Variable 'char_16' should have 16 children") @@ -176,7 +176,7 @@ # Notice the pattern of int(child0_2.GetValue(frame), 0). We pass a # base of 0 so that the proper radix is determined based on the contents # of the string. Same applies to long(). - variable = frame.LookupVar("ushort_matrix") + variable = frame.FindVariable("ushort_matrix") self.DebugSBValue(frame, variable) self.assertTrue(variable.GetNumChildren() == 2, "Variable 'ushort_matrix' should have 2 children") @@ -190,7 +190,7 @@ "ushort_matrix[0][2] == 3") # Lookup the "long_6" char array variable. - variable = frame.LookupVar("long_6") + variable = frame.FindVariable("long_6") self.DebugSBValue(frame, variable) self.assertTrue(variable.GetNumChildren() == 6, "Variable 'long_6' should have 6 children") @@ -205,7 +205,7 @@ self.assertTrue(variable.GetValueType() == lldb.eValueTypeVariableLocal, "Variable 'long_6' should have '%s' value type." % ValueTypeString(lldb.eValueTypeVariableLocal)) - argc = frame.LookupVar("argc") + argc = frame.FindVariable("argc") self.DebugSBValue(frame, argc) self.assertTrue(argc.GetValueType() == lldb.eValueTypeVariableArgument, "Variable 'argc' should have '%s' value type." % Modified: lldb/trunk/test/bitfields/TestBitfields.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/bitfields/TestBitfields.py?rev=121782&r1=121781&r2=121782&view=diff ============================================================================== --- lldb/trunk/test/bitfields/TestBitfields.py (original) +++ lldb/trunk/test/bitfields/TestBitfields.py Tue Dec 14 12:59:15 2010 @@ -109,7 +109,7 @@ # Lookup the "bits" variable which contains 8 bitfields. frame = thread.GetFrameAtIndex(0) - bits = frame.LookupVar("bits") + bits = frame.FindVariable("bits") self.DebugSBValue(frame, bits) self.assertTrue(bits.GetTypeName() == "Bits" and bits.GetNumChildren() == 8 and Modified: lldb/trunk/test/breakpoint_conditions/TestBreakpointConditions.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/breakpoint_conditions/TestBreakpointConditions.py?rev=121782&r1=121781&r2=121782&view=diff ============================================================================== --- lldb/trunk/test/breakpoint_conditions/TestBreakpointConditions.py (original) +++ lldb/trunk/test/breakpoint_conditions/TestBreakpointConditions.py Tue Dec 14 12:59:15 2010 @@ -133,7 +133,7 @@ # Frame #0 should be on self.line1 and the break condition should hold. frame0 = self.process.GetThreadAtIndex(0).GetFrameAtIndex(0) - var = frame0.LookupVarInScope('val', 'parameter') + var = frame0.FindValue('val', lldb.eValueTypeVariableArgument) self.assertTrue(frame0.GetLineEntry().GetLine() == self.line1 and var.GetValue(frame0) == '3') Modified: lldb/trunk/test/class_static/TestStaticVariables.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/class_static/TestStaticVariables.py?rev=121782&r1=121781&r2=121782&view=diff ============================================================================== --- lldb/trunk/test/class_static/TestStaticVariables.py (original) +++ lldb/trunk/test/class_static/TestStaticVariables.py Tue Dec 14 12:59:15 2010 @@ -119,21 +119,21 @@ self.assertTrue(child1_x.GetTypeName() == 'int' and child1_x.GetValue(frame) == '11') - # SBFrame.LookupVarInScope() should also work. - val = frame.LookupVarInScope("A::g_points", "global") + # SBFrame.FindValue() should also work. + val = frame.FindValue("A::g_points", lldb.eValueTypeVariableGlobal) self.DebugSBValue(frame, val) self.assertTrue(val.GetName() == 'A::g_points') # Also exercise the "parameter" and "local" scopes while we are at it. - val = frame.LookupVarInScope("argc", "parameter") + val = frame.FindValue("argc", lldb.eValueTypeVariableArgument) self.DebugSBValue(frame, val) self.assertTrue(val.GetName() == 'argc') - val = frame.LookupVarInScope("argv", "parameter") + val = frame.FindValue("argv", lldb.eValueTypeVariableArgument) self.DebugSBValue(frame, val) self.assertTrue(val.GetName() == 'argv') - val = frame.LookupVarInScope("hello_world", "local") + val = frame.FindValue("hello_world", lldb.eValueTypeVariableLocal) self.DebugSBValue(frame, val) self.assertTrue(val.GetName() == 'hello_world') Modified: lldb/trunk/test/conditional_break/TestConditionalBreak.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/conditional_break/TestConditionalBreak.py?rev=121782&r1=121781&r2=121782&view=diff ============================================================================== --- lldb/trunk/test/conditional_break/TestConditionalBreak.py (original) +++ lldb/trunk/test/conditional_break/TestConditionalBreak.py Tue Dec 14 12:59:15 2010 @@ -89,7 +89,7 @@ "Immediate caller a() at main.c:%d" % line) # And the local variable 'val' should have a value of (int) 3. - val = frame1.LookupVar("val") + val = frame1.FindVariable("val") self.assertTrue(val.GetTypeName() == "int", "'val' has int type") self.assertTrue(val.GetValue(frame1) == "3", "'val' has a value of 3") break Modified: lldb/trunk/test/objc-stepping/TestObjCStepping.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/objc-stepping/TestObjCStepping.py?rev=121782&r1=121781&r2=121782&view=diff ============================================================================== --- lldb/trunk/test/objc-stepping/TestObjCStepping.py (original) +++ lldb/trunk/test/objc-stepping/TestObjCStepping.py Tue Dec 14 12:59:15 2010 @@ -80,7 +80,7 @@ line_number = thread.GetFrameAtIndex(0).GetLineEntry().GetLine() self.assertTrue (line_number == self.line1, "Hit the first breakpoint.") - mySource = thread.GetFrameAtIndex(0).LookupVar("mySource") + mySource = thread.GetFrameAtIndex(0).FindVariable("mySource") self.assertTrue(mySource.IsValid(), "Found mySource local variable.") mySource_isa = mySource.GetChildMemberWithName ("isa") self.assertTrue(mySource_isa.IsValid(), "Found mySource->isa local variable.") From jingham at apple.com Tue Dec 14 13:56:02 2010 From: jingham at apple.com (Jim Ingham) Date: Tue, 14 Dec 2010 19:56:02 -0000 Subject: [Lldb-commits] [lldb] r121785 - /lldb/trunk/source/Interpreter/CommandInterpreter.cpp Message-ID: <20101214195602.173BF2A6C12D@llvm.org> Author: jingham Date: Tue Dec 14 13:56:01 2010 New Revision: 121785 URL: http://llvm.org/viewvc/llvm-project?rev=121785&view=rev Log: Fix the completion of "fr " and the like. Modified: lldb/trunk/source/Interpreter/CommandInterpreter.cpp Modified: lldb/trunk/source/Interpreter/CommandInterpreter.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Interpreter/CommandInterpreter.cpp?rev=121785&r1=121784&r2=121785&view=diff ============================================================================== --- lldb/trunk/source/Interpreter/CommandInterpreter.cpp (original) +++ lldb/trunk/source/Interpreter/CommandInterpreter.cpp Tue Dec 14 13:56:01 2010 @@ -1007,6 +1007,23 @@ cursor_char_position = 0; else cursor_char_position = strlen (partial_parsed_line.GetArgumentAtIndex(cursor_index)); + + if (cursor > current_line && cursor[-1] == ' ') + { + // We are just after a space. If we are in an argument, then we will continue + // parsing, but if we are between arguments, then we have to complete whatever the next + // element would be. + // We can distinguish the two cases because if we are in an argument (e.g. because the space is + // protected by a quote) then the space will also be in the parsed argument... + + const char *current_elem = partial_parsed_line.GetArgumentAtIndex(cursor_index); + if (cursor_char_position == 0 || current_elem[cursor_char_position - 1] != ' ') + { + parsed_line.InsertArgumentAtIndex(cursor_index + 1, "", '"'); + cursor_index++; + cursor_char_position = 0; + } + } int num_command_matches; From johnny.chen at apple.com Tue Dec 14 16:26:34 2010 From: johnny.chen at apple.com (Johnny Chen) Date: Tue, 14 Dec 2010 22:26:34 -0000 Subject: [Lldb-commits] [lldb] r121796 - in /lldb/trunk/test/load_unload: TestLoadUnload.py d.c main.c Message-ID: <20101214222634.A4DB62A6C12D@llvm.org> Author: johnny Date: Tue Dec 14 16:26:34 2010 New Revision: 121796 URL: http://llvm.org/viewvc/llvm-project?rev=121796&view=rev Log: Added a test case LoadUnloadTestCase.test_dyld_library_path to test launching a process linked with a dylib which has been relocated by specifying the DYLD_LIBRARY_PATH environment variable. Test that the function name breakpoint defined in the dylib is resolved. Modified: lldb/trunk/test/load_unload/TestLoadUnload.py lldb/trunk/test/load_unload/d.c lldb/trunk/test/load_unload/main.c Modified: lldb/trunk/test/load_unload/TestLoadUnload.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/load_unload/TestLoadUnload.py?rev=121796&r1=121795&r2=121796&view=diff ============================================================================== --- lldb/trunk/test/load_unload/TestLoadUnload.py (original) +++ lldb/trunk/test/load_unload/TestLoadUnload.py Tue Dec 14 16:26:34 2010 @@ -1,5 +1,5 @@ """ -Test that breakpoint by symbol name works correctly dlopen'ing a dynamic lib. +Test that breakpoint by symbol name works correctly with dynamic libs. """ import os, time @@ -18,6 +18,62 @@ # Find the line number to break for main.cpp. self.line = line_number('main.c', '// Set break point at this line for test_lldb_process_load_and_unload_commands().') + self.line_d_function = line_number('d.c', + '// Find this line number within d_dunction().') + + def test_dyld_library_path(self): + """Test DYLD_LIBRARY_PATH after moving libd.dylib, which defines d_function, somewhere else.""" + + # Invoke the default build rule. + self.buildDefault() + + if sys.platform.startswith("darwin"): + dylibName = 'libd.dylib' + dsymName = 'libd.dylib.dSYM' + dylibPath = 'DYLD_LIBRARY_PATH' + + # Now let's move the dynamic library to a different directory than $CWD. + + # The directory to relocate the dynamic library and its debugging info. + new_dir = os.path.join(os.getcwd(), "dyld_path") + + # This is the function to remove the dyld_path directory after the test. + def remove_dyld_path(): + import shutil + shutil.rmtree(new_dir) + + old_dylib = os.path.join(os.getcwd(), dylibName) + new_dylib = os.path.join(new_dir, dylibName) + old_dSYM = os.path.join(os.getcwd(), dsymName) + new_dSYM = os.path.join(new_dir, dsymName) + #system(["ls", "-lR", "."]) + os.mkdir(new_dir) + os.rename(old_dylib, new_dylib) + if dsymName: + os.rename(old_dSYM, new_dSYM) + self.addTearDownHook(remove_dyld_path) + #system(["ls", "-lR", "."]) + + # With libd.dylib moved, a.out run should fail. + exe = os.path.join(os.getcwd(), "a.out") + self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) + # Set breakpoint by function name d_function. + self.expect("breakpoint set -n d_function", BREAKPOINT_CREATED, + substrs = ["Breakpoint created", + "name = 'd_function'", + "locations = 0 (pending)"]) + self.runCmd("run") + self.expect("process status", "Not expected to hit the d_function breakpoint", + matching=False, + substrs = ["stop reason = breakpoint"]) + # Kill the inferior process. + self.runCmd("process kill") + + # Try again with the DYLD_LIBRARY_PATH environment variable properly set. + os.environ[dylibPath] = new_dir + self.runCmd("run") + self.expect("thread backtrace", STOPPED_DUE_TO_BREAKPOINT, + patterns = ["frame #0.*d_function.*at d.c:%d" % self.line_d_function]) def test_lldb_process_load_and_unload_commands(self): """Test that lldb process load/unload command work correctly.""" @@ -68,7 +124,6 @@ self.runCmd("process continue") - def test_load_unload(self): """Test breakpoint by name works correctly with dlopen'ing.""" Modified: lldb/trunk/test/load_unload/d.c URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/load_unload/d.c?rev=121796&r1=121795&r2=121796&view=diff ============================================================================== --- lldb/trunk/test/load_unload/d.c (original) +++ lldb/trunk/test/load_unload/d.c Tue Dec 14 16:26:34 2010 @@ -9,5 +9,5 @@ int d_function () { - return 700; + return 700; // Find this line number within d_dunction(). } Modified: lldb/trunk/test/load_unload/main.c URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/load_unload/main.c?rev=121796&r1=121795&r2=121796&view=diff ============================================================================== --- lldb/trunk/test/load_unload/main.c (original) +++ lldb/trunk/test/load_unload/main.c Tue Dec 14 16:26:34 2010 @@ -68,5 +68,8 @@ printf ("Second time around, got: %d\n", a_function ()); dlclose (a_dylib_handle); + int d_function(void); + printf ("d_function returns: %d\n", d_function()); + return 0; } From johnny.chen at apple.com Tue Dec 14 17:13:03 2010 From: johnny.chen at apple.com (Johnny Chen) Date: Tue, 14 Dec 2010 23:13:03 -0000 Subject: [Lldb-commits] [lldb] r121802 - in /lldb/trunk/test: lldbtest.py load_unload/TestLoadUnload.py Message-ID: <20101214231303.4838C2A6C12C@llvm.org> Author: johnny Date: Tue Dec 14 17:13:03 2010 New Revision: 121802 URL: http://llvm.org/viewvc/llvm-project?rev=121802&view=rev Log: Execute the test case teardown hooks in a LIFO (last in, first out) order. ALso add a teardown hook to the LoadUnloadTestCase.test_dyld_library_path() test case to have it restore the DYLD_LIBRARY_PATH environment variable. Modified: lldb/trunk/test/lldbtest.py lldb/trunk/test/load_unload/TestLoadUnload.py Modified: lldb/trunk/test/lldbtest.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/lldbtest.py?rev=121802&r1=121801&r2=121802&view=diff ============================================================================== --- lldb/trunk/test/lldbtest.py (original) +++ lldb/trunk/test/lldbtest.py Tue Dec 14 17:13:03 2010 @@ -648,7 +648,7 @@ #traceback.print_stack() # Check and run any hook functions. - for hook in self.hooks: + for hook in reversed(self.hooks): with recording(self, traceAlways) as sbuf: print >> sbuf, "Executing tearDown hook:", getsource_if_available(hook) hook() Modified: lldb/trunk/test/load_unload/TestLoadUnload.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/load_unload/TestLoadUnload.py?rev=121802&r1=121801&r2=121802&view=diff ============================================================================== --- lldb/trunk/test/load_unload/TestLoadUnload.py (original) +++ lldb/trunk/test/load_unload/TestLoadUnload.py Tue Dec 14 17:13:03 2010 @@ -38,7 +38,7 @@ new_dir = os.path.join(os.getcwd(), "dyld_path") # This is the function to remove the dyld_path directory after the test. - def remove_dyld_path(): + def remove_dyld_dir(): import shutil shutil.rmtree(new_dir) @@ -51,7 +51,7 @@ os.rename(old_dylib, new_dylib) if dsymName: os.rename(old_dSYM, new_dSYM) - self.addTearDownHook(remove_dyld_path) + self.addTearDownHook(remove_dyld_dir) #system(["ls", "-lR", "."]) # With libd.dylib moved, a.out run should fail. @@ -71,6 +71,7 @@ # Try again with the DYLD_LIBRARY_PATH environment variable properly set. os.environ[dylibPath] = new_dir + self.addTearDownHook(lambda: os.environ.pop(dylibPath)) self.runCmd("run") self.expect("thread backtrace", STOPPED_DUE_TO_BREAKPOINT, patterns = ["frame #0.*d_function.*at d.c:%d" % self.line_d_function]) From gclayton at apple.com Tue Dec 14 17:13:52 2010 From: gclayton at apple.com (Greg Clayton) Date: Tue, 14 Dec 2010 23:13:52 -0000 Subject: [Lldb-commits] [lldb] r121803 - in /lldb/trunk: lldb.xcodeproj/project.pbxproj source/Commands/CommandObjectCall.cpp source/Commands/CommandObjectCall.h Message-ID: <20101214231352.2F3B92A6C12C@llvm.org> Author: gclayton Date: Tue Dec 14 17:13:51 2010 New Revision: 121803 URL: http://llvm.org/viewvc/llvm-project?rev=121803&view=rev Log: Removed unused files that were out of date and causing issues with the linux build. Removed: lldb/trunk/source/Commands/CommandObjectCall.cpp lldb/trunk/source/Commands/CommandObjectCall.h Modified: lldb/trunk/lldb.xcodeproj/project.pbxproj Modified: lldb/trunk/lldb.xcodeproj/project.pbxproj URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/lldb.xcodeproj/project.pbxproj?rev=121803&r1=121802&r2=121803&view=diff ============================================================================== --- lldb/trunk/lldb.xcodeproj/project.pbxproj (original) +++ lldb/trunk/lldb.xcodeproj/project.pbxproj Tue Dec 14 17:13:51 2010 @@ -989,8 +989,6 @@ 4C98D3DB118FB96F00E575D0 /* RecordingMemoryManager.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = RecordingMemoryManager.cpp; path = source/Expression/RecordingMemoryManager.cpp; sourceTree = ""; }; 4C98D3E0118FB98F00E575D0 /* ClangFunction.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ClangFunction.h; path = include/lldb/Expression/ClangFunction.h; sourceTree = ""; }; 4C98D3E1118FB98F00E575D0 /* RecordingMemoryManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = RecordingMemoryManager.h; path = include/lldb/Expression/RecordingMemoryManager.h; sourceTree = ""; }; - 4C98D3E4118FB9B100E575D0 /* CommandObjectCall.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = CommandObjectCall.cpp; path = source/Commands/CommandObjectCall.cpp; sourceTree = ""; }; - 4C98D3E5118FB9B100E575D0 /* CommandObjectCall.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CommandObjectCall.h; path = source/Commands/CommandObjectCall.h; sourceTree = ""; }; 4CA9637911B6E99A00780E28 /* CommandObjectApropos.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = CommandObjectApropos.cpp; path = source/Commands/CommandObjectApropos.cpp; sourceTree = ""; }; 4CA9637A11B6E99A00780E28 /* CommandObjectApropos.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CommandObjectApropos.h; path = source/Commands/CommandObjectApropos.h; sourceTree = ""; }; 4CAFCE001101216B00CA63DB /* ThreadPlanRunToAddress.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ThreadPlanRunToAddress.h; path = include/lldb/Target/ThreadPlanRunToAddress.h; sourceTree = ""; }; @@ -1892,8 +1890,6 @@ 26BC7E2D10F1B84700F91463 /* CommandObjectBreakpoint.cpp */, 9A42976111861A9F00FE05CD /* CommandObjectBreakpointCommand.h */, 9A42976211861AA600FE05CD /* CommandObjectBreakpointCommand.cpp */, - 4C98D3E5118FB9B100E575D0 /* CommandObjectCall.h */, - 4C98D3E4118FB9B100E575D0 /* CommandObjectCall.cpp */, 4C5DBBC711E3FEC60035160F /* CommandObjectCommands.h */, 4C5DBBC611E3FEC60035160F /* CommandObjectCommands.cpp */, 26BC7D1710F1B76300F91463 /* CommandObjectDisassemble.h */, @@ -2459,7 +2455,6 @@ isa = PBXProject; buildConfigurationList = 1DEB91EF08733DB70010E9CD /* Build configuration list for PBXProject "lldb" */; compatibilityVersion = "Xcode 3.1"; - developmentRegion = English; hasScannedForEncodings = 1; knownRegions = ( en, Removed: lldb/trunk/source/Commands/CommandObjectCall.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectCall.cpp?rev=121802&view=auto ============================================================================== --- lldb/trunk/source/Commands/CommandObjectCall.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectCall.cpp (removed) @@ -1,341 +0,0 @@ -//===-- CommandObjectCall.cpp -----------------------------------*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -#include "CommandObjectCall.h" - -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes -#include "lldb/Interpreter/Args.h" -#include "lldb/Core/Value.h" -#include "lldb/Expression/ClangExpression.h" -#include "lldb/Expression/ClangExpressionVariable.h" -#include "lldb/Expression/ClangFunction.h" -#include "lldb/Host/Host.h" -#include "lldb/Interpreter/CommandInterpreter.h" -#include "lldb/Core/Debugger.h" -#include "lldb/Interpreter/CommandReturnObject.h" -#include "lldb/Symbol/ObjectFile.h" -#include "lldb/Symbol/Variable.h" -#include "lldb/Target/Process.h" -#include "lldb/Target/Target.h" -#include "lldb/Target/StackFrame.h" - -using namespace lldb; -using namespace lldb_private; - -// This command is a toy. I'm just using it to have a way to construct the arguments to -// calling functions. -// - -CommandObjectCall::CommandOptions::CommandOptions () : - Options() -{ - // Keep only one place to reset the values to their defaults - ResetOptionValues(); -} - - -CommandObjectCall::CommandOptions::~CommandOptions () -{ -} - -Error -CommandObjectCall::CommandOptions::SetOptionValue (int option_idx, const char *option_arg) -{ - Error error; - - char short_option = (char) m_getopt_table[option_idx].val; - - switch (short_option) - { - case 'l': - if (language.SetLanguageFromCString (option_arg) == false) - { - error.SetErrorStringWithFormat("Invalid language option argument '%s'.\n", option_arg); - } - break; - - case 'g': - debug = true; - break; - - case 'f': - error = Args::StringToFormat(option_arg,format); - break; - - case 'n': - noexecute = true; - break; - - case 'a': - use_abi = true; - break; - - default: - error.SetErrorStringWithFormat("Invalid short option character '%c'.\n", short_option); - break; - } - - return error; -} - -void -CommandObjectCall::CommandOptions::ResetOptionValues () -{ - Options::ResetOptionValues(); - language.Clear(); - debug = false; - format = eFormatDefault; - show_types = true; - show_summary = true; - noexecute = false; - use_abi = false; -} - -const lldb::OptionDefinition* -CommandObjectCall::CommandOptions::GetDefinitions () -{ - return g_option_table; -} - -CommandObjectCall::CommandObjectCall () : - CommandObject ( - "call", - "Call a function.", - //"call [[ ] ... ] []", - NULL, - eFlagProcessMustBeLaunched | eFlagProcessMustBePaused) -{ - CommandArgumentEntry arg1; - CommandArgumentEntry arg2; - CommandArgumentEntry arg3; - CommandArgumentData return_type_arg; - CommandArgumentData function_name_arg; - CommandArgumentData arg_type_arg; - CommandArgumentData arg_value_arg; - - // Define the first (and only) variant of this arg. - return_type_arg.arg_type = eArgTypeType; - return_type_arg.arg_repetition = eArgRepeatPlain; - - arg1.push_back (return_type_arg); - - function_name_arg.arg_type = eArgTypeFunctionName; - function_name_arg.arg_repetition = eArgTypePlain; - - arg2.push_back (function_name_arg); - - arg_type_arg.arg_type = eArgTypeArgType; - arg_type_arg.arg_repetition = eArgRepeatPairRangeOptional; - - arg_value_arg.arg_type = eArgTypeValue; - arg_value_arg.arg_repetition = eArgRepeatPairRangeOptional; - - arg3.push_back (arg_type_arg); - arg3.push_back (arg_value_arg); - - // Push the data for the first argument into the m_arguments vector. - m_arguments.push_back (arg1); - m_arguments.push_back (arg2); - m_arguments.push_back (arg3); -} - -CommandObjectCall::~CommandObjectCall () -{ -} - -Options * -CommandObjectCall::GetOptions () -{ - return &m_options; -} - -bool -CommandObjectCall::Execute -( - Args &command, - CommandReturnObject &result -) -{ - ConstString target_triple; - int num_args = command.GetArgumentCount(); - - ExecutionContext exe_ctx(interpreter.GetDebugger().GetExecutionContext()); - if (exe_ctx.target) - exe_ctx.target->GetTargetTriple(target_triple); - - if (!target_triple) - target_triple = Host::GetTargetTriple (); - - if (exe_ctx.thread == NULL || exe_ctx.frame == NULL) - { - result.AppendError ("No currently selected thread and frame."); - result.SetStatus (eReturnStatusFailed); - return false; - } - - if (num_args < 2) - { - result.AppendErrorWithFormat ("Invalid usage, should be: %s.\n", GetSyntax()); - result.SetStatus (eReturnStatusFailed); - return false; - } - - if ((num_args - 2) %2 != 0) - { - result.AppendErrorWithFormat ("Invalid usage - unmatched args & types, should be: %s.\n", GetSyntax()); - result.SetStatus (eReturnStatusFailed); - return false; - } - - if (target_triple) - { - //const char *return_type = command.GetArgumentAtIndex(0); - const char *function_name = command.GetArgumentAtIndex(1); - // Look up the called function: - - Function *target_fn = NULL; - - SymbolContextList sc_list; - - exe_ctx.frame->GetSymbolContext(eSymbolContextEverything).FindFunctionsByName(ConstString(function_name), false, sc_list); - - if (sc_list.GetSize() > 0) - { - SymbolContext sc; - sc_list.GetContextAtIndex(0, sc); - target_fn = sc.function; - } - - // FIXME: If target_fn is NULL, we should look up the name as a symbol and use it and the provided - // return type. - - if (target_fn == NULL) - { - result.AppendErrorWithFormat ("Could not find function '%s'.\n", function_name); - result.SetStatus (eReturnStatusFailed); - return false; - } - - ValueList value_list; - // Okay, now parse arguments. For now we only accept basic types. - for (int i = 2; i < num_args; i+= 2) - { - const char *type_str = command.GetArgumentAtIndex(i); - const char *value_str = command.GetArgumentAtIndex(i + 1); - bool success; - if (strcmp(type_str, "int") == 0 - || strcmp(type_str, "int32_t") == 0) - { - value_list.PushValue(Value(Args::StringToSInt32(value_str, 0, 0, &success))); - } - else if (strcmp (type_str, "int64_t") == 0) - { - value_list.PushValue(Value(Args::StringToSInt64(value_str, 0, 0, &success))); - } - else if (strcmp(type_str, "uint") == 0 - || strcmp(type_str, "uint32_t") == 0) - { - value_list.PushValue(Value(Args::StringToUInt32(value_str, 0, 0, &success))); - } - else if (strcmp (type_str, "uint64_t") == 0) - { - value_list.PushValue(Value(Args::StringToUInt64(value_str, 0, 0, &success))); - } - else if (strcmp (type_str, "cstr") == 0) - { - Value val ((intptr_t)value_str); - val.SetValueType (Value::eValueTypeHostAddress); - - - void *cstr_type = exe_ctx.target->GetScratchClangASTContext()->GetCStringType(true); - val.SetContext (Value::eContextTypeClangType, cstr_type); - value_list.PushValue(val); - - success = true; - } - - if (!success) - { - result.AppendErrorWithFormat ("Could not convert value: '%s' to type '%s'.\n", value_str, type_str); - result.SetStatus (eReturnStatusFailed); - return false; - } - } - // Okay, we have the function and the argument list and the return type. Now make a ClangFunction object and - // run it: - - StreamString errors; - ClangFunction clang_fun (target_triple.GetCString(), *target_fn, exe_ctx.target->GetScratchClangASTContext(), value_list); - if (m_options.noexecute) - { - // Now write down the argument values for this call. - lldb::addr_t args_addr = LLDB_INVALID_ADDRESS; - if (!clang_fun.InsertFunction (exe_ctx, args_addr, errors)) - { - result.AppendErrorWithFormat("Error inserting function: '%s'.\n", errors.GetData()); - result.SetStatus (eReturnStatusFailed); - return false; - } - else - { - result.Succeeded(); - return true; - } - } - - Process::ExecutionResults return_status; - Value return_value; - - bool stop_others = true; - return_status = clang_fun.ExecuteFunction(exe_ctx, errors, stop_others, NULL, return_value); - - // Now figure out what to do with the return value. - if (return_status == Process::eExecutionSetupError) - { - result.AppendErrorWithFormat("Error setting up function execution: '%s'.\n", errors.GetData()); - result.SetStatus (eReturnStatusFailed); - return false; - } - else if (return_status != Process::eExecutionCompleted) - { - result.AppendWarningWithFormat("Interrupted while calling function: '%s'.\n", errors.GetData()); - result.SetStatus(eReturnStatusSuccessFinishNoResult); - return true; - } - else - { - // Now print out the result. - result.GetOutputStream().Printf("Return value: "); - return_value.Dump(&(result.GetOutputStream())); - result.Succeeded(); - } - - } - else - { - result.AppendError ("invalid target triple"); - result.SetStatus (eReturnStatusFailed); - } - return result.Succeeded(); -} - -lldb::OptionDefinition -CommandObjectCall::CommandOptions::g_option_table[] = -{ -{ LLDB_OPT_SET_1, false, "language", 'l', required_argument, NULL, 0, "[c|c++|objc|objc++]", "Sets the language to use when parsing the expression."}, -{ LLDB_OPT_SET_1, false, "format", 'f', required_argument, NULL, 0, "[ [bool|b] | [bin] | [char|c] | [oct|o] | [dec|i|d|u] | [hex|x] | [float|f] | [cstr|s] ]", "Specify the format that the expression output should use."}, -{ LLDB_OPT_SET_1, false, "debug", 'g', no_argument, NULL, 0, NULL, "Enable verbose debug logging of the expression parsing and evaluation."}, -{ LLDB_OPT_SET_1, false, "noexecute", 'n', no_argument, NULL, 0, "no execute", "Only JIT and copy the wrapper & arguments, but don't execute."}, -{ LLDB_OPT_SET_1, false, "use-abi", 'a', no_argument, NULL, 0, NULL, "Use the ABI instead of the JIT to marshall arguments."}, -{ 0, false, NULL, 0, 0, NULL, NULL, NULL, NULL } -}; - Removed: lldb/trunk/source/Commands/CommandObjectCall.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectCall.h?rev=121802&view=auto ============================================================================== --- lldb/trunk/source/Commands/CommandObjectCall.h (original) +++ lldb/trunk/source/Commands/CommandObjectCall.h (removed) @@ -1,82 +0,0 @@ -//===-- CommandObjectCall.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_CommandObjectCall_h_ -#define liblldb_CommandObjectCall_h_ - -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes -#include "lldb/Interpreter/CommandObject.h" -#include "lldb/Interpreter/Options.h" -#include "lldb/Core/Language.h" - -namespace lldb_private { - -class CommandObjectCall : public CommandObject -{ -public: - - class CommandOptions : public Options - { - public: - - CommandOptions (); - - virtual - ~CommandOptions (); - - virtual Error - SetOptionValue (int option_idx, const char *option_arg); - - void - ResetOptionValues (); - - const lldb::OptionDefinition* - GetDefinitions (); - - // Options table: Required for subclasses of Options. - - static lldb::OptionDefinition g_option_table[]; - Language language; - lldb::Encoding encoding; - lldb::Format format; - bool debug; - bool show_types; - bool show_summary; - bool noexecute; - bool use_abi; - }; - - CommandObjectCall (); - - virtual - ~CommandObjectCall (); - - virtual - Options * - GetOptions (); - - - virtual bool - Execute (Args& command, - CommandReturnObject &result); - - virtual bool - WantsRawCommandString() { return false; } - -protected: - - CommandOptions m_options; -}; - -} // namespace lldb_private - -#endif // liblldb_CommandObjectCall_h_ From gclayton at apple.com Tue Dec 14 17:19:04 2010 From: gclayton at apple.com (Greg Clayton) Date: Tue, 14 Dec 2010 23:19:04 -0000 Subject: [Lldb-commits] [lldb] r121804 - /lldb/trunk/docs/code-signing.txt Message-ID: <20101214231904.E0A902A6C12C@llvm.org> Author: gclayton Date: Tue Dec 14 17:19:04 2010 New Revision: 121804 URL: http://llvm.org/viewvc/llvm-project?rev=121804&view=rev Log: Updated the code signing instructions to be more complete. Modified: lldb/trunk/docs/code-signing.txt Modified: lldb/trunk/docs/code-signing.txt URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/docs/code-signing.txt?rev=121804&r1=121803&r2=121804&view=diff ============================================================================== --- lldb/trunk/docs/code-signing.txt (original) +++ lldb/trunk/docs/code-signing.txt Tue Dec 14 17:19:04 2010 @@ -43,4 +43,10 @@ sudo security add-trust -d -r trustRoot -p basic -p codeSign -k /Library/Keychains/System.keychain ~/Desktop/lldb_codesign.cer +- Right click on the "lldb_codesign" certificate in the "System" keychain (NOT + "login", but the one in "System"), and select "Delete" to delete it from + the "System" keychain. +- Reboot +- Clean and rebuild lldb and you should be able to debug. + That should do it. From gclayton at apple.com Tue Dec 14 17:43:15 2010 From: gclayton at apple.com (Greg Clayton) Date: Tue, 14 Dec 2010 23:43:15 -0000 Subject: [Lldb-commits] [lldb] r121810 - /lldb/trunk/source/Plugins/SymbolFile/DWARF/LogChannelDWARF.cpp Message-ID: <20101214234315.502AF2A6C12C@llvm.org> Author: gclayton Date: Tue Dec 14 17:43:15 2010 New Revision: 121810 URL: http://llvm.org/viewvc/llvm-project?rev=121810&view=rev Log: Fixed a crasher in the DWARF log channel code. Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/LogChannelDWARF.cpp Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/LogChannelDWARF.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/LogChannelDWARF.cpp?rev=121810&r1=121809&r2=121810&view=diff ============================================================================== --- lldb/trunk/source/Plugins/SymbolFile/DWARF/LogChannelDWARF.cpp (original) +++ lldb/trunk/source/Plugins/SymbolFile/DWARF/LogChannelDWARF.cpp Tue Dec 14 17:43:15 2010 @@ -122,6 +122,9 @@ void LogChannelDWARF::Disable (Args &categories, Stream *feedback_strm) { + if (!m_log_sp) + return; + g_log_channel = this; uint32_t flag_bits = m_log_sp->GetMask().Get(); const size_t argc = categories.GetArgumentCount(); From johnny.chen at apple.com Tue Dec 14 17:43:29 2010 From: johnny.chen at apple.com (Johnny Chen) Date: Tue, 14 Dec 2010 23:43:29 -0000 Subject: [Lldb-commits] [lldb] r121811 - in /lldb/trunk/test/settings: TestSettings.py main.cpp Message-ID: <20101214234329.97B172A6C12C@llvm.org> Author: johnny Date: Tue Dec 14 17:43:29 2010 New Revision: 121811 URL: http://llvm.org/viewvc/llvm-project?rev=121811&view=rev Log: Make the TestSettings.py test cases use different output filenames: o "output1.txt" for test_pass_host_env_vars() test case o "output2.txt" for test_run_args_and_env_vars_with_dsym() test case o "output2.txt" for test_run_args_and_env_vars_with_dwarf() test case and add teardown hook to test_pass_host_env_vars() in order to properly unset the host environment variables set while running the test case. Modified: lldb/trunk/test/settings/TestSettings.py lldb/trunk/test/settings/main.cpp Modified: lldb/trunk/test/settings/TestSettings.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/settings/TestSettings.py?rev=121811&r1=121810&r2=121811&view=diff ============================================================================== --- lldb/trunk/test/settings/TestSettings.py (original) +++ lldb/trunk/test/settings/TestSettings.py Tue Dec 14 17:43:29 2010 @@ -14,7 +14,8 @@ @classmethod def classCleanup(cls): """Cleanup the test byproducts.""" - system(["/bin/sh", "-c", "rm -f output.txt"]) + system(["/bin/sh", "-c", "rm -f output1.txt"]) + system(["/bin/sh", "-c", "rm -f output2.txt"]) system(["/bin/sh", "-c", "rm -f stdout.txt"]) def test_set_prompt(self): @@ -72,12 +73,12 @@ startstr = "auto-confirm (boolean) = 'false'") @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin") - def test_with_dsym(self): + def test_run_args_and_env_vars_with_dsym(self): """Test that run-args and env-vars are passed to the launched process.""" self.buildDsym() self.pass_run_args_and_env_vars() - def test_with_dwarf(self): + def test_run_args_and_env_vars_with_dwarf(self): """Test that run-args and env-vars are passed to the launched process.""" self.buildDwarf() self.pass_run_args_and_env_vars() @@ -99,7 +100,7 @@ self.runCmd("run", RUN_SUCCEEDED) # Read the output file produced by running the program. - with open('output.txt', 'r') as f: + with open('output2.txt', 'r') as f: output = f.read() self.expect(output, exe=False, @@ -123,10 +124,16 @@ os.environ["MY_HOST_ENV_VAR1"] = "VAR1" os.environ["MY_HOST_ENV_VAR2"] = "VAR2" + # This is the function to unset the two env variables set above. + def unset_env_variables(): + os.environ.pop("MY_HOST_ENV_VAR1") + os.environ.pop("MY_HOST_ENV_VAR2") + + self.addTearDownHook(unset_env_variables) self.runCmd("run", RUN_SUCCEEDED) # Read the output file produced by running the program. - with open('output.txt', 'r') as f: + with open('output1.txt', 'r') as f: output = f.read() self.expect(output, exe=False, Modified: lldb/trunk/test/settings/main.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/settings/main.cpp?rev=121811&r1=121810&r2=121811&view=diff ============================================================================== --- lldb/trunk/test/settings/main.cpp (original) +++ lldb/trunk/test/settings/main.cpp Tue Dec 14 17:43:29 2010 @@ -15,8 +15,16 @@ int main(int argc, char const *argv[]) { - // The program writes its output to the "output.txt" file. - std::ofstream outfile("output.txt"); + // The program writes its output to the following file: + // + // o "output1.txt" for test_pass_host_env_vars() test case + // o "output2.txt" for test_run_args_and_env_vars_with_dsym() test case + // o "output2.txt" for test_run_args_and_env_vars_with_dwarf() test case + std::ofstream outfile; + if (argc == 1) + outfile.open("output1.txt"); + else + outfile.open("output2.txt"); for (unsigned i = 0; i < argc; ++i) { std::string theArg(argv[i]); @@ -56,5 +64,6 @@ std::cout << "This message should go to standard out.\n"; + outfile.close(); return 0; } From johnny.chen at apple.com Tue Dec 14 17:47:55 2010 From: johnny.chen at apple.com (Johnny Chen) Date: Tue, 14 Dec 2010 23:47:55 -0000 Subject: [Lldb-commits] [lldb] r121813 - /lldb/trunk/test/settings/TestSettings.py Message-ID: <20101214234755.EE52A2A6C12C@llvm.org> Author: johnny Date: Tue Dec 14 17:47:55 2010 New Revision: 121813 URL: http://llvm.org/viewvc/llvm-project?rev=121813&view=rev Log: Rearrange some statements so that the adding of teardown hook follows immediately after the statement it wants to revert the effect of. Modified: lldb/trunk/test/settings/TestSettings.py Modified: lldb/trunk/test/settings/TestSettings.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/settings/TestSettings.py?rev=121813&r1=121812&r2=121813&view=diff ============================================================================== --- lldb/trunk/test/settings/TestSettings.py (original) +++ lldb/trunk/test/settings/TestSettings.py Tue Dec 14 17:47:55 2010 @@ -89,11 +89,11 @@ self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) # Set the run-args and the env-vars. - self.runCmd('settings set target.process.run-args A B C') - self.runCmd('settings set target.process.env-vars ["MY_ENV_VAR"]=YES') # And add hooks to restore the settings during tearDown(). + self.runCmd('settings set target.process.run-args A B C') self.addTearDownHook( lambda: self.runCmd("settings set -r target.process.run-args")) + self.runCmd('settings set target.process.env-vars ["MY_ENV_VAR"]=YES') self.addTearDownHook( lambda: self.runCmd("settings set -r target.process.env-vars")) From ctice at apple.com Tue Dec 14 17:50:59 2010 From: ctice at apple.com (Caroline Tice) Date: Tue, 14 Dec 2010 23:50:59 -0000 Subject: [Lldb-commits] [lldb] r121814 - in /lldb/trunk/test/abbreviation_tests: ./ Makefile TestAbbreviations.py change_prompt.lldb main.cpp Message-ID: <20101214235059.7A5B52A6C12C@llvm.org> Author: ctice Date: Tue Dec 14 17:50:59 2010 New Revision: 121814 URL: http://llvm.org/viewvc/llvm-project?rev=121814&view=rev Log: Add test cases to make sure the Command Interpreter is handling command completion properly (e.g. abbreviated commands, which are NOT the same as aliases). Added: lldb/trunk/test/abbreviation_tests/ lldb/trunk/test/abbreviation_tests/Makefile lldb/trunk/test/abbreviation_tests/TestAbbreviations.py lldb/trunk/test/abbreviation_tests/change_prompt.lldb lldb/trunk/test/abbreviation_tests/main.cpp Added: lldb/trunk/test/abbreviation_tests/Makefile URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/abbreviation_tests/Makefile?rev=121814&view=auto ============================================================================== --- lldb/trunk/test/abbreviation_tests/Makefile (added) +++ lldb/trunk/test/abbreviation_tests/Makefile Tue Dec 14 17:50:59 2010 @@ -0,0 +1,5 @@ +LEVEL = ../make + +CXX_SOURCES := main.cpp + +include $(LEVEL)/Makefile.rules Added: lldb/trunk/test/abbreviation_tests/TestAbbreviations.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/abbreviation_tests/TestAbbreviations.py?rev=121814&view=auto ============================================================================== --- lldb/trunk/test/abbreviation_tests/TestAbbreviations.py (added) +++ lldb/trunk/test/abbreviation_tests/TestAbbreviations.py Tue Dec 14 17:50:59 2010 @@ -0,0 +1,157 @@ +""" +Test some lldb command abbreviations. +""" + +import os, time +import unittest2 +import lldb +from lldbtest import * + +class AbbreviationsTestCase(TestBase): + + mydir = "abbreviation_tests" + + def test_nonrunning_command_abbreviations (self): + self.expect("ap script", + startstr = "The following commands may relate to 'script':", + substrs = ['breakpoint command add', + 'breakpoint command list', + 'breakpoint list', + 'commands alias', + 'expression', + 'script']) + + self.runCmd("com a alias com al") + self.runCmd("alias gurp help") + self.expect("gurp file", + substrs = ['Syntax: file ']) + self.runCmd("com u gurp") + self.expect("gurp", + COMMAND_FAILED_AS_EXPECTED, error = True, + substrs = ["error: 'gurp' is not a valid command."]) + + self.expect("h", + startstr = "The following is a list of built-in, permanent debugger commands:") + + + self.expect("com s ./change_prompt.lldb", + patterns = ["Executing commands in '.*change_prompt.lldb'"]) + + self.expect("settings show prompt", + startstr = "prompt (string) = '[old-oak]'") + + + self.runCmd("settings set -r prompt") + self.expect("settings show prompt", + startstr = "prompt (string) = '(lldb) '") + + + self.expect("lo li", + startstr = "Logging categories for 'lldb':") + + self.runCmd("se se prompt Sycamore> ") + self.expect("se sh prompt", + startstr = "prompt (string) = 'Sycamore>'") + + self.runCmd("se se -r prompt") + self.expect("set sh prompt", + startstr = "prompt (string) = '(lldb) '") + + self.runCmd (r'''sc print "\n\n\tHello!\n"''') + + + @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin") + def test_with_dsym (self): + self.buildDsym () + self.running_abbreviations () + + def test_with_dwarf (self): + self.buildDwarf () + self.running_abbreviations () + + def running_abbreviations (self): + exe = os.path.join (os.getcwd(), "a.out") + self.expect("fil " + exe, + patterns = [ "Current executable set to .*a.out.*(x86_64)" ]) + + self.expect("regex product", + substrs = [ "breakpoint set --name 'product'", + "Breakpoint created: 1: name = 'product', locations = 1" ]) + + self.expect("br s -n sum", + startstr = "Breakpoint created: 2: name = 'sum', locations = 1") + + self.expect("br s -f main.cpp -l 32", + startstr = "Breakpoint created: 3: file ='main.cpp', line = 32, locations = 1") + + self.runCmd("br co a -p 1 -o 'print frame'") + self.expect("br co l 1", + substrs = [ "Breakpoint 1:", + "Breakpoint commands:", + "print frame" ]) + + self.runCmd("br co rem 1") + self.expect("breakpoint command list 1", + startstr = "Breakpoint 1 does not have an associated command.") + + self.expect("br di", + startstr = 'All breakpoints disabled. (3 breakpoints)') + + self.expect("bre e", + startstr = "All breakpoints enabled. (3 breakpoints)") + + self.expect("break list", + substrs = ["1: name = 'product', locations = 1", + "2: name = 'sum', locations = 1", + "3: file ='main.cpp', line = 32, locations = 1"]) + self.expect("br cl -l 32 -f main.cpp", + startstr = "1 breakpoints cleared:", + substrs = ["3: file ='main.cpp', line = 32, locations = 1"]) + + self.expect("pro la", + patterns = [ "Process .* launched: "]) + + self.expect("pro st", + patterns = [ "Process .* stopped", + "thread #1:", + "a.out", + "sum\(int, int\)", + "at main.cpp\:25", + "stop reason = breakpoint 2.1" ]) + + self.expect("d -f", + startstr = "a.out`sum(int, int):", + substrs = [' pushq ', + ' movq ', + ' addl ', + 'leave', + 'ret']) + + self.expect("i d l main.cpp", + patterns = ["Line table for .*main.cpp in `a.out"]) + + self.expect("i d se", + startstr = "Dumping sections for 5 modules.") + + self.expect("i d symf", + startstr = "Dumping debug symbols for 5 modules.") + + self.expect("i d symt", + startstr = "Dumping symbol table for 5 modules.") + + self.expect("i li", + substrs = [ 'a.out', + '/usr/lib/dyld', + '/usr/lib/libstdc++', + '/usr/lib/libSystem.B.dylib', + '/usr/lib/system/libmathCommon.A.dylib']) + + + + +if __name__ == '__main__': + import atexit + lldb.SBDebugger.Initialize() + atexit.register(lambda: lldb.SBDebugger.Terminate()) + unittest2.main() + Added: lldb/trunk/test/abbreviation_tests/change_prompt.lldb URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/abbreviation_tests/change_prompt.lldb?rev=121814&view=auto ============================================================================== --- lldb/trunk/test/abbreviation_tests/change_prompt.lldb (added) +++ lldb/trunk/test/abbreviation_tests/change_prompt.lldb Tue Dec 14 17:50:59 2010 @@ -0,0 +1 @@ +settings set prompt [old-oak] Added: lldb/trunk/test/abbreviation_tests/main.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/abbreviation_tests/main.cpp?rev=121814&view=auto ============================================================================== --- lldb/trunk/test/abbreviation_tests/main.cpp (added) +++ lldb/trunk/test/abbreviation_tests/main.cpp Tue Dec 14 17:50:59 2010 @@ -0,0 +1,62 @@ +//===-- main.cpp ------------------------------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#include +#include +#include +#include + +int +product (int x, int y) +{ + int result = x * y; + return result; +} + +int +sum (int a, int b) +{ + int result = a + b; + return result; +} + +int +strange_max (int m, int n) +{ + if (m > n) + return m; + else if (n > m) + return n; + else + return 0; +} + +int +foo (int i, int j) +{ + if (strange_max (i, j) == i) + return product (i, j); + else if (strange_max (i, j) == j) + return sum (i, j); + else + return product (sum (i, i), sum (j, j)); +} + +int +main(int argc, char const *argv[]) +{ + + int array[3]; + + array[0] = foo (1238, 78392); + array[1] = foo (379265, 23674); + array[2] = foo (872934, 234); + + return 0; +} From johnny.chen at apple.com Tue Dec 14 18:58:49 2010 From: johnny.chen at apple.com (Johnny Chen) Date: Wed, 15 Dec 2010 00:58:49 -0000 Subject: [Lldb-commits] [lldb] r121818 - /lldb/trunk/test/abbreviation_tests/TestAbbreviations.py Message-ID: <20101215005849.E21192A6C12C@llvm.org> Author: johnny Date: Tue Dec 14 18:58:49 2010 New Revision: 121818 URL: http://llvm.org/viewvc/llvm-project?rev=121818&view=rev Log: Modify the test case to run under ['gcc', 'llvm-gcc', 'clang'] x ['x86_64', 'i386'] combinations. Modified: lldb/trunk/test/abbreviation_tests/TestAbbreviations.py Modified: lldb/trunk/test/abbreviation_tests/TestAbbreviations.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/abbreviation_tests/TestAbbreviations.py?rev=121818&r1=121817&r2=121818&view=diff ============================================================================== --- lldb/trunk/test/abbreviation_tests/TestAbbreviations.py (original) +++ lldb/trunk/test/abbreviation_tests/TestAbbreviations.py Tue Dec 14 18:58:49 2010 @@ -72,7 +72,7 @@ def running_abbreviations (self): exe = os.path.join (os.getcwd(), "a.out") self.expect("fil " + exe, - patterns = [ "Current executable set to .*a.out.*(x86_64)" ]) + patterns = [ "Current executable set to .*a.out.*" ]) self.expect("regex product", substrs = [ "breakpoint set --name 'product'", @@ -121,11 +121,11 @@ self.expect("d -f", startstr = "a.out`sum(int, int):", - substrs = [' pushq ', - ' movq ', + substrs = [' push', + ' mov', ' addl ', - 'leave', - 'ret']) + 'ret'], + patterns = ['(leave|popq|popl)']) self.expect("i d l main.cpp", patterns = ["Line table for .*main.cpp in `a.out"]) From jmolenda at apple.com Tue Dec 14 22:20:25 2010 From: jmolenda at apple.com (Jason Molenda) Date: Wed, 15 Dec 2010 04:20:25 -0000 Subject: [Lldb-commits] [lldb] r121834 - /lldb/trunk/source/Core/Mangled.cpp Message-ID: <20101215042025.AB29A2A6C12C@llvm.org> Author: jmolenda Date: Tue Dec 14 22:20:25 2010 New Revision: 121834 URL: http://llvm.org/viewvc/llvm-project?rev=121834&view=rev Log: Fix a crash on some platforms where a dSYM for a system library lists a DW_AT_mips_linkage_name for a non-mangled function - we pass the non mangled string down through abi::__cxa_demangle and it crashes. Usually passing non mangled strings to abi::__cxa_demangle works out fine but not always, apparently. Modified: lldb/trunk/source/Core/Mangled.cpp Modified: lldb/trunk/source/Core/Mangled.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/Mangled.cpp?rev=121834&r1=121833&r2=121834&view=diff ============================================================================== --- lldb/trunk/source/Core/Mangled.cpp (original) +++ lldb/trunk/source/Core/Mangled.cpp Tue Dec 14 22:20:25 2010 @@ -143,7 +143,8 @@ // We already know mangled is valid from the above check, // lets just make sure it isn't empty... const char * mangled = m_mangled.AsCString(); - if (mangled[0]) + // Don't bother running anything that doesn't start with _Z through the demangler + if (mangled[0] != '\0' && mangled[0] == '_' && mangled[1] == 'Z') { // Since demangling can be a costly, and since all names that go // into a ConstString (like our m_mangled and m_demangled members) From jmolenda at apple.com Tue Dec 14 22:27:04 2010 From: jmolenda at apple.com (Jason Molenda) Date: Wed, 15 Dec 2010 04:27:04 -0000 Subject: [Lldb-commits] [lldb] r121835 - /lldb/trunk/source/Core/Mangled.cpp Message-ID: <20101215042704.C6FCF2A6C12C@llvm.org> Author: jmolenda Date: Tue Dec 14 22:27:04 2010 New Revision: 121835 URL: http://llvm.org/viewvc/llvm-project?rev=121835&view=rev Log: Move the demangle-failed indication out a bit so other failing cases also get marked as having failed (so we don't try to demangle the same symbol multiple times). Modified: lldb/trunk/source/Core/Mangled.cpp Modified: lldb/trunk/source/Core/Mangled.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/Mangled.cpp?rev=121835&r1=121834&r2=121835&view=diff ============================================================================== --- lldb/trunk/source/Core/Mangled.cpp (original) +++ lldb/trunk/source/Core/Mangled.cpp Tue Dec 14 22:27:04 2010 @@ -181,14 +181,14 @@ g_mangled_to_demangled.insert (std::make_pair (mangled, m_demangled.GetCString())); free (demangled_name); } - else - { - // Set the demangled string to the empty string to indicate we - // tried to parse it once and failed. - m_demangled.SetCString(""); - } } } + if (!m_demangled) + { + // Set the demangled string to the empty string to indicate we + // tried to parse it once and failed. + m_demangled.SetCString(""); + } } return m_demangled; From gclayton at apple.com Tue Dec 14 23:08:08 2010 From: gclayton at apple.com (Greg Clayton) Date: Wed, 15 Dec 2010 05:08:08 -0000 Subject: [Lldb-commits] [lldb] r121841 - in /lldb/trunk: include/lldb/Core/ValueObject.h include/lldb/Symbol/ClangASTContext.h include/lldb/Target/StackFrame.h lldb.xcodeproj/project.pbxproj source/API/SBTarget.cpp source/Commands/CommandObjectFrame.cpp source/Core/ValueObject.cpp source/Symbol/ClangASTContext.cpp source/Target/StackFrame.cpp source/Target/Target.cpp test/forward/TestForwardDeclaration.py test/foundation/TestObjCMethods.py Message-ID: <20101215050809.0AB112A6C12C@llvm.org> Author: gclayton Date: Tue Dec 14 23:08:08 2010 New Revision: 121841 URL: http://llvm.org/viewvc/llvm-project?rev=121841&view=rev Log: Fixed the "expression" command object to use the StackFrame::GetValueForExpressionPath() function and also hooked up better error reporting for when things fail. Fixed issues with trying to display children of pointers when none are supposed to be shown (no children for function pointers, and more like this). This was causing child value objects to be made that were correctly firing an assertion. Modified: lldb/trunk/include/lldb/Core/ValueObject.h lldb/trunk/include/lldb/Symbol/ClangASTContext.h lldb/trunk/include/lldb/Target/StackFrame.h lldb/trunk/lldb.xcodeproj/project.pbxproj lldb/trunk/source/API/SBTarget.cpp lldb/trunk/source/Commands/CommandObjectFrame.cpp lldb/trunk/source/Core/ValueObject.cpp lldb/trunk/source/Symbol/ClangASTContext.cpp lldb/trunk/source/Target/StackFrame.cpp lldb/trunk/source/Target/Target.cpp lldb/trunk/test/forward/TestForwardDeclaration.py lldb/trunk/test/foundation/TestObjCMethods.py Modified: lldb/trunk/include/lldb/Core/ValueObject.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/ValueObject.h?rev=121841&r1=121840&r2=121841&view=diff ============================================================================== --- lldb/trunk/include/lldb/Core/ValueObject.h (original) +++ lldb/trunk/include/lldb/Core/ValueObject.h Tue Dec 14 23:08:08 2010 @@ -207,10 +207,10 @@ CreateConstantValue (ExecutionContextScope *exe_scope, const ConstString &name); virtual lldb::ValueObjectSP - Dereference (ExecutionContextScope *exe_scope, Error *error_ptr); + Dereference (ExecutionContextScope *exe_scope, Error &error); virtual lldb::ValueObjectSP - AddressOf (); + AddressOf (Error &error); // The backing bits of this value object were updated, clear any value // values, summaries or descriptions so we refetch them. Modified: lldb/trunk/include/lldb/Symbol/ClangASTContext.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Symbol/ClangASTContext.h?rev=121841&r1=121840&r2=121841&view=diff ============================================================================== --- lldb/trunk/include/lldb/Symbol/ClangASTContext.h (original) +++ lldb/trunk/include/lldb/Symbol/ClangASTContext.h Tue Dec 14 23:08:08 2010 @@ -348,6 +348,9 @@ GetNumChildren (lldb::clang_type_t clang_type, bool omit_empty_base_classes); + static uint32_t + GetNumPointeeChildren (lldb::clang_type_t clang_type); + lldb::clang_type_t GetChildClangTypeAtIndex (const char *parent_name, lldb::clang_type_t parent_clang_type, Modified: lldb/trunk/include/lldb/Target/StackFrame.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/StackFrame.h?rev=121841&r1=121840&r2=121841&view=diff ============================================================================== --- lldb/trunk/include/lldb/Target/StackFrame.h (original) +++ lldb/trunk/include/lldb/Target/StackFrame.h Tue Dec 14 23:08:08 2010 @@ -97,7 +97,7 @@ GetVariableList (bool get_file_globals); lldb::ValueObjectSP - GetValueForVariableExpressionPath (const char *var_expr); + GetValueForVariableExpressionPath (const char *var_expr, bool check_ptr_vs_member, Error &error); bool HasDebugInformation (); Modified: lldb/trunk/lldb.xcodeproj/project.pbxproj URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/lldb.xcodeproj/project.pbxproj?rev=121841&r1=121840&r2=121841&view=diff ============================================================================== --- lldb/trunk/lldb.xcodeproj/project.pbxproj (original) +++ lldb/trunk/lldb.xcodeproj/project.pbxproj Tue Dec 14 23:08:08 2010 @@ -2455,6 +2455,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/API/SBTarget.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBTarget.cpp?rev=121841&r1=121840&r2=121841&view=diff ============================================================================== --- lldb/trunk/source/API/SBTarget.cpp (original) +++ lldb/trunk/source/API/SBTarget.cpp Tue Dec 14 23:08:08 2010 @@ -50,7 +50,8 @@ //---------------------------------------------------------------------- // SBTarget constructor //---------------------------------------------------------------------- -SBTarget::SBTarget () +SBTarget::SBTarget () : + m_opaque_sp () { } Modified: lldb/trunk/source/Commands/CommandObjectFrame.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectFrame.cpp?rev=121841&r1=121840&r2=121841&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectFrame.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectFrame.cpp Tue Dec 14 23:08:08 2010 @@ -586,175 +586,36 @@ } else { - bool address_of = false; - // If first character is a '*', then show pointer contents - if (name_cstr[0] == '*') + Error error; + const bool check_ptr_vs_member = true; + valobj_sp = exe_ctx.frame->GetValueForVariableExpressionPath (name_cstr, check_ptr_vs_member, error); + if (valobj_sp) { - ++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(".-["); - - ConstString name_const_string; - if (separator_idx == std::string::npos) - name_const_string.SetCString (var_path.c_str()); - else - name_const_string.SetCStringWithLength (var_path.c_str(), separator_idx); - - var_sp = variable_list->FindVariable(name_const_string); - if (var_sp) - { - valobj_sp = exe_ctx.frame->GetValueObjectForFrameVariable (var_sp); - - var_path.erase (0, name_const_string.GetLength ()); - // We are dumping at least one child - while (separator_idx != std::string::npos) + if (m_options.show_decl && var_sp->GetDeclaration ().GetFile()) { - // Calculate the next separator index ahead of time - ValueObjectSP child_valobj_sp; - const char separator_type = var_path[0]; - switch (separator_type) - { - - case '-': - if (var_path.size() >= 2 && var_path[1] != '>') - { - result.GetErrorStream().Printf ("error: invalid character in variable path starting at '%s'\n", - var_path.c_str()); - var_path.clear(); - valobj_sp.reset(); - break; - } - var_path.erase (0, 1); // Remove the '-' - // Fall through - case '.': - { - var_path.erase (0, 1); // Remove the '.' or '>' - separator_idx = var_path.find_first_of(".-["); - ConstString child_name; - if (separator_idx == std::string::npos) - child_name.SetCString (var_path.c_str()); - else - child_name.SetCStringWithLength(var_path.c_str(), separator_idx); - - child_valobj_sp = valobj_sp->GetChildMemberWithName (child_name, true); - if (!child_valobj_sp) - { - result.GetErrorStream().Printf ("error: can't find child of '%s' named '%s'\n", - valobj_sp->GetName().AsCString(), - child_name.GetCString()); - var_path.clear(); - valobj_sp.reset(); - break; - } - // Remove the child name from the path - var_path.erase(0, child_name.GetLength()); - } - break; - - case '[': - // Array member access, or treating pointer as an array - if (var_path.size() > 2) // Need at least two brackets and a number - { - char *end = NULL; - int32_t child_index = ::strtol (&var_path[1], &end, 0); - if (end && *end == ']') - { - - if (valobj_sp->IsPointerType ()) - { - child_valobj_sp = valobj_sp->GetSyntheticArrayMemberFromPointer (child_index, true); - } - else - { - child_valobj_sp = valobj_sp->GetChildAtIndex (child_index, true); - } - - if (!child_valobj_sp) - { - result.GetErrorStream().Printf ("error: invalid array index %u in '%s'\n", - child_index, - valobj_sp->GetName().AsCString()); - var_path.clear(); - valobj_sp.reset(); - break; - } - - // Erase the array member specification '[%i]' where %i is the array index - var_path.erase(0, (end - var_path.c_str()) + 1); - separator_idx = var_path.find_first_of(".-["); - - // Break out early from the switch since we were able to find the child member - break; - } - } - result.GetErrorStream().Printf ("error: invalid array member specification for '%s' starting at '%s'\n", - valobj_sp->GetName().AsCString(), - var_path.c_str()); - var_path.clear(); - valobj_sp.reset(); - break; - - break; - - default: - result.GetErrorStream().Printf ("error: invalid character in variable path starting at '%s'\n", - var_path.c_str()); - var_path.clear(); - valobj_sp.reset(); - separator_idx = std::string::npos; - break; - } - - if (child_valobj_sp) - valobj_sp = child_valobj_sp; - - if (var_path.empty()) - break; - - } - - if (valobj_sp) - { - if (m_options.show_decl && var_sp->GetDeclaration ().GetFile()) - { - var_sp->GetDeclaration ().DumpStopContext (&s, false); - s.PutCString (": "); - } - - - 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); - } + var_sp->GetDeclaration ().DumpStopContext (&s, false); + s.PutCString (": "); } + 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 { - result.GetErrorStream().Printf ("error: unable to find any variables named '%s'\n", name_cstr); - var_path.clear(); + const char *error_cstr = error.AsCString(NULL); + if (error_cstr) + result.GetErrorStream().Printf("error: %s\n", error_cstr); + else + result.GetErrorStream().Printf ("error: unable to find any variable expression path that matches '%s'\n", name_cstr); } } } Modified: lldb/trunk/source/Core/ValueObject.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/ValueObject.cpp?rev=121841&r1=121840&r2=121841&view=diff ============================================================================== --- lldb/trunk/source/Core/ValueObject.cpp (original) +++ lldb/trunk/source/Core/ValueObject.cpp Tue Dec 14 23:08:08 2010 @@ -1203,10 +1203,11 @@ } lldb::ValueObjectSP -ValueObject::Dereference (ExecutionContextScope *exe_scope, Error *error_ptr) +ValueObject::Dereference (ExecutionContextScope *exe_scope, Error &error) { lldb::ValueObjectSP valobj_sp; - if (IsPointerType()) + const bool is_pointer_type = IsPointerType(); + if (is_pointer_type) { bool omit_empty_base_classes = true; @@ -1249,98 +1250,46 @@ child_is_base_class)); } } + + if (valobj_sp) + { + error.Clear(); + } else { - if (error_ptr) - error_ptr->SetErrorString("can't dereference a non-pointer value"); + StreamString strm; + GetExpressionPath(strm); + + if (is_pointer_type) + error.SetErrorStringWithFormat("dereference failed: (%s) %s", GetTypeName().AsCString(""), strm.GetString().c_str()); + else + error.SetErrorStringWithFormat("not a pointer type: (%s) %s", GetTypeName().AsCString(""), strm.GetString().c_str()); } return valobj_sp; } - - -//lldb::ValueObjectSP -//ValueObject::Dereference (ExecutionContextScope *exe_scope, Error *error_ptr) -//{ -// lldb::ValueObjectSP valobj_sp; -// if (IsPointerType()) -// { -// UpdateValueIfNeeded(exe_scope); -// if (m_error.Success()) -// { -// lldb::AddressType address_type = eAddressTypeInvalid; -// const bool scalar_is_load_address = true; -// lldb::addr_t addr = GetPointerValue (address_type, scalar_is_load_address); -// if (addr != LLDB_INVALID_ADDRESS) -// { -// switch (address_type) -// { -// case eAddressTypeInvalid: -// if (error_ptr) -// error_ptr->SetErrorString("value is not in memory"); -// break; -// case eAddressTypeFile: -// case eAddressTypeLoad: -// case eAddressTypeHost: -// { -// clang::ASTContext *ast = GetClangAST(); -// clang_type_t clang_type = ClangASTType::GetPointeeType (GetClangType()); -// if (ast && clang_type) -// { -// std::string name (1, '*'); -// name.append (m_name.AsCString("")); -// valobj_sp.reset (new ValueObjectConstResult (ast, -// ClangASTContext::CreatePointerType (ast, clang_type), -// ConstString (name.c_str()), -// addr, -// address_type, -// m_data.GetAddressByteSize())); -// } -// else -// { -// if (error_ptr) -// error_ptr->SetErrorString("invalid clang type info"); -// } -// } -// break; -// } -// } -// else -// { -// if (error_ptr) -// error_ptr->SetErrorString("failed to extract pointer value"); -// } -// } -// else -// { -// if (error_ptr) -// *error_ptr = m_error; -// } -// } -// else -// { -// if (error_ptr) -// error_ptr->SetErrorString("can't dereference a non-pointer value"); -// } -// -// return valobj_sp; -//} - -lldb::ValueObjectSP -ValueObject::AddressOf () + lldb::ValueObjectSP +ValueObject::AddressOf (Error &error) { lldb::ValueObjectSP valobj_sp; - lldb::AddressType address_type = eAddressTypeInvalid; const bool scalar_is_load_address = false; lldb::addr_t addr = GetAddressOf (address_type, scalar_is_load_address); + error.Clear(); if (addr != LLDB_INVALID_ADDRESS) { switch (address_type) { + default: case eAddressTypeInvalid: + { + StreamString expr_path_strm; + GetExpressionPath(expr_path_strm); + error.SetErrorStringWithFormat("'%s' is not in memory", expr_path_strm.GetString().c_str()); + } break; + case eAddressTypeFile: case eAddressTypeLoad: case eAddressTypeHost: Modified: lldb/trunk/source/Symbol/ClangASTContext.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/ClangASTContext.cpp?rev=121841&r1=121840&r2=121841&view=diff ============================================================================== --- lldb/trunk/source/Symbol/ClangASTContext.cpp (original) +++ lldb/trunk/source/Symbol/ClangASTContext.cpp Tue Dec 14 23:08:08 2010 @@ -1901,7 +1901,10 @@ break; } break; - + + case clang::Type::Complex: + return 2; + case clang::Type::Record: if (ClangASTType::IsDefined (clang_qual_type)) { @@ -1995,12 +1998,15 @@ case clang::Type::Pointer: { PointerType *pointer_type = cast(qual_type.getTypePtr()); - QualType pointee_type = pointer_type->getPointeeType(); + QualType pointee_type (pointer_type->getPointeeType()); uint32_t num_pointee_children = ClangASTContext::GetNumChildren (pointee_type.getAsOpaquePtr(), omit_empty_base_classes); - // If this type points to a simple type, then it has 1 child if (num_pointee_children == 0) - num_children = 1; + { + // We have a pointer to a pointee type that claims it has no children. + // We will want to look at + num_children = ClangASTContext::GetNumPointeeChildren (pointee_type.getAsOpaquePtr()); + } else num_children = num_pointee_children; } @@ -2032,6 +2038,60 @@ return num_children; } +// If a pointer to a pointee type (the clang_type arg) says that it has no +// children, then we either need to trust it, or override it and return a +// different result. For example, an "int *" has one child that is an integer, +// but a function pointer doesn't have any children. Likewise if a Record type +// claims it has no children, then there really is nothing to show. +uint32_t +ClangASTContext::GetNumPointeeChildren (clang_type_t clang_type) +{ + if (clang_type == NULL) + return 0; + + QualType qual_type(QualType::getFromOpaquePtr(clang_type)); + const clang::Type::TypeClass type_class = qual_type->getTypeClass(); + switch (type_class) + { + case clang::Type::Builtin: return 1; + case clang::Type::Complex: return 2; + case clang::Type::Pointer: return 1; + case clang::Type::BlockPointer: return 0; // If block pointers don't have debug info, then no children for them + case clang::Type::LValueReference: return 1; + case clang::Type::RValueReference: return 1; + case clang::Type::MemberPointer: return 0; + case clang::Type::ConstantArray: return 0; + case clang::Type::IncompleteArray: return 0; + case clang::Type::VariableArray: return 0; + case clang::Type::DependentSizedArray: return 0; + case clang::Type::DependentSizedExtVector: return 0; + case clang::Type::Vector: return 0; + case clang::Type::ExtVector: return 0; + case clang::Type::FunctionProto: return 0; // When we function pointers, they have no children... + case clang::Type::FunctionNoProto: return 0; // When we function pointers, they have no children... + case clang::Type::UnresolvedUsing: return 0; + case clang::Type::Paren: return 0; + case clang::Type::Typedef: return ClangASTContext::GetNumPointeeChildren (cast(qual_type)->getDecl()->getUnderlyingType().getAsOpaquePtr()); + case clang::Type::TypeOfExpr: return 0; + case clang::Type::TypeOf: return 0; + case clang::Type::Decltype: return 0; + case clang::Type::Record: return 0; + case clang::Type::Enum: return 1; + case clang::Type::Elaborated: return 1; + case clang::Type::TemplateTypeParm: return 1; + case clang::Type::SubstTemplateTypeParm: return 1; + case clang::Type::TemplateSpecialization: return 1; + case clang::Type::InjectedClassName: return 0; + case clang::Type::DependentName: return 1; + case clang::Type::DependentTemplateSpecialization: return 1; + case clang::Type::ObjCObject: return 0; + case clang::Type::ObjCInterface: return 0; + case clang::Type::ObjCObjectPointer: return 1; + default: + break; + } + return 0; +} clang_type_t ClangASTContext::GetChildClangTypeAtIndex Modified: lldb/trunk/source/Target/StackFrame.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/StackFrame.cpp?rev=121841&r1=121840&r2=121841&view=diff ============================================================================== --- lldb/trunk/source/Target/StackFrame.cpp (original) +++ lldb/trunk/source/Target/StackFrame.cpp Tue Dec 14 23:08:08 2010 @@ -18,6 +18,7 @@ #include "lldb/Core/Disassembler.h" #include "lldb/Core/Value.h" #include "lldb/Core/ValueObjectVariable.h" +#include "lldb/Core/ValueObjectConstResult.h" #include "lldb/Symbol/Function.h" #include "lldb/Symbol/VariableList.h" #include "lldb/Target/ExecutionContext.h" @@ -479,156 +480,235 @@ } ValueObjectSP -StackFrame::GetValueForVariableExpressionPath (const char *var_expr) +StackFrame::GetValueForVariableExpressionPath (const char *var_expr_cstr, bool check_ptr_vs_member, Error &error) { - bool deref = false; - bool address_of = false; - ValueObjectSP valobj_sp; - const bool get_file_globals = true; - VariableList *variable_list = GetVariableList (get_file_globals); - - if (variable_list) + + if (var_expr_cstr && var_expr_cstr[0]) { - // If first character is a '*', then show pointer contents - if (var_expr[0] == '*') - { - deref = true; - var_expr++; // Skip the '*' - } - else if (var_expr[0] == '&') + error.Clear(); + bool deref = false; + bool address_of = false; + ValueObjectSP valobj_sp; + const bool get_file_globals = true; + VariableList *variable_list = GetVariableList (get_file_globals); + + if (variable_list) { - address_of = true; - var_expr++; // Skip the '&' - } - - std::string var_path (var_expr); - size_t separator_idx = var_path.find_first_of(".-["); + // If first character is a '*', then show pointer contents + const char *var_expr = var_expr_cstr; + if (var_expr[0] == '*') + { + deref = true; + var_expr++; // Skip the '*' + } + else if (var_expr[0] == '&') + { + address_of = true; + var_expr++; // Skip the '&' + } - ConstString name_const_string; - if (separator_idx == std::string::npos) - name_const_string.SetCString (var_path.c_str()); - else - name_const_string.SetCStringWithLength (var_path.c_str(), separator_idx); + std::string var_path (var_expr); + size_t separator_idx = var_path.find_first_of(".-[=+~|&^%#@!/?,<>{}"); + StreamString var_expr_path_strm; - VariableSP var_sp (variable_list->FindVariable(name_const_string)); - if (var_sp) - { - valobj_sp = GetValueObjectForFrameVariable (var_sp); + ConstString name_const_string; + if (separator_idx == std::string::npos) + name_const_string.SetCString (var_path.c_str()); + else + name_const_string.SetCStringWithLength (var_path.c_str(), separator_idx); - var_path.erase (0, name_const_string.GetLength ()); - // We are dumping at least one child - while (separator_idx != std::string::npos) + VariableSP var_sp (variable_list->FindVariable(name_const_string)); + if (var_sp) { - // Calculate the next separator index ahead of time - ValueObjectSP child_valobj_sp; - const char separator_type = var_path[0]; - switch (separator_type) - { - - case '-': - if (var_path.size() >= 2 && var_path[1] != '>') - return ValueObjectSP(); + valobj_sp = GetValueObjectForFrameVariable (var_sp); - var_path.erase (0, 1); // Remove the '-' - // Fall through - case '.': + var_path.erase (0, name_const_string.GetLength ()); + // We are dumping at least one child + while (separator_idx != std::string::npos) + { + // Calculate the next separator index ahead of time + ValueObjectSP child_valobj_sp; + const char separator_type = var_path[0]; + switch (separator_type) { - // We either have a pointer type and need to verify - // valobj_sp is a pointer, or we have a member of a - // class/union/struct being accessed with the . syntax - // and need to verify we don't have a pointer. - const bool is_ptr = var_path[0] == '>'; - - if (valobj_sp->IsPointerType () != is_ptr) - { - // Incorrect use of "." with a pointer, or "->" with - // a class/union/struct instance or reference. - return ValueObjectSP(); - } - var_path.erase (0, 1); // Remove the '.' or '>' - separator_idx = var_path.find_first_of(".-["); - ConstString child_name; - if (separator_idx == std::string::npos) - child_name.SetCString (var_path.c_str()); - else - child_name.SetCStringWithLength(var_path.c_str(), separator_idx); - - child_valobj_sp = valobj_sp->GetChildMemberWithName (child_name, true); - if (!child_valobj_sp) - { - // No child member with name "child_name" + case '-': + if (var_path.size() >= 2 && var_path[1] != '>') return ValueObjectSP(); - } - // Remove the child name from the path - var_path.erase(0, child_name.GetLength()); - } - break; - case '[': - // Array member access, or treating pointer as an array - if (var_path.size() > 2) // Need at least two brackets and a number - { - char *end = NULL; - int32_t child_index = ::strtol (&var_path[1], &end, 0); - if (end && *end == ']') + var_path.erase (0, 1); // Remove the '-' + // Fall through + case '.': { + const bool expr_is_ptr = var_path[0] == '>'; - if (valobj_sp->IsPointerType ()) - { - child_valobj_sp = valobj_sp->GetSyntheticArrayMemberFromPointer (child_index, true); - } + var_path.erase (0, 1); // Remove the '.' or '>' + separator_idx = var_path.find_first_of(".-["); + ConstString child_name; + if (separator_idx == std::string::npos) + child_name.SetCString (var_path.c_str()); else + child_name.SetCStringWithLength(var_path.c_str(), separator_idx); + + if (check_ptr_vs_member) { - child_valobj_sp = valobj_sp->GetChildAtIndex (child_index, true); + // We either have a pointer type and need to verify + // valobj_sp is a pointer, or we have a member of a + // class/union/struct being accessed with the . syntax + // and need to verify we don't have a pointer. + const bool actual_is_ptr = valobj_sp->IsPointerType (); + + if (actual_is_ptr != expr_is_ptr) + { + // Incorrect use of "." with a pointer, or "->" with + // a class/union/struct instance or reference. + valobj_sp->GetExpressionPath (var_expr_path_strm); + if (actual_is_ptr) + error.SetErrorStringWithFormat ("\"%s\" is a pointer and . was used to attempt to access \"%s\". Did you mean \"%s->%s\"?", + var_expr_path_strm.GetString().c_str(), + child_name.GetCString(), + var_expr_path_strm.GetString().c_str(), + var_path.c_str()); + else + error.SetErrorStringWithFormat ("\"%s\" is not a pointer and -> was used to attempt to access \"%s\". Did you mean \"%s.%s\"?", + var_expr_path_strm.GetString().c_str(), + child_name.GetCString(), + var_expr_path_strm.GetString().c_str(), + var_path.c_str()); + return ValueObjectSP(); + } } + child_valobj_sp = valobj_sp->GetChildMemberWithName (child_name, true); if (!child_valobj_sp) { - // Invalid array index... + // No child member with name "child_name" + valobj_sp->GetExpressionPath (var_expr_path_strm); + if (child_name) + { + error.SetErrorStringWithFormat ("\"%s\" is not a member of \"(%s) %s\"", + child_name.GetCString(), + valobj_sp->GetTypeName().AsCString(""), + var_expr_path_strm.GetString().c_str()); + } + else + { + error.SetErrorStringWithFormat ("incomplete expression path after \"%s\" in \"%s\"", + var_expr_path_strm.GetString().c_str(), + var_expr_cstr); + } + return ValueObjectSP(); } + // Remove the child name from the path + var_path.erase(0, child_name.GetLength()); + } + break; - // Erase the array member specification '[%i]' where - // %i is the array index - var_path.erase(0, (end - var_path.c_str()) + 1); - separator_idx = var_path.find_first_of(".-["); + case '[': + // Array member access, or treating pointer as an array + if (var_path.size() > 2) // Need at least two brackets and a number + { + char *end = NULL; + int32_t child_index = ::strtol (&var_path[1], &end, 0); + if (end && *end == ']') + { - // Break out early from the switch since we were - // able to find the child member - break; + if (valobj_sp->IsPointerType ()) + { + child_valobj_sp = valobj_sp->GetSyntheticArrayMemberFromPointer (child_index, true); + if (!child_valobj_sp) + { + valobj_sp->GetExpressionPath (var_expr_path_strm); + error.SetErrorStringWithFormat ("failed to use pointer as array for index %i for \"(%s) %s\"", + child_index, + valobj_sp->GetTypeName().AsCString(""), + var_expr_path_strm.GetString().c_str()); + } + } + else if (ClangASTContext::IsArrayType (valobj_sp->GetClangType(), NULL, NULL)) + { + child_valobj_sp = valobj_sp->GetChildAtIndex (child_index, true); + if (!child_valobj_sp) + { + valobj_sp->GetExpressionPath (var_expr_path_strm); + error.SetErrorStringWithFormat ("array index %i is not valid for \"(%s) %s\"", + child_index, + valobj_sp->GetTypeName().AsCString(""), + var_expr_path_strm.GetString().c_str()); + } + } + else + { + valobj_sp->GetExpressionPath (var_expr_path_strm); + error.SetErrorStringWithFormat ("\"(%s) %s\" is not an array type", + valobj_sp->GetTypeName().AsCString(""), + var_expr_path_strm.GetString().c_str()); + } + + if (!child_valobj_sp) + { + // Invalid array index... + return ValueObjectSP(); + } + + // Erase the array member specification '[%i]' where + // %i is the array index + var_path.erase(0, (end - var_path.c_str()) + 1); + separator_idx = var_path.find_first_of(".-["); + + // Break out early from the switch since we were + // able to find the child member + break; + } } - } - return ValueObjectSP(); + return ValueObjectSP(); - default: - // Failure... - return ValueObjectSP(); - } + default: + // Failure... + { + valobj_sp->GetExpressionPath (var_expr_path_strm); + error.SetErrorStringWithFormat ("unexpected char '%c' encountered after \"%s\" in \"%s\"", + separator_type, + var_expr_path_strm.GetString().c_str(), + var_path.c_str()); - if (child_valobj_sp) - valobj_sp = child_valobj_sp; + return ValueObjectSP(); + } + } - if (var_path.empty()) - break; + if (child_valobj_sp) + valobj_sp = child_valobj_sp; + + if (var_path.empty()) + break; - } - if (valobj_sp) - { - if (deref) - { - ValueObjectSP deref_valobj_sp (valobj_sp->Dereference(this, NULL)); - valobj_sp = deref_valobj_sp; } - else if (address_of) + if (valobj_sp) { - ValueObjectSP address_of_valobj_sp (valobj_sp->AddressOf()); - valobj_sp = address_of_valobj_sp; + if (deref) + { + ValueObjectSP deref_valobj_sp (valobj_sp->Dereference(this, error)); + valobj_sp = deref_valobj_sp; + } + else if (address_of) + { + ValueObjectSP address_of_valobj_sp (valobj_sp->AddressOf(error)); + valobj_sp = address_of_valobj_sp; + } } + return valobj_sp; + } + else + { + error.SetErrorStringWithFormat("no variable named '%s' found in this frame", name_const_string.GetCString()); } - return valobj_sp; } } + else + { + error.SetErrorStringWithFormat("invalid variable path '%s'", var_expr_cstr); + } return ValueObjectSP(); } Modified: lldb/trunk/source/Target/Target.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/Target.cpp?rev=121841&r1=121840&r2=121841&view=diff ============================================================================== --- lldb/trunk/source/Target/Target.cpp (original) +++ lldb/trunk/source/Target/Target.cpp Tue Dec 14 23:08:08 2010 @@ -886,7 +886,9 @@ if (frame) { frame->CalculateExecutionContext(exe_ctx); - result_valobj_sp = frame->GetValueForVariableExpressionPath (expr_cstr); + Error error; + const bool check_ptr_vs_member = true; + result_valobj_sp = frame->GetValueForVariableExpressionPath (expr_cstr, check_ptr_vs_member, error); } else if (m_process_sp) { Modified: lldb/trunk/test/forward/TestForwardDeclaration.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/forward/TestForwardDeclaration.py?rev=121841&r1=121840&r2=121841&view=diff ============================================================================== --- lldb/trunk/test/forward/TestForwardDeclaration.py (original) +++ lldb/trunk/test/forward/TestForwardDeclaration.py Tue Dec 14 23:08:08 2010 @@ -47,7 +47,7 @@ # This should display correctly. # Note that the member fields of a = 1 and b = 2 is by design. self.expect("frame variable -t *bar_ptr", VARIABLES_DISPLAYED_CORRECTLY, - substrs = ['(struct bar *) bar_ptr = ', + substrs = ['(struct bar) *bar_ptr = ', '(int) a = 1', '(int) b = 2']) Modified: lldb/trunk/test/foundation/TestObjCMethods.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/foundation/TestObjCMethods.py?rev=121841&r1=121840&r2=121841&view=diff ============================================================================== --- lldb/trunk/test/foundation/TestObjCMethods.py (original) +++ lldb/trunk/test/foundation/TestObjCMethods.py Tue Dec 14 23:08:08 2010 @@ -151,7 +151,7 @@ # This should display the str and date member fields as well. self.expect("frame variable -t *self", VARIABLES_DISPLAYED_CORRECTLY, - substrs = ["(MyString *) self", + substrs = ["(MyString) *self", "(NSString *) str", "(NSDate *) date"]) From wilsons at start.ca Wed Dec 15 12:37:16 2010 From: wilsons at start.ca (Stephen Wilson) Date: Wed, 15 Dec 2010 13:37:16 -0500 Subject: [Lldb-commits] [PATCH] linux: fix Host definitions Message-ID: Hi all, This is the first patch in a series I plan on sending to get the Linux build back on its feet. I have roughly 25 patches to send out and would very much appreciate some review before they go into the tree. I think I still have commit access and would be happy to commit them myself if desired. Fix definitions of Host::LaunchInNewTerminal and Host::OpenFileInExternalEditor. Definitions did not agree with the corresponding declarations when compiling on non-Apple platforms. diff --git a/source/Host/common/Host.cpp b/source/Host/common/Host.cpp index 527d20a..c760aa3 100644 --- a/source/Host/common/Host.cpp +++ b/source/Host/common/Host.cpp @@ -877,7 +877,7 @@ Host::GetArchSpecForExistingProcess (const char *process_name) #if !defined (__APPLE__) // see macosx/Host.mm bool -Host::OpenFileInExternalEditor (FileSpec &file_spec, uint32_t line_no) +Host::OpenFileInExternalEditor (const FileSpec &file_spec, uint32_t line_no) { return false; } @@ -901,6 +901,7 @@ LaunchApplication (const FileSpec &app_file_spec) lldb::pid_t Host::LaunchInNewTerminal ( + const char *tty_name, const char **argv, const char **envp, const ArchSpec *arch_spec, From ctice at apple.com Wed Dec 15 13:04:51 2010 From: ctice at apple.com (Caroline Tice) Date: Wed, 15 Dec 2010 19:04:51 -0000 Subject: [Lldb-commits] [lldb] r121879 - in /lldb/trunk/test/alias_tests: ./ Makefile TestAliases.py main.cpp Message-ID: <20101215190451.AA7A42A6C12C@llvm.org> Author: ctice Date: Wed Dec 15 13:04:51 2010 New Revision: 121879 URL: http://llvm.org/viewvc/llvm-project?rev=121879&view=rev Log: Add test cases to test various aspect of the 'alias' command. Added: lldb/trunk/test/alias_tests/ lldb/trunk/test/alias_tests/Makefile lldb/trunk/test/alias_tests/TestAliases.py lldb/trunk/test/alias_tests/main.cpp Added: lldb/trunk/test/alias_tests/Makefile URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/alias_tests/Makefile?rev=121879&view=auto ============================================================================== --- lldb/trunk/test/alias_tests/Makefile (added) +++ lldb/trunk/test/alias_tests/Makefile Wed Dec 15 13:04:51 2010 @@ -0,0 +1,5 @@ +LEVEL = ../make + +CXX_SOURCES := main.cpp + +include $(LEVEL)/Makefile.rules Added: lldb/trunk/test/alias_tests/TestAliases.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/alias_tests/TestAliases.py?rev=121879&view=auto ============================================================================== --- lldb/trunk/test/alias_tests/TestAliases.py (added) +++ lldb/trunk/test/alias_tests/TestAliases.py Wed Dec 15 13:04:51 2010 @@ -0,0 +1,129 @@ +""" +Test lldb command aliases. +""" + +import os, time +import unittest2 +import lldb +from lldbtest import * + +class AliasTestCase(TestBase): + + mydir = "alias_tests" + + @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin") + def test_with_dsym (self): + self.buildDsym () + self.alias_tests () + + def test_with_dwarf (self): + self.buildDwarf () + self.alias_tests () + + def alias_tests (self): + exe = os.path.join (os.getcwd(), "a.out") + self.expect("file " + exe, + patterns = [ "Current executable set to .*a.out" ]) + + + self.runCmd (r'''command alias hello expr (int) printf ("\n\nHello, anybody!\n\n")''') + + self.runCmd ("command alias python script") + self.runCmd (r'''python print "\n\n\nWhoopee!\n\n\n"''') +# self.expect (r'''python print "\n\n\nWhoopee!\n\n\n"''', +# substrs = [ "Whoopee!" ]) + + self.runCmd (r'''python print "\n\t\x68\x65\x6c\x6c\x6f\n"''') +# self.expect (r'''python print "\n\t\x68\x65\x6c\x6c\x6f\n"''', +# substrs = [ "hello" ]) + + self.runCmd (r'''command alias pp python print "\n\t\x68\x65\x6c\x6c\x6f\n"''') + self.runCmd ("pp") +# self.expect ("pp", +# substrs = [ "hello" ]) + + + self.runCmd ("commands alias alias commands alias") + self.runCmd ("commands alias unalias commands unalias") + + self.runCmd ("alias myrun process launch -t%1 --") + self.runCmd ("alias bp breakpoint") + + self.expect ("alias bpa bp add", + COMMAND_FAILED_AS_EXPECTED, error = True, + substrs = [ "'add' is not a valid sub-command of 'bp'" ]) + + self.runCmd ("alias bpa bp command add") + self.runCmd ("alias bpi bp list") + + self.expect ("bp set -n foo", + startstr = "Breakpoint created: 1: name = 'foo', locations = 1") + + self.expect ("bp set -n sum", + startstr = "Breakpoint created: 2: name = 'sum', locations = 1") + + self.runCmd ("alias bfl bp set -f %1 -l %2") + self.expect ("bfl main.cpp 32", + startstr = "Breakpoint created: 3: file ='main.cpp', line = 32, locations = 1") + + self.expect ("bpi", + startstr = "Current breakpoints:", + substrs = [ "1: name = 'foo', locations = 1", + "2: name = 'sum', locations = 1", + "3: file ='main.cpp', line = 32, locations = 1" ]) + + self.runCmd ("bpa -p 1 -o 'print frame; print bp_loc'") + self.runCmd ("bpa -c 2 -o 'frame variable b'") + self.expect ("bpi", + substrs = [ "Current breakpoints:", + "1: name = 'foo', locations = 1", + "print frame; print bp_loc", + "2: name = 'sum', locations = 1", + "frame variable b" ]) + self.expect ("run", + patterns = [ "Process .* launched: .*a.out" ]) + + self.expect (r'''expression printf("\x68\x65\x6c\x6c\x6f\n")''', + substrs = [ "(unsigned long) $", + "= 6" ]) + + self.expect ("hello", + substrs = [ "(int) $", + "= 19" ]) + + self.expect ("expr -f x -- 68", + substrs = [ "(int) $", + "= 0x00000044" ]) + + self.runCmd ("alias exprf expr -f %1") + self.runCmd ("alias exprf2 expr -f %1 --") + self.expect ("exprf x -- 1234", + substrs = [ "(int) $", + "= 0x000004d2" ]) + + self.expect ('exprf2 s "Hi there!"', + substrs = [ "(const char) [0] = 'H'", + "(const char) [1] = 'i'", + "(const char) [2] = ' '", + "(const char) [3] = 't'", + "(const char) [4] = 'h'", + "(const char) [5] = 'e'", + "(const char) [6] = 'r'", + "(const char) [7] = 'e'", + "(const char) [8] = '!'", + "(const char) [9] = '\\0'" ]) + + + self.expect ("exprf x 1234", + COMMAND_FAILED_AS_EXPECTED, error = True, + substrs = [ "use of undeclared identifier 'f'", + "1 errors parsing expression" ]) + + + +if __name__ == '__main__': + import atexit + lldb.SBDebugger.Initialize() + atexit.register(lambda: lldb.SBDebugger.Terminate()) + unittest2.main() + Added: lldb/trunk/test/alias_tests/main.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/alias_tests/main.cpp?rev=121879&view=auto ============================================================================== --- lldb/trunk/test/alias_tests/main.cpp (added) +++ lldb/trunk/test/alias_tests/main.cpp Wed Dec 15 13:04:51 2010 @@ -0,0 +1,62 @@ +//===-- main.cpp ------------------------------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#include +#include +#include +#include + +int +product (int x, int y) +{ + int result = x * y; + return result; +} + +int +sum (int a, int b) +{ + int result = a + b; + return result; +} + +int +strange_max (int m, int n) +{ + if (m > n) + return m; + else if (n > m) + return n; + else + return 0; +} + +int +foo (int i, int j) +{ + if (strange_max (i, j) == i) + return product (i, j); + else if (strange_max (i, j) == j) + return sum (i, j); + else + return product (sum (i, i), sum (j, j)); +} + +int +main(int argc, char const *argv[]) +{ + + int array[3]; + + array[0] = foo (1238, 78392); + array[1] = foo (379265, 23674); + array[2] = foo (872934, 234); + + return 0; +} From ctice at apple.com Wed Dec 15 13:51:12 2010 From: ctice at apple.com (Caroline Tice) Date: Wed, 15 Dec 2010 19:51:12 -0000 Subject: [Lldb-commits] [lldb] r121884 - /lldb/trunk/source/Interpreter/ScriptInterpreterPython.cpp Message-ID: <20101215195112.C4C912A6C12C@llvm.org> Author: ctice Date: Wed Dec 15 13:51:12 2010 New Revision: 121884 URL: http://llvm.org/viewvc/llvm-project?rev=121884&view=rev Log: Add termination instructions when entering the interactive script interpreter. Modified: lldb/trunk/source/Interpreter/ScriptInterpreterPython.cpp Modified: lldb/trunk/source/Interpreter/ScriptInterpreterPython.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Interpreter/ScriptInterpreterPython.cpp?rev=121884&r1=121883&r2=121884&view=diff ============================================================================== --- lldb/trunk/source/Interpreter/ScriptInterpreterPython.cpp (original) +++ lldb/trunk/source/Interpreter/ScriptInterpreterPython.cpp Wed Dec 15 13:51:12 2010 @@ -330,11 +330,20 @@ if (baton == NULL) return 0; + FILE *out_fh = reader.GetDebugger().GetOutputFileHandle (); + if (out_fh == NULL) + out_fh = stdout; + ScriptInterpreterPython *script_interpreter = (ScriptInterpreterPython *) baton; switch (notification) { case eInputReaderActivate: { + if (out_fh) + { + ::fprintf (out_fh, "Python Interactive Interpreter. To exit Python, type 'quit()' or 'exit()'.\n"); + ::fprintf (out_fh, "Do NOT use Ctrl-D (EOF) to exit, as that will cause the lldb debugger to hang.\n"); + } // Save terminal settings if we can int input_fd; FILE *input_fh = reader.GetDebugger().GetInputFileHandle(); From johnny.chen at apple.com Wed Dec 15 14:11:04 2010 From: johnny.chen at apple.com (Johnny Chen) Date: Wed, 15 Dec 2010 20:11:04 -0000 Subject: [Lldb-commits] [lldb] r121887 - /lldb/trunk/test/blacklist.py Message-ID: <20101215201104.8BD252A6C12C@llvm.org> Author: johnny Date: Wed Dec 15 14:11:04 2010 New Revision: 121887 URL: http://llvm.org/viewvc/llvm-project?rev=121887&view=rev Log: Add an entry for test case BasicExprCommandsTestCase.test_evaluate_expression_python, due to crashes while running the entire test suite with clang-126. To reproduce: CC=clang ./dotest.py -v -w 2> ~/Developer/Log/lldbtest.log To skip this test case: CC=clang ./dotest.py -b blacklist.py -v -w 2> ~/Developer/Log/lldbtest.log Modified: lldb/trunk/test/blacklist.py Modified: lldb/trunk/test/blacklist.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/blacklist.py?rev=121887&r1=121886&r2=121887&view=diff ============================================================================== --- lldb/trunk/test/blacklist.py (original) +++ lldb/trunk/test/blacklist.py Wed Dec 15 14:11:04 2010 @@ -13,4 +13,9 @@ } """ -blacklist = {} +blacklist = {'BasicExprCommandsTestCase.test_evaluate_expression_python': 'Crashed while running the entire test suite with CC=clang' + # To reproduce the crash: CC=clang ./dotest.py -v -w 2> ~/Developer/Log/lldbtest.log + # The clang version used is clang-126. + # Two radars filed for the crashes: rdar://problem/8769826 and rdar://problem/8773329. + # To skip this test case: CC=clang ./dotest.py -b blacklist.py -v -w 2> ~/Developer/Log/lldbtest.log + } From wilsons at start.ca Wed Dec 15 14:28:35 2010 From: wilsons at start.ca (Stephen Wilson) Date: Wed, 15 Dec 2010 15:28:35 -0500 Subject: [Lldb-commits] [PATCH] linux: fix include in lldb.swig Message-ID: I would appreciate it if someone with experience in Swig could look this one over. I am not 100% positive this is the proper fix. Use #include rather than the Swig %include directive. In order to use the %include directive Swig needs to be instructed as to the search path. However, Swig 1.3.40 cannot process stdint.h provided by glibc. This fix takes advantage of the fact that, by default, Swig does not process headers introduced via #include. diff --git a/scripts/lldb.swig b/scripts/lldb.swig index 95c409e..63167c8 100644 --- a/scripts/lldb.swig +++ b/scripts/lldb.swig @@ -97,7 +97,7 @@ %} /* Various liblldb typedefs that SWIG needs to know about. */ -%include +#include %include "lldb/lldb-defines.h" %include "lldb/lldb-enumerations.h" %include "lldb/lldb-forward.h" From wilsons at start.ca Wed Dec 15 14:34:21 2010 From: wilsons at start.ca (Stephen Wilson) Date: Wed, 15 Dec 2010 15:34:21 -0500 Subject: [Lldb-commits] [PATCH] linux: fix SBBreakpoint::GetThreadIndex Message-ID: Log using the proper argument and make SBBreakpoint::GetThreadIndex return the thread index instead of zero. diff --git a/source/API/SBBreakpoint.cpp b/source/API/SBBreakpoint.cpp index f2dccf9..eed986d 100644 --- a/source/API/SBBreakpoint.cpp +++ b/source/API/SBBreakpoint.cpp @@ -319,9 +319,9 @@ SBBreakpoint::GetThreadIndex() const } LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); if (log) - log->Printf ("SBBreakpoint(%p)::GetThreadIndex () => %u", m_opaque_sp.get(), index); + log->Printf ("SBBreakpoint(%p)::GetThreadIndex () => %u", m_opaque_sp.get(), thread_idx); - return 0; + return thread_idx; } From wilsons at start.ca Wed Dec 15 14:40:54 2010 From: wilsons at start.ca (Stephen Wilson) Date: Wed, 15 Dec 2010 15:40:54 -0500 Subject: [Lldb-commits] [PATCH] linux: const violation Message-ID: Fix invalid conversion from "const char *" to "char *". diff --git a/source/Target/Process.cpp b/source/Target/Process.cpp index c949555..7237815 100644 --- a/source/Target/Process.cpp +++ b/source/Target/Process.cpp @@ -371,7 +371,7 @@ Process::ProcessInstanceSettings::GetHostEnvironmentIfNeeded () const char *env_entry = host_env.GetStringAtIndex (idx); if (env_entry) { - char *equal_pos = ::strchr(env_entry, '='); + const char *equal_pos = ::strchr(env_entry, '='); if (equal_pos) { std::string key (env_entry, equal_pos - env_entry); From jingham at apple.com Wed Dec 15 14:47:34 2010 From: jingham at apple.com (Jim Ingham) Date: Wed, 15 Dec 2010 20:47:34 -0000 Subject: [Lldb-commits] [lldb] r121894 - in /lldb/trunk/test/foundation: Makefile TestObjCMethods.py main.m my-base.h my-base.m Message-ID: <20101215204734.7B2242A6C12C@llvm.org> Author: jingham Date: Wed Dec 15 14:47:34 2010 New Revision: 121894 URL: http://llvm.org/viewvc/llvm-project?rev=121894&view=rev Log: Added a test for finding the correct values for ivars when a property causes the ivar offsets in the DWARF to be incorrect. Added: lldb/trunk/test/foundation/my-base.h lldb/trunk/test/foundation/my-base.m Modified: lldb/trunk/test/foundation/Makefile lldb/trunk/test/foundation/TestObjCMethods.py lldb/trunk/test/foundation/main.m Modified: lldb/trunk/test/foundation/Makefile URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/foundation/Makefile?rev=121894&r1=121893&r2=121894&view=diff ============================================================================== --- lldb/trunk/test/foundation/Makefile (original) +++ lldb/trunk/test/foundation/Makefile Wed Dec 15 14:47:34 2010 @@ -1,6 +1,6 @@ LEVEL = ../make -OBJC_SOURCES := main.m +OBJC_SOURCES := main.m my-base.m LDFLAGS = $(CFLAGS) -lobjc -framework Foundation include $(LEVEL)/Makefile.rules Modified: lldb/trunk/test/foundation/TestObjCMethods.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/foundation/TestObjCMethods.py?rev=121894&r1=121893&r2=121894&view=diff ============================================================================== --- lldb/trunk/test/foundation/TestObjCMethods.py (original) +++ lldb/trunk/test/foundation/TestObjCMethods.py Wed Dec 15 14:47:34 2010 @@ -39,6 +39,16 @@ self.buildDwarf() self.data_type_and_expr_objc() + @python_api_test + def test_print_ivars_correctly_with_dsym (self): + self.buildDsym() + self.print_ivars_correctly() + + @python_api_test + def test_print_ivars_correctly_with_dwarf (self): + self.buildDwarf() + self.print_ivars_correctly() + def break_on_objc_methods(self): """Test setting objc breakpoints using 'regexp-break' and 'breakpoint set'.""" exe = os.path.join(os.getcwd(), "a.out") @@ -100,7 +110,8 @@ # Call super's setUp(). TestBase.setUp(self) # Find the line number to break inside main(). - self.line = line_number('main.m', '// Set break point at this line.') + self.main_source = "main.m" + self.line = line_number(self.main_source, '// Set break point at this line.') def data_type_and_expr_objc(self): """Lookup objective-c data types and evaluate expressions.""" @@ -151,7 +162,7 @@ # This should display the str and date member fields as well. self.expect("frame variable -t *self", VARIABLES_DISPLAYED_CORRECTLY, - substrs = ["(MyString) *self", + substrs = ["(MyString *) self", "(NSString *) str", "(NSDate *) date"]) @@ -189,7 +200,54 @@ self.expect("expression -o -- my", "Object description displayed correctly", patterns = ["Hello from.*a.out.*with timestamp: "]) + @unittest2.expectedFailure + # See: lldb needs to use the ObjC runtime symbols for ivar offsets + # Only fails for the ObjC 2.0 runtime. + def print_ivars_correctly(self) : + exe = os.path.join(os.getcwd(), "a.out") + + target = self.dbg.CreateTarget(exe) + self.assertTrue(target.IsValid(), VALID_TARGET) + + break1 = target.BreakpointCreateByLocation(self.main_source, self.line) + self.assertTrue(break1.IsValid(), VALID_BREAKPOINT) + + # Now launch the process, and do not stop at entry point. + self.process = target.LaunchProcess([], [], os.ctermid(), 0, False) + + self.assertTrue(self.process.IsValid(), PROCESS_IS_VALID) + + # The stop reason of the thread should be breakpoint. + thread = self.process.GetThreadAtIndex(0) + if thread.GetStopReason() != lldb.eStopReasonBreakpoint: + from lldbutil import StopReasonString + self.fail(STOPPED_DUE_TO_BREAKPOINT_WITH_STOP_REASON_AS % + StopReasonString(thread.GetStopReason())) + + # Make sure we stopped at the first breakpoint. + + cur_frame = thread.GetFrameAtIndex(0) + + line_number = cur_frame.GetLineEntry().GetLine() + self.assertTrue (line_number == self.line, "Hit the first breakpoint.") + + my_var = cur_frame.FindVariable("my") + self.assertTrue(my_var.IsValid(), "Made a variable object for my") + + str_var = cur_frame.FindVariable("str") + self.assertTrue(str_var.IsValid(), "Made a variable object for str") + + # Now make sure that the my->str == str: + + my_str_var = my_var.GetChildMemberWithName("str") + self.assertTrue(my_str_var.IsValid(), "Found a str ivar in my") + + str_value = int(str_var.GetValue(cur_frame), 0) + + my_str_value = int(my_str_var.GetValue(cur_frame), 0) + self.assertTrue(str_value == my_str_value, "Got the correct value for my->str") + if __name__ == '__main__': import atexit lldb.SBDebugger.Initialize() Modified: lldb/trunk/test/foundation/main.m URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/foundation/main.m?rev=121894&r1=121893&r2=121894&view=diff ============================================================================== --- lldb/trunk/test/foundation/main.m (original) +++ lldb/trunk/test/foundation/main.m Wed Dec 15 14:47:34 2010 @@ -1,12 +1,14 @@ #import #include +#import "my-base.h" - at interface MyString : NSObject { + at interface MyString : MyBase { NSString *str; NSDate *date; BOOL _desc_pauses; } + at property(retain) NSString * str_property; @property BOOL descriptionPauses; - (id)initWithNSString:(NSString *)string; @@ -14,6 +16,7 @@ @implementation MyString @synthesize descriptionPauses = _desc_pauses; + at synthesize str_property = str; - (id)initWithNSString:(NSString *)string { @@ -88,8 +91,7 @@ NSString *str = [NSString stringWithFormat:@"Hello from '%s'", program]; MyString *my = [[MyString alloc] initWithNSString:str]; NSLog(@"MyString instance: %@", [my description]); - // Set break point at this line. Test 'expression -o -- my'. - my.descriptionPauses = YES; + my.descriptionPauses = YES; // Set break point at this line. Test 'expression -o -- my'. NSLog(@"MyString instance: %@", [my description]); } Added: lldb/trunk/test/foundation/my-base.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/foundation/my-base.h?rev=121894&view=auto ============================================================================== --- lldb/trunk/test/foundation/my-base.h (added) +++ lldb/trunk/test/foundation/my-base.h Wed Dec 15 14:47:34 2010 @@ -0,0 +1,8 @@ + at interface MyBase : NSObject +{ +#if !__OBJC2__ + int maybe_used; // The 1.0 runtime needs to have backed properties... +#endif +} + at property int propertyMovesThings; + at end Added: lldb/trunk/test/foundation/my-base.m URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/foundation/my-base.m?rev=121894&view=auto ============================================================================== --- lldb/trunk/test/foundation/my-base.m (added) +++ lldb/trunk/test/foundation/my-base.m Wed Dec 15 14:47:34 2010 @@ -0,0 +1,10 @@ +#import +#import "my-base.h" + at implementation MyBase +#if __OBJC2__ + at synthesize propertyMovesThings; +#else + at synthesize propertyMovesThings = maybe_used; +#endif + at end + From gclayton at apple.com Wed Dec 15 14:50:06 2010 From: gclayton at apple.com (Greg Clayton) Date: Wed, 15 Dec 2010 20:50:06 -0000 Subject: [Lldb-commits] [lldb] r121896 - in /lldb/trunk/source: API/SBBreakpoint.cpp Target/ThreadSpec.cpp Message-ID: <20101215205007.072A82A6C12C@llvm.org> Author: gclayton Date: Wed Dec 15 14:50:06 2010 New Revision: 121896 URL: http://llvm.org/viewvc/llvm-project?rev=121896&view=rev Log: Fixed an error where the thread index was being returned as zero in "uint32_t SBBreakpoint::GetThreadIndex() const" even when it isn't specified. It should be UINT32_MAX to indicate there is no thread index set for the breakpoint (the breakpoint isn't thread specific). Also fixed the ThreadSpec.cpp to use UINT32_MAX instead of -1. Fixed the logging Printf statement in "uint32_t SBBreakpoint::GetThreadIndex() const" to not print the address of the "index" function from ! Modified: lldb/trunk/source/API/SBBreakpoint.cpp lldb/trunk/source/Target/ThreadSpec.cpp Modified: lldb/trunk/source/API/SBBreakpoint.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBBreakpoint.cpp?rev=121896&r1=121895&r2=121896&view=diff ============================================================================== --- lldb/trunk/source/API/SBBreakpoint.cpp (original) +++ lldb/trunk/source/API/SBBreakpoint.cpp Wed Dec 15 14:50:06 2010 @@ -310,7 +310,7 @@ uint32_t SBBreakpoint::GetThreadIndex() const { - uint32_t thread_idx = 0; + uint32_t thread_idx = UINT32_MAX; if (m_opaque_sp) { const ThreadSpec *thread_spec = m_opaque_sp->GetOptions()->GetThreadSpec(); @@ -319,9 +319,9 @@ } LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); if (log) - log->Printf ("SBBreakpoint(%p)::GetThreadIndex () => %u", m_opaque_sp.get(), index); + log->Printf ("SBBreakpoint(%p)::GetThreadIndex () => %u", m_opaque_sp.get(), thread_idx); - return 0; + return UINT32_MAX; } Modified: lldb/trunk/source/Target/ThreadSpec.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/ThreadSpec.cpp?rev=121896&r1=121895&r2=121896&view=diff ============================================================================== --- lldb/trunk/source/Target/ThreadSpec.cpp (original) +++ lldb/trunk/source/Target/ThreadSpec.cpp Wed Dec 15 14:50:06 2010 @@ -14,7 +14,7 @@ using namespace lldb_private; ThreadSpec::ThreadSpec() : - m_index (-1), + m_index (UINT32_MAX), m_tid (LLDB_INVALID_THREAD_ID), m_name(), m_queue_name () @@ -83,7 +83,7 @@ bool ThreadSpec::HasSpecification() const { - return (m_index != -1 || m_tid != LLDB_INVALID_THREAD_ID || !m_name.empty() || !m_queue_name.empty()); + return (m_index != UINT32_MAX || m_tid != LLDB_INVALID_THREAD_ID || !m_name.empty() || !m_queue_name.empty()); } void ThreadSpec::GetDescription (Stream *s, lldb::DescriptionLevel level) const @@ -106,7 +106,7 @@ if (GetTID() != LLDB_INVALID_THREAD_ID) s->Printf("tid: 0x%llx ", GetTID()); - if (GetIndex() != -1) + if (GetIndex() != UINT32_MAX) s->Printf("index: %d ", GetIndex()); const char *name = GetName(); From gclayton at apple.com Wed Dec 15 14:53:29 2010 From: gclayton at apple.com (Greg Clayton) Date: Wed, 15 Dec 2010 12:53:29 -0800 Subject: [Lldb-commits] [PATCH] linux: fix SBBreakpoint::GetThreadIndex In-Reply-To: References: Message-ID: <3A417CED-D342-4F0C-B218-0DD092947A83@apple.com> A modified fix that correctly returns UINT32_MAX when the breakpoint isn't thread specific was applied with: File: /Volumes/work/gclayton/Documents/src/lldb/source/Target/ThreadSpec.cpp Revision: 121896 Date: Wednesday, December 15, 2010 12:50:06 PM PT Author: gclayton Fixed an error where the thread index was being returned as zero in "uint32_t SBBreakpoint::GetThreadIndex() const" even when it isn't specified. It should be UINT32_MAX to indicate there is no thread index set for the breakpoint (the breakpoint isn't thread specific). Also fixed the ThreadSpec.cpp to use UINT32_MAX instead of -1. Fixed the logging Printf statement in "uint32_t SBBreakpoint::GetThreadIndex() const" to not print the address of the "index" function from ! Changes: M /lldb/trunk/source/API/SBBreakpoint.cpp M /lldb/trunk/source/Target/ThreadSpec.cpp Thanks Stephen On Dec 15, 2010, at 12:34 PM, Stephen Wilson wrote: > > Log using the proper argument and make SBBreakpoint::GetThreadIndex > return the thread index instead of zero. > > diff --git a/source/API/SBBreakpoint.cpp b/source/API/SBBreakpoint.cpp > index f2dccf9..eed986d 100644 > --- a/source/API/SBBreakpoint.cpp > +++ b/source/API/SBBreakpoint.cpp > @@ -319,9 +319,9 @@ SBBreakpoint::GetThreadIndex() const > } > LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); > if (log) > - log->Printf ("SBBreakpoint(%p)::GetThreadIndex () => %u", m_opaque_sp.get(), index); > + log->Printf ("SBBreakpoint(%p)::GetThreadIndex () => %u", m_opaque_sp.get(), thread_idx); > > - return 0; > + return thread_idx; > } > _______________________________________________ > lldb-commits mailing list > lldb-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/lldb-commits From gclayton at apple.com Wed Dec 15 14:52:40 2010 From: gclayton at apple.com (Greg Clayton) Date: Wed, 15 Dec 2010 20:52:40 -0000 Subject: [Lldb-commits] [lldb] r121897 - /lldb/trunk/source/Target/Process.cpp Message-ID: <20101215205240.5380F2A6C12C@llvm.org> Author: gclayton Date: Wed Dec 15 14:52:40 2010 New Revision: 121897 URL: http://llvm.org/viewvc/llvm-project?rev=121897&view=rev Log: Fix invalid conversion from "const char *" to "char *" for linux systems. strchr() on darwin returns "char *" so we weren't seeing this issue on MacOSX. Modified: lldb/trunk/source/Target/Process.cpp Modified: lldb/trunk/source/Target/Process.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/Process.cpp?rev=121897&r1=121896&r2=121897&view=diff ============================================================================== --- lldb/trunk/source/Target/Process.cpp (original) +++ lldb/trunk/source/Target/Process.cpp Wed Dec 15 14:52:40 2010 @@ -371,7 +371,7 @@ const char *env_entry = host_env.GetStringAtIndex (idx); if (env_entry) { - char *equal_pos = ::strchr(env_entry, '='); + const char *equal_pos = ::strchr(env_entry, '='); if (equal_pos) { std::string key (env_entry, equal_pos - env_entry); From gclayton at apple.com Wed Dec 15 14:55:33 2010 From: gclayton at apple.com (Greg Clayton) Date: Wed, 15 Dec 2010 12:55:33 -0800 Subject: [Lldb-commits] [PATCH] linux: const violation In-Reply-To: References: Message-ID: File: /Volumes/work/gclayton/Documents/src/lldb/source/Target/Process.cpp Revision: 121897 Date: Wednesday, December 15, 2010 12:52:40 PM PT Author: gclayton Fix invalid conversion from "const char *" to "char *" for linux systems. strchr() on darwin returns "char *" so we weren't seeing this issue on MacOSX. Changes: M /lldb/trunk/source/Target/Process.cpp On Dec 15, 2010, at 12:40 PM, Stephen Wilson wrote: > > Fix invalid conversion from "const char *" to "char *". > > diff --git a/source/Target/Process.cpp b/source/Target/Process.cpp > index c949555..7237815 100644 > --- a/source/Target/Process.cpp > +++ b/source/Target/Process.cpp > @@ -371,7 +371,7 @@ Process::ProcessInstanceSettings::GetHostEnvironmentIfNeeded () > const char *env_entry = host_env.GetStringAtIndex (idx); > if (env_entry) > { > - char *equal_pos = ::strchr(env_entry, '='); > + const char *equal_pos = ::strchr(env_entry, '='); > if (equal_pos) > { > std::string key (env_entry, equal_pos - env_entry); > _______________________________________________ > lldb-commits mailing list > lldb-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/lldb-commits From gclayton at apple.com Wed Dec 15 15:03:50 2010 From: gclayton at apple.com (Greg Clayton) Date: Wed, 15 Dec 2010 13:03:50 -0800 Subject: [Lldb-commits] [PATCH] linux: fix include in lldb.swig In-Reply-To: References: Message-ID: <4535BD27-D1B7-4F83-B96C-54B8D16857FA@apple.com> I am not sure this is what we want either. We want the UINT32_MAX and friends to be defined in the generated SWIG file since we use them to test for invalid indexes (much like in the "uint32_t SBBreakpoint::GetThreadIndex() const" function. Can you try setting your PYTHONPATH to point to the lldb.so on linux (the lldb.py file needs to be in the same directory and then make and run this python script: % setenv PYTHONPATH /build/Debug/LLDB.framework/Resources/Python % cat dirlldb.py #!/usr/bin/python import lldb print dir(lldb) If I do this on MacOSX I see all of the stuff from stdint.h: % ./dirlldb.py ['INT16_MAX', 'INT16_MIN', 'INT32_MAX', 'INT32_MIN', 'INT64_MAX', 'INT64_MIN', 'INT8_MAX', 'INT8_MIN', 'INTMAX_MAX', 'INTMAX_MIN', 'INTPTR_MAX', 'INTPTR_MIN', 'INT_FAST16_MAX', 'INT_FAST16_MIN', 'INT_FAST32_MAX', 'INT_FAST32_MIN', 'INT_FAST64_MAX', 'INT_FAST64_MIN', 'INT_FAST8_MAX', 'INT_FAST8_MIN', 'INT_LEAST16_MAX', 'INT_LEAST16_MIN', 'INT_LEAST32_MAX', 'INT_LEAST32_MIN', 'INT_LEAST64_MAX', 'INT_LEAST64_MIN', 'INT_LEAST8_MAX', 'INT_LEAST8_MIN', 'LLDB_ARCH_DEFAULT', ... Do you still see these in the resulting SWIG module when you use #include? On Dec 15, 2010, at 12:28 PM, Stephen Wilson wrote: > > I would appreciate it if someone with experience in Swig could look this > one over. I am not 100% positive this is the proper fix. > > > Use #include rather than the Swig %include directive. > > In order to use the %include directive Swig needs to be instructed as to the > search path. However, Swig 1.3.40 cannot process stdint.h provided by glibc. > This fix takes advantage of the fact that, by default, Swig does not process > headers introduced via #include. > > diff --git a/scripts/lldb.swig b/scripts/lldb.swig > index 95c409e..63167c8 100644 > --- a/scripts/lldb.swig > +++ b/scripts/lldb.swig > @@ -97,7 +97,7 @@ > %} > > /* Various liblldb typedefs that SWIG needs to know about. */ > -%include > +#include > %include "lldb/lldb-defines.h" > %include "lldb/lldb-enumerations.h" > %include "lldb/lldb-forward.h" > _______________________________________________ > lldb-commits mailing list > lldb-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/lldb-commits From wilsons at start.ca Wed Dec 15 15:31:11 2010 From: wilsons at start.ca (Stephen Wilson) Date: Wed, 15 Dec 2010 16:31:11 -0500 Subject: [Lldb-commits] [PATCH] linux: fix include in lldb.swig In-Reply-To: <4535BD27-D1B7-4F83-B96C-54B8D16857FA@apple.com> (Greg Clayton's message of "Wed, 15 Dec 2010 13:03:50 -0800") References: <4535BD27-D1B7-4F83-B96C-54B8D16857FA@apple.com> Message-ID: Hi Greg, Greg Clayton writes: > I am not sure this is what we want either. We want the UINT32_MAX and friends to > be defined in the generated SWIG file since we use them to test for invalid > indexes (much like in the "uint32_t SBBreakpoint::GetThreadIndex() const" > function. Can you try setting your PYTHONPATH to point to the lldb.so on linux > (the lldb.py file needs to be in the same directory and then make and run this > python script: I hope this question is not too stupid, but where is lldb.py? I see a reference in dotest.py indicating that it is distributed with XCode4. If it is not in the lldb tree, do you have a link handy (google can't seem to help me here)? > % setenv PYTHONPATH /build/Debug/LLDB.framework/Resources/Python % cat > dirlldb.py #!/usr/bin/python import lldb print dir(lldb) > > > If I do this on MacOSX I see all of the stuff from stdint.h: > > % ./dirlldb.py ['INT16_MAX', 'INT16_MIN', 'INT32_MAX', 'INT32_MIN', 'INT64_MAX', > INT64_MIN', 'INT8_MAX', 'INT8_MIN', 'INTMAX_MAX', 'INTMAX_MIN', 'INTPTR_MAX', > INTPTR_MIN', 'INT_FAST16_MAX', 'INT_FAST16_MIN', 'INT_FAST32_MAX', > INT_FAST32_MIN', 'INT_FAST64_MAX', 'INT_FAST64_MIN', 'INT_FAST8_MAX', > INT_FAST8_MIN', 'INT_LEAST16_MAX', 'INT_LEAST16_MIN', 'INT_LEAST32_MAX', > INT_LEAST32_MIN', 'INT_LEAST64_MAX', 'INT_LEAST64_MIN', 'INT_LEAST8_MAX', > INT_LEAST8_MIN', 'LLDB_ARCH_DEFAULT', ... > > Do you still see these in the resulting SWIG module when you use #include? > > > On Dec 15, 2010, at 12:28 PM, Stephen Wilson wrote: > >> I would appreciate it if someone with experience in Swig could look this one >> over. I am not 100% positive this is the proper fix. >> >> >> Use #include rather than the Swig %include directive. >> >> In order to use the %include directive Swig needs to be instructed as to >> the search path. However, Swig 1.3.40 cannot process stdint.h provided by >> glibc. This fix takes advantage of the fact that, by default, Swig does not >> process headers introduced via #include. >> >> diff --git a/scripts/lldb.swig b/scripts/lldb.swig index 95c409e..63167c8 >> 100644 --- a/scripts/lldb.swig +++ b/scripts/lldb.swig @@ -97,7 +97,7 @@ %} >> >> /* Various liblldb typedefs that SWIG needs to know about. */ -%include >> +#include %include "lldb/lldb-defines.h" %include >> "lldb/lldb-enumerations.h" %include "lldb/lldb-forward.h" >> _______________________________________________ lldb-commits mailing list >> lldb-commits at cs.uiuc.edu >> http://lists.cs.uiuc.edu/mailman/listinfo/lldb-commits > -- steve From gclayton at apple.com Wed Dec 15 15:36:13 2010 From: gclayton at apple.com (Greg Clayton) Date: Wed, 15 Dec 2010 13:36:13 -0800 Subject: [Lldb-commits] [PATCH] linux: fix include in lldb.swig In-Reply-To: References: <4535BD27-D1B7-4F83-B96C-54B8D16857FA@apple.com> Message-ID: On Dec 15, 2010, at 1:31 PM, Stephen Wilson wrote: > > Hi Greg, > > Greg Clayton writes: > >> I am not sure this is what we want either. We want the UINT32_MAX and friends to >> be defined in the generated SWIG file since we use them to test for invalid >> indexes (much like in the "uint32_t SBBreakpoint::GetThreadIndex() const" >> function. Can you try setting your PYTHONPATH to point to the lldb.so on linux >> (the lldb.py file needs to be in the same directory and then make and run this >> python script: > > I hope this question is not too stupid, but where is lldb.py? I see a > reference in dotest.py indicating that it is distributed with XCode4. > If it is not in the lldb tree, do you have a link handy (google can't > seem to help me here)? the swig invocation should produce the lldb.py file. Not sure where it will end up on linux, possibly next to the "lldb" binary? > >> % setenv PYTHONPATH /build/Debug/LLDB.framework/Resources/Python % cat >> dirlldb.py #!/usr/bin/python import lldb print dir(lldb) >> >> >> If I do this on MacOSX I see all of the stuff from stdint.h: >> >> % ./dirlldb.py ['INT16_MAX', 'INT16_MIN', 'INT32_MAX', 'INT32_MIN', 'INT64_MAX', >> INT64_MIN', 'INT8_MAX', 'INT8_MIN', 'INTMAX_MAX', 'INTMAX_MIN', 'INTPTR_MAX', >> INTPTR_MIN', 'INT_FAST16_MAX', 'INT_FAST16_MIN', 'INT_FAST32_MAX', >> INT_FAST32_MIN', 'INT_FAST64_MAX', 'INT_FAST64_MIN', 'INT_FAST8_MAX', >> INT_FAST8_MIN', 'INT_LEAST16_MAX', 'INT_LEAST16_MIN', 'INT_LEAST32_MAX', >> INT_LEAST32_MIN', 'INT_LEAST64_MAX', 'INT_LEAST64_MIN', 'INT_LEAST8_MAX', >> INT_LEAST8_MIN', 'LLDB_ARCH_DEFAULT', ... >> >> Do you still see these in the resulting SWIG module when you use #include? >> >> >> On Dec 15, 2010, at 12:28 PM, Stephen Wilson wrote: >> >>> I would appreciate it if someone with experience in Swig could look this one >>> over. I am not 100% positive this is the proper fix. >>> >>> >>> Use #include rather than the Swig %include directive. >>> >>> In order to use the %include directive Swig needs to be instructed as to >>> the search path. However, Swig 1.3.40 cannot process stdint.h provided by >>> glibc. This fix takes advantage of the fact that, by default, Swig does not >>> process headers introduced via #include. >>> >>> diff --git a/scripts/lldb.swig b/scripts/lldb.swig index 95c409e..63167c8 >>> 100644 --- a/scripts/lldb.swig +++ b/scripts/lldb.swig @@ -97,7 +97,7 @@ %} >>> >>> /* Various liblldb typedefs that SWIG needs to know about. */ -%include >>> +#include %include "lldb/lldb-defines.h" %include >>> "lldb/lldb-enumerations.h" %include "lldb/lldb-forward.h" >>> _______________________________________________ lldb-commits mailing list >>> lldb-commits at cs.uiuc.edu >>> http://lists.cs.uiuc.edu/mailman/listinfo/lldb-commits >> > > -- > steve From johnny.chen at apple.com Wed Dec 15 15:39:37 2010 From: johnny.chen at apple.com (Johnny Chen) Date: Wed, 15 Dec 2010 21:39:37 -0000 Subject: [Lldb-commits] [lldb] r121898 - in /lldb/trunk: source/API/SBBreakpoint.cpp test/breakpoint_conditions/TestBreakpointConditions.py Message-ID: <20101215213937.856172A6C12C@llvm.org> Author: johnny Date: Wed Dec 15 15:39:37 2010 New Revision: 121898 URL: http://llvm.org/viewvc/llvm-project?rev=121898&view=rev Log: Fix typos in SBBreakpoint::GetThreadIndex()/GetThreadName(), and test sequences for the two API calls. Modified: lldb/trunk/source/API/SBBreakpoint.cpp lldb/trunk/test/breakpoint_conditions/TestBreakpointConditions.py Modified: lldb/trunk/source/API/SBBreakpoint.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBBreakpoint.cpp?rev=121898&r1=121897&r2=121898&view=diff ============================================================================== --- lldb/trunk/source/API/SBBreakpoint.cpp (original) +++ lldb/trunk/source/API/SBBreakpoint.cpp Wed Dec 15 15:39:37 2010 @@ -314,14 +314,14 @@ if (m_opaque_sp) { const ThreadSpec *thread_spec = m_opaque_sp->GetOptions()->GetThreadSpec(); - if (thread_spec == NULL) + if (thread_spec != NULL) thread_idx = thread_spec->GetIndex(); } LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); if (log) log->Printf ("SBBreakpoint(%p)::GetThreadIndex () => %u", m_opaque_sp.get(), thread_idx); - return UINT32_MAX; + return thread_idx; } @@ -343,7 +343,7 @@ if (m_opaque_sp) { const ThreadSpec *thread_spec = m_opaque_sp->GetOptions()->GetThreadSpec(); - if (thread_spec == NULL) + if (thread_spec != NULL) name = thread_spec->GetName(); } LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); Modified: lldb/trunk/test/breakpoint_conditions/TestBreakpointConditions.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/breakpoint_conditions/TestBreakpointConditions.py?rev=121898&r1=121897&r2=121898&view=diff ============================================================================== --- lldb/trunk/test/breakpoint_conditions/TestBreakpointConditions.py (original) +++ lldb/trunk/test/breakpoint_conditions/TestBreakpointConditions.py Wed Dec 15 15:39:37 2010 @@ -113,6 +113,19 @@ breakpoint.GetNumLocations() == 1, VALID_BREAKPOINT) + # We didn't associate a thread index with the breakpoint, so it should be invalid. + self.assertTrue(breakpoint.GetThreadIndex() == lldb.UINT32_MAX, + "The thread index should be invalid") + # The thread name should be invalid, too. + self.assertTrue(breakpoint.GetThreadName() is None, + "The thread name should be invalid") + + # Let's set the thread index for this breakpoint and verify that it is, + # indeed, being set correctly. + breakpoint.SetThreadIndex(1) # There's only one thread for the process. + self.assertTrue(breakpoint.GetThreadIndex() == 1, + "The thread index has been set correctly") + # Get the breakpoint location from breakpoint after we verified that, # indeed, it has one location. location = breakpoint.GetLocationAtIndex(0) From wilsons at start.ca Wed Dec 15 16:05:54 2010 From: wilsons at start.ca (Stephen Wilson) Date: Wed, 15 Dec 2010 17:05:54 -0500 Subject: [Lldb-commits] [PATCH] linux: fix include in lldb.swig In-Reply-To: (Greg Clayton's message of "Wed, 15 Dec 2010 13:36:13 -0800") References: <4535BD27-D1B7-4F83-B96C-54B8D16857FA@apple.com> Message-ID: Greg Clayton writes: > On Dec 15, 2010, at 1:31 PM, Stephen Wilson wrote: > >> >> Hi Greg, >> >> Greg Clayton writes: >> >>> I am not sure this is what we want either. We want the UINT32_MAX and friends to >>> be defined in the generated SWIG file since we use them to test for invalid >>> indexes (much like in the "uint32_t SBBreakpoint::GetThreadIndex() const" >>> function. Can you try setting your PYTHONPATH to point to the lldb.so on linux >>> (the lldb.py file needs to be in the same directory and then make and run this >>> python script: >> >> I hope this question is not too stupid, but where is lldb.py? I see a >> reference in dotest.py indicating that it is distributed with XCode4. >> If it is not in the lldb tree, do you have a link handy (google can't >> seem to help me here)? > > the swig invocation should produce the lldb.py file. Not sure where it > will end up on linux, possibly next to the "lldb" binary? Ah, OK! I also needed to add a "_lldb.so" symlink pointing to liblldb.so. Unfortunately, I do not see the stuff from stdint.h. I also upgraded my Swig installation to 2.0.1 but still cannot process stdint.h. The error I am getting is: swig -c++ -shadow -python -I"/home/steve/development/llvm/llvm-git/tools/lldb/source/Interpreter/../../include" \ -I./. -I"/usr/include" -outdir "/home/steve/development/build/llvm-git/Debug+Asserts/bin" \ -o LLDBWrapPython.cpp "/home/steve/development/llvm/llvm-git/tools/lldb/source/Interpreter/../../scripts/lldb.swig" /usr/include/stdint.h:44: Error: Syntax error in input(1). Looks to me like Swig does not like GCC's __extension__ "keyword". I wish I knew more about Swig... Any ideas? Thanks for your help, >> >>> % setenv PYTHONPATH /build/Debug/LLDB.framework/Resources/Python % cat >>> dirlldb.py #!/usr/bin/python import lldb print dir(lldb) >>> >>> >>> If I do this on MacOSX I see all of the stuff from stdint.h: >>> >>> % ./dirlldb.py ['INT16_MAX', 'INT16_MIN', 'INT32_MAX', 'INT32_MIN', 'INT64_MAX', >>> INT64_MIN', 'INT8_MAX', 'INT8_MIN', 'INTMAX_MAX', 'INTMAX_MIN', 'INTPTR_MAX', >>> INTPTR_MIN', 'INT_FAST16_MAX', 'INT_FAST16_MIN', 'INT_FAST32_MAX', >>> INT_FAST32_MIN', 'INT_FAST64_MAX', 'INT_FAST64_MIN', 'INT_FAST8_MAX', >>> INT_FAST8_MIN', 'INT_LEAST16_MAX', 'INT_LEAST16_MIN', 'INT_LEAST32_MAX', >>> INT_LEAST32_MIN', 'INT_LEAST64_MAX', 'INT_LEAST64_MIN', 'INT_LEAST8_MAX', >>> INT_LEAST8_MIN', 'LLDB_ARCH_DEFAULT', ... >>> >>> Do you still see these in the resulting SWIG module when you use #include? >>> >>> >>> On Dec 15, 2010, at 12:28 PM, Stephen Wilson wrote: >>> >>>> I would appreciate it if someone with experience in Swig could look this one >>>> over. I am not 100% positive this is the proper fix. >>>> >>>> >>>> Use #include rather than the Swig %include directive. >>>> >>>> In order to use the %include directive Swig needs to be instructed as to >>>> the search path. However, Swig 1.3.40 cannot process stdint.h provided by >>>> glibc. This fix takes advantage of the fact that, by default, Swig does not >>>> process headers introduced via #include. >>>> >>>> diff --git a/scripts/lldb.swig b/scripts/lldb.swig index 95c409e..63167c8 >>>> 100644 --- a/scripts/lldb.swig +++ b/scripts/lldb.swig @@ -97,7 +97,7 @@ %} >>>> >>>> /* Various liblldb typedefs that SWIG needs to know about. */ -%include >>>> +#include %include "lldb/lldb-defines.h" %include >>>> "lldb/lldb-enumerations.h" %include "lldb/lldb-forward.h" >>>> _______________________________________________ lldb-commits mailing list >>>> lldb-commits at cs.uiuc.edu >>>> http://lists.cs.uiuc.edu/mailman/listinfo/lldb-commits >>> >> >> -- >> steve > -- steve From gclayton at apple.com Wed Dec 15 16:17:59 2010 From: gclayton at apple.com (Greg Clayton) Date: Wed, 15 Dec 2010 14:17:59 -0800 Subject: [Lldb-commits] [PATCH] linux: fix include in lldb.swig In-Reply-To: References: <4535BD27-D1B7-4F83-B96C-54B8D16857FA@apple.com> Message-ID: On Dec 15, 2010, at 2:05 PM, Stephen Wilson wrote: > Greg Clayton writes: > >> On Dec 15, 2010, at 1:31 PM, Stephen Wilson wrote: >> >>> >>> Hi Greg, >>> >>> Greg Clayton writes: >>> >>>> I am not sure this is what we want either. We want the UINT32_MAX and friends to >>>> be defined in the generated SWIG file since we use them to test for invalid >>>> indexes (much like in the "uint32_t SBBreakpoint::GetThreadIndex() const" >>>> function. Can you try setting your PYTHONPATH to point to the lldb.so on linux >>>> (the lldb.py file needs to be in the same directory and then make and run this >>>> python script: >>> >>> I hope this question is not too stupid, but where is lldb.py? I see a >>> reference in dotest.py indicating that it is distributed with XCode4. >>> If it is not in the lldb tree, do you have a link handy (google can't >>> seem to help me here)? >> >> the swig invocation should produce the lldb.py file. Not sure where it >> will end up on linux, possibly next to the "lldb" binary? > > Ah, OK! I also needed to add a "_lldb.so" symlink pointing to liblldb.so. > > Unfortunately, I do not see the stuff from stdint.h. sounds like we want to still use %include if we can then... > > I also upgraded my Swig installation to 2.0.1 but still cannot process > stdint.h. The error I am getting is: > > swig -c++ -shadow -python -I"/home/steve/development/llvm/llvm-git/tools/lldb/source/Interpreter/../../include" \ > -I./. -I"/usr/include" -outdir "/home/steve/development/build/llvm-git/Debug+Asserts/bin" \ > -o LLDBWrapPython.cpp "/home/steve/development/llvm/llvm-git/tools/lldb/source/Interpreter/../../scripts/lldb.swig" > /usr/include/stdint.h:44: Error: Syntax error in input(1). > > > Looks to me like Swig does not like GCC's __extension__ "keyword". > > > I wish I knew more about Swig... Any ideas? No ideas off the top of my head. Are there any other header files that define UINT32_MAX and friends? Maybe ? > > > > Thanks for your help, > >>> >>>> % setenv PYTHONPATH /build/Debug/LLDB.framework/Resources/Python % cat >>>> dirlldb.py #!/usr/bin/python import lldb print dir(lldb) >>>> >>>> >>>> If I do this on MacOSX I see all of the stuff from stdint.h: >>>> >>>> % ./dirlldb.py ['INT16_MAX', 'INT16_MIN', 'INT32_MAX', 'INT32_MIN', 'INT64_MAX', >>>> INT64_MIN', 'INT8_MAX', 'INT8_MIN', 'INTMAX_MAX', 'INTMAX_MIN', 'INTPTR_MAX', >>>> INTPTR_MIN', 'INT_FAST16_MAX', 'INT_FAST16_MIN', 'INT_FAST32_MAX', >>>> INT_FAST32_MIN', 'INT_FAST64_MAX', 'INT_FAST64_MIN', 'INT_FAST8_MAX', >>>> INT_FAST8_MIN', 'INT_LEAST16_MAX', 'INT_LEAST16_MIN', 'INT_LEAST32_MAX', >>>> INT_LEAST32_MIN', 'INT_LEAST64_MAX', 'INT_LEAST64_MIN', 'INT_LEAST8_MAX', >>>> INT_LEAST8_MIN', 'LLDB_ARCH_DEFAULT', ... >>>> >>>> Do you still see these in the resulting SWIG module when you use #include? >>>> >>>> >>>> On Dec 15, 2010, at 12:28 PM, Stephen Wilson wrote: >>>> >>>>> I would appreciate it if someone with experience in Swig could look this one >>>>> over. I am not 100% positive this is the proper fix. >>>>> >>>>> >>>>> Use #include rather than the Swig %include directive. >>>>> >>>>> In order to use the %include directive Swig needs to be instructed as to >>>>> the search path. However, Swig 1.3.40 cannot process stdint.h provided by >>>>> glibc. This fix takes advantage of the fact that, by default, Swig does not >>>>> process headers introduced via #include. >>>>> >>>>> diff --git a/scripts/lldb.swig b/scripts/lldb.swig index 95c409e..63167c8 >>>>> 100644 --- a/scripts/lldb.swig +++ b/scripts/lldb.swig @@ -97,7 +97,7 @@ %} >>>>> >>>>> /* Various liblldb typedefs that SWIG needs to know about. */ -%include >>>>> +#include %include "lldb/lldb-defines.h" %include >>>>> "lldb/lldb-enumerations.h" %include "lldb/lldb-forward.h" >>>>> _______________________________________________ lldb-commits mailing list >>>>> lldb-commits at cs.uiuc.edu >>>>> http://lists.cs.uiuc.edu/mailman/listinfo/lldb-commits >>>> >>> >>> -- >>> steve >> > > > > -- > steve From johnny.chen at apple.com Wed Dec 15 16:50:54 2010 From: johnny.chen at apple.com (Johnny Chen) Date: Wed, 15 Dec 2010 22:50:54 -0000 Subject: [Lldb-commits] [lldb] r121907 - /lldb/trunk/test/foundation/TestObjCMethods.py Message-ID: <20101215225054.938B92A6C12C@llvm.org> Author: johnny Date: Wed Dec 15 16:50:54 2010 New Revision: 121907 URL: http://llvm.org/viewvc/llvm-project?rev=121907&view=rev Log: Fix one of the golden output of "frame variable -t *self" to be: "(MyString) *self" 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=121907&r1=121906&r2=121907&view=diff ============================================================================== --- lldb/trunk/test/foundation/TestObjCMethods.py (original) +++ lldb/trunk/test/foundation/TestObjCMethods.py Wed Dec 15 16:50:54 2010 @@ -162,7 +162,7 @@ # This should display the str and date member fields as well. self.expect("frame variable -t *self", VARIABLES_DISPLAYED_CORRECTLY, - substrs = ["(MyString *) self", + substrs = ["(MyString) *self", "(NSString *) str", "(NSDate *) date"]) From wilsons at start.ca Wed Dec 15 17:14:55 2010 From: wilsons at start.ca (Stephen Wilson) Date: Wed, 15 Dec 2010 18:14:55 -0500 Subject: [Lldb-commits] [PATCH] linux: fix include in lldb.swig In-Reply-To: (Greg Clayton's message of "Wed, 15 Dec 2010 14:17:59 -0800") References: <4535BD27-D1B7-4F83-B96C-54B8D16857FA@apple.com> Message-ID: Hi Greg, How about the following patch. It makes Swig happy on Linux and we retain all of the stdint.h constants. Allow Swig to process stdint.h on Linux. Define GCC's __extension__ keyword out of existence to make Swig happy when processing glibc's stdint.h. Also, update the Makefile to include /usr/local in Swig's search path and define __STDC_LIMIT_MACROS so we get all the constants. diff --git a/scripts/lldb.swig b/scripts/lldb.swig index 95c409e..7ba4e01 100644 --- a/scripts/lldb.swig +++ b/scripts/lldb.swig @@ -97,6 +97,7 @@ %} /* Various liblldb typedefs that SWIG needs to know about. */ +#define __extension__ %include %include "lldb/lldb-defines.h" %include "lldb/lldb-enumerations.h" diff --git a/source/Interpreter/Makefile b/source/Interpreter/Makefile index 0a9d172..0683a4d 100644 --- a/source/Interpreter/Makefile +++ b/source/Interpreter/Makefile @@ -20,5 +20,7 @@ LLDB_BIN_DIR := $(PROJ_OBJ_ROOT)/$(BuildMode)/bin PYTHON_DIR := $(LLDB_BIN_DIR) LLDBWrapPython.cpp: - swig -c++ -shadow -python -I"$(PROJ_SRC_DIR)/$(LLDB_LEVEL)/include" -I./. -outdir "$(LLDB_BIN_DIR)" -o LLDBWrapPython.cpp "$(PROJ_SRC_DIR)/$(LLDB_LEVEL)/scripts/lldb.swig" + swig -c++ -shadow -python -I"$(PROJ_SRC_DIR)/$(LLDB_LEVEL)/include" \ + -I./. -I"/usr/include" -D__STDC_LIMIT_MACROS -outdir "$(LLDB_BIN_DIR)" \ + -o LLDBWrapPython.cpp "$(PROJ_SRC_DIR)/$(LLDB_LEVEL)/scripts/lldb.swig" cp "$(PROJ_SRC_DIR)/embedded_interpreter.py" "$(PYTHON_DIR)" From johnny.chen at apple.com Wed Dec 15 17:34:50 2010 From: johnny.chen at apple.com (Johnny Chen) Date: Wed, 15 Dec 2010 15:34:50 -0800 Subject: [Lldb-commits] [PATCH] linux: fix include in lldb.swig In-Reply-To: References: <4535BD27-D1B7-4F83-B96C-54B8D16857FA@apple.com> Message-ID: <66224C65-2427-4015-A0EF-3DE18CA44E9E@apple.com> I'm building with your proposed diff on Mac OS X. I assumed that you meant: > + -I./. -I"/usr/local/include" -D__STDC_LIMIT_MACROS -outdir "$(LLDB_BIN_DIR)" \ correct? On Dec 15, 2010, at 3:14 PM, Stephen Wilson wrote: > > Hi Greg, > > How about the following patch. It makes Swig happy on Linux and we retain > all of the stdint.h constants. > > > Allow Swig to process stdint.h on Linux. > > Define GCC's __extension__ keyword out of existence to make Swig happy when > processing glibc's stdint.h. Also, update the Makefile to include /usr/local in > Swig's search path and define __STDC_LIMIT_MACROS so we get all the constants. > > diff --git a/scripts/lldb.swig b/scripts/lldb.swig > index 95c409e..7ba4e01 100644 > --- a/scripts/lldb.swig > +++ b/scripts/lldb.swig > @@ -97,6 +97,7 @@ > %} > > /* Various liblldb typedefs that SWIG needs to know about. */ > +#define __extension__ > %include > %include "lldb/lldb-defines.h" > %include "lldb/lldb-enumerations.h" > diff --git a/source/Interpreter/Makefile b/source/Interpreter/Makefile > index 0a9d172..0683a4d 100644 > --- a/source/Interpreter/Makefile > +++ b/source/Interpreter/Makefile > @@ -20,5 +20,7 @@ LLDB_BIN_DIR := $(PROJ_OBJ_ROOT)/$(BuildMode)/bin > PYTHON_DIR := $(LLDB_BIN_DIR) > > LLDBWrapPython.cpp: > - swig -c++ -shadow -python -I"$(PROJ_SRC_DIR)/$(LLDB_LEVEL)/include" -I./. -outdir "$(LLDB_BIN_DIR)" -o LLDBWrapPython.cpp "$(PROJ_SRC_DIR)/$(LLDB_LEVEL)/scripts/lldb.swig" > + swig -c++ -shadow -python -I"$(PROJ_SRC_DIR)/$(LLDB_LEVEL)/include" \ > + -I./. -I"/usr/include" -D__STDC_LIMIT_MACROS -outdir "$(LLDB_BIN_DIR)" \ > + -o LLDBWrapPython.cpp "$(PROJ_SRC_DIR)/$(LLDB_LEVEL)/scripts/lldb.swig" > cp "$(PROJ_SRC_DIR)/embedded_interpreter.py" "$(PYTHON_DIR)" > > > _______________________________________________ > lldb-commits mailing list > lldb-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/lldb-commits From johnny.chen at apple.com Wed Dec 15 18:01:06 2010 From: johnny.chen at apple.com (Johnny Chen) Date: Thu, 16 Dec 2010 00:01:06 -0000 Subject: [Lldb-commits] [lldb] r121924 - in /lldb/trunk: scripts/lldb.swig source/Interpreter/Makefile Message-ID: <20101216000106.D12862A6C12C@llvm.org> Author: johnny Date: Wed Dec 15 18:01:06 2010 New Revision: 121924 URL: http://llvm.org/viewvc/llvm-project?rev=121924&view=rev Log: Patch by Stephen Wilson to make Swig happy building on linux. Pass the test suite on Mac OS X Snow Leopard. Modified: lldb/trunk/scripts/lldb.swig lldb/trunk/source/Interpreter/Makefile Modified: lldb/trunk/scripts/lldb.swig URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/scripts/lldb.swig?rev=121924&r1=121923&r2=121924&view=diff ============================================================================== --- lldb/trunk/scripts/lldb.swig (original) +++ lldb/trunk/scripts/lldb.swig Wed Dec 15 18:01:06 2010 @@ -97,6 +97,7 @@ %} /* Various liblldb typedefs that SWIG needs to know about. */ +#define __extension__ /* Undefine GCC keyword to make Swig happy when processing glibc's stdint.h. */ %include %include "lldb/lldb-defines.h" %include "lldb/lldb-enumerations.h" Modified: lldb/trunk/source/Interpreter/Makefile URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Interpreter/Makefile?rev=121924&r1=121923&r2=121924&view=diff ============================================================================== --- lldb/trunk/source/Interpreter/Makefile (original) +++ lldb/trunk/source/Interpreter/Makefile Wed Dec 15 18:01:06 2010 @@ -20,5 +20,7 @@ PYTHON_DIR := $(LLDB_BIN_DIR) LLDBWrapPython.cpp: - swig -c++ -shadow -python -I"$(PROJ_SRC_DIR)/$(LLDB_LEVEL)/include" -I./. -outdir "$(LLDB_BIN_DIR)" -o LLDBWrapPython.cpp "$(PROJ_SRC_DIR)/$(LLDB_LEVEL)/scripts/lldb.swig" + swig -c++ -shadow -python -I"$(PROJ_SRC_DIR)/$(LLDB_LEVEL)/include" \ + -I./. -I"/usr/local/include" -D__STDC_LIMIT_MACROS -outdir "$(LLDB_BIN_DIR)" \ + -o LLDBWrapPython.cpp "$(PROJ_SRC_DIR)/$(LLDB_LEVEL)/scripts/lldb.swig" cp "$(PROJ_SRC_DIR)/embedded_interpreter.py" "$(PYTHON_DIR)" From wilsons at start.ca Wed Dec 15 18:07:33 2010 From: wilsons at start.ca (Stephen Wilson) Date: Wed, 15 Dec 2010 19:07:33 -0500 Subject: [Lldb-commits] [PATCH] linux: fix include in lldb.swig In-Reply-To: <66224C65-2427-4015-A0EF-3DE18CA44E9E@apple.com> (Johnny Chen's message of "Wed, 15 Dec 2010 15:34:50 -0800") References: <4535BD27-D1B7-4F83-B96C-54B8D16857FA@apple.com> <66224C65-2427-4015-A0EF-3DE18CA44E9E@apple.com> Message-ID: Hi Johnny, Johnny Chen writes: > I'm building with your proposed diff on Mac OS X. Great! Thanks! > I assumed that you meant: > >> + -I./. -I"/usr/local/include" -D__STDC_LIMIT_MACROS -outdir "$(LLDB_BIN_DIR)" \ > > correct? Actually for me (Fedora 11) stdint.h lives under /usr/include. We certainly need come additional configure/makefile logic for this to work portably. I will look into extending the makefiles to handle this better. > On Dec 15, 2010, at 3:14 PM, Stephen Wilson wrote: > >> >> Hi Greg, >> >> How about the following patch. It makes Swig happy on Linux and we retain >> all of the stdint.h constants. >> >> >> Allow Swig to process stdint.h on Linux. >> >> Define GCC's __extension__ keyword out of existence to make Swig happy when >> processing glibc's stdint.h. Also, update the Makefile to include /usr/local in >> Swig's search path and define __STDC_LIMIT_MACROS so we get all the constants. >> >> diff --git a/scripts/lldb.swig b/scripts/lldb.swig >> index 95c409e..7ba4e01 100644 >> --- a/scripts/lldb.swig >> +++ b/scripts/lldb.swig >> @@ -97,6 +97,7 @@ >> %} >> >> /* Various liblldb typedefs that SWIG needs to know about. */ >> +#define __extension__ >> %include >> %include "lldb/lldb-defines.h" >> %include "lldb/lldb-enumerations.h" >> diff --git a/source/Interpreter/Makefile b/source/Interpreter/Makefile >> index 0a9d172..0683a4d 100644 >> --- a/source/Interpreter/Makefile >> +++ b/source/Interpreter/Makefile >> @@ -20,5 +20,7 @@ LLDB_BIN_DIR := $(PROJ_OBJ_ROOT)/$(BuildMode)/bin >> PYTHON_DIR := $(LLDB_BIN_DIR) >> >> LLDBWrapPython.cpp: >> - swig -c++ -shadow -python -I"$(PROJ_SRC_DIR)/$(LLDB_LEVEL)/include" -I./. -outdir "$(LLDB_BIN_DIR)" -o LLDBWrapPython.cpp "$(PROJ_SRC_DIR)/$(LLDB_LEVEL)/scripts/lldb.swig" >> + swig -c++ -shadow -python -I"$(PROJ_SRC_DIR)/$(LLDB_LEVEL)/include" \ >> + -I./. -I"/usr/include" -D__STDC_LIMIT_MACROS -outdir "$(LLDB_BIN_DIR)" \ >> + -o LLDBWrapPython.cpp "$(PROJ_SRC_DIR)/$(LLDB_LEVEL)/scripts/lldb.swig" >> cp "$(PROJ_SRC_DIR)/embedded_interpreter.py" "$(PYTHON_DIR)" >> >> >> _______________________________________________ >> lldb-commits mailing list >> lldb-commits at cs.uiuc.edu >> http://lists.cs.uiuc.edu/mailman/listinfo/lldb-commits > -- steve From johnny.chen at apple.com Wed Dec 15 18:13:40 2010 From: johnny.chen at apple.com (Johnny Chen) Date: Wed, 15 Dec 2010 16:13:40 -0800 Subject: [Lldb-commits] [PATCH] linux: fix include in lldb.swig In-Reply-To: References: <4535BD27-D1B7-4F83-B96C-54B8D16857FA@apple.com> <66224C65-2427-4015-A0EF-3DE18CA44E9E@apple.com> Message-ID: Hi Stephen, On Dec 15, 2010, at 4:07 PM, Stephen Wilson wrote: > Hi Johnny, > > Johnny Chen writes: >> I'm building with your proposed diff on Mac OS X. > > Great! Thanks! You are welcome! > >> I assumed that you meant: >> >>> + -I./. -I"/usr/local/include" -D__STDC_LIMIT_MACROS -outdir "$(LLDB_BIN_DIR)" \ >> >> correct? > > Actually for me (Fedora 11) stdint.h lives under /usr/include. We > certainly need come additional configure/makefile logic for this to work > portably. > > I will look into extending the makefiles to handle this better. Great! Johnny Chen -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.cs.uiuc.edu/pipermail/lldb-commits/attachments/20101215/bf8bfe9f/attachment.html From wilsons at start.ca Wed Dec 15 19:28:16 2010 From: wilsons at start.ca (Stephen Wilson) Date: Wed, 15 Dec 2010 20:28:16 -0500 Subject: [Lldb-commits] [PATCH] linux: fix include in lldb.swig In-Reply-To: (Johnny Chen's message of "Wed, 15 Dec 2010 16:13:40 -0800") References: <4535BD27-D1B7-4F83-B96C-54B8D16857FA@apple.com> <66224C65-2427-4015-A0EF-3DE18CA44E9E@apple.com> Message-ID: Hi Johnny, The following patch should apply cleanly atop r121924 if it is acceptable. Thanks again! Extend Swig's include search path. Cover both /usr/include and /usr/local/include. This should allow Swig to find system headers such as stdint.h on all platforms we currently support. diff --git a/source/Interpreter/Makefile b/source/Interpreter/Makefile index 248de5e..6e72f49 100644 --- a/source/Interpreter/Makefile +++ b/source/Interpreter/Makefile @@ -18,9 +18,16 @@ include $(LLDB_LEVEL)/Makefile LLDB_PYTHON_SWIG_CPP = $(PROJ_OBJ_ROOT)/$(BuildMode)/LLDBWrapPython.cpp LLDB_BIN_DIR := $(PROJ_OBJ_ROOT)/$(BuildMode)/bin PYTHON_DIR := $(LLDB_BIN_DIR) +LLDB_SWIG_INCLUDE_DIRS:= -I"$(PROJ_SRC_DIR)/$(LLDB_LEVEL)/include" -I./. + +# We need Swig to process stdint.h, but by default it will not inspect system +# include directories. The following should cover the standard locations on +# most platforms. +LLDB_SWIG_INCLUDE_DIRS += -I"/usr/local/include" +LLDB_SWIG_INCLUDE_DIRS += -I"/usr/include" LLDBWrapPython.cpp: - swig -c++ -shadow -python -I"$(PROJ_SRC_DIR)/$(LLDB_LEVEL)/include" \ - -I./. -I"/usr/local/include" -D__STDC_LIMIT_MACROS -outdir "$(LLDB_BIN_DIR)" \ - -o LLDBWrapPython.cpp "$(PROJ_SRC_DIR)/$(LLDB_LEVEL)/scripts/lldb.swig" + swig -c++ -shadow -python $(LLDB_SWIG_INCLUDE_DIRS) \ + -D__STDC_LIMIT_MACROS -outdir "$(LLDB_BIN_DIR)" \ + -o LLDBWrapPython.cpp "$(PROJ_SRC_DIR)/$(LLDB_LEVEL)/scripts/lldb.swig" cp "$(PROJ_SRC_DIR)/embedded_interpreter.py" "$(PYTHON_DIR)" From johnny.chen at apple.com Wed Dec 15 19:41:37 2010 From: johnny.chen at apple.com (Johnny Chen) Date: Thu, 16 Dec 2010 01:41:37 -0000 Subject: [Lldb-commits] [lldb] r121941 - in /lldb/trunk/test/python_api: ./ symbol-context/ symbol-context/Makefile symbol-context/TestSymbolContext.py symbol-context/main.c Message-ID: <20101216014137.B25672A6C12C@llvm.org> Author: johnny Date: Wed Dec 15 19:41:37 2010 New Revision: 121941 URL: http://llvm.org/viewvc/llvm-project?rev=121941&view=rev Log: Add python_api/symbol-context to test getting the symbol context while stopped on a frame and to exercise the methods of SBSymbolContext. Added: lldb/trunk/test/python_api/ lldb/trunk/test/python_api/symbol-context/ lldb/trunk/test/python_api/symbol-context/Makefile lldb/trunk/test/python_api/symbol-context/TestSymbolContext.py lldb/trunk/test/python_api/symbol-context/main.c Added: lldb/trunk/test/python_api/symbol-context/Makefile URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/python_api/symbol-context/Makefile?rev=121941&view=auto ============================================================================== --- lldb/trunk/test/python_api/symbol-context/Makefile (added) +++ lldb/trunk/test/python_api/symbol-context/Makefile Wed Dec 15 19:41:37 2010 @@ -0,0 +1,5 @@ +LEVEL = ../../make + +C_SOURCES := main.c + +include $(LEVEL)/Makefile.rules Added: lldb/trunk/test/python_api/symbol-context/TestSymbolContext.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/python_api/symbol-context/TestSymbolContext.py?rev=121941&view=auto ============================================================================== --- lldb/trunk/test/python_api/symbol-context/TestSymbolContext.py (added) +++ lldb/trunk/test/python_api/symbol-context/TestSymbolContext.py Wed Dec 15 19:41:37 2010 @@ -0,0 +1,100 @@ +""" +Test SBSymbolContext APIs. +""" + +import os, time +import re +import unittest2 +import lldb, lldbutil +from lldbtest import * + +class SymbolContextAPITestCase(TestBase): + + mydir = os.path.join("python_api", "symbol-context") + + @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin") + @python_api_test + def test_with_dsym(self): + """Exercise SBSymbolContext API extensively.""" + self.buildDsym() + self.symbol_context() + + @python_api_test + def test_with_dwarf(self): + """Exercise SBSymbolContext API extensively.""" + self.buildDwarf() + self.symbol_context() + + def setUp(self): + # Call super's setUp(). + TestBase.setUp(self) + # Find the line number to of function 'c'. + self.line = line_number('main.c', '// Find the line number of function "c" here.') + + def symbol_context(self): + """Get an SBSymbolContext object and call its many methods.""" + exe = os.path.join(os.getcwd(), "a.out") + + # Create a target by the debugger. + target = self.dbg.CreateTarget(exe) + self.assertTrue(target.IsValid(), VALID_TARGET) + + # Now create a breakpoint on main.c by name 'c'. + breakpoint = target.BreakpointCreateByName('c', 'a.out') + #print "breakpoint:", breakpoint + self.assertTrue(breakpoint.IsValid() and + breakpoint.GetNumLocations() == 1, + VALID_BREAKPOINT) + + # Now launch the process, and do not stop at entry point. + self.process = target.LaunchProcess([''], [''], os.ctermid(), 0, False) + + self.process = target.GetProcess() + self.assertTrue(self.process.IsValid(), PROCESS_IS_VALID) + + # Frame #0 should be on self.line. + frame0 = self.process.GetThreadAtIndex(0).GetFrameAtIndex(0) + self.assertTrue(frame0.GetLineEntry().GetLine() == self.line) + + # Now get the SBSymbolContext from this frame. We want everything. :-) + context = frame0.GetSymbolContext(lldb.eSymbolContextEverything) + self.assertTrue(context.IsValid()) + + module = context.GetModule() + self.expect(repr(module), "The module should match", exe=False, + substrs = [os.path.join(self.mydir, 'a.out')]) + #print "module:", module + + compileUnit = context.GetCompileUnit() + self.expect(repr(compileUnit), "The compile unit should match", exe=False, + substrs = [os.path.join(self.mydir, 'main.c')]) + #print "compile unit:", compileUnit + + function = context.GetFunction() + self.assertTrue(function.IsValid()) + #print "function:", function + + block = context.GetBlock() + self.assertTrue(block.IsValid()) + #print "block:", block + + lineEntry = context.GetLineEntry() + self.expect(lineEntry.GetFileSpec().GetDirectory(), "The line entry should have the correct directory", + exe=False, + substrs = [self.mydir]) + self.expect(lineEntry.GetFileSpec().GetFilename(), "The line entry should have the correct filename", + exe=False, + substrs = ['main.c']) + self.assertTrue(lineEntry.GetLine() == self.line, + "The line entry's line number should match ") + + symbol = context.GetSymbol() + self.assertTrue(function.GetName() == symbol.GetName() and symbol.GetName() == 'c', + "The symbol name should be 'c'") + + +if __name__ == '__main__': + import atexit + lldb.SBDebugger.Initialize() + atexit.register(lambda: lldb.SBDebugger.Terminate()) + unittest2.main() Added: lldb/trunk/test/python_api/symbol-context/main.c URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/python_api/symbol-context/main.c?rev=121941&view=auto ============================================================================== --- lldb/trunk/test/python_api/symbol-context/main.c (added) +++ lldb/trunk/test/python_api/symbol-context/main.c Wed Dec 15 19:41:37 2010 @@ -0,0 +1,51 @@ +//===-- main.c --------------------------------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +#include + +// This simple program is to test the lldb Python API SBSymbolContext. +// When stopped on a frame, we can get the symbol context using the SBFrame API +// SBFrame.GetSymbolContext(). + +int a(int); +int b(int); +int c(int); + +int a(int val) +{ + if (val <= 1) + return b(val); + else if (val >= 3) + return c(val); + + return val; +} + +int b(int val) +{ + return c(val); +} + +int c(int val) +{ + return val + 3; // Find the line number of function "c" here. +} + +int main (int argc, char const *argv[]) +{ + int A1 = a(1); // a(1) -> b(1) -> c(1) + printf("a(1) returns %d\n", A1); + + int B2 = b(2); // b(2) -> c(2) + printf("b(2) returns %d\n", B2); + + int A3 = a(3); // a(3) -> c(3) + printf("a(3) returns %d\n", A3); + + return 0; +} From johnny.chen at apple.com Wed Dec 15 20:03:07 2010 From: johnny.chen at apple.com (Johnny Chen) Date: Thu, 16 Dec 2010 02:03:07 -0000 Subject: [Lldb-commits] [lldb] r121943 - /lldb/trunk/source/Interpreter/Makefile Message-ID: <20101216020307.0ECCB2A6C12C@llvm.org> Author: johnny Date: Wed Dec 15 20:03:06 2010 New Revision: 121943 URL: http://llvm.org/viewvc/llvm-project?rev=121943&view=rev Log: Patch from Stephen Wilson: Extend Swig's include search path. Cover both /usr/include and /usr/local/include. This should allow Swig to find system headers such as stdint.h on all platforms we currently support. Modified: lldb/trunk/source/Interpreter/Makefile Modified: lldb/trunk/source/Interpreter/Makefile URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Interpreter/Makefile?rev=121943&r1=121942&r2=121943&view=diff ============================================================================== --- lldb/trunk/source/Interpreter/Makefile (original) +++ lldb/trunk/source/Interpreter/Makefile Wed Dec 15 20:03:06 2010 @@ -18,9 +18,16 @@ LLDB_PYTHON_SWIG_CPP = $(PROJ_OBJ_ROOT)/$(BuildMode)/LLDBWrapPython.cpp LLDB_BIN_DIR := $(PROJ_OBJ_ROOT)/$(BuildMode)/bin PYTHON_DIR := $(LLDB_BIN_DIR) +LLDB_SWIG_INCLUDE_DIRS:= -I"$(PROJ_SRC_DIR)/$(LLDB_LEVEL)/include" -I./. + +# We need Swig to process stdint.h, but by default it will not inspect system +# include directories. The following should cover the standard locations on +# most platforms. +LLDB_SWIG_INCLUDE_DIRS += -I"/usr/local/include" +LLDB_SWIG_INCLUDE_DIRS += -I"/usr/include" LLDBWrapPython.cpp: - swig -c++ -shadow -python -I"$(PROJ_SRC_DIR)/$(LLDB_LEVEL)/include" \ - -I./. -I"/usr/local/include" -D__STDC_LIMIT_MACROS -outdir "$(LLDB_BIN_DIR)" \ + swig -c++ -shadow -python $(LLDB_SWIG_INCLUDE_DIRS) \ + -D__STDC_LIMIT_MACROS -outdir "$(LLDB_BIN_DIR)" \ -o LLDBWrapPython.cpp "$(PROJ_SRC_DIR)/$(LLDB_LEVEL)/scripts/lldb.swig" cp "$(PROJ_SRC_DIR)/embedded_interpreter.py" "$(PYTHON_DIR)" From scallanan at apple.com Wed Dec 15 21:17:46 2010 From: scallanan at apple.com (Sean Callanan) Date: Thu, 16 Dec 2010 03:17:46 -0000 Subject: [Lldb-commits] [lldb] r121952 - in /lldb/trunk: include/lldb/Expression/ClangExpressionDeclMap.h include/lldb/Expression/ClangExpressionParser.h include/lldb/Expression/ClangUserExpression.h include/lldb/Expression/IRForTarget.h include/lldb/Expression/RecordingMemoryManager.h source/Expression/ClangExpressionDeclMap.cpp source/Expression/ClangExpressionParser.cpp source/Expression/ClangUserExpression.cpp source/Expression/IRForTarget.cpp Message-ID: <20101216031746.740E82A6C12C@llvm.org> Author: spyffe Date: Wed Dec 15 21:17:46 2010 New Revision: 121952 URL: http://llvm.org/viewvc/llvm-project?rev=121952&view=rev Log: Implemented a feature where the expression parser can avoid running the code in the target if the expression's result is known and the expression has no side effects. Right now this feature is quite conservative in its guess about side effects, and it only computes integer results, but the machinery to make it more sophisticated is there. Modified: lldb/trunk/include/lldb/Expression/ClangExpressionDeclMap.h lldb/trunk/include/lldb/Expression/ClangExpressionParser.h lldb/trunk/include/lldb/Expression/ClangUserExpression.h lldb/trunk/include/lldb/Expression/IRForTarget.h lldb/trunk/include/lldb/Expression/RecordingMemoryManager.h lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp lldb/trunk/source/Expression/ClangExpressionParser.cpp lldb/trunk/source/Expression/ClangUserExpression.cpp lldb/trunk/source/Expression/IRForTarget.cpp Modified: lldb/trunk/include/lldb/Expression/ClangExpressionDeclMap.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Expression/ClangExpressionDeclMap.h?rev=121952&r1=121951&r2=121952&view=diff ============================================================================== --- lldb/trunk/include/lldb/Expression/ClangExpressionDeclMap.h (original) +++ lldb/trunk/include/lldb/Expression/ClangExpressionDeclMap.h Wed Dec 15 21:17:46 2010 @@ -110,6 +110,28 @@ const ClangNamespaceDecl &namespace_decl); //------------------------------------------------------------------ + /// [Used by IRForTarget] Get a constant variable given a name, + /// a type, and an llvm::APInt. + /// + /// @param[in] name + /// The name of the variable + /// + /// @param[in] type + /// The type of the variable, which will be imported into the + /// target's AST context + /// + /// @param[in] value + /// The value of the variable + /// + /// @return + /// The created variable + //------------------------------------------------------------------ + lldb::ClangExpressionVariableSP + BuildIntegerVariable (const ConstString &name, + lldb_private::TypeFromParser type, + const llvm::APInt& value); + + //------------------------------------------------------------------ /// [Used by IRForTarget] Add a variable to the list of persistent /// variables for the process. /// Modified: lldb/trunk/include/lldb/Expression/ClangExpressionParser.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Expression/ClangExpressionParser.h?rev=121952&r1=121951&r2=121952&view=diff ============================================================================== --- lldb/trunk/include/lldb/Expression/ClangExpressionParser.h (original) +++ lldb/trunk/include/lldb/Expression/ClangExpressionParser.h Wed Dec 15 21:17:46 2010 @@ -101,6 +101,11 @@ /// @param[in] exe_ctx /// The execution context to write the function into. /// + /// @param[out] const_result + /// If non-NULL, the result of the expression is constant, and the + /// expression has no side effects, this is set to the result of the + /// expression. + /// /// @return /// An error code indicating the success or failure of the operation. /// Test with Success(). @@ -108,7 +113,8 @@ Error MakeJIT (lldb::addr_t &func_addr, lldb::addr_t &func_end, - ExecutionContext &exe_ctx); + ExecutionContext &exe_ctx, + lldb::ClangExpressionVariableSP *const_result = NULL); //------------------------------------------------------------------ /// Disassemble the machine code for a JITted function from the target @@ -120,10 +126,6 @@ /// @param[in] exc_context /// The execution context to get the machine code from. /// - /// @param[in] func_name - /// The name of the function to be disassembled. By default, the - /// function wrapped by ParseExpression(). - /// /// @return /// The error generated. If .Success() is true, disassembly succeeded. //------------------------------------------------------------------ Modified: lldb/trunk/include/lldb/Expression/ClangUserExpression.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Expression/ClangUserExpression.h?rev=121952&r1=121951&r2=121952&view=diff ============================================================================== --- lldb/trunk/include/lldb/Expression/ClangUserExpression.h (original) +++ lldb/trunk/include/lldb/Expression/ClangUserExpression.h Wed Dec 15 21:17:46 2010 @@ -81,13 +81,19 @@ /// The type that the expression should be coerced to. If NULL, /// inferred from the expression itself. /// + /// @param[out] const_result + /// If this is non-NULL, the expression has no side effects, and + /// the expression returns a constant result, then that result + /// is put into this variable. + /// /// @return /// True on success (no errors); false otherwise. //------------------------------------------------------------------ bool Parse (Stream &error_stream, ExecutionContext &exe_ctx, - TypeFromUser desired_type); + TypeFromUser desired_type, + lldb::ClangExpressionVariableSP *const_result = NULL); //------------------------------------------------------------------ /// Execute the parsed expression Modified: lldb/trunk/include/lldb/Expression/IRForTarget.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Expression/IRForTarget.h?rev=121952&r1=121951&r2=121952&view=diff ============================================================================== --- lldb/trunk/include/lldb/Expression/IRForTarget.h (original) +++ lldb/trunk/include/lldb/Expression/IRForTarget.h Wed Dec 15 21:17:46 2010 @@ -10,6 +10,9 @@ #ifndef liblldb_IRForTarget_h_ #define liblldb_IRForTarget_h_ +#include "lldb/lldb-include.h" +#include "lldb/Core/ConstString.h" +#include "lldb/Symbol/TaggedASTType.h" #include "llvm/Pass.h" namespace llvm { @@ -62,6 +65,7 @@ //------------------------------------------------------------------ IRForTarget(lldb_private::ClangExpressionDeclMap *decl_map, bool resolve_vars, + lldb::ClangExpressionVariableSP *const_result, const char* func_name = "$__lldb_expr"); //------------------------------------------------------------------ @@ -106,11 +110,55 @@ private: //------------------------------------------------------------------ + /// A function-level pass to check whether the function has side + /// effects. + //------------------------------------------------------------------ + + //------------------------------------------------------------------ + /// The top-level pass implementation + /// + /// @param[in] llvm_module + /// The module currently being processed. + /// + /// @param[in] llvm_function + /// The function currently being processed. + /// + /// @return + /// True if the function has side effects (or if this cannot + /// be determined); false otherwise. + //------------------------------------------------------------------ + bool + HasSideEffects (llvm::Module &llvm_module, + llvm::Function &llvm_function); + + //------------------------------------------------------------------ /// A function-level pass to take the generated global value /// $__lldb_expr_result and make it into a persistent variable. /// Also see ASTResultSynthesizer. //------------------------------------------------------------------ - + + //------------------------------------------------------------------ + /// Set the constant result variable m_const_result to the provided + /// constant, assuming it can be evaluated. The result variable + /// will be reset to NULL later if the expression has side effects. + /// + /// @param[in] initializer + /// The constant initializer for the variable. + /// + /// @param[in] name + /// The name of the result variable. + /// + /// @param[in] type + /// The Clang type of the result variable. + /// + /// @return + /// True on success; false otherwise + //------------------------------------------------------------------ + void + MaybeSetConstantResult (llvm::Constant *initializer, + const lldb_private::ConstString &name, + lldb_private::TypeFromParser type); + //------------------------------------------------------------------ /// The top-level pass implementation /// @@ -403,6 +451,9 @@ lldb_private::ClangExpressionDeclMap *m_decl_map; ///< The DeclMap containing the Decls llvm::Constant *m_CFStringCreateWithBytes; ///< The address of the function CFStringCreateWithBytes, cast to the appropriate function pointer type llvm::Constant *m_sel_registerName; ///< The address of the function sel_registerName, cast to the appropriate function pointer type + lldb::ClangExpressionVariableSP *m_const_result; ///< If non-NULL, this value should be set to the return value of the expression if it is constant and the expression has no side effects + + bool m_has_side_effects; ///< True if the function's result cannot be simply determined statically private: //------------------------------------------------------------------ Modified: lldb/trunk/include/lldb/Expression/RecordingMemoryManager.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Expression/RecordingMemoryManager.h?rev=121952&r1=121951&r2=121952&view=diff ============================================================================== --- lldb/trunk/include/lldb/Expression/RecordingMemoryManager.h (original) +++ lldb/trunk/include/lldb/Expression/RecordingMemoryManager.h Wed Dec 15 21:17:46 2010 @@ -54,7 +54,8 @@ { friend Error ClangExpressionParser::MakeJIT (uint64_t &, uint64_t&, - ExecutionContext &); + ExecutionContext &, + lldb::ClangExpressionVariableSP *); public: //------------------------------------------------------------------ Modified: lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp?rev=121952&r1=121951&r2=121952&view=diff ============================================================================== --- lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp (original) +++ lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp Wed Dec 15 21:17:46 2010 @@ -20,6 +20,7 @@ #include "lldb/Core/Error.h" #include "lldb/Core/Log.h" #include "lldb/Core/Module.h" +#include "lldb/Core/ValueObjectConstResult.h" #include "lldb/Expression/ClangASTSource.h" #include "lldb/Expression/ClangPersistentVariables.h" #include "lldb/Symbol/ClangASTContext.h" @@ -121,6 +122,78 @@ return m_struct_vars->m_result_name; } +lldb::ClangExpressionVariableSP +ClangExpressionDeclMap::BuildIntegerVariable (const ConstString &name, + lldb_private::TypeFromParser type, + const llvm::APInt& value) +{ + assert (m_parser_vars.get()); + + + clang::ASTContext *context(m_parser_vars->m_exe_ctx->target->GetScratchClangASTContext()->getASTContext()); + + TypeFromUser user_type(ClangASTContext::CopyType(context, + type.GetASTContext(), + type.GetOpaqueQualType()), + context); + + DataBufferHeap *heap_data_buf = new DataBufferHeap(ClangASTType::GetClangTypeBitWidth(user_type.GetASTContext(), + user_type.GetOpaqueQualType()) / 8, + '\0'); + + DataBufferSP data_sp(heap_data_buf); + + uint64_t value64 = value.getLimitedValue(); + + ByteOrder byte_order = m_parser_vars->m_exe_ctx->process->GetByteOrder(); + + size_t num_val_bytes = sizeof(value64); + size_t num_data_bytes = heap_data_buf->GetByteSize(); + + size_t num_bytes = num_val_bytes; + if (num_bytes > num_data_bytes) + num_bytes = num_data_bytes; + + uint8_t *data_bytes = heap_data_buf->GetBytes(); + + for (off_t byte_idx = 0; + byte_idx < num_bytes; + ++byte_idx) + { + uint64_t shift = byte_idx * 8; + uint64_t mask = 0xffll << shift; + uint8_t cur_byte = (uint8_t)((value64 & mask) >> shift); + + switch (byte_order) + { + case eByteOrderBig: + // High Low + // Original: |AABBCCDDEEFFGGHH| + // Target: |EEFFGGHH| + + data_bytes[num_data_bytes - (1 + byte_idx)] = cur_byte; + break; + case eByteOrderLittle: + // Target: |HHGGFFEE| + data_bytes[byte_idx] = cur_byte; + break; + default: + return lldb::ClangExpressionVariableSP(); + } + } + + ValueObjectSP valobj_sp(new ValueObjectConstResult(user_type.GetASTContext(), + user_type.GetOpaqueQualType(), + name, + data_sp, + m_parser_vars->m_exe_ctx->process->GetByteOrder(), + m_parser_vars->m_exe_ctx->process->GetAddressByteSize())); + + ClangExpressionVariableSP var_sp(new ClangExpressionVariable(valobj_sp)); + + return var_sp; +} + bool ClangExpressionDeclMap::AddPersistentVariable ( Modified: lldb/trunk/source/Expression/ClangExpressionParser.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/ClangExpressionParser.cpp?rev=121952&r1=121951&r2=121952&view=diff ============================================================================== --- lldb/trunk/source/Expression/ClangExpressionParser.cpp (original) +++ lldb/trunk/source/Expression/ClangExpressionParser.cpp Wed Dec 15 21:17:46 2010 @@ -409,7 +409,8 @@ Error ClangExpressionParser::MakeJIT (lldb::addr_t &func_addr, lldb::addr_t &func_end, - ExecutionContext &exe_ctx) + ExecutionContext &exe_ctx, + lldb::ClangExpressionVariableSP *const_result) { lldb::LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS)); @@ -446,6 +447,7 @@ { IRForTarget ir_for_target(decl_map, m_expr.NeedsVariableResolution(), + const_result, function_name.c_str()); if (!ir_for_target.runOnModule(*module)) Modified: lldb/trunk/source/Expression/ClangUserExpression.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/ClangUserExpression.cpp?rev=121952&r1=121951&r2=121952&view=diff ============================================================================== --- lldb/trunk/source/Expression/ClangUserExpression.cpp (original) +++ lldb/trunk/source/Expression/ClangUserExpression.cpp Wed Dec 15 21:17:46 2010 @@ -22,10 +22,11 @@ #include "lldb/Core/Log.h" #include "lldb/Core/StreamString.h" #include "lldb/Core/ValueObjectConstResult.h" +#include "lldb/Expression/ASTSplitConsumer.h" +#include "lldb/Expression/ASTResultSynthesizer.h" #include "lldb/Expression/ClangExpressionDeclMap.h" #include "lldb/Expression/ClangExpressionParser.h" #include "lldb/Expression/ClangFunction.h" -#include "lldb/Expression/ASTResultSynthesizer.h" #include "lldb/Expression/ClangUserExpression.h" #include "lldb/Host/Host.h" #include "lldb/Symbol/VariableList.h" @@ -143,7 +144,8 @@ bool ClangUserExpression::Parse (Stream &error_stream, ExecutionContext &exe_ctx, - TypeFromUser desired_type) + TypeFromUser desired_type, + lldb::ClangExpressionVariableSP *const_result) { lldb::LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS)); @@ -292,8 +294,8 @@ m_dwarf_opcodes.reset(); lldb::addr_t jit_end; - - Error jit_error = parser.MakeJIT (m_jit_addr, jit_end, exe_ctx); + + Error jit_error = parser.MakeJIT (m_jit_addr, jit_end, exe_ctx, const_result); m_expr_decl_map->DidParse(); @@ -601,10 +603,12 @@ StreamString error_stream; + lldb::ClangExpressionVariableSP const_result; + if (log) log->Printf("== [ClangUserExpression::Evaluate] Parsing expression %s ==", expr_cstr); - if (!user_expression_sp->Parse (error_stream, exe_ctx, TypeFromUser(NULL, NULL))) + if (!user_expression_sp->Parse (error_stream, exe_ctx, TypeFromUser(NULL, NULL), &const_result)) { if (error_stream.GetString().empty()) error.SetErrorString ("expression failed to parse, unknown error"); @@ -615,41 +619,52 @@ { lldb::ClangExpressionVariableSP expr_result; - error_stream.GetString().clear(); - - if (log) - log->Printf("== [ClangUserExpression::Evaluate] Executing expression =="); - - execution_results = user_expression_sp->Execute (error_stream, - exe_ctx, - discard_on_error, - user_expression_sp, - expr_result); - if (execution_results != lldb::eExecutionCompleted) + if (const_result.get()) { if (log) - log->Printf("== [ClangUserExpression::Evaluate] Execution completed abnormally =="); + log->Printf("== [ClangUserExpression::Evaluate] Expression evaluated as a constant =="); - if (error_stream.GetString().empty()) - error.SetErrorString ("expression failed to execute, unknown error"); - else - error.SetErrorString (error_stream.GetString().c_str()); + result_valobj_sp = const_result->GetValueObject(); } - else - { - if (expr_result) + else + { + error_stream.GetString().clear(); + + if (log) + log->Printf("== [ClangUserExpression::Evaluate] Executing expression =="); + + execution_results = user_expression_sp->Execute (error_stream, + exe_ctx, + discard_on_error, + user_expression_sp, + expr_result); + + if (execution_results != lldb::eExecutionCompleted) { - result_valobj_sp = expr_result->GetValueObject(); - if (log) - log->Printf("== [ClangUserExpression::Evaluate] Execution completed normally with result %s ==", result_valobj_sp->GetValueAsCString(exe_ctx.GetBestExecutionContextScope())); + log->Printf("== [ClangUserExpression::Evaluate] Execution completed abnormally =="); + + if (error_stream.GetString().empty()) + error.SetErrorString ("expression failed to execute, unknown error"); + else + error.SetErrorString (error_stream.GetString().c_str()); } - else + else { - if (log) - log->Printf("== [ClangUserExpression::Evaluate] Execution completed normally with no result =="); - - error.SetErrorString ("Expression did not return a result"); + if (expr_result) + { + result_valobj_sp = expr_result->GetValueObject(); + + if (log) + log->Printf("== [ClangUserExpression::Evaluate] Execution completed normally with result %s ==", result_valobj_sp->GetValueAsCString(exe_ctx.GetBestExecutionContextScope())); + } + else + { + if (log) + log->Printf("== [ClangUserExpression::Evaluate] Execution completed normally with no result =="); + + error.SetErrorString ("Expression did not return a result"); + } } } } Modified: lldb/trunk/source/Expression/IRForTarget.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/IRForTarget.cpp?rev=121952&r1=121951&r2=121952&view=diff ============================================================================== --- lldb/trunk/source/Expression/IRForTarget.cpp (original) +++ lldb/trunk/source/Expression/IRForTarget.cpp Wed Dec 15 21:17:46 2010 @@ -34,13 +34,16 @@ IRForTarget::IRForTarget (lldb_private::ClangExpressionDeclMap *decl_map, bool resolve_vars, + lldb::ClangExpressionVariableSP *const_result, const char *func_name) : ModulePass(ID), m_decl_map(decl_map), m_CFStringCreateWithBytes(NULL), m_sel_registerName(NULL), m_func_name(func_name), - m_resolve_vars(resolve_vars) + m_resolve_vars(resolve_vars), + m_const_result(const_result), + m_has_side_effects(NULL) { } @@ -75,6 +78,64 @@ } bool +IRForTarget::HasSideEffects (llvm::Module &llvm_module, + llvm::Function &llvm_function) +{ + llvm::Function::iterator bbi; + BasicBlock::iterator ii; + + for (bbi = llvm_function.begin(); + bbi != llvm_function.end(); + ++bbi) + { + BasicBlock &basic_block = *bbi; + + for (ii = basic_block.begin(); + ii != basic_block.end(); + ++ii) + { + switch (ii->getOpcode()) + { + default: + return true; + case Instruction::Store: + { + StoreInst *store_inst = dyn_cast(ii); + + Value *store_ptr = store_inst->getPointerOperand(); + + if (!isa (store_ptr)) + return true; + else + break; + } + case Instruction::Load: + case Instruction::Alloca: + case Instruction::GetElementPtr: + case Instruction::Ret: + break; + } + } + } + + return false; +} + +void +IRForTarget::MaybeSetConstantResult (llvm::Constant *initializer, + const lldb_private::ConstString &name, + lldb_private::TypeFromParser type) +{ + if (!m_const_result) + return; + + if (llvm::ConstantInt *init_int = dyn_cast(initializer)) + { + *m_const_result = m_decl_map->BuildIntegerVariable(name, type, init_int->getValue()); + } +} + +bool IRForTarget::CreateResultVariable (llvm::Module &llvm_module, llvm::Function &llvm_function) { lldb::LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS)); @@ -239,6 +300,16 @@ } Constant *initializer = result_global->getInitializer(); + + // Here we write the initializer into a result variable assuming it + // can be computed statically. + + if (!m_has_side_effects) + { + MaybeSetConstantResult (initializer, + new_result_name, + result_decl_type); + } StoreInst *synthesized_store = new StoreInst::StoreInst(initializer, new_result_global, @@ -1442,6 +1513,8 @@ Function::iterator bbi; + m_has_side_effects = HasSideEffects(llvm_module, *function); + //////////////////////////////////////////////////////////// // Replace $__lldb_expr_result with a persistent variable // @@ -1456,19 +1529,7 @@ /////////////////////////////////////////////////////////////////////////////// // Fix all Objective-C constant strings to use NSStringWithCString:encoding: // - - if (log) - { - std::string s; - raw_string_ostream oss(s); - - llvm_module.print(oss, NULL); - - oss.flush(); - log->Printf("Module after creating the result variable: \n\"%s\"", s.c_str()); - } - if (!RewriteObjCConstStrings(llvm_module, *function)) { if (log) @@ -1476,18 +1537,6 @@ return false; } - if (log) - { - std::string s; - raw_string_ostream oss(s); - - llvm_module.print(oss, NULL); - - oss.flush(); - - log->Printf("Module after rewriting Objective-C const strings: \n\"%s\"", s.c_str()); - } - ////////////////////////////////// // Run basic-block level passes // From jmolenda at apple.com Wed Dec 15 21:23:53 2010 From: jmolenda at apple.com (Jason Molenda) Date: Thu, 16 Dec 2010 03:23:53 -0000 Subject: [Lldb-commits] [lldb] r121954 - /lldb/trunk/source/Expression/ClangUserExpression.cpp Message-ID: <20101216032353.B0D942A6C12C@llvm.org> Author: jmolenda Date: Wed Dec 15 21:23:53 2010 New Revision: 121954 URL: http://llvm.org/viewvc/llvm-project?rev=121954&view=rev Log: Remove #include of non-existant lldb/Expression/ASTSplitConsumer.h (from Sean's commit a minute ago) 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=121954&r1=121953&r2=121954&view=diff ============================================================================== --- lldb/trunk/source/Expression/ClangUserExpression.cpp (original) +++ lldb/trunk/source/Expression/ClangUserExpression.cpp Wed Dec 15 21:23:53 2010 @@ -22,7 +22,6 @@ #include "lldb/Core/Log.h" #include "lldb/Core/StreamString.h" #include "lldb/Core/ValueObjectConstResult.h" -#include "lldb/Expression/ASTSplitConsumer.h" #include "lldb/Expression/ASTResultSynthesizer.h" #include "lldb/Expression/ClangExpressionDeclMap.h" #include "lldb/Expression/ClangExpressionParser.h" From johnny.chen at apple.com Thu Dec 16 12:10:16 2010 From: johnny.chen at apple.com (Johnny Chen) Date: Thu, 16 Dec 2010 18:10:16 -0000 Subject: [Lldb-commits] [lldb] r121986 - /lldb/trunk/test/blacklist.py Message-ID: <20101216181016.383B72A6C12C@llvm.org> Author: johnny Date: Thu Dec 16 12:10:16 2010 New Revision: 121986 URL: http://llvm.org/viewvc/llvm-project?rev=121986&view=rev Log: Update the comment section of blacklist.py with the command line to reproduce the crash. Modified: lldb/trunk/test/blacklist.py Modified: lldb/trunk/test/blacklist.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/blacklist.py?rev=121986&r1=121985&r2=121986&view=diff ============================================================================== --- lldb/trunk/test/blacklist.py (original) +++ lldb/trunk/test/blacklist.py Thu Dec 16 12:10:16 2010 @@ -14,7 +14,7 @@ """ blacklist = {'BasicExprCommandsTestCase.test_evaluate_expression_python': 'Crashed while running the entire test suite with CC=clang' - # To reproduce the crash: CC=clang ./dotest.py -v -w 2> ~/Developer/Log/lldbtest.log + # To reproduce the crash: CC=clang ./dotest.py -v -w -# 5 -f BasicExprCommandsTestCase.test_evaluate_expression_python # The clang version used is clang-126. # Two radars filed for the crashes: rdar://problem/8769826 and rdar://problem/8773329. # To skip this test case: CC=clang ./dotest.py -b blacklist.py -v -w 2> ~/Developer/Log/lldbtest.log From johnny.chen at apple.com Thu Dec 16 12:37:46 2010 From: johnny.chen at apple.com (Johnny Chen) Date: Thu, 16 Dec 2010 18:37:46 -0000 Subject: [Lldb-commits] [lldb] r121989 - /lldb/trunk/test/python_api/symbol-context/TestSymbolContext.py Message-ID: <20101216183746.5F8242A6C12C@llvm.org> Author: johnny Date: Thu Dec 16 12:37:46 2010 New Revision: 121989 URL: http://llvm.org/viewvc/llvm-project?rev=121989&view=rev Log: Use SBModule.GetDescription(SBStream) API to get the module description to match against. Modified: lldb/trunk/test/python_api/symbol-context/TestSymbolContext.py Modified: lldb/trunk/test/python_api/symbol-context/TestSymbolContext.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/python_api/symbol-context/TestSymbolContext.py?rev=121989&r1=121988&r2=121989&view=diff ============================================================================== --- lldb/trunk/test/python_api/symbol-context/TestSymbolContext.py (original) +++ lldb/trunk/test/python_api/symbol-context/TestSymbolContext.py Thu Dec 16 12:37:46 2010 @@ -60,15 +60,16 @@ context = frame0.GetSymbolContext(lldb.eSymbolContextEverything) self.assertTrue(context.IsValid()) + # Get the description of this module. module = context.GetModule() - self.expect(repr(module), "The module should match", exe=False, + stream = lldb.SBStream() + module.GetDescription(stream) + self.expect(stream.GetData(), "The module should match", exe=False, substrs = [os.path.join(self.mydir, 'a.out')]) - #print "module:", module compileUnit = context.GetCompileUnit() self.expect(repr(compileUnit), "The compile unit should match", exe=False, substrs = [os.path.join(self.mydir, 'main.c')]) - #print "compile unit:", compileUnit function = context.GetFunction() self.assertTrue(function.IsValid()) From gclayton at apple.com Thu Dec 16 14:01:20 2010 From: gclayton at apple.com (Greg Clayton) Date: Thu, 16 Dec 2010 20:01:20 -0000 Subject: [Lldb-commits] [lldb] r121996 - in /lldb/trunk: include/lldb/Target/Process.h source/Target/Process.cpp Message-ID: <20101216200120.347A22A6C12C@llvm.org> Author: gclayton Date: Thu Dec 16 14:01:20 2010 New Revision: 121996 URL: http://llvm.org/viewvc/llvm-project?rev=121996&view=rev Log: Added the ability to read unsigned integers from the Process: uint64_t Process::ReadUnsignedInteger (addr_t addr, size_t int_byte_size, Error &error); Modified: lldb/trunk/include/lldb/Target/Process.h lldb/trunk/source/Target/Process.cpp Modified: lldb/trunk/include/lldb/Target/Process.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/Process.h?rev=121996&r1=121995&r2=121996&view=diff ============================================================================== --- lldb/trunk/include/lldb/Target/Process.h (original) +++ lldb/trunk/include/lldb/Target/Process.h Thu Dec 16 14:01:20 2010 @@ -1336,6 +1336,10 @@ size_t size, Error &error); + uint64_t + ReadUnsignedInteger (lldb::addr_t vm_addr, + size_t integer_byte_size, + Error &error); //------------------------------------------------------------------ /// Actually do the writing of memory to a process. /// Modified: lldb/trunk/source/Target/Process.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/Process.cpp?rev=121996&r1=121995&r2=121996&view=diff ============================================================================== --- lldb/trunk/source/Target/Process.cpp (original) +++ lldb/trunk/source/Target/Process.cpp Thu Dec 16 14:01:20 2010 @@ -1072,6 +1072,29 @@ return bytes_read; } +uint64_t +Process::ReadUnsignedInteger (lldb::addr_t vm_addr, size_t integer_byte_size, Error &error) +{ + if (integer_byte_size > sizeof(uint64_t)) + { + error.SetErrorString ("unsupported integer size"); + } + else + { + uint8_t tmp[sizeof(uint64_t)]; + DataExtractor data (tmp, integer_byte_size, GetByteOrder(), GetAddressByteSize()); + if (ReadMemory (vm_addr, tmp, integer_byte_size, error) == integer_byte_size) + { + uint32_t offset = 0; + return data.GetMaxU64 (&offset, integer_byte_size); + } + } + // Any plug-in that doesn't return success a memory read with the number + // of bytes that were requested should be setting the error + assert (error.Fail()); + return 0; +} + size_t Process::WriteMemoryPrivate (addr_t addr, const void *buf, size_t size, Error &error) { From gclayton at apple.com Thu Dec 16 14:15:34 2010 From: gclayton at apple.com (Greg Clayton) Date: Thu, 16 Dec 2010 20:15:34 -0000 Subject: [Lldb-commits] [lldb] r121999 - /lldb/trunk/include/lldb/Target/Process.h Message-ID: <20101216201534.805C52A6C12C@llvm.org> Author: gclayton Date: Thu Dec 16 14:15:34 2010 New Revision: 121999 URL: http://llvm.org/viewvc/llvm-project?rev=121999&view=rev Log: Added header doc for the recently added Process::ReadUnsignedInteger (addr_t addr, size_t int_byte_size, Error &error) function. Modified: lldb/trunk/include/lldb/Target/Process.h Modified: lldb/trunk/include/lldb/Target/Process.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/Process.h?rev=121999&r1=121998&r2=121999&view=diff ============================================================================== --- lldb/trunk/include/lldb/Target/Process.h (original) +++ lldb/trunk/include/lldb/Target/Process.h Thu Dec 16 14:15:34 2010 @@ -1336,9 +1336,33 @@ size_t size, Error &error); + //------------------------------------------------------------------ + /// Reads an unsigned integer of the specified byte size from + /// process memory. + /// + /// @param[in] load_addr + /// A load address of the integer to read. + /// + /// @param[in] byte_size + /// The size in byte of the integer to read. + /// + /// @param[out] error + /// An error that indicates the success or failure of this + /// operation. If error indicates success (error.Success()), + /// then the value returned can be trusted, otherwise zero + /// will be returned. + /// + /// @return + /// The unsigned integer that was read from the process memory + /// space. If the integer was smaller than a uint64_t, any + /// unused upper bytes will be zero filled. If the process + /// byte order differs from the host byte order, the integer + /// value will be appropriately byte swapped into host byte + /// order. + //------------------------------------------------------------------ uint64_t - ReadUnsignedInteger (lldb::addr_t vm_addr, - size_t integer_byte_size, + ReadUnsignedInteger (lldb::addr_t load_addr, + size_t byte_size, Error &error); //------------------------------------------------------------------ /// Actually do the writing of memory to a process. From wilsons at start.ca Thu Dec 16 14:54:51 2010 From: wilsons at start.ca (Stephen Wilson) Date: Thu, 16 Dec 2010 15:54:51 -0500 Subject: [Lldb-commits] [PATCH 0/3] linux: lldb.cpp Message-ID: <1292532894-4455-1-git-send-email-wilsons@start.ca> Hi all, The following three patches update source/lldb.cpp for building on linux systems. The changes are fairly minimal -- the main part is to move some of the initialization/termination calls plus some #include's under the __APPLE__ guard as these components are not yet supported on Linux. Thanks, __ steve From wilsons at start.ca Thu Dec 16 14:54:52 2010 From: wilsons at start.ca (Stephen Wilson) Date: Thu, 16 Dec 2010 15:54:52 -0500 Subject: [Lldb-commits] [PATCH 1/3] Use the lldb namespace. In-Reply-To: <1292532894-4455-1-git-send-email-wilsons@start.ca> References: <1292532894-4455-1-git-send-email-wilsons@start.ca> Message-ID: <1292532894-4455-2-git-send-email-wilsons@start.ca> Eliminates many errors when compiling using GCC under Linux (references to lldb defined enumerations in particular). diff --git a/source/lldb.cpp b/source/lldb.cpp index 082274b..6f68111 100644 --- a/source/lldb.cpp +++ b/source/lldb.cpp @@ -43,6 +43,7 @@ #include "Plugins/Process/Linux/ProcessLinux.h" #endif +using namespace lldb; using namespace lldb_private; -- 1.7.3.2 From wilsons at start.ca Thu Dec 16 14:54:53 2010 From: wilsons at start.ca (Stephen Wilson) Date: Thu, 16 Dec 2010 15:54:53 -0500 Subject: [Lldb-commits] [PATCH 2/3] Add missing includes. In-Reply-To: <1292532894-4455-1-git-send-email-wilsons@start.ca> References: <1292532894-4455-1-git-send-email-wilsons@start.ca> Message-ID: <1292532894-4455-3-git-send-email-wilsons@start.ca> The full declarations for lldb_private::Target and lldb_private::Thread are needed. diff --git a/source/lldb.cpp b/source/lldb.cpp index 6f68111..137ad86 100644 --- a/source/lldb.cpp +++ b/source/lldb.cpp @@ -14,6 +14,8 @@ #include "lldb/Core/Timer.h" #include "lldb/Host/Host.h" #include "lldb/Host/Mutex.h" +#include "lldb/Target/Target.h" +#include "lldb/Target/Thread.h" #include "Plugins/Disassembler/llvm/DisassemblerLLVM.h" #include "Plugins/SymbolVendor/MacOSX/SymbolVendorMacOSX.h" -- 1.7.3.2 From wilsons at start.ca Thu Dec 16 14:54:54 2010 From: wilsons at start.ca (Stephen Wilson) Date: Thu, 16 Dec 2010 15:54:54 -0500 Subject: [Lldb-commits] [PATCH 3/3] Rearrange #include's, initialization/termination. In-Reply-To: <1292532894-4455-1-git-send-email-wilsons@start.ca> References: <1292532894-4455-1-git-send-email-wilsons@start.ca> Message-ID: <1292532894-4455-4-git-send-email-wilsons@start.ca> Guard #include's and component initialization/termination with the __APPLE__ define to allow compilation on non-Apple platforms. diff --git a/source/lldb.cpp b/source/lldb.cpp index 137ad86..ae8fe6a 100644 --- a/source/lldb.cpp +++ b/source/lldb.cpp @@ -24,9 +24,6 @@ #include "Plugins/SymbolFile/DWARF/SymbolFileDWARF.h" #include "Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h" #include "Plugins/SymbolFile/Symtab/SymbolFileSymtab.h" -#include "Plugins/Process/Utility/UnwindAssemblyProfiler-x86.h" -#include "Plugins/Process/Utility/ArchDefaultUnwindPlan-x86.h" -#include "Plugins/Process/Utility/ArchVolatileRegs-x86.h" #ifdef __APPLE__ #include "Plugins/ABI/MacOSX-i386/ABIMacOSX_i386.h" @@ -39,6 +36,9 @@ #include "Plugins/ObjectFile/Mach-O/ObjectFileMachO.h" #include "Plugins/Process/MacOSX-User/source/ProcessMacOSX.h" #include "Plugins/Process/gdb-remote/ProcessGDBRemote.h" +#include "Plugins/Process/Utility/UnwindAssemblyProfiler-x86.h" +#include "Plugins/Process/Utility/ArchDefaultUnwindPlan-x86.h" +#include "Plugins/Process/Utility/ArchVolatileRegs-x86.h" #endif #ifdef __linux__ @@ -73,11 +73,11 @@ lldb_private::Initialize () SymbolFileDWARF::Initialize(); SymbolFileDWARFDebugMap::Initialize(); SymbolFileSymtab::Initialize(); + +#ifdef __APPLE__ UnwindAssemblyProfiler_x86::Initialize(); ArchDefaultUnwindPlan_x86::Initialize(); ArchVolatileRegs_x86::Initialize(); - -#ifdef __APPLE__ ABIMacOSX_i386::Initialize(); ABISysV_x86_64::Initialize(); DynamicLoaderMacOSXDYLD::Initialize(); @@ -112,11 +112,11 @@ lldb_private::Terminate () SymbolFileDWARF::Terminate(); SymbolFileDWARFDebugMap::Terminate(); SymbolFileSymtab::Terminate(); + +#ifdef __APPLE__ UnwindAssemblyProfiler_x86::Terminate(); ArchDefaultUnwindPlan_x86::Terminate(); ArchVolatileRegs_x86::Terminate(); - -#ifdef __APPLE__ DynamicLoaderMacOSXDYLD::Terminate(); ItaniumABILanguageRuntime::Terminate(); AppleObjCRuntimeV2::Terminate(); -- 1.7.3.2 From gclayton at apple.com Thu Dec 16 15:33:41 2010 From: gclayton at apple.com (Greg Clayton) Date: Thu, 16 Dec 2010 21:33:41 -0000 Subject: [Lldb-commits] [lldb] r122001 - /lldb/trunk/source/lldb.cpp Message-ID: <20101216213341.E651A2A6C12C@llvm.org> Author: gclayton Date: Thu Dec 16 15:33:41 2010 New Revision: 122001 URL: http://llvm.org/viewvc/llvm-project?rev=122001&view=rev Log: Fixes for linux building from Stephen Wilson. Modified: lldb/trunk/source/lldb.cpp Modified: lldb/trunk/source/lldb.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/lldb.cpp?rev=122001&r1=122000&r2=122001&view=diff ============================================================================== --- lldb/trunk/source/lldb.cpp (original) +++ lldb/trunk/source/lldb.cpp Thu Dec 16 15:33:41 2010 @@ -43,6 +43,7 @@ #include "Plugins/Process/Linux/ProcessLinux.h" #endif +using namespace lldb; using namespace lldb_private; From gclayton at apple.com Thu Dec 16 15:36:31 2010 From: gclayton at apple.com (Greg Clayton) Date: Thu, 16 Dec 2010 21:36:31 -0000 Subject: [Lldb-commits] [lldb] r122002 - /lldb/trunk/source/lldb.cpp Message-ID: <20101216213631.146E52A6C12C@llvm.org> Author: gclayton Date: Thu Dec 16 15:36:30 2010 New Revision: 122002 URL: http://llvm.org/viewvc/llvm-project?rev=122002&view=rev Log: Fixes for linux building from Stephen Wilson. Modified: lldb/trunk/source/lldb.cpp Modified: lldb/trunk/source/lldb.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/lldb.cpp?rev=122002&r1=122001&r2=122002&view=diff ============================================================================== --- lldb/trunk/source/lldb.cpp (original) +++ lldb/trunk/source/lldb.cpp Thu Dec 16 15:36:30 2010 @@ -14,6 +14,8 @@ #include "lldb/Core/Timer.h" #include "lldb/Host/Host.h" #include "lldb/Host/Mutex.h" +#include "lldb/Target/Target.h" +#include "lldb/Target/Thread.h" #include "Plugins/Disassembler/llvm/DisassemblerLLVM.h" #include "Plugins/SymbolVendor/MacOSX/SymbolVendorMacOSX.h" From gclayton at apple.com Thu Dec 16 15:43:05 2010 From: gclayton at apple.com (Greg Clayton) Date: Thu, 16 Dec 2010 13:43:05 -0800 Subject: [Lldb-commits] [PATCH 3/3] Rearrange #include's, initialization/termination. In-Reply-To: <1292532894-4455-4-git-send-email-wilsons@start.ca> References: <1292532894-4455-1-git-send-email-wilsons@start.ca> <1292532894-4455-4-git-send-email-wilsons@start.ca> Message-ID: <288C6745-F9A7-404C-9CB2-1FC89C8E6328@apple.com> This one shouldn't be committed, we will need to get the UnwindAssemblyProfiler-x86, ArchDefaultUnwindPlan-x86, and the ArchVolatileRegs-x86 to compile and build on linux. They are the basis for our i386/x86_64 unwinder. This unwinder should be able to be used by the linux debugger plug-in as the unwinder for both i386 and for x86_64. Do these files not build on linux? Is the make system just not building these? If the build system isn't then it should be. Stephen, let me know what issue you run into when tryingo t build these? Greg Clayton On Dec 16, 2010, at 12:54 PM, Stephen Wilson wrote: > Guard #include's and component initialization/termination with the __APPLE__ > define to allow compilation on non-Apple platforms. > > diff --git a/source/lldb.cpp b/source/lldb.cpp > index 137ad86..ae8fe6a 100644 > --- a/source/lldb.cpp > +++ b/source/lldb.cpp > @@ -24,9 +24,6 @@ > #include "Plugins/SymbolFile/DWARF/SymbolFileDWARF.h" > #include "Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h" > #include "Plugins/SymbolFile/Symtab/SymbolFileSymtab.h" > -#include "Plugins/Process/Utility/UnwindAssemblyProfiler-x86.h" > -#include "Plugins/Process/Utility/ArchDefaultUnwindPlan-x86.h" > -#include "Plugins/Process/Utility/ArchVolatileRegs-x86.h" > > #ifdef __APPLE__ > #include "Plugins/ABI/MacOSX-i386/ABIMacOSX_i386.h" > @@ -39,6 +36,9 @@ > #include "Plugins/ObjectFile/Mach-O/ObjectFileMachO.h" > #include "Plugins/Process/MacOSX-User/source/ProcessMacOSX.h" > #include "Plugins/Process/gdb-remote/ProcessGDBRemote.h" > +#include "Plugins/Process/Utility/UnwindAssemblyProfiler-x86.h" > +#include "Plugins/Process/Utility/ArchDefaultUnwindPlan-x86.h" > +#include "Plugins/Process/Utility/ArchVolatileRegs-x86.h" > #endif > > #ifdef __linux__ > @@ -73,11 +73,11 @@ lldb_private::Initialize () > SymbolFileDWARF::Initialize(); > SymbolFileDWARFDebugMap::Initialize(); > SymbolFileSymtab::Initialize(); > + > +#ifdef __APPLE__ > UnwindAssemblyProfiler_x86::Initialize(); > ArchDefaultUnwindPlan_x86::Initialize(); > ArchVolatileRegs_x86::Initialize(); > - > -#ifdef __APPLE__ > ABIMacOSX_i386::Initialize(); > ABISysV_x86_64::Initialize(); > DynamicLoaderMacOSXDYLD::Initialize(); > @@ -112,11 +112,11 @@ lldb_private::Terminate () > SymbolFileDWARF::Terminate(); > SymbolFileDWARFDebugMap::Terminate(); > SymbolFileSymtab::Terminate(); > + > +#ifdef __APPLE__ > UnwindAssemblyProfiler_x86::Terminate(); > ArchDefaultUnwindPlan_x86::Terminate(); > ArchVolatileRegs_x86::Terminate(); > - > -#ifdef __APPLE__ > DynamicLoaderMacOSXDYLD::Terminate(); > ItaniumABILanguageRuntime::Terminate(); > AppleObjCRuntimeV2::Terminate(); > -- > 1.7.3.2 > > _______________________________________________ > lldb-commits mailing list > lldb-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/lldb-commits From wilsons at start.ca Thu Dec 16 16:29:54 2010 From: wilsons at start.ca (Stephen Wilson) Date: Thu, 16 Dec 2010 17:29:54 -0500 Subject: [Lldb-commits] [PATCH 3/3] Rearrange #include's, initialization/termination. In-Reply-To: <288C6745-F9A7-404C-9CB2-1FC89C8E6328@apple.com> (Greg Clayton's message of "Thu, 16 Dec 2010 13:43:05 -0800") References: <1292532894-4455-1-git-send-email-wilsons@start.ca> <1292532894-4455-4-git-send-email-wilsons@start.ca> <288C6745-F9A7-404C-9CB2-1FC89C8E6328@apple.com> Message-ID: Hi Greg, Greg Clayton writes: > This one shouldn't be committed, we will need to get the > UnwindAssemblyProfiler-x86, ArchDefaultUnwindPlan-x86, and the > ArchVolatileRegs-x86 to compile and build on linux. They are the basis > for our i386/x86_64 unwinder. This unwinder should be able to be used > by the linux debugger plug-in as the unwinder for both i386 and for > x86_64. > > Do these files not build on linux? Is the make system just not > building these? If the build system isn't then it should be. Currently the build system does not enter Process/Utility. The main issue here is LLDB's libunwind. I have not looked deeply at what is needed to get libunwind to build on linux -- I expect it will take some time. The main focus of these patches is to simply get the tree to build under linux without compromising the Darwin build, and to do so with the smallest number of changes possible. Once the tree is buildable my plan was to start working on all of the "missing" features and re-integrate support. However, if you feel that this is not a proper strategy that is perfectly OK with me -- I can keep this change local and still have a buildable tree and submit patches against Process/Utility down the road. > Stephen, let me know what issue you run into when tryingo t build these? There are quite a few. For example we need to conditionalize the include of Availability.h and provide Linux builds with an empty define for __OSX_AVAILABLE_STARTING (libunwind.h). We need to remove references to mach/mach_types.h, mach/machine.h etc and use the support headers provided by LLVM (possibly extending them?). There are quite a few other examples. Of course, I may be wrong here in expecting that LLDB's libunwind is intended to be cross-platform in time -- perhaps we should be using the system libunwind on linux? If we want to use the system libunwind on linux then we will need to figure out how to work around the fact that the symbols are extern "C" and do not live in the lldb_private namespace. Please let me know if you have any suggestions on how to approach this problem and I would be happy to look into any other approaches. Take care, > Greg Clayton > > > On Dec 16, 2010, at 12:54 PM, Stephen Wilson wrote: > >> Guard #include's and component initialization/termination with the __APPLE__ >> define to allow compilation on non-Apple platforms. >> >> diff --git a/source/lldb.cpp b/source/lldb.cpp >> index 137ad86..ae8fe6a 100644 >> --- a/source/lldb.cpp >> +++ b/source/lldb.cpp >> @@ -24,9 +24,6 @@ >> #include "Plugins/SymbolFile/DWARF/SymbolFileDWARF.h" >> #include "Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h" >> #include "Plugins/SymbolFile/Symtab/SymbolFileSymtab.h" >> -#include "Plugins/Process/Utility/UnwindAssemblyProfiler-x86.h" >> -#include "Plugins/Process/Utility/ArchDefaultUnwindPlan-x86.h" >> -#include "Plugins/Process/Utility/ArchVolatileRegs-x86.h" >> >> #ifdef __APPLE__ >> #include "Plugins/ABI/MacOSX-i386/ABIMacOSX_i386.h" >> @@ -39,6 +36,9 @@ >> #include "Plugins/ObjectFile/Mach-O/ObjectFileMachO.h" >> #include "Plugins/Process/MacOSX-User/source/ProcessMacOSX.h" >> #include "Plugins/Process/gdb-remote/ProcessGDBRemote.h" >> +#include "Plugins/Process/Utility/UnwindAssemblyProfiler-x86.h" >> +#include "Plugins/Process/Utility/ArchDefaultUnwindPlan-x86.h" >> +#include "Plugins/Process/Utility/ArchVolatileRegs-x86.h" >> #endif >> >> #ifdef __linux__ >> @@ -73,11 +73,11 @@ lldb_private::Initialize () >> SymbolFileDWARF::Initialize(); >> SymbolFileDWARFDebugMap::Initialize(); >> SymbolFileSymtab::Initialize(); >> + >> +#ifdef __APPLE__ >> UnwindAssemblyProfiler_x86::Initialize(); >> ArchDefaultUnwindPlan_x86::Initialize(); >> ArchVolatileRegs_x86::Initialize(); >> - >> -#ifdef __APPLE__ >> ABIMacOSX_i386::Initialize(); >> ABISysV_x86_64::Initialize(); >> DynamicLoaderMacOSXDYLD::Initialize(); >> @@ -112,11 +112,11 @@ lldb_private::Terminate () >> SymbolFileDWARF::Terminate(); >> SymbolFileDWARFDebugMap::Terminate(); >> SymbolFileSymtab::Terminate(); >> + >> +#ifdef __APPLE__ >> UnwindAssemblyProfiler_x86::Terminate(); >> ArchDefaultUnwindPlan_x86::Terminate(); >> ArchVolatileRegs_x86::Terminate(); >> - >> -#ifdef __APPLE__ >> DynamicLoaderMacOSXDYLD::Terminate(); >> ItaniumABILanguageRuntime::Terminate(); >> AppleObjCRuntimeV2::Terminate(); >> -- >> 1.7.3.2 >> >> _______________________________________________ >> lldb-commits mailing list >> lldb-commits at cs.uiuc.edu >> http://lists.cs.uiuc.edu/mailman/listinfo/lldb-commits > -- steve From johnny.chen at apple.com Thu Dec 16 19:35:41 2010 From: johnny.chen at apple.com (Johnny Chen) Date: Fri, 17 Dec 2010 01:35:41 -0000 Subject: [Lldb-commits] [lldb] r122020 - /lldb/trunk/utils/emacs/gud.el Message-ID: <20101217013541.329BC2A6C12C@llvm.org> Author: johnny Date: Thu Dec 16 19:35:41 2010 New Revision: 122020 URL: http://llvm.org/viewvc/llvm-project?rev=122020&view=rev Log: Modify the regexp to match the debugger output of the 'Up Stack' and 'Down Stack' gud commands in order to more reliably locate the program counter and to display the file-and-line. 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=122020&r1=122019&r2=122020&view=diff ============================================================================== --- lldb/trunk/utils/emacs/gud.el (original) +++ lldb/trunk/utils/emacs/gud.el Thu Dec 16 19:35:41 2010 @@ -945,6 +945,7 @@ (defun lldb-extract-breakpoint-id (string) ;; Search for "Breakpoint created: \\([^:\n]*\\):" pattern. + ;(message "gud-marker-acc string is: |%s|" string) (if (string-match "Breakpoint created: \\([^:\n]*\\):" string) (progn (setq gud-breakpoint-id (match-string 1 string)) @@ -966,8 +967,9 @@ gud-marker-acc start) ;; (lldb) frame select -r 1 ;; frame #1: 0x0000000100000e09 a.out`main + 25 at main.c:44 - (string-match "\nframe.* at \\([^:\n]*\\):\\([0-9]*\\)\n" + (string-match "^frame.* at \\([^:\n]*\\):\\([0-9]*\\)\n" gud-marker-acc start)) + ;(message "gud-marker-acc matches our pattern....") (setq gud-last-frame (cons (match-string 1 gud-marker-acc) (string-to-number (match-string 2 gud-marker-acc))) From gclayton at apple.com Thu Dec 16 20:26:25 2010 From: gclayton at apple.com (Greg Clayton) Date: Fri, 17 Dec 2010 02:26:25 -0000 Subject: [Lldb-commits] [lldb] r122027 - in /lldb/trunk: include/lldb/API/SBThread.h include/lldb/Core/Scalar.h source/API/SBThread.cpp source/Expression/ClangUserExpression.cpp Message-ID: <20101217022625.180DF2A6C12C@llvm.org> Author: gclayton Date: Thu Dec 16 20:26:24 2010 New Revision: 122027 URL: http://llvm.org/viewvc/llvm-project?rev=122027&view=rev Log: Added access to set the current stack frame within a thread so any command line commands can use the current thread/frame. Fixed an issue with expressions that get sandboxed in an objective C method where unichar wasn't being passed down. Added a "static size_t Scalar::GetMaxByteSize();" function in case we need to know the max supported by size of something within a Scalar object. Modified: lldb/trunk/include/lldb/API/SBThread.h lldb/trunk/include/lldb/Core/Scalar.h lldb/trunk/source/API/SBThread.cpp lldb/trunk/source/Expression/ClangUserExpression.cpp Modified: lldb/trunk/include/lldb/API/SBThread.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBThread.h?rev=122027&r1=122026&r2=122027&view=diff ============================================================================== --- lldb/trunk/include/lldb/API/SBThread.h (original) +++ lldb/trunk/include/lldb/API/SBThread.h Thu Dec 16 20:26:24 2010 @@ -96,6 +96,12 @@ lldb::SBFrame GetFrameAtIndex (uint32_t idx); + lldb::SBFrame + GetSelectedFrame (); + + lldb::SBFrame + SetSelectedFrame (uint32_t frame_idx); + lldb::SBProcess GetProcess (); Modified: lldb/trunk/include/lldb/Core/Scalar.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/Scalar.h?rev=122027&r1=122026&r2=122027&view=diff ============================================================================== --- lldb/trunk/include/lldb/Core/Scalar.h (original) +++ lldb/trunk/include/lldb/Core/Scalar.h Thu Dec 16 20:26:24 2010 @@ -57,6 +57,12 @@ size_t GetByteSize() const; + static size_t + GetMaxByteSize() + { + return std::max (sizeof(long double), sizeof (unsigned long long)); + } + bool GetData (DataExtractor &data, size_t limit_byte_size = UINT32_MAX) const; Modified: lldb/trunk/source/API/SBThread.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBThread.cpp?rev=122027&r1=122026&r2=122027&view=diff ============================================================================== --- lldb/trunk/source/API/SBThread.cpp (original) +++ lldb/trunk/source/API/SBThread.cpp Thu Dec 16 20:26:24 2010 @@ -606,6 +606,53 @@ return sb_frame; } +lldb::SBFrame +SBThread::GetSelectedFrame () +{ + LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); + + SBFrame sb_frame; + if (m_opaque_sp) + sb_frame.SetFrame (m_opaque_sp->GetSelectedFrame ()); + + if (log) + { + SBStream sstr; + sb_frame.GetDescription (sstr); + log->Printf ("SBThread(%p)::GetSelectedFrame () => SBFrame(%p): %s", + m_opaque_sp.get(), sb_frame.get(), sstr.GetData()); + } + + return sb_frame; +} + +lldb::SBFrame +SBThread::SetSelectedFrame (uint32_t idx) +{ + LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); + + SBFrame sb_frame; + if (m_opaque_sp) + { + lldb::StackFrameSP frame_sp (m_opaque_sp->GetStackFrameAtIndex (idx)); + if (frame_sp) + { + m_opaque_sp->SetSelectedFrame (frame_sp.get()); + sb_frame.SetFrame (frame_sp); + } + } + + if (log) + { + SBStream sstr; + sb_frame.GetDescription (sstr); + log->Printf ("SBThread(%p)::SetSelectedFrame (idx=%u) => SBFrame(%p): %s", + m_opaque_sp.get(), idx, sb_frame.get(), sstr.GetData()); + } + return sb_frame; +} + + bool SBThread::operator == (const SBThread &rhs) const { Modified: lldb/trunk/source/Expression/ClangUserExpression.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/ClangUserExpression.cpp?rev=122027&r1=122026&r2=122027&view=diff ============================================================================== --- lldb/trunk/source/Expression/ClangUserExpression.cpp (original) +++ lldb/trunk/source/Expression/ClangUserExpression.cpp Thu Dec 16 20:26:24 2010 @@ -180,6 +180,7 @@ const char *function_name = FunctionName(); m_transformed_stream.Printf("%s \n" + "typedef unsigned short unichar; \n" "@interface $__lldb_objc_class ($__lldb_category) \n" "-(void)%s:(void *)$__lldb_arg; \n" "@end \n" From wilsons at start.ca Thu Dec 16 23:21:58 2010 From: wilsons at start.ca (Stephen Wilson) Date: Fri, 17 Dec 2010 00:21:58 -0500 Subject: [Lldb-commits] [PATCH 3/3] Rearrange #include's, initialization/termination. In-Reply-To: <288C6745-F9A7-404C-9CB2-1FC89C8E6328@apple.com> (Greg Clayton's message of "Thu, 16 Dec 2010 13:43:05 -0800") References: <1292532894-4455-1-git-send-email-wilsons@start.ca> <1292532894-4455-4-git-send-email-wilsons@start.ca> <288C6745-F9A7-404C-9CB2-1FC89C8E6328@apple.com> Message-ID: Hi Greg, Greg Clayton writes: > Stephen, let me know what issue you run into when tryingo t build these? OK. I definitely jumped the gun on this one -- I thought the code in Process/Utility was a bit more interdependent than it is :) Does the following patch look OK to you? This is the only issue I found among UnwindAssemblyProfiler-x86, ArchDefaultUnwindPlan-x86, and ArchVolatileRegs-x86. The only remaining problem is how to get the Makefiles working for this directory. I will take a closer look at the LLVM Makefiles, but I do not remember seeing a way to exclude files within a directory from the build. Would it be unreasonable to split up Process/Utility with a few more logical subdirectories in which we place platform-specific components if it turns out the current Makefile system cannot be pushed into dealing with the layout as is? Thanks! diff --git a/source/Plugins/Process/Utility/UnwindAssemblyProfiler-x86.cpp b/source/Plugins/Process/Utility/UnwindAssemblyProfiler-x86.cpp index 6b64886..61e3c70 100644 --- a/source/Plugins/Process/Utility/UnwindAssemblyProfiler-x86.cpp +++ b/source/Plugins/Process/Utility/UnwindAssemblyProfiler-x86.cpp @@ -844,11 +844,11 @@ UnwindAssemblyProfiler_x86::FirstNonPrologueInsn (AddressRange& func, Target& ta lldb_private::UnwindAssemblyProfiler * UnwindAssemblyProfiler_x86::CreateInstance (const lldb_private::ArchSpec &arch) { - uint32_t cpu = arch.GetCPUType (); - if (cpu != CPU_TYPE_X86_64 && cpu != CPU_TYPE_I386) + ArchSpec::CPU cpu = arch.GetGenericCPUType (); + if (cpu != ArchSpec::eCPU_x86_64 && cpu != ArchSpec::eCPU_i386) return NULL; - return new UnwindAssemblyProfiler_x86 (cpu == CPU_TYPE_X86_64 ? k_x86_64 : k_i386); + return new UnwindAssemblyProfiler_x86 (cpu == ArchSpec::eCPU_x86_64 ? k_x86_64 : k_i386); } From wilsons at start.ca Fri Dec 17 00:31:22 2010 From: wilsons at start.ca (Stephen Wilson) Date: Fri, 17 Dec 2010 01:31:22 -0500 Subject: [Lldb-commits] [PATCH 3/3] Rearrange #include's, initialization/termination. In-Reply-To: (Stephen Wilson's message of "Fri, 17 Dec 2010 00:21:58 -0500") References: <1292532894-4455-1-git-send-email-wilsons@start.ca> <1292532894-4455-4-git-send-email-wilsons@start.ca> <288C6745-F9A7-404C-9CB2-1FC89C8E6328@apple.com> Message-ID: Hi Greg, Stephen Wilson writes: > The only remaining problem is how to get the Makefiles working for this > directory. I will take a closer look at the LLVM Makefiles, but I do > not remember seeing a way to exclude files within a directory from the > build. > > Would it be unreasonable to split up Process/Utility with a few more > logical subdirectories in which we place platform-specific components if > it turns out the current Makefile system cannot be pushed into dealing > with the layout as is? I have a solution for the Makefiles. Will push the patch out along with some of the other Makefile changes shortly. Take care, -- steve From gclayton at apple.com Fri Dec 17 09:50:21 2010 From: gclayton at apple.com (Greg Clayton) Date: Fri, 17 Dec 2010 15:50:21 -0000 Subject: [Lldb-commits] [lldb] r122059 - in /lldb/trunk: include/lldb/Target/ lldb.xcodeproj/ source/Plugins/Process/MacOSX-User/source/ source/Plugins/Process/Utility/ source/Plugins/Process/Utility/libunwind/ source/Plugins/Process/gdb-remote/ Message-ID: <20101217155021.287E12A6C12C@llvm.org> Author: gclayton Date: Fri Dec 17 09:50:20 2010 New Revision: 122059 URL: http://llvm.org/viewvc/llvm-project?rev=122059&view=rev Log: Removed libunwind sources as we aren't using them anymore. Removed: lldb/trunk/source/Plugins/Process/Utility/LibUnwindRegisterContext.cpp lldb/trunk/source/Plugins/Process/Utility/LibUnwindRegisterContext.h lldb/trunk/source/Plugins/Process/Utility/MacOSXLibunwindCallbacks.cpp lldb/trunk/source/Plugins/Process/Utility/MacOSXLibunwindCallbacks.h lldb/trunk/source/Plugins/Process/Utility/UnwindLibUnwind.cpp lldb/trunk/source/Plugins/Process/Utility/UnwindLibUnwind.h lldb/trunk/source/Plugins/Process/Utility/libunwind/ Modified: lldb/trunk/include/lldb/Target/Thread.h lldb/trunk/lldb.xcodeproj/project.pbxproj lldb/trunk/source/Plugins/Process/MacOSX-User/source/ThreadMacOSX.cpp lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h lldb/trunk/source/Plugins/Process/gdb-remote/ThreadGDBRemote.cpp lldb/trunk/source/Plugins/Process/gdb-remote/ThreadGDBRemote.h Modified: lldb/trunk/include/lldb/Target/Thread.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/Thread.h?rev=122059&r1=122058&r2=122059&view=diff ============================================================================== --- lldb/trunk/include/lldb/Target/Thread.h (original) +++ lldb/trunk/include/lldb/Target/Thread.h Fri Dec 17 09:50:20 2010 @@ -16,7 +16,6 @@ #include "lldb/Core/UserSettingsController.h" #include "lldb/Target/ExecutionContextScope.h" #include "lldb/Target/StackFrameList.h" -#include "libunwind/include/libunwind.h" #define LLDB_THREAD_MAX_STOP_EXC_DATA 8 Modified: lldb/trunk/lldb.xcodeproj/project.pbxproj URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/lldb.xcodeproj/project.pbxproj?rev=122059&r1=122058&r2=122059&view=diff ============================================================================== --- lldb/trunk/lldb.xcodeproj/project.pbxproj (original) +++ lldb/trunk/lldb.xcodeproj/project.pbxproj Fri Dec 17 09:50:20 2010 @@ -282,17 +282,11 @@ 26D5B14B11B07550009A862E /* CommandObjectTarget.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 269416AD119A024800FF2715 /* CommandObjectTarget.cpp */; }; 26D5B14C11B07550009A862E /* PathMappingList.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 495BBACB119A0DBE00418BEA /* PathMappingList.cpp */; }; 26D5B14D11B07550009A862E /* StringExtractorGDBRemote.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2676A093119C93C8008A98EF /* StringExtractorGDBRemote.cpp */; }; - 26D5B14E11B07550009A862E /* MacOSXLibunwindCallbacks.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9654F79C1197DA1300F72B43 /* MacOSXLibunwindCallbacks.cpp */; }; - 26D5B15011B07550009A862E /* Registers.s in Sources */ = {isa = PBXBuildFile; fileRef = 9654F7B51197DA3F00F72B43 /* Registers.s */; }; - 26D5B15111B07550009A862E /* unw_getcontext.s in Sources */ = {isa = PBXBuildFile; fileRef = 9654F7BA1197DA3F00F72B43 /* unw_getcontext.s */; }; - 26D5B15211B07550009A862E /* LibUnwindRegisterContext.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26B4666F11A2091600CF6220 /* LibUnwindRegisterContext.cpp */; }; 26D5B15311B07550009A862E /* ABIMacOSX_i386.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 497650CE11A21BEE008DDB57 /* ABIMacOSX_i386.cpp */; }; 26D5B15511B07550009A862E /* Baton.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26A0604811A5D03C00F75969 /* Baton.cpp */; }; 26D5B15611B07550009A862E /* CommandObjectArgs.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 499F381F11A5B3F300F5CE02 /* CommandObjectArgs.cpp */; }; - 26D5B15911B07550009A862E /* UnwindLibUnwind.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26E3EEBE11A98A1900FBADB6 /* UnwindLibUnwind.cpp */; }; 26D5B15A11B07550009A862E /* UnwindMacOSXFrameBackchain.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26E3EEE311A9901300FBADB6 /* UnwindMacOSXFrameBackchain.cpp */; }; 26D5B15B11B07550009A862E /* RegisterContextMacOSXFrameBackchain.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26E3EEF711A994E800FBADB6 /* RegisterContextMacOSXFrameBackchain.cpp */; }; - 26D5B18E11B07979009A862E /* libuwind.cxx in Sources */ = {isa = PBXBuildFile; fileRef = 9654F7B31197DA3F00F72B43 /* libuwind.cxx */; }; 26DE1E6B11616C2E00A093E2 /* lldb-forward-rtti.h in Headers */ = {isa = PBXBuildFile; fileRef = 26DE1E6911616C2E00A093E2 /* lldb-forward-rtti.h */; settings = {ATTRIBUTES = (Public, ); }; }; 26DE1E6C11616C2E00A093E2 /* lldb-forward.h in Headers */ = {isa = PBXBuildFile; fileRef = 26DE1E6A11616C2E00A093E2 /* lldb-forward.h */; settings = {ATTRIBUTES = (Public, ); }; }; 26DE204111618AB900A093E2 /* SBSymbolContext.h in Headers */ = {isa = PBXBuildFile; fileRef = 26DE204011618AB900A093E2 /* SBSymbolContext.h */; settings = {ATTRIBUTES = (Public, ); }; }; @@ -599,8 +593,6 @@ 26B167A41123BF5500DC7B4F /* ThreadSafeValue.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ThreadSafeValue.h; path = include/lldb/Core/ThreadSafeValue.h; sourceTree = ""; }; 26B42B1E1187A92B0079C8C8 /* lldb-include.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = "lldb-include.h"; path = "include/lldb/lldb-include.h"; sourceTree = ""; }; 26B42C4C1187ABA50079C8C8 /* LLDB.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = LLDB.h; path = include/lldb/API/LLDB.h; sourceTree = ""; }; - 26B4666F11A2091600CF6220 /* LibUnwindRegisterContext.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = LibUnwindRegisterContext.cpp; path = Utility/LibUnwindRegisterContext.cpp; sourceTree = ""; }; - 26B4667011A2091600CF6220 /* LibUnwindRegisterContext.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = LibUnwindRegisterContext.h; path = Utility/LibUnwindRegisterContext.h; sourceTree = ""; }; 26B4E26E112F35F700AB3F64 /* TimeValue.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = TimeValue.h; path = include/lldb/Host/TimeValue.h; sourceTree = ""; }; 26BC7C2510F1B3BC00F91463 /* lldb-defines.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = "lldb-defines.h"; path = "include/lldb/lldb-defines.h"; sourceTree = ""; }; 26BC7C2610F1B3BC00F91463 /* lldb-enumerations.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = "lldb-enumerations.h"; path = "include/lldb/lldb-enumerations.h"; sourceTree = ""; }; @@ -899,8 +891,6 @@ 26DFBC58113B48F300DD817F /* CommandObjectMultiword.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = CommandObjectMultiword.cpp; path = source/Commands/CommandObjectMultiword.cpp; sourceTree = ""; }; 26DFBC59113B48F300DD817F /* CommandObjectRegexCommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = CommandObjectRegexCommand.cpp; path = source/Interpreter/CommandObjectRegexCommand.cpp; sourceTree = ""; }; 26E3EEBD11A9870400FBADB6 /* Unwind.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Unwind.h; path = include/lldb/Target/Unwind.h; sourceTree = ""; }; - 26E3EEBE11A98A1900FBADB6 /* UnwindLibUnwind.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = UnwindLibUnwind.cpp; path = Utility/UnwindLibUnwind.cpp; sourceTree = ""; }; - 26E3EEBF11A98A1900FBADB6 /* UnwindLibUnwind.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = UnwindLibUnwind.h; path = Utility/UnwindLibUnwind.h; sourceTree = ""; }; 26E3EEE311A9901300FBADB6 /* UnwindMacOSXFrameBackchain.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = UnwindMacOSXFrameBackchain.cpp; path = Utility/UnwindMacOSXFrameBackchain.cpp; sourceTree = ""; }; 26E3EEE411A9901300FBADB6 /* UnwindMacOSXFrameBackchain.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = UnwindMacOSXFrameBackchain.h; path = Utility/UnwindMacOSXFrameBackchain.h; sourceTree = ""; }; 26E3EEF711A994E800FBADB6 /* RegisterContextMacOSXFrameBackchain.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = RegisterContextMacOSXFrameBackchain.cpp; path = Utility/RegisterContextMacOSXFrameBackchain.cpp; sourceTree = ""; }; @@ -1024,31 +1014,6 @@ 961FAC18123605A200F93A47 /* ArchDefaultUnwindPlan.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = ArchDefaultUnwindPlan.cpp; path = source/Utility/ArchDefaultUnwindPlan.cpp; sourceTree = ""; }; 961FAC1C12360C7D00F93A47 /* ArchDefaultUnwindPlan-x86.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = "ArchDefaultUnwindPlan-x86.cpp"; path = "Utility/ArchDefaultUnwindPlan-x86.cpp"; sourceTree = ""; }; 961FAC1D12360C7D00F93A47 /* ArchDefaultUnwindPlan-x86.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = "ArchDefaultUnwindPlan-x86.h"; path = "Utility/ArchDefaultUnwindPlan-x86.h"; sourceTree = ""; }; - 9654F79C1197DA1300F72B43 /* MacOSXLibunwindCallbacks.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = MacOSXLibunwindCallbacks.cpp; path = Utility/MacOSXLibunwindCallbacks.cpp; sourceTree = ""; }; - 9654F79D1197DA1300F72B43 /* MacOSXLibunwindCallbacks.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = MacOSXLibunwindCallbacks.h; path = Utility/MacOSXLibunwindCallbacks.h; sourceTree = ""; }; - 9654F7A11197DA3F00F72B43 /* libunwind.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = libunwind.h; sourceTree = ""; }; - 9654F7A31197DA3F00F72B43 /* compact_unwind_encoding.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = compact_unwind_encoding.h; sourceTree = ""; }; - 9654F7A41197DA3F00F72B43 /* unwind.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = unwind.h; sourceTree = ""; }; - 9654F7A61197DA3F00F72B43 /* AddressSpace.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = AddressSpace.hpp; sourceTree = ""; }; - 9654F7A71197DA3F00F72B43 /* ArchDefaultUnwinder.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = ArchDefaultUnwinder.hpp; sourceTree = ""; }; - 9654F7A81197DA3F00F72B43 /* AssemblyInstructions.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = AssemblyInstructions.hpp; sourceTree = ""; }; - 9654F7A91197DA3F00F72B43 /* AssemblyParser.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = AssemblyParser.hpp; sourceTree = ""; }; - 9654F7AA1197DA3F00F72B43 /* CompactUnwinder.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = CompactUnwinder.hpp; sourceTree = ""; }; - 9654F7AB1197DA3F00F72B43 /* dwarf2.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = dwarf2.h; sourceTree = ""; }; - 9654F7AC1197DA3F00F72B43 /* DwarfInstructions.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = DwarfInstructions.hpp; sourceTree = ""; }; - 9654F7AD1197DA3F00F72B43 /* DwarfParser.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = DwarfParser.hpp; sourceTree = ""; }; - 9654F7AE1197DA3F00F72B43 /* FileAbstraction.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = FileAbstraction.hpp; sourceTree = ""; }; - 9654F7AF1197DA3F00F72B43 /* InternalMacros.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = InternalMacros.h; sourceTree = ""; }; - 9654F7B21197DA3F00F72B43 /* libunwind_priv.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = libunwind_priv.h; sourceTree = ""; }; - 9654F7B31197DA3F00F72B43 /* libuwind.cxx */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = libuwind.cxx; sourceTree = ""; }; - 9654F7B41197DA3F00F72B43 /* Registers.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = Registers.hpp; sourceTree = ""; }; - 9654F7B51197DA3F00F72B43 /* Registers.s */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.asm; path = Registers.s; sourceTree = ""; }; - 9654F7B61197DA3F00F72B43 /* RemoteDebuggerDummyUnwinder.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = RemoteDebuggerDummyUnwinder.hpp; sourceTree = ""; }; - 9654F7B71197DA3F00F72B43 /* RemoteProcInfo.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = RemoteProcInfo.hpp; sourceTree = ""; }; - 9654F7B81197DA3F00F72B43 /* RemoteRegisterMap.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = RemoteRegisterMap.hpp; sourceTree = ""; }; - 9654F7B91197DA3F00F72B43 /* RemoteUnwindProfile.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RemoteUnwindProfile.h; sourceTree = ""; }; - 9654F7BA1197DA3F00F72B43 /* unw_getcontext.s */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.asm; path = unw_getcontext.s; sourceTree = ""; }; - 9654F7BD1197DA3F00F72B43 /* UnwindCursor.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = UnwindCursor.hpp; sourceTree = ""; }; 96A6D9C51249D96F00250B38 /* ArchVolatileRegs.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = ArchVolatileRegs.cpp; path = source/Utility/ArchVolatileRegs.cpp; sourceTree = ""; }; 96A6D9C71249D98800250B38 /* ArchVolatileRegs-x86.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = "ArchVolatileRegs-x86.cpp"; path = "Utility/ArchVolatileRegs-x86.cpp"; sourceTree = ""; }; 96A6D9C81249D98800250B38 /* ArchVolatileRegs-x86.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = "ArchVolatileRegs-x86.h"; path = "Utility/ArchVolatileRegs-x86.h"; sourceTree = ""; }; @@ -1639,17 +1604,10 @@ 961FAC1D12360C7D00F93A47 /* ArchDefaultUnwindPlan-x86.h */, 961FABE81235F26800F93A47 /* UnwindAssemblyProfiler-x86.cpp */, 961FABE91235F26800F93A47 /* UnwindAssemblyProfiler-x86.h */, - 9654F79F1197DA3F00F72B43 /* libunwind */, - 26B4667011A2091600CF6220 /* LibUnwindRegisterContext.h */, - 26B4666F11A2091600CF6220 /* LibUnwindRegisterContext.cpp */, - 9654F79D1197DA1300F72B43 /* MacOSXLibunwindCallbacks.h */, - 9654F79C1197DA1300F72B43 /* MacOSXLibunwindCallbacks.cpp */, 26E3EEF811A994E800FBADB6 /* RegisterContextMacOSXFrameBackchain.h */, 26E3EEF711A994E800FBADB6 /* RegisterContextMacOSXFrameBackchain.cpp */, 2615DBC91208B5FC0021781D /* StopInfoMachException.h */, 2615DBC81208B5FC0021781D /* StopInfoMachException.cpp */, - 26E3EEBF11A98A1900FBADB6 /* UnwindLibUnwind.h */, - 26E3EEBE11A98A1900FBADB6 /* UnwindLibUnwind.cpp */, 26E3EEE411A9901300FBADB6 /* UnwindMacOSXFrameBackchain.h */, 26E3EEE311A9901300FBADB6 /* UnwindMacOSXFrameBackchain.cpp */, ); @@ -2274,61 +2232,6 @@ path = source/Host/common; sourceTree = ""; }; - 9654F79F1197DA3F00F72B43 /* libunwind */ = { - isa = PBXGroup; - children = ( - 9654F7A01197DA3F00F72B43 /* include */, - 9654F7A51197DA3F00F72B43 /* src */, - ); - name = libunwind; - path = Utility/libunwind; - sourceTree = ""; - }; - 9654F7A01197DA3F00F72B43 /* include */ = { - isa = PBXGroup; - children = ( - 9654F7A11197DA3F00F72B43 /* libunwind.h */, - 9654F7A21197DA3F00F72B43 /* mach-o */, - 9654F7A41197DA3F00F72B43 /* unwind.h */, - ); - path = include; - sourceTree = ""; - }; - 9654F7A21197DA3F00F72B43 /* mach-o */ = { - isa = PBXGroup; - children = ( - 9654F7A31197DA3F00F72B43 /* compact_unwind_encoding.h */, - ); - path = "mach-o"; - sourceTree = ""; - }; - 9654F7A51197DA3F00F72B43 /* src */ = { - isa = PBXGroup; - children = ( - 9654F7A61197DA3F00F72B43 /* AddressSpace.hpp */, - 9654F7A71197DA3F00F72B43 /* ArchDefaultUnwinder.hpp */, - 9654F7A81197DA3F00F72B43 /* AssemblyInstructions.hpp */, - 9654F7A91197DA3F00F72B43 /* AssemblyParser.hpp */, - 9654F7AA1197DA3F00F72B43 /* CompactUnwinder.hpp */, - 9654F7AB1197DA3F00F72B43 /* dwarf2.h */, - 9654F7AC1197DA3F00F72B43 /* DwarfInstructions.hpp */, - 9654F7AD1197DA3F00F72B43 /* DwarfParser.hpp */, - 9654F7AE1197DA3F00F72B43 /* FileAbstraction.hpp */, - 9654F7AF1197DA3F00F72B43 /* InternalMacros.h */, - 9654F7B21197DA3F00F72B43 /* libunwind_priv.h */, - 9654F7B31197DA3F00F72B43 /* libuwind.cxx */, - 9654F7B41197DA3F00F72B43 /* Registers.hpp */, - 9654F7B51197DA3F00F72B43 /* Registers.s */, - 9654F7B61197DA3F00F72B43 /* RemoteDebuggerDummyUnwinder.hpp */, - 9654F7B71197DA3F00F72B43 /* RemoteProcInfo.hpp */, - 9654F7B81197DA3F00F72B43 /* RemoteRegisterMap.hpp */, - 9654F7B91197DA3F00F72B43 /* RemoteUnwindProfile.h */, - 9654F7BA1197DA3F00F72B43 /* unw_getcontext.s */, - 9654F7BD1197DA3F00F72B43 /* UnwindCursor.hpp */, - ); - path = src; - sourceTree = ""; - }; /* End PBXGroup section */ /* Begin PBXHeadersBuildPhase section */ @@ -2791,14 +2694,9 @@ 26D5B14B11B07550009A862E /* CommandObjectTarget.cpp in Sources */, 26D5B14C11B07550009A862E /* PathMappingList.cpp in Sources */, 26D5B14D11B07550009A862E /* StringExtractorGDBRemote.cpp in Sources */, - 26D5B14E11B07550009A862E /* MacOSXLibunwindCallbacks.cpp in Sources */, - 26D5B15011B07550009A862E /* Registers.s in Sources */, - 26D5B15111B07550009A862E /* unw_getcontext.s in Sources */, - 26D5B15211B07550009A862E /* LibUnwindRegisterContext.cpp in Sources */, 26D5B15311B07550009A862E /* ABIMacOSX_i386.cpp in Sources */, 26D5B15511B07550009A862E /* Baton.cpp in Sources */, 26D5B15611B07550009A862E /* CommandObjectArgs.cpp in Sources */, - 26D5B15911B07550009A862E /* UnwindLibUnwind.cpp in Sources */, 26D5B15A11B07550009A862E /* UnwindMacOSXFrameBackchain.cpp in Sources */, 26D5B15B11B07550009A862E /* RegisterContextMacOSXFrameBackchain.cpp in Sources */, 26680324116005D9008E1FE4 /* SBThread.cpp in Sources */, @@ -2833,7 +2731,6 @@ 9AC703AF117675410086C050 /* SBInstruction.cpp in Sources */, 9AC703B1117675490086C050 /* SBInstructionList.cpp in Sources */, 9AA69DB1118A024600D753A0 /* SBInputReader.cpp in Sources */, - 26D5B18E11B07979009A862E /* libuwind.cxx in Sources */, 49F1A74611B3388F003ED505 /* ClangExpressionDeclMap.cpp in Sources */, 49D7072911B5AD11001AD875 /* ClangASTSource.cpp in Sources */, 4CA9637B11B6E99A00780E28 /* CommandObjectApropos.cpp in Sources */, Modified: lldb/trunk/source/Plugins/Process/MacOSX-User/source/ThreadMacOSX.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/MacOSX-User/source/ThreadMacOSX.cpp?rev=122059&r1=122058&r2=122059&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Process/MacOSX-User/source/ThreadMacOSX.cpp (original) +++ lldb/trunk/source/Plugins/Process/MacOSX-User/source/ThreadMacOSX.cpp Fri Dec 17 09:50:20 2010 @@ -23,8 +23,6 @@ #include "lldb/Breakpoint/WatchpointLocation.h" #include "lldb/Core/StreamString.h" #include "lldb/Target/Unwind.h" -#include "LibUnwindRegisterContext.h" -#include "UnwindLibUnwind.h" #include "UnwindMacOSXFrameBackchain.h" using namespace lldb; Removed: lldb/trunk/source/Plugins/Process/Utility/LibUnwindRegisterContext.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Utility/LibUnwindRegisterContext.cpp?rev=122058&view=auto ============================================================================== --- lldb/trunk/source/Plugins/Process/Utility/LibUnwindRegisterContext.cpp (original) +++ lldb/trunk/source/Plugins/Process/Utility/LibUnwindRegisterContext.cpp (removed) @@ -1,336 +0,0 @@ -//===-- LibUnwindRegisterContext.cpp ----------------------------*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -#include "LibUnwindRegisterContext.h" - -// C Includes -// C++ Includes -// Other libraries and framework includes -#include "lldb/Core/DataBufferHeap.h" -#include "lldb/Core/DataExtractor.h" -#include "lldb/Target/Thread.h" -// Project includes - -using namespace lldb; -using namespace lldb_private; - -//---------------------------------------------------------------------- -// LibUnwindRegisterContext constructor -//---------------------------------------------------------------------- -LibUnwindRegisterContext::LibUnwindRegisterContext -( - Thread &thread, - StackFrame *frame, - const lldb_private::unw_cursor_t& unwind_cursor -) : - RegisterContext (thread, frame), - m_unwind_cursor (unwind_cursor), - m_unwind_cursor_is_valid (true) -{ -} - -//---------------------------------------------------------------------- -// Destructor -//---------------------------------------------------------------------- -LibUnwindRegisterContext::~LibUnwindRegisterContext() -{ -} - -void -LibUnwindRegisterContext::Invalidate () -{ - m_unwind_cursor_is_valid = false; -} - -size_t -LibUnwindRegisterContext::GetRegisterCount () -{ - return m_thread.GetRegisterContext()->GetRegisterCount(); -} - -const lldb::RegisterInfo * -LibUnwindRegisterContext::GetRegisterInfoAtIndex (uint32_t reg) -{ - return m_thread.GetRegisterContext()->GetRegisterInfoAtIndex(reg); -} - -size_t -LibUnwindRegisterContext::GetRegisterSetCount () -{ - return m_thread.GetRegisterContext()->GetRegisterSetCount(); -} - - - -const lldb::RegisterSet * -LibUnwindRegisterContext::GetRegisterSet (uint32_t reg_set) -{ - return m_thread.GetRegisterContext()->GetRegisterSet (reg_set); -} - - - -bool -LibUnwindRegisterContext::ReadRegisterValue (uint32_t reg, Scalar &value) -{ - if (m_unwind_cursor_is_valid == false) - return false; - - // Read the register - unw_word_t reg_value; - if (unw_get_reg (&m_unwind_cursor, reg, ®_value) != UNW_ESUCCESS) - return false; - - const RegisterInfo *reg_info = GetRegisterInfoAtIndex (reg); - switch (reg_info->encoding) - { - case eEncodingUint: - switch (reg_info->byte_size) - { - case 1: - case 2: - case 4: - value = (uint32_t)reg_value; - return true; - - case 8: - value = (uint64_t)reg_value; - return true; - } - break; - - case eEncodingSint: - switch (reg_info->byte_size) - { - case 1: - case 2: - case 4: - value = (int32_t)reg_value; - return true; - - case 8: - value = (int64_t)reg_value; - return true; - } - break; - - case eEncodingIEEE754: - if (reg_info->byte_size > sizeof(unw_word_t)) - return false; - - switch (reg_info->byte_size) - { - case sizeof (float): - if (sizeof (float) == sizeof(uint32_t)) - { - value = (uint32_t)reg_value; - return true; - } - else if (sizeof (float) == sizeof(uint64_t)) - { - value = (uint64_t)reg_value; - return true; - } - break; - - case sizeof (double): - if (sizeof (double) == sizeof(uint32_t)) - { - value = (uint32_t)reg_value; - return true; - } - else if (sizeof (double) == sizeof(uint64_t)) - { - value = (uint64_t)reg_value; - return true; - } - break; - - case sizeof (long double): - if (sizeof (long double) == sizeof(uint32_t)) - { - value = (uint32_t)reg_value; - return true; - } - else if (sizeof (long double) == sizeof(uint64_t)) - { - value = (uint64_t)reg_value; - return true; - } - break; - } - break; - - default: - break; - } - return false; -} - - -bool -LibUnwindRegisterContext::ReadRegisterBytes (uint32_t reg, DataExtractor &data) -{ - Scalar reg_value; - - if (ReadRegisterValue (reg, reg_value)) - { - if (reg_value.GetData(data)) - { - // "reg_value" is local and now "data" points to the data within - // "reg_value", so we must make a copy that will live within "data" - DataBufferSP data_sp (new DataBufferHeap (data.GetDataStart(), data.GetByteSize())); - data.SetData (data_sp, 0, data.GetByteSize()); - return true; - } - } - return false; -} - - -bool -LibUnwindRegisterContext::WriteRegisterValue (uint32_t reg, const Scalar &value) -{ - const RegisterInfo *reg_info = GetRegisterInfoAtIndex (reg); - if (reg_info == NULL) - return false; - unw_word_t reg_value = 0; - switch (value.GetType()) - { - case Scalar::e_void: - return false; - - case Scalar::e_sint: reg_value = value.SInt(); break; - case Scalar::e_uint: reg_value = value.UInt(); break; - case Scalar::e_slong: reg_value = value.SLong(); break; - case Scalar::e_ulong: reg_value = value.ULong(); break; - case Scalar::e_slonglong: reg_value = value.SLongLong(); break; - case Scalar::e_ulonglong: reg_value = value.ULongLong(); break; - case Scalar::e_float: - if (sizeof (float) == sizeof (unsigned int)) - reg_value = value.UInt(); - else if (sizeof (float) == sizeof (unsigned long)) - reg_value = value.ULong(); - else if (sizeof (float) == sizeof (unsigned long long)) - reg_value = value.ULongLong(); - else - return false; - break; - - case Scalar::e_double: - if (sizeof (double) == sizeof (unsigned int)) - reg_value = value.UInt(); - else if (sizeof (double) == sizeof (unsigned long)) - reg_value = value.ULong(); - else if (sizeof (double) == sizeof (unsigned long long)) - reg_value = value.ULongLong(); - else - return false; - break; - - case Scalar::e_long_double: - if (sizeof (long double) == sizeof (unsigned int)) - reg_value = value.UInt(); - else if (sizeof (long double) == sizeof (unsigned long)) - reg_value = value.ULong(); - else if (sizeof (long double) == sizeof (unsigned long long)) - reg_value = value.ULongLong(); - else - return false; - break; - } - - return unw_set_reg (&m_unwind_cursor, reg, reg_value) == UNW_ESUCCESS; -} - - -bool -LibUnwindRegisterContext::WriteRegisterBytes (uint32_t reg, DataExtractor &data, uint32_t data_offset) -{ - const RegisterInfo *reg_info = GetRegisterInfoAtIndex (reg); - - if (reg_info == NULL) - return false; - if (reg_info->byte_size > sizeof (unw_word_t)) - return false; - - Scalar value; - uint32_t offset = data_offset; - - switch (reg_info->encoding) - { - case eEncodingUint: - if (reg_info->byte_size <= 4) - value = data.GetMaxU32 (&offset, reg_info->byte_size); - else if (reg_info->byte_size <= 8) - value = data.GetMaxU64 (&offset, reg_info->byte_size); - else - return false; - break; - - case eEncodingSint: - if (reg_info->byte_size <= 4) - value = (int32_t)data.GetMaxU32 (&offset, reg_info->byte_size); - else if (reg_info->byte_size <= 8) - value = data.GetMaxS64 (&offset, reg_info->byte_size); - else - return false; - break; - - case eEncodingIEEE754: - switch (reg_info->byte_size) - { - case sizeof (float): - value = data.GetFloat (&offset); - break; - - case sizeof (double): - value = data.GetDouble (&offset); - break; - - case sizeof (long double): - value = data.GetLongDouble (&offset); - break; - default: - return false; - } - - default: - return false; - } - return WriteRegisterValue (reg, value); -} - - -bool -LibUnwindRegisterContext::ReadAllRegisterValues (lldb::DataBufferSP &data_sp) -{ - // libunwind frames can't handle this it doesn't always have all register - // values. This call should only be called on frame zero anyway so there - // shouldn't be any problem - return false; -} - -bool -LibUnwindRegisterContext::WriteAllRegisterValues (const lldb::DataBufferSP &data_sp) -{ - // Since this class doesn't respond to "ReadAllRegisterValues()", it must - // not have been the one that saved all the register values. So we just let - // the thread's register context (the register context for frame zero) do - // the writing. - return m_thread.GetRegisterContext()->WriteAllRegisterValues(data_sp); -} - - -uint32_t -LibUnwindRegisterContext::ConvertRegisterKindToRegisterNumber (uint32_t kind, uint32_t num) -{ - return m_thread.GetRegisterContext()->ConvertRegisterKindToRegisterNumber (kind, num); -} - Removed: lldb/trunk/source/Plugins/Process/Utility/LibUnwindRegisterContext.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Utility/LibUnwindRegisterContext.h?rev=122058&view=auto ============================================================================== --- lldb/trunk/source/Plugins/Process/Utility/LibUnwindRegisterContext.h (original) +++ lldb/trunk/source/Plugins/Process/Utility/LibUnwindRegisterContext.h (removed) @@ -1,83 +0,0 @@ -//===-- LibUnwindRegisterContext.h ------------------------------*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -#ifndef lldb_LibUnwindRegisterContext_h_ -#define lldb_LibUnwindRegisterContext_h_ - -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes -#include "lldb/lldb-private.h" -#include "lldb/Target/RegisterContext.h" - -#include "libunwind/include/libunwind.h" - -class LibUnwindRegisterContext : public lldb_private::RegisterContext -{ -public: - //------------------------------------------------------------------ - // Constructors and Destructors - //------------------------------------------------------------------ - LibUnwindRegisterContext (lldb_private::Thread &thread, - lldb_private::StackFrame *frame, - const lldb_private::unw_cursor_t &unwind_cursor); - - virtual - ~LibUnwindRegisterContext (); - - //------------------------------------------------------------------ - // Subclasses must override these functions - //------------------------------------------------------------------ - virtual void - Invalidate (); - - virtual size_t - GetRegisterCount (); - - virtual const lldb::RegisterInfo * - GetRegisterInfoAtIndex (uint32_t reg); - - virtual size_t - GetRegisterSetCount (); - - virtual const lldb::RegisterSet * - GetRegisterSet (uint32_t reg_set); - - virtual bool - ReadRegisterValue (uint32_t reg, lldb_private::Scalar &value); - - virtual bool - ReadRegisterBytes (uint32_t reg, lldb_private::DataExtractor &data); - - virtual bool - ReadAllRegisterValues (lldb::DataBufferSP &data_sp); - - virtual bool - WriteRegisterValue (uint32_t reg, const lldb_private::Scalar &value); - - virtual bool - WriteRegisterBytes (uint32_t reg, lldb_private::DataExtractor &data, uint32_t data_offset); - - virtual bool - WriteAllRegisterValues (const lldb::DataBufferSP &data_sp); - - virtual uint32_t - ConvertRegisterKindToRegisterNumber (uint32_t kind, uint32_t num); - -private: - lldb_private::unw_cursor_t m_unwind_cursor; - bool m_unwind_cursor_is_valid; - //------------------------------------------------------------------ - // For LibUnwindRegisterContext only - //------------------------------------------------------------------ - DISALLOW_COPY_AND_ASSIGN (LibUnwindRegisterContext); -}; - -#endif // lldb_LibUnwindRegisterContext_h_ Removed: lldb/trunk/source/Plugins/Process/Utility/MacOSXLibunwindCallbacks.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Utility/MacOSXLibunwindCallbacks.cpp?rev=122058&view=auto ============================================================================== --- lldb/trunk/source/Plugins/Process/Utility/MacOSXLibunwindCallbacks.cpp (original) +++ lldb/trunk/source/Plugins/Process/Utility/MacOSXLibunwindCallbacks.cpp (removed) @@ -1,320 +0,0 @@ -//===-- MacOSXLibunwindCallbacks.cpp ----------------------------*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -#ifndef liblldb_MacOSXLibunwindCallbacks_cpp_ -#define liblldb_MacOSXLibunwindCallbacks_cpp_ -#if defined(__cplusplus) - -#include "lldb/Core/DataExtractor.h" -#include "lldb/Core/FileSpec.h" -#include "lldb/Core/DataBufferHeap.h" -#include "lldb/Symbol/ObjectFile.h" -#include "lldb/Symbol/SymbolContext.h" -#include "lldb/Target/Process.h" -#include "lldb/Target/RegisterContext.h" -#include "lldb/Target/Target.h" -#include "lldb/Target/Thread.h" - -#include "lldb/lldb-enumerations.h" -#include "llvm-c/EnhancedDisassembly.h" - -#include "libunwind/include/libunwind.h" - -using namespace lldb; - -namespace lldb_private { - -/* Don't implement (libunwind does not use) - find_proc_info - put_unwind_info - get_dyn_info_list_addr - access_mem - resume -*/ -/* - Should implement (not needed yet) - access_fpreg - access_vecreg - proc_is_sigtramp - proc_is_inferior_function_call - access_reg_inf_func_call -*/ - -static int -access_reg (lldb_private::unw_addr_space_t as, lldb_private::unw_regnum_t regnum, lldb_private::unw_word_t *valp, int write, void *arg) -{ - if (arg == 0) - return -1; - Thread *th = (Thread *) arg; - /* FIXME Only support reading for now. */ - if (write == 1) - return -1; - if (th->GetRegisterContext()->GetRegisterInfoAtIndex(regnum) == NULL) - return -1; - DataExtractor de; - if (!th->GetRegisterContext()->ReadRegisterBytes (regnum, de)) - return -1; - memcpy (valp, de.GetDataStart(), de.GetByteSize()); - return UNW_ESUCCESS; -} - -static int -get_proc_name (lldb_private::unw_addr_space_t as, lldb_private::unw_word_t ip, char *bufp, size_t buf_len, lldb_private::unw_word_t *offp, void *arg) -{ - if (arg == 0) - return -1; - Thread *thread = (Thread *) arg; - Target &target = thread->GetProcess().GetTarget(); - Address addr; - if (!target.GetSectionLoadList().ResolveLoadAddress(ip, addr)) - return -1; - - SymbolContext sc; - if (!target.GetImages().ResolveSymbolContextForAddress (addr, eSymbolContextFunction, sc)) - return -1; - if (!sc.symbol) - return -1; - strlcpy (bufp, sc.symbol->GetMangled().GetMangledName().AsCString(""), buf_len); - if (offp) - *offp = addr.GetLoadAddress(&target) - sc.symbol->GetValue().GetLoadAddress(&target); - return UNW_ESUCCESS; -} - -static int -find_image_info (lldb_private::unw_addr_space_t as, lldb_private::unw_word_t load_addr, lldb_private::unw_word_t *mh, - lldb_private::unw_word_t *text_start, lldb_private::unw_word_t *text_end, - lldb_private::unw_word_t *eh_frame, lldb_private::unw_word_t *eh_frame_len, - lldb_private::unw_word_t *compact_unwind_start, lldb_private::unw_word_t *compact_unwind_len, void *arg) -{ - if (arg == 0) - return -1; - Thread *thread = (Thread *) arg; - Target &target = thread->GetProcess().GetTarget(); - Address addr; - if (!target.GetSectionLoadList().ResolveLoadAddress(load_addr, addr)) - return -1; - - SymbolContext sc; - if (!target.GetImages().ResolveSymbolContextForAddress (addr, eSymbolContextModule, sc)) - return -1; - - SectionList *sl = sc.module_sp->GetObjectFile()->GetSectionList(); - static ConstString g_segment_name_TEXT("__TEXT"); - SectionSP text_segment_sp(sl->FindSectionByName(g_segment_name_TEXT)); - if (!text_segment_sp) - return -1; - - *mh = text_segment_sp->GetLoadBaseAddress (&target); - *text_start = text_segment_sp->GetLoadBaseAddress (&target); - *text_end = *text_start + text_segment_sp->GetByteSize(); - - static ConstString g_section_name_eh_frame ("__eh_frame"); - SectionSP eh_frame_section_sp = text_segment_sp->GetChildren().FindSectionByName(g_section_name_eh_frame); - if (eh_frame_section_sp.get()) { - *eh_frame = eh_frame_section_sp->GetLoadBaseAddress (&target); - *eh_frame_len = eh_frame_section_sp->GetByteSize(); - } else { - *eh_frame = 0; - *eh_frame_len = 0; - } - - static ConstString g_section_name_unwind_info ("__unwind_info"); - SectionSP unwind_info_section_sp = text_segment_sp->GetChildren().FindSectionByName(g_section_name_unwind_info); - if (unwind_info_section_sp.get()) { - *compact_unwind_start = unwind_info_section_sp->GetLoadBaseAddress (&target); - *compact_unwind_len = unwind_info_section_sp->GetByteSize(); - } else { - *compact_unwind_start = 0; - *compact_unwind_len = 0; - } - return UNW_ESUCCESS; -} - -static int -get_proc_bounds (lldb_private::unw_addr_space_t as, lldb_private::unw_word_t ip, lldb_private::unw_word_t *low, lldb_private::unw_word_t *high, void *arg) -{ - if (arg == 0) - return -1; - Thread *thread = (Thread *) arg; - Target &target = thread->GetProcess().GetTarget(); - Address addr; - if (!target.GetSectionLoadList().ResolveLoadAddress(ip, addr)) - return -1; - SymbolContext sc; - if (!target.GetImages().ResolveSymbolContextForAddress (addr, eSymbolContextFunction | eSymbolContextSymbol, sc)) - return -1; - if (sc.function) - { - lldb::addr_t start, len; - start = sc.function->GetAddressRange().GetBaseAddress().GetLoadAddress(&target); - len = sc.function->GetAddressRange().GetByteSize(); - if (start == LLDB_INVALID_ADDRESS || len == LLDB_INVALID_ADDRESS) - return -1; - *low = start; - *high = start + len; - return UNW_ESUCCESS; - } - if (sc.symbol) - { - lldb::addr_t start, len; - start = sc.symbol->GetAddressRangeRef().GetBaseAddress().GetLoadAddress(&target); - len = sc.symbol->GetAddressRangeRef().GetByteSize(); - if (start == LLDB_INVALID_ADDRESS) - return -1; - *low = start; - if (len != LLDB_INVALID_ADDRESS) - *high = start + len; - else - *high = 0; - return UNW_ESUCCESS; - } - return -1; -} - -static int -access_raw (lldb_private::unw_addr_space_t as, lldb_private::unw_word_t addr, lldb_private::unw_word_t extent, uint8_t *valp, int write, void *arg) -{ - if (arg == 0) - return -1; - Thread *th = (Thread *) arg; - /* FIXME Only support reading for now. */ - if (write == 1) - return -1; - - Error error; - if (th->GetProcess().ReadMemory (addr, valp, extent, error) != extent) - return -1; - return UNW_ESUCCESS; -} - - -static int -reg_info -( - lldb_private::unw_addr_space_t as, - lldb_private::unw_regnum_t regnum, - lldb_private::unw_regtype_t *type, - char *buf, - size_t buflen, - void *arg -) -{ - if (arg == 0) - return -1; - Thread *th = (Thread *) arg; - RegisterContext *regc = th->GetRegisterContext(); - if (regnum > regc->GetRegisterCount()) - { - *type = UNW_NOT_A_REG; - return UNW_ESUCCESS; - } - - const char *name = regc->GetRegisterName (regnum); - if (name == NULL) - { - *type = UNW_NOT_A_REG; - return UNW_ESUCCESS; - } - strlcpy (buf, name, buflen); - - const lldb::RegisterInfo *reginfo = regc->GetRegisterInfoAtIndex (regnum); - if (reginfo == NULL || reginfo->encoding == eEncodingInvalid) - { - *type = UNW_NOT_A_REG; - return UNW_ESUCCESS; - } - if (reginfo->encoding == eEncodingUint || reginfo->encoding == eEncodingSint) - *type = UNW_INTEGER_REG; - if (reginfo->encoding == eEncodingIEEE754) - *type = UNW_FLOATING_POINT_REG; - if (reginfo->encoding == eEncodingVector) - *type = UNW_VECTOR_REG; - - return UNW_ESUCCESS; -} - - -static int -read_byte_for_edis (uint8_t *buf, uint64_t addr, void *arg) -{ - if (arg == 0) - return -1; - Thread *th = (Thread *) arg; - DataBufferHeap onebyte(1, 0); - Error error; - if (th->GetProcess().ReadMemory (addr, onebyte.GetBytes(), onebyte.GetByteSize(), error) != 1) - return -1; - *buf = onebyte.GetBytes()[0]; - return UNW_ESUCCESS; -} - -static int -instruction_length (lldb_private::unw_addr_space_t as, lldb_private::unw_word_t addr, int *length, void *arg) -{ - EDDisassemblerRef disasm; - EDInstRef cur_insn; - - if (arg == 0) - return -1; - Thread *thread = (Thread *) arg; - Target &target = thread->GetProcess().GetTarget(); - - const ArchSpec::CPU arch_cpu = target.GetArchitecture ().GetGenericCPUType(); - - if (arch_cpu == ArchSpec::eCPU_i386) - { - if (EDGetDisassembler (&disasm, "i386-apple-darwin", kEDAssemblySyntaxX86ATT) != 0) - return -1; - } - else if (arch_cpu == ArchSpec::eCPU_x86_64) - { - if (EDGetDisassembler (&disasm, "x86_64-apple-darwin", kEDAssemblySyntaxX86ATT) != 0) - return -1; - } - else - { - return -1; - } - - if (EDCreateInsts (&cur_insn, 1, disasm, read_byte_for_edis, addr, arg) != 1) - return -1; - *length = EDInstByteSize (cur_insn); - EDReleaseInst (cur_insn); - return UNW_ESUCCESS; -} - -lldb_private::unw_accessors_t -get_macosx_libunwind_callbacks () { - lldb_private::unw_accessors_t ap; - bzero (&ap, sizeof (lldb_private::unw_accessors_t)); - ap.find_proc_info = NULL; - ap.put_unwind_info = NULL; - ap.get_dyn_info_list_addr = NULL; - ap.find_image_info = find_image_info; - ap.access_mem = NULL; - ap.access_reg = access_reg; - ap.access_fpreg = NULL; - ap.access_vecreg = NULL; - ap.resume = NULL; - ap.get_proc_name = get_proc_name; - ap.get_proc_bounds = get_proc_bounds; - ap.access_raw = access_raw; - ap.reg_info = reg_info; - ap.proc_is_sigtramp = NULL; - ap.proc_is_inferior_function_call = NULL; - ap.access_reg_inf_func_call = NULL; - ap.instruction_length = instruction_length; - return ap; -} - - -} // namespace lldb_private - -#endif // #if defined(__cplusplus) -#endif // #ifndef liblldb_MacOSXLibunwindCallbacks_cpp_ Removed: lldb/trunk/source/Plugins/Process/Utility/MacOSXLibunwindCallbacks.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Utility/MacOSXLibunwindCallbacks.h?rev=122058&view=auto ============================================================================== --- lldb/trunk/source/Plugins/Process/Utility/MacOSXLibunwindCallbacks.h (original) +++ lldb/trunk/source/Plugins/Process/Utility/MacOSXLibunwindCallbacks.h (removed) @@ -1,22 +0,0 @@ -//===-- MacOSXLibunwindCallbacks.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_MacOSXLibunwindCallbacks_h_ -#define liblldb_MacOSXLibunwindCallbacks_h_ -#if defined(__cplusplus) - -namespace lldb_private { - -unw_accessors_t get_macosx_libunwind_callbacks (); - -} // namespace lldb_utility - -#endif // #if defined(__cplusplus) -#endif // #ifndef liblldb_MacOSXLibunwindCallbacks_h_ - Removed: lldb/trunk/source/Plugins/Process/Utility/UnwindLibUnwind.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Utility/UnwindLibUnwind.cpp?rev=122058&view=auto ============================================================================== --- lldb/trunk/source/Plugins/Process/Utility/UnwindLibUnwind.cpp (original) +++ lldb/trunk/source/Plugins/Process/Utility/UnwindLibUnwind.cpp (removed) @@ -1,73 +0,0 @@ -//===-- UnwindLibUnwind.cpp -------------------------------------*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes -#include "lldb/Target/Thread.h" -#include "UnwindLibUnwind.h" -#include "LibUnwindRegisterContext.h" - -using namespace lldb; -using namespace lldb_private; - -UnwindLibUnwind::UnwindLibUnwind (Thread &thread, unw_addr_space_t addr_space) : - Unwind (thread), - m_addr_space (addr_space), - m_cursors() -{ - m_pc_regnum = thread.GetRegisterContext()->ConvertRegisterKindToRegisterNumber (eRegisterKindGeneric, LLDB_REGNUM_GENERIC_PC); - m_sp_regnum = thread.GetRegisterContext()->ConvertRegisterKindToRegisterNumber (eRegisterKindGeneric, LLDB_REGNUM_GENERIC_SP); -} - -uint32_t -UnwindLibUnwind::GetFrameCount() -{ - if (m_cursors.empty()) - { - unw_cursor_t cursor; - unw_init_remote (&cursor, m_addr_space, &m_thread); - - m_cursors.push_back (cursor); - - while (1) - { - int stepresult = unw_step (&cursor); - if (stepresult > 0) - m_cursors.push_back (cursor); - else - break; - } - } - return m_cursors.size(); -} - -bool -UnwindLibUnwind::GetFrameInfoAtIndex (uint32_t idx, addr_t& cfa, addr_t& pc) -{ - const uint32_t frame_count = GetFrameCount(); - if (idx < frame_count) - { - int pc_err = unw_get_reg (&m_cursors[idx], m_pc_regnum, &pc); - int sp_err = unw_get_reg (&m_cursors[idx], m_sp_regnum, &cfa); - return pc_err == UNW_ESUCCESS && sp_err == UNW_ESUCCESS; - } - return false; -} - -RegisterContext * -UnwindLibUnwind::CreateRegisterContextForFrame (StackFrame *frame) -{ - uint32_t idx = frame->GetUnwindFrameIndex (); - const uint32_t frame_count = GetFrameCount(); - if (idx < frame_count) - return new LibUnwindRegisterContext (m_thread, frame, m_cursors[idx]); - return NULL; -} Removed: lldb/trunk/source/Plugins/Process/Utility/UnwindLibUnwind.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Utility/UnwindLibUnwind.h?rev=122058&view=auto ============================================================================== --- lldb/trunk/source/Plugins/Process/Utility/UnwindLibUnwind.h (original) +++ lldb/trunk/source/Plugins/Process/Utility/UnwindLibUnwind.h (removed) @@ -1,66 +0,0 @@ -//===-- UnwindLibUnwind.h ---------------------------------------*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -#ifndef lldb_UnwindLibUnwind_h_ -#define lldb_UnwindLibUnwind_h_ - -// C Includes -// C++ Includes -#include - -// Other libraries and framework includes -#include "libunwind/include/libunwind.h" - -// Project includes -#include "lldb/lldb-private.h" -#include "lldb/Target/Unwind.h" - -class UnwindLibUnwind : public lldb_private::Unwind -{ -public: - UnwindLibUnwind (lldb_private::Thread &thread, - lldb_private::unw_addr_space_t addr_space); - - virtual - ~UnwindLibUnwind() - { - } - - virtual void - Clear() - { - m_cursors.clear(); - } - - virtual uint32_t - GetFrameCount(); - - bool - GetFrameInfoAtIndex (uint32_t frame_idx, - lldb::addr_t& cfa, - lldb::addr_t& pc); - - lldb_private::RegisterContext * - CreateRegisterContextForFrame (lldb_private::StackFrame *frame); - - lldb_private::Thread & - GetThread(); - -private: - lldb_private::unw_addr_space_t m_addr_space; - std::vector m_cursors; - uint32_t m_pc_regnum; - uint32_t m_sp_regnum; - //------------------------------------------------------------------ - // For UnwindLibUnwind only - //------------------------------------------------------------------ - DISALLOW_COPY_AND_ASSIGN (UnwindLibUnwind); -}; - -#endif // lldb_UnwindLibUnwind_h_ Modified: lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp?rev=122059&r1=122058&r2=122059&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp (original) +++ lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp Fri Dec 17 09:50:20 2010 @@ -45,7 +45,6 @@ #include "ProcessGDBRemote.h" #include "ProcessGDBRemoteLog.h" #include "ThreadGDBRemote.h" -#include "MacOSXLibunwindCallbacks.h" #include "StopInfoMachException.h" @@ -119,8 +118,6 @@ m_dispatch_queue_offsets_addr (LLDB_INVALID_ADDRESS), m_packet_timeout (1), m_max_memory_size (512), - m_libunwind_target_type (UNW_TARGET_UNSPECIFIED), - m_libunwind_addr_space (NULL), m_waiting_for_attach (false), m_local_debugserver (true) { @@ -1615,7 +1612,6 @@ Mutex::Locker locker(m_stdio_mutex); m_stdout_data.clear(); } - DestoryLibUnwindAddressSpace(); } Error @@ -2170,45 +2166,6 @@ return NULL; } -lldb_private::unw_addr_space_t -ProcessGDBRemote::GetLibUnwindAddressSpace () -{ - unw_targettype_t target_type = UNW_TARGET_UNSPECIFIED; - - ArchSpec::CPU arch_cpu = m_target.GetArchitecture().GetGenericCPUType(); - if (arch_cpu == ArchSpec::eCPU_i386) - target_type = UNW_TARGET_I386; - else if (arch_cpu == ArchSpec::eCPU_x86_64) - target_type = UNW_TARGET_X86_64; - - if (m_libunwind_addr_space) - { - if (m_libunwind_target_type != target_type) - DestoryLibUnwindAddressSpace(); - else - return m_libunwind_addr_space; - } - unw_accessors_t callbacks = get_macosx_libunwind_callbacks (); - m_libunwind_addr_space = unw_create_addr_space (&callbacks, target_type); - if (m_libunwind_addr_space) - m_libunwind_target_type = target_type; - else - m_libunwind_target_type = UNW_TARGET_UNSPECIFIED; - return m_libunwind_addr_space; -} - -void -ProcessGDBRemote::DestoryLibUnwindAddressSpace () -{ - if (m_libunwind_addr_space) - { - unw_destroy_addr_space (m_libunwind_addr_space); - m_libunwind_addr_space = NULL; - } - m_libunwind_target_type = UNW_TARGET_UNSPECIFIED; -} - - const char * ProcessGDBRemote::GetDispatchQueueNameForThread ( Modified: lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h?rev=122059&r1=122058&r2=122059&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h (original) +++ lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h Fri Dec 17 09:50:20 2010 @@ -29,7 +29,6 @@ #include "GDBRemoteCommunication.h" #include "Utility/StringExtractor.h" #include "GDBRemoteRegisterContext.h" -#include "libunwind/include/libunwind.h" class ThreadGDBRemote; @@ -335,8 +334,6 @@ lldb::addr_t m_dispatch_queue_offsets_addr; uint32_t m_packet_timeout; size_t m_max_memory_size; // The maximum number of bytes to read/write when reading and writing memory - lldb_private::unw_targettype_t m_libunwind_target_type; - lldb_private::unw_addr_space_t m_libunwind_addr_space; // libunwind address space object for this process. bool m_waiting_for_attach; bool m_local_debugserver; // Is the debugserver process we are talking to local or on another machine. @@ -384,11 +381,6 @@ //------------------------------------------------------------------ DISALLOW_COPY_AND_ASSIGN (ProcessGDBRemote); - lldb_private::unw_addr_space_t - GetLibUnwindAddressSpace (); - - void - DestoryLibUnwindAddressSpace (); }; #endif // liblldb_ProcessGDBRemote_h_ Modified: lldb/trunk/source/Plugins/Process/gdb-remote/ThreadGDBRemote.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/gdb-remote/ThreadGDBRemote.cpp?rev=122059&r1=122058&r2=122059&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Process/gdb-remote/ThreadGDBRemote.cpp (original) +++ lldb/trunk/source/Plugins/Process/gdb-remote/ThreadGDBRemote.cpp Fri Dec 17 09:50:20 2010 @@ -20,11 +20,9 @@ #include "lldb/Target/Unwind.h" #include "lldb/Breakpoint/WatchpointLocation.h" -#include "LibUnwindRegisterContext.h" #include "ProcessGDBRemote.h" #include "ProcessGDBRemoteLog.h" #include "Utility/StringExtractorGDBRemote.h" -#include "UnwindLibUnwind.h" #include "UnwindMacOSXFrameBackchain.h" #include "UnwindLLDB.h" Modified: lldb/trunk/source/Plugins/Process/gdb-remote/ThreadGDBRemote.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/gdb-remote/ThreadGDBRemote.h?rev=122059&r1=122058&r2=122059&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Process/gdb-remote/ThreadGDBRemote.h (original) +++ lldb/trunk/source/Plugins/Process/gdb-remote/ThreadGDBRemote.h Fri Dec 17 09:50:20 2010 @@ -14,7 +14,6 @@ #include "lldb/Target/Process.h" #include "lldb/Target/Thread.h" -#include "libunwind/include/libunwind.h" class StringExtractor; class ProcessGDBRemote; From gclayton at apple.com Fri Dec 17 09:54:09 2010 From: gclayton at apple.com (Greg Clayton) Date: Fri, 17 Dec 2010 15:54:09 -0000 Subject: [Lldb-commits] [lldb] r122060 - /lldb/trunk/source/Plugins/Process/Utility/UnwindAssemblyProfiler-x86.cpp Message-ID: <20101217155409.EF6CA2A6C12C@llvm.org> Author: gclayton Date: Fri Dec 17 09:54:09 2010 New Revision: 122060 URL: http://llvm.org/viewvc/llvm-project?rev=122060&view=rev Log: Removed darwin specific CPU type defines to make UnwindAssemblyProfiler_x86 able to compile on linux (patch from Stephen Wilson). Modified: lldb/trunk/source/Plugins/Process/Utility/UnwindAssemblyProfiler-x86.cpp Modified: lldb/trunk/source/Plugins/Process/Utility/UnwindAssemblyProfiler-x86.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Utility/UnwindAssemblyProfiler-x86.cpp?rev=122060&r1=122059&r2=122060&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Process/Utility/UnwindAssemblyProfiler-x86.cpp (original) +++ lldb/trunk/source/Plugins/Process/Utility/UnwindAssemblyProfiler-x86.cpp Fri Dec 17 09:54:09 2010 @@ -841,14 +841,14 @@ return asm_parse.find_first_non_prologue_insn (first_non_prologue_insn); } -lldb_private::UnwindAssemblyProfiler * -UnwindAssemblyProfiler_x86::CreateInstance (const lldb_private::ArchSpec &arch) +UnwindAssemblyProfiler * +UnwindAssemblyProfiler_x86::CreateInstance (const ArchSpec &arch) { - uint32_t cpu = arch.GetCPUType (); - if (cpu != CPU_TYPE_X86_64 && cpu != CPU_TYPE_I386) + ArchSpec::CPU cpu = arch.GetGenericCPUType (); + if (cpu != ArchSpec::eCPU_x86_64 && cpu != ArchSpec::eCPU_i386) return NULL; - return new UnwindAssemblyProfiler_x86 (cpu == CPU_TYPE_X86_64 ? k_x86_64 : k_i386); + return new UnwindAssemblyProfiler_x86 (cpu == ArchSpec::eCPU_x86_64 ? k_x86_64 : k_i386); } From gclayton at apple.com Fri Dec 17 09:57:29 2010 From: gclayton at apple.com (Greg Clayton) Date: Fri, 17 Dec 2010 07:57:29 -0800 Subject: [Lldb-commits] [PATCH 3/3] Rearrange #include's, initialization/termination. In-Reply-To: References: <1292532894-4455-1-git-send-email-wilsons@start.ca> <1292532894-4455-4-git-send-email-wilsons@start.ca> <288C6745-F9A7-404C-9CB2-1FC89C8E6328@apple.com> Message-ID: committed: File: /Volumes/work/gclayton/Documents/src/lldb/source/Plugins/Process/Utility/UnwindAssemblyProfiler-x86.cpp Revision: 122060 Date: Friday, December 17, 2010 7:54:09 AM PT Author: gclayton Removed darwin specific CPU type defines to make UnwindAssemblyProfiler_x86 able to compile on linux (patch from Stephen Wilson). Changes: M /lldb/trunk/source/Plugins/Process/Utility/UnwindAssemblyProfiler-x86.cpp On Dec 16, 2010, at 9:21 PM, Stephen Wilson wrote: > > Hi Greg, > > Greg Clayton writes: >> Stephen, let me know what issue you run into when tryingo t build these? > > OK. I definitely jumped the gun on this one -- I thought the code in > Process/Utility was a bit more interdependent than it is :) > > Does the following patch look OK to you? This is the only issue I found > among UnwindAssemblyProfiler-x86, ArchDefaultUnwindPlan-x86, and > ArchVolatileRegs-x86. > > The only remaining problem is how to get the Makefiles working for this > directory. I will take a closer look at the LLVM Makefiles, but I do > not remember seeing a way to exclude files within a directory from the > build. > > Would it be unreasonable to split up Process/Utility with a few more > logical subdirectories in which we place platform-specific components if > it turns out the current Makefile system cannot be pushed into dealing > with the layout as is? > > > Thanks! > > > diff --git a/source/Plugins/Process/Utility/UnwindAssemblyProfiler-x86.cpp b/source/Plugins/Process/Utility/UnwindAssemblyProfiler-x86.cpp > index 6b64886..61e3c70 100644 > --- a/source/Plugins/Process/Utility/UnwindAssemblyProfiler-x86.cpp > +++ b/source/Plugins/Process/Utility/UnwindAssemblyProfiler-x86.cpp > @@ -844,11 +844,11 @@ UnwindAssemblyProfiler_x86::FirstNonPrologueInsn (AddressRange& func, Target& ta > lldb_private::UnwindAssemblyProfiler * > UnwindAssemblyProfiler_x86::CreateInstance (const lldb_private::ArchSpec &arch) > { > - uint32_t cpu = arch.GetCPUType (); > - if (cpu != CPU_TYPE_X86_64 && cpu != CPU_TYPE_I386) > + ArchSpec::CPU cpu = arch.GetGenericCPUType (); > + if (cpu != ArchSpec::eCPU_x86_64 && cpu != ArchSpec::eCPU_i386) > return NULL; > > - return new UnwindAssemblyProfiler_x86 (cpu == CPU_TYPE_X86_64 ? k_x86_64 : k_i386); > + return new UnwindAssemblyProfiler_x86 (cpu == ArchSpec::eCPU_x86_64 ? k_x86_64 : k_i386); > } > > From gclayton at apple.com Fri Dec 17 09:59:59 2010 From: gclayton at apple.com (Greg Clayton) Date: Fri, 17 Dec 2010 07:59:59 -0800 Subject: [Lldb-commits] [PATCH 3/3] Rearrange #include's, initialization/termination. In-Reply-To: References: <1292532894-4455-1-git-send-email-wilsons@start.ca> <1292532894-4455-4-git-send-email-wilsons@start.ca> <288C6745-F9A7-404C-9CB2-1FC89C8E6328@apple.com> Message-ID: I have removed "lldb/trunk/source/Plugins/Process/Utility/libunwind" and all the tentacles that it had left behind as, after we switched to our new unwinder, we no longer used any of the libunwind sources. This should help keep the needed files down to a minimum and ease your linux porting changes! Let me know how these latest changes work for you, Greg Clayton Author: gclayton Date: Fri Dec 17 09:50:20 2010 New Revision: 122059 URL: http://llvm.org/viewvc/llvm-project?rev=122059&view=rev Log: Removed libunwind sources as we aren't using them anymore. Removed: lldb/trunk/source/Plugins/Process/Utility/LibUnwindRegisterContext.cpp lldb/trunk/source/Plugins/Process/Utility/LibUnwindRegisterContext.h lldb/trunk/source/Plugins/Process/Utility/MacOSXLibunwindCallbacks.cpp lldb/trunk/source/Plugins/Process/Utility/MacOSXLibunwindCallbacks.h lldb/trunk/source/Plugins/Process/Utility/UnwindLibUnwind.cpp lldb/trunk/source/Plugins/Process/Utility/UnwindLibUnwind.h lldb/trunk/source/Plugins/Process/Utility/libunwind/ Modified: lldb/trunk/include/lldb/Target/Thread.h lldb/trunk/lldb.xcodeproj/project.pbxproj lldb/trunk/source/Plugins/Process/MacOSX-User/source/ThreadMacOSX.cpp lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h lldb/trunk/source/Plugins/Process/gdb-remote/ThreadGDBRemote.cpp lldb/trunk/source/Plugins/Process/gdb-remote/ThreadGDBRemote.h On Dec 16, 2010, at 10:31 PM, Stephen Wilson wrote: > > Hi Greg, > > Stephen Wilson writes: >> The only remaining problem is how to get the Makefiles working for this >> directory. I will take a closer look at the LLVM Makefiles, but I do >> not remember seeing a way to exclude files within a directory from the >> build. >> >> Would it be unreasonable to split up Process/Utility with a few more >> logical subdirectories in which we place platform-specific components if >> it turns out the current Makefile system cannot be pushed into dealing >> with the layout as is? > > I have a solution for the Makefiles. Will push the patch out along with > some of the other Makefile changes shortly. > > Take care, > > -- > steve From gclayton at apple.com Fri Dec 17 09:59:24 2010 From: gclayton at apple.com (Greg Clayton) Date: Fri, 17 Dec 2010 15:59:24 -0000 Subject: [Lldb-commits] [lldb] r122061 - in /lldb/trunk: lldb.xcodeproj/project.pbxproj resources/LLDB-Info.plist tools/debugserver/debugserver.xcodeproj/project.pbxproj Message-ID: <20101217155925.071202A6C12C@llvm.org> Author: gclayton Date: Fri Dec 17 09:59:24 2010 New Revision: 122061 URL: http://llvm.org/viewvc/llvm-project?rev=122061&view=rev Log: Bumped Xcode project versions to for lldb-36 and debugserver-122. 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=122061&r1=122060&r2=122061&view=diff ============================================================================== --- lldb/trunk/lldb.xcodeproj/project.pbxproj (original) +++ lldb/trunk/lldb.xcodeproj/project.pbxproj Fri Dec 17 09:59:24 2010 @@ -2920,9 +2920,9 @@ buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; COPY_PHASE_STRIP = NO; - CURRENT_PROJECT_VERSION = 35; + CURRENT_PROJECT_VERSION = 36; DYLIB_COMPATIBILITY_VERSION = 1; - DYLIB_CURRENT_VERSION = 35; + DYLIB_CURRENT_VERSION = 36; EXPORTED_SYMBOLS_FILE = "resources/lldb-framework-exports"; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", @@ -2972,11 +2972,11 @@ buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; COPY_PHASE_STRIP = NO; - CURRENT_PROJECT_VERSION = 35; + CURRENT_PROJECT_VERSION = 36; DEAD_CODE_STRIPPING = YES; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; DYLIB_COMPATIBILITY_VERSION = 1; - DYLIB_CURRENT_VERSION = 35; + DYLIB_CURRENT_VERSION = 36; EXPORTED_SYMBOLS_FILE = "resources/lldb-framework-exports"; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", @@ -3046,7 +3046,7 @@ isa = XCBuildConfiguration; buildSettings = { COPY_PHASE_STRIP = YES; - CURRENT_PROJECT_VERSION = 35; + CURRENT_PROJECT_VERSION = 36; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", @@ -3081,11 +3081,11 @@ buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; COPY_PHASE_STRIP = YES; - CURRENT_PROJECT_VERSION = 35; + CURRENT_PROJECT_VERSION = 36; DEAD_CODE_STRIPPING = YES; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; DYLIB_COMPATIBILITY_VERSION = 1; - DYLIB_CURRENT_VERSION = 35; + DYLIB_CURRENT_VERSION = 36; EXPORTED_SYMBOLS_FILE = "resources/lldb-framework-exports"; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", @@ -3134,7 +3134,7 @@ buildSettings = { CODE_SIGN_IDENTITY = lldb_codesign; COPY_PHASE_STRIP = NO; - CURRENT_PROJECT_VERSION = 35; + CURRENT_PROJECT_VERSION = 36; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", "\"$(SYSTEM_LIBRARY_DIR)/PrivateFrameworks\"", @@ -3172,7 +3172,7 @@ ); CODE_SIGN_IDENTITY = lldb_codesign; COPY_PHASE_STRIP = YES; - CURRENT_PROJECT_VERSION = 35; + CURRENT_PROJECT_VERSION = 36; 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=122061&r1=122060&r2=122061&view=diff ============================================================================== --- lldb/trunk/resources/LLDB-Info.plist (original) +++ lldb/trunk/resources/LLDB-Info.plist Fri Dec 17 09:59:24 2010 @@ -17,7 +17,7 @@ CFBundleSignature ???? CFBundleVersion - 35 + 36 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=122061&r1=122060&r2=122061&view=diff ============================================================================== --- lldb/trunk/tools/debugserver/debugserver.xcodeproj/project.pbxproj (original) +++ lldb/trunk/tools/debugserver/debugserver.xcodeproj/project.pbxproj Fri Dec 17 09:59:24 2010 @@ -460,7 +460,7 @@ i386, ); COPY_PHASE_STRIP = NO; - CURRENT_PROJECT_VERSION = 121; + CURRENT_PROJECT_VERSION = 122; GCC_WARN_ABOUT_RETURN_TYPE = YES; GCC_WARN_UNUSED_VARIABLE = YES; STRIP_INSTALLED_PRODUCT = NO; @@ -478,7 +478,7 @@ x86_64, i386, ); - CURRENT_PROJECT_VERSION = 121; + CURRENT_PROJECT_VERSION = 122; DEAD_CODE_STRIPPING = YES; GCC_WARN_ABOUT_RETURN_TYPE = YES; GCC_WARN_UNUSED_VARIABLE = YES; @@ -498,7 +498,7 @@ x86_64, i386, ); - CURRENT_PROJECT_VERSION = 121; + CURRENT_PROJECT_VERSION = 122; DEAD_CODE_STRIPPING = YES; GCC_WARN_ABOUT_RETURN_TYPE = YES; GCC_WARN_UNUSED_VARIABLE = YES; @@ -515,7 +515,7 @@ buildSettings = { "CODE_SIGN_ENTITLEMENTS[sdk=iphoneos*]" = "source/debugserver-entitlements.plist"; COPY_PHASE_STRIP = YES; - CURRENT_PROJECT_VERSION = 121; + CURRENT_PROJECT_VERSION = 122; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; FRAMEWORK_SEARCH_PATHS = $SDKROOT/System/Library/PrivateFrameworks; "FRAMEWORK_SEARCH_PATHS[sdk=iphoneos*][arch=*]" = ( @@ -556,7 +556,7 @@ "CODE_SIGN_ENTITLEMENTS[sdk=iphoneos*]" = "source/debugserver-entitlements.plist"; "CODE_SIGN_IDENTITY[sdk=macosx*]" = lldb_codesign; COPY_PHASE_STRIP = YES; - CURRENT_PROJECT_VERSION = 121; + CURRENT_PROJECT_VERSION = 122; FRAMEWORK_SEARCH_PATHS = $SDKROOT/System/Library/PrivateFrameworks; "FRAMEWORK_SEARCH_PATHS[sdk=iphoneos*][arch=*]" = ( "$(SDKROOT)/System/Library/PrivateFrameworks", @@ -597,7 +597,7 @@ "CODE_SIGN_ENTITLEMENTS[sdk=iphoneos*]" = "source/debugserver-entitlements.plist"; "CODE_SIGN_IDENTITY[sdk=macosx*]" = lldb_codesign; COPY_PHASE_STRIP = YES; - CURRENT_PROJECT_VERSION = 121; + CURRENT_PROJECT_VERSION = 122; 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 Fri Dec 17 12:02:09 2010 From: johnny.chen at apple.com (Johnny Chen) Date: Fri, 17 Dec 2010 18:02:09 -0000 Subject: [Lldb-commits] [lldb] r122071 - /lldb/trunk/test/order/TestOrderFile.py Message-ID: <20101217180209.0D3122A6C12C@llvm.org> Author: johnny Date: Fri Dec 17 12:02:08 2010 New Revision: 122071 URL: http://llvm.org/viewvc/llvm-project?rev=122071&view=rev Log: Fix wrong test logic -- should pass "-s address" option to "image dump symtab" in order to sort the output by address. Modified: lldb/trunk/test/order/TestOrderFile.py Modified: lldb/trunk/test/order/TestOrderFile.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/order/TestOrderFile.py?rev=122071&r1=122070&r2=122071&view=diff ============================================================================== --- lldb/trunk/test/order/TestOrderFile.py (original) +++ lldb/trunk/test/order/TestOrderFile.py Fri Dec 17 12:02:08 2010 @@ -29,7 +29,8 @@ self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) # Test that the debug symbols have Function f3 before Function f1. - self.runCmd("image dump symtab a.out") + # Use "-s address" option to sort by address. + self.runCmd("image dump symtab -s address a.out") output = self.res.GetOutput() mo_f3 = re.search("Code +.+f3", output) mo_f1 = re.search("Code +.+f1", output) From wilsons at start.ca Fri Dec 17 12:41:44 2010 From: wilsons at start.ca (Stephen Wilson) Date: Fri, 17 Dec 2010 13:41:44 -0500 Subject: [Lldb-commits] [PATCH 3/3] Rearrange #include's, initialization/termination. In-Reply-To: (Greg Clayton's message of "Fri, 17 Dec 2010 07:59:59 -0800") References: <1292532894-4455-1-git-send-email-wilsons@start.ca> <1292532894-4455-4-git-send-email-wilsons@start.ca> <288C6745-F9A7-404C-9CB2-1FC89C8E6328@apple.com> Message-ID: Greg Clayton writes: > I have removed "lldb/trunk/source/Plugins/Process/Utility/libunwind" > and all the tentacles that it had left behind as, after we switched to > our new unwinder, we no longer used any of the libunwind sources. This > should help keep the needed files down to a minimum and ease your > linux porting changes! > > Let me know how these latest changes work for you, This is fantastic! Everything in the Process/Utility directory compiles just fine for me now. Thanks! > Greg Clayton > > > > Author: gclayton > Date: Fri Dec 17 09:50:20 2010 > New Revision: 122059 > > URL: http://llvm.org/viewvc/llvm-project?rev=122059&view=rev > Log: > Removed libunwind sources as we aren't using them anymore. > > > Removed: > lldb/trunk/source/Plugins/Process/Utility/LibUnwindRegisterContext.cpp > lldb/trunk/source/Plugins/Process/Utility/LibUnwindRegisterContext.h > lldb/trunk/source/Plugins/Process/Utility/MacOSXLibunwindCallbacks.cpp > lldb/trunk/source/Plugins/Process/Utility/MacOSXLibunwindCallbacks.h > lldb/trunk/source/Plugins/Process/Utility/UnwindLibUnwind.cpp > lldb/trunk/source/Plugins/Process/Utility/UnwindLibUnwind.h > lldb/trunk/source/Plugins/Process/Utility/libunwind/ > Modified: > lldb/trunk/include/lldb/Target/Thread.h > lldb/trunk/lldb.xcodeproj/project.pbxproj > lldb/trunk/source/Plugins/Process/MacOSX-User/source/ThreadMacOSX.cpp > lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp > lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h > lldb/trunk/source/Plugins/Process/gdb-remote/ThreadGDBRemote.cpp > lldb/trunk/source/Plugins/Process/gdb-remote/ThreadGDBRemote.h > On Dec 16, 2010, at 10:31 PM, Stephen Wilson wrote: > >> >> Hi Greg, >> >> Stephen Wilson writes: >>> The only remaining problem is how to get the Makefiles working for this >>> directory. I will take a closer look at the LLVM Makefiles, but I do >>> not remember seeing a way to exclude files within a directory from the >>> build. >>> >>> Would it be unreasonable to split up Process/Utility with a few more >>> logical subdirectories in which we place platform-specific components if >>> it turns out the current Makefile system cannot be pushed into dealing >>> with the layout as is? >> >> I have a solution for the Makefiles. Will push the patch out along with >> some of the other Makefile changes shortly. >> >> Take care, >> >> -- >> steve > -- steve From wilsons at start.ca Fri Dec 17 17:48:52 2010 From: wilsons at start.ca (Stephen Wilson) Date: Fri, 17 Dec 2010 18:48:52 -0500 Subject: [Lldb-commits] [PATCH 0/4] linux: missing includes Message-ID: <1292629736-8445-1-git-send-email-wilsons@start.ca> Hi all, This is a very simple patch series adding the #include's needed for some standard library functions on Linux. From wilsons at start.ca Fri Dec 17 17:48:53 2010 From: wilsons at start.ca (Stephen Wilson) Date: Fri, 17 Dec 2010 18:48:53 -0500 Subject: [Lldb-commits] [PATCH 1/4] Add missing include for standard library function strdup. In-Reply-To: <1292629736-8445-1-git-send-email-wilsons@start.ca> References: <1292629736-8445-1-git-send-email-wilsons@start.ca> Message-ID: <1292629736-8445-2-git-send-email-wilsons@start.ca> --- source/API/SBType.cpp | 2 ++ 1 files changed, 2 insertions(+), 0 deletions(-) diff --git a/source/API/SBType.cpp b/source/API/SBType.cpp index 4f9559b..b918ab2 100644 --- a/source/API/SBType.cpp +++ b/source/API/SBType.cpp @@ -7,6 +7,8 @@ // //===----------------------------------------------------------------------===// +#include + #include "lldb/API/SBType.h" #include "lldb/API/SBStream.h" #include "lldb/Core/ConstString.h" -- 1.7.3.2 From wilsons at start.ca Fri Dec 17 17:48:54 2010 From: wilsons at start.ca (Stephen Wilson) Date: Fri, 17 Dec 2010 18:48:54 -0500 Subject: [Lldb-commits] [PATCH 2/4] Add a missing include to provide strcmp(). In-Reply-To: <1292629736-8445-1-git-send-email-wilsons@start.ca> References: <1292629736-8445-1-git-send-email-wilsons@start.ca> Message-ID: <1292629736-8445-3-git-send-email-wilsons@start.ca> --- include/lldb/Expression/ClangExpressionVariable.h | 1 + 1 files changed, 1 insertions(+), 0 deletions(-) diff --git a/include/lldb/Expression/ClangExpressionVariable.h b/include/lldb/Expression/ClangExpressionVariable.h index 70e8ae1..6b2f43b 100644 --- a/include/lldb/Expression/ClangExpressionVariable.h +++ b/include/lldb/Expression/ClangExpressionVariable.h @@ -13,6 +13,7 @@ // C Includes #include #include +#include // C++ Includes #include -- 1.7.3.2 From wilsons at start.ca Fri Dec 17 17:48:55 2010 From: wilsons at start.ca (Stephen Wilson) Date: Fri, 17 Dec 2010 18:48:55 -0500 Subject: [Lldb-commits] [PATCH 3/4] Add missing includes for standard declaration of FILE. In-Reply-To: <1292629736-8445-1-git-send-email-wilsons@start.ca> References: <1292629736-8445-1-git-send-email-wilsons@start.ca> Message-ID: <1292629736-8445-4-git-send-email-wilsons@start.ca> --- include/lldb/API/SBStream.h | 2 ++ source/API/SBCommandReturnObject.cpp | 2 ++ 2 files changed, 4 insertions(+), 0 deletions(-) diff --git a/include/lldb/API/SBStream.h b/include/lldb/API/SBStream.h index a2050f2..6888943 100644 --- a/include/lldb/API/SBStream.h +++ b/include/lldb/API/SBStream.h @@ -10,6 +10,8 @@ #ifndef LLDB_SBStream_h_ #define LLDB_SBStream_h_ +#include + #include "lldb/API/SBDefines.h" namespace lldb { diff --git a/source/API/SBCommandReturnObject.cpp b/source/API/SBCommandReturnObject.cpp index 69dcab6..6c4f38b 100644 --- a/source/API/SBCommandReturnObject.cpp +++ b/source/API/SBCommandReturnObject.cpp @@ -7,6 +7,8 @@ // //===----------------------------------------------------------------------===// +#include + #include "lldb/API/SBCommandReturnObject.h" #include "lldb/API/SBStream.h" -- 1.7.3.2 From wilsons at start.ca Fri Dec 17 17:48:56 2010 From: wilsons at start.ca (Stephen Wilson) Date: Fri, 17 Dec 2010 18:48:56 -0500 Subject: [Lldb-commits] [PATCH 4/4] Add missing include for std::auto_ptr. In-Reply-To: <1292629736-8445-1-git-send-email-wilsons@start.ca> References: <1292629736-8445-1-git-send-email-wilsons@start.ca> Message-ID: <1292629736-8445-5-git-send-email-wilsons@start.ca> --- include/lldb/Utility/SharingPtr.h | 1 + 1 files changed, 1 insertions(+), 0 deletions(-) diff --git a/include/lldb/Utility/SharingPtr.h b/include/lldb/Utility/SharingPtr.h index 867918f..a5d7f37 100644 --- a/include/lldb/Utility/SharingPtr.h +++ b/include/lldb/Utility/SharingPtr.h @@ -11,6 +11,7 @@ #define utility_SharingPtr_h_ #include +#include namespace lldb_private { -- 1.7.3.2 From wilsons at start.ca Fri Dec 17 17:53:52 2010 From: wilsons at start.ca (Stephen Wilson) Date: Fri, 17 Dec 2010 18:53:52 -0500 Subject: [Lldb-commits] [PATCH] linux: fix Host definitions In-Reply-To: (Stephen Wilson's message of "Wed, 15 Dec 2010 13:37:16 -0500") References: Message-ID: Ping? This is the only patch that I did not get a response to so far. I presume it was overlooked. Thanks! Stephen Wilson writes: > Hi all, > > This is the first patch in a series I plan on sending to get the Linux > build back on its feet. > > I have roughly 25 patches to send out and would very much appreciate > some review before they go into the tree. I think I still have commit > access and would be happy to commit them myself if desired. > > > > > Fix definitions of Host::LaunchInNewTerminal and Host::OpenFileInExternalEditor. > > Definitions did not agree with the corresponding declarations when > compiling on non-Apple platforms. > > > diff --git a/source/Host/common/Host.cpp b/source/Host/common/Host.cpp > index 527d20a..c760aa3 100644 > --- a/source/Host/common/Host.cpp > +++ b/source/Host/common/Host.cpp > @@ -877,7 +877,7 @@ Host::GetArchSpecForExistingProcess (const char *process_name) > > #if !defined (__APPLE__) // see macosx/Host.mm > bool > -Host::OpenFileInExternalEditor (FileSpec &file_spec, uint32_t line_no) > +Host::OpenFileInExternalEditor (const FileSpec &file_spec, uint32_t line_no) > { > return false; > } > @@ -901,6 +901,7 @@ LaunchApplication (const FileSpec &app_file_spec) > lldb::pid_t > Host::LaunchInNewTerminal > ( > + const char *tty_name, > const char **argv, > const char **envp, > const ArchSpec *arch_spec, > > _______________________________________________ > lldb-commits mailing list > lldb-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/lldb-commits -- steve From scallanan at apple.com Fri Dec 17 18:32:26 2010 From: scallanan at apple.com (Sean Callanan) Date: Sat, 18 Dec 2010 00:32:26 -0000 Subject: [Lldb-commits] [lldb] r122118 - /lldb/trunk/source/Plugins/ABI/MacOSX-i386/ABIMacOSX_i386.cpp Message-ID: <20101218003226.14E0A2A6C12C@llvm.org> Author: spyffe Date: Fri Dec 17 18:32:25 2010 New Revision: 122118 URL: http://llvm.org/viewvc/llvm-project?rev=122118&view=rev Log: Fixed the handling of the _cmd parameter in the i386 ABI. Modified: lldb/trunk/source/Plugins/ABI/MacOSX-i386/ABIMacOSX_i386.cpp 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=122118&r1=122117&r2=122118&view=diff ============================================================================== --- lldb/trunk/source/Plugins/ABI/MacOSX-i386/ABIMacOSX_i386.cpp (original) +++ lldb/trunk/source/Plugins/ABI/MacOSX-i386/ABIMacOSX_i386.cpp Fri Dec 17 18:32:25 2010 @@ -97,9 +97,9 @@ if (thread.GetProcess().WriteMemory(sp, &this_argU32, sizeof(this_argU32), error) != sizeof(this_argU32)) return false; - if (thread.GetProcess().WriteMemory(sp, &cmd_argU32, sizeof(cmd_argU32), error) != sizeof(cmd_argU32)) + if (thread.GetProcess().WriteMemory(sp + 4, &cmd_argU32, sizeof(cmd_argU32), error) != sizeof(cmd_argU32)) return false; - if (thread.GetProcess().WriteMemory(sp + 4, &argU32, sizeof(argU32), error) != sizeof(argU32)) + if (thread.GetProcess().WriteMemory(sp + 8, &argU32, sizeof(argU32), error) != sizeof(argU32)) return false; } else if (this_arg) From gclayton at apple.com Fri Dec 17 19:48:09 2010 From: gclayton at apple.com (Greg Clayton) Date: Sat, 18 Dec 2010 01:48:09 -0000 Subject: [Lldb-commits] [lldb] r122125 - /lldb/trunk/source/API/SBType.cpp Message-ID: <20101218014809.CDF762A6C12C@llvm.org> Author: gclayton Date: Fri Dec 17 19:48:09 2010 New Revision: 122125 URL: http://llvm.org/viewvc/llvm-project?rev=122125&view=rev Log: Linux patches from Stephen Wilson. Modified: lldb/trunk/source/API/SBType.cpp Modified: lldb/trunk/source/API/SBType.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBType.cpp?rev=122125&r1=122124&r2=122125&view=diff ============================================================================== --- lldb/trunk/source/API/SBType.cpp (original) +++ lldb/trunk/source/API/SBType.cpp Fri Dec 17 19:48:09 2010 @@ -7,6 +7,8 @@ // //===----------------------------------------------------------------------===// +#include + #include "lldb/API/SBType.h" #include "lldb/API/SBStream.h" #include "lldb/Core/ConstString.h" From gclayton at apple.com Fri Dec 17 19:49:57 2010 From: gclayton at apple.com (Greg Clayton) Date: Sat, 18 Dec 2010 01:49:57 -0000 Subject: [Lldb-commits] [lldb] r122126 - /lldb/trunk/include/lldb/Expression/ClangExpressionVariable.h Message-ID: <20101218014957.514B52A6C12C@llvm.org> Author: gclayton Date: Fri Dec 17 19:49:57 2010 New Revision: 122126 URL: http://llvm.org/viewvc/llvm-project?rev=122126&view=rev Log: Linux patches from Stephen Wilson. Modified: lldb/trunk/include/lldb/Expression/ClangExpressionVariable.h Modified: lldb/trunk/include/lldb/Expression/ClangExpressionVariable.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Expression/ClangExpressionVariable.h?rev=122126&r1=122125&r2=122126&view=diff ============================================================================== --- lldb/trunk/include/lldb/Expression/ClangExpressionVariable.h (original) +++ lldb/trunk/include/lldb/Expression/ClangExpressionVariable.h Fri Dec 17 19:49:57 2010 @@ -13,6 +13,7 @@ // C Includes #include #include +#include // C++ Includes #include From gclayton at apple.com Fri Dec 17 19:52:08 2010 From: gclayton at apple.com (Greg Clayton) Date: Sat, 18 Dec 2010 01:52:08 -0000 Subject: [Lldb-commits] [lldb] r122127 - in /lldb/trunk/include/lldb/API: SBCommandReturnObject.h SBStream.h Message-ID: <20101218015208.BF8872A6C12C@llvm.org> Author: gclayton Date: Fri Dec 17 19:52:08 2010 New Revision: 122127 URL: http://llvm.org/viewvc/llvm-project?rev=122127&view=rev Log: Linux patches from Stephen Wilson. Modified: lldb/trunk/include/lldb/API/SBCommandReturnObject.h lldb/trunk/include/lldb/API/SBStream.h Modified: lldb/trunk/include/lldb/API/SBCommandReturnObject.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBCommandReturnObject.h?rev=122127&r1=122126&r2=122127&view=diff ============================================================================== --- lldb/trunk/include/lldb/API/SBCommandReturnObject.h (original) +++ lldb/trunk/include/lldb/API/SBCommandReturnObject.h Fri Dec 17 19:52:08 2010 @@ -10,6 +10,8 @@ #ifndef LLDB_SBCommandReturnObject_h_ #define LLDB_SBCommandReturnObject_h_ +#include + #include "lldb/API/SBDefines.h" namespace lldb { Modified: lldb/trunk/include/lldb/API/SBStream.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBStream.h?rev=122127&r1=122126&r2=122127&view=diff ============================================================================== --- lldb/trunk/include/lldb/API/SBStream.h (original) +++ lldb/trunk/include/lldb/API/SBStream.h Fri Dec 17 19:52:08 2010 @@ -10,6 +10,8 @@ #ifndef LLDB_SBStream_h_ #define LLDB_SBStream_h_ +#include + #include "lldb/API/SBDefines.h" namespace lldb { From gclayton at apple.com Fri Dec 17 19:52:51 2010 From: gclayton at apple.com (Greg Clayton) Date: Sat, 18 Dec 2010 01:52:51 -0000 Subject: [Lldb-commits] [lldb] r122128 - /lldb/trunk/include/lldb/Utility/SharingPtr.h Message-ID: <20101218015252.005AC2A6C12C@llvm.org> Author: gclayton Date: Fri Dec 17 19:52:51 2010 New Revision: 122128 URL: http://llvm.org/viewvc/llvm-project?rev=122128&view=rev Log: Linux patches from Stephen Wilson. Modified: lldb/trunk/include/lldb/Utility/SharingPtr.h Modified: lldb/trunk/include/lldb/Utility/SharingPtr.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Utility/SharingPtr.h?rev=122128&r1=122127&r2=122128&view=diff ============================================================================== --- lldb/trunk/include/lldb/Utility/SharingPtr.h (original) +++ lldb/trunk/include/lldb/Utility/SharingPtr.h Fri Dec 17 19:52:51 2010 @@ -11,6 +11,7 @@ #define utility_SharingPtr_h_ #include +#include namespace lldb_private { From gclayton at apple.com Fri Dec 17 19:54:34 2010 From: gclayton at apple.com (Greg Clayton) Date: Sat, 18 Dec 2010 01:54:34 -0000 Subject: [Lldb-commits] [lldb] r122130 - /lldb/trunk/source/Host/common/Host.cpp Message-ID: <20101218015434.8A4A02A6C12C@llvm.org> Author: gclayton Date: Fri Dec 17 19:54:34 2010 New Revision: 122130 URL: http://llvm.org/viewvc/llvm-project?rev=122130&view=rev Log: Linux patches from Stephen Wilson. Modified: lldb/trunk/source/Host/common/Host.cpp Modified: lldb/trunk/source/Host/common/Host.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/common/Host.cpp?rev=122130&r1=122129&r2=122130&view=diff ============================================================================== --- lldb/trunk/source/Host/common/Host.cpp (original) +++ lldb/trunk/source/Host/common/Host.cpp Fri Dec 17 19:54:34 2010 @@ -877,7 +877,7 @@ #if !defined (__APPLE__) // see macosx/Host.mm bool -Host::OpenFileInExternalEditor (FileSpec &file_spec, uint32_t line_no) +Host::OpenFileInExternalEditor (const FileSpec &file_spec, uint32_t line_no) { return false; } @@ -901,6 +901,7 @@ lldb::pid_t Host::LaunchInNewTerminal ( + const char *tty_name, const char **argv, const char **envp, const ArchSpec *arch_spec, From gclayton at apple.com Fri Dec 17 19:58:06 2010 From: gclayton at apple.com (Greg Clayton) Date: Fri, 17 Dec 2010 17:58:06 -0800 Subject: [Lldb-commits] [PATCH] linux: fix Host definitions In-Reply-To: References: Message-ID: All of your patches have been committed. Let me know if you have commit access and want just an OK to commit these yourself? I have been assuming we would do them, but I am totally fine with you doing it! Greg Clayton From wilsons at start.ca Fri Dec 17 20:58:48 2010 From: wilsons at start.ca (Stephen Wilson) Date: Fri, 17 Dec 2010 21:58:48 -0500 Subject: [Lldb-commits] [PATCH] linux: fix Host definitions In-Reply-To: (Greg Clayton's message of "Fri, 17 Dec 2010 17:58:06 -0800") References: Message-ID: Greg Clayton writes: > All of your patches have been committed. Awesome :) > Let me know if you have commit access and want just an OK to commit > these yourself? I have been assuming we would do them, but I am > totally fine with you doing it! It has been a few months since I made a commit to the LLDB repo, but AFAIK I still have access. I am more than happy to do the commits so let's leave them to me and I will let you know if I run into problems. Of course, I will continue (and prefer) to post all patches for review before commit'ing. Thanks, > > Greg Clayton > -- steve From gclayton at apple.com Sat Dec 18 14:52:52 2010 From: gclayton at apple.com (Greg Clayton) Date: Sat, 18 Dec 2010 12:52:52 -0800 Subject: [Lldb-commits] [PATCH] linux: fix Host definitions In-Reply-To: References: Message-ID: On Dec 17, 2010, at 6:58 PM, Stephen Wilson wrote: > Greg Clayton writes: > >> All of your patches have been committed. > > Awesome :) > >> Let me know if you have commit access and want just an OK to commit >> these yourself? I have been assuming we would do them, but I am >> totally fine with you doing it! > > It has been a few months since I made a commit to the LLDB repo, but > AFAIK I still have access. I am more than happy to do the commits so > let's leave them to me and I will let you know if I run into problems. > > Of course, I will continue (and prefer) to post all patches for review > before commit'ing. Sounds good! Greg From gclayton at apple.com Sat Dec 18 21:41:24 2010 From: gclayton at apple.com (Greg Clayton) Date: Sun, 19 Dec 2010 03:41:24 -0000 Subject: [Lldb-commits] [lldb] r122166 - in /lldb/trunk: include/lldb/Core/RegularExpression.h source/Core/RegularExpression.cpp source/Core/UserSettingsController.cpp source/Interpreter/Args.cpp Message-ID: <20101219034125.01E932A6C12C@llvm.org> Author: gclayton Date: Sat Dec 18 21:41:24 2010 New Revision: 122166 URL: http://llvm.org/viewvc/llvm-project?rev=122166&view=rev Log: Improved our argument parsing abilities to be able to handle stuff more like a shell would interpret it. A few examples that we now handle correctly INPUT: "Hello "world OUTPUT: "Hello World" INPUT: "Hello "' World' OUTPUT: "Hello World" INPUT: Hello" World" OUTPUT: "Hello World" This broke the setting of dictionary values for the "settings set" command for things like: (lldb) settings set target.process.env-vars ["MY_ENV_VAR"]=YES since we would drop the quotes. I fixed the user settings controller to use a regular expression so it can accept any of the following inputs for dictionary setting: settings set target.process.env-vars ["MY_ENV_VAR"]=YES settings set target.process.env-vars [MY_ENV_VAR]=YES settings set target.process.env-vars MY_ENV_VAR=YES We might want to eventually drop the first two syntaxes, but I won't make that decision right now. This allows more natural setting of the envirorment variables: settings set target.process.env-vars MY_ENV_VAR=YES ABC=DEF CWD=/tmp Modified: lldb/trunk/include/lldb/Core/RegularExpression.h lldb/trunk/source/Core/RegularExpression.cpp lldb/trunk/source/Core/UserSettingsController.cpp lldb/trunk/source/Interpreter/Args.cpp Modified: lldb/trunk/include/lldb/Core/RegularExpression.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/RegularExpression.h?rev=122166&r1=122165&r2=122166&view=diff ============================================================================== --- lldb/trunk/include/lldb/Core/RegularExpression.h (original) +++ lldb/trunk/include/lldb/Core/RegularExpression.h Sat Dec 18 21:41:24 2010 @@ -101,10 +101,6 @@ /// @param[in] match_count /// The number of regmatch_t objects in \a match_ptr /// - /// @param[out] match_ptr - /// A pointer to at least \a match_count regmatch_t objects - /// if \a match_count is non-zero. - /// /// @param[in] execute_flags /// Flags to pass to the \c regexec() function. /// Modified: lldb/trunk/source/Core/RegularExpression.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/RegularExpression.cpp?rev=122166&r1=122165&r2=122166&view=diff ============================================================================== --- lldb/trunk/source/Core/RegularExpression.cpp (original) +++ lldb/trunk/source/Core/RegularExpression.cpp Sat Dec 18 21:41:24 2010 @@ -100,7 +100,7 @@ match_result = ::regexec (&m_preg, s, m_matches.size(), - &m_matches.front(), + &m_matches[0], execute_flags); } return match_result == 0; @@ -111,9 +111,18 @@ { if (idx <= m_preg.re_nsub && idx < m_matches.size()) { - match_str.assign (s + m_matches[idx].rm_so, - m_matches[idx].rm_eo - m_matches[idx].rm_so); - return true; + if (m_matches[idx].rm_eo == m_matches[idx].rm_so) + { + // Matched the empty string... + match_str.clear(); + return true; + } + else if (m_matches[idx].rm_eo > m_matches[idx].rm_so) + { + match_str.assign (s + m_matches[idx].rm_so, + m_matches[idx].rm_eo - m_matches[idx].rm_so); + return true; + } } return false; } Modified: lldb/trunk/source/Core/UserSettingsController.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/UserSettingsController.cpp?rev=122166&r1=122165&r2=122166&view=diff ============================================================================== --- lldb/trunk/source/Core/UserSettingsController.cpp (original) +++ lldb/trunk/source/Core/UserSettingsController.cpp Sat Dec 18 21:41:24 2010 @@ -12,6 +12,7 @@ #include "lldb/Core/UserSettingsController.h" #include "lldb/Core/Error.h" +#include "lldb/Core/RegularExpression.h" #include "lldb/Core/Stream.h" #include "lldb/Core/StreamString.h" #include "lldb/Interpreter/CommandInterpreter.h" @@ -2102,34 +2103,32 @@ } Args args (new_value); size_t num_args = args.GetArgumentCount(); + RegularExpression regex("(\\[\"?)?" // Regex match 1 (optional key prefix of '["' pr '[') + "([A-Za-z_][A-Za-z_0-9]*)" // Regex match 2 (key string) + "(\"?\\])?" // Regex match 3 (optional key suffix of '"]' pr ']') + "=" // The equal sign that is required + "(.*)"); // Regex match 4 (value string) + std::string key, value; + for (size_t i = 0; i < num_args; ++i) { - std::string tmp_arg = args.GetArgumentAtIndex (i); - size_t eq_sign = tmp_arg.find ('='); - if (eq_sign != std::string::npos) + const char *key_equal_value_arg = args.GetArgumentAtIndex (i); + // Execute the regular expression on each arg. + if (regex.Execute(key_equal_value_arg, 5)) { - if (eq_sign > 4) - { - std::string tmp_key = tmp_arg.substr (0, eq_sign); - std::string real_value = tmp_arg.substr (eq_sign+1); - if ((tmp_key[0] == '[') - && (tmp_key[1] == '"') - && (tmp_key[eq_sign-2] == '"') - && (tmp_key[eq_sign-1] == ']')) - { - std::string real_key = tmp_key.substr (2, eq_sign-4); - dictionary[real_key] = real_value; - } - else - err.SetErrorString ("Invalid key format for dictionary assignment. " - "Expected '[\"\"]'\n"); - } - else - err.SetErrorString ("Invalid key format for dictionary assignment. " - "Expected '[\"\"]'\n"); + // The regular expression succeeded. The match at index + // zero will be the entire string that matched the entire + // regular expression. The match at index 1 - 4 will be + // as mentioned above by the creation of the regex pattern. + // Match index 2 is the key, match index 4 is the value. + regex.GetMatchAtIndex (key_equal_value_arg, 2, key); + regex.GetMatchAtIndex (key_equal_value_arg, 4, value); + dictionary[key] = value; } else - err.SetErrorString ("Invalid format for dictionary value. Expected '[\"\"]='\n"); + { + err.SetErrorString ("Invalid format for dictionary value. Expected one of '[\"\"]=', '[]=', or '='\n"); + } } } break; Modified: lldb/trunk/source/Interpreter/Args.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Interpreter/Args.cpp?rev=122166&r1=122165&r2=122166&view=diff ============================================================================== --- lldb/trunk/source/Interpreter/Args.cpp (original) +++ lldb/trunk/source/Interpreter/Args.cpp Sat Dec 18 21:41:24 2010 @@ -23,10 +23,6 @@ using namespace lldb; using namespace lldb_private; -static const char *k_space_characters = "\t\n\v\f\r "; -static const char *k_space_characters_with_slash = "\t\n\v\f\r \\"; - - //---------------------------------------------------------------------- // Args constructor //---------------------------------------------------------------------- @@ -34,7 +30,8 @@ m_args(), m_argv() { - SetCommandString (command); + if (command) + SetCommandString (command); } @@ -42,11 +39,10 @@ m_args(), m_argv() { - SetCommandString (command, len); + if (command && len) + SetCommandString (command, len); } - - //---------------------------------------------------------------------- // Destructor //---------------------------------------------------------------------- @@ -97,20 +93,20 @@ Args::GetQuotedCommandString (std::string &command) { command.clear (); - int argc = GetArgumentCount (); - for (int i = 0; i < argc; ++i) + size_t argc = GetArgumentCount (); + for (size_t i = 0; i < argc; ++i) { if (i > 0) - command += ' '; - char quote_char = m_args_quote_char[i]; - if (quote_char != '\0') - { - command += quote_char; - command += m_argv[i]; - command += quote_char; + command.append (1, ' '); + char quote_char = GetArgumentQuoteCharAtIndex(i); + if (quote_char) + { + command.append (1, quote_char); + command.append (m_argv[i]); + command.append (1, quote_char); } else - command += m_argv[i]; + command.append (m_argv[i]); } return argc > 0; } @@ -127,136 +123,197 @@ void Args::SetCommandString (const char *command) { + StreamFile s(stdout); + s.Printf("\nCOMMAND: %s\n", command); m_args.clear(); m_argv.clear(); + m_args_quote_char.clear(); + if (command && command[0]) { - const char *arg_start; - const char *next_arg_start; - for (arg_start = command, next_arg_start = NULL; - arg_start && arg_start[0]; - arg_start = next_arg_start, next_arg_start = NULL) + static const char *k_space_separators = " \t"; + static const char *k_space_separators_with_slash_and_quotes = " \t \\'\"`"; + const char *arg_end = NULL; + const char *arg_pos; + for (arg_pos = command; + arg_pos && arg_pos[0]; + arg_pos = arg_end) { - // Skip any leading space characters - arg_start = ::strspn (arg_start, k_space_characters) + arg_start; - - // If there were only space characters to the end of the line, then + // Skip any leading space separators + const char *arg_start = ::strspn (arg_pos, k_space_separators) + arg_pos; + + // If there were only space separators to the end of the line, then // we're done. if (*arg_start == '\0') break; + // Arguments can be split into multiple discongituous pieces, + // for example: + // "Hello ""World" + // this would result in a single argument "Hello World" (without/ + // the quotes) since the quotes would be removed and there is + // not space between the strings. So we need to keep track of the + // current start of each argument piece in "arg_piece_start" + const char *arg_piece_start = arg_start; + arg_pos = arg_piece_start; + std::string arg; - const char *arg_end = NULL; + // Since we can have multiple quotes that form a single command + // in a command like: "Hello "world'!' (which will make a single + // argument "Hello world!") we remember the first quote character + // we encounter and use that for the quote character. + char first_quote_char = '\0'; + char quote_char = '\0'; + bool arg_complete = false; - switch (*arg_start) + do { - case '\'': - case '"': - case '`': + arg_end = ::strcspn (arg_pos, k_space_separators_with_slash_and_quotes) + arg_pos; + + switch (arg_end[0]) { - // Look for either a quote character, or the backslash - // character - const char quote_char = *arg_start; - char find_chars[3] = { quote_char, '\\' , '\0'}; - bool is_backtick = (quote_char == '`'); - if (quote_char == '"' || quote_char == '`') - m_args_quote_char.push_back(quote_char); - else - m_args_quote_char.push_back('\0'); + default: + assert (!"Unhandled case statement, we must handle this..."); + break; - while (*arg_start != '\0') + case '\0': + // End of C string + if (arg_piece_start && arg_piece_start[0]) + arg.append (arg_piece_start); + arg_complete = true; + break; + + case '\\': + // Backslash character + switch (arg_end[1]) { - arg_end = ::strcspn (arg_start + 1, find_chars) + arg_start + 1; + case '\0': + arg.append (arg_piece_start); + arg_complete = true; + break; - if (*arg_end == '\0') - { - arg.append (arg_start); + default: + arg_pos = arg_end + 2; break; + } + break; + + case '"': + case '\'': + case '`': + // Quote characters + if (quote_char) + { + // We found a quote character while inside a quoted + // character argument. If it matches our current quote + // character, this ends the effect of the quotes. If it + // doesn't we ignore it. + if (quote_char == arg_end[0]) + { + arg.append (arg_piece_start, arg_end - arg_piece_start); + // Clear the quote character and let parsing + // continue (we need to watch for things like: + // "Hello ""World" + // "Hello "World + // "Hello "'World' + // All of which will result in a single argument "Hello World" + quote_char = '\0'; // Note that we are no longer inside quotes + arg_pos = arg_end + 1; // Skip the quote character + arg_piece_start = arg_pos; // Note we are starting from later in the string } - - // Watch out for quote characters prefixed with '\' - if (*arg_end == '\\') + else { - if (arg_end[1] == quote_char) + // different quote, skip it and keep going + arg_pos = arg_end + 1; + } + } + else + { + // We found the start of a quote scope. + // Make sure there isn't a string that predeces + // the start of a quote scope like: + // Hello" World" + // If so, then add the "Hello" to the arg + if (arg_end > arg_piece_start) + arg.append (arg_piece_start, arg_end - arg_piece_start); + + // Enter into a quote scope + quote_char = arg_end[0]; + + if (first_quote_char == '\0') + first_quote_char = quote_char; + + arg_pos = arg_end; + + if (quote_char != '`') + ++arg_pos; // Skip the quote character if it is not a backtick + + arg_piece_start = arg_pos; // Note we are starting from later in the string + + // Skip till the next quote character + const char *end_quote = ::strchr (arg_piece_start, quote_char); + while (end_quote && end_quote[-1] == '\\') + { + // Don't skip the quote character if it is + // preceded by a '\' character + end_quote = ::strchr (end_quote + 1, quote_char); + } + + if (end_quote) + { + if (end_quote > arg_piece_start) { - // The character following the '\' is our quote - // character so strip the backslash character - arg.append (arg_start, arg_end); + // Keep the backtick quote on commands + if (quote_char == '`') + arg.append (arg_piece_start, end_quote + 1 - arg_piece_start); + else + arg.append (arg_piece_start, end_quote - arg_piece_start); + } + + // If the next character is a space or the end of + // string, this argument is complete... + if (end_quote[1] == ' ' || end_quote[1] == '\t' || end_quote[1] == '\0') + { + arg_complete = true; + arg_end = end_quote + 1; } else { - // The character following the '\' is NOT our - // quote character, so include the backslash - // and continue - arg.append (arg_start, arg_end + 1); + arg_pos = end_quote + 1; + arg_piece_start = arg_pos; } - arg_start = arg_end + 1; - continue; - } - else - { - arg.append (arg_start, arg_end + 1); - next_arg_start = arg_end + 1; - break; + quote_char = '\0'; } } + break; - // Skip single and double quotes, but leave backtick quotes - if (!is_backtick) + case ' ': + case '\t': + if (quote_char) { - char first_c = arg[0]; - arg.erase(0,1); - // Only erase the last character if it is the same as the first. - // Otherwise, we're parsing an incomplete command line, and we - // would be stripping off the last character of that string. - if (arg[arg.size() - 1] == first_c) - arg.erase(arg.size() - 1, 1); + // We are currently processing a quoted character and found + // a space character, skip any spaces and keep trying to find + // the end of the argument. + arg_pos = ::strspn (arg_end, k_space_separators) + arg_end; } - } - break; - default: - { - m_args_quote_char.push_back('\0'); - // Look for the next non-escaped space character - while (*arg_start != '\0') + else { - arg_end = ::strcspn (arg_start, k_space_characters_with_slash) + arg_start; - - if (arg_end == NULL) - { - arg.append(arg_start); - break; - } - - if (*arg_end == '\\') - { - // Append up to the '\' char - arg.append (arg_start, arg_end); - - if (arg_end[1] == '\0') - break; - - // Append the character following the '\' if it isn't - // the end of the string - arg.append (1, arg_end[1]); - arg_start = arg_end + 2; - continue; - } - else - { - arg.append (arg_start, arg_end); - next_arg_start = arg_end; - break; - } + // We are not inside any quotes, we just found a space after an + // argument + if (arg_end > arg_piece_start) + arg.append (arg_piece_start, arg_end - arg_piece_start); + arg_complete = true; } + break; } - break; - } + } while (!arg_complete); m_args.push_back(arg); + m_args_quote_char.push_back (first_quote_char); } + UpdateArgvFromArgs(); } - UpdateArgvFromArgs(); + Dump (&s); } void @@ -309,6 +366,9 @@ for (pos = m_args.begin(); pos != end; ++pos) m_argv.push_back(pos->c_str()); m_argv.push_back(NULL); + // Make sure we have enough arg quote chars in the array + if (m_args_quote_char.size() < m_args.size()) + m_args_quote_char.resize (m_argv.size()); } size_t @@ -359,7 +419,8 @@ { m_argv.erase(m_argv.begin()); m_args.pop_front(); - m_args_quote_char.erase(m_args_quote_char.begin()); + if (!m_args_quote_char.empty()) + m_args_quote_char.erase(m_args_quote_char.begin()); } } @@ -399,8 +460,13 @@ pos = m_args.insert(pos, arg_cstr); - - m_args_quote_char.insert(m_args_quote_char.begin() + idx, quote_char); + if (idx >= m_args_quote_char.size()) + { + m_args_quote_char.resize(idx + 1); + m_args_quote_char[idx] = quote_char; + } + else + m_args_quote_char.insert(m_args_quote_char.begin() + idx, quote_char); UpdateArgvFromArgs(); return GetArgumentAtIndex(idx); @@ -422,6 +488,8 @@ pos->assign(arg_cstr); assert(idx < m_argv.size() - 1); m_argv[idx] = pos->c_str(); + if (idx >= m_args_quote_char.size()) + m_args_quote_char.resize(idx + 1); m_args_quote_char[idx] = quote_char; return GetArgumentAtIndex(idx); } @@ -444,7 +512,8 @@ m_args.erase (pos); assert(idx < m_argv.size() - 1); m_argv.erase(m_argv.begin() + idx); - m_args_quote_char.erase(m_args_quote_char.begin() + idx); + if (idx < m_args_quote_char.size()) + m_args_quote_char.erase(m_args_quote_char.begin() + idx); } } @@ -462,7 +531,7 @@ for (i=0; i Author: gclayton Date: Sun Dec 19 15:36:12 2010 New Revision: 122198 URL: http://llvm.org/viewvc/llvm-project?rev=122198&view=rev Log: Removed logging code that I accidentally left in after recent changes. Modified: lldb/trunk/source/Interpreter/Args.cpp Modified: lldb/trunk/source/Interpreter/Args.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Interpreter/Args.cpp?rev=122198&r1=122197&r2=122198&view=diff ============================================================================== --- lldb/trunk/source/Interpreter/Args.cpp (original) +++ lldb/trunk/source/Interpreter/Args.cpp Sun Dec 19 15:36:12 2010 @@ -123,8 +123,6 @@ void Args::SetCommandString (const char *command) { - StreamFile s(stdout); - s.Printf("\nCOMMAND: %s\n", command); m_args.clear(); m_argv.clear(); m_args_quote_char.clear(); @@ -313,7 +311,6 @@ } UpdateArgvFromArgs(); } - Dump (&s); } void From gclayton at apple.com Sun Dec 19 16:07:39 2010 From: gclayton at apple.com (Greg Clayton) Date: Sun, 19 Dec 2010 22:07:39 -0000 Subject: [Lldb-commits] [lldb] r122200 - in /lldb/trunk: include/lldb/Symbol/LineTable.h source/Symbol/LineTable.cpp Message-ID: <20101219220740.0AAB32A6C12C@llvm.org> Author: gclayton Date: Sun Dec 19 16:07:39 2010 New Revision: 122200 URL: http://llvm.org/viewvc/llvm-project?rev=122200&view=rev Log: Line tables were trying to be too clever and only use 24 bits for a line table offset where the offset is within a section. Increased the section offset for line table entries to be 32 bits (from 24 bits), giving each section a 4G offset, and increased the section index to 32 bits (from 8 bits). Modified: lldb/trunk/include/lldb/Symbol/LineTable.h lldb/trunk/source/Symbol/LineTable.cpp Modified: lldb/trunk/include/lldb/Symbol/LineTable.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Symbol/LineTable.h?rev=122200&r1=122199&r2=122200&view=diff ============================================================================== --- lldb/trunk/include/lldb/Symbol/LineTable.h (original) +++ lldb/trunk/include/lldb/Symbol/LineTable.h Sun Dec 19 16:07:39 2010 @@ -194,7 +194,7 @@ struct Entry { - enum { kInvalidSectIdx = 255 }; + enum { kInvalidSectIdx = UINT32_MAX }; Entry () : sect_idx (kInvalidSectIdx), @@ -210,7 +210,7 @@ { } - Entry ( uint8_t _sect_idx, + Entry ( uint32_t _sect_idx, lldb::addr_t _sect_offset, uint32_t _line, uint16_t _column, @@ -231,10 +231,10 @@ is_epilogue_begin (_is_epilogue_begin), is_terminal_entry (_is_terminal_entry) { - // We have reserved 24 bits for the section offset which should + // We have reserved 32 bits for the section offset which should // be enough, but if it isn't then we need to make m_section_offset // bigger - assert((_sect_offset & 0xffffffffff000000ull) == 0); + assert(_sect_offset <= UINT32_MAX); } int @@ -295,8 +295,8 @@ //------------------------------------------------------------------ // Member variables. //------------------------------------------------------------------ - uint32_t sect_idx:8, ///< The section index for this line entry. - sect_offset:24; ///< The offset into the section for this line entry. + uint32_t sect_idx; ///< The section index for this line entry. + uint32_t sect_offset; ///< The offset into the section for this line entry. uint32_t line; ///< The source line number, or zero if there is no line number information. uint16_t column; ///< The column number of the source line, or zero if there is no column information. uint16_t file_idx:11, ///< The file index into CompileUnit's file table, or zero if there is no file information. Modified: lldb/trunk/source/Symbol/LineTable.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/LineTable.cpp?rev=122200&r1=122199&r2=122200&view=diff ============================================================================== --- lldb/trunk/source/Symbol/LineTable.cpp (original) +++ lldb/trunk/source/Symbol/LineTable.cpp Sun Dec 19 16:07:39 2010 @@ -57,10 +57,6 @@ ) { uint32_t sect_idx = m_section_list.AddUniqueSection (section_sp); - // Make sure we don't user more than 256 sections as that is all we have - // room for in the LineTable::Entry::m_sect_idx. If this assert fires, - // we will need to m_sect_idx have more bits... - assert((section_offset & 0xffffffffff000000ull) == 0); Entry entry(sect_idx, section_offset, line, column, file_idx, is_start_of_statement, is_start_of_basic_block, is_prologue_end, is_epilogue_begin, is_terminal_entry); m_entries.push_back (entry); } @@ -91,10 +87,6 @@ } uint32_t sect_idx = m_section_list.AddUniqueSection (line_section_sp); - // Make sure we don't user more than 256 sections as that is all we have - // room for in the LineTable::Entry::m_sect_idx. If this assert fires, - // we will need to m_sect_idx have more bits... - assert((section_offset & 0xffffffffff000000ull) == 0); Entry entry(sect_idx, section_offset, line, column, file_idx, is_start_of_statement, is_start_of_basic_block, is_prologue_end, is_epilogue_begin, is_terminal_entry); entry_collection::iterator begin_pos = m_entries.begin();