From ctice at apple.com Mon Sep 13 00:27:16 2010 From: ctice at apple.com (Caroline Tice) Date: Mon, 13 Sep 2010 05:27:16 -0000 Subject: [Lldb-commits] [lldb] r113738 - /lldb/trunk/source/Interpreter/CommandInterpreter.cpp Message-ID: <20100913052716.3E09B2A6C12C@llvm.org> Author: ctice Date: Mon Sep 13 00:27:16 2010 New Revision: 113738 URL: http://llvm.org/viewvc/llvm-project?rev=113738&view=rev Log: Clean up help text. 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=113738&r1=113737&r2=113738&view=diff ============================================================================== --- lldb/trunk/source/Interpreter/CommandInterpreter.cpp (original) +++ lldb/trunk/source/Interpreter/CommandInterpreter.cpp Mon Sep 13 00:27:16 2010 @@ -457,7 +457,7 @@ if (m_alias_dict.size() > 0) { - result.AppendMessage("The following is a list of your current command abbreviations (see 'commands alias' for more info):"); + result.AppendMessage("The following is a list of your current command abbreviations (see 'help commands alias' for more info):"); result.AppendMessage(""); max_len = FindLongestCommandWord (m_alias_dict); From johnny.chen at apple.com Mon Sep 13 11:06:19 2010 From: johnny.chen at apple.com (Johnny Chen) Date: Mon, 13 Sep 2010 16:06:19 -0000 Subject: [Lldb-commits] [lldb] r113748 - /lldb/trunk/test/conditional_break/TestConditionalBreak.py Message-ID: <20100913160619.ECDC12A6C12C@llvm.org> Author: johnny Date: Mon Sep 13 11:06:19 2010 New Revision: 113748 URL: http://llvm.org/viewvc/llvm-project?rev=113748&view=rev Log: Updated the expected matching string after the recent flurry of check ins. Modified: lldb/trunk/test/conditional_break/TestConditionalBreak.py Modified: lldb/trunk/test/conditional_break/TestConditionalBreak.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/conditional_break/TestConditionalBreak.py?rev=113748&r1=113747&r2=113748&view=diff ============================================================================== --- lldb/trunk/test/conditional_break/TestConditionalBreak.py (original) +++ lldb/trunk/test/conditional_break/TestConditionalBreak.py Mon Sep 13 11:06:19 2010 @@ -73,8 +73,8 @@ self.assertTrue(line == 27, "Immediate caller a() at main.c:27") self.expect("thread backtrace", "Call site at a()", substrs = ["main.c:27"]) - self.expect("frame variable", "Passed in arg val of (int) 3", - startstr = "val = (int) 3") + self.expect("frame variable", "Passed in arg (int) val of 3", + startstr = "(int) val = 3") break # This doesn't work? From johnny.chen at apple.com Mon Sep 13 11:14:55 2010 From: johnny.chen at apple.com (Johnny Chen) Date: Mon, 13 Sep 2010 16:14:55 -0000 Subject: [Lldb-commits] [lldb] r113750 - /lldb/trunk/test/bitfields/TestBitfields.py Message-ID: <20100913161455.8F6112A6C12C@llvm.org> Author: johnny Date: Mon Sep 13 11:14:55 2010 New Revision: 113750 URL: http://llvm.org/viewvc/llvm-project?rev=113750&view=rev Log: Removed the two expectedFailure decorators from the test cases. They have been fixed. Modified: lldb/trunk/test/bitfields/TestBitfields.py Modified: lldb/trunk/test/bitfields/TestBitfields.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/bitfields/TestBitfields.py?rev=113750&r1=113749&r2=113750&view=diff ============================================================================== --- lldb/trunk/test/bitfields/TestBitfields.py (original) +++ lldb/trunk/test/bitfields/TestBitfields.py Mon Sep 13 11:14:55 2010 @@ -10,7 +10,6 @@ mydir = "bitfields" @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin") - @unittest2.expectedFailure def test_with_dsym_and_run_command(self): """Test 'frame variable ...' on a variable with bitfields.""" self.buildDsym() @@ -22,7 +21,6 @@ self.buildDsym() self.bitfields_variable_python() - @unittest2.expectedFailure def test_with_dwarf_and_run_command(self): """Test 'frame variable ...' on a variable with bitfields.""" self.buildDwarf() From johnny.chen at apple.com Mon Sep 13 11:19:09 2010 From: johnny.chen at apple.com (Johnny Chen) Date: Mon, 13 Sep 2010 16:19:09 -0000 Subject: [Lldb-commits] [lldb] r113751 - /lldb/trunk/test/unsigned_types/TestUnsignedTypes.py Message-ID: <20100913161909.BD0322A6C12C@llvm.org> Author: johnny Date: Mon Sep 13 11:19:09 2010 New Revision: 113751 URL: http://llvm.org/viewvc/llvm-project?rev=113751&view=rev Log: Updated the expected matching strings. Modified: lldb/trunk/test/unsigned_types/TestUnsignedTypes.py Modified: lldb/trunk/test/unsigned_types/TestUnsignedTypes.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/unsigned_types/TestUnsignedTypes.py?rev=113751&r1=113750&r2=113751&view=diff ============================================================================== --- lldb/trunk/test/unsigned_types/TestUnsignedTypes.py (original) +++ lldb/trunk/test/unsigned_types/TestUnsignedTypes.py Mon Sep 13 11:19:09 2010 @@ -44,12 +44,12 @@ # Test that unsigned types display correctly. self.expect("frame variable -a", VARIABLES_DISPLAYED_CORRECTLY, - startstr = "the_unsigned_char = (unsigned char) 'c'", - substrs = ["the_unsigned_short = (short unsigned int) 0x0063", - "the_unsigned_int = (unsigned int) 0x00000063", - "the_unsigned_long = (long unsigned int) 0x0000000000000063", - "the_unsigned_long_long = (long long unsigned int) 0x0000000000000063", - "the_uint32 = (uint32_t) 0x00000063"]) + startstr = "(unsigned char) the_unsigned_char = 'c'", + substrs = ["(short unsigned int) the_unsigned_short = 0x0063", + "(unsigned int) the_unsigned_int = 0x00000063", + "(long unsigned int) the_unsigned_long = 0x0000000000000063", + "(long long unsigned int) the_unsigned_long_long = 0x0000000000000063", + "(uint32_t) the_uint32 = 0x00000063"]) if __name__ == '__main__': From johnny.chen at apple.com Mon Sep 13 11:31:46 2010 From: johnny.chen at apple.com (Johnny Chen) Date: Mon, 13 Sep 2010 16:31:46 -0000 Subject: [Lldb-commits] [lldb] r113753 - /lldb/trunk/test/set_values/TestSetValues.py Message-ID: <20100913163146.317292A6C12C@llvm.org> Author: johnny Date: Mon Sep 13 11:31:46 2010 New Revision: 113753 URL: http://llvm.org/viewvc/llvm-project?rev=113753&view=rev Log: Updated the expected matching strings, and added a radar comment. Modified: lldb/trunk/test/set_values/TestSetValues.py Modified: lldb/trunk/test/set_values/TestSetValues.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/set_values/TestSetValues.py?rev=113753&r1=113752&r2=113753&view=diff ============================================================================== --- lldb/trunk/test/set_values/TestSetValues.py (original) +++ lldb/trunk/test/set_values/TestSetValues.py Mon Sep 13 11:31:46 2010 @@ -55,7 +55,7 @@ # main.c:15 # Check that 'frame variable' displays the correct data type and value. self.expect("frame variable", VARIABLES_DISPLAYED_CORRECTLY, - startstr = "i = (char) 'a'") + startstr = "(char) i = 'a'") # TODO: # Now set variable 'i' and check that it is correctly displayed. @@ -65,7 +65,7 @@ # main.c:36 # Check that 'frame variable' displays the correct data type and value. self.expect("frame variable", VARIABLES_DISPLAYED_CORRECTLY, - startstr = "i = (short unsigned int) 0x0021") + startstr = "(short unsigned int) i = 0x0021") # TODO: # Now set variable 'i' and check that it is correctly displayed. @@ -75,7 +75,7 @@ # main.c:57 # Check that 'frame variable' displays the correct data type and value. self.expect("frame variable", VARIABLES_DISPLAYED_CORRECTLY, - startstr = "i = (long int) 33") + startstr = "(long int) i = 33") # TODO: # Now set variable 'i' and check that it is correctly displayed. @@ -85,7 +85,7 @@ # main.c:78 # Check that 'frame variable' displays the correct data type and value. self.expect("frame variable", VARIABLES_DISPLAYED_CORRECTLY, - startstr = "i = (double) 3.14159") + startstr = "(double) i = 3.14159") # TODO: # Now set variable 'i' and check that it is correctly displayed. @@ -94,8 +94,10 @@ # main.c:85 # Check that 'frame variable' displays the correct data type and value. + # rdar://problem/8422727 + # set_values test directory: 'frame variable' shows only (long double) i = self.expect("frame variable", VARIABLES_DISPLAYED_CORRECTLY, - startstr = "i = (long double) ") + startstr = "(long double) i = ") # TODO: # Now set variable 'i' and check that it is correctly displayed. From johnny.chen at apple.com Mon Sep 13 11:46:00 2010 From: johnny.chen at apple.com (Johnny Chen) Date: Mon, 13 Sep 2010 16:46:00 -0000 Subject: [Lldb-commits] [lldb] r113755 - /lldb/trunk/test/global_variables/TestGlobalVariables.py Message-ID: <20100913164600.168462A6C12C@llvm.org> Author: johnny Date: Mon Sep 13 11:45:59 2010 New Revision: 113755 URL: http://llvm.org/viewvc/llvm-project?rev=113755&view=rev Log: Updated the expected matching strings. Modified: lldb/trunk/test/global_variables/TestGlobalVariables.py Modified: lldb/trunk/test/global_variables/TestGlobalVariables.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/global_variables/TestGlobalVariables.py?rev=113755&r1=113754&r2=113755&view=diff ============================================================================== --- lldb/trunk/test/global_variables/TestGlobalVariables.py (original) +++ lldb/trunk/test/global_variables/TestGlobalVariables.py Mon Sep 13 11:45:59 2010 @@ -41,12 +41,11 @@ substrs = [' resolved, hit count = 1']) # Check that GLOBAL scopes are indicated for the variables. - self.expect("frame variable -s -a", VARIABLES_DISPLAYED_CORRECTLY, - substrs = ['GLOBAL: g_file_static_cstr', + self.expect("frame variable -s -g -a", VARIABLES_DISPLAYED_CORRECTLY, + substrs = ['GLOBAL: (char const *) g_file_static_cstr', '"g_file_static_cstr"', - 'GLOBAL: g_file_global_int', - '(int) 42', - 'GLOBAL: g_file_global_cstr', + 'GLOBAL: (int) g_file_global_int = 42', + 'GLOBAL: (char const *) g_file_global_cstr', '"g_file_global_cstr"']) From johnny.chen at apple.com Mon Sep 13 11:59:12 2010 From: johnny.chen at apple.com (Johnny Chen) Date: Mon, 13 Sep 2010 16:59:12 -0000 Subject: [Lldb-commits] [lldb] r113756 - /lldb/trunk/test/order/TestOrderFile.py Message-ID: <20100913165912.1D7EF2A6C12C@llvm.org> Author: johnny Date: Mon Sep 13 11:59:11 2010 New Revision: 113756 URL: http://llvm.org/viewvc/llvm-project?rev=113756&view=rev Log: Updated the expected matching strings. 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=113756&r1=113755&r2=113756&view=diff ============================================================================== --- lldb/trunk/test/order/TestOrderFile.py (original) +++ lldb/trunk/test/order/TestOrderFile.py Mon Sep 13 11:59:11 2010 @@ -20,8 +20,8 @@ # Test that the debug symbols have Function f3 before Function f1. self.runCmd("image dump symtab a.out") output = self.res.GetOutput() - mo_f3 = re.search("Function +.+f3", output) - mo_f1 = re.search("Function +.+f1", output) + mo_f3 = re.search("Code +.+f3", output) + mo_f1 = re.search("Code +.+f1", output) # Match objects for f3 and f1 must exist and f3 must come before f1. self.assertTrue(mo_f3 and mo_f1 and mo_f3.start() < mo_f1.start(), From johnny.chen at apple.com Mon Sep 13 15:54:30 2010 From: johnny.chen at apple.com (Johnny Chen) Date: Mon, 13 Sep 2010 20:54:30 -0000 Subject: [Lldb-commits] [lldb] r113781 - in /lldb/trunk/test: lldbtest.py make/Makefile.rules plugins/darwin.py Message-ID: <20100913205430.4C2EF2A6C12C@llvm.org> Author: johnny Date: Mon Sep 13 15:54:30 2010 New Revision: 113781 URL: http://llvm.org/viewvc/llvm-project?rev=113781&view=rev Log: Extend the build mechanism to allow for specifying the compiler used to build the binaries. If the build* function is passed the compiler argument, for example, 'llvm-gcc', it is passed as a make variable to the make command. Otherwise, we check the LLDB_CC environment variable; if it is defined, it is passed as a make variable to the make command. If neither the compiler keyword argument nor the LLDB_CC environment variable is specified, no CC make variable is passed to the make command. The Makefile gets to define the default CC being used. -------------------------------------------------------------------------------- Example usage follows: o Via the keyword argument: class ArrayTypesTestCase(TestBase): mydir = "array_types" @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin") def test_with_dsym_and_run_command(self): """Test 'frame variable var_name' on some variables with array types.""" self.buildDsym(compiler='llvm-gcc') self.array_types() ... o Via LLDB_CC environment variable: $ LLDB_CC=llvm-gcc ./dotest.py -v -t array_types ---------------------------------------------------------------------- Collected 4 tests test_with_dsym_and_python_api (TestArrayTypes.ArrayTypesTestCase) Use Python APIs to inspect variables with array types. ... os command: [['/bin/sh', '-c', 'make clean; make MAKE_DSYM=YES CC=llvm-gcc']] output: rm -rf "a.out" "a.out.dSYM" main.o main.d llvm-gcc -arch x86_64 -gdwarf-2 -O0 -arch x86_64 -gdwarf-2 -O0 -c -o main.o main.c llvm-gcc -arch x86_64 -gdwarf-2 -O0 main.o -o "a.out" /usr/bin/dsymutil -o "a.out.dSYM" "a.out" ... Modified: lldb/trunk/test/lldbtest.py lldb/trunk/test/make/Makefile.rules lldb/trunk/test/plugins/darwin.py Modified: lldb/trunk/test/lldbtest.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/lldbtest.py?rev=113781&r1=113780&r2=113781&view=diff ============================================================================== --- lldb/trunk/test/lldbtest.py (original) +++ lldb/trunk/test/lldbtest.py Mon Sep 13 15:54:30 2010 @@ -460,22 +460,22 @@ # End of while loop. - def buildDefault(self): + def buildDefault(self, compiler=None): """Platform specific way to build the default binaries.""" module = __import__(sys.platform) - if not module.buildDefault(): + if not module.buildDefault(compiler): raise Exception("Don't know how to build default binary") - def buildDsym(self): + def buildDsym(self, compiler=None): """Platform specific way to build binaries with dsym info.""" module = __import__(sys.platform) - if not module.buildDsym(): + if not module.buildDsym(compiler): raise Exception("Don't know how to build binary with dsym") - def buildDwarf(self): + def buildDwarf(self, compiler=None): """Platform specific way to build binaries with dwarf maps.""" module = __import__(sys.platform) - if not module.buildDwarf(): + if not module.buildDwarf(compiler): raise Exception("Don't know how to build binary with dwarf") def DebugSBValue(self, frame, val): Modified: lldb/trunk/test/make/Makefile.rules URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/make/Makefile.rules?rev=113781&r1=113780&r2=113781&view=diff ============================================================================== --- lldb/trunk/test/make/Makefile.rules (original) +++ lldb/trunk/test/make/Makefile.rules Mon Sep 13 15:54:30 2010 @@ -19,7 +19,7 @@ CFLAGS ?=-arch x86_64 -gdwarf-2 -O0 CPLUSPLUSFLAGS +=$(CFLAGS) CPPFLAGS +=$(CFLAGS) -LD = gcc +LD = $(CC) LDFLAGS ?= $(CFLAGS) OBJECTS = EXE = a.out Modified: lldb/trunk/test/plugins/darwin.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/plugins/darwin.py?rev=113781&r1=113780&r2=113781&view=diff ============================================================================== --- lldb/trunk/test/plugins/darwin.py (original) +++ lldb/trunk/test/plugins/darwin.py Mon Sep 13 15:54:30 2010 @@ -1,21 +1,52 @@ +""" +If the build* function is passed the compiler argument, for example, 'llvm-gcc', +it is passed as a make variable to the make command. Otherwise, we check the +LLDB_CC environment variable; if it is defined, it is passed as a make variable +to the make command. + +If neither the compiler keyword argument nor the LLDB_CC environment variable is +specified, no CC make variable is passed to the make command. The Makefile gets +to define the default CC being used. +""" + +import os import lldbtest #print "Hello, darwin plugin!" -def buildDefault(): - lldbtest.system(["/bin/sh", "-c", "make clean; make"]) +def getCCSpec(compiler): + """ + Helper function to return the key-value pair string to specify the compiler + used for the make system. + """ + cc = compiler if compiler else None + if not cc and "LLDB_CC" in os.environ: + cc = os.environ["LLDB_CC"] + + # Note the leading space character. + return (" CC=" + cc) if cc else "" + + +def buildDefault(compiler=None): + """Build the binaries the default way.""" + lldbtest.system(["/bin/sh", "-c", + "make clean; make" + getCCSpec(compiler)]) # True signifies that we can handle building default. return True -def buildDsym(): - lldbtest.system(["/bin/sh", "-c", "make clean; make MAKE_DSYM=YES"]) +def buildDsym(compiler=None): + """Build the binaries with dsym debug info.""" + lldbtest.system(["/bin/sh", "-c", + "make clean; make MAKE_DSYM=YES" + getCCSpec(compiler)]) # True signifies that we can handle building dsym. return True -def buildDwarf(): - lldbtest.system(["/bin/sh", "-c", "make clean; make MAKE_DSYM=NO"]) +def buildDwarf(compiler=None): + """Build the binaries with dwarf debug info.""" + lldbtest.system(["/bin/sh", "-c", + "make clean; make MAKE_DSYM=NO" + getCCSpec(compiler)]) # True signifies that we can handle building dsym. return True From scallanan at apple.com Mon Sep 13 16:34:22 2010 From: scallanan at apple.com (Sean Callanan) Date: Mon, 13 Sep 2010 21:34:22 -0000 Subject: [Lldb-commits] [lldb] r113789 - in /lldb/trunk: include/lldb/Expression/ source/Commands/ source/Expression/ Message-ID: <20100913213422.4D4952A6C12C@llvm.org> Author: spyffe Date: Mon Sep 13 16:34:21 2010 New Revision: 113789 URL: http://llvm.org/viewvc/llvm-project?rev=113789&view=rev Log: Bugfixes to the expression parser. Fixes include: - If you put a semicolon at the end of an expression, this no longer causes the expression parser to error out. This was a two-part fix: first, ClangExpressionDeclMap::Materialize now handles an empty struct (such as when there is no return value); second, ASTResultSynthesizer walks backward from the end of the ASTs until it reaches something that's not a NullStmt. - ClangExpressionVariable now properly byte-swaps when printing itself. - ClangUtilityFunction now cleans up after itself when it's done compiling itself. - Utility functions can now use external functions just like user expressions. - If you end your expression with a statement that does not return a value, the expression now runs correctly anyway. Also, added the beginnings of an Objective-C object validator function, which is neither installed nor used as yet. Modified: lldb/trunk/include/lldb/Expression/ClangExpression.h lldb/trunk/include/lldb/Expression/ClangFunction.h lldb/trunk/include/lldb/Expression/ClangUserExpression.h lldb/trunk/include/lldb/Expression/ClangUtilityFunction.h lldb/trunk/include/lldb/Expression/IRDynamicChecks.h lldb/trunk/include/lldb/Expression/IRForTarget.h lldb/trunk/source/Commands/CommandObjectExpression.cpp lldb/trunk/source/Expression/ASTResultSynthesizer.cpp lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp lldb/trunk/source/Expression/ClangExpressionParser.cpp lldb/trunk/source/Expression/ClangExpressionVariable.cpp lldb/trunk/source/Expression/ClangUserExpression.cpp lldb/trunk/source/Expression/ClangUtilityFunction.cpp lldb/trunk/source/Expression/IRDynamicChecks.cpp lldb/trunk/source/Expression/IRForTarget.cpp Modified: lldb/trunk/include/lldb/Expression/ClangExpression.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Expression/ClangExpression.h?rev=113789&r1=113788&r2=113789&view=diff ============================================================================== --- lldb/trunk/include/lldb/Expression/ClangExpression.h (original) +++ lldb/trunk/include/lldb/Expression/ClangExpression.h Mon Sep 13 16:34:21 2010 @@ -94,6 +94,24 @@ //------------------------------------------------------------------ virtual StreamString & DwarfOpcodeStream () = 0; + + //------------------------------------------------------------------ + /// Flags + //------------------------------------------------------------------ + + //------------------------------------------------------------------ + /// Return true if validation code should be inserted into the + /// expression. + //------------------------------------------------------------------ + virtual bool + NeedsValidation () = 0; + + //------------------------------------------------------------------ + /// Return true if external variables in the expression should be + /// resolved. + //------------------------------------------------------------------ + virtual bool + NeedsVariableResolution () = 0; }; } // namespace lldb_private Modified: lldb/trunk/include/lldb/Expression/ClangFunction.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Expression/ClangFunction.h?rev=113789&r1=113788&r2=113789&view=diff ============================================================================== --- lldb/trunk/include/lldb/Expression/ClangFunction.h (original) +++ lldb/trunk/include/lldb/Expression/ClangFunction.h Mon Sep 13 16:34:21 2010 @@ -564,6 +564,26 @@ return *((StreamString*)0); } + //------------------------------------------------------------------ + /// Return true if validation code should be inserted into the + /// expression. + //------------------------------------------------------------------ + bool + NeedsValidation () + { + return false; + } + + //------------------------------------------------------------------ + /// Return true if external variables in the expression should be + /// resolved. + //------------------------------------------------------------------ + bool + NeedsVariableResolution () + { + return false; + } + private: //------------------------------------------------------------------ // For ClangFunction only Modified: lldb/trunk/include/lldb/Expression/ClangUserExpression.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Expression/ClangUserExpression.h?rev=113789&r1=113788&r2=113789&view=diff ============================================================================== --- lldb/trunk/include/lldb/Expression/ClangUserExpression.h (original) +++ lldb/trunk/include/lldb/Expression/ClangUserExpression.h Mon Sep 13 16:34:21 2010 @@ -149,6 +149,26 @@ //------------------------------------------------------------------ StreamString & DwarfOpcodeStream (); + + //------------------------------------------------------------------ + /// Return true if validation code should be inserted into the + /// expression. + //------------------------------------------------------------------ + bool + NeedsValidation () + { + return true; + } + + //------------------------------------------------------------------ + /// Return true if external variables in the expression should be + /// resolved. + //------------------------------------------------------------------ + bool + NeedsVariableResolution () + { + return true; + } private: std::string m_expr_text; ///< The text of the expression, as typed by the user Modified: lldb/trunk/include/lldb/Expression/ClangUtilityFunction.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Expression/ClangUtilityFunction.h?rev=113789&r1=113788&r2=113789&view=diff ============================================================================== --- lldb/trunk/include/lldb/Expression/ClangUtilityFunction.h (original) +++ lldb/trunk/include/lldb/Expression/ClangUtilityFunction.h Mon Sep 13 16:34:21 2010 @@ -126,7 +126,7 @@ ClangExpressionDeclMap * DeclMap () { - return NULL; + return m_expr_decl_map.get(); } //------------------------------------------------------------------ @@ -163,12 +163,34 @@ return *((StreamString*)NULL); } + //------------------------------------------------------------------ + /// Return true if validation code should be inserted into the + /// expression. + //------------------------------------------------------------------ + bool + NeedsValidation () + { + return false; + } + + //------------------------------------------------------------------ + /// Return true if external variables in the expression should be + /// resolved. + //------------------------------------------------------------------ + bool + NeedsVariableResolution () + { + return false; + } + private: - std::string m_function_text; ///< The text of the function. Must be a well-formed translation unit. - std::string m_function_name; ///< The name of the function. + std::auto_ptr m_expr_decl_map; ///< The map to use when parsing and materializing the expression. + + std::string m_function_text; ///< The text of the function. Must be a well-formed translation unit. + std::string m_function_name; ///< The name of the function. - lldb::addr_t m_jit_begin; ///< The address of the JITted code. LLDB_INVALID_ADDRESS if invalid. - lldb::addr_t m_jit_end; ///< The end of the JITted code. LLDB_INVALID_ADDRESS if invalid. + lldb::addr_t m_jit_begin; ///< The address of the JITted code. LLDB_INVALID_ADDRESS if invalid. + lldb::addr_t m_jit_end; ///< The end of the JITted code. LLDB_INVALID_ADDRESS if invalid. }; } // namespace lldb_private Modified: lldb/trunk/include/lldb/Expression/IRDynamicChecks.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Expression/IRDynamicChecks.h?rev=113789&r1=113788&r2=113789&view=diff ============================================================================== --- lldb/trunk/include/lldb/Expression/IRDynamicChecks.h (original) +++ lldb/trunk/include/lldb/Expression/IRDynamicChecks.h Mon Sep 13 16:34:21 2010 @@ -75,6 +75,7 @@ ExecutionContext &exe_ctx); std::auto_ptr m_valid_pointer_check; + std::auto_ptr m_objc_object_check; }; //---------------------------------------------------------------------- @@ -99,6 +100,10 @@ /// /// @param[in] func_name /// The name of the function to prepare for execution in the target. + /// + /// @param[in] decl_map + /// The mapping used to look up entities in the target process. In + /// this case, used to find objc_msgSend //------------------------------------------------------------------ IRDynamicChecks(DynamicCheckerFunctions &checker_functions, const char* func_name = "___clang_expr"); Modified: lldb/trunk/include/lldb/Expression/IRForTarget.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Expression/IRForTarget.h?rev=113789&r1=113788&r2=113789&view=diff ============================================================================== --- lldb/trunk/include/lldb/Expression/IRForTarget.h (original) +++ lldb/trunk/include/lldb/Expression/IRForTarget.h Mon Sep 13 16:34:21 2010 @@ -59,9 +59,15 @@ /// /// @param[in] func_name /// The name of the function to prepare for execution in the target. + /// + /// @param[in] resolve_vars + /// True if the external variable references (including persistent + /// variables) should be resolved. If not, only external functions + /// are resolved. //------------------------------------------------------------------ IRForTarget(lldb_private::ClangExpressionDeclMap *decl_map, const llvm::TargetData *target_data, + bool resolve_vars, const char* func_name = "___clang_expr"); //------------------------------------------------------------------ @@ -294,10 +300,13 @@ bool replaceVariables(llvm::Module &M, llvm::Function &F); - std::string m_func_name; ///< The name of the function to translate - lldb_private::ClangExpressionDeclMap *m_decl_map; ///< The DeclMap containing the Decls - const llvm::TargetData *m_target_data; ///< The TargetData for use in determining type sizes - llvm::Constant *m_sel_registerName; ///< The address of the function sel_registerName, cast to the appropriate function pointer type + /// Flags + bool m_resolve_vars; ///< True if external variable references and persistent variable references should be resolved + + std::string m_func_name; ///< The name of the function to translate + lldb_private::ClangExpressionDeclMap *m_decl_map; ///< The DeclMap containing the Decls + const llvm::TargetData *m_target_data; ///< The TargetData for use in determining type sizes + llvm::Constant *m_sel_registerName; ///< The address of the function sel_registerName, cast to the appropriate function pointer type }; #endif Modified: lldb/trunk/source/Commands/CommandObjectExpression.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectExpression.cpp?rev=113789&r1=113788&r2=113789&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectExpression.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectExpression.cpp Mon Sep 13 16:34:21 2010 @@ -219,7 +219,7 @@ return false; } - ClangExpressionVariable *expr_result; + ClangExpressionVariable *expr_result = NULL; if (!user_expression.Execute (error_stream, m_exe_ctx, expr_result)) { @@ -249,7 +249,6 @@ } else { - error_stream.Printf ("Expression produced no result\n"); if (result) result->SetStatus (eReturnStatusSuccessFinishNoResult); } Modified: lldb/trunk/source/Expression/ASTResultSynthesizer.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/ASTResultSynthesizer.cpp?rev=113789&r1=113788&r2=113789&view=diff ============================================================================== --- lldb/trunk/source/Expression/ASTResultSynthesizer.cpp (original) +++ lldb/trunk/source/Expression/ASTResultSynthesizer.cpp Mon Sep 13 16:34:21 2010 @@ -113,6 +113,18 @@ if (!function_decl) return false; + if (log) + { + std::string s; + raw_string_ostream os(s); + + function_decl->print(os); + + os.flush(); + + log->Printf("Function AST before transforming:\n%s", s.c_str()); + } + Stmt *function_body = function_decl->getBody(); CompoundStmt *compound_stmt = dyn_cast(function_body); @@ -125,6 +137,15 @@ Stmt **last_stmt_ptr = compound_stmt->body_end() - 1; Stmt *last_stmt = *last_stmt_ptr; + while (dyn_cast(last_stmt)) + { + if (last_stmt_ptr != compound_stmt->body_begin()) + { + last_stmt_ptr--; + last_stmt = *last_stmt_ptr; + } + } + Expr *last_expr = dyn_cast(last_stmt); if (!last_expr) Modified: lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp?rev=113789&r1=113788&r2=113789&view=diff ============================================================================== --- lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp (original) +++ lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp Mon Sep 13 16:34:21 2010 @@ -401,6 +401,16 @@ return LLDB_INVALID_ADDRESS; } + if (!m_struct_size) + { + if (log) + log->PutCString("Not bothering to allocate a struct because no arguments are needed"); + + m_allocated_area = NULL; + + return true; + } + const SymbolContext &sym_ctx(exe_ctx->frame->GetSymbolContext(lldb::eSymbolContextEverything)); if (!dematerialize) Modified: lldb/trunk/source/Expression/ClangExpressionParser.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/ClangExpressionParser.cpp?rev=113789&r1=113788&r2=113789&view=diff ============================================================================== --- lldb/trunk/source/Expression/ClangExpressionParser.cpp (original) +++ lldb/trunk/source/Expression/ClangExpressionParser.cpp Mon Sep 13 16:34:21 2010 @@ -403,7 +403,10 @@ std::auto_ptr target_machine(target->createTargetMachine(m_target_triple, "")); - IRForTarget ir_for_target(decl_map, target_machine->getTargetData(), m_expr.FunctionName()); + IRForTarget ir_for_target(decl_map, + target_machine->getTargetData(), + m_expr.NeedsVariableResolution(), + m_expr.FunctionName()); if (!ir_for_target.runOnModule(*module)) { @@ -412,14 +415,17 @@ return err; } - IRDynamicChecks ir_dynamic_checks(*exe_ctx.process->GetDynamicCheckers(), m_expr.FunctionName()); - - if (!ir_dynamic_checks.runOnModule(*module)) + if (m_expr.NeedsValidation()) { - err.SetErrorToGenericError(); - err.SetErrorString("Couldn't add dynamic checks to the expression"); - return err; - } + IRDynamicChecks ir_dynamic_checks(*exe_ctx.process->GetDynamicCheckers(), m_expr.FunctionName()); + + if (!ir_dynamic_checks.runOnModule(*module)) + { + err.SetErrorToGenericError(); + err.SetErrorString("Couldn't add dynamic checks to the expression"); + return err; + } + } } m_jit_mm = new RecordingMemoryManager(); Modified: lldb/trunk/source/Expression/ClangExpressionVariable.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/ClangExpressionVariable.cpp?rev=113789&r1=113788&r2=113789&view=diff ============================================================================== --- lldb/trunk/source/Expression/ClangExpressionVariable.cpp (original) +++ lldb/trunk/source/Expression/ClangExpressionVariable.cpp Mon Sep 13 16:34:21 2010 @@ -18,6 +18,8 @@ #include "lldb/Core/DataExtractor.h" #include "lldb/Core/Stream.h" #include "lldb/Core/Value.h" +#include "lldb/Target/ExecutionContext.h" +#include "lldb/Target/Process.h" using namespace lldb_private; using namespace clang; @@ -79,6 +81,12 @@ DataExtractor data; Error expr_error = val.GetValueAsData (&exe_ctx, ast_context, data, 0); + + // Set byte order and pointer size to TARGET byte order and pointer size! + + data.SetByteOrder(exe_ctx.process->GetByteOrder()); + data.SetAddressByteSize(exe_ctx.process->GetAddressByteSize()); + if (!expr_error.Success ()) { err.SetErrorToGenericError (); Modified: lldb/trunk/source/Expression/ClangUserExpression.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/ClangUserExpression.cpp?rev=113789&r1=113788&r2=113789&view=diff ============================================================================== --- lldb/trunk/source/Expression/ClangUserExpression.cpp (original) +++ lldb/trunk/source/Expression/ClangUserExpression.cpp Mon Sep 13 16:34:21 2010 @@ -196,13 +196,16 @@ Error dump_error; - if (!m_expr_decl_map->DumpMaterializedStruct(&exe_ctx, args, dump_error)) + if (struct_address) { - log->Printf("Couldn't extract variable values : %s", dump_error.AsCString("unknown error")); - } - else - { - log->Printf("Structure contents:\n%s", args.GetData()); + if (!m_expr_decl_map->DumpMaterializedStruct(&exe_ctx, args, dump_error)) + { + log->Printf("Couldn't extract variable values : %s", dump_error.AsCString("unknown error")); + } + else + { + log->Printf("Structure contents:\n%s", args.GetData()); + } } } Modified: lldb/trunk/source/Expression/ClangUtilityFunction.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/ClangUtilityFunction.cpp?rev=113789&r1=113788&r2=113789&view=diff ============================================================================== --- lldb/trunk/source/Expression/ClangUtilityFunction.cpp (original) +++ lldb/trunk/source/Expression/ClangUtilityFunction.cpp Mon Sep 13 16:34:21 2010 @@ -17,6 +17,7 @@ #include "lldb/Core/ConstString.h" #include "lldb/Core/Stream.h" +#include "lldb/Expression/ClangExpressionDeclMap.h" #include "lldb/Expression/ClangExpressionParser.h" #include "lldb/Expression/ClangUtilityFunction.h" #include "lldb/Host/Host.h" @@ -93,6 +94,8 @@ ////////////////////////// // Parse the expression // + + m_expr_decl_map.reset(new ClangExpressionDeclMap(&exe_ctx)); ClangExpressionParser parser(target_triple.GetCString(), *this); @@ -101,6 +104,9 @@ if (num_errors) { error_stream.Printf ("error: %d errors parsing expression\n", num_errors); + + m_expr_decl_map.reset(); + return false; } @@ -110,6 +116,8 @@ Error jit_error = parser.MakeJIT (m_jit_begin, m_jit_end, exe_ctx); + m_expr_decl_map.reset(); + if (jit_error.Success()) { return true; Modified: lldb/trunk/source/Expression/IRDynamicChecks.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/IRDynamicChecks.cpp?rev=113789&r1=113788&r2=113789&view=diff ============================================================================== --- lldb/trunk/source/Expression/IRDynamicChecks.cpp (original) +++ lldb/trunk/source/Expression/IRDynamicChecks.cpp Mon Sep 13 16:34:21 2010 @@ -8,9 +8,12 @@ //===----------------------------------------------------------------------===// #include "lldb/Expression/IRDynamicChecks.h" -#include "lldb/Expression/ClangUtilityFunction.h" +#include "lldb/Core/ConstString.h" #include "lldb/Core/Log.h" +#include "lldb/Expression/ClangUtilityFunction.h" +#include "lldb/Target/ExecutionContext.h" +#include "lldb/Target/StackFrame.h" #include "llvm/Support/raw_ostream.h" #include "llvm/Function.h" @@ -23,6 +26,9 @@ static char ID; +static const char valid_pointer_check_name[] = +"___clang_valid_pointer_check"; + static const char valid_pointer_check_text[] = "extern \"C\" void " "___clang_valid_pointer_check (unsigned char *ptr)" @@ -30,13 +36,57 @@ "unsigned char val = *ptr;" "}"; -static const char valid_pointer_check_name[] = - "___clang_valid_pointer_check"; +static const char objc_object_check_name[] = + "___clang_objc_object_check"; + +static bool FunctionExists(const SymbolContext &sym_ctx, const char *name) +{ + ConstString name_cs(name); + + SymbolContextList sym_ctxs; + + sym_ctx.FindFunctionsByName(name_cs, false, sym_ctxs); + + return (sym_ctxs.GetSize() != 0); +} + +static const char *objc_object_check_text(ExecutionContext &exe_ctx) +{ + std::string ret; + + if (!exe_ctx.frame) + return "extern \"C\" void ___clang_objc_object_check (unsigned char *obj) { }"; + + const SymbolContext &sym_ctx(exe_ctx.frame->GetSymbolContext(lldb::eSymbolContextEverything)); + + if (FunctionExists(sym_ctx, "gdb_object_getClass")) + { + return "extern \"C\" void " + "___clang_objc_object_check(uint8_t *obj)" + "{" + "" + "}"; + } + else if (FunctionExists(sym_ctx, "gdb_class_getClass")) + { + return "extern \"C\" void " + "___clang_objc_object_check(uint8_t *obj)" + "{" + "" + "}"; + } + else + { + return "extern \"C\" void " + "___clang_objc_object_check(uint8_t *obj)" + "{" + "" + "}"; + } +} DynamicCheckerFunctions::DynamicCheckerFunctions () { - m_valid_pointer_check.reset(new ClangUtilityFunction(valid_pointer_check_text, - valid_pointer_check_name)); } DynamicCheckerFunctions::~DynamicCheckerFunctions () @@ -47,6 +97,9 @@ DynamicCheckerFunctions::Install(Stream &error_stream, ExecutionContext &exe_ctx) { + m_valid_pointer_check.reset(new ClangUtilityFunction(valid_pointer_check_text, + valid_pointer_check_name)); + if (!m_valid_pointer_check->Install(error_stream, exe_ctx)) return false; @@ -104,7 +157,8 @@ Instrumenter (llvm::Module &module, DynamicCheckerFunctions &checker_functions) : m_module(module), - m_checker_functions(checker_functions) + m_checker_functions(checker_functions), + m_i8ptr_ty(NULL) { } @@ -222,12 +276,42 @@ return true; } + //------------------------------------------------------------------ + /// Build a function pointer for a function with signature + /// void (*)(uint8_t*) with a given address + /// + /// @param[in] start_address + /// The address of the function. + /// + /// @return + /// The function pointer, for use in a CallInst. + //------------------------------------------------------------------ + llvm::Value *BuildPointerValidatorFunc(lldb::addr_t start_address) + { + std::vector params; + + const IntegerType *intptr_ty = llvm::Type::getIntNTy(m_module.getContext(), + (m_module.getPointerSize() == llvm::Module::Pointer64) ? 64 : 32); + + if (!m_i8ptr_ty) + m_i8ptr_ty = llvm::Type::getInt8PtrTy(m_module.getContext()); + + params.push_back(m_i8ptr_ty); + + FunctionType *fun_ty = FunctionType::get(llvm::Type::getVoidTy(m_module.getContext()), params, true); + PointerType *fun_ptr_ty = PointerType::getUnqual(fun_ty); + Constant *fun_addr_int = ConstantInt::get(intptr_ty, start_address, false); + return ConstantExpr::getIntToPtr(fun_addr_int, fun_ptr_ty); + } + typedef std::vector InstVector; typedef InstVector::iterator InstIterator; InstVector m_to_instrument; ///< List of instructions the inspector found llvm::Module &m_module; ///< The module which is being instrumented DynamicCheckerFunctions &m_checker_functions; ///< The dynamic checker functions for the process + + const PointerType *m_i8ptr_ty; }; class ValidPointerChecker : public Instrumenter @@ -249,21 +333,7 @@ PrintValue(inst).c_str()); if (!m_valid_pointer_check_func) - { - std::vector params; - - const IntegerType *intptr_ty = llvm::Type::getIntNTy(m_module.getContext(), - (m_module.getPointerSize() == llvm::Module::Pointer64) ? 64 : 32); - - m_i8ptr_ty = llvm::Type::getInt8PtrTy(m_module.getContext()); - - params.push_back(m_i8ptr_ty); - - FunctionType *fun_ty = FunctionType::get(llvm::Type::getVoidTy(m_module.getContext()), params, true); - PointerType *fun_ptr_ty = PointerType::getUnqual(fun_ty); - Constant *fun_addr_int = ConstantInt::get(intptr_ty, m_checker_functions.m_valid_pointer_check->StartAddress(), false); - m_valid_pointer_check_func = ConstantExpr::getIntToPtr(fun_addr_int, fun_ptr_ty); - } + m_valid_pointer_check_func = BuildPointerValidatorFunc(m_checker_functions.m_valid_pointer_check->StartAddress()); llvm::Value *dereferenced_ptr; @@ -305,6 +375,104 @@ } llvm::Value *m_valid_pointer_check_func; +}; + +class ObjcObjectChecker : public Instrumenter +{ +public: + ObjcObjectChecker(llvm::Module &module, + DynamicCheckerFunctions &checker_functions) : + Instrumenter(module, checker_functions), + m_objc_object_check_func(NULL) + { + } +private: + bool InstrumentInstruction(llvm::Instruction *inst) + { + CallInst *call_inst = dyn_cast(inst); + + if (!call_inst) + return false; // this really should be true, because otherwise InspectInstruction wouldn't have registered it + + if (!m_objc_object_check_func) + m_objc_object_check_func = BuildPointerValidatorFunc(m_checker_functions.m_objc_object_check->StartAddress()); + + llvm::Value *target_object; + + // id objc_msgSend(id theReceiver, SEL theSelector, ...) + + target_object = call_inst->getArgOperand(0); + + // Insert an instruction to cast the receiver id to int8_t* + + BitCastInst *bit_cast = new BitCastInst(target_object, + m_i8ptr_ty, + "", + inst); + + // Insert an instruction to call the helper with the result + + SmallVector args; + args.push_back(bit_cast); + + CallInst::Create(m_objc_object_check_func, + args.begin(), + args.end(), + "", + inst); + + return true; + } + + bool InspectInstruction(llvm::Instruction &i) + { + lldb_private::Log *log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS); + + CallInst *call_inst = dyn_cast(&i); + + if (call_inst) + { + // This metadata is set by IRForTarget::MaybeHandleCall(). + + MDNode *metadata = call_inst->getMetadata("lldb.call.realName"); + + if (!metadata) + return true; + + if (metadata->getNumOperands() != 1) + { + if (log) + log->Printf("Function call metadata has %d operands for [%p] %s", metadata->getNumOperands(), call_inst, PrintValue(call_inst).c_str()); + return false; + } + + ConstantArray *real_name = dyn_cast(metadata->getOperand(0)); + + if (!real_name) + { + if (log) + log->Printf("Function call metadata is not a ConstantArray for [%p] %s", call_inst, PrintValue(call_inst).c_str()); + return false; + } + + if (!real_name->isString()) + { + if (log) + log->Printf("Function call metadata is not a string for [%p] %s", call_inst, PrintValue(call_inst).c_str()); + return false; + } + + if (log) + log->Printf("Found call to %s: %s\n", real_name->getAsString().c_str(), PrintValue(call_inst).c_str()); + + if (real_name->getAsString().find("objc_msgSend") != std::string::npos) + RegisterInstruction(i); + } + + return true; + } + + llvm::Value *m_objc_object_check_func; const PointerType *m_i8ptr_ty; }; @@ -343,6 +511,16 @@ if (!vpc.Instrument()) return false; + /* + ObjcObjectChecker ooc(M, m_checker_functions); + + if (!ooc.Inspect(*function)) + return false; + + if (!ooc.Instrument()) + return false; + */ + if (log) { std::string s; Modified: lldb/trunk/source/Expression/IRForTarget.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/IRForTarget.cpp?rev=113789&r1=113788&r2=113789&view=diff ============================================================================== --- lldb/trunk/source/Expression/IRForTarget.cpp (original) +++ lldb/trunk/source/Expression/IRForTarget.cpp Mon Sep 13 16:34:21 2010 @@ -32,12 +32,14 @@ IRForTarget::IRForTarget(lldb_private::ClangExpressionDeclMap *decl_map, const TargetData *target_data, + bool resolve_vars, const char *func_name) : ModulePass(&ID), m_decl_map(decl_map), m_target_data(target_data), m_sel_registerName(NULL), - m_func_name(func_name) + m_func_name(func_name), + m_resolve_vars(resolve_vars) { } @@ -65,7 +67,10 @@ { lldb_private::Log *log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS); - // Find the result variable + if (!m_resolve_vars) + return true; + + // Find the result variable. If it doesn't exist, we can give up right here. Value *result_value = M.getNamedValue("___clang_expr_result"); @@ -73,9 +78,10 @@ { if (log) log->PutCString("Couldn't find result variable"); - return false; + + return true; } - + if (log) log->Printf("Found result in the IR: %s", PrintValue(result_value, false).c_str()); @@ -429,6 +435,9 @@ IRForTarget::rewritePersistentAllocs(llvm::Module &M, llvm::BasicBlock &BB) { + if (!m_resolve_vars) + return true; + lldb_private::Log *log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS); BasicBlock::iterator ii; @@ -649,6 +658,17 @@ C->setCalledFunction(fun_addr_ptr); + ConstantArray *func_name = (ConstantArray*)ConstantArray::get(M.getContext(), fun->getName()); + + Value *values[1]; + values[0] = func_name; + MDNode *func_metadata = MDNode::get(M.getContext(), values, 1); + + C->setMetadata("lldb.call.realName", func_metadata); + + if (log) + log->Printf("Set metadata for %p [%d, %s]", C, func_name->isString(), func_name->getAsString().c_str()); + return true; } @@ -667,13 +687,16 @@ { Instruction &inst = *ii; - if (LoadInst *load = dyn_cast(&inst)) - if (!MaybeHandleVariable(M, load->getPointerOperand(), false)) - return false; + if (m_resolve_vars) + { + if (LoadInst *load = dyn_cast(&inst)) + if (!MaybeHandleVariable(M, load->getPointerOperand(), false)) + return false; - if (StoreInst *store = dyn_cast(&inst)) - if (!MaybeHandleVariable(M, store->getPointerOperand(), true)) - return false; + if (StoreInst *store = dyn_cast(&inst)) + if (!MaybeHandleVariable(M, store->getPointerOperand(), true)) + return false; + } if (CallInst *call = dyn_cast(&inst)) if (!MaybeHandleCall(M, call)) @@ -886,6 +909,9 @@ bool IRForTarget::replaceVariables(Module &M, Function &F) { + if (!m_resolve_vars) + return true; + lldb_private::Log *log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS); m_decl_map->DoStructLayout(); From johnny.chen at apple.com Mon Sep 13 19:53:54 2010 From: johnny.chen at apple.com (Johnny Chen) Date: Tue, 14 Sep 2010 00:53:54 -0000 Subject: [Lldb-commits] [lldb] r113825 - in /lldb/trunk: source/Commands/CommandObjectThread.cpp source/Core/Debugger.cpp test/stl/TestSTL.py Message-ID: <20100914005354.1424D2A6C12C@llvm.org> Author: johnny Date: Mon Sep 13 19:53:53 2010 New Revision: 113825 URL: http://llvm.org/viewvc/llvm-project?rev=113825&view=rev Log: Fixed an error in Debugger::UpdateExecutionContext() where an invalid index ID 0 was used to set the selected thread if none was selected. Use a more robust API to accomplish the task. Also fixed an error found, while investigating, in CommandObjectThreadSelect:: Execute() where the return status was not properly set if successful. As a result, both the stl step-in test cases with expectedFailure decorators now passed. Modified: lldb/trunk/source/Commands/CommandObjectThread.cpp lldb/trunk/source/Core/Debugger.cpp lldb/trunk/test/stl/TestSTL.py Modified: lldb/trunk/source/Commands/CommandObjectThread.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectThread.cpp?rev=113825&r1=113824&r2=113825&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectThread.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectThread.cpp Mon Sep 13 19:53:53 2010 @@ -1280,6 +1280,7 @@ } process->GetThreadList().SetSelectedThreadByID(new_thread->GetID()); + result.SetStatus (eReturnStatusSuccessFinishNoResult); DisplayThreadInfo (interpreter, result.GetOutputStream(), Modified: lldb/trunk/source/Core/Debugger.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/Debugger.cpp?rev=113825&r1=113824&r2=113825&view=diff ============================================================================== --- lldb/trunk/source/Core/Debugger.cpp (original) +++ lldb/trunk/source/Core/Debugger.cpp Mon Sep 13 19:53:53 2010 @@ -507,7 +507,7 @@ m_exe_ctx.thread = m_exe_ctx.process->GetThreadList().GetThreadAtIndex(0).get(); // If we didn't have a selected thread, select one here. if (m_exe_ctx.thread != NULL) - m_exe_ctx.process->GetThreadList().SetSelectedThreadByIndexID(0); + m_exe_ctx.process->GetThreadList().SetSelectedThreadByID(m_exe_ctx.thread->GetID()); } if (m_exe_ctx.thread) { Modified: lldb/trunk/test/stl/TestSTL.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/stl/TestSTL.py?rev=113825&r1=113824&r2=113825&view=diff ============================================================================== --- lldb/trunk/test/stl/TestSTL.py (original) +++ lldb/trunk/test/stl/TestSTL.py Mon Sep 13 19:53:53 2010 @@ -12,13 +12,11 @@ mydir = "stl" @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin") - @unittest2.expectedFailure def test_with_dsym(self): """Test that we can successfully step into an STL function.""" self.buildDsym() self.step_into_stl() - @unittest2.expectedFailure def test_with_dwarf(self): """Test that we can successfully step into an STL function.""" self.buildDwarf() From gclayton at apple.com Mon Sep 13 21:20:48 2010 From: gclayton at apple.com (Greg Clayton) Date: Tue, 14 Sep 2010 02:20:48 -0000 Subject: [Lldb-commits] [lldb] r113829 - in /lldb/trunk: include/lldb/Core/ include/lldb/Expression/ include/lldb/Symbol/ source/Commands/ source/Core/ source/Expression/ source/Plugins/Process/MacOSX-User/source/ source/Plugins/SymbolFile/DWARF/ source/Symbol/ source/Target/ Message-ID: <20100914022049.1C67A2A6C12C@llvm.org> Author: gclayton Date: Mon Sep 13 21:20:48 2010 New Revision: 113829 URL: http://llvm.org/viewvc/llvm-project?rev=113829&view=rev Log: Looking at some of the test suite failures in DWARF in .o files with the debug map showed that the location lists in the .o files needed some refactoring in order to work. The case that was failing was where a function that was in the "__TEXT.__textcoal_nt" in the .o file, and in the "__TEXT.__text" section in the main executable. This made symbol lookup fail due to the way we were finding a real address in the debug map which was by finding the section that the function was in in the .o file and trying to find this in the main executable. Now the section list supports finding a linked address in a section or any child sections. After fixing this, we ran into issue that were due to DWARF and how it represents locations lists. DWARF makes a list of address ranges and expressions that go along with those address ranges. The location addresses are expressed in terms of a compile unit address + offset. This works fine as long as nothing moves around. When stuff moves around and offsets change between the remapped compile unit base address and the new function address, then we can run into trouble. To deal with this, we now store supply a location list slide amount to any location list expressions that will allow us to make the location list addresses into zero based offsets from the object that owns the location list (always a function in our case). With these fixes we can now re-link random address ranges inside the debugger for use with our DWARF + debug map, incremental linking, and more. Another issue that arose when doing the DWARF in the .o files was that GCC 4.2 emits a ".debug_aranges" that only mentions functions that are externally visible. This makes .debug_aranges useless to us and we now generate a real address range lookup table in the DWARF parser at the same time as we index the name tables (that are needed because .debug_pubnames is just as useless). llvm-gcc doesn't generate a .debug_aranges section, though this could be fixed, we aren't going to rely upon it. Renamed a bunch of "UINT_MAX" to "UINT32_MAX". Modified: lldb/trunk/include/lldb/Core/DataExtractor.h lldb/trunk/include/lldb/Core/Module.h lldb/trunk/include/lldb/Core/ModuleList.h lldb/trunk/include/lldb/Core/Section.h lldb/trunk/include/lldb/Expression/DWARFExpression.h lldb/trunk/include/lldb/Symbol/Symtab.h lldb/trunk/source/Commands/CommandObjectFrame.cpp lldb/trunk/source/Core/Section.cpp lldb/trunk/source/Core/ValueObjectVariable.cpp lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp lldb/trunk/source/Expression/DWARFExpression.cpp lldb/trunk/source/Plugins/Process/MacOSX-User/source/RegisterContextMach_arm.cpp lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.h lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugAbbrev.cpp lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugAranges.cpp lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugAranges.h lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.cpp lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugLine.cpp lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp lldb/trunk/source/Symbol/CompileUnit.cpp lldb/trunk/source/Symbol/LineTable.cpp lldb/trunk/source/Symbol/Variable.cpp lldb/trunk/source/Target/StackFrame.cpp Modified: lldb/trunk/include/lldb/Core/DataExtractor.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/DataExtractor.h?rev=113829&r1=113828&r2=113829&view=diff ============================================================================== --- lldb/trunk/include/lldb/Core/DataExtractor.h (original) +++ lldb/trunk/include/lldb/Core/DataExtractor.h Mon Sep 13 21:20:48 2010 @@ -1024,7 +1024,7 @@ /// The number of bytes that this object now contains. //------------------------------------------------------------------ uint32_t - SetData (const DataExtractor& data, uint32_t offset = 0, uint32_t length = UINT_MAX); + SetData (const DataExtractor& data, uint32_t offset = 0, uint32_t length = UINT32_MAX); //------------------------------------------------------------------ /// Adopt a subset of shared data in \a data_sp. @@ -1052,7 +1052,7 @@ /// The number of bytes that this object now contains. //------------------------------------------------------------------ uint32_t - SetData (lldb::DataBufferSP& data_sp, uint32_t offset = 0, uint32_t length = UINT_MAX); + SetData (lldb::DataBufferSP& data_sp, uint32_t offset = 0, uint32_t length = UINT32_MAX); //------------------------------------------------------------------ /// Set the byte_order value. Modified: lldb/trunk/include/lldb/Core/Module.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/Module.h?rev=113829&r1=113828&r2=113829&view=diff ============================================================================== --- lldb/trunk/include/lldb/Core/Module.h (original) +++ lldb/trunk/include/lldb/Core/Module.h Mon Sep 13 21:20:48 2010 @@ -208,7 +208,7 @@ /// /// @param[in] max_matches /// Allow the number of matches to be limited to \a - /// max_matches. Specify UINT_MAX to get all possible matches. + /// max_matches. Specify UINT32_MAX to get all possible matches. /// /// @param[in] variable_list /// A list of variables that gets the matches appended to (if @@ -233,7 +233,7 @@ /// /// @param[in] max_matches /// Allow the number of matches to be limited to \a - /// max_matches. Specify UINT_MAX to get all possible matches. + /// max_matches. Specify UINT32_MAX to get all possible matches. /// /// @param[in] variable_list /// A list of variables that gets the matches appended to (if @@ -262,7 +262,7 @@ /// /// @param[in] max_matches /// Allow the number of matches to be limited to \a - /// max_matches. Specify UINT_MAX to get all possible matches. + /// max_matches. Specify UINT32_MAX to get all possible matches. /// /// @param[in] encoding /// Limit the search to specific types, or get all types if @@ -298,7 +298,7 @@ /// /// @param[in] max_matches /// Allow the number of matches to be limited to \a - /// max_matches. Specify UINT_MAX to get all possible matches. + /// max_matches. Specify UINT32_MAX to get all possible matches. /// /// @param[in] encoding /// Limit the search to specific types, or get all types if Modified: lldb/trunk/include/lldb/Core/ModuleList.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/ModuleList.h?rev=113829&r1=113828&r2=113829&view=diff ============================================================================== --- lldb/trunk/include/lldb/Core/ModuleList.h (original) +++ lldb/trunk/include/lldb/Core/ModuleList.h Mon Sep 13 21:20:48 2010 @@ -177,7 +177,7 @@ /// /// @param[in] max_matches /// Allow the number of matches to be limited to \a - /// max_matches. Specify UINT_MAX to get all possible matches. + /// max_matches. Specify UINT32_MAX to get all possible matches. /// /// @param[in] variable_list /// A list of variables that gets the matches appended to (if @@ -205,7 +205,7 @@ /// /// @param[in] max_matches /// Allow the number of matches to be limited to \a - /// max_matches. Specify UINT_MAX to get all possible matches. + /// max_matches. Specify UINT32_MAX to get all possible matches. /// /// @param[in] variable_list /// A list of variables that gets the matches appended to (if @@ -287,7 +287,7 @@ /// /// @param[in] max_matches /// Allow the number of matches to be limited to \a - /// max_matches. Specify UINT_MAX to get all possible matches. + /// max_matches. Specify UINT32_MAX to get all possible matches. /// /// @param[in] encoding /// Limit the search to specific types, or get all types if Modified: lldb/trunk/include/lldb/Core/Section.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/Section.h?rev=113829&r1=113828&r2=113829&view=diff ============================================================================== --- lldb/trunk/include/lldb/Core/Section.h (original) +++ lldb/trunk/include/lldb/Core/Section.h Mon Sep 13 21:20:48 2010 @@ -61,10 +61,10 @@ GetSharedPointer (const Section *section, bool check_children) const; lldb::SectionSP - FindSectionContainingFileAddress (lldb::addr_t addr, uint32_t depth = UINT_MAX) const; + FindSectionContainingFileAddress (lldb::addr_t addr, uint32_t depth = UINT32_MAX) const; lldb::SectionSP - FindSectionContainingLinkedFileAddress (lldb::addr_t vm_addr) const; + FindSectionContainingLinkedFileAddress (lldb::addr_t vm_addr, uint32_t depth) const; bool GetSectionData (const DataExtractor& module_data, DataExtractor& section_data) const; @@ -81,7 +81,7 @@ GetNumSections (uint32_t depth) const; bool - ReplaceSection (lldb::user_id_t sect_id, lldb::SectionSP& sect_sp, uint32_t depth = UINT_MAX); + ReplaceSection (lldb::user_id_t sect_id, lldb::SectionSP& sect_sp, uint32_t depth = UINT32_MAX); lldb::SectionSP GetSectionAtIndex (uint32_t idx) const; Modified: lldb/trunk/include/lldb/Expression/DWARFExpression.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Expression/DWARFExpression.h?rev=113829&r1=113828&r2=113829&view=diff ============================================================================== --- lldb/trunk/include/lldb/Expression/DWARFExpression.h (original) +++ lldb/trunk/include/lldb/Expression/DWARFExpression.h Mon Sep 13 21:20:48 2010 @@ -57,15 +57,10 @@ /// /// @param[in] data_length /// The byte length of the location expression. - /// - /// @param[in] loclist_base_addr_ptr - /// If non-NULL, the address of the location list in the target - /// process's .debug_loc section. //------------------------------------------------------------------ DWARFExpression(const DataExtractor& data, uint32_t data_offset, - uint32_t data_length, - const Address* loclist_base_addr_ptr); + uint32_t data_length); //------------------------------------------------------------------ /// Copy constructor @@ -86,9 +81,18 @@ /// /// @param[in] level /// The level of verbosity to use. + /// + /// @param[in] location_list_base_addr + /// If this is a location list based expression, this is the + /// address of the object that owns it. NOTE: this value is + /// different from the DWARF version of the location list base + /// address which is compile unit relative. This base address + /// is the address of the object that owns the location list. //------------------------------------------------------------------ void - GetDescription (Stream *s, lldb::DescriptionLevel level) const; + GetDescription (Stream *s, + lldb::DescriptionLevel level, + lldb::addr_t location_list_base_addr) const; //------------------------------------------------------------------ /// Return true if the location expression contains data @@ -115,11 +119,11 @@ /// True if IsLocationList() is true and the address was found; /// false otherwise. //------------------------------------------------------------------ +// bool +// LocationListContainsLoadAddress (Process* process, const Address &addr) const; +// bool - LocationListContainsLoadAddress (Process* process, const Address &addr) const; - - bool - LocationListContainsLoadAddress (Process* process, lldb::addr_t load_addr) const; + LocationListContainsAddress (lldb::addr_t loclist_base_addr, lldb::addr_t addr) const; //------------------------------------------------------------------ /// Make the expression parser read its location information from a @@ -128,13 +132,9 @@ /// @param[in] data /// A data extractor configured to read the DWARF location expression's /// bytecode. - /// - /// @param[in] loclist_base_addr_ptr - /// If non-NULL, the address of the location list in the target - /// process's .debug_loc section. //------------------------------------------------------------------ void - SetOpcodeData(const DataExtractor& data, const Address* loclist_base_addr_ptr); + SetOpcodeData(const DataExtractor& data); //------------------------------------------------------------------ /// Make the expression parser read its location information from a @@ -149,23 +149,22 @@ /// /// @param[in] data_length /// The byte length of the location expression. - /// - /// @param[in] loclist_base_addr_ptr - /// If non-NULL, the address of the location list in the target - /// process's .debug_loc section. //------------------------------------------------------------------ void - SetOpcodeData(const DataExtractor& data, uint32_t data_offset, uint32_t data_length, const Address* loclist_base_addr_ptr); + SetOpcodeData(const DataExtractor& data, uint32_t data_offset, uint32_t data_length); //------------------------------------------------------------------ - /// Make the expression parser refer to a location list + /// Tells the expression that it refers to a location list. /// - /// @param[in] base_addr - /// The address of the location list in the target process's .debug_loc - /// section. + /// @param[in] slide + /// This value should be a slide that is applied to any values + /// in the location list data so the values become zero based + /// offsets into the object that owns the location list. We need + /// to make location lists relative to the objects that own them + /// so we can relink addresses on the fly. //------------------------------------------------------------------ void - SetLocationListBaseAddress(Address& base_addr); + SetLocationListSlide (lldb::addr_t slide); //------------------------------------------------------------------ /// Return the call-frame-info style register kind @@ -190,6 +189,7 @@ bool Evaluate (ExecutionContextScope *exe_scope, clang::ASTContext *ast_context, + lldb::addr_t loclist_base_load_addr, const Value* initial_value_ptr, Value& result, Error *error_ptr) const; @@ -201,6 +201,7 @@ bool Evaluate (ExecutionContext *exe_ctx, clang::ASTContext *ast_context, + lldb::addr_t loclist_base_load_addr, const Value* initial_value_ptr, Value& result, Error *error_ptr) const; @@ -318,7 +319,9 @@ DataExtractor m_data; ///< A data extractor capable of reading opcode bytes int m_reg_kind; ///< One of the defines that starts with LLDB_REGKIND_ - Address m_loclist_base_addr; ///< Base address needed for location lists + lldb::addr_t m_loclist_slide; ///< A value used to slide the location list offsets so that + ///< they are relative to the object that owns the location list + ///< (the function for frame base and variable location lists) ClangExpressionVariableList *m_expr_locals; ///< The locals used by this expression. See Evaluate() ClangExpressionDeclMap *m_decl_map; ///< The external variables used by this expression. See Evaluate() }; Modified: lldb/trunk/include/lldb/Symbol/Symtab.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Symbol/Symtab.h?rev=113829&r1=113828&r2=113829&view=diff ============================================================================== --- lldb/trunk/include/lldb/Symbol/Symtab.h (original) +++ lldb/trunk/include/lldb/Symbol/Symtab.h Mon Sep 13 21:20:48 2010 @@ -49,8 +49,8 @@ const Symbol * SymbolAtIndex (uint32_t idx) const; Symbol * FindSymbolWithType (lldb::SymbolType symbol_type, Debug symbol_debug_type, Visibility symbol_visibility, uint32_t &start_idx); // const Symbol * FindSymbolWithType (lldb::SymbolType symbol_type, Debug symbol_debug_type, Visibility symbol_visibility, uint32_t &start_idx) const; - uint32_t AppendSymbolIndexesWithType (lldb::SymbolType symbol_type, std::vector& indexes, uint32_t start_idx = 0, uint32_t end_index = UINT_MAX) const; - uint32_t AppendSymbolIndexesWithType (lldb::SymbolType symbol_type, Debug symbol_debug_type, Visibility symbol_visibility, std::vector& matches, uint32_t start_idx = 0, uint32_t end_index = UINT_MAX) const; + uint32_t AppendSymbolIndexesWithType (lldb::SymbolType symbol_type, std::vector& indexes, uint32_t start_idx = 0, uint32_t end_index = UINT32_MAX) const; + uint32_t AppendSymbolIndexesWithType (lldb::SymbolType symbol_type, Debug symbol_debug_type, Visibility symbol_visibility, std::vector& matches, uint32_t start_idx = 0, uint32_t end_index = UINT32_MAX) const; uint32_t AppendSymbolIndexesWithName (const ConstString& symbol_name, std::vector& matches); uint32_t AppendSymbolIndexesWithName (const ConstString& symbol_name, Debug symbol_debug_type, Visibility symbol_visibility, std::vector& matches); uint32_t AppendSymbolIndexesWithNameAndType (const ConstString& symbol_name, lldb::SymbolType symbol_type, std::vector& matches); Modified: lldb/trunk/source/Commands/CommandObjectFrame.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectFrame.cpp?rev=113829&r1=113828&r2=113829&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectFrame.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectFrame.cpp Mon Sep 13 21:20:48 2010 @@ -309,91 +309,6 @@ } void - DumpVariable (CommandReturnObject &result, ExecutionContext *exe_ctx, Variable *variable) - { - if (variable) - { - Stream &s = result.GetOutputStream(); - DWARFExpression &expr = variable->LocationExpression(); - Value expr_result; - Error expr_error; - Type *variable_type = variable->GetType(); - bool expr_success = expr.Evaluate(exe_ctx, NULL, NULL, expr_result, &expr_error); - - if (m_options.debug) - s.Printf ("Variable{0x%8.8x}: ", variable->GetID()); - - if (!expr_success) - s.Printf ("%s = ERROR: %s\n", variable->GetName().AsCString(NULL), expr_error.AsCString()); - else - { - Value::ValueType expr_value_type = expr_result.GetValueType(); - switch (expr_value_type) - { - case Value::eValueTypeScalar: - s.Printf ("%s = ", variable->GetName().AsCString(NULL)); - if (variable_type) - { - DataExtractor data; - if (expr_result.ResolveValue (exe_ctx, NULL).GetData (data)) - variable_type->DumpValue (exe_ctx, &s, data, 0, m_options.show_types, m_options.show_summary, m_options.debug); - } - break; - - case Value::eValueTypeFileAddress: - case Value::eValueTypeLoadAddress: - case Value::eValueTypeHostAddress: - { - s.Printf ("%s = ", variable->GetName().AsCString(NULL)); - lldb::addr_t addr = LLDB_INVALID_ADDRESS; - lldb::AddressType addr_type = eAddressTypeLoad; - - if (expr_value_type == Value::eValueTypeFileAddress) - { - lldb::addr_t file_addr = expr_result.ResolveValue (exe_ctx, NULL).ULongLong(LLDB_INVALID_ADDRESS); - SymbolContext var_sc; - variable->CalculateSymbolContext(&var_sc); - if (var_sc.module_sp) - { - ObjectFile *objfile = var_sc.module_sp->GetObjectFile(); - if (objfile) - { - Address so_addr(file_addr, objfile->GetSectionList()); - addr = so_addr.GetLoadAddress(exe_ctx->process); - } - if (addr == LLDB_INVALID_ADDRESS) - { - result.GetErrorStream().Printf ("error: %s is not loaded\n", - var_sc.module_sp->GetFileSpec().GetFilename().AsCString()); - } - } - else - { - result.GetErrorStream().Printf ("error: unable to resolve the variable address 0x%llx\n", file_addr); - } - } - else - { - if (expr_value_type == Value::eValueTypeHostAddress) - addr_type = eAddressTypeHost; - addr = expr_result.ResolveValue (exe_ctx, NULL).ULongLong(LLDB_INVALID_ADDRESS); - } - - if (addr != LLDB_INVALID_ADDRESS) - { - if (m_options.debug) - s.Printf("@ 0x%8.8llx, value = ", addr); - variable_type->DumpValueInMemory (exe_ctx, &s, addr, addr_type, m_options.show_types, m_options.show_summary, m_options.debug); - } - } - break; - } - s.EOL(); - } - } - } - - void DumpValueObject (CommandReturnObject &result, ExecutionContextScope *exe_scope, ValueObject *valobj, Modified: lldb/trunk/source/Core/Section.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/Section.cpp?rev=113829&r1=113828&r2=113829&view=diff ============================================================================== --- lldb/trunk/source/Core/Section.cpp (original) +++ lldb/trunk/source/Core/Section.cpp Mon Sep 13 21:20:48 2010 @@ -641,7 +641,7 @@ SectionSP -SectionList::FindSectionContainingLinkedFileAddress (addr_t vm_addr) const +SectionList::FindSectionContainingLinkedFileAddress (addr_t vm_addr, uint32_t depth) const { SectionSP sect_sp; const_iterator sect_iter; @@ -652,7 +652,10 @@ if (sect->ContainsLinkedFileAddress (vm_addr)) { sect_sp = *sect_iter; - break; + } + else if (depth > 0) + { + sect_sp = sect->GetChildren().FindSectionContainingLinkedFileAddress (vm_addr, depth - 1); } } return sect_sp; Modified: lldb/trunk/source/Core/ValueObjectVariable.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/ValueObjectVariable.cpp?rev=113829&r1=113828&r2=113829&view=diff ============================================================================== --- lldb/trunk/source/Core/ValueObjectVariable.cpp (original) +++ lldb/trunk/source/Core/ValueObjectVariable.cpp Mon Sep 13 21:20:48 2010 @@ -103,9 +103,17 @@ Variable *variable = m_variable_sp.get(); DWARFExpression &expr = variable->LocationExpression(); - Value old_value(m_value); + lldb::addr_t loclist_base_load_addr = LLDB_INVALID_ADDRESS; ExecutionContext exe_ctx (exe_scope); - if (expr.Evaluate (&exe_ctx, GetClangAST(), NULL, m_value, &m_error)) + if (expr.IsLocationList()) + { + SymbolContext sc; + variable->CalculateSymbolContext (&sc); + if (sc.function) + loclist_base_load_addr = sc.function->GetAddressRange().GetBaseAddress().GetLoadAddress (exe_ctx.process); + } + Value old_value(m_value); + if (expr.Evaluate (&exe_ctx, GetClangAST(), loclist_base_load_addr, NULL, m_value, &m_error)) { m_value.SetContext(Value::eContextTypeDCVariable, variable); Modified: lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp?rev=113829&r1=113828&r2=113829&view=diff ============================================================================== --- lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp (original) +++ lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp Mon Sep 13 21:20:48 2010 @@ -830,9 +830,17 @@ std::auto_ptr var_location(new Value); + lldb::addr_t loclist_base_load_addr = LLDB_INVALID_ADDRESS; + + if (var_location_expr.IsLocationList()) + { + SymbolContext var_sc; + var->CalculateSymbolContext (&var_sc); + loclist_base_load_addr = var_sc.function->GetAddressRange().GetBaseAddress().GetLoadAddress (exe_ctx.process); + } Error err; - if (!var_location_expr.Evaluate(&exe_ctx, exe_ast_ctx, NULL, *var_location.get(), &err)) + if (!var_location_expr.Evaluate(&exe_ctx, exe_ast_ctx, loclist_base_load_addr, NULL, *var_location.get(), &err)) { if (log) log->Printf("Error evaluating location: %s", err.AsCString()); Modified: lldb/trunk/source/Expression/DWARFExpression.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/DWARFExpression.cpp?rev=113829&r1=113828&r2=113829&view=diff ============================================================================== --- lldb/trunk/source/Expression/DWARFExpression.cpp (original) +++ lldb/trunk/source/Expression/DWARFExpression.cpp Mon Sep 13 21:20:48 2010 @@ -16,6 +16,7 @@ #include "lldb/Core/StreamString.h" #include "lldb/Core/Scalar.h" #include "lldb/Core/Value.h" +#include "lldb/Core/VMRange.h" #include "lldb/Expression/ClangExpressionDeclMap.h" #include "lldb/Expression/ClangExpressionVariable.h" @@ -216,7 +217,7 @@ DWARFExpression::DWARFExpression() : m_data(), m_reg_kind (eRegisterKindDWARF), - m_loclist_base_addr(), + m_loclist_slide (LLDB_INVALID_ADDRESS), m_expr_locals (NULL), m_decl_map (NULL) { @@ -225,22 +226,20 @@ DWARFExpression::DWARFExpression(const DWARFExpression& rhs) : m_data(rhs.m_data), m_reg_kind (rhs.m_reg_kind), - m_loclist_base_addr(rhs.m_loclist_base_addr), + m_loclist_slide(rhs.m_loclist_slide), m_expr_locals (rhs.m_expr_locals), m_decl_map (rhs.m_decl_map) { } -DWARFExpression::DWARFExpression(const DataExtractor& data, uint32_t data_offset, uint32_t data_length, const Address* loclist_base_addr_ptr) : +DWARFExpression::DWARFExpression(const DataExtractor& data, uint32_t data_offset, uint32_t data_length) : m_data(data, data_offset, data_length), m_reg_kind (eRegisterKindDWARF), - m_loclist_base_addr(), + m_loclist_slide(LLDB_INVALID_ADDRESS), m_expr_locals (NULL), m_decl_map (NULL) { - if (loclist_base_addr_ptr) - m_loclist_base_addr = *loclist_base_addr_ptr; } //---------------------------------------------------------------------- @@ -271,23 +270,15 @@ } void -DWARFExpression::SetOpcodeData (const DataExtractor& data, const Address* loclist_base_addr_ptr) +DWARFExpression::SetOpcodeData (const DataExtractor& data) { m_data = data; - if (loclist_base_addr_ptr != NULL) - m_loclist_base_addr = *loclist_base_addr_ptr; - else - m_loclist_base_addr.Clear(); } void -DWARFExpression::SetOpcodeData (const DataExtractor& data, uint32_t data_offset, uint32_t data_length, const Address* loclist_base_addr_ptr) +DWARFExpression::SetOpcodeData (const DataExtractor& data, uint32_t data_offset, uint32_t data_length) { m_data.SetData(data, data_offset, data_length); - if (loclist_base_addr_ptr != NULL) - m_loclist_base_addr = *loclist_base_addr_ptr; - else - m_loclist_base_addr.Clear(); } void @@ -561,9 +552,9 @@ } void -DWARFExpression::SetLocationListBaseAddress(Address& base_addr) +DWARFExpression::SetLocationListSlide (addr_t slide) { - m_loclist_base_addr = base_addr; + m_loclist_slide = slide; } int @@ -581,18 +572,18 @@ bool DWARFExpression::IsLocationList() const { - return m_loclist_base_addr.IsSectionOffset(); + return m_loclist_slide != LLDB_INVALID_ADDRESS; } void -DWARFExpression::GetDescription (Stream *s, lldb::DescriptionLevel level) const +DWARFExpression::GetDescription (Stream *s, lldb::DescriptionLevel level, addr_t location_list_base_addr) const { if (IsLocationList()) { // We have a location list uint32_t offset = 0; uint32_t count = 0; - Address base_addr(m_loclist_base_addr); + addr_t curr_base_addr = location_list_base_addr; while (m_data.ValidOffset(offset)) { lldb::addr_t begin_addr_offset = m_data.GetAddress(&offset); @@ -601,9 +592,8 @@ { if (count > 0) s->PutCString(", "); - AddressRange addr_range(base_addr, end_addr_offset - begin_addr_offset); - addr_range.GetBaseAddress().SetOffset(base_addr.GetOffset() + begin_addr_offset); - addr_range.Dump (s, NULL, Address::DumpStyleFileAddress); + VMRange addr_range(curr_base_addr + begin_addr_offset, curr_base_addr + end_addr_offset); + addr_range.Dump(s, 0, 8); s->PutChar('{'); uint32_t location_length = m_data.GetU16(&offset); DumpLocation (s, offset, location_length, level); @@ -620,6 +610,7 @@ if (m_data.GetAddressByteSize() == 4 && begin_addr_offset == 0xFFFFFFFFull || m_data.GetAddressByteSize() == 8 && begin_addr_offset == 0xFFFFFFFFFFFFFFFFull) { + curr_base_addr = end_addr_offset + location_list_base_addr; // We have a new base address if (count > 0) s->PutCString(", "); @@ -685,25 +676,60 @@ return false; } -bool -DWARFExpression::LocationListContainsLoadAddress (Process* process, const Address &addr) const -{ - return LocationListContainsLoadAddress(process, addr.GetLoadAddress(process)); -} +//bool +//DWARFExpression::LocationListContainsLoadAddress (Process* process, const Address &addr) const +//{ +// return LocationListContainsLoadAddress(process, addr.GetLoadAddress(process)); +//} +// +//bool +//DWARFExpression::LocationListContainsLoadAddress (Process* process, addr_t load_addr) const +//{ +// if (load_addr == LLDB_INVALID_ADDRESS) +// return false; +// +// if (IsLocationList()) +// { +// uint32_t offset = 0; +// +// addr_t loc_list_base_addr = m_loclist_slide.GetLoadAddress(process); +// +// if (loc_list_base_addr == LLDB_INVALID_ADDRESS) +// return false; +// +// while (m_data.ValidOffset(offset)) +// { +// // We need to figure out what the value is for the location. +// addr_t lo_pc = m_data.GetAddress(&offset); +// addr_t hi_pc = m_data.GetAddress(&offset); +// if (lo_pc == 0 && hi_pc == 0) +// break; +// else +// { +// lo_pc += loc_list_base_addr; +// hi_pc += loc_list_base_addr; +// +// if (lo_pc <= load_addr && load_addr < hi_pc) +// return true; +// +// offset += m_data.GetU16(&offset); +// } +// } +// } +// return false; +//} bool -DWARFExpression::LocationListContainsLoadAddress (Process* process, addr_t load_addr) const +DWARFExpression::LocationListContainsAddress (lldb::addr_t loclist_base_addr, lldb::addr_t addr) const { - if (load_addr == LLDB_INVALID_ADDRESS) + if (addr == LLDB_INVALID_ADDRESS) return false; if (IsLocationList()) { uint32_t offset = 0; - addr_t loc_list_base_addr = m_loclist_base_addr.GetLoadAddress(process); - - if (loc_list_base_addr == LLDB_INVALID_ADDRESS) + if (loclist_base_addr == LLDB_INVALID_ADDRESS) return false; while (m_data.ValidOffset(offset)) @@ -715,10 +741,10 @@ break; else { - lo_pc += loc_list_base_addr; - hi_pc += loc_list_base_addr; + lo_pc += loclist_base_addr - m_loclist_slide; + hi_pc += loclist_base_addr - m_loclist_slide; - if (lo_pc <= load_addr && load_addr < hi_pc) + if (lo_pc <= addr && addr < hi_pc) return true; offset += m_data.GetU16(&offset); @@ -733,13 +759,14 @@ ( ExecutionContextScope *exe_scope, clang::ASTContext *ast_context, + lldb::addr_t loclist_base_load_addr, const Value* initial_value_ptr, Value& result, Error *error_ptr ) const { ExecutionContext exe_ctx (exe_scope); - return Evaluate(&exe_ctx, ast_context, initial_value_ptr, result, error_ptr); + return Evaluate(&exe_ctx, ast_context, loclist_base_load_addr, initial_value_ptr, result, error_ptr); } bool @@ -747,6 +774,7 @@ ( ExecutionContext *exe_ctx, clang::ASTContext *ast_context, + lldb::addr_t loclist_base_load_addr, const Value* initial_value_ptr, Value& result, Error *error_ptr @@ -757,43 +785,39 @@ uint32_t offset = 0; addr_t pc = exe_ctx->frame->GetRegisterContext()->GetPC(); - if (pc == LLDB_INVALID_ADDRESS) + if (loclist_base_load_addr != LLDB_INVALID_ADDRESS) { - if (error_ptr) - error_ptr->SetErrorString("Invalid PC in frame."); - return false; - } - - addr_t loc_list_base_addr = m_loclist_base_addr.GetLoadAddress(exe_ctx->process); - - if (loc_list_base_addr == LLDB_INVALID_ADDRESS) - { - if (error_ptr) - error_ptr->SetErrorString("Out of scope."); - return false; - } - - while (m_data.ValidOffset(offset)) - { - // We need to figure out what the value is for the location. - addr_t lo_pc = m_data.GetAddress(&offset); - addr_t hi_pc = m_data.GetAddress(&offset); - if (lo_pc == 0 && hi_pc == 0) + if (pc == LLDB_INVALID_ADDRESS) { - break; + if (error_ptr) + error_ptr->SetErrorString("Invalid PC in frame."); + return false; } - else - { - lo_pc += loc_list_base_addr; - hi_pc += loc_list_base_addr; - uint16_t length = m_data.GetU16(&offset); + addr_t curr_loclist_base_load_addr = loclist_base_load_addr; - if (length > 0 && lo_pc <= pc && pc < hi_pc) + while (m_data.ValidOffset(offset)) + { + // We need to figure out what the value is for the location. + addr_t lo_pc = m_data.GetAddress(&offset); + addr_t hi_pc = m_data.GetAddress(&offset); + if (lo_pc == 0 && hi_pc == 0) + { + break; + } + else { - return DWARFExpression::Evaluate (exe_ctx, ast_context, m_data, m_expr_locals, m_decl_map, offset, length, m_reg_kind, initial_value_ptr, result, error_ptr); + lo_pc += curr_loclist_base_load_addr - m_loclist_slide; + hi_pc += curr_loclist_base_load_addr - m_loclist_slide; + + uint16_t length = m_data.GetU16(&offset); + + if (length > 0 && lo_pc <= pc && pc < hi_pc) + { + return DWARFExpression::Evaluate (exe_ctx, ast_context, m_data, m_expr_locals, m_decl_map, offset, length, m_reg_kind, initial_value_ptr, result, error_ptr); + } + offset += length; } - offset += length; } } if (error_ptr) Modified: lldb/trunk/source/Plugins/Process/MacOSX-User/source/RegisterContextMach_arm.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/MacOSX-User/source/RegisterContextMach_arm.cpp?rev=113829&r1=113828&r2=113829&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Process/MacOSX-User/source/RegisterContextMach_arm.cpp (original) +++ lldb/trunk/source/Plugins/Process/MacOSX-User/source/RegisterContextMach_arm.cpp Mon Sep 13 21:20:48 2010 @@ -1152,8 +1152,8 @@ #if defined (__arm__) // Set the init value to something that will let us know that we need to // autodetect how many breakpoints are supported dynamically... - static uint32_t g_num_supported_hw_breakpoints = UINT_MAX - if (g_num_supported_hw_breakpoints == UINT_MAX) + static uint32_t g_num_supported_hw_breakpoints = UINT32_MAX; + if (g_num_supported_hw_breakpoints == UINT32_MAX) { // Set this to zero in case we can't tell if there are any HW breakpoints g_num_supported_hw_breakpoints = 0; @@ -1282,8 +1282,8 @@ #if defined (__arm__) // Set the init value to something that will let us know that we need to // autodetect how many watchpoints are supported dynamically... - static uint32_t g_num_supported_hw_watchpoints = UINT_MAX; - if (g_num_supported_hw_watchpoints == UINT_MAX) + static uint32_t g_num_supported_hw_watchpoints = UINT32_MAX; + if (g_num_supported_hw_watchpoints == UINT32_MAX) { // Set this to zero in case we can't tell if there are any HW breakpoints g_num_supported_hw_watchpoints = 0; Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp?rev=113829&r1=113828&r2=113829&view=diff ============================================================================== --- lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp (original) +++ lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp Mon Sep 13 21:20:48 2010 @@ -355,7 +355,7 @@ // the running average ends up being in the stdout log. static size_t g_total_cu_debug_info_size = 0; static size_t g_total_num_dies = 0; - static size_t g_min_bytes_per_die = UINT_MAX; + static size_t g_min_bytes_per_die = UINT32_MAX; static size_t g_max_bytes_per_die = 0; const size_t num_dies = m_die_array.size(); const size_t cu_debug_info_size = GetDebugInfoSize(); @@ -555,7 +555,9 @@ lldb_private::UniqueCStringMap& method_name_to_function_die, lldb_private::UniqueCStringMap& selector_name_to_function_die, lldb_private::UniqueCStringMap& name_to_type_die, - lldb_private::UniqueCStringMap& name_to_global_die + lldb_private::UniqueCStringMap& name_to_global_die, + const DWARFDebugRanges *debug_ranges, + DWARFDebugAranges *aranges ) { const DataExtractor* debug_str = &m_dwarf2Data->get_debug_str_data(); @@ -599,6 +601,10 @@ bool has_address = false; bool has_location = false; bool is_global_or_static_variable = false; + dw_addr_t lo_pc = DW_INVALID_ADDRESS; + dw_addr_t hi_pc = DW_INVALID_ADDRESS; + DWARFDebugRanges::RangeList ranges; + dw_offset_t specification_die_offset = DW_INVALID_OFFSET; const size_t num_attributes = die.GetAttributes(m_dwarf2Data, this, attributes); if (num_attributes > 0) @@ -634,7 +640,36 @@ break; case DW_AT_low_pc: + has_address = true; + if (tag == DW_TAG_subprogram && attributes.ExtractFormValueAtIndex(m_dwarf2Data, i, form_value)) + { + lo_pc = form_value.Unsigned(); + } + break; + + case DW_AT_high_pc: + has_address = true; + if (tag == DW_TAG_subprogram && attributes.ExtractFormValueAtIndex(m_dwarf2Data, i, form_value)) + { + hi_pc = form_value.Unsigned(); + } + break; + case DW_AT_ranges: + if (tag == DW_TAG_subprogram && attributes.ExtractFormValueAtIndex(m_dwarf2Data, i, form_value)) + { + if (debug_ranges) + { + debug_ranges->FindRanges(form_value.Unsigned(), ranges); + // All DW_AT_ranges are relative to the base address of the + // compile unit. We add the compile unit base address to make + // sure all the addresses are properly fixed up. + ranges.AddOffset(GetBaseAddress()); + } + } + has_address = true; + break; + case DW_AT_entry_pc: has_address = true; break; @@ -693,6 +728,22 @@ break; } } + + if (tag == DW_TAG_subprogram) + { + if (lo_pc != DW_INVALID_ADDRESS && hi_pc != DW_INVALID_ADDRESS) + { + aranges->AppendRange (m_offset, lo_pc, hi_pc); + } + else + { + for (size_t i=0, num_ranges = ranges.Size(); iAppendRange (m_offset, range->begin_offset, range->end_offset); + } + } + } } switch (tag) Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.h?rev=113829&r1=113828&r2=113829&view=diff ============================================================================== --- lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.h (original) +++ lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.h Mon Sep 13 21:20:48 2010 @@ -26,7 +26,7 @@ DWARFDebugInfoEntry** function_die, DWARFDebugInfoEntry** block_die); - size_t AppendDIEsWithTag (const dw_tag_t tag, DWARFDIECollection& matching_dies, uint32_t depth = UINT_MAX) const; + size_t AppendDIEsWithTag (const dw_tag_t tag, DWARFDIECollection& matching_dies, uint32_t depth = UINT32_MAX) const; void Clear(); bool Verify(lldb_private::Stream *s) const; void Dump(lldb_private::Stream *s) const; @@ -147,7 +147,9 @@ lldb_private::UniqueCStringMap& method_name_to_function_die, lldb_private::UniqueCStringMap& selector_name_to_function_die, lldb_private::UniqueCStringMap& name_to_type_die, - lldb_private::UniqueCStringMap& name_to_global_die); + lldb_private::UniqueCStringMap& name_to_global_die, + const DWARFDebugRanges* debug_ranges, + DWARFDebugAranges *aranges); protected: Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugAbbrev.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugAbbrev.cpp?rev=113829&r1=113828&r2=113829&view=diff ============================================================================== --- lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugAbbrev.cpp (original) +++ lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugAbbrev.cpp Mon Sep 13 21:20:48 2010 @@ -45,7 +45,7 @@ else { if (prev_abbr_code + 1 != abbrevDeclaration.Code()) - m_idx_offset = UINT_MAX; // Out of order indexes, we can't do O(1) lookups... + m_idx_offset = UINT32_MAX; // Out of order indexes, we can't do O(1) lookups... } prev_abbr_code = abbrevDeclaration.Code(); } @@ -69,7 +69,7 @@ const DWARFAbbreviationDeclaration* DWARFAbbreviationDeclarationSet::GetAbbreviationDeclaration(dw_uleb128_t abbrCode) const { - if (m_idx_offset == UINT_MAX) + if (m_idx_offset == UINT32_MAX) { DWARFAbbreviationDeclarationCollConstIter pos; DWARFAbbreviationDeclarationCollConstIter end = m_decls.end(); Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugAranges.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugAranges.cpp?rev=113829&r1=113828&r2=113829&view=diff ============================================================================== --- lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugAranges.cpp (original) +++ lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugAranges.cpp Mon Sep 13 21:20:48 2010 @@ -35,7 +35,6 @@ //---------------------------------------------------------------------- static bool RangeLessThan (const DWARFDebugAranges::Range& range1, const DWARFDebugAranges::Range& range2) { -// printf("RangeLessThan -- 0x%8.8x < 0x%8.8x ? %d\n", range1.lo_pc, range1.lo_pc, range1.lo_pc < range2.lo_pc); return range1.lo_pc < range2.lo_pc; } @@ -274,6 +273,54 @@ } +void +DWARFDebugAranges::AppendRange (dw_offset_t offset, dw_addr_t low_pc, dw_addr_t high_pc) +{ + if (!m_aranges.empty()) + { + if (m_aranges.back().offset == offset && m_aranges.back().hi_pc == low_pc) + { + m_aranges.back().hi_pc = high_pc; + return; + } + } + m_aranges.push_back (DWARFDebugAranges::Range(low_pc, high_pc, offset)); +} + +void +DWARFDebugAranges::Sort() +{ + // Sort our address range entries + std::stable_sort (m_aranges.begin(), m_aranges.end(), RangeLessThan); + + // Merge any entries that have the same offset and same start/end address + RangeColl::iterator pos = m_aranges.begin(); + RangeColl::iterator end = m_aranges.end(); + while (pos != end) + { + RangeColl::iterator next_pos = pos + 1; + if (next_pos != end && + pos->offset == next_pos->offset && + pos->hi_pc == next_pos->lo_pc) + { + // We have found an entry whose end address it he same as the + // next entry's start address and the offsets are the same so + // we can merge these two entries. + pos->hi_pc = next_pos->hi_pc; + // Erase the next entry that wasn't needed + pos = m_aranges.erase (next_pos); + // Now recompute the end of the collection + end = m_aranges.end(); + } + else + { + // Two entries have either different offsets or there are gaps + // in the address range, move along, nothing to see here. + pos = next_pos; + } + } +} + //---------------------------------------------------------------------- // FindAddress //---------------------------------------------------------------------- Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugAranges.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugAranges.h?rev=113829&r1=113828&r2=113829&view=diff ============================================================================== --- lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugAranges.h (original) +++ lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugAranges.h Mon Sep 13 21:20:48 2010 @@ -59,8 +59,13 @@ bool GetMaxRange(dw_addr_t& lo_pc, dw_addr_t& hi_pc) const; bool Extract(const lldb_private::DataExtractor &debug_aranges_data); bool Generate(SymbolFileDWARF* dwarf2Data); - void InsertRange(dw_offset_t cu_offset, dw_addr_t low_pc, dw_addr_t high_pc); - void InsertRange(const DWARFDebugAranges::Range& range); + void InsertRange (dw_offset_t cu_offset, dw_addr_t low_pc, dw_addr_t high_pc); + void InsertRange (const DWARFDebugAranges::Range& range); + + // Use append range multiple times and then call sort + void AppendRange (dw_offset_t cu_offset, dw_addr_t low_pc, dw_addr_t high_pc); + void Sort(); + const Range* RangeAtIndex(uint32_t idx) const { if (idx < m_aranges.size()) Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.cpp?rev=113829&r1=113828&r2=113829&view=diff ============================================================================== --- lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.cpp (original) +++ lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.cpp Mon Sep 13 21:20:48 2010 @@ -868,7 +868,7 @@ strm(init_strm), die_offset(off), recurse_depth(depth), - found_depth(UINT_MAX), + found_depth(UINT32_MAX), found_die(false), ancestors() { @@ -959,7 +959,7 @@ // We have already found our DIE and are printing it's children. Obey // our recurse depth and return an invalid offset if we get done // dumping all the the children - if (dumpInfo->recurse_depth == UINT_MAX || curr_depth <= dumpInfo->found_depth + dumpInfo->recurse_depth) + if (dumpInfo->recurse_depth == UINT32_MAX || curr_depth <= dumpInfo->found_depth + dumpInfo->recurse_depth) die->Dump(dwarf2Data, cu, s, 0); } else if (dumpInfo->die_offset > die->GetOffset()) @@ -1076,7 +1076,7 @@ else { s->Printf(" for DIE entry at .debug_info[0x%8.8x]", die_offset); - if (recurse_depth != UINT_MAX) + if (recurse_depth != UINT32_MAX) s->Printf(" recursing %u levels deep.", recurse_depth); s->EOL(); } Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp?rev=113829&r1=113828&r2=113829&view=diff ============================================================================== --- lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp (original) +++ lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp Mon Sep 13 21:20:48 2010 @@ -56,7 +56,7 @@ if (pos->attr == attr) return std::distance(beg, pos); } - return UINT_MAX; + return UINT32_MAX; } void @@ -69,14 +69,14 @@ bool DWARFDebugInfoEntry::Attributes::ContainsAttribute(dw_attr_t attr) const { - return FindAttributeIndex(attr) != UINT_MAX; + return FindAttributeIndex(attr) != UINT32_MAX; } bool DWARFDebugInfoEntry::Attributes::RemoveAttribute(dw_attr_t attr) { uint32_t attr_index = FindAttributeIndex(attr); - if (attr_index != UINT_MAX) + if (attr_index != UINT32_MAX) { m_infos.erase(m_infos.begin() + attr_index); return true; @@ -584,9 +584,9 @@ if (a_attr_count != b_attr_count) { uint32_t is_decl_index = a_attrs.FindAttributeIndex(DW_AT_declaration); - uint32_t a_name_index = UINT_MAX; - uint32_t b_name_index = UINT_MAX; - if (is_decl_index != UINT_MAX) + uint32_t a_name_index = UINT32_MAX; + uint32_t b_name_index = UINT32_MAX; + if (is_decl_index != UINT32_MAX) { if (a_attr_count == 2) { @@ -597,13 +597,13 @@ else { is_decl_index = b_attrs.FindAttributeIndex(DW_AT_declaration); - if (is_decl_index != UINT_MAX && a_attr_count == 2) + if (is_decl_index != UINT32_MAX && a_attr_count == 2) { a_name_index = a_attrs.FindAttributeIndex(DW_AT_name); b_name_index = b_attrs.FindAttributeIndex(DW_AT_name); } } - if (a_name_index != UINT_MAX && b_name_index != UINT_MAX) + if (a_name_index != UINT32_MAX && b_name_index != UINT32_MAX) { if (a_attrs.ExtractFormValueAtIndex(dwarf2Data, a_name_index, a_form_value) && b_attrs.ExtractFormValueAtIndex(dwarf2Data, b_name_index, b_form_value)) @@ -794,6 +794,7 @@ dw_addr_t lo_pc = DW_INVALID_ADDRESS; dw_addr_t hi_pc = DW_INVALID_ADDRESS; std::vector die_offsets; + bool set_frame_base_loclist_addr = false; if (m_abbrevDecl) { const DataExtractor& debug_info_data = dwarf2Data->get_debug_info_data(); @@ -892,18 +893,26 @@ { uint32_t block_offset = form_value.BlockData() - debug_info_data.GetDataStart(); uint32_t block_length = form_value.Unsigned(); - frame_base->SetOpcodeData(debug_info_data, block_offset, block_length, NULL); + frame_base->SetOpcodeData(debug_info_data, block_offset, block_length); } else { - const DataExtractor& debug_loc_data = dwarf2Data->get_debug_loc_data(); + const DataExtractor &debug_loc_data = dwarf2Data->get_debug_loc_data(); const dw_offset_t debug_loc_offset = form_value.Unsigned(); size_t loc_list_length = DWARFLocationList::Size(debug_loc_data, debug_loc_offset); if (loc_list_length > 0) { - Address base_address(cu->GetBaseAddress(), dwarf2Data->GetObjectFile()->GetSectionList()); - frame_base->SetOpcodeData(debug_loc_data, debug_loc_offset, loc_list_length, &base_address); + frame_base->SetOpcodeData(debug_loc_data, debug_loc_offset, loc_list_length); + if (lo_pc != DW_INVALID_ADDRESS) + { + assert (lo_pc >= cu->GetBaseAddress()); + frame_base->SetLocationListSlide(lo_pc - cu->GetBaseAddress()); + } + else + { + set_frame_base_loclist_addr = true; + } } } } @@ -928,6 +937,12 @@ ranges.AddRange(lo_pc, lo_pc); } } + + if (set_frame_base_loclist_addr) + { + assert (ranges.LowestAddress(0) >= cu->GetBaseAddress()); + frame_base->SetLocationListSlide(ranges.LowestAddress(0) - cu->GetBaseAddress()); + } if (ranges.Size() == 0 || (name == NULL) || (mangled == NULL)) { Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugLine.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugLine.cpp?rev=113829&r1=113828&r2=113829&view=diff ============================================================================== --- lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugLine.cpp (original) +++ lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugLine.cpp Mon Sep 13 21:20:48 2010 @@ -1008,7 +1008,7 @@ uint32_t DWARFDebugLine::LineTable::LookupAddress(dw_addr_t address, dw_addr_t cu_high_pc) const { - uint32_t index = UINT_MAX; + uint32_t index = UINT32_MAX; if (!rows.empty()) { // Use the lower_bound algorithm to perform a binary search since we know @@ -1036,7 +1036,7 @@ if (index > 0) --index; else - index = UINT_MAX; + index = UINT32_MAX; } } } Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp?rev=113829&r1=113828&r2=113829&view=diff ============================================================================== --- lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp (original) +++ lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp Mon Sep 13 21:20:48 2010 @@ -418,19 +418,29 @@ DWARFDebugAranges* SymbolFileDWARF::DebugAranges() { - if (m_aranges.get() == NULL) - { - Timer scoped_timer(__PRETTY_FUNCTION__, "%s this = %p", __PRETTY_FUNCTION__, this); - m_aranges.reset(new DWARFDebugAranges()); - if (m_aranges.get()) - { - const DataExtractor &debug_aranges_data = get_debug_aranges_data(); - if (debug_aranges_data.GetByteSize() > 0) - m_aranges->Extract(debug_aranges_data); - else - m_aranges->Generate(this); - } - } + // It turns out that llvm-gcc doesn't generate .debug_aranges in .o files + // and we are already parsing all of the DWARF because the .debug_pubnames + // is useless (it only mentions symbols that are externally visible), so + // don't use the .debug_aranges section, we should be using a debug aranges + // we got from SymbolFileDWARF::Index(). + + if (!m_indexed) + Index(); + + +// if (m_aranges.get() == NULL) +// { +// Timer scoped_timer(__PRETTY_FUNCTION__, "%s this = %p", __PRETTY_FUNCTION__, this); +// m_aranges.reset(new DWARFDebugAranges()); +// if (m_aranges.get()) +// { +// const DataExtractor &debug_aranges_data = get_debug_aranges_data(); +// if (debug_aranges_data.GetByteSize() > 0) +// m_aranges->Extract(debug_aranges_data); +// else +// m_aranges->Generate(this); +// } +// } return m_aranges.get(); } @@ -1492,7 +1502,7 @@ if (dc_cu.get()) { // Figure out the compile unit index if we weren't given one - if (cu_idx == UINT_MAX) + if (cu_idx == UINT32_MAX) DebugInfo()->GetCompileUnit(cu->GetOffset(), &cu_idx); m_obj_file->GetModule()->GetSymbolVendor()->SetCompileUnitAtIndex(dc_cu, cu_idx); @@ -1507,7 +1517,7 @@ sc.Clear(); // Check if the symbol vendor already knows about this compile unit? sc.module_sp = m_obj_file->GetModule()->GetSP(); - sc.comp_unit = GetCompUnitForDWARFCompUnit(cu, UINT_MAX); + sc.comp_unit = GetCompUnitForDWARFCompUnit(cu, UINT32_MAX); sc.function = sc.comp_unit->FindFunctionByUID (func_die->GetOffset()).get(); if (sc.function == NULL) @@ -1669,7 +1679,7 @@ uint32_t line_idx = line_table->FindLineEntryIndexByFileIndex (0, file_idx, line, false, &sc.line_entry); found_line = sc.line_entry.line; - while (line_idx != UINT_MAX) + while (line_idx != UINT32_MAX) { sc.function = NULL; sc.block = NULL; @@ -1742,6 +1752,8 @@ DWARFDebugInfo* debug_info = DebugInfo(); if (debug_info) { + m_aranges.reset(new DWARFDebugAranges()); + uint32_t cu_idx = 0; const uint32_t num_compile_units = GetNumCompileUnits(); for (cu_idx = 0; cu_idx < num_compile_units; ++cu_idx) @@ -1755,7 +1767,9 @@ m_method_name_to_function_die, m_selector_name_to_function_die, m_name_to_global_die, - m_name_to_type_die); + m_name_to_type_die, + DebugRanges(), + m_aranges.get()); // Keep memory down by clearing DIEs if this generate function // caused them to be parsed @@ -1769,6 +1783,7 @@ m_selector_name_to_function_die.Sort(); m_name_to_global_die.Sort(); m_name_to_type_die.Sort(); + m_aranges->Sort(); } } @@ -1804,10 +1819,10 @@ sc.module_sp = m_obj_file->GetModule()->GetSP(); assert (sc.module_sp); - sc.comp_unit = GetCompUnitForDWARFCompUnit(cu, UINT_MAX); + sc.comp_unit = GetCompUnitForDWARFCompUnit(cu, UINT32_MAX); assert(sc.comp_unit != NULL); - ParseVariables(sc, cu_sp.get(), die, false, false, &variables); + ParseVariables(sc, cu_sp.get(), LLDB_INVALID_ADDRESS, die, false, false, &variables); if (variables.GetSize() - original_size >= max_matches) break; @@ -1854,10 +1869,10 @@ assert (sc.module_sp); - sc.comp_unit = GetCompUnitForDWARFCompUnit(cu, UINT_MAX); + sc.comp_unit = GetCompUnitForDWARFCompUnit(cu, UINT32_MAX); assert(sc.comp_unit != NULL); - ParseVariables(sc, cu_sp.get(), die, false, false, &variables); + ParseVariables(sc, cu_sp.get(), LLDB_INVALID_ADDRESS, die, false, false, &variables); if (variables.GetSize() - original_size >= max_matches) break; @@ -3308,7 +3323,11 @@ if (sc.function) { const DWARFDebugInfoEntry *function_die = dwarf_cu->GetDIEPtr(sc.function->GetID()); - return ParseVariables(sc, dwarf_cu, function_die->GetFirstChild(), true, true); + + dw_addr_t func_lo_pc = function_die->GetAttributeValueAsUnsigned (this, dwarf_cu, DW_AT_low_pc, DW_INVALID_ADDRESS); + assert (func_lo_pc != DW_INVALID_ADDRESS); + + return ParseVariables(sc, dwarf_cu, func_lo_pc, function_die->GetFirstChild(), true, true); } else if (sc.comp_unit) { @@ -3328,7 +3347,7 @@ const size_t num_globals = dwarf_cu->GetNumGlobals(); for (size_t idx=0; idxGetGlobalDIEAtIndex (idx))); + VariableSP var_sp (ParseVariableDIE(sc, dwarf_cu, dwarf_cu->GetGlobalDIEAtIndex (idx), LLDB_INVALID_ADDRESS)); if (var_sp) { variables->AddVariable(var_sp); @@ -3348,7 +3367,8 @@ ( const SymbolContext& sc, const DWARFCompileUnit* dwarf_cu, - const DWARFDebugInfoEntry *die + const DWARFDebugInfoEntry *die, + const lldb::addr_t func_low_pc ) { @@ -3393,7 +3413,7 @@ uint32_t block_offset = form_value.BlockData() - debug_info_data.GetDataStart(); uint32_t block_length = form_value.Unsigned(); - location.SetOpcodeData(get_debug_info_data(), block_offset, block_length, NULL); + location.SetOpcodeData(get_debug_info_data(), block_offset, block_length); } else { @@ -3403,8 +3423,9 @@ size_t loc_list_length = DWARFLocationList::Size(debug_loc_data, debug_loc_offset); if (loc_list_length > 0) { - Address base_address(dwarf_cu->GetBaseAddress(), m_obj_file->GetSectionList()); - location.SetOpcodeData(debug_loc_data, debug_loc_offset, loc_list_length, &base_address); + location.SetOpcodeData(debug_loc_data, debug_loc_offset, loc_list_length); + assert (func_low_pc != LLDB_INVALID_ADDRESS); + location.SetLocationListSlide (func_low_pc - dwarf_cu->GetBaseAddress()); } } } @@ -3489,6 +3510,7 @@ ( const SymbolContext& sc, const DWARFCompileUnit* dwarf_cu, + const lldb::addr_t func_low_pc, const DWARFDebugInfoEntry *orig_die, bool parse_siblings, bool parse_children, @@ -3565,7 +3587,7 @@ (tag == DW_TAG_constant) || (tag == DW_TAG_formal_parameter && sc.function)) { - VariableSP var_sp (ParseVariableDIE(sc, dwarf_cu, die)); + VariableSP var_sp (ParseVariableDIE(sc, dwarf_cu, die, func_low_pc)); if (var_sp) { variables->AddVariable(var_sp); @@ -3578,7 +3600,7 @@ if (!skip_children && parse_children && die->HasChildren()) { - vars_added += ParseVariables(sc, dwarf_cu, die->GetFirstChild(), true, true); + vars_added += ParseVariables(sc, dwarf_cu, func_low_pc, die->GetFirstChild(), true, true); //vars_added += ParseVariables(sc, dwarf_cu, die->GetFirstChild(), parse_siblings, parse_children); } Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h?rev=113829&r1=113828&r2=113829&view=diff ============================================================================== --- lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h (original) +++ lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h Mon Sep 13 21:20:48 2010 @@ -218,7 +218,7 @@ bool ParseCompileUnit(DWARFCompileUnit* cu, lldb::CompUnitSP& compile_unit_sp); DWARFCompileUnit* GetDWARFCompileUnitForUID(lldb::user_id_t cu_uid); DWARFCompileUnit* GetNextUnparsedDWARFCompileUnit(DWARFCompileUnit* prev_cu); - lldb_private::CompileUnit* GetCompUnitForDWARFCompUnit(DWARFCompileUnit* cu, uint32_t cu_idx = UINT_MAX); + lldb_private::CompileUnit* GetCompUnitForDWARFCompUnit(DWARFCompileUnit* cu, uint32_t cu_idx = UINT32_MAX); bool GetFunction (DWARFCompileUnit* cu, const DWARFDebugInfoEntry* func_die, lldb_private::SymbolContext& sc); lldb_private::Function * ParseCompileUnitFunction (const lldb_private::SymbolContext& sc, const DWARFCompileUnit* dwarf_cu, const DWARFDebugInfoEntry *die); size_t ParseFunctionBlocks (const lldb_private::SymbolContext& sc, @@ -234,11 +234,13 @@ lldb::VariableSP ParseVariableDIE( const lldb_private::SymbolContext& sc, const DWARFCompileUnit* dwarf_cu, - const DWARFDebugInfoEntry *die); + const DWARFDebugInfoEntry *die, + const lldb::addr_t func_low_pc); size_t ParseVariables( const lldb_private::SymbolContext& sc, const DWARFCompileUnit* dwarf_cu, + const lldb::addr_t func_low_pc, const DWARFDebugInfoEntry *die, bool parse_siblings, bool parse_children, Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp?rev=113829&r1=113828&r2=113829&view=diff ============================================================================== --- lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp (original) +++ lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp Mon Sep 13 21:20:48 2010 @@ -617,30 +617,15 @@ { SectionList *oso_section_list = oso_objfile->GetSectionList(); + SectionSP oso_symbol_section_sp (oso_section_list->FindSectionContainingLinkedFileAddress (exe_file_addr, UINT32_MAX)); - SectionSP oso_section_sp(oso_section_list->FindSectionByName(exe_so_addr.GetSection()->GetName())); - if (oso_section_sp) + if (oso_symbol_section_sp) { - SectionSP oso_symbol_section_sp (oso_section_sp->GetChildren().FindSectionContainingLinkedFileAddress (exe_file_addr)); - - if (oso_symbol_section_sp) - { - const addr_t linked_file_addr = oso_symbol_section_sp->GetLinkedFileAddress(); - Address oso_so_addr (oso_symbol_section_sp.get(), exe_file_addr - linked_file_addr); - if (oso_so_addr.IsSectionOffset()) - resolved_flags |= oso_dwarf->ResolveSymbolContext (oso_so_addr, resolve_scope, sc); - } + const addr_t linked_file_addr = oso_symbol_section_sp->GetLinkedFileAddress(); + Address oso_so_addr (oso_symbol_section_sp.get(), exe_file_addr - linked_file_addr); + if (oso_so_addr.IsSectionOffset()) + resolved_flags |= oso_dwarf->ResolveSymbolContext (oso_so_addr, resolve_scope, sc); } - // Map the load address from in the executable back to a - // section/offset address in the .o file so we can do - // lookups in the .o DWARF. -// Address oso_so_addr (exe_load_addr, false, comp_unit_info->debug_map_sections_sp.get()); -// -// // Make sure we were able to resolve this back to a .o -// // section offset address, and if so, resolve the context -// // for everything that was asked for. -// if (oso_so_addr.IsSectionOffset()) -// resolved_flags |= oso_dwarf->ResolveSymbolContext (oso_so_addr, resolve_scope, sc); } } } Modified: lldb/trunk/source/Symbol/CompileUnit.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/CompileUnit.cpp?rev=113829&r1=113828&r2=113829&view=diff ============================================================================== --- lldb/trunk/source/Symbol/CompileUnit.cpp (original) +++ lldb/trunk/source/Symbol/CompileUnit.cpp Mon Sep 13 21:20:48 2010 @@ -331,7 +331,7 @@ // we will use this for our subsequent line exact matches below. found_line = sc.line_entry.line; - while (line_idx != UINT_MAX) + while (line_idx != UINT32_MAX) { sc_list.Append(sc); line_idx = line_table->FindLineEntryIndexByFileIndex (line_idx + 1, file_indexes.front(), found_line, true, &sc.line_entry); @@ -350,7 +350,7 @@ // we will use this for our subsequent line exact matches below. found_line = sc.line_entry.line; - while (line_idx != UINT_MAX) + while (line_idx != UINT32_MAX) { sc_list.Append(sc); line_idx = line_table->FindLineEntryIndexByFileIndex (line_idx + 1, file_indexes, found_line, true, &sc.line_entry); Modified: lldb/trunk/source/Symbol/LineTable.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/LineTable.cpp?rev=113829&r1=113828&r2=113829&view=diff ============================================================================== --- lldb/trunk/source/Symbol/LineTable.cpp (original) +++ lldb/trunk/source/Symbol/LineTable.cpp Mon Sep 13 21:20:48 2010 @@ -294,7 +294,7 @@ const size_t count = m_entries.size(); std::vector::const_iterator begin_pos = file_indexes.begin(); std::vector::const_iterator end_pos = file_indexes.end(); - size_t best_match = UINT_MAX; + size_t best_match = UINT32_MAX; for (size_t idx = start_idx; idx < count; ++idx) { @@ -329,20 +329,20 @@ } } - if (best_match != UINT_MAX) + if (best_match != UINT32_MAX) { if (line_entry_ptr) ConvertEntryAtIndexToLineEntry (best_match, *line_entry_ptr); return best_match; } - return UINT_MAX; + return UINT32_MAX; } uint32_t LineTable::FindLineEntryIndexByFileIndex (uint32_t start_idx, uint32_t file_idx, uint32_t line, bool exact, LineEntry* line_entry_ptr) { const size_t count = m_entries.size(); - size_t best_match = UINT_MAX; + size_t best_match = UINT32_MAX; for (size_t idx = start_idx; idx < count; ++idx) { @@ -377,13 +377,13 @@ } } - if (best_match != UINT_MAX) + if (best_match != UINT32_MAX) { if (line_entry_ptr) ConvertEntryAtIndexToLineEntry (best_match, *line_entry_ptr); return best_match; } - return UINT_MAX; + return UINT32_MAX; } void Modified: lldb/trunk/source/Symbol/Variable.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/Variable.cpp?rev=113829&r1=113828&r2=113829&view=diff ============================================================================== --- lldb/trunk/source/Symbol/Variable.cpp (original) +++ lldb/trunk/source/Symbol/Variable.cpp Mon Sep 13 21:20:48 2010 @@ -94,7 +94,15 @@ if (m_location.IsValid()) { s->PutCString(", location = "); - m_location.GetDescription(s, lldb::eDescriptionLevelBrief); + lldb::addr_t loclist_base_addr = LLDB_INVALID_ADDRESS; + if (m_location.IsLocationList()) + { + SymbolContext variable_sc; + m_owner_scope->CalculateSymbolContext(&variable_sc); + if (variable_sc.function) + loclist_base_addr = variable_sc.function->GetAddressRange().GetBaseAddress().GetFileAddress(); + } + m_location.GetDescription(s, lldb::eDescriptionLevelBrief, loclist_base_addr); } if (m_external) @@ -130,6 +138,7 @@ switch (m_scope) { case eValueTypeVariableGlobal: + case eValueTypeVariableStatic: // Globals and statics are always in scope. return true; @@ -140,27 +149,40 @@ // address range? if (m_location.IsLocationList()) { + SymbolContext sc; + CalculateSymbolContext(&sc); + + // Currently we only support functions that have things with + // locations lists. If this expands, we will need to add support + assert (sc.function); + Process *process = &frame->GetThread().GetProcess(); + addr_t loclist_base_load_addr = sc.function->GetAddressRange().GetBaseAddress().GetLoadAddress (process); + if (loclist_base_load_addr == LLDB_INVALID_ADDRESS) + return false; // It is a location list. We just need to tell if the location // list contains the current address when converted to a load // address - return m_location.LocationListContainsLoadAddress (&frame->GetThread().GetProcess(), frame->GetRegisterContext()->GetPC()); + return m_location.LocationListContainsAddress (loclist_base_load_addr, frame->GetFrameCodeAddress().GetLoadAddress (process)); } else { // We don't have a location list, we just need to see if the block // that this variable was defined in is currently - Block *frame_block = frame->GetSymbolContext(eSymbolContextBlock).block; + Block *frame_block = frame->GetFrameBlock(); if (frame_block) { SymbolContext variable_sc; CalculateSymbolContext (&variable_sc); - if (variable_sc.function && variable_sc.block) - return variable_sc.block->FindBlockByID(frame_block->GetID()) != NULL; + if (frame_block == variable_sc.block) + return true; + + return frame_block->Contains (variable_sc.block); } } break; default: + assert (!"Unhandled case"); break; } return false; Modified: lldb/trunk/source/Target/StackFrame.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/StackFrame.cpp?rev=113829&r1=113828&r2=113829&view=diff ============================================================================== --- lldb/trunk/source/Target/StackFrame.cpp (original) +++ lldb/trunk/source/Target/StackFrame.cpp Mon Sep 13 21:20:48 2010 @@ -486,7 +486,11 @@ m_flags.Set(GOT_FRAME_BASE); ExecutionContext exe_ctx (&m_thread.GetProcess(), &m_thread, this); Value expr_value; - if (m_sc.function->GetFrameBaseExpression().Evaluate(&exe_ctx, NULL, NULL, expr_value, &m_frame_base_error) < 0) + addr_t loclist_base_addr = LLDB_INVALID_ADDRESS; + if (m_sc.function->GetFrameBaseExpression().IsLocationList()) + loclist_base_addr = m_sc.function->GetAddressRange().GetBaseAddress().GetLoadAddress (&m_thread.GetProcess()); + + if (m_sc.function->GetFrameBaseExpression().Evaluate(&exe_ctx, NULL, loclist_base_addr, NULL, expr_value, &m_frame_base_error) == false) { // We should really have an error if evaluate returns, but in case // we don't, lets set the error to something at least. From gclayton at apple.com Mon Sep 13 22:16:59 2010 From: gclayton at apple.com (Greg Clayton) Date: Tue, 14 Sep 2010 03:16:59 -0000 Subject: [Lldb-commits] [lldb] r113830 - in /lldb/trunk: include/lldb/Symbol/Block.h source/Commands/CommandObjectFrame.cpp source/Symbol/Block.cpp source/Symbol/Variable.cpp Message-ID: <20100914031659.286812A6C12C@llvm.org> Author: gclayton Date: Mon Sep 13 22:16:58 2010 New Revision: 113830 URL: http://llvm.org/viewvc/llvm-project?rev=113830&view=rev Log: Fixed the implementation of "bool Block::Contains (const Block *block) const" to return the correct result. Fixed "bool Variable::IsInScope (StackFrame *frame)" to return the correct result when there are no location lists. Modified the "frame variable" command such that: - if no arguments are given (dump all frame variables), then we only show variables that are currently in scope - if some arguments are given, we show an error if the variable is out of scope Modified: lldb/trunk/include/lldb/Symbol/Block.h lldb/trunk/source/Commands/CommandObjectFrame.cpp lldb/trunk/source/Symbol/Block.cpp lldb/trunk/source/Symbol/Variable.cpp Modified: lldb/trunk/include/lldb/Symbol/Block.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Symbol/Block.h?rev=113830&r1=113829&r2=113830&view=diff ============================================================================== --- lldb/trunk/include/lldb/Symbol/Block.h (original) +++ lldb/trunk/include/lldb/Symbol/Block.h Mon Sep 13 22:16:58 2010 @@ -133,6 +133,17 @@ bool Contains (const VMRange& range) const; + //------------------------------------------------------------------ + /// Check if this object contains "block" as a child block at any + /// depth. + /// + /// @param[in] block + /// A potential child block. + /// + /// @return + /// Returns \b true if \a block is a child of this block, \b + /// false otherwise. + //------------------------------------------------------------------ bool Contains (const Block *block) const; Modified: lldb/trunk/source/Commands/CommandObjectFrame.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectFrame.cpp?rev=113830&r1=113829&r2=113830&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectFrame.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectFrame.cpp Mon Sep 13 22:16:58 2010 @@ -316,7 +316,8 @@ uint32_t ptr_depth, uint32_t curr_depth, uint32_t max_depth, - bool use_objc) + bool use_objc, + bool scope_already_checked) { if (valobj) { @@ -338,12 +339,18 @@ const char *name_cstr = root_valobj_name ? root_valobj_name : valobj->GetName().AsCString(""); s.Printf ("%s = ", name_cstr); + if (!scope_already_checked && !valobj->IsInScope(exe_scope->CalculateStackFrame())) + { + s.PutCString("error: out of scope"); + return; + } + const char *val_cstr = valobj->GetValueAsCString(exe_scope); const char *err_cstr = valobj->GetError().AsCString(); if (err_cstr) { - s.Printf ("error: %s\n", err_cstr); + s.Printf ("error: %s", err_cstr); } else { @@ -395,7 +402,8 @@ is_ptr_or_ref ? ptr_depth - 1 : ptr_depth, curr_depth + 1, max_depth, - false); + false, + true); if (idx + 1 < num_children) s.PutChar(','); } @@ -476,13 +484,22 @@ if (valobj_sp) { - DumpValueObject (result, exe_ctx.frame, valobj_sp.get(), name_cstr, m_options.ptr_depth, 0, m_options.max_depth, false); - if (m_options.show_decl && var_sp->GetDeclaration ().GetFile()) { - var_sp->GetDeclaration ().Dump (&s); + var_sp->GetDeclaration ().DumpStopContext (&s, false); + s.PutCString (": "); } + DumpValueObject (result, + exe_ctx.frame, + valobj_sp.get(), + name_cstr, + m_options.ptr_depth, + 0, + m_options.max_depth, + m_options.use_objc, + false); + s.EOL(); } } @@ -646,7 +663,8 @@ ptr_depth, 0, m_options.max_depth, - m_options.use_objc); + m_options.use_objc, + false); s.EOL(); } @@ -701,7 +719,6 @@ if (dump_variable) { - //DumpVariable (result, &exe_ctx, var_sp.get()); // Use the variable object code to make sure we are // using the same APIs as the the public API will be @@ -709,22 +726,27 @@ valobj_sp = exe_ctx.frame->GetValueObjectForFrameVariable (var_sp); if (valobj_sp) { - - if (m_options.show_decl && var_sp->GetDeclaration ().GetFile()) + // When dumping all variables, don't print any variables + // that are not in scope to avoid extra unneeded output + if (valobj_sp->IsInScope (exe_ctx.frame)) { - var_sp->GetDeclaration ().DumpStopContext (&s, false); - s.PutCString (": "); - } - DumpValueObject (result, - exe_ctx.frame, - valobj_sp.get(), - name_cstr, - m_options.ptr_depth, - 0, - m_options.max_depth, - m_options.use_objc); + if (m_options.show_decl && var_sp->GetDeclaration ().GetFile()) + { + var_sp->GetDeclaration ().DumpStopContext (&s, false); + s.PutCString (": "); + } + DumpValueObject (result, + exe_ctx.frame, + valobj_sp.get(), + name_cstr, + m_options.ptr_depth, + 0, + m_options.max_depth, + m_options.use_objc, + true); - s.EOL(); + s.EOL(); + } } } } Modified: lldb/trunk/source/Symbol/Block.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/Block.cpp?rev=113830&r1=113829&r2=113830&view=diff ============================================================================== --- lldb/trunk/source/Symbol/Block.cpp (original) +++ lldb/trunk/source/Symbol/Block.cpp Mon Sep 13 22:16:58 2010 @@ -239,17 +239,17 @@ bool Block::Contains (const Block *block) const { - // Block objects can't contain themselves... if (this == block) - return false; + return false; // This block doesn't contain itself... + // Walk the parent chain for "block" and see if any if them match this block const Block *block_parent; for (block_parent = block->GetParent(); block_parent != NULL; block_parent = block_parent->GetParent()) { - if (block_parent == block) - return true; + if (this == block_parent) + return true; // One of the parents of "block" is this object! } return false; } Modified: lldb/trunk/source/Symbol/Variable.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/Variable.cpp?rev=113830&r1=113829&r2=113830&view=diff ============================================================================== --- lldb/trunk/source/Symbol/Variable.cpp (original) +++ lldb/trunk/source/Symbol/Variable.cpp Mon Sep 13 22:16:58 2010 @@ -168,15 +168,15 @@ { // We don't have a location list, we just need to see if the block // that this variable was defined in is currently - Block *frame_block = frame->GetFrameBlock(); - if (frame_block) + Block *deepest_frame_block = frame->GetSymbolContext(eSymbolContextBlock).block; + if (deepest_frame_block) { SymbolContext variable_sc; CalculateSymbolContext (&variable_sc); - if (frame_block == variable_sc.block) + if (variable_sc.block == deepest_frame_block) return true; - return frame_block->Contains (variable_sc.block); + return variable_sc.block->Contains (deepest_frame_block); } } break; From gclayton at apple.com Mon Sep 13 22:47:41 2010 From: gclayton at apple.com (Greg Clayton) Date: Tue, 14 Sep 2010 03:47:41 -0000 Subject: [Lldb-commits] [lldb] r113831 - /lldb/trunk/source/Target/Process.cpp Message-ID: <20100914034741.60D502A6C12C@llvm.org> Author: gclayton Date: Mon Sep 13 22:47:41 2010 New Revision: 113831 URL: http://llvm.org/viewvc/llvm-project?rev=113831&view=rev Log: Fixed an issue that was always causing an extra empty argument to be sent to any inferior process because the code was checking if no run args were set and then adding and empty string. This was happening for environment vars as well. 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=113831&r1=113830&r2=113831&view=diff ============================================================================== --- lldb/trunk/source/Target/Process.cpp (original) +++ lldb/trunk/source/Target/Process.cpp Mon Sep 13 22:47:41 2010 @@ -2099,10 +2099,10 @@ if (var_name == RunArgsVarName()) { if (m_run_args.GetArgumentCount() > 0) + { for (int i = 0; i < m_run_args.GetArgumentCount(); ++i) value.AppendString (m_run_args.GetArgumentAtIndex (i)); - else - value.AppendString (""); + } } else if (var_name == EnvVarsVarName()) { @@ -2116,8 +2116,6 @@ value.AppendString (value_str.GetData()); } } - else - value.AppendString (""); } else if (var_name == InputPathVarName()) { From gclayton at apple.com Mon Sep 13 23:09:57 2010 From: gclayton at apple.com (Greg Clayton) Date: Tue, 14 Sep 2010 04:09:57 -0000 Subject: [Lldb-commits] [lldb] r113832 - /lldb/trunk/source/Core/DataExtractor.cpp Message-ID: <20100914040957.2B0BF2A6C12C@llvm.org> Author: gclayton Date: Mon Sep 13 23:09:57 2010 New Revision: 113832 URL: http://llvm.org/viewvc/llvm-project?rev=113832&view=rev Log: Fixed display for long double and cleaned up float and doubles as well. Modified: lldb/trunk/source/Core/DataExtractor.cpp Modified: lldb/trunk/source/Core/DataExtractor.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/DataExtractor.cpp?rev=113832&r1=113831&r2=113832&view=diff ============================================================================== --- lldb/trunk/source/Core/DataExtractor.cpp (original) +++ lldb/trunk/source/Core/DataExtractor.cpp Mon Sep 13 23:09:57 2010 @@ -739,62 +739,80 @@ float DataExtractor::GetFloat (uint32_t *offset_ptr) const { - uint32_t val = 0; - register uint32_t offset = *offset_ptr; - - if ( ValidOffsetForDataOfSize(offset, sizeof(val)) ) + typedef float float_type; + float_type val = 0.0; + const uint8_t *src_data = PeekData (*offset_ptr, sizeof(float_type)); + + if (src_data) { if (m_byte_order != eByteOrderHost) - val = ReadSwapInt32 (m_start, offset); + { + uint8_t *dst_data = (uint8_t *)&val; + for (int i=0; iPrintf ("%g", (double)(*((float *)&a32))); + s->Printf ("%g", GetFloat (&offset)); } else if (sizeof(double) == item_byte_size) { - uint64_t a64 = GetU64(&offset); - s->Printf ("%lg", (*((double *)&a64))); + s->Printf ("%lg", GetDouble(&offset)); } - else if (sizeof(long double) == item_byte_size && sizeof(long double) <= sizeof(uint64_t)) + else if (sizeof(long double) == item_byte_size) { - uint64_t a64 = GetU64(&offset); - s->Printf ("%Lg", (*((long double *)&a64))); + s->Printf ("%Lg", GetLongDouble(&offset)); } break; From scallanan at apple.com Tue Sep 14 16:59:35 2010 From: scallanan at apple.com (Sean Callanan) Date: Tue, 14 Sep 2010 21:59:35 -0000 Subject: [Lldb-commits] [lldb] r113866 - in /lldb/trunk: include/lldb/Expression/ClangASTSource.h include/lldb/Expression/ClangExpressionDeclMap.h source/Expression/ClangASTSource.cpp source/Expression/ClangExpressionDeclMap.cpp source/Expression/ClangUserExpression.cpp Message-ID: <20100914215935.320572A6C12C@llvm.org> Author: spyffe Date: Tue Sep 14 16:59:34 2010 New Revision: 113866 URL: http://llvm.org/viewvc/llvm-project?rev=113866&view=rev Log: Added code to support use of "this" and "self" in expressions. This involved three main changes: - In ClangUserExpression::ClangUserExpression(), we now insert the following lines into the expression: #define this ___clang_this #define self ___clang_self - In ClangExpressionDeclMap::GetDecls(), we special-case ___clang_(this|self) and instead look up "this" or "self" - In ClangASTSource, we introduce the capability to generate Decls with a different, overridden, name from the one that was requested, e.g. this for ___clang_this. Modified: lldb/trunk/include/lldb/Expression/ClangASTSource.h lldb/trunk/include/lldb/Expression/ClangExpressionDeclMap.h lldb/trunk/source/Expression/ClangASTSource.cpp lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp lldb/trunk/source/Expression/ClangUserExpression.cpp Modified: lldb/trunk/include/lldb/Expression/ClangASTSource.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Expression/ClangASTSource.h?rev=113866&r1=113865&r2=113866&view=diff ============================================================================== --- lldb/trunk/include/lldb/Expression/ClangASTSource.h (original) +++ lldb/trunk/include/lldb/Expression/ClangASTSource.h Tue Sep 14 16:59:34 2010 @@ -161,8 +161,15 @@ /// /// @param[in] type /// The opaque QualType for the VarDecl being registered. + /// + /// @param[in] override_name + /// In some cases, the name needs to be overridden (such as when + /// searching for ___clang_this, which should resolve to this). + /// This is the name to be used instead of what is being searched + /// for. //------------------------------------------------------------------ - clang::NamedDecl *AddVarDecl(void *type); + clang::NamedDecl *AddVarDecl(void *type, + const char *override_name = NULL); //------------------------------------------------------------------ /// Create a FunDecl with the name being searched for and the provided Modified: lldb/trunk/include/lldb/Expression/ClangExpressionDeclMap.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Expression/ClangExpressionDeclMap.h?rev=113866&r1=113865&r2=113866&view=diff ============================================================================== --- lldb/trunk/include/lldb/Expression/ClangExpressionDeclMap.h (original) +++ lldb/trunk/include/lldb/Expression/ClangExpressionDeclMap.h Tue Sep 14 16:59:34 2010 @@ -342,14 +342,13 @@ std::string m_result_name; ///< The name of the result variable ($1, for example) //------------------------------------------------------------------ - /// Given a symbol context, find a variable that matches the given - /// name and type. We need this for expression re-use; we may not - /// always get the same lldb::Variable back, and we want the expression - /// to work wherever it can. Returns the variable defined in the - /// tightest scope. + /// Given a stack frame, find a variable that matches the given name and + /// type. We need this for expression re-use; we may not always get the + /// same lldb::Variable back, and we want the expression to work wherever + /// it can. Returns the variable defined in the tightest scope. /// - /// @param[in] sym_ctx - /// The SymbolContext to search for the variable. + /// @param[in] frame + /// The stack frame to use as a basis for finding the variable. /// /// @param[in] name /// The name as a plain C string. @@ -362,9 +361,15 @@ /// @return /// The LLDB Variable found, or NULL if none was found. //------------------------------------------------------------------ +#ifdef OLD_CODE Variable *FindVariableInScope(const SymbolContext &sym_ctx, const char *name, TypeFromUser *type = NULL); +#endif + + Variable *FindVariableInScope(StackFrame &frame, + const char *name, + TypeFromUser *type = NULL); //------------------------------------------------------------------ /// Get the value of a variable in a given execution context and return @@ -410,8 +415,14 @@ /// /// @param[in] var /// The LLDB Variable that needs a Decl. - //------------------------------------------------------------------ - void AddOneVariable(NameSearchContext &context, Variable *var); + /// + /// @param[in] override_name + /// A new name to give the Decl, if the one being looked for needs + /// to be overriden. Example: this for ___clang_this. + //------------------------------------------------------------------ + void AddOneVariable(NameSearchContext &context, + Variable *var, + const char *override_name); //------------------------------------------------------------------ /// Use the NameSearchContext to generate a Decl for the given Modified: lldb/trunk/source/Expression/ClangASTSource.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/ClangASTSource.cpp?rev=113866&r1=113865&r2=113866&view=diff ============================================================================== --- lldb/trunk/source/Expression/ClangASTSource.cpp (original) +++ lldb/trunk/source/Expression/ClangASTSource.cpp Tue Sep 14 16:59:34 2010 @@ -85,11 +85,20 @@ return &ASTSource.Context; } -clang::NamedDecl *NameSearchContext::AddVarDecl(void *type) { +clang::NamedDecl *NameSearchContext::AddVarDecl(void *type, + const char *override_name) { + IdentifierInfo *ii = NULL; + + if (override_name) + ii = &ASTSource.Context.Idents.get(override_name); + else + ii = Name.getAsIdentifierInfo(); + + clang::NamedDecl *Decl = VarDecl::Create(ASTSource.Context, const_cast(DC), SourceLocation(), - Name.getAsIdentifierInfo(), + ii, QualType::getFromOpaquePtr(type), 0, VarDecl::Static, Modified: lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp?rev=113866&r1=113865&r2=113866&view=diff ============================================================================== --- lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp (original) +++ lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp Tue Sep 14 16:59:34 2010 @@ -539,7 +539,10 @@ { Log *log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS); - Variable *var = FindVariableInScope(sym_ctx, name, &type); + if (!exe_ctx.frame) + return false; + + Variable *var = FindVariableInScope(*exe_ctx.frame, name, &type); if (!var) { @@ -612,6 +615,7 @@ return true; } +#ifdef OLD_CODE Variable* ClangExpressionDeclMap::FindVariableInScope(const SymbolContext &sym_ctx, const char *name, @@ -715,6 +719,43 @@ return NULL; } +#endif + +Variable * +ClangExpressionDeclMap::FindVariableInScope(StackFrame &frame, + const char *name, + TypeFromUser *type) +{ + Log *log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS); + + ConstString name_cs(name); + + VariableList *var_list = frame.GetVariableList(true); + + lldb::VariableSP var = var_list->FindVariable(name_cs); + + if (!var) + return NULL; + + if (!type) + return var.get(); + + if (type->GetASTContext() == var->GetType()->GetClangAST()) + { + if (!ClangASTContext::AreTypesSame(type->GetASTContext(), type->GetOpaqueQualType(), var->GetType()->GetOpaqueClangQualType())) + return NULL; + } + else + { + if (log) + log->PutCString("Skipping a candidate variable because of different AST contexts"); + return NULL; + } + + return var.get(); + + return NULL; +} // Interface for ClangASTSource void @@ -723,14 +764,23 @@ { Log *log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS); + const char* override_name = NULL; + + if (!strcmp(name, "___clang_this")) + override_name = "this"; + if (!strcmp(name, "___clang_self")) + override_name = "self"; + + const char *search_name = (override_name ? override_name : name); + if (log) - log->Printf("Hunting for a definition for %s", name); + log->Printf("Hunting for a definition for %s", search_name); // Back out in all cases where we're not fully initialized if (!m_exe_ctx || !m_exe_ctx->frame || !m_sym_ctx) return; - - ConstString name_cs(name); + + ConstString name_cs(search_name); SymbolContextList sym_ctxs; m_sym_ctx->FindFunctionsByName(name_cs, false, sym_ctxs); @@ -763,10 +813,10 @@ } } - Variable *var = FindVariableInScope(*m_sym_ctx, name); + Variable *var = FindVariableInScope(*m_exe_ctx->frame, search_name); if (var) - AddOneVariable(context, var); + AddOneVariable(context, var, override_name); ClangExpressionVariable *pvar(m_persistent_vars->GetVariable(name)); @@ -893,7 +943,8 @@ void ClangExpressionDeclMap::AddOneVariable(NameSearchContext &context, - Variable* var) + Variable* var, + const char *override_name) { Log *log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS); @@ -906,10 +957,10 @@ &ut, &pt); - NamedDecl *var_decl = context.AddVarDecl(pt.GetOpaqueQualType()); + NamedDecl *var_decl = context.AddVarDecl(pt.GetOpaqueQualType(), override_name); ClangExpressionVariable &entity(m_found_entities.VariableAtIndex(m_found_entities.CreateVariable())); - entity.m_name = context.Name.getAsString(); + entity.m_name = (override_name ? override_name : context.Name.getAsString()); entity.m_user_type = ut; entity.EnableParserVars(); Modified: lldb/trunk/source/Expression/ClangUserExpression.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/ClangUserExpression.cpp?rev=113866&r1=113865&r2=113866&view=diff ============================================================================== --- lldb/trunk/source/Expression/ClangUserExpression.cpp (original) +++ lldb/trunk/source/Expression/ClangUserExpression.cpp Tue Sep 14 16:59:34 2010 @@ -38,7 +38,13 @@ { StreamString m_transformed_stream; - m_transformed_stream.Printf("extern \"C\" void %s(void *___clang_arg) { %s; }\n", + m_transformed_stream.Printf("#define this ___clang_this \n" + "#define self ___clang_self \n" + "extern \"C\" void \n" + "%s(void *___clang_arg) \n" + "{ \n" + "%s; \n" + "} \n", FunctionName(), m_expr_text.c_str()); From johnny.chen at apple.com Tue Sep 14 17:01:40 2010 From: johnny.chen at apple.com (Johnny Chen) Date: Tue, 14 Sep 2010 22:01:40 -0000 Subject: [Lldb-commits] [lldb] r113868 - in /lldb/trunk/test: class_types/TestClassTypes.py dotest.py lldbtest.py Message-ID: <20100914220140.55E232A6C12C@llvm.org> Author: johnny Date: Tue Sep 14 17:01:40 2010 New Revision: 113868 URL: http://llvm.org/viewvc/llvm-project?rev=113868&view=rev Log: Removed the expectedFailure decorator from test_with_dwarf_and_run_command() test case as it now passes. Added some extra tests to breakpoint_creation_by_filespec_python(). More clarification for the "os command" output and error as defined in lldbtest.system() function. Cleaned up the option processing of the test driver (dotest.py) and fixed the comment about enabling gdb-remote logging. Example: $ GDB_REMOTE_LOG=/tmp/log.txt ./dotest.py -v -t enum_types Modified: lldb/trunk/test/class_types/TestClassTypes.py lldb/trunk/test/dotest.py lldb/trunk/test/lldbtest.py Modified: lldb/trunk/test/class_types/TestClassTypes.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/class_types/TestClassTypes.py?rev=113868&r1=113867&r2=113868&view=diff ============================================================================== --- lldb/trunk/test/class_types/TestClassTypes.py (original) +++ lldb/trunk/test/class_types/TestClassTypes.py Tue Sep 14 17:01:40 2010 @@ -24,7 +24,6 @@ # rdar://problem/8378863 # "frame variable this" returns # error: unable to find any variables named 'this' - @unittest2.expectedFailure def test_with_dwarf_and_run_command(self): """Test 'frame variable this' when stopped on a class constructor.""" self.buildDwarf() @@ -69,15 +68,26 @@ filespec = target.GetExecutable() self.assertTrue(filespec.IsValid(), VALID_FILESPEC) - breakpoint = target.BreakpointCreateByLocation(filespec, 73) - self.assertTrue(breakpoint.IsValid(), VALID_BREAKPOINT) - fsDir = filespec.GetDirectory() fsFile = filespec.GetFilename() self.assertTrue(fsDir == os.getcwd() and fsFile == "a.out", "FileSpec matches the executable") + bpfilespec = lldb.SBFileSpec("main.cpp") + + breakpoint = target.BreakpointCreateByLocation(bpfilespec, 73) + self.assertTrue(breakpoint.IsValid(), VALID_BREAKPOINT) + + # Verify the breakpoint just created. + self.expect("breakpoint list", BREAKPOINT_CREATED, + substrs = ['main.cpp:73']) + + self.runCmd("run", RUN_SUCCEEDED) + + # We should be stopped on the breakpoint with a hit count of 1. + self.assertTrue(breakpoint.GetHitCount() == 1) + if __name__ == '__main__': import atexit Modified: lldb/trunk/test/dotest.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/dotest.py?rev=113868&r1=113867&r2=113868&view=diff ============================================================================== --- lldb/trunk/test/dotest.py (original) +++ lldb/trunk/test/dotest.py Tue Sep 14 17:01:40 2010 @@ -70,6 +70,15 @@ Running of this script also sets up the LLDB_TEST environment variable so that individual test cases can locate their supporting files correctly. + +Environment variables related to loggings: + +o LLDB_LOG: if defined, specifies the log file pathname for the 'lldb' subsystem + with a default option of 'event process' if LLDB_LOG_OPTION is not defined. + +o GDB_REMOTE_LOG: if defined, specifies the log file pathname for the + 'process.gdb-remote' subsystem with a default option of 'packets' if + GDB_REMOTE_LOG_OPTION is not defined. """ @@ -126,14 +135,18 @@ else: # Process possible trace and/or verbose flag. index = 1 - for i in range(1, len(sys.argv) - 1): + for i in range(1, len(sys.argv)): + if not sys.argv[index].startswith('-'): + # End of option processing. + break + if sys.argv[index].startswith('-d'): delay = True index += 1 - if sys.argv[index].startswith('-t'): + elif sys.argv[index].startswith('-t'): os.environ["LLDB_COMMAND_TRACE"] = "YES" index += 1 - if sys.argv[index].startswith('-v'): + elif sys.argv[index].startswith('-v'): verbose = 2 index += 1 @@ -219,7 +232,7 @@ res) if not res.Succeeded(): raise Exception('log enable failed (check LLDB_LOG env variable.') -# Ditto for gdb-remote logging if ${LLDB_LOG} environment variable is defined. +# Ditto for gdb-remote logging if ${GDB_REMOTE_LOG} environment variable is defined. # Use ${GDB_REMOTE_LOG} to specify the log file. if ("GDB_REMOTE_LOG" in os.environ): if ("GDB_REMOTE_LOG_OPTION" in os.environ): Modified: lldb/trunk/test/lldbtest.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/lldbtest.py?rev=113868&r1=113867&r2=113868&view=diff ============================================================================== --- lldb/trunk/test/lldbtest.py (original) +++ lldb/trunk/test/lldbtest.py Tue Sep 14 17:01:40 2010 @@ -228,7 +228,7 @@ if 'stdout' in kwargs: raise ValueError('stdout argument not allowed, it will be overridden.') process = Popen(stdout=PIPE, *popenargs, **kwargs) - output, unused_err = process.communicate() + output, error = process.communicate() retcode = process.poll() if traceAlways: @@ -239,8 +239,9 @@ print >> sys.stderr print >> sys.stderr, "os command:", args print >> sys.stderr, "output:", output - print >> sys.stderr, "error:", unused_err - print >> sys.stderr, "retcode:", retcode + print >> sys.stderr, "error (from os comand):", error + print >> sys.stderr, "retcode (from os command):", retcode + print >> sys.stderr if retcode: cmd = kwargs.get("args") From jingham at apple.com Tue Sep 14 17:03:00 2010 From: jingham at apple.com (Jim Ingham) Date: Tue, 14 Sep 2010 22:03:00 -0000 Subject: [Lldb-commits] [lldb] r113869 - in /lldb/trunk: include/lldb/Core/Mangled.h include/lldb/Target/ThreadPlanRunToAddress.h lldb.xcodeproj/project.pbxproj source/Core/Mangled.cpp source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.cpp source/Target/ThreadPlanRunToAddress.cpp source/Target/ThreadPlanStepInRange.cpp Message-ID: <20100914220300.9C5A42A6C12C@llvm.org> Author: jingham Date: Tue Sep 14 17:03:00 2010 New Revision: 113869 URL: http://llvm.org/viewvc/llvm-project?rev=113869&view=rev Log: Add the ability for "ThreadPlanRunToAddress" to run to multiple addresses. Added the ability to specify a preference for mangled or demangled to Mangled::GetName. Changed one place where mangled was prefered in GetName. The Dynamic loader should look up the target of a stub by mangled name if it exists. Modified: lldb/trunk/include/lldb/Core/Mangled.h lldb/trunk/include/lldb/Target/ThreadPlanRunToAddress.h lldb/trunk/lldb.xcodeproj/project.pbxproj lldb/trunk/source/Core/Mangled.cpp lldb/trunk/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.cpp lldb/trunk/source/Target/ThreadPlanRunToAddress.cpp lldb/trunk/source/Target/ThreadPlanStepInRange.cpp Modified: lldb/trunk/include/lldb/Core/Mangled.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/Mangled.h?rev=113869&r1=113868&r2=113869&view=diff ============================================================================== --- lldb/trunk/include/lldb/Core/Mangled.h (original) +++ lldb/trunk/include/lldb/Core/Mangled.h Tue Sep 14 17:03:00 2010 @@ -51,6 +51,12 @@ eQualifier, ///< A language qualifier eError ///< The token failed to parse }; + + enum NamePreference + { + ePreferMangled, + ePreferDemangled + }; //------------------------------------------------------------------ /// Mangled::Token structure @@ -415,13 +421,16 @@ //---------------------------------------------------------------------- /// Best name get accessor. /// + /// @param[in] preference + /// Which name would you prefer to get? + /// /// @return - /// A const reference to the the mangled name string object if this - /// object has a valid mangled name, else a const reference to the - /// demangled name is returned. + /// A const reference to the the preferred name string object if this + /// object has a valid name of that kind, else a const reference to the + /// other name is returned. //---------------------------------------------------------------------- const ConstString& - GetName () const; + GetName (NamePreference preference = ePreferDemangled) const; //---------------------------------------------------------------------- /// Generate the tokens from the demangled name. Modified: lldb/trunk/include/lldb/Target/ThreadPlanRunToAddress.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/ThreadPlanRunToAddress.h?rev=113869&r1=113868&r2=113869&view=diff ============================================================================== --- lldb/trunk/include/lldb/Target/ThreadPlanRunToAddress.h (original) +++ lldb/trunk/include/lldb/Target/ThreadPlanRunToAddress.h Tue Sep 14 17:03:00 2010 @@ -12,6 +12,8 @@ // C Includes // C++ Includes +#include + // Other libraries and framework includes // Project includes #include "lldb/lldb-private.h" @@ -30,6 +32,11 @@ lldb::addr_t address, bool stop_others); + ThreadPlanRunToAddress (Thread &thread, + std::vector &addresses, + bool stop_others); + + virtual ~ThreadPlanRunToAddress (); @@ -61,13 +68,13 @@ MischiefManaged (); protected: - void SetInitialBreakpoint(); + void SetInitialBreakpoints(); bool AtOurAddress(); private: bool m_stop_others; - lldb::addr_t m_address; // This is the address we are going to run to. + std::vector m_addresses; // This is the address we are going to run to. // TODO: Would it be useful to have multiple addresses? - lldb::user_id_t m_break_id; // This is the breakpoint we are using to stop us at m_address. + std::vector m_break_ids; // This is the breakpoint we are using to stop us at m_address. DISALLOW_COPY_AND_ASSIGN (ThreadPlanRunToAddress); Modified: lldb/trunk/lldb.xcodeproj/project.pbxproj URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/lldb.xcodeproj/project.pbxproj?rev=113869&r1=113868&r2=113869&view=diff ============================================================================== --- lldb/trunk/lldb.xcodeproj/project.pbxproj (original) +++ lldb/trunk/lldb.xcodeproj/project.pbxproj Tue Sep 14 17:03:00 2010 @@ -2325,7 +2325,6 @@ isa = PBXProject; buildConfigurationList = 1DEB91EF08733DB70010E9CD /* Build configuration list for PBXProject "lldb" */; compatibilityVersion = "Xcode 3.1"; - developmentRegion = English; hasScannedForEncodings = 1; knownRegions = ( en, Modified: lldb/trunk/source/Core/Mangled.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/Mangled.cpp?rev=113869&r1=113868&r2=113869&view=diff ============================================================================== --- lldb/trunk/source/Core/Mangled.cpp (original) +++ lldb/trunk/source/Core/Mangled.cpp Tue Sep 14 17:03:00 2010 @@ -95,7 +95,7 @@ int Mangled::Compare (const Mangled& a, const Mangled& b) { - return ConstString::Compare(a.GetName(), a.GetName()); + return ConstString::Compare(a.GetName(ePreferDemangled), a.GetName(ePreferDemangled)); } @@ -214,12 +214,28 @@ // Get the demangled name if there is one, else return the mangled name. //---------------------------------------------------------------------- const ConstString& -Mangled::GetName () const +Mangled::GetName (Mangled::NamePreference preference) const { - const ConstString& name = GetDemangledName(); - if (name && !name.IsEmpty()) - return name; - return m_mangled; + switch (preference) + { + case ePreferDemangled: + { + const ConstString& name = GetDemangledName(); + if (name && !name.IsEmpty()) + return name; + return m_mangled; + } + break; + case ePreferMangled: + { + const ConstString& name = GetMangledName(); + if (name && !name.IsEmpty()) + return name; + return m_demangled; + + } + break; + } } //---------------------------------------------------------------------- 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=113869&r1=113868&r2=113869&view=diff ============================================================================== --- lldb/trunk/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.cpp (original) +++ lldb/trunk/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.cpp Tue Sep 14 17:03:00 2010 @@ -1067,12 +1067,14 @@ StackFrame *current_frame = thread.GetStackFrameAtIndex(0).get(); const SymbolContext ¤t_context = current_frame->GetSymbolContext(eSymbolContextSymbol); Symbol *current_symbol = current_context.symbol; + Log *log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_STEP); if (current_symbol != NULL) { if (current_symbol->IsTrampoline()) { - const ConstString &trampoline_name = current_symbol->GetMangled().GetName(); + const ConstString &trampoline_name = current_symbol->GetMangled().GetName(Mangled::ePreferMangled); + if (trampoline_name) { SymbolContextList target_symbols; @@ -1080,7 +1082,8 @@ images.FindSymbolsWithNameAndType(trampoline_name, eSymbolTypeCode, target_symbols); // FIXME - Make the Run to Address take multiple addresses, and // run to any of them. - if (target_symbols.GetSize() == 1) + uint32_t num_symbols = target_symbols.GetSize(); + if (num_symbols == 1) { SymbolContext context; AddressRange addr_range; @@ -1089,18 +1092,37 @@ context.GetAddressRange (eSymbolContextEverything, addr_range); thread_plan_sp.reset (new ThreadPlanRunToAddress (thread, addr_range.GetBaseAddress(), stop_others)); } + else + { + if (log) + log->Printf ("Couldn't resolve the symbol context."); + } } - else if (target_symbols.GetSize() > 1) + else if (num_symbols > 1) { - Log *log = DynamicLoaderMacOSXDYLDLog::GetLogIfAllCategoriesSet (1); - if (log) + std::vector addresses; + addresses.resize (num_symbols); + for (uint32_t i = 0; i < num_symbols; i++) { - log->Printf ("Found more than one symbol for trampoline target: \"%s\"", trampoline_name.AsCString()); + SymbolContext context; + AddressRange addr_range; + if (target_symbols.GetContextAtIndex(i, context)) + { + context.GetAddressRange (eSymbolContextEverything, addr_range); + lldb::addr_t load_addr = addr_range.GetBaseAddress().GetLoadAddress(&(thread.GetProcess())); + addresses[i] = load_addr; + } + } + if (addresses.size() > 0) + thread_plan_sp.reset (new ThreadPlanRunToAddress (thread, addresses, stop_others)); + else + { + if (log) + log->Printf ("Couldn't resolve the symbol contexts."); } } else { - Log *log = DynamicLoaderMacOSXDYLDLog::GetLogIfAllCategoriesSet (1); if (log) { log->Printf ("Could not find symbol for trampoline target: \"%s\"", trampoline_name.AsCString()); @@ -1109,6 +1131,11 @@ } } } + else + { + if (log) + log->Printf ("Could not find symbol for step through."); + } if (thread_plan_sp == NULL && m_objc_trampoline_handler_ap.get()) thread_plan_sp = m_objc_trampoline_handler_ap->GetStepThroughDispatchPlan (thread, stop_others); Modified: lldb/trunk/source/Target/ThreadPlanRunToAddress.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/ThreadPlanRunToAddress.cpp?rev=113869&r1=113868&r2=113869&view=diff ============================================================================== --- lldb/trunk/source/Target/ThreadPlanRunToAddress.cpp (original) +++ lldb/trunk/source/Target/ThreadPlanRunToAddress.cpp Tue Sep 14 17:03:00 2010 @@ -34,13 +34,13 @@ Address &address, bool stop_others ) : - ThreadPlan (ThreadPlan::eKindRunToAddress, "Run to breakpoint plan", thread, eVoteNoOpinion, eVoteNoOpinion), + ThreadPlan (ThreadPlan::eKindRunToAddress, "Run to address plan", thread, eVoteNoOpinion, eVoteNoOpinion), m_stop_others (stop_others), - m_address (LLDB_INVALID_ADDRESS), - m_break_id (LLDB_INVALID_BREAK_ID) + m_addresses (), + m_break_ids () { - m_address = address.GetLoadAddress(&m_thread.GetProcess()); - SetInitialBreakpoint(); + m_addresses.push_back (address.GetLoadAddress(&m_thread.GetProcess())); + SetInitialBreakpoints(); } ThreadPlanRunToAddress::ThreadPlanRunToAddress @@ -49,52 +49,109 @@ lldb::addr_t address, bool stop_others ) : - ThreadPlan (ThreadPlan::eKindRunToAddress, "Run to breakpoint plan", thread, eVoteNoOpinion, eVoteNoOpinion), + ThreadPlan (ThreadPlan::eKindRunToAddress, "Run to address plan", thread, eVoteNoOpinion, eVoteNoOpinion), m_stop_others (stop_others), - m_address (address), - m_break_id (LLDB_INVALID_BREAK_ID) + m_addresses (), + m_break_ids () { - SetInitialBreakpoint(); + m_addresses.push_back(address); + SetInitialBreakpoints(); +} + +ThreadPlanRunToAddress::ThreadPlanRunToAddress +( + Thread &thread, + std::vector &addresses, + bool stop_others +) : + ThreadPlan (ThreadPlan::eKindRunToAddress, "Run to address plan", thread, eVoteNoOpinion, eVoteNoOpinion), + m_stop_others (stop_others), + m_addresses (addresses), + m_break_ids () +{ + SetInitialBreakpoints(); } void -ThreadPlanRunToAddress::SetInitialBreakpoint () +ThreadPlanRunToAddress::SetInitialBreakpoints () { - Breakpoint *breakpoint; - breakpoint = m_thread.GetProcess().GetTarget().CreateBreakpoint (m_address, true).get(); - if (breakpoint != NULL) + size_t num_addresses = m_addresses.size(); + m_break_ids.resize(num_addresses); + + for (size_t i = 0; i < num_addresses; i++) { - m_break_id = breakpoint->GetID(); - breakpoint->SetThreadID(m_thread.GetID()); + Breakpoint *breakpoint; + breakpoint = m_thread.GetProcess().GetTarget().CreateBreakpoint (m_addresses[i], true).get(); + if (breakpoint != NULL) + { + m_break_ids[i] = breakpoint->GetID(); + breakpoint->SetThreadID(m_thread.GetID()); + } } } ThreadPlanRunToAddress::~ThreadPlanRunToAddress () { - if (m_break_id != LLDB_INVALID_BREAK_ID) + size_t num_break_ids = m_break_ids.size(); + for (size_t i = 0; i < num_break_ids; i++) { - m_thread.GetProcess().GetTarget().RemoveBreakpointByID (m_break_id); + m_thread.GetProcess().GetTarget().RemoveBreakpointByID (m_break_ids[i]); } } void ThreadPlanRunToAddress::GetDescription (Stream *s, lldb::DescriptionLevel level) { + size_t num_addresses = m_addresses.size(); + if (level == lldb::eDescriptionLevelBrief) { - s->Printf ("run to address: "); - s->Address (m_address, sizeof (addr_t)); + if (num_addresses == 0) + { + s->Printf ("run to address with no addresses given."); + return; + } + else if (num_addresses == 1) + s->Printf ("run to address: "); + else + s->Printf ("run to addresses: "); + + for (size_t i = 0; i < num_addresses; i++) + { + s->Address (m_addresses[i], sizeof (addr_t)); + s->Printf(" "); + } } else { - s->Printf ("Run to address: "); - s->Address(m_address, sizeof (addr_t)); - s->Printf (" using breakpoint: %d - ", m_break_id); - Breakpoint *breakpoint = m_thread.GetProcess().GetTarget().GetBreakpointByID (m_break_id).get(); - if (breakpoint) - breakpoint->Dump (s); + if (num_addresses == 0) + { + s->Printf ("run to address with no addresses given."); + return; + } + else if (num_addresses == 1) + s->Printf ("Run to address: "); else - s->Printf ("but the breakpoint has been deleted."); + { + s->Printf ("Run to addresses: "); + } + + for (size_t i = 0; i < num_addresses; i++) + { + if (num_addresses > 1) + { + s->Printf("\n"); + s->Indent(); + } + + s->Address(m_addresses[i], sizeof (addr_t)); + s->Printf (" using breakpoint: %d - ", m_break_ids[i]); + Breakpoint *breakpoint = m_thread.GetProcess().GetTarget().GetBreakpointByID (m_break_ids[i]).get(); + if (breakpoint) + breakpoint->Dump (s); + else + s->Printf ("but the breakpoint has been deleted."); + } } } @@ -103,10 +160,20 @@ { // If we couldn't set the breakpoint for some reason, then this won't // work. - if(m_break_id == LLDB_INVALID_BREAK_ID) - return false; - else - return true; + bool all_bps_good = true; + size_t num_break_ids = m_break_ids.size(); + + for (size_t i = 0; i < num_break_ids; i++) + { + if (m_break_ids[i] == LLDB_INVALID_BREAK_ID) + { + all_bps_good = false; + error->Printf ("Could not set breakpoint for address: "); + error->Address (m_addresses[i], sizeof (addr_t)); + error->Printf ("\n"); + } + } + return all_bps_good; } bool @@ -153,12 +220,16 @@ if (AtOurAddress()) { // Remove the breakpoint - if (m_break_id != LLDB_INVALID_BREAK_ID) + size_t num_break_ids = m_break_ids.size(); + + for (size_t i = 0; i < num_break_ids; i++) { - m_thread.GetProcess().GetTarget().RemoveBreakpointByID (m_break_id); - m_break_id = LLDB_INVALID_BREAK_ID; + if (m_break_ids[i] != LLDB_INVALID_BREAK_ID) + { + m_thread.GetProcess().GetTarget().RemoveBreakpointByID (m_break_ids[i]); + m_break_ids[i] = LLDB_INVALID_BREAK_ID; + } } - if (log) log->Printf("Completed run to address plan."); ThreadPlan::MischiefManaged (); @@ -172,5 +243,14 @@ ThreadPlanRunToAddress::AtOurAddress () { lldb::addr_t current_address = m_thread.GetRegisterContext()->GetPC(); - return m_address == current_address; + bool found_it = false; + for (size_t i = 0; i < m_addresses[i]; i++) + { + if (m_addresses[i] == current_address) + { + found_it = true; + break; + } + } + return found_it; } Modified: lldb/trunk/source/Target/ThreadPlanStepInRange.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/ThreadPlanStepInRange.cpp?rev=113869&r1=113868&r2=113869&view=diff ============================================================================== --- lldb/trunk/source/Target/ThreadPlanStepInRange.cpp (original) +++ lldb/trunk/source/Target/ThreadPlanStepInRange.cpp Tue Sep 14 17:03:00 2010 @@ -111,6 +111,15 @@ stop_others = false; new_plan = m_thread.QueueThreadPlanForStepThrough (false, stop_others); + + if (log) + { + if (new_plan != NULL) + log->Printf ("Found a step through plan: %s", new_plan->GetName()); + else + log->Printf ("No step through plan found."); + } + // If not, give the "should_stop" callback a chance to push a plan to get us out of here. // But only do that if we actually have stepped in. if (!new_plan && FrameIsYounger()) From johnny.chen at apple.com Tue Sep 14 17:10:43 2010 From: johnny.chen at apple.com (Johnny Chen) Date: Tue, 14 Sep 2010 22:10:43 -0000 Subject: [Lldb-commits] [lldb] r113874 - /lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp Message-ID: <20100914221043.5A46D2A6C12C@llvm.org> Author: johnny Date: Tue Sep 14 17:10:43 2010 New Revision: 113874 URL: http://llvm.org/viewvc/llvm-project?rev=113874&view=rev Log: Added logging of an error message in GDBRemoteCommunication::SendPacketNoLock() if sending of the packet fails for any reason. Modified: lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp Modified: lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp?rev=113874&r1=113873&r2=113874&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp (original) +++ lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp Tue Sep 14 17:10:43 2010 @@ -393,6 +393,10 @@ return 0; } } + else + { + ProcessGDBRemoteLog::LogIf (GDBR_LOG_PACKETS, "error: failed to send packet: %s", packet.GetData()); + } return bytes_written; } //m_error.SetErrorString("Not connected."); From johnny.chen at apple.com Tue Sep 14 17:39:02 2010 From: johnny.chen at apple.com (Johnny Chen) Date: Tue, 14 Sep 2010 22:39:02 -0000 Subject: [Lldb-commits] [lldb] r113879 - /lldb/trunk/test/lldbtest.py Message-ID: <20100914223902.C3E2D2A6C12C@llvm.org> Author: johnny Date: Tue Sep 14 17:39:02 2010 New Revision: 113879 URL: http://llvm.org/viewvc/llvm-project?rev=113879&view=rev Log: More appropriate headings for the traceoutput: stdout & stderr. Modified: lldb/trunk/test/lldbtest.py Modified: lldb/trunk/test/lldbtest.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/lldbtest.py?rev=113879&r1=113878&r2=113879&view=diff ============================================================================== --- lldb/trunk/test/lldbtest.py (original) +++ lldb/trunk/test/lldbtest.py Tue Sep 14 17:39:02 2010 @@ -238,9 +238,9 @@ args = list(popenargs) print >> sys.stderr print >> sys.stderr, "os command:", args - print >> sys.stderr, "output:", output - print >> sys.stderr, "error (from os comand):", error - print >> sys.stderr, "retcode (from os command):", retcode + print >> sys.stderr, "stdout:", output + print >> sys.stderr, "stderr:", error + print >> sys.stderr, "retcode:", retcode print >> sys.stderr if retcode: From ctice at apple.com Tue Sep 14 17:49:06 2010 From: ctice at apple.com (Caroline Tice) Date: Tue, 14 Sep 2010 22:49:06 -0000 Subject: [Lldb-commits] [lldb] r113880 - in /lldb/trunk/source: Commands/CommandObjectProcess.cpp Interpreter/ScriptInterpreterPython.cpp Message-ID: <20100914224906.A979C2A6C12C@llvm.org> Author: ctice Date: Tue Sep 14 17:49:06 2010 New Revision: 113880 URL: http://llvm.org/viewvc/llvm-project?rev=113880&view=rev Log: Remove help text that is no longer correct. Fix Python script interpreter to not fail when the Debugger does not have input/output file handles. Modified: lldb/trunk/source/Commands/CommandObjectProcess.cpp lldb/trunk/source/Interpreter/ScriptInterpreterPython.cpp Modified: lldb/trunk/source/Commands/CommandObjectProcess.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectProcess.cpp?rev=113880&r1=113879&r2=113880&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectProcess.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectProcess.cpp Tue Sep 14 17:49:06 2010 @@ -464,8 +464,6 @@ "Attach to a process.", "process attach ") { - SetHelpLong("Currently, you must set the executable file before you can attach " - "to a process.\n"); } ~CommandObjectProcessAttach () Modified: lldb/trunk/source/Interpreter/ScriptInterpreterPython.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Interpreter/ScriptInterpreterPython.cpp?rev=113880&r1=113879&r2=113880&view=diff ============================================================================== --- lldb/trunk/source/Interpreter/ScriptInterpreterPython.cpp (original) +++ lldb/trunk/source/Interpreter/ScriptInterpreterPython.cpp Tue Sep 14 17:49:06 2010 @@ -298,8 +298,13 @@ case eInputReaderActivate: { // Save terminal settings if we can + int input_fd; FILE *input_fh = reader.GetDebugger().GetInputFileHandle(); - int input_fd = ::fileno (input_fh); + if (input_fh != NULL) + input_fd = ::fileno (input_fh); + else + input_fd = STDIN_FILENO; + script_interpreter->m_termios_valid = ::tcgetattr (input_fd, &script_interpreter->m_termios) == 0; struct termios tmp_termios; if (::tcgetattr (input_fd, &tmp_termios) == 0) @@ -335,9 +340,14 @@ // Restore terminal settings if they were validly saved if (script_interpreter->m_termios_valid) { - ::tcsetattr (::fileno (reader.GetDebugger().GetInputFileHandle()), - TCSANOW, - &script_interpreter->m_termios); + int input_fd; + FILE *input_fh = reader.GetDebugger().GetInputFileHandle(); + if (input_fh != NULL) + input_fd = ::fileno (input_fh); + else + input_fd = STDIN_FILENO; + + ::tcsetattr (input_fd, TCSANOW, &script_interpreter->m_termios); } break; } @@ -352,6 +362,15 @@ Timer scoped_timer (__PRETTY_FUNCTION__, __PRETTY_FUNCTION__); Debugger &debugger = interpreter.GetDebugger(); + + // At the moment, the only time the debugger does not have an input file handle is when this is called + // directly from Python, in which case it is both dangerous and unnecessary (not to mention confusing) to + // try to embed a running interpreter loop inside the already running Python interpreter loop, so we won't + // do it. + + if (debugger.GetInputFileHandle() == NULL) + return; + InputReaderSP reader_sp (new InputReader(debugger)); if (reader_sp) { @@ -556,6 +575,9 @@ static StringList commands_in_progress; FILE *out_fh = reader.GetDebugger().GetOutputFileHandle(); + if (out_fh == NULL) + out_fh = stdout; + switch (notification) { case eInputReaderActivate: From johnny.chen at apple.com Tue Sep 14 17:50:50 2010 From: johnny.chen at apple.com (Johnny Chen) Date: Tue, 14 Sep 2010 22:50:50 -0000 Subject: [Lldb-commits] [lldb] r113881 - /lldb/trunk/test/order/TestOrderFile.py Message-ID: <20100914225050.5E7822A6C12C@llvm.org> Author: johnny Date: Tue Sep 14 17:50:50 2010 New Revision: 113881 URL: http://llvm.org/viewvc/llvm-project?rev=113881&view=rev Log: Need to call self.buildDefault() before running the test logic. 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=113881&r1=113880&r2=113881&view=diff ============================================================================== --- lldb/trunk/test/order/TestOrderFile.py (original) +++ lldb/trunk/test/order/TestOrderFile.py Tue Sep 14 17:50:50 2010 @@ -14,6 +14,8 @@ def test_order_file(self): """Test debug symbols follow the correct order by the order file.""" + self.buildDefault() + exe = os.path.join(os.getcwd(), "a.out") self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) From johnny.chen at apple.com Tue Sep 14 17:55:48 2010 From: johnny.chen at apple.com (Johnny Chen) Date: Tue, 14 Sep 2010 22:55:48 -0000 Subject: [Lldb-commits] [lldb] r113884 - /lldb/trunk/test/order/TestOrderFile.py Message-ID: <20100914225548.345E82A6C12C@llvm.org> Author: johnny Date: Tue Sep 14 17:55:48 2010 New Revision: 113884 URL: http://llvm.org/viewvc/llvm-project?rev=113884&view=rev Log: Test order file with both dsym and dwarf combination. 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=113884&r1=113883&r2=113884&view=diff ============================================================================== --- lldb/trunk/test/order/TestOrderFile.py (original) +++ lldb/trunk/test/order/TestOrderFile.py Tue Sep 14 17:55:48 2010 @@ -12,10 +12,19 @@ mydir = "order" - def test_order_file(self): + @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin") + def test_with_dsym(self): """Test debug symbols follow the correct order by the order file.""" - self.buildDefault() + self.buildDsym() + self.order_file() + def test_with_dwarf(self): + """Test debug symbols follow the correct order by the order file.""" + self.buildDwarf() + self.order_file() + + def order_file(self): + """Test debug symbols follow the correct order by the order file.""" exe = os.path.join(os.getcwd(), "a.out") self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) From gclayton at apple.com Tue Sep 14 18:36:40 2010 From: gclayton at apple.com (Greg Clayton) Date: Tue, 14 Sep 2010 23:36:40 -0000 Subject: [Lldb-commits] [lldb] r113895 - in /lldb/trunk: include/lldb/API/ include/lldb/Core/ include/lldb/Symbol/ include/lldb/Target/ lldb.xcodeproj/ source/API/ source/Breakpoint/ source/Commands/ source/Core/ source/Expression/ source/Plugins/Disassembler/llvm/ source/Plugins/DynamicLoader/MacOSX-DYLD/ source/Plugins/Process/MacOSX-User/source/ source/Plugins/Process/Utility/ source/Plugins/Process/gdb-remote/ source/Symbol/ source/Target/ Message-ID: <20100914233641.73AA42A6C12C@llvm.org> Author: gclayton Date: Tue Sep 14 18:36:40 2010 New Revision: 113895 URL: http://llvm.org/viewvc/llvm-project?rev=113895&view=rev Log: Moved the section load list up into the target so we can use the target to symbolicate things without the need for a valid process subclass. Modified: lldb/trunk/include/lldb/API/SBAddress.h lldb/trunk/include/lldb/API/SBTarget.h lldb/trunk/include/lldb/Core/Address.h lldb/trunk/include/lldb/Core/AddressRange.h lldb/trunk/include/lldb/Core/Section.h lldb/trunk/include/lldb/Core/ThreadSafeSTLMap.h lldb/trunk/include/lldb/Symbol/Block.h lldb/trunk/include/lldb/Symbol/Function.h lldb/trunk/include/lldb/Symbol/LineEntry.h lldb/trunk/include/lldb/Symbol/LineTable.h lldb/trunk/include/lldb/Symbol/Symbol.h lldb/trunk/include/lldb/Symbol/SymbolContext.h lldb/trunk/include/lldb/Symbol/Symtab.h lldb/trunk/include/lldb/Symbol/UnwindPlan.h lldb/trunk/include/lldb/Target/Process.h lldb/trunk/include/lldb/Target/Target.h lldb/trunk/lldb.xcodeproj/project.pbxproj lldb/trunk/source/API/SBAddress.cpp lldb/trunk/source/API/SBBreakpoint.cpp lldb/trunk/source/API/SBFrame.cpp lldb/trunk/source/API/SBTarget.cpp lldb/trunk/source/Breakpoint/BreakpointLocation.cpp lldb/trunk/source/Commands/CommandObjectImage.cpp lldb/trunk/source/Commands/CommandObjectThread.cpp lldb/trunk/source/Core/Address.cpp lldb/trunk/source/Core/AddressRange.cpp lldb/trunk/source/Core/Disassembler.cpp lldb/trunk/source/Core/Section.cpp lldb/trunk/source/Core/Value.cpp lldb/trunk/source/Core/ValueObject.cpp lldb/trunk/source/Core/ValueObjectVariable.cpp lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp lldb/trunk/source/Expression/ClangFunction.cpp lldb/trunk/source/Plugins/Disassembler/llvm/DisassemblerLLVM.cpp lldb/trunk/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.cpp lldb/trunk/source/Plugins/DynamicLoader/MacOSX-DYLD/ObjCTrampolineHandler.cpp lldb/trunk/source/Plugins/Process/MacOSX-User/source/ThreadMacOSX.cpp lldb/trunk/source/Plugins/Process/Utility/MacOSXLibunwindCallbacks.cpp lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp lldb/trunk/source/Symbol/Block.cpp lldb/trunk/source/Symbol/Function.cpp lldb/trunk/source/Symbol/LineEntry.cpp lldb/trunk/source/Symbol/LineTable.cpp lldb/trunk/source/Symbol/Symbol.cpp lldb/trunk/source/Symbol/SymbolContext.cpp lldb/trunk/source/Symbol/Symtab.cpp lldb/trunk/source/Symbol/UnwindPlan.cpp lldb/trunk/source/Symbol/Variable.cpp lldb/trunk/source/Target/Process.cpp lldb/trunk/source/Target/StackFrame.cpp lldb/trunk/source/Target/Target.cpp lldb/trunk/source/Target/ThreadPlanCallFunction.cpp lldb/trunk/source/Target/ThreadPlanRunToAddress.cpp lldb/trunk/source/Target/ThreadPlanStepInRange.cpp lldb/trunk/source/Target/ThreadPlanStepOverRange.cpp lldb/trunk/source/Target/ThreadPlanStepRange.cpp Modified: lldb/trunk/include/lldb/API/SBAddress.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBAddress.h?rev=113895&r1=113894&r2=113895&view=diff ============================================================================== --- lldb/trunk/include/lldb/API/SBAddress.h (original) +++ lldb/trunk/include/lldb/API/SBAddress.h Tue Sep 14 18:36:40 2010 @@ -39,7 +39,7 @@ GetFileAddress () const; addr_t - GetLoadAddress (const lldb::SBProcess &process) const; + GetLoadAddress (const lldb::SBTarget &target) const; bool OffsetAddress (addr_t offset); Modified: lldb/trunk/include/lldb/API/SBTarget.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBTarget.h?rev=113895&r1=113894&r2=113895&view=diff ============================================================================== --- lldb/trunk/include/lldb/API/SBTarget.h (original) +++ lldb/trunk/include/lldb/API/SBTarget.h Tue Sep 14 18:36:40 2010 @@ -143,6 +143,7 @@ #endif protected: + friend class SBAddress; friend class SBDebugger; friend class SBProcess; Modified: lldb/trunk/include/lldb/Core/Address.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/Address.h?rev=113895&r1=113894&r2=113895&view=diff ============================================================================== --- lldb/trunk/include/lldb/Core/Address.h (original) +++ lldb/trunk/include/lldb/Core/Address.h Tue Sep 14 18:36:40 2010 @@ -197,7 +197,7 @@ CompareFileAddress (const Address& lhs, const Address& rhs); static int - CompareLoadAddress (const Address& lhs, const Address& rhs, Process *process); + CompareLoadAddress (const Address& lhs, const Address& rhs, Target *target); static int CompareModulePointerAndOffset (const Address& lhs, const Address& rhs); @@ -291,7 +291,7 @@ /// the address is currently not loaded. //------------------------------------------------------------------ lldb::addr_t - GetLoadAddress (Process *process) const; + GetLoadAddress (Target *target) const; //------------------------------------------------------------------ /// Get the section relative offset value. Modified: lldb/trunk/include/lldb/Core/AddressRange.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/AddressRange.h?rev=113895&r1=113894&r2=113895&view=diff ============================================================================== --- lldb/trunk/include/lldb/Core/AddressRange.h (original) +++ lldb/trunk/include/lldb/Core/AddressRange.h Tue Sep 14 18:36:40 2010 @@ -163,7 +163,7 @@ /// in the address range, \b false otherwise. //------------------------------------------------------------------ bool - ContainsLoadAddress (const Address &so_addr, Process *process) const; + ContainsLoadAddress (const Address &so_addr, Target *target) const; //------------------------------------------------------------------ /// Check if the resolved load address \a load_addr is contained @@ -178,7 +178,7 @@ /// range, \b false otherwise. //------------------------------------------------------------------ bool - ContainsLoadAddress (lldb::addr_t load_addr, Process *process) const; + ContainsLoadAddress (lldb::addr_t load_addr, Target *target) const; //------------------------------------------------------------------ /// Dump a description of this object to a Stream. @@ -203,7 +203,7 @@ /// @see Address::DumpStyle //------------------------------------------------------------------ bool - Dump (Stream *s, Process *process, Address::DumpStyle style, Address::DumpStyle fallback_style = Address::DumpStyleInvalid) const; + Dump (Stream *s, Target *target, Address::DumpStyle style, Address::DumpStyle fallback_style = Address::DumpStyleInvalid) const; //------------------------------------------------------------------ /// Dump a debug description of this object to a Stream. Modified: lldb/trunk/include/lldb/Core/Section.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/Section.h?rev=113895&r1=113894&r2=113895&view=diff ============================================================================== --- lldb/trunk/include/lldb/Core/Section.h (original) +++ lldb/trunk/include/lldb/Core/Section.h Tue Sep 14 18:36:40 2010 @@ -46,7 +46,7 @@ ContainsSection(lldb::user_id_t sect_id) const; void - Dump (Stream *s, Process *process, bool show_header) const; + Dump (Stream *s, Target *target, bool show_header) const; lldb::SectionSP FindSectionByName (const ConstString §ion_dstr) const; @@ -137,13 +137,13 @@ } void - Dump (Stream *s, Process *process) const; + Dump (Stream *s, Target *target) const; void DumpName (Stream *s) const; lldb::addr_t - GetLoadBaseAddress (Process *process) const; + GetLoadBaseAddress (Target *target) const; bool ResolveContainedAddress (lldb::addr_t offset, Address &so_addr) const; Modified: lldb/trunk/include/lldb/Core/ThreadSafeSTLMap.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/ThreadSafeSTLMap.h?rev=113895&r1=113894&r2=113895&view=diff ============================================================================== --- lldb/trunk/include/lldb/Core/ThreadSafeSTLMap.h (original) +++ lldb/trunk/include/lldb/Core/ThreadSafeSTLMap.h Tue Sep 14 18:36:40 2010 @@ -40,6 +40,13 @@ { } + bool + IsEmpty() const + { + Mutex::Locker locker(m_mutex); + return m_collection.empty(); + } + size_t Erase (const _Key& key) { Modified: lldb/trunk/include/lldb/Symbol/Block.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Symbol/Block.h?rev=113895&r1=113894&r2=113895&view=diff ============================================================================== --- lldb/trunk/include/lldb/Symbol/Block.h (original) +++ lldb/trunk/include/lldb/Symbol/Block.h Tue Sep 14 18:36:40 2010 @@ -188,7 +188,7 @@ GetDescription (Stream *s, Function *function, lldb::DescriptionLevel level, - Process *process) const; + Target *target) const; //------------------------------------------------------------------ /// Get the parent block. Modified: lldb/trunk/include/lldb/Symbol/Function.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Symbol/Function.h?rev=113895&r1=113894&r2=113895&view=diff ============================================================================== --- lldb/trunk/include/lldb/Symbol/Function.h (original) +++ lldb/trunk/include/lldb/Symbol/Function.h Tue Sep 14 18:36:40 2010 @@ -487,7 +487,7 @@ GetCompileUnit() const; void - GetDescription(Stream *s, lldb::DescriptionLevel level, Process *process); + GetDescription(Stream *s, lldb::DescriptionLevel level, Target *target); //------------------------------------------------------------------ /// Get accessor for the frame base location. Modified: lldb/trunk/include/lldb/Symbol/LineEntry.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Symbol/LineEntry.h?rev=113895&r1=113894&r2=113895&view=diff ============================================================================== --- lldb/trunk/include/lldb/Symbol/LineEntry.h (original) +++ lldb/trunk/include/lldb/Symbol/LineEntry.h Tue Sep 14 18:36:40 2010 @@ -84,13 +84,13 @@ /// @see Address::DumpStyle //------------------------------------------------------------------ bool - Dump (Stream *s, Process *process, bool show_file, Address::DumpStyle style, Address::DumpStyle fallback_style, bool show_range) const; + Dump (Stream *s, Target *target, bool show_file, Address::DumpStyle style, Address::DumpStyle fallback_style, bool show_range) const; bool GetDescription (Stream *s, lldb::DescriptionLevel level, CompileUnit* cu, - Process *process, + Target *target, bool show_address_only) const; //------------------------------------------------------------------ Modified: lldb/trunk/include/lldb/Symbol/LineTable.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Symbol/LineTable.h?rev=113895&r1=113894&r2=113895&view=diff ============================================================================== --- lldb/trunk/include/lldb/Symbol/LineTable.h (original) +++ lldb/trunk/include/lldb/Symbol/LineTable.h Tue Sep 14 18:36:40 2010 @@ -91,10 +91,10 @@ /// @see Address::DumpStyle //------------------------------------------------------------------ void - Dump (Stream *s, Process *process, Address::DumpStyle style, Address::DumpStyle fallback_style, bool show_line_ranges); + Dump (Stream *s, Target *target, Address::DumpStyle style, Address::DumpStyle fallback_style, bool show_line_ranges); void - GetDescription (Stream *s, Process *process, lldb::DescriptionLevel level); + GetDescription (Stream *s, Target *target, lldb::DescriptionLevel level); //------------------------------------------------------------------ /// Find a line entry that contains the section offset address \a Modified: lldb/trunk/include/lldb/Symbol/Symbol.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Symbol/Symbol.h?rev=113895&r1=113894&r2=113895&view=diff ============================================================================== --- lldb/trunk/include/lldb/Symbol/Symbol.h (original) +++ lldb/trunk/include/lldb/Symbol/Symbol.h Tue Sep 14 18:36:40 2010 @@ -61,7 +61,7 @@ Compare (const ConstString& name, lldb::SymbolType type) const; void - Dump (Stream *s, Process *process, uint32_t index) const; + Dump (Stream *s, Target *target, uint32_t index) const; AddressRange * GetAddressRangePtr (); @@ -109,7 +109,7 @@ SetFlags (uint32_t flags) { m_flags = flags; } void - GetDescription (Stream *s, lldb::DescriptionLevel level, Process *process) const; + GetDescription (Stream *s, lldb::DescriptionLevel level, Target *target) const; Function * GetFunction (); Modified: lldb/trunk/include/lldb/Symbol/SymbolContext.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Symbol/SymbolContext.h?rev=113895&r1=113894&r2=113895&view=diff ============================================================================== --- lldb/trunk/include/lldb/Symbol/SymbolContext.h (original) +++ lldb/trunk/include/lldb/Symbol/SymbolContext.h Tue Sep 14 18:36:40 2010 @@ -140,7 +140,7 @@ /// The stream to which to dump the object descripton. //------------------------------------------------------------------ void - Dump (Stream *s, Process *process) const; + Dump (Stream *s, Target *target) const; //------------------------------------------------------------------ /// Dump the stop context in this object to a Stream. @@ -190,7 +190,7 @@ void GetDescription(Stream *s, lldb::DescriptionLevel level, - Process *process) const; + Target *target) const; uint32_t GetResolvedMask () const; @@ -292,7 +292,7 @@ /// The stream to which to dump the object descripton. //------------------------------------------------------------------ void - Dump(Stream *s, Process *process) const; + Dump(Stream *s, Target *target) const; //------------------------------------------------------------------ /// Get accessor for a symbol context at index \a idx. Modified: lldb/trunk/include/lldb/Symbol/Symtab.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Symbol/Symtab.h?rev=113895&r1=113894&r2=113895&view=diff ============================================================================== --- lldb/trunk/include/lldb/Symbol/Symtab.h (original) +++ lldb/trunk/include/lldb/Symbol/Symtab.h Tue Sep 14 18:36:40 2010 @@ -41,8 +41,8 @@ Symbol * Resize (uint32_t count); uint32_t AddSymbol(const Symbol& symbol); size_t GetNumSymbols() const; - void Dump(Stream *s, Process *process) const; - void Dump(Stream *s, Process *process, std::vector& indexes) const; + void Dump(Stream *s, Target *target) const; + void Dump(Stream *s, Target *target, std::vector& indexes) const; uint32_t GetIndexForSymbol (const Symbol *symbol) const; Symbol * FindSymbolByID (lldb::user_id_t uid) const; Symbol * SymbolAtIndex (uint32_t idx); Modified: lldb/trunk/include/lldb/Symbol/UnwindPlan.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Symbol/UnwindPlan.h?rev=113895&r1=113894&r2=113895&view=diff ============================================================================== --- lldb/trunk/include/lldb/Symbol/UnwindPlan.h (original) +++ lldb/trunk/include/lldb/Symbol/UnwindPlan.h Tue Sep 14 18:36:40 2010 @@ -178,7 +178,7 @@ UnwindPlan () : m_register_kind(-1), m_row_list(), m_plan_valid_address_range() { } - void Dump (Stream& s, Process* process, Thread* thread) const; + void Dump (Stream& s, Thread* thread) const; void AppendRow (const Row& row); Modified: lldb/trunk/include/lldb/Target/Process.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/Process.h?rev=113895&r1=113894&r2=113895&view=diff ============================================================================== --- lldb/trunk/include/lldb/Target/Process.h (original) +++ lldb/trunk/include/lldb/Target/Process.h Tue Sep 14 18:36:40 2010 @@ -24,7 +24,6 @@ #include "lldb/Core/Event.h" #include "lldb/Core/StringList.h" #include "lldb/Core/ThreadSafeValue.h" -#include "lldb/Core/ThreadSafeSTLMap.h" #include "lldb/Core/PluginInterface.h" #include "lldb/Core/UserSettingsController.h" #include "lldb/Breakpoint/BreakpointSiteList.h" @@ -1459,27 +1458,6 @@ virtual DynamicLoader * GetDynamicLoader (); - lldb::addr_t - GetSectionLoadAddress (const Section *section) const; - - bool - ResolveLoadAddress (lldb::addr_t load_addr, Address &so_addr) const; - - bool - SectionLoaded (const Section *section, lldb::addr_t load_addr); - - // The old load address should be specified when unloading to ensure we get - // the correct instance of the section as a shared library could be loaded - // at more than one location. - bool - SectionUnloaded (const Section *section, lldb::addr_t load_addr); - - // Unload all instances of a section. This function can be used on systems - // that don't support multiple copies of the same shared library to be - // loaded at the same time. - size_t - SectionUnloaded (const Section *section); - bool IsRunning () const; @@ -1521,12 +1499,10 @@ GetObjCObjectPrinter(); protected: - typedef ThreadSafeSTLMap SectionLoadColl; //------------------------------------------------------------------ // Member variables //------------------------------------------------------------------ Target & m_target; ///< The target that owns this process. - SectionLoadColl m_section_load_info; ///< A mapping of all currently loaded sections. ThreadSafeValue m_public_state; ThreadSafeValue m_private_state; // The actual state of our process Broadcaster m_private_state_broadcaster; // This broadcaster feeds state changed events into the private state thread's listener. Modified: lldb/trunk/include/lldb/Target/Target.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/Target.h?rev=113895&r1=113894&r2=113895&view=diff ============================================================================== --- lldb/trunk/include/lldb/Target/Target.h (original) +++ lldb/trunk/include/lldb/Target/Target.h Tue Sep 14 18:36:40 2010 @@ -25,6 +25,7 @@ #include "lldb/Target/ABI.h" #include "lldb/Target/ExecutionContextScope.h" #include "lldb/Target/PathMappingList.h" +#include "lldb/Target/SectionLoadList.h" #include "lldb/API/SBTarget.h" @@ -290,6 +291,20 @@ size_t dst_len, Error &error); + + + SectionLoadList& + GetSectionLoadList() + { + return m_section_load_list; + } + + const SectionLoadList& + GetSectionLoadList() const + { + return m_section_load_list; + } + //------------------------------------------------------------------ // lldb::ExecutionContextScope pure virtual functions //------------------------------------------------------------------ @@ -323,6 +338,7 @@ Debugger & m_debugger; ArchSpec m_arch_spec; ModuleList m_images; ///< The list of images for this process (shared libraries and anything dynamically loaded). + SectionLoadList m_section_load_list; BreakpointList m_breakpoint_list; BreakpointList m_internal_breakpoint_list; // We want to tightly control the process destruction process so Modified: lldb/trunk/lldb.xcodeproj/project.pbxproj URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/lldb.xcodeproj/project.pbxproj?rev=113895&r1=113894&r2=113895&view=diff ============================================================================== --- lldb/trunk/lldb.xcodeproj/project.pbxproj (original) +++ lldb/trunk/lldb.xcodeproj/project.pbxproj Tue Sep 14 18:36:40 2010 @@ -14,6 +14,8 @@ 2615DBCB1208B5FC0021781D /* StopInfoMachException.h in Headers */ = {isa = PBXBuildFile; fileRef = 2615DBC91208B5FC0021781D /* StopInfoMachException.h */; }; 261744781168585B005ADD65 /* SBType.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 261744771168585B005ADD65 /* SBType.cpp */; }; 2617447A11685869005ADD65 /* SBType.h in Headers */ = {isa = PBXBuildFile; fileRef = 2617447911685869005ADD65 /* SBType.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 2618D7901240115500F2B8FE /* SectionLoadList.h in Headers */ = {isa = PBXBuildFile; fileRef = 2618D78F1240115500F2B8FE /* SectionLoadList.h */; }; + 2618D7921240116900F2B8FE /* SectionLoadList.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2618D7911240116900F2B8FE /* SectionLoadList.cpp */; }; 261B5A5411C3F2AD00AABD0A /* SharingPtr.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 261B5A5211C3F2AD00AABD0A /* SharingPtr.cpp */; }; 261B5A5511C3F2AD00AABD0A /* SharingPtr.h in Headers */ = {isa = PBXBuildFile; fileRef = 261B5A5311C3F2AD00AABD0A /* SharingPtr.h */; settings = {ATTRIBUTES = (Public, ); }; }; 262CFC7711A4510000946C6C /* debugserver in Resources */ = {isa = PBXBuildFile; fileRef = 26CE05A0115C31E50022F371 /* debugserver */; }; @@ -530,6 +532,8 @@ 2615DBC91208B5FC0021781D /* StopInfoMachException.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = StopInfoMachException.h; path = Utility/StopInfoMachException.h; sourceTree = ""; }; 261744771168585B005ADD65 /* SBType.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = SBType.cpp; path = source/API/SBType.cpp; sourceTree = ""; }; 2617447911685869005ADD65 /* SBType.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SBType.h; path = include/lldb/API/SBType.h; sourceTree = ""; }; + 2618D78F1240115500F2B8FE /* SectionLoadList.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SectionLoadList.h; path = include/lldb/Target/SectionLoadList.h; sourceTree = ""; }; + 2618D7911240116900F2B8FE /* SectionLoadList.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = SectionLoadList.cpp; path = source/Target/SectionLoadList.cpp; sourceTree = ""; }; 261B5A5211C3F2AD00AABD0A /* SharingPtr.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = SharingPtr.cpp; path = source/Utility/SharingPtr.cpp; sourceTree = ""; }; 261B5A5311C3F2AD00AABD0A /* SharingPtr.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SharingPtr.h; path = include/lldb/Utility/SharingPtr.h; sourceTree = ""; }; 261E18CC1148966100BADCD3 /* GDBRemoteRegisterContext.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = GDBRemoteRegisterContext.h; path = "source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.h"; sourceTree = ""; }; @@ -1967,6 +1971,8 @@ 26BC7F3610F1B90C00F91463 /* Process.cpp */, 26BC7DF410F1B81A00F91463 /* RegisterContext.h */, 26BC7F3710F1B90C00F91463 /* RegisterContext.cpp */, + 2618D78F1240115500F2B8FE /* SectionLoadList.h */, + 2618D7911240116900F2B8FE /* SectionLoadList.cpp */, 26BC7DF510F1B81A00F91463 /* StackFrame.h */, 26BC7F3810F1B90C00F91463 /* StackFrame.cpp */, 26BC7DF610F1B81A00F91463 /* StackFrameList.h */, @@ -2271,6 +2277,7 @@ 961FABEB1235F26800F93A47 /* UnwindAssemblyProfiler-x86.h in Headers */, 961FAC1F12360C7D00F93A47 /* ArchDefaultUnwindPlan-x86.h in Headers */, 268F9D53123AA15200B91E9B /* SBSymbolContextList.h in Headers */, + 2618D7901240115500F2B8FE /* SectionLoadList.h in Headers */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -2325,6 +2332,7 @@ isa = PBXProject; buildConfigurationList = 1DEB91EF08733DB70010E9CD /* Build configuration list for PBXProject "lldb" */; compatibilityVersion = "Xcode 3.1"; + developmentRegion = English; hasScannedForEncodings = 1; knownRegions = ( en, @@ -2733,6 +2741,7 @@ 69A01E251236C5D400C660B5 /* Symbols.cpp in Sources */, 69A01E261236C5D400C660B5 /* TimeValue.cpp in Sources */, 268F9D55123AA16600B91E9B /* SBSymbolContextList.cpp in Sources */, + 2618D7921240116900F2B8FE /* SectionLoadList.cpp in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; Modified: lldb/trunk/source/API/SBAddress.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBAddress.cpp?rev=113895&r1=113894&r2=113895&view=diff ============================================================================== --- lldb/trunk/source/API/SBAddress.cpp (original) +++ lldb/trunk/source/API/SBAddress.cpp Tue Sep 14 18:36:40 2010 @@ -85,10 +85,10 @@ } lldb::addr_t -SBAddress::GetLoadAddress (const SBProcess &process) const +SBAddress::GetLoadAddress (const SBTarget &target) const { if (m_opaque_ap.get()) - return m_opaque_ap->GetLoadAddress(process.get()); + return m_opaque_ap->GetLoadAddress(target.get()); else return LLDB_INVALID_ADDRESS; } Modified: lldb/trunk/source/API/SBBreakpoint.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBBreakpoint.cpp?rev=113895&r1=113894&r2=113895&view=diff ============================================================================== --- lldb/trunk/source/API/SBBreakpoint.cpp (original) +++ lldb/trunk/source/API/SBBreakpoint.cpp Tue Sep 14 18:36:40 2010 @@ -134,8 +134,8 @@ if (vm_addr != LLDB_INVALID_ADDRESS) { Address address; - Process *sb_process = m_opaque_sp->GetTarget().GetProcessSP().get(); - if (sb_process == NULL || sb_process->ResolveLoadAddress (vm_addr, address) == false) + Target &target = m_opaque_sp->GetTarget(); + if (target.GetSectionLoadList().ResolveLoadAddress (vm_addr, address) == false) { address.SetSection (NULL); address.SetOffset (vm_addr); @@ -156,8 +156,8 @@ if (vm_addr != LLDB_INVALID_ADDRESS) { Address address; - Process *sb_process = m_opaque_sp->GetTarget().GetProcessSP().get(); - if (sb_process == NULL || sb_process->ResolveLoadAddress (vm_addr, address) == false) + Target &target = m_opaque_sp->GetTarget(); + if (target.GetSectionLoadList().ResolveLoadAddress (vm_addr, address) == false) { address.SetSection (NULL); address.SetOffset (vm_addr); Modified: lldb/trunk/source/API/SBFrame.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBFrame.cpp?rev=113895&r1=113894&r2=113895&view=diff ============================================================================== --- lldb/trunk/source/API/SBFrame.cpp (original) +++ lldb/trunk/source/API/SBFrame.cpp Tue Sep 14 18:36:40 2010 @@ -132,7 +132,7 @@ SBFrame::GetPC () const { if (m_opaque_sp) - return m_opaque_sp->GetFrameCodeAddress().GetLoadAddress (&m_opaque_sp->GetThread().GetProcess()); + return m_opaque_sp->GetFrameCodeAddress().GetLoadAddress (&m_opaque_sp->GetThread().GetProcess().GetTarget()); return LLDB_INVALID_ADDRESS; } Modified: lldb/trunk/source/API/SBTarget.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBTarget.cpp?rev=113895&r1=113894&r2=113895&view=diff ============================================================================== --- lldb/trunk/source/API/SBTarget.cpp (original) +++ lldb/trunk/source/API/SBTarget.cpp Tue Sep 14 18:36:40 2010 @@ -399,6 +399,7 @@ // Make sure the process object is alive if we have one (it might be // created but we might not be launched yet). + Process *process = m_opaque_sp->GetProcessSP().get(); if (process && !process->IsAlive()) process = NULL; @@ -410,11 +411,11 @@ if (!module_sp->ResolveFileAddress (start_addr, range.GetBaseAddress())) range.GetBaseAddress().SetOffset(start_addr); } - else if (process) + else if (m_opaque_sp->GetSectionLoadList().IsEmpty() == false) { // We don't have a module, se we need to figure out if "start_addr" // resolves to anything in a running process. - if (!process->ResolveLoadAddress(start_addr, range.GetBaseAddress())) + if (!m_opaque_sp->GetSectionLoadList().ResolveLoadAddress (start_addr, range.GetBaseAddress())) range.GetBaseAddress().SetOffset(start_addr); } else Modified: lldb/trunk/source/Breakpoint/BreakpointLocation.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Breakpoint/BreakpointLocation.cpp?rev=113895&r1=113894&r2=113895&view=diff ============================================================================== --- lldb/trunk/source/Breakpoint/BreakpointLocation.cpp (original) +++ lldb/trunk/source/Breakpoint/BreakpointLocation.cpp Tue Sep 14 18:36:40 2010 @@ -35,7 +35,7 @@ lldb::tid_t tid, bool hardware ) : - StoppointLocation (loc_id, addr.GetLoadAddress(owner.GetTarget().GetProcessSP().get()), hardware), + StoppointLocation (loc_id, addr.GetLoadAddress(&owner.GetTarget()), hardware), m_address (addr), m_owner (owner), m_options_ap (), @@ -52,7 +52,7 @@ lldb::addr_t BreakpointLocation::GetLoadAddress () const { - return m_address.GetLoadAddress(m_owner.GetTarget().GetProcessSP().get()); + return m_address.GetLoadAddress(&m_owner.GetTarget()); } Address & @@ -223,10 +223,13 @@ if (m_bp_site_sp) return true; - Process* process = m_owner.GetTarget().GetProcessSP().get(); + Process *process = m_owner.GetTarget().GetProcessSP().get(); if (process == NULL) return false; + if (m_owner.GetTarget().GetSectionLoadList().IsEmpty()) + return false; + BreakpointLocationSP myself_sp(m_owner.GetLocationSP (this)); lldb::break_id_t new_id = process->CreateBreakpointSite (myself_sp, false); @@ -236,7 +239,7 @@ Log *log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_BREAKPOINTS); if (log) log->Warning ("Tried to add breakpoint site at 0x%llx but it was already present.\n", - m_address.GetLoadAddress(process)); + m_address.GetLoadAddress(&m_owner.GetTarget())); return false; } @@ -384,7 +387,7 @@ "hw_index = %i hit_count = %-4u ignore_count = %-4u", GetID(), GetOptionsNoCreate()->GetThreadSpecNoCreate()->GetTID(), - (uint64_t) m_address.GetLoadAddress(m_owner.GetTarget().GetProcessSP().get()), + (uint64_t) m_address.GetLoadAddress (&m_owner.GetTarget()), (m_options_ap.get() ? m_options_ap->IsEnabled() : m_owner.IsEnabled()) ? "enabled " : "disabled", IsHardware() ? "hardware" : "software", GetHardwareIndex(), Modified: lldb/trunk/source/Commands/CommandObjectImage.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectImage.cpp?rev=113895&r1=113894&r2=113895&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectImage.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectImage.cpp Tue Sep 14 18:36:40 2010 @@ -87,7 +87,7 @@ LineTable *line_table = sc.comp_unit->GetLineTable(); if (line_table) line_table->GetDescription (&strm, - interpreter.GetDebugger().GetExecutionContext().process, + interpreter.GetDebugger().GetExecutionContext().target, lldb::eDescriptionLevelBrief); else strm << "No line table"; @@ -165,7 +165,7 @@ { Symtab *symtab = objfile->GetSymtab(); if (symtab) - symtab->Dump(&strm, interpreter.GetDebugger().GetExecutionContext().process); + symtab->Dump(&strm, interpreter.GetDebugger().GetExecutionContext().target); } } } @@ -180,7 +180,7 @@ { SectionList *section_list = objfile->GetSectionList(); if (section_list) - section_list->Dump(&strm, interpreter.GetDebugger().GetExecutionContext().process, true); + section_list->Dump(&strm, interpreter.GetDebugger().GetExecutionContext().target, true); } } } @@ -217,10 +217,10 @@ lldb::addr_t addr = raw_addr - offset; Address so_addr; SymbolContext sc; - Process *process = interpreter.GetDebugger().GetExecutionContext().process; - if (process && process->IsAlive()) + Target *target = interpreter.GetDebugger().GetExecutionContext().target; + if (target && !target->GetSectionLoadList().IsEmpty()) { - if (!process->ResolveLoadAddress (addr, so_addr)) + if (!target->GetSectionLoadList().ResolveLoadAddress (addr, so_addr)) return false; else if (so_addr.GetModule() != module) return false; @@ -299,7 +299,7 @@ { Symbol *symbol = symtab->SymbolAtIndex(match_indexes[i]); strm.Indent (); - symbol->Dump (&strm, interpreter.GetDebugger().GetExecutionContext().process, i); + symbol->Dump (&strm, interpreter.GetDebugger().GetExecutionContext().target, i); } strm.IndentLess (); return num_matches; @@ -328,8 +328,7 @@ { if (sc.line_entry.range.GetBaseAddress().IsValid()) { - lldb::addr_t vm_addr = - sc.line_entry.range.GetBaseAddress().GetLoadAddress(interpreter.GetDebugger().GetExecutionContext().process); + lldb::addr_t vm_addr = sc.line_entry.range.GetBaseAddress().GetLoadAddress(interpreter.GetDebugger().GetExecutionContext().target); int addr_size = sizeof (addr_t); Process *process = interpreter.GetDebugger().GetExecutionContext().process; if (process) Modified: lldb/trunk/source/Commands/CommandObjectThread.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectThread.cpp?rev=113895&r1=113894&r2=113895&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectThread.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectThread.cpp Tue Sep 14 18:36:40 2010 @@ -1067,7 +1067,8 @@ { bool synchronous_execution = interpreter.GetSynchronous (); - if (!interpreter.GetDebugger().GetSelectedTarget().get()) + Target *target = interpreter.GetDebugger().GetSelectedTarget().get(); + if (target == NULL) { result.AppendError ("invalid target, set executable file using 'file' command"); result.SetStatus (eReturnStatusFailed); @@ -1166,7 +1167,7 @@ if (index_ptr == UINT32_MAX) break; - addr_t address = line_entry.range.GetBaseAddress().GetLoadAddress(process); + addr_t address = line_entry.range.GetBaseAddress().GetLoadAddress(target); if (address != LLDB_INVALID_ADDRESS) address_list.push_back (address); index_ptr++; Modified: lldb/trunk/source/Core/Address.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/Address.cpp?rev=113895&r1=113894&r2=113895&view=diff ============================================================================== --- lldb/trunk/source/Core/Address.cpp (original) +++ lldb/trunk/source/Core/Address.cpp Tue Sep 14 18:36:40 2010 @@ -11,6 +11,7 @@ #include "lldb/Core/Module.h" #include "lldb/Core/Section.h" #include "lldb/Symbol/ObjectFile.h" +#include "lldb/Target/ExecutionContext.h" #include "lldb/Target/Process.h" #include "lldb/Target/Target.h" @@ -138,27 +139,30 @@ addr_t deref_addr = ReadUIntMax64 (exe_scope, address, pointer_size, success); if (success) { - Process *process = exe_scope->CalculateProcess(); - if (process && process->IsAlive()) + ExecutionContext exe_ctx; + exe_scope->Calculate(exe_ctx); + // If we have any sections that are loaded, try and resolve using the + // section load list + if (exe_ctx.target && !exe_ctx.target->GetSectionLoadList().IsEmpty()) { - if (!process->ResolveLoadAddress (deref_addr, deref_so_addr)) - { - deref_so_addr.SetSection(NULL); - deref_so_addr.SetOffset(deref_addr); - } + if (exe_ctx.target->GetSectionLoadList().ResolveLoadAddress (deref_addr, deref_so_addr)) + return true; } else { - Target *target = exe_scope->CalculateTarget(); - if (target == NULL) - return false; - - if (!target->GetImages().ResolveFileAddress(deref_addr, deref_so_addr)) - { - deref_so_addr.SetSection(NULL); - deref_so_addr.SetOffset(deref_addr); - } + // If we were not running, yet able to read an integer, we must + // have a module + Module *module = address.GetModule(); + assert (module); + if (module->ResolveFileAddress(deref_addr, deref_so_addr)) + return true; } + + // We couldn't make "deref_addr" into a section offset value, but we were + // able to read the address, so we return a section offset address with + // no section and "deref_addr" as the offset (address). + deref_so_addr.SetSection(NULL); + deref_so_addr.SetOffset(deref_addr); return true; } return false; @@ -334,27 +338,28 @@ } addr_t -Address::GetLoadAddress (Process *process) const +Address::GetLoadAddress (Target *target) const { - if (m_section != NULL) + if (m_section == NULL) { - if (process) - { - addr_t sect_load_addr = m_section->GetLoadBaseAddress (process); + // No section, we just return the offset since it is the value in this case + return m_offset; + } + + if (target) + { + addr_t sect_load_addr = m_section->GetLoadBaseAddress (target); - if (sect_load_addr != LLDB_INVALID_ADDRESS) - { - // We have a valid file range, so we can return the file based - // address by adding the file base address to our offset - return sect_load_addr + m_offset; - } + if (sect_load_addr != LLDB_INVALID_ADDRESS) + { + // We have a valid file range, so we can return the file based + // address by adding the file base address to our offset + return sect_load_addr + m_offset; } - // The section isn't resolved or no process was supplied so we can't - // return a valid file address. - return LLDB_INVALID_ADDRESS; } - // No section, we just return the offset since it is the value in this case - return m_offset; + // The section isn't resolved or no process was supplied so we can't + // return a valid file address. + return LLDB_INVALID_ADDRESS; } bool @@ -424,7 +429,7 @@ case DumpStyleLoadAddress: { - addr_t load_addr = GetLoadAddress (process); + addr_t load_addr = GetLoadAddress (target); if (load_addr == LLDB_INVALID_ADDRESS) { if (fallback_style != DumpStyleInvalid) @@ -440,7 +445,7 @@ if (IsSectionOffset()) { lldb::AddressType addr_type = eAddressTypeLoad; - addr_t addr = GetLoadAddress (process); + addr_t addr = GetLoadAddress (target); if (addr == LLDB_INVALID_ADDRESS) { addr = GetFileAddress(); @@ -670,7 +675,7 @@ if (sc.symbol->GetAddressRangePtr() && sc.symbol->GetAddressRangePtr()->GetBaseAddress().GetSection() != GetSection()) sc.symbol = NULL; } - sc.GetDescription(s, eDescriptionLevelBrief, process); + sc.GetDescription(s, eDescriptionLevelBrief, target); } } if (fallback_style != DumpStyleInvalid) @@ -733,11 +738,11 @@ int -Address::CompareLoadAddress (const Address& a, const Address& b, Process *process) +Address::CompareLoadAddress (const Address& a, const Address& b, Target *target) { - assert (process != NULL); - addr_t a_load_addr = a.GetLoadAddress (process); - addr_t b_load_addr = b.GetLoadAddress (process); + assert (target != NULL); + addr_t a_load_addr = a.GetLoadAddress (target); + addr_t b_load_addr = b.GetLoadAddress (target); if (a_load_addr < b_load_addr) return -1; if (a_load_addr > b_load_addr) Modified: lldb/trunk/source/Core/AddressRange.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/AddressRange.cpp?rev=113895&r1=113894&r2=113895&view=diff ============================================================================== --- lldb/trunk/source/Core/AddressRange.cpp (original) +++ lldb/trunk/source/Core/AddressRange.cpp Tue Sep 14 18:36:40 2010 @@ -11,6 +11,7 @@ #include "lldb/Core/Module.h" #include "lldb/Core/Stream.h" #include "lldb/Target/Process.h" +#include "lldb/Target/Target.h" using namespace lldb; using namespace lldb_private; @@ -96,15 +97,15 @@ bool -AddressRange::ContainsLoadAddress (const Address &addr, Process *process) const +AddressRange::ContainsLoadAddress (const Address &addr, Target *target) const { if (addr.GetSection() == m_base_addr.GetSection()) return (addr.GetOffset() - m_base_addr.GetOffset()) < GetByteSize(); - addr_t load_base_addr = GetBaseAddress().GetLoadAddress(process); + addr_t load_base_addr = GetBaseAddress().GetLoadAddress(target); if (load_base_addr == LLDB_INVALID_ADDRESS) return false; - addr_t load_addr = addr.GetLoadAddress(process); + addr_t load_addr = addr.GetLoadAddress(target); if (load_addr == LLDB_INVALID_ADDRESS) return false; @@ -115,12 +116,12 @@ } bool -AddressRange::ContainsLoadAddress (addr_t load_addr, Process *process) const +AddressRange::ContainsLoadAddress (addr_t load_addr, Target *target) const { if (load_addr == LLDB_INVALID_ADDRESS) return false; - addr_t load_base_addr = GetBaseAddress().GetLoadAddress(process); + addr_t load_base_addr = GetBaseAddress().GetLoadAddress(target); if (load_base_addr == LLDB_INVALID_ADDRESS) return false; @@ -138,12 +139,12 @@ } bool -AddressRange::Dump(Stream *s, Process *process, Address::DumpStyle style, Address::DumpStyle fallback_style) const +AddressRange::Dump(Stream *s, Target *target, Address::DumpStyle style, Address::DumpStyle fallback_style) const { addr_t vmaddr = LLDB_INVALID_ADDRESS; int addr_size = sizeof (addr_t); - if (process) - addr_size = process->GetAddressByteSize (); + if (target && target->GetProcessSP()) + addr_size = target->GetProcessSP()->GetAddressByteSize (); bool show_module = false; switch (style) @@ -153,7 +154,7 @@ case Address::DumpStyleSectionNameOffset: case Address::DumpStyleSectionPointerOffset: s->PutChar ('['); - m_base_addr.Dump(s, process, style, fallback_style); + m_base_addr.Dump(s, target, style, fallback_style); s->PutChar ('-'); s->Address (m_base_addr.GetOffset() + GetByteSize(), addr_size); s->PutChar (')'); @@ -168,7 +169,7 @@ break; case Address::DumpStyleLoadAddress: - vmaddr = m_base_addr.GetLoadAddress(process); + vmaddr = m_base_addr.GetLoadAddress(target); break; } @@ -185,7 +186,7 @@ } else if (fallback_style != Address::DumpStyleInvalid) { - return Dump(s, process, fallback_style, Address::DumpStyleInvalid); + return Dump(s, target, fallback_style, Address::DumpStyleInvalid); } return false; Modified: lldb/trunk/source/Core/Disassembler.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/Disassembler.cpp?rev=113895&r1=113894&r2=113895&view=diff ============================================================================== --- lldb/trunk/source/Core/Disassembler.cpp (original) +++ lldb/trunk/source/Core/Disassembler.cpp Tue Sep 14 18:36:40 2010 @@ -155,17 +155,19 @@ // try and resolve it to something if (range.GetBaseAddress().IsSectionOffset() == false) { - if (process && process->IsAlive()) + if (exe_ctx.target) { - process->ResolveLoadAddress (range.GetBaseAddress().GetOffset(), range.GetBaseAddress()); - } - else if (exe_ctx.target) - { - exe_ctx.target->GetImages().ResolveFileAddress (range.GetBaseAddress().GetOffset(), range.GetBaseAddress()); + if (exe_ctx.target->GetSectionLoadList().IsEmpty()) + { + exe_ctx.target->GetImages().ResolveFileAddress (range.GetBaseAddress().GetOffset(), range.GetBaseAddress()); + } + else + { + exe_ctx.target->GetSectionLoadList().ResolveLoadAddress (range.GetBaseAddress().GetOffset(), range.GetBaseAddress()); + } } } - DataExtractor data; size_t bytes_disassembled = disassembler->ParseInstructions (&exe_ctx, range, data); if (bytes_disassembled == 0) Modified: lldb/trunk/source/Core/Section.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/Section.cpp?rev=113895&r1=113894&r2=113895&view=diff ============================================================================== --- lldb/trunk/source/Core/Section.cpp (original) +++ lldb/trunk/source/Core/Section.cpp Tue Sep 14 18:36:40 2010 @@ -10,7 +10,7 @@ #include "lldb/Core/Section.h" #include "lldb/Core/Module.h" #include "lldb/Symbol/ObjectFile.h" -#include "lldb/Target/Process.h" +#include "lldb/Target/Target.h" using namespace lldb; using namespace lldb_private; @@ -112,23 +112,23 @@ addr_t -Section::GetLoadBaseAddress (Process *process) const +Section::GetLoadBaseAddress (Target *target) const { addr_t load_base_addr = LLDB_INVALID_ADDRESS; if (m_linked_section) { - load_base_addr = m_linked_section->GetLoadBaseAddress(process) + m_linked_offset; + load_base_addr = m_linked_section->GetLoadBaseAddress(target) + m_linked_offset; } else if (m_parent) { - load_base_addr = m_parent->GetLoadBaseAddress (process); + load_base_addr = m_parent->GetLoadBaseAddress (target); if (load_base_addr != LLDB_INVALID_ADDRESS) load_base_addr += GetOffset(); } else { - load_base_addr = process->GetSectionLoadAddress(this); + load_base_addr = target->GetSectionLoadList().GetSectionLoadAddress (this); } return load_base_addr; @@ -222,7 +222,7 @@ void -Section::Dump(Stream *s, Process *process) const +Section::Dump(Stream *s, Target *target) const { s->Printf("%.*p: ", (int)sizeof(void*) * 2, this); s->Indent(); @@ -234,12 +234,12 @@ s->Printf("%39s", ""); else { - if (process) - addr = GetLoadBaseAddress (process); + if (target) + addr = GetLoadBaseAddress (target); if (addr == LLDB_INVALID_ADDRESS) { - if (process) + if (target) resolved = false; addr = GetFileAddress(); } @@ -258,16 +258,16 @@ { addr = LLDB_INVALID_ADDRESS; - if (process) + if (target) { - addr = m_linked_section->GetLoadBaseAddress(process); + addr = m_linked_section->GetLoadBaseAddress(target); if (addr != LLDB_INVALID_ADDRESS) addr += m_linked_offset; } if (addr == LLDB_INVALID_ADDRESS) { - if (process) + if (target) resolved = false; addr = m_linked_section->GetFileAddress() + m_linked_offset; } @@ -283,7 +283,7 @@ s->Printf(" + 0x%llx\n", m_linked_offset); } - m_children.Dump(s, process, false); + m_children.Dump(s, target, false); } void @@ -668,7 +668,7 @@ } void -SectionList::Dump (Stream *s, Process *process, bool show_header) const +SectionList::Dump (Stream *s, Target *target, bool show_header) const { if (show_header && !m_sections.empty()) { @@ -678,7 +678,7 @@ s->IndentMore(); s->Printf("%*s", 2*(sizeof(void *) + 2), ""); s->Indent(); - s->Printf("SectID %s Address File Off. File Size Flags Section Name\n", process ? "Load" : "File"); + s->Printf("SectID %s Address File Off. File Size Flags Section Name\n", (target && target->GetSectionLoadList().IsEmpty() == false) ? "Load" : "File"); s->Printf("%*s", 2*(sizeof(void *) + 2), ""); s->Indent(); s->PutCString("---------- --------------------------------------- ---------- ---------- ---------- ----------------------------\n"); @@ -689,7 +689,7 @@ const_iterator end = m_sections.end(); for (sect_iter = m_sections.begin(); sect_iter != end; ++sect_iter) { - (*sect_iter)->Dump(s, process); + (*sect_iter)->Dump(s, target); } if (show_header && !m_sections.empty()) Modified: lldb/trunk/source/Core/Value.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/Value.cpp?rev=113895&r1=113894&r2=113895&view=diff ============================================================================== --- lldb/trunk/source/Core/Value.cpp (original) +++ lldb/trunk/source/Core/Value.cpp Tue Sep 14 18:36:40 2010 @@ -558,7 +558,7 @@ if (objfile) { Address so_addr(file_addr, objfile->GetSectionList()); - address = so_addr.GetLoadAddress (exe_ctx->process); + address = so_addr.GetLoadAddress (exe_ctx->target); if (address != LLDB_INVALID_ADDRESS) { address_type = eAddressTypeLoad; Modified: lldb/trunk/source/Core/ValueObject.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/ValueObject.cpp?rev=113895&r1=113894&r2=113895&view=diff ============================================================================== --- lldb/trunk/source/Core/ValueObject.cpp (original) +++ lldb/trunk/source/Core/ValueObject.cpp Tue Sep 14 18:36:40 2010 @@ -10,6 +10,8 @@ #include "lldb/Core/ValueObject.h" // C Includes +#include + // C++ Includes // Other libraries and framework includes #include "llvm/Support/raw_ostream.h" @@ -27,8 +29,8 @@ #include "lldb/Target/ExecutionContext.h" #include "lldb/Target/Process.h" #include "lldb/Target/RegisterContext.h" +#include "lldb/Target/Target.h" #include "lldb/Target/Thread.h" -#include using namespace lldb; using namespace lldb_private; @@ -495,10 +497,10 @@ case eAddressTypeLoad: { Address so_addr; - Process *process = exe_scope->CalculateProcess(); - if (process != NULL) + Target *target = exe_scope->CalculateTarget(); + if (target && target->GetSectionLoadList().IsEmpty() == false) { - if (process->ResolveLoadAddress(func_ptr_address, so_addr)) + if (target->GetSectionLoadList().ResolveLoadAddress(func_ptr_address, so_addr)) { so_addr.Dump (&sstr, exe_scope, Modified: lldb/trunk/source/Core/ValueObjectVariable.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/ValueObjectVariable.cpp?rev=113895&r1=113894&r2=113895&view=diff ============================================================================== --- lldb/trunk/source/Core/ValueObjectVariable.cpp (original) +++ lldb/trunk/source/Core/ValueObjectVariable.cpp Tue Sep 14 18:36:40 2010 @@ -110,7 +110,7 @@ SymbolContext sc; variable->CalculateSymbolContext (&sc); if (sc.function) - loclist_base_load_addr = sc.function->GetAddressRange().GetBaseAddress().GetLoadAddress (exe_ctx.process); + loclist_base_load_addr = sc.function->GetAddressRange().GetBaseAddress().GetLoadAddress (exe_ctx.target); } Value old_value(m_value); if (expr.Evaluate (&exe_ctx, GetClangAST(), loclist_base_load_addr, NULL, m_value, &m_error)) @@ -156,7 +156,7 @@ if (objfile) { Address so_addr(file_addr, objfile->GetSectionList()); - lldb::addr_t load_addr = so_addr.GetLoadAddress (exe_ctx.process); + lldb::addr_t load_addr = so_addr.GetLoadAddress (exe_ctx.target); if (load_addr != LLDB_INVALID_ADDRESS) { m_value.SetValueType(Value::eValueTypeLoadAddress); Modified: lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp?rev=113895&r1=113894&r2=113895&view=diff ============================================================================== --- lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp (original) +++ lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp Tue Sep 14 18:36:40 2010 @@ -279,7 +279,7 @@ else return false; - ptr = fun_address->GetLoadAddress(m_exe_ctx->process); + ptr = fun_address->GetLoadAddress(m_exe_ctx->target); return true; } @@ -886,7 +886,7 @@ { SymbolContext var_sc; var->CalculateSymbolContext (&var_sc); - loclist_base_load_addr = var_sc.function->GetAddressRange().GetBaseAddress().GetLoadAddress (exe_ctx.process); + loclist_base_load_addr = var_sc.function->GetAddressRange().GetBaseAddress().GetLoadAddress (exe_ctx.target); } Error err; @@ -929,7 +929,7 @@ Address so_addr(var_location->GetScalar().ULongLong(), object_file->GetSectionList()); - lldb::addr_t load_addr = so_addr.GetLoadAddress(m_exe_ctx->process); + lldb::addr_t load_addr = so_addr.GetLoadAddress(m_exe_ctx->target); var_location->GetScalar() = load_addr; var_location->SetValueType(Value::eValueTypeLoadAddress); @@ -1062,7 +1062,7 @@ return; } - lldb::addr_t load_addr = fun_address->GetLoadAddress(m_exe_ctx->process); + lldb::addr_t load_addr = fun_address->GetLoadAddress(m_exe_ctx->target); fun_location->SetValueType(Value::eValueTypeLoadAddress); fun_location->GetScalar() = load_addr; Modified: lldb/trunk/source/Expression/ClangFunction.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/ClangFunction.cpp?rev=113895&r1=113894&r2=113895&view=diff ============================================================================== --- lldb/trunk/source/Expression/ClangFunction.cpp (original) +++ lldb/trunk/source/Expression/ClangFunction.cpp Tue Sep 14 18:36:40 2010 @@ -294,7 +294,7 @@ // FIXME: This is fake, and just assumes that it matches that architecture. // Make a data extractor and put the address into the right byte order & size. - uint64_t fun_addr = function_address.GetLoadAddress(exe_ctx.process); + uint64_t fun_addr = function_address.GetLoadAddress(exe_ctx.target); int first_offset = m_member_offsets[0]; process->WriteMemory(args_addr_ref + first_offset, &fun_addr, 8, error); Modified: lldb/trunk/source/Plugins/Disassembler/llvm/DisassemblerLLVM.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Disassembler/llvm/DisassemblerLLVM.cpp?rev=113895&r1=113894&r2=113895&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Disassembler/llvm/DisassemblerLLVM.cpp (original) +++ lldb/trunk/source/Plugins/Disassembler/llvm/DisassemblerLLVM.cpp Tue Sep 14 18:36:40 2010 @@ -139,14 +139,14 @@ int currentOpIndex = -1; - lldb_private::Process *process = exe_ctx.process; + //lldb_private::Process *process = exe_ctx.process; std::auto_ptr rra; if (!raw) { addr_t base_addr = LLDB_INVALID_ADDRESS; - if (process && process->IsAlive()) - base_addr = inst_addr_ptr->GetLoadAddress (process); + if (exe_ctx.target && !exe_ctx.target->GetSectionLoadList().IsEmpty()) + base_addr = inst_addr_ptr->GetLoadAddress (exe_ctx.target); if (base_addr == LLDB_INVALID_ADDRESS) base_addr = inst_addr_ptr->GetFileAddress (); @@ -246,9 +246,9 @@ } lldb_private::Address so_addr; - if (process && process->IsAlive()) + if (exe_ctx.target && !exe_ctx.target->GetSectionLoadList().IsEmpty()) { - if (process->ResolveLoadAddress (operand_value, so_addr)) + if (exe_ctx.target->GetSectionLoadList().ResolveLoadAddress (operand_value, so_addr)) so_addr.Dump(&comment, exe_scope, Address::DumpStyleResolvedDescriptionNoModule, Address::DumpStyleSectionNameOffset); } else if (inst_addr_ptr) 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=113895&r1=113894&r2=113895&view=diff ============================================================================== --- lldb/trunk/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.cpp (original) +++ lldb/trunk/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.cpp Tue Sep 14 18:36:40 2010 @@ -218,7 +218,7 @@ static ConstString g_dyld_all_image_infos ("dyld_all_image_infos"); const Symbol *symbol = dyld_module_sp->FindFirstSymbolWithNameAndType (g_dyld_all_image_infos, eSymbolTypeData); if (symbol) - m_dyld_all_image_infos_addr = symbol->GetValue().GetLoadAddress(m_process); + m_dyld_all_image_infos_addr = symbol->GetValue().GetLoadAddress(&m_process->GetTarget()); } // Update all image infos @@ -263,11 +263,11 @@ if (section) { const addr_t new_section_load_addr = section->GetFileAddress (); - const addr_t old_section_load_addr = m_process->GetSectionLoadAddress (section); + const addr_t old_section_load_addr = m_process->GetTarget().GetSectionLoadList().GetSectionLoadAddress (section); if (old_section_load_addr == LLDB_INVALID_ADDRESS || old_section_load_addr != new_section_load_addr) { - if (m_process->SectionLoaded (section, section->GetFileAddress ())) + if (m_process->GetTarget().GetSectionLoadList().SetSectionLoadAddress (section, section->GetFileAddress ())) changed = true; } } @@ -336,11 +336,11 @@ SectionSP section_sp(section_list->FindSectionByName(info.segments[i].name)); assert (section_sp.get() != NULL); const addr_t new_section_load_addr = info.segments[i].addr + info.slide; - const addr_t old_section_load_addr = m_process->GetSectionLoadAddress (section_sp.get()); + const addr_t old_section_load_addr = m_process->GetTarget().GetSectionLoadList().GetSectionLoadAddress (section_sp.get()); if (old_section_load_addr == LLDB_INVALID_ADDRESS || old_section_load_addr != new_section_load_addr) { - if (m_process->SectionLoaded (section_sp.get(), new_section_load_addr)) + if (m_process->GetTarget().GetSectionLoadList().SetSectionLoadAddress (section_sp.get(), new_section_load_addr)) changed = true; } } @@ -372,7 +372,7 @@ SectionSP section_sp(section_list->FindSectionByName(info.segments[i].name)); assert (section_sp.get() != NULL); const addr_t old_section_load_addr = info.segments[i].addr + info.slide; - if (m_process->SectionUnloaded (section_sp.get(), old_section_load_addr)) + if (m_process->GetTarget().GetSectionLoadList().SetSectionUnloaded (section_sp.get(), old_section_load_addr)) changed = true; } } @@ -1008,7 +1008,7 @@ // breakpoint gets hit. We will use this to track when shared // libraries get loaded/unloaded. - if (m_process->ResolveLoadAddress(m_dyld_all_image_infos.notification, so_addr)) + if (m_process->GetTarget().GetSectionLoadList().ResolveLoadAddress(m_dyld_all_image_infos.notification, so_addr)) { Breakpoint *dyld_break = m_process->GetTarget().CreateBreakpoint (so_addr, true).get(); dyld_break->SetCallback (DynamicLoaderMacOSXDYLD::NotifyBreakpointHit, this, true); @@ -1109,7 +1109,7 @@ if (target_symbols.GetContextAtIndex(i, context)) { context.GetAddressRange (eSymbolContextEverything, addr_range); - lldb::addr_t load_addr = addr_range.GetBaseAddress().GetLoadAddress(&(thread.GetProcess())); + lldb::addr_t load_addr = addr_range.GetBaseAddress().GetLoadAddress(&thread.GetProcess().GetTarget()); addresses[i] = load_addr; } } Modified: lldb/trunk/source/Plugins/DynamicLoader/MacOSX-DYLD/ObjCTrampolineHandler.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/DynamicLoader/MacOSX-DYLD/ObjCTrampolineHandler.cpp?rev=113895&r1=113894&r2=113895&view=diff ============================================================================== --- lldb/trunk/source/Plugins/DynamicLoader/MacOSX-DYLD/ObjCTrampolineHandler.cpp (original) +++ lldb/trunk/source/Plugins/DynamicLoader/MacOSX-DYLD/ObjCTrampolineHandler.cpp Tue Sep 14 18:36:40 2010 @@ -84,13 +84,14 @@ ConstString get_impl_name("class_getMethodImplementation"); ConstString get_impl_stret_name("class_getMethodImplementation_stret"); + Target *target = m_process_sp ? &m_process_sp->GetTarget() : NULL; const Symbol *class_getMethodImplementation = m_objc_module_sp->FindFirstSymbolWithNameAndType (get_impl_name, eSymbolTypeCode); const Symbol *class_getMethodImplementation_stret = m_objc_module_sp->FindFirstSymbolWithNameAndType (get_impl_stret_name, eSymbolTypeCode); if (class_getMethodImplementation) - m_impl_fn_addr = class_getMethodImplementation->GetValue().GetLoadAddress(m_process_sp.get()); + m_impl_fn_addr = class_getMethodImplementation->GetValue().GetLoadAddress(target); if (class_getMethodImplementation_stret) - m_impl_stret_fn_addr = class_getMethodImplementation_stret->GetValue().GetLoadAddress(m_process_sp.get()); + m_impl_stret_fn_addr = class_getMethodImplementation_stret->GetValue().GetLoadAddress(target); // FIXME: Do some kind of logging here. if (m_impl_fn_addr == LLDB_INVALID_ADDRESS || m_impl_stret_fn_addr == LLDB_INVALID_ADDRESS) @@ -111,7 +112,7 @@ // Problem is we also need to lookup the dispatch function. For now we could have a side table of stret & non-stret // dispatch functions. If that's as complex as it gets, we're fine. - lldb::addr_t sym_addr = msgSend_symbol->GetValue().GetLoadAddress(m_process_sp.get()); + lldb::addr_t sym_addr = msgSend_symbol->GetValue().GetLoadAddress(target); m_msgSend_map.insert(std::pair(sym_addr, i)); } 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=113895&r1=113894&r2=113895&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Process/MacOSX-User/source/ThreadMacOSX.cpp (original) +++ lldb/trunk/source/Plugins/Process/MacOSX-User/source/ThreadMacOSX.cpp Tue Sep 14 18:36:40 2010 @@ -115,7 +115,7 @@ lldb::addr_t dispatch_queue_offsets_addr = LLDB_INVALID_ADDRESS; const Symbol *dispatch_queue_offsets_symbol = module_sp->FindFirstSymbolWithNameAndType (ConstString("dispatch_queue_offsets"), eSymbolTypeData); if (dispatch_queue_offsets_symbol) - dispatch_queue_offsets_addr = dispatch_queue_offsets_symbol->GetValue().GetLoadAddress(&GetProcess()); + dispatch_queue_offsets_addr = dispatch_queue_offsets_symbol->GetValue().GetLoadAddress(&m_process.GetTarget()); if (dispatch_queue_offsets_addr == LLDB_INVALID_ADDRESS) return NULL; Modified: lldb/trunk/source/Plugins/Process/Utility/MacOSXLibunwindCallbacks.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Utility/MacOSXLibunwindCallbacks.cpp?rev=113895&r1=113894&r2=113895&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Process/Utility/MacOSXLibunwindCallbacks.cpp (original) +++ lldb/trunk/source/Plugins/Process/Utility/MacOSXLibunwindCallbacks.cpp Tue Sep 14 18:36:40 2010 @@ -69,19 +69,20 @@ { if (arg == 0) return -1; - Thread *th = (Thread *) arg; + Thread *thread = (Thread *) arg; + Target &target = thread->GetProcess().GetTarget(); Address addr; - if (!th->GetProcess().ResolveLoadAddress(ip, addr)) + if (!target.GetSectionLoadList().ResolveLoadAddress(ip, addr)) return -1; SymbolContext sc; - if (!th->GetProcess().GetTarget().GetImages().ResolveSymbolContextForAddress (addr, eSymbolContextFunction, 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(&th->GetProcess()) - sc.symbol->GetValue().GetLoadAddress(&th->GetProcess()); + *offp = addr.GetLoadAddress(&target) - sc.symbol->GetValue().GetLoadAddress(&target); return UNW_ESUCCESS; } @@ -93,13 +94,14 @@ { if (arg == 0) return -1; - Thread *th = (Thread *) arg; + Thread *thread = (Thread *) arg; + Target &target = thread->GetProcess().GetTarget(); Address addr; - if (!th->GetProcess().ResolveLoadAddress(load_addr, addr)) + if (!target.GetSectionLoadList().ResolveLoadAddress(load_addr, addr)) return -1; SymbolContext sc; - if (!th->GetProcess().GetTarget().GetImages().ResolveSymbolContextForAddress (addr, eSymbolContextModule, sc)) + if (!target.GetImages().ResolveSymbolContextForAddress (addr, eSymbolContextModule, sc)) return -1; SectionList *sl = sc.module_sp->GetObjectFile()->GetSectionList(); @@ -108,14 +110,14 @@ if (!text_segment_sp) return -1; - *mh = text_segment_sp->GetLoadBaseAddress (&th->GetProcess()); - *text_start = text_segment_sp->GetLoadBaseAddress (&th->GetProcess()); + *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 (&th->GetProcess()); + *eh_frame = eh_frame_section_sp->GetLoadBaseAddress (&target); *eh_frame_len = eh_frame_section_sp->GetByteSize(); } else { *eh_frame = 0; @@ -125,7 +127,7 @@ 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 (&th->GetProcess()); + *compact_unwind_start = unwind_info_section_sp->GetLoadBaseAddress (&target); *compact_unwind_len = unwind_info_section_sp->GetByteSize(); } else { *compact_unwind_start = 0; @@ -139,17 +141,18 @@ { if (arg == 0) return -1; - Thread *th = (Thread *) arg; + Thread *thread = (Thread *) arg; + Target &target = thread->GetProcess().GetTarget(); Address addr; - if (!th->GetProcess().ResolveLoadAddress(ip, addr)) + if (!target.GetSectionLoadList().ResolveLoadAddress(ip, addr)) return -1; SymbolContext sc; - if (!th->GetProcess().GetTarget().GetImages().ResolveSymbolContextForAddress (addr, eSymbolContextFunction | eSymbolContextSymbol, 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(&th->GetProcess()); + start = sc.function->GetAddressRange().GetBaseAddress().GetLoadAddress(&target); len = sc.function->GetAddressRange().GetByteSize(); if (start == LLDB_INVALID_ADDRESS || len == LLDB_INVALID_ADDRESS) return -1; @@ -160,7 +163,7 @@ if (sc.symbol) { lldb::addr_t start, len; - start = sc.symbol->GetAddressRangeRef().GetBaseAddress().GetLoadAddress(&th->GetProcess()); + start = sc.symbol->GetAddressRangeRef().GetBaseAddress().GetLoadAddress(&target); len = sc.symbol->GetAddressRangeRef().GetByteSize(); if (start == LLDB_INVALID_ADDRESS) return -1; @@ -260,8 +263,9 @@ if (arg == 0) return -1; Thread *thread = (Thread *) arg; - - const ArchSpec::CPU arch_cpu = thread->GetProcess().GetTarget().GetArchitecture ().GetGenericCPUType(); + Target &target = thread->GetProcess().GetTarget(); + + const ArchSpec::CPU arch_cpu = target.GetArchitecture ().GetGenericCPUType(); if (arch_cpu == ArchSpec::eCPU_i386) { Modified: lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp?rev=113895&r1=113894&r2=113895&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp (original) +++ lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp Tue Sep 14 18:36:40 2010 @@ -398,8 +398,7 @@ ProcessGDBRemoteLog::LogIf (GDBR_LOG_PACKETS, "error: failed to send packet: %s", packet.GetData()); } return bytes_written; - } - //m_error.SetErrorString("Not connected."); + } return 0; } 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=113895&r1=113894&r2=113895&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp (original) +++ lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp Tue Sep 14 18:36:40 2010 @@ -2246,7 +2246,7 @@ const Symbol *dispatch_queue_offsets_symbol = module_sp->FindFirstSymbolWithNameAndType (ConstString("dispatch_queue_offsets"), eSymbolTypeData); if (dispatch_queue_offsets_symbol) - m_dispatch_queue_offsets_addr = dispatch_queue_offsets_symbol->GetValue().GetLoadAddress(this); + m_dispatch_queue_offsets_addr = dispatch_queue_offsets_symbol->GetValue().GetLoadAddress(&m_target); if (m_dispatch_queue_offsets_addr == LLDB_INVALID_ADDRESS) return NULL; Modified: lldb/trunk/source/Symbol/Block.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/Block.cpp?rev=113895&r1=113894&r2=113895&view=diff ============================================================================== --- lldb/trunk/source/Symbol/Block.cpp (original) +++ lldb/trunk/source/Symbol/Block.cpp Tue Sep 14 18:36:40 2010 @@ -36,7 +36,7 @@ } void -Block::GetDescription(Stream *s, Function *function, lldb::DescriptionLevel level, Process *process) const +Block::GetDescription(Stream *s, Function *function, lldb::DescriptionLevel level, Target *target) const { *s << "id = " << ((const UserID&)*this); @@ -45,8 +45,8 @@ { addr_t base_addr = LLDB_INVALID_ADDRESS; - if (process) - base_addr = function->GetAddressRange().GetBaseAddress().GetLoadAddress(process); + if (target) + base_addr = function->GetAddressRange().GetBaseAddress().GetLoadAddress(target); if (base_addr == LLDB_INVALID_ADDRESS) base_addr = function->GetAddressRange().GetBaseAddress().GetFileAddress(); Modified: lldb/trunk/source/Symbol/Function.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/Function.cpp?rev=113895&r1=113894&r2=113895&view=diff ============================================================================== --- lldb/trunk/source/Symbol/Function.cpp (original) +++ lldb/trunk/source/Symbol/Function.cpp Tue Sep 14 18:36:40 2010 @@ -326,7 +326,7 @@ void -Function::GetDescription(Stream *s, lldb::DescriptionLevel level, Process *process) +Function::GetDescription(Stream *s, lldb::DescriptionLevel level, Target *target) { Type* func_type = GetType(); *s << "id = " << (const UserID&)*this << ", name = \"" << func_type->GetName() << "\", range = "; @@ -336,7 +336,7 @@ fallback_style = Address::DumpStyleModuleWithFileAddress; else fallback_style = Address::DumpStyleFileAddress; - GetAddressRange().Dump(s, process, Address::DumpStyleLoadAddress, fallback_style); + GetAddressRange().Dump(s, target, Address::DumpStyleLoadAddress, fallback_style); } void Modified: lldb/trunk/source/Symbol/LineEntry.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/LineEntry.cpp?rev=113895&r1=113894&r2=113895&view=diff ============================================================================== --- lldb/trunk/source/Symbol/LineEntry.cpp (original) +++ lldb/trunk/source/Symbol/LineEntry.cpp Tue Sep 14 18:36:40 2010 @@ -10,6 +10,7 @@ #include "lldb/Symbol/LineEntry.h" #include "lldb/Symbol/CompileUnit.h" #include "lldb/Target/Process.h" +#include "lldb/Target/Target.h" using namespace lldb_private; @@ -100,7 +101,7 @@ LineEntry::Dump ( Stream *s, - Process *process, + Target *target, bool show_file, Address::DumpStyle style, Address::DumpStyle fallback_style, @@ -110,14 +111,14 @@ if (show_range) { // Show address range - if (!range.Dump(s, process, style, fallback_style)) + if (!range.Dump(s, target, style, fallback_style)) return false; } else { // Show address only if (!range.GetBaseAddress().Dump(s, - process, + target, style, fallback_style)) return false; @@ -146,18 +147,18 @@ } bool -LineEntry::GetDescription (Stream *s, lldb::DescriptionLevel level, CompileUnit* cu, Process *process, bool show_address_only) const +LineEntry::GetDescription (Stream *s, lldb::DescriptionLevel level, CompileUnit* cu, Target *target, bool show_address_only) const { if (level == lldb::eDescriptionLevelBrief || level == lldb::eDescriptionLevelFull) { if (show_address_only) { - range.GetBaseAddress().Dump(s, process, Address::DumpStyleLoadAddress, Address::DumpStyleFileAddress); + range.GetBaseAddress().Dump(s, target, Address::DumpStyleLoadAddress, Address::DumpStyleFileAddress); } else { - range.Dump(s, process, Address::DumpStyleLoadAddress, Address::DumpStyleFileAddress); + range.Dump(s, target, Address::DumpStyleLoadAddress, Address::DumpStyleFileAddress); } *s << ": " << file; @@ -195,7 +196,7 @@ } else { - return Dump (s, process, true, Address::DumpStyleLoadAddress, Address::DumpStyleModuleWithFileAddress, true); + return Dump (s, target, true, Address::DumpStyleLoadAddress, Address::DumpStyleModuleWithFileAddress, true); } return true; } Modified: lldb/trunk/source/Symbol/LineTable.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/LineTable.cpp?rev=113895&r1=113894&r2=113895&view=diff ============================================================================== --- lldb/trunk/source/Symbol/LineTable.cpp (original) +++ lldb/trunk/source/Symbol/LineTable.cpp Tue Sep 14 18:36:40 2010 @@ -387,7 +387,7 @@ } void -LineTable::Dump (Stream *s, Process *process, Address::DumpStyle style, Address::DumpStyle fallback_style, bool show_line_ranges) +LineTable::Dump (Stream *s, Target *target, Address::DumpStyle style, Address::DumpStyle fallback_style, bool show_line_ranges) { const size_t count = m_entries.size(); LineEntry line_entry; @@ -395,7 +395,7 @@ for (size_t idx = 0; idx < count; ++idx) { ConvertEntryAtIndexToLineEntry (idx, line_entry); - line_entry.Dump (s, process, prev_file != line_entry.file, style, fallback_style, show_line_ranges); + line_entry.Dump (s, target, prev_file != line_entry.file, style, fallback_style, show_line_ranges); s->EOL(); prev_file = line_entry.file; } @@ -403,14 +403,14 @@ void -LineTable::GetDescription (Stream *s, Process *process, DescriptionLevel level) +LineTable::GetDescription (Stream *s, Target *target, DescriptionLevel level) { const size_t count = m_entries.size(); LineEntry line_entry; for (size_t idx = 0; idx < count; ++idx) { ConvertEntryAtIndexToLineEntry (idx, line_entry); - line_entry.GetDescription (s, level, m_comp_unit, process, true); + line_entry.GetDescription (s, level, m_comp_unit, target, true); s->EOL(); } } Modified: lldb/trunk/source/Symbol/Symbol.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/Symbol.cpp?rev=113895&r1=113894&r2=113895&view=diff ============================================================================== --- lldb/trunk/source/Symbol/Symbol.cpp (original) +++ lldb/trunk/source/Symbol/Symbol.cpp Tue Sep 14 18:36:40 2010 @@ -13,6 +13,7 @@ #include "lldb/Core/Section.h" #include "lldb/Core/Stream.h" #include "lldb/Target/Process.h" +#include "lldb/Target/Target.h" using namespace lldb; using namespace lldb_private; @@ -173,7 +174,7 @@ } void -Symbol::GetDescription (Stream *s, lldb::DescriptionLevel level, Process *process) const +Symbol::GetDescription (Stream *s, lldb::DescriptionLevel level, Target *target) const { *s << "id = " << (const UserID&)*this << ", name = \"" << m_mangled.GetName() << '"'; const Section *section = m_addr_range.GetBaseAddress().GetSection(); @@ -184,12 +185,12 @@ if (m_addr_range.GetByteSize() > 0) { s->PutCString (", range = "); - m_addr_range.Dump(s, process, Address::DumpStyleLoadAddress, Address::DumpStyleFileAddress); + m_addr_range.Dump(s, target, Address::DumpStyleLoadAddress, Address::DumpStyleFileAddress); } else { s->PutCString (", address = "); - m_addr_range.GetBaseAddress().Dump(s, process, Address::DumpStyleLoadAddress, Address::DumpStyleFileAddress); + m_addr_range.GetBaseAddress().Dump(s, target, Address::DumpStyleLoadAddress, Address::DumpStyleFileAddress); } } else @@ -203,7 +204,7 @@ } void -Symbol::Dump(Stream *s, Process *process, uint32_t index) const +Symbol::Dump(Stream *s, Target *target, uint32_t index) const { // s->Printf("%.*p: ", (int)sizeof(void*) * 2, this); // s->Indent(); @@ -224,7 +225,7 @@ s->PutChar(' '); - if (!m_addr_range.GetBaseAddress().Dump(s, process, Address::DumpStyleLoadAddress)) + if (!m_addr_range.GetBaseAddress().Dump(s, target, Address::DumpStyleLoadAddress)) s->Printf("%*s", 18, ""); const char *format = m_size_is_sibling ? Modified: lldb/trunk/source/Symbol/SymbolContext.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/SymbolContext.cpp?rev=113895&r1=113894&r2=113895&view=diff ============================================================================== --- lldb/trunk/source/Symbol/SymbolContext.cpp (original) +++ lldb/trunk/source/Symbol/SymbolContext.cpp Tue Sep 14 18:36:40 2010 @@ -197,7 +197,7 @@ } void -SymbolContext::GetDescription(Stream *s, lldb::DescriptionLevel level, Process *process) const +SymbolContext::GetDescription(Stream *s, lldb::DescriptionLevel level, Target *target) const { if (module_sp) { @@ -219,7 +219,7 @@ if (function != NULL) { s->Indent(" Function: "); - function->GetDescription (s, level, process); + function->GetDescription (s, level, target); s->EOL(); Type *func_type = function->GetType(); @@ -251,7 +251,7 @@ s->Indent(" Blocks: "); else s->Indent(" "); - (*pos)->GetDescription(s, function, level, process); + (*pos)->GetDescription(s, function, level, target); s->EOL(); } } @@ -259,14 +259,14 @@ if (line_entry.IsValid()) { s->Indent(" LineEntry: "); - line_entry.GetDescription (s, level, comp_unit, process, false); + line_entry.GetDescription (s, level, comp_unit, target, false); s->EOL(); } if (symbol != NULL) { s->Indent(" Symbol: "); - symbol->GetDescription(s, level, process); + symbol->GetDescription(s, level, target); s->EOL(); } } @@ -287,7 +287,7 @@ void -SymbolContext::Dump(Stream *s, Process *process) const +SymbolContext::Dump(Stream *s, Target *target) const { *s << (void *)this << ": "; s->Indent(); @@ -310,7 +310,7 @@ if (function != NULL) { *s << " {0x" << function->GetID() << "} " << function->GetType()->GetName() << ", address-range = "; - function->GetAddressRange().Dump(s, process, Address::DumpStyleLoadAddress, Address::DumpStyleModuleWithFileAddress); + function->GetAddressRange().Dump(s, target, Address::DumpStyleLoadAddress, Address::DumpStyleModuleWithFileAddress); s->EOL(); s->Indent(); Type* func_type = function->GetType(); @@ -331,7 +331,7 @@ s->EOL(); s->Indent(); *s << "LineEntry = "; - line_entry.Dump (s, process, true, Address::DumpStyleLoadAddress, Address::DumpStyleModuleWithFileAddress, true); + line_entry.Dump (s, target, true, Address::DumpStyleLoadAddress, Address::DumpStyleModuleWithFileAddress, true); s->EOL(); s->Indent(); *s << "Symbol = " << (void *)symbol; @@ -494,7 +494,7 @@ } void -SymbolContextList::Dump(Stream *s, Process *process) const +SymbolContextList::Dump(Stream *s, Target *target) const { *s << (void *)this << ": "; @@ -506,7 +506,7 @@ collection::const_iterator pos, end = m_symbol_contexts.end(); for (pos = m_symbol_contexts.begin(); pos != end; ++pos) { - pos->Dump(s, process); + pos->Dump(s, target); } s->IndentLess(); } Modified: lldb/trunk/source/Symbol/Symtab.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/Symtab.cpp?rev=113895&r1=113894&r2=113895&view=diff ============================================================================== --- lldb/trunk/source/Symbol/Symtab.cpp (original) +++ lldb/trunk/source/Symbol/Symtab.cpp Tue Sep 14 18:36:40 2010 @@ -62,7 +62,7 @@ } void -Symtab::Dump(Stream *s, Process *process) const +Symtab::Dump(Stream *s, Target *target) const { const_iterator pos; s->Printf("%.*p: ", (int)sizeof(void*) * 2, this); @@ -92,14 +92,14 @@ for (pos = m_symbols.begin(); pos != end; ++pos) { s->Indent(); - pos->Dump(s, process, std::distance(begin, pos)); + pos->Dump(s, target, std::distance(begin, pos)); } } s->IndentLess (); } void -Symtab::Dump(Stream *s, Process *process, std::vector& indexes) const +Symtab::Dump(Stream *s, Target *target, std::vector& indexes) const { const size_t num_symbols = GetNumSymbols(); s->Printf("%.*p: ", (int)sizeof(void*) * 2, this); @@ -118,7 +118,7 @@ if (idx < num_symbols) { s->Indent(); - m_symbols[idx].Dump(s, process, idx); + m_symbols[idx].Dump(s, target, idx); } } } Modified: lldb/trunk/source/Symbol/UnwindPlan.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/UnwindPlan.cpp?rev=113895&r1=113894&r2=113895&view=diff ============================================================================== --- lldb/trunk/source/Symbol/UnwindPlan.cpp (original) +++ lldb/trunk/source/Symbol/UnwindPlan.cpp Tue Sep 14 18:36:40 2010 @@ -8,8 +8,9 @@ //===----------------------------------------------------------------------===// #include "lldb/Symbol/UnwindPlan.h" -#include "lldb/Target/Thread.h" +#include "lldb/Target/Process.h" #include "lldb/Target/RegisterContext.h" +#include "lldb/Target/Thread.h" using namespace lldb; using namespace lldb_private; @@ -285,10 +286,10 @@ } void -UnwindPlan::Dump (Stream& s, Process* process, Thread *thread) const +UnwindPlan::Dump (Stream& s, Thread *thread) const { s.Printf ("Address range of this UnwindPlan: "); - m_plan_valid_address_range.Dump (&s, process, Address::DumpStyleSectionNameOffset); + m_plan_valid_address_range.Dump (&s, &thread->GetProcess().GetTarget(), Address::DumpStyleSectionNameOffset); s.Printf ("\n"); s.Printf ("UnwindPlan register kind %d", m_register_kind); switch (m_register_kind) Modified: lldb/trunk/source/Symbol/Variable.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/Variable.cpp?rev=113895&r1=113894&r2=113895&view=diff ============================================================================== --- lldb/trunk/source/Symbol/Variable.cpp (original) +++ lldb/trunk/source/Symbol/Variable.cpp Tue Sep 14 18:36:40 2010 @@ -14,9 +14,11 @@ #include "lldb/Symbol/Function.h" #include "lldb/Symbol/SymbolContext.h" #include "lldb/Symbol/Type.h" +#include "lldb/Target/Process.h" #include "lldb/Target/RegisterContext.h" #include "lldb/Target/StackFrame.h" #include "lldb/Target/Thread.h" +#include "lldb/Target/Target.h" using namespace lldb; using namespace lldb_private; @@ -155,14 +157,14 @@ // Currently we only support functions that have things with // locations lists. If this expands, we will need to add support assert (sc.function); - Process *process = &frame->GetThread().GetProcess(); - addr_t loclist_base_load_addr = sc.function->GetAddressRange().GetBaseAddress().GetLoadAddress (process); + Target *target = &frame->GetThread().GetProcess().GetTarget(); + addr_t loclist_base_load_addr = sc.function->GetAddressRange().GetBaseAddress().GetLoadAddress (target); if (loclist_base_load_addr == LLDB_INVALID_ADDRESS) return false; // It is a location list. We just need to tell if the location // list contains the current address when converted to a load // address - return m_location.LocationListContainsAddress (loclist_base_load_addr, frame->GetFrameCodeAddress().GetLoadAddress (process)); + return m_location.LocationListContainsAddress (loclist_base_load_addr, frame->GetFrameCodeAddress().GetLoadAddress (target)); } else { Modified: lldb/trunk/source/Target/Process.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/Process.cpp?rev=113895&r1=113894&r2=113895&view=diff ============================================================================== --- lldb/trunk/source/Target/Process.cpp (original) +++ lldb/trunk/source/Target/Process.cpp Tue Sep 14 18:36:40 2010 @@ -66,7 +66,6 @@ Broadcaster ("Process"), ProcessInstanceSettings (*(Process::GetSettingsController().get())), m_target (target), - m_section_load_info (), m_public_state (eStateUnloaded), m_private_state (eStateUnloaded), m_private_state_broadcaster ("lldb.process.internal_state_broadcaster"), @@ -529,7 +528,7 @@ lldb::break_id_t Process::CreateBreakpointSite (BreakpointLocationSP &owner, bool use_hardware) { - const addr_t load_addr = owner->GetAddress().GetLoadAddress (this); + const addr_t load_addr = owner->GetAddress().GetLoadAddress (&m_target); if (load_addr != LLDB_INVALID_ADDRESS) { BreakpointSiteSP bp_site_sp; @@ -1575,103 +1574,6 @@ return NULL; } -addr_t -Process::GetSectionLoadAddress (const Section *section) const -{ - // TODO: add support for the same section having multiple load addresses - addr_t section_load_addr = LLDB_INVALID_ADDRESS; - if (m_section_load_info.GetFirstKeyForValue (section, section_load_addr)) - return section_load_addr; - return LLDB_INVALID_ADDRESS; -} - -bool -Process::SectionLoaded (const Section *section, addr_t load_addr) -{ - Log *log = lldb_private::GetLogIfAnyCategoriesSet (LIBLLDB_LOG_SHLIB | LIBLLDB_LOG_VERBOSE); - - if (log) - log->Printf ("Process::%s (section = %p (%s.%s), load_addr = 0x%16.16llx)", - __FUNCTION__, - section, - section->GetModule()->GetFileSpec().GetFilename().AsCString(), - section->GetName().AsCString(), - load_addr); - - - const Section *existing_section = NULL; - Mutex::Locker locker(m_section_load_info.GetMutex()); - - if (m_section_load_info.GetValueForKeyNoLock (load_addr, existing_section)) - { - if (existing_section == section) - return false; // No change - } - m_section_load_info.SetValueForKeyNoLock (load_addr, section); - return true; // Changed -} - -size_t -Process::SectionUnloaded (const Section *section) -{ - Log *log = lldb_private::GetLogIfAnyCategoriesSet (LIBLLDB_LOG_SHLIB | LIBLLDB_LOG_VERBOSE); - - if (log) - log->Printf ("Process::%s (section = %p (%s.%s))", - __FUNCTION__, - section, - section->GetModule()->GetFileSpec().GetFilename().AsCString(), - section->GetName().AsCString()); - - Mutex::Locker locker(m_section_load_info.GetMutex()); - - size_t unload_count = 0; - addr_t section_load_addr; - while (m_section_load_info.GetFirstKeyForValueNoLock (section, section_load_addr)) - { - unload_count += m_section_load_info.EraseNoLock (section_load_addr); - } - return unload_count; -} - -bool -Process::SectionUnloaded (const Section *section, addr_t load_addr) -{ - Log *log = lldb_private::GetLogIfAnyCategoriesSet (LIBLLDB_LOG_SHLIB | LIBLLDB_LOG_VERBOSE); - - if (log) - log->Printf ("Process::%s (section = %p (%s.%s), load_addr = 0x%16.16llx)", - __FUNCTION__, - section, - section->GetModule()->GetFileSpec().GetFilename().AsCString(), - section->GetName().AsCString(), - load_addr); - - return m_section_load_info.Erase (load_addr) == 1; -} - - -bool -Process::ResolveLoadAddress (addr_t load_addr, Address &so_addr) const -{ - addr_t section_load_addr = LLDB_INVALID_ADDRESS; - const Section *section = NULL; - - // First find the top level section that this load address exists in - if (m_section_load_info.LowerBound (load_addr, section_load_addr, section, true)) - { - addr_t offset = load_addr - section_load_addr; - if (offset < section->GetByteSize()) - { - // We have found the top level section, now we need to find the - // deepest child section. - return section->ResolveContainedAddress (offset, so_addr); - } - } - so_addr.Clear(); - return false; -} - //------------------------------------------------------------------ // Process Event Data //------------------------------------------------------------------ Modified: lldb/trunk/source/Target/StackFrame.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/StackFrame.cpp?rev=113895&r1=113894&r2=113895&view=diff ============================================================================== --- lldb/trunk/source/Target/StackFrame.cpp (original) +++ lldb/trunk/source/Target/StackFrame.cpp Tue Sep 14 18:36:40 2010 @@ -115,7 +115,7 @@ m_unwind_frame_index (unwind_frame_index), m_thread (thread), m_reg_context_sp (reg_context_sp), - m_id (pc_addr.GetLoadAddress (&thread.GetProcess()), cfa, NULL), + m_id (pc_addr.GetLoadAddress (&thread.GetProcess().GetTarget()), cfa, NULL), m_frame_code_addr (pc_addr), m_sc (), m_flags (), @@ -213,7 +213,7 @@ // Resolve the PC into a temporary address because if ResolveLoadAddress // fails to resolve the address, it will clear the address object... Address resolved_pc; - if (m_thread.GetProcess().ResolveLoadAddress(m_frame_code_addr.GetOffset(), resolved_pc)) + if (m_thread.GetProcess().GetTarget().GetSectionLoadList().ResolveLoadAddress(m_frame_code_addr.GetOffset(), resolved_pc)) { m_frame_code_addr = resolved_pc; const Section *section = m_frame_code_addr.GetSection(); @@ -488,7 +488,7 @@ Value expr_value; addr_t loclist_base_addr = LLDB_INVALID_ADDRESS; if (m_sc.function->GetFrameBaseExpression().IsLocationList()) - loclist_base_addr = m_sc.function->GetAddressRange().GetBaseAddress().GetLoadAddress (&m_thread.GetProcess()); + loclist_base_addr = m_sc.function->GetAddressRange().GetBaseAddress().GetLoadAddress (&m_thread.GetProcess().GetTarget()); if (m_sc.function->GetFrameBaseExpression().Evaluate(&exe_ctx, NULL, loclist_base_addr, NULL, expr_value, &m_frame_base_error) == false) { @@ -629,7 +629,7 @@ if (show_frame_index) strm->Printf("frame #%u: ", m_frame_index); - strm->Printf("0x%0*llx ", m_thread.GetProcess().GetAddressByteSize() * 2, GetFrameCodeAddress().GetLoadAddress(&m_thread.GetProcess())); + strm->Printf("0x%0*llx ", m_thread.GetProcess().GetAddressByteSize() * 2, GetFrameCodeAddress().GetLoadAddress(&m_thread.GetProcess().GetTarget())); GetSymbolContext(eSymbolContextEverything); const bool show_module = true; const bool show_inline = true; Modified: lldb/trunk/source/Target/Target.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/Target.cpp?rev=113895&r1=113894&r2=113895&view=diff ============================================================================== --- lldb/trunk/source/Target/Target.cpp (original) +++ lldb/trunk/source/Target/Target.cpp Tue Sep 14 18:36:40 2010 @@ -37,6 +37,7 @@ Broadcaster("Target"), m_debugger (debugger), m_images(), + m_section_load_list (), m_breakpoint_list (false), m_internal_breakpoint_list (true), m_process_sp(), @@ -162,10 +163,8 @@ // Attempt to resolve our load address if possible, though it is ok if // it doesn't resolve to section/offset. - Process *process = GetProcessSP().get(); // Try and resolve as a load address if possible - if (process) - process->ResolveLoadAddress(addr, so_addr); + m_section_load_list.ResolveLoadAddress(addr, so_addr); if (!so_addr.IsValid()) { // The address didn't resolve, so just set this as an absolute address @@ -567,7 +566,7 @@ { if (process_is_valid) { - m_process_sp->ResolveLoadAddress (addr.GetOffset(), resolved_addr); + m_section_load_list.ResolveLoadAddress (addr.GetOffset(), resolved_addr); } else { @@ -578,7 +577,7 @@ if (process_is_valid) { - lldb::addr_t load_addr = resolved_addr.GetLoadAddress(m_process_sp.get()); + lldb::addr_t load_addr = resolved_addr.GetLoadAddress (this); if (load_addr == LLDB_INVALID_ADDRESS) { if (resolved_addr.GetModule() && resolved_addr.GetModule()->GetFileSpec()) Modified: lldb/trunk/source/Target/ThreadPlanCallFunction.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/ThreadPlanCallFunction.cpp?rev=113895&r1=113894&r2=113895&view=diff ============================================================================== --- lldb/trunk/source/Target/ThreadPlanCallFunction.cpp (original) +++ lldb/trunk/source/Target/ThreadPlanCallFunction.cpp Tue Sep 14 18:36:40 2010 @@ -66,13 +66,13 @@ contexts.GetContextAtIndex(0, context); m_start_addr = context.symbol->GetValue(); - lldb::addr_t StartLoadAddr = m_start_addr.GetLoadAddress(&process); + lldb::addr_t StartLoadAddr = m_start_addr.GetLoadAddress(&target); if (!thread.SaveFrameZeroState(m_register_backup)) return; m_function_addr = function; - lldb::addr_t FunctionLoadAddr = m_function_addr.GetLoadAddress(&process); + lldb::addr_t FunctionLoadAddr = m_function_addr.GetLoadAddress(&target); if (!abi->PrepareTrivialCall(thread, spBelowRedZone, @@ -120,13 +120,13 @@ contexts.GetContextAtIndex(0, context); m_start_addr = context.symbol->GetValue(); - lldb::addr_t StartLoadAddr = m_start_addr.GetLoadAddress(&process); + lldb::addr_t StartLoadAddr = m_start_addr.GetLoadAddress(&target); if(!thread.SaveFrameZeroState(m_register_backup)) return; m_function_addr = function; - lldb::addr_t FunctionLoadAddr = m_function_addr.GetLoadAddress(&process); + lldb::addr_t FunctionLoadAddr = m_function_addr.GetLoadAddress(&target); if (!abi->PrepareNormalCall(thread, spBelowRedZone, @@ -152,9 +152,9 @@ else { if (m_args) - s->Printf("Thread plan to call 0x%llx with parsed arguments", m_function_addr.GetLoadAddress(&m_process), m_arg_addr); + s->Printf("Thread plan to call 0x%llx with parsed arguments", m_function_addr.GetLoadAddress(&m_process.GetTarget()), m_arg_addr); else - s->Printf("Thread plan to call 0x%llx void * argument at: 0x%llx", m_function_addr.GetLoadAddress(&m_process), m_arg_addr); + s->Printf("Thread plan to call 0x%llx void * argument at: 0x%llx", m_function_addr.GetLoadAddress(&m_process.GetTarget()), m_arg_addr); } } Modified: lldb/trunk/source/Target/ThreadPlanRunToAddress.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/ThreadPlanRunToAddress.cpp?rev=113895&r1=113894&r2=113895&view=diff ============================================================================== --- lldb/trunk/source/Target/ThreadPlanRunToAddress.cpp (original) +++ lldb/trunk/source/Target/ThreadPlanRunToAddress.cpp Tue Sep 14 18:36:40 2010 @@ -39,7 +39,7 @@ m_addresses (), m_break_ids () { - m_addresses.push_back (address.GetLoadAddress(&m_thread.GetProcess())); + m_addresses.push_back (address.GetLoadAddress(&m_thread.GetProcess().GetTarget())); SetInitialBreakpoints(); } Modified: lldb/trunk/source/Target/ThreadPlanStepInRange.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/ThreadPlanStepInRange.cpp?rev=113895&r1=113894&r2=113895&view=diff ============================================================================== --- lldb/trunk/source/Target/ThreadPlanStepInRange.cpp (original) +++ lldb/trunk/source/Target/ThreadPlanStepInRange.cpp Tue Sep 14 18:36:40 2010 @@ -61,7 +61,7 @@ else { s->Printf ("Stepping through range (stepping into functions): "); - m_address_range.Dump (s, &m_thread.GetProcess(), Address::DumpStyleLoadAddress); + m_address_range.Dump (s, &m_thread.GetProcess().GetTarget(), Address::DumpStyleLoadAddress); } } Modified: lldb/trunk/source/Target/ThreadPlanStepOverRange.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/ThreadPlanStepOverRange.cpp?rev=113895&r1=113894&r2=113895&view=diff ============================================================================== --- lldb/trunk/source/Target/ThreadPlanStepOverRange.cpp (original) +++ lldb/trunk/source/Target/ThreadPlanStepOverRange.cpp Tue Sep 14 18:36:40 2010 @@ -56,7 +56,7 @@ else { s->Printf ("stepping through range (stepping over functions): "); - m_address_range.Dump (s, &m_thread.GetProcess(), Address::DumpStyleLoadAddress); + m_address_range.Dump (s, &m_thread.GetProcess().GetTarget(), Address::DumpStyleLoadAddress); } } Modified: lldb/trunk/source/Target/ThreadPlanStepRange.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/ThreadPlanStepRange.cpp?rev=113895&r1=113894&r2=113895&view=diff ============================================================================== --- lldb/trunk/source/Target/ThreadPlanStepRange.cpp (original) +++ lldb/trunk/source/Target/ThreadPlanStepRange.cpp Tue Sep 14 18:36:40 2010 @@ -100,7 +100,7 @@ lldb::addr_t pc_load_addr = m_thread.GetRegisterContext()->GetPC(); - ret_value = m_address_range.ContainsLoadAddress(pc_load_addr, &m_thread.GetProcess()); + ret_value = m_address_range.ContainsLoadAddress(pc_load_addr, &m_thread.GetProcess().GetTarget()); if (!ret_value) { @@ -119,7 +119,7 @@ if (log) { StreamString s; - m_address_range.Dump (&s, &m_thread.GetProcess(), Address::DumpStyleLoadAddress); + m_address_range.Dump (&s, &m_thread.GetProcess().GetTarget(), Address::DumpStyleLoadAddress); log->Printf ("Step range plan stepped to another range of same line: %s", s.GetData()); } @@ -138,15 +138,13 @@ ThreadPlanStepRange::InSymbol() { lldb::addr_t cur_pc = m_thread.GetRegisterContext()->GetPC(); - Process *process = m_thread.CalculateProcess(); - if (m_addr_context.function != NULL) { - return m_addr_context.function->GetAddressRange().ContainsLoadAddress (cur_pc, process); + return m_addr_context.function->GetAddressRange().ContainsLoadAddress (cur_pc, &m_thread.GetProcess().GetTarget()); } else if (m_addr_context.symbol != NULL) { - return m_addr_context.symbol->GetAddressRangeRef().ContainsLoadAddress (cur_pc, process); + return m_addr_context.symbol->GetAddressRangeRef().ContainsLoadAddress (cur_pc, &m_thread.GetProcess().GetTarget()); } return false; } From gclayton at apple.com Tue Sep 14 18:44:49 2010 From: gclayton at apple.com (Greg Clayton) Date: Tue, 14 Sep 2010 23:44:49 -0000 Subject: [Lldb-commits] [lldb] r113899 - /lldb/trunk/source/Core/Mangled.cpp Message-ID: <20100914234449.6038A2A6C12C@llvm.org> Author: gclayton Date: Tue Sep 14 18:44:49 2010 New Revision: 113899 URL: http://llvm.org/viewvc/llvm-project?rev=113899&view=rev Log: Fixed a compiler warning. 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=113899&r1=113898&r2=113899&view=diff ============================================================================== --- lldb/trunk/source/Core/Mangled.cpp (original) +++ lldb/trunk/source/Core/Mangled.cpp Tue Sep 14 18:44:49 2010 @@ -216,25 +216,19 @@ const ConstString& Mangled::GetName (Mangled::NamePreference preference) const { - switch (preference) + if (preference == ePreferDemangled) { - case ePreferDemangled: - { - const ConstString& name = GetDemangledName(); - if (name && !name.IsEmpty()) - return name; - return m_mangled; - } - break; - case ePreferMangled: - { - const ConstString& name = GetMangledName(); - if (name && !name.IsEmpty()) - return name; - return m_demangled; - - } - break; + const ConstString& name = GetDemangledName(); + if (name && !name.IsEmpty()) + return name; + return m_mangled; + } + else + { + const ConstString& name = GetMangledName(); + if (name && !name.IsEmpty()) + return name; + return m_demangled; } } From gclayton at apple.com Tue Sep 14 18:48:44 2010 From: gclayton at apple.com (Greg Clayton) Date: Tue, 14 Sep 2010 23:48:44 -0000 Subject: [Lldb-commits] [lldb] r113900 - /lldb/trunk/source/Core/Mangled.cpp Message-ID: <20100914234844.6AEFF2A6C12C@llvm.org> Author: gclayton Date: Tue Sep 14 18:48:44 2010 New Revision: 113900 URL: http://llvm.org/viewvc/llvm-project?rev=113900&view=rev Log: Fixed a case where Mangled::GetName(...) could return a invalid demangled name when one could be calculated. 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=113900&r1=113899&r2=113900&view=diff ============================================================================== --- lldb/trunk/source/Core/Mangled.cpp (original) +++ lldb/trunk/source/Core/Mangled.cpp Tue Sep 14 18:48:44 2010 @@ -218,17 +218,17 @@ { if (preference == ePreferDemangled) { - const ConstString& name = GetDemangledName(); - if (name && !name.IsEmpty()) - return name; + // Call the accessor to make sure we get a demangled name in case + // it hasn't been demangled yet... + if (GetDemangledName()) + return m_demangled; return m_mangled; } else { - const ConstString& name = GetMangledName(); - if (name && !name.IsEmpty()) - return name; - return m_demangled; + if (m_mangled) + return m_mangled; + return GetDemangledName(); } } From johnny.chen at apple.com Tue Sep 14 18:49:44 2010 From: johnny.chen at apple.com (Johnny Chen) Date: Tue, 14 Sep 2010 23:49:44 -0000 Subject: [Lldb-commits] [lldb] r113901 - /lldb/trunk/test/class_types/main.cpp Message-ID: <20100914234944.979BE2A6C12C@llvm.org> Author: johnny Date: Tue Sep 14 18:49:44 2010 New Revision: 113901 URL: http://llvm.org/viewvc/llvm-project?rev=113901&view=rev Log: Updated to add a printf() stmt. Modified: lldb/trunk/test/class_types/main.cpp Modified: lldb/trunk/test/class_types/main.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/class_types/main.cpp?rev=113901&r1=113900&r2=113901&view=diff ============================================================================== --- lldb/trunk/test/class_types/main.cpp (original) +++ lldb/trunk/test/class_types/main.cpp Tue Sep 14 18:49:44 2010 @@ -66,7 +66,7 @@ int m_b_int; }; - +#include class C : public B { public: @@ -74,6 +74,7 @@ B(ai, bi), m_c_int(ci) { + printf("Within C::ctor() m_c_int=%d\n", m_c_int); } //virtual From gclayton at apple.com Tue Sep 14 18:52:43 2010 From: gclayton at apple.com (Greg Clayton) Date: Tue, 14 Sep 2010 23:52:43 -0000 Subject: [Lldb-commits] [lldb] r113902 - in /lldb/trunk: include/lldb/Core/ThreadSafeSTLMap.h include/lldb/Target/SectionLoadList.h source/Target/SectionLoadList.cpp source/Target/Target.cpp Message-ID: <20100914235243.5C2DA2A6C12C@llvm.org> Author: gclayton Date: Tue Sep 14 18:52:43 2010 New Revision: 113902 URL: http://llvm.org/viewvc/llvm-project?rev=113902&view=rev Log: Clear the section list when a our current process is destroyed. Add missing files that I forgot to checkin. Added: lldb/trunk/include/lldb/Target/SectionLoadList.h lldb/trunk/source/Target/SectionLoadList.cpp Modified: lldb/trunk/include/lldb/Core/ThreadSafeSTLMap.h lldb/trunk/source/Target/Target.cpp Modified: lldb/trunk/include/lldb/Core/ThreadSafeSTLMap.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/ThreadSafeSTLMap.h?rev=113902&r1=113901&r2=113902&view=diff ============================================================================== --- lldb/trunk/include/lldb/Core/ThreadSafeSTLMap.h (original) +++ lldb/trunk/include/lldb/Core/ThreadSafeSTLMap.h Tue Sep 14 18:52:43 2010 @@ -46,6 +46,13 @@ Mutex::Locker locker(m_mutex); return m_collection.empty(); } + + void + Clear() + { + Mutex::Locker locker(m_mutex); + return m_collection.clear(); + } size_t Erase (const _Key& key) Added: lldb/trunk/include/lldb/Target/SectionLoadList.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/SectionLoadList.h?rev=113902&view=auto ============================================================================== --- lldb/trunk/include/lldb/Target/SectionLoadList.h (added) +++ lldb/trunk/include/lldb/Target/SectionLoadList.h Tue Sep 14 18:52:43 2010 @@ -0,0 +1,75 @@ +//===-- SectionLoadList.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_SectionLoadList_h_ +#define liblldb_SectionLoadList_h_ + +// C Includes +// C++ Includes +// Other libraries and framework includes +// Project includes +#include "lldb/lldb-include.h" +#include "lldb/Core/ThreadSafeSTLMap.h" + +namespace lldb_private { + +class SectionLoadList +{ +public: + //------------------------------------------------------------------ + // Constructors and Destructors + //------------------------------------------------------------------ + SectionLoadList () : + m_section_load_info () + { + } + + ~SectionLoadList() + { + } + + bool + IsEmpty() const; + + void + Clear (); + + lldb::addr_t + GetSectionLoadAddress (const Section *section) const; + + bool + ResolveLoadAddress (lldb::addr_t load_addr, Address &so_addr) const; + + bool + SetSectionLoadAddress (const Section *section, lldb::addr_t load_addr); + + // The old load address should be specified when unloading to ensure we get + // the correct instance of the section as a shared library could be loaded + // at more than one location. + bool + SetSectionUnloaded (const Section *section, lldb::addr_t load_addr); + + // Unload all instances of a section. This function can be used on systems + // that don't support multiple copies of the same shared library to be + // loaded at the same time. + size_t + SetSectionUnloaded (const Section *section); + + +protected: + typedef ThreadSafeSTLMap collection; + collection m_section_load_info; ///< A mapping of all currently loaded sections. + +private: + DISALLOW_COPY_AND_ASSIGN (SectionLoadList); +}; + +} // namespace lldb_private + +#endif // liblldb_SectionLoadList_h_ Added: lldb/trunk/source/Target/SectionLoadList.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/SectionLoadList.cpp?rev=113902&view=auto ============================================================================== --- lldb/trunk/source/Target/SectionLoadList.cpp (added) +++ lldb/trunk/source/Target/SectionLoadList.cpp Tue Sep 14 18:52:43 2010 @@ -0,0 +1,135 @@ +//===-- SectionLoadList.cpp -------------------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#include "lldb/Target/SectionLoadList.h" + +// C Includes +// C++ Includes +// Other libraries and framework includes +// Project includes +#include "lldb/Core/Log.h" +#include "lldb/Core/Module.h" +#include "lldb/Core/Section.h" +#include "lldb/Core/Stream.h" +#include "lldb/Symbol/Block.h" +#include "lldb/Symbol/Symbol.h" +#include "lldb/Symbol/SymbolContext.h" + +using namespace lldb; +using namespace lldb_private; + + +bool +SectionLoadList::IsEmpty() const +{ + return m_section_load_info.IsEmpty(); +} + +void +SectionLoadList::Clear () +{ + m_section_load_info.Clear(); +} + +addr_t +SectionLoadList::GetSectionLoadAddress (const Section *section) const +{ + // TODO: add support for the same section having multiple load addresses + addr_t section_load_addr = LLDB_INVALID_ADDRESS; + if (m_section_load_info.GetFirstKeyForValue (section, section_load_addr)) + return section_load_addr; + return LLDB_INVALID_ADDRESS; +} + +bool +SectionLoadList::SetSectionLoadAddress (const Section *section, addr_t load_addr) +{ + Log *log = lldb_private::GetLogIfAnyCategoriesSet (LIBLLDB_LOG_SHLIB | LIBLLDB_LOG_VERBOSE); + + if (log) + log->Printf ("SectionLoadList::%s (section = %p (%s.%s), load_addr = 0x%16.16llx)", + __FUNCTION__, + section, + section->GetModule()->GetFileSpec().GetFilename().AsCString(), + section->GetName().AsCString(), + load_addr); + + + const Section *existing_section = NULL; + Mutex::Locker locker(m_section_load_info.GetMutex()); + + if (m_section_load_info.GetValueForKeyNoLock (load_addr, existing_section)) + { + if (existing_section == section) + return false; // No change + } + m_section_load_info.SetValueForKeyNoLock (load_addr, section); + return true; // Changed +} + +size_t +SectionLoadList::SetSectionUnloaded (const Section *section) +{ + Log *log = lldb_private::GetLogIfAnyCategoriesSet (LIBLLDB_LOG_SHLIB | LIBLLDB_LOG_VERBOSE); + + if (log) + log->Printf ("SectionLoadList::%s (section = %p (%s.%s))", + __FUNCTION__, + section, + section->GetModule()->GetFileSpec().GetFilename().AsCString(), + section->GetName().AsCString()); + + Mutex::Locker locker(m_section_load_info.GetMutex()); + + size_t unload_count = 0; + addr_t section_load_addr; + while (m_section_load_info.GetFirstKeyForValueNoLock (section, section_load_addr)) + { + unload_count += m_section_load_info.EraseNoLock (section_load_addr); + } + return unload_count; +} + +bool +SectionLoadList::SetSectionUnloaded (const Section *section, addr_t load_addr) +{ + Log *log = lldb_private::GetLogIfAnyCategoriesSet (LIBLLDB_LOG_SHLIB | LIBLLDB_LOG_VERBOSE); + + if (log) + log->Printf ("SectionLoadList::%s (section = %p (%s.%s), load_addr = 0x%16.16llx)", + __FUNCTION__, + section, + section->GetModule()->GetFileSpec().GetFilename().AsCString(), + section->GetName().AsCString(), + load_addr); + + return m_section_load_info.Erase (load_addr) == 1; +} + + +bool +SectionLoadList::ResolveLoadAddress (addr_t load_addr, Address &so_addr) const +{ + addr_t section_load_addr = LLDB_INVALID_ADDRESS; + const Section *section = NULL; + + // First find the top level section that this load address exists in + if (m_section_load_info.LowerBound (load_addr, section_load_addr, section, true)) + { + addr_t offset = load_addr - section_load_addr; + if (offset < section->GetByteSize()) + { + // We have found the top level section, now we need to find the + // deepest child section. + return section->ResolveContainedAddress (offset, so_addr); + } + } + so_addr.Clear(); + return false; +} Modified: lldb/trunk/source/Target/Target.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/Target.cpp?rev=113902&r1=113901&r2=113902&view=diff ============================================================================== --- lldb/trunk/source/Target/Target.cpp (original) +++ lldb/trunk/source/Target/Target.cpp Tue Sep 14 18:52:43 2010 @@ -82,6 +82,7 @@ { if (m_process_sp.get()) { + m_section_load_list.Clear(); if (m_process_sp->IsAlive()) m_process_sp->Destroy(); else From johnny.chen at apple.com Tue Sep 14 19:00:54 2010 From: johnny.chen at apple.com (Johnny Chen) Date: Wed, 15 Sep 2010 00:00:54 -0000 Subject: [Lldb-commits] [lldb] r113905 - in /lldb/trunk/test: class_types/TestClassTypes.py lldbtest.py Message-ID: <20100915000054.46F662A6C12C@llvm.org> Author: johnny Date: Tue Sep 14 19:00:54 2010 New Revision: 113905 URL: http://llvm.org/viewvc/llvm-project?rev=113905&view=rev Log: Added two test cases to exercise 'expr this->m_c_int' with @expectedFailure decorators for the time being. Modified: lldb/trunk/test/class_types/TestClassTypes.py lldb/trunk/test/lldbtest.py Modified: lldb/trunk/test/class_types/TestClassTypes.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/class_types/TestClassTypes.py?rev=113905&r1=113904&r2=113905&view=diff ============================================================================== --- lldb/trunk/test/class_types/TestClassTypes.py (original) +++ lldb/trunk/test/class_types/TestClassTypes.py Tue Sep 14 19:00:54 2010 @@ -34,6 +34,19 @@ self.buildDwarf() self.breakpoint_creation_by_filespec_python() + @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin") + @unittest2.expectedFailure + def test_with_dsym_and_expr_parser(self): + """Test 'frame variable this' aand 'expr this' when stopped inside a constructor.""" + self.buildDsym() + self.class_types_expr_parser() + + @unittest2.expectedFailure + def test_with_dwarf_and_expr_parser(self): + """Test 'frame variable this' aand 'expr this' when stopped inside a constructor.""" + self.buildDwarf() + self.class_types_expr_parser() + def class_types(self): """Test 'frame variable this' when stopped on a class constructor.""" exe = os.path.join(os.getcwd(), "a.out") @@ -85,9 +98,45 @@ self.runCmd("run", RUN_SUCCEEDED) + self.runCmd("thread backtrace") + # We should be stopped on the breakpoint with a hit count of 1. self.assertTrue(breakpoint.GetHitCount() == 1) + def class_types_expr_parser(self): + """Test 'frame variable this' aand 'expr this' when stopped inside a constructor.""" + exe = os.path.join(os.getcwd(), "a.out") + self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) + + # Break on the ctor function of class C. + self.expect("breakpoint set -M C", BREAKPOINT_CREATED, + startstr = "Breakpoint created: 1: name = 'C', locations = 1") + + self.runCmd("run", RUN_SUCCEEDED) + + # The stop reason of the thread should be breakpoint. + self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT, + substrs = ['state is Stopped', + 'stop reason = breakpoint']) + + # The breakpoint should have a hit count of 1. + self.expect("breakpoint list", BREAKPOINT_HIT_ONCE, + substrs = [' resolved, hit count = 1']) + + # Continue on inside the ctor() body... + self.runCmd("thread step-over") + + # Verify that frame variable this->m_c_int behaves correctly. + self.expect("frame variable this->m_c_int", VARIABLES_DISPLAYED_CORRECTLY, + startstr = '(int) this->m_c_int = 66') + + # rdar://problem/8430916 + # expr this->m_c_int returns an incorrect value + # + # Verify that expr this->m_c_int behaves correctly. + self.expect("expr this->m_c_int", VARIABLES_DISPLAYED_CORRECTLY, + substrs = ['(int) 66']) + if __name__ == '__main__': import atexit Modified: lldb/trunk/test/lldbtest.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/lldbtest.py?rev=113905&r1=113904&r2=113905&view=diff ============================================================================== --- lldb/trunk/test/lldbtest.py (original) +++ lldb/trunk/test/lldbtest.py Tue Sep 14 19:00:54 2010 @@ -452,9 +452,9 @@ process.Continue() count = count + 1 - if count == 10: + if count == 15: if trace: - print >> sys.stderr, "Reached 10 iterations, giving up..." + print >> sys.stderr, "Reached 15 iterations, giving up..." # Enough iterations already, break out of the loop. return False From johnny.chen at apple.com Tue Sep 14 19:02:30 2010 From: johnny.chen at apple.com (Johnny Chen) Date: Wed, 15 Sep 2010 00:02:30 -0000 Subject: [Lldb-commits] [lldb] r113906 - /lldb/trunk/test/class_types/TestClassTypes.py Message-ID: <20100915000230.F29C22A6C12C@llvm.org> Author: johnny Date: Tue Sep 14 19:02:30 2010 New Revision: 113906 URL: http://llvm.org/viewvc/llvm-project?rev=113906&view=rev Log: Fixed typo in the doc strings. Modified: lldb/trunk/test/class_types/TestClassTypes.py Modified: lldb/trunk/test/class_types/TestClassTypes.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/class_types/TestClassTypes.py?rev=113906&r1=113905&r2=113906&view=diff ============================================================================== --- lldb/trunk/test/class_types/TestClassTypes.py (original) +++ lldb/trunk/test/class_types/TestClassTypes.py Tue Sep 14 19:02:30 2010 @@ -37,13 +37,13 @@ @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin") @unittest2.expectedFailure def test_with_dsym_and_expr_parser(self): - """Test 'frame variable this' aand 'expr this' when stopped inside a constructor.""" + """Test 'frame variable this' and 'expr this' when stopped inside a constructor.""" self.buildDsym() self.class_types_expr_parser() @unittest2.expectedFailure def test_with_dwarf_and_expr_parser(self): - """Test 'frame variable this' aand 'expr this' when stopped inside a constructor.""" + """Test 'frame variable this' and 'expr this' when stopped inside a constructor.""" self.buildDwarf() self.class_types_expr_parser() @@ -104,7 +104,7 @@ self.assertTrue(breakpoint.GetHitCount() == 1) def class_types_expr_parser(self): - """Test 'frame variable this' aand 'expr this' when stopped inside a constructor.""" + """Test 'frame variable this' and 'expr this' when stopped inside a constructor.""" exe = os.path.join(os.getcwd(), "a.out") self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) From jingham at apple.com Tue Sep 14 19:06:52 2010 From: jingham at apple.com (Jim Ingham) Date: Wed, 15 Sep 2010 00:06:52 -0000 Subject: [Lldb-commits] [lldb] r113907 - /lldb/trunk/source/Target/ThreadPlanStepInRange.cpp Message-ID: <20100915000652.1CC562A6C12C@llvm.org> Author: jingham Date: Tue Sep 14 19:06:51 2010 New Revision: 113907 URL: http://llvm.org/viewvc/llvm-project?rev=113907&view=rev Log: Adding a bit more logging. Modified: lldb/trunk/source/Target/ThreadPlanStepInRange.cpp Modified: lldb/trunk/source/Target/ThreadPlanStepInRange.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/ThreadPlanStepInRange.cpp?rev=113907&r1=113906&r2=113907&view=diff ============================================================================== --- lldb/trunk/source/Target/ThreadPlanStepInRange.cpp (original) +++ lldb/trunk/source/Target/ThreadPlanStepInRange.cpp Tue Sep 14 19:06:51 2010 @@ -190,11 +190,17 @@ { bool should_step_out = false; StackFrame *frame = current_plan->GetThread().GetStackFrameAtIndex(0).get(); + Log *log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_STEP); if (flags.IsSet(eAvoidNoDebug)) { if (!frame->HasDebugInformation()) + { + if (log) + log->Printf ("Stepping out of frame with no debug info"); + should_step_out = true; + } } if (!should_step_out) From jingham at apple.com Tue Sep 14 19:13:44 2010 From: jingham at apple.com (Jim Ingham) Date: Wed, 15 Sep 2010 00:13:44 -0000 Subject: [Lldb-commits] [lldb] r113908 - /lldb/trunk/source/Core/Mangled.cpp Message-ID: <20100915001344.6CAD52A6C12C@llvm.org> Author: jingham Date: Tue Sep 14 19:13:44 2010 New Revision: 113908 URL: http://llvm.org/viewvc/llvm-project?rev=113908&view=rev Log: The Mangled name comparision should prefer the mangled name. 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=113908&r1=113907&r2=113908&view=diff ============================================================================== --- lldb/trunk/source/Core/Mangled.cpp (original) +++ lldb/trunk/source/Core/Mangled.cpp Tue Sep 14 19:13:44 2010 @@ -95,7 +95,7 @@ int Mangled::Compare (const Mangled& a, const Mangled& b) { - return ConstString::Compare(a.GetName(ePreferDemangled), a.GetName(ePreferDemangled)); + return ConstString::Compare(a.GetName(ePreferMangled), a.GetName(ePreferMangled)); } From jingham at apple.com Tue Sep 14 20:34:14 2010 From: jingham at apple.com (Jim Ingham) Date: Wed, 15 Sep 2010 01:34:14 -0000 Subject: [Lldb-commits] [lldb] r113916 - /lldb/trunk/source/Commands/CommandObjectProcess.cpp Message-ID: <20100915013414.CF16C2A6C12C@llvm.org> Author: jingham Date: Tue Sep 14 20:34:14 2010 New Revision: 113916 URL: http://llvm.org/viewvc/llvm-project?rev=113916&view=rev Log: If you have already loaded a file into the debugger, "process attach" will attach to a process with the filename, unless you specify otherwise. Modified: lldb/trunk/source/Commands/CommandObjectProcess.cpp Modified: lldb/trunk/source/Commands/CommandObjectProcess.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectProcess.cpp?rev=113916&r1=113915&r2=113916&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectProcess.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectProcess.cpp Tue Sep 14 20:34:14 2010 @@ -537,30 +537,44 @@ Error error; int attach_pid = m_options.pid; + const char *wait_name = NULL; + + if (m_options.name.empty()) + { + if (old_exec_module_sp) + { + wait_name = old_exec_module_sp->GetFileSpec().GetFilename().AsCString(); + } + } + else + { + wait_name = m_options.name.c_str(); + } + // If we are waiting for a process with this name to show up, do that first. if (m_options.waitfor) { - if (m_options.name.empty()) + + if (wait_name == NULL) { - result.AppendError("Invalid arguments: must supply a process name with the waitfor option.\n"); + result.AppendError("Invalid arguments: must have a file loaded or supply a process name with the waitfor option.\n"); result.SetStatus (eReturnStatusFailed); return false; } + + interpreter.GetDebugger().GetOutputStream().Printf("Waiting to attach to a process named \"%s\".\n", wait_name); + error = process->Attach (wait_name, m_options.waitfor); + if (error.Success()) + { + result.SetStatus (eReturnStatusSuccessContinuingNoResult); + } else { - error = process->Attach (m_options.name.c_str(), m_options.waitfor); - if (error.Success()) - { - result.SetStatus (eReturnStatusSuccessContinuingNoResult); - } - else - { - result.AppendErrorWithFormat ("Waiting for a process to launch named '%s': %s\n", - m_options.name.c_str(), - error.AsCString()); - result.SetStatus (eReturnStatusFailed); - return false; - } + result.AppendErrorWithFormat ("Waiting for a process to launch named '%s': %s\n", + wait_name, + error.AsCString()); + result.SetStatus (eReturnStatusFailed); + return false; } } else @@ -568,21 +582,21 @@ // If the process was specified by name look it up, so we can warn if there are multiple // processes with this pid. - if (attach_pid == LLDB_INVALID_PROCESS_ID && !m_options.name.empty()) + if (attach_pid == LLDB_INVALID_PROCESS_ID && wait_name != NULL) { std::vector pids; StringList matches; - process->ListProcessesMatchingName(m_options.name.c_str(), matches, pids); + process->ListProcessesMatchingName(wait_name, matches, pids); if (matches.GetSize() > 1) { - result.AppendErrorWithFormat("More than one process named %s\n", m_options.name.c_str()); + result.AppendErrorWithFormat("More than one process named %s\n", wait_name); result.SetStatus (eReturnStatusFailed); return false; } else if (matches.GetSize() == 0) { - result.AppendErrorWithFormat("Could not find a process named %s\n", m_options.name.c_str()); + result.AppendErrorWithFormat("Could not find a process named %s\n", wait_name); result.SetStatus (eReturnStatusFailed); return false; } @@ -673,7 +687,7 @@ { { LLDB_OPT_SET_ALL, false, "plugin", 'P', required_argument, NULL, 0, "", "Name of the process plugin you want to use."}, { LLDB_OPT_SET_1, false, "pid", 'p', required_argument, NULL, 0, "", "The process ID of an existing process to attach to."}, -{ LLDB_OPT_SET_2, true, "name", 'n', required_argument, NULL, 0, "", "The name of the process to attach to."}, +{ LLDB_OPT_SET_2, false, "name", 'n', required_argument, NULL, 0, "", "The name of the process to attach to."}, { LLDB_OPT_SET_2, false, "waitfor", 'w', no_argument, NULL, 0, NULL, "Wait for the the process with to launch."}, { 0, false, NULL, 0, 0, NULL, 0, NULL, NULL } }; From gclayton at apple.com Tue Sep 14 23:15:46 2010 From: gclayton at apple.com (Greg Clayton) Date: Wed, 15 Sep 2010 04:15:46 -0000 Subject: [Lldb-commits] [lldb] r113933 - in /lldb/trunk: lldb.xcodeproj/ source/Plugins/SymbolFile/DWARF/ Message-ID: <20100915041547.07D8B2A6C12C@llvm.org> Author: gclayton Date: Tue Sep 14 23:15:46 2010 New Revision: 113933 URL: http://llvm.org/viewvc/llvm-project?rev=113933&view=rev Log: So we can't use .debug_pubtypes as it, as designed, does not tell us about all types in all compile units. I added a new kind of accelerator table to the DWARF that allows us to index the DWARF compile units and DIEs in a way that doesn't require the data to stay loaded. Currently when indexing the DWARF we check if the compile unit had parsed its DIEs and if it hasn't we index the data and free all of the DIEs so we can reparse later when we need to after using one of our complete accelerator tables to determine we need to reparse some DWARF. If the DIEs had already been parsed we leave them loaded. The new accelerator table uses the "const char *" pointers from our ConstString class as the keys, and NameToDIE::Info as the value. This info contains the compile unit index and the DIE index which means we are pointed right to the DIE we need unlike the other DWARF accelerator tables that often just point us to the compile unit we would find our answer in. Added: lldb/trunk/source/Plugins/SymbolFile/DWARF/NameToDIE.cpp lldb/trunk/source/Plugins/SymbolFile/DWARF/NameToDIE.h Modified: lldb/trunk/lldb.xcodeproj/project.pbxproj lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.h lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugAranges.cpp lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugAranges.h lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugPubnames.cpp lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h Modified: lldb/trunk/lldb.xcodeproj/project.pbxproj URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/lldb.xcodeproj/project.pbxproj?rev=113933&r1=113932&r2=113933&view=diff ============================================================================== --- lldb/trunk/lldb.xcodeproj/project.pbxproj (original) +++ lldb/trunk/lldb.xcodeproj/project.pbxproj Tue Sep 14 23:15:46 2010 @@ -16,6 +16,8 @@ 2617447A11685869005ADD65 /* SBType.h in Headers */ = {isa = PBXBuildFile; fileRef = 2617447911685869005ADD65 /* SBType.h */; settings = {ATTRIBUTES = (Public, ); }; }; 2618D7901240115500F2B8FE /* SectionLoadList.h in Headers */ = {isa = PBXBuildFile; fileRef = 2618D78F1240115500F2B8FE /* SectionLoadList.h */; }; 2618D7921240116900F2B8FE /* SectionLoadList.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2618D7911240116900F2B8FE /* SectionLoadList.cpp */; }; + 2618D959124056C700F2B8FE /* NameToDIE.h in Headers */ = {isa = PBXBuildFile; fileRef = 2618D957124056C700F2B8FE /* NameToDIE.h */; }; + 2618D9EB12406FE600F2B8FE /* NameToDIE.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2618D9EA12406FE600F2B8FE /* NameToDIE.cpp */; }; 261B5A5411C3F2AD00AABD0A /* SharingPtr.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 261B5A5211C3F2AD00AABD0A /* SharingPtr.cpp */; }; 261B5A5511C3F2AD00AABD0A /* SharingPtr.h in Headers */ = {isa = PBXBuildFile; fileRef = 261B5A5311C3F2AD00AABD0A /* SharingPtr.h */; settings = {ATTRIBUTES = (Public, ); }; }; 262CFC7711A4510000946C6C /* debugserver in Resources */ = {isa = PBXBuildFile; fileRef = 26CE05A0115C31E50022F371 /* debugserver */; }; @@ -534,6 +536,8 @@ 2617447911685869005ADD65 /* SBType.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SBType.h; path = include/lldb/API/SBType.h; sourceTree = ""; }; 2618D78F1240115500F2B8FE /* SectionLoadList.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SectionLoadList.h; path = include/lldb/Target/SectionLoadList.h; sourceTree = ""; }; 2618D7911240116900F2B8FE /* SectionLoadList.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = SectionLoadList.cpp; path = source/Target/SectionLoadList.cpp; sourceTree = ""; }; + 2618D957124056C700F2B8FE /* NameToDIE.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NameToDIE.h; sourceTree = ""; }; + 2618D9EA12406FE600F2B8FE /* NameToDIE.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = NameToDIE.cpp; sourceTree = ""; }; 261B5A5211C3F2AD00AABD0A /* SharingPtr.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = SharingPtr.cpp; path = source/Utility/SharingPtr.cpp; sourceTree = ""; }; 261B5A5311C3F2AD00AABD0A /* SharingPtr.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SharingPtr.h; path = include/lldb/Utility/SharingPtr.h; sourceTree = ""; }; 261E18CC1148966100BADCD3 /* GDBRemoteRegisterContext.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = GDBRemoteRegisterContext.h; path = "source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.h"; sourceTree = ""; }; @@ -1384,6 +1388,8 @@ 260C89D610F57C5600BB2B04 /* DWARFLocationDescription.h */, 260C89D710F57C5600BB2B04 /* DWARFLocationList.cpp */, 260C89D810F57C5600BB2B04 /* DWARFLocationList.h */, + 2618D9EA12406FE600F2B8FE /* NameToDIE.cpp */, + 2618D957124056C700F2B8FE /* NameToDIE.h */, 260C89D910F57C5600BB2B04 /* SymbolFileDWARF.cpp */, 260C89DA10F57C5600BB2B04 /* SymbolFileDWARF.h */, 26109B3B1155D70100CC3529 /* LogChannelDWARF.cpp */, @@ -2278,6 +2284,7 @@ 961FAC1F12360C7D00F93A47 /* ArchDefaultUnwindPlan-x86.h in Headers */, 268F9D53123AA15200B91E9B /* SBSymbolContextList.h in Headers */, 2618D7901240115500F2B8FE /* SectionLoadList.h in Headers */, + 2618D959124056C700F2B8FE /* NameToDIE.h in Headers */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -2742,6 +2749,7 @@ 69A01E261236C5D400C660B5 /* TimeValue.cpp in Sources */, 268F9D55123AA16600B91E9B /* SBSymbolContextList.cpp in Sources */, 2618D7921240116900F2B8FE /* SectionLoadList.cpp in Sources */, + 2618D9EB12406FE600F2B8FE /* NameToDIE.cpp in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp?rev=113933&r1=113932&r2=113933&view=diff ============================================================================== --- lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp (original) +++ lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp Tue Sep 14 23:15:46 2010 @@ -19,6 +19,7 @@ #include "DWARFDIECollection.h" #include "DWARFFormValue.h" #include "LogChannelDWARF.h" +#include "NameToDIE.h" #include "SymbolFileDWARF.h" using namespace lldb_private; @@ -524,44 +525,46 @@ return dies.Size() - old_size; } -void -DWARFCompileUnit::AddGlobalDIEByIndex (uint32_t die_idx) -{ - m_global_die_indexes.push_back (die_idx); -} - - -void -DWARFCompileUnit::AddGlobal (const DWARFDebugInfoEntry* die) -{ - // Indexes to all file level global and static variables - m_global_die_indexes; - - if (m_die_array.empty()) - return; - - const DWARFDebugInfoEntry* first_die = &m_die_array[0]; - const DWARFDebugInfoEntry* end = first_die + m_die_array.size(); - if (first_die <= die && die < end) - m_global_die_indexes.push_back (die - first_die); -} +//void +//DWARFCompileUnit::AddGlobalDIEByIndex (uint32_t die_idx) +//{ +// m_global_die_indexes.push_back (die_idx); +//} +// +// +//void +//DWARFCompileUnit::AddGlobal (const DWARFDebugInfoEntry* die) +//{ +// // Indexes to all file level global and static variables +// m_global_die_indexes; +// +// if (m_die_array.empty()) +// return; +// +// const DWARFDebugInfoEntry* first_die = &m_die_array[0]; +// const DWARFDebugInfoEntry* end = first_die + m_die_array.size(); +// if (first_die <= die && die < end) +// m_global_die_indexes.push_back (die - first_die); +//} void DWARFCompileUnit::Index ( - lldb_private::UniqueCStringMap& base_name_to_function_die, - lldb_private::UniqueCStringMap& full_name_to_function_die, - lldb_private::UniqueCStringMap& method_name_to_function_die, - lldb_private::UniqueCStringMap& selector_name_to_function_die, - lldb_private::UniqueCStringMap& name_to_type_die, - lldb_private::UniqueCStringMap& name_to_global_die, + const uint32_t cu_idx, + NameToDIE& base_name_to_function_die, + NameToDIE& full_name_to_function_die, + NameToDIE& method_name_to_function_die, + NameToDIE& selector_name_to_function_die, + NameToDIE& name_to_global_die, + NameToDIE& name_to_type_die, const DWARFDebugRanges *debug_ranges, DWARFDebugAranges *aranges ) { const DataExtractor* debug_str = &m_dwarf2Data->get_debug_str_data(); + NameToDIE::Info die_info = { cu_idx, 0 }; DWARFDebugInfoEntry::const_iterator pos; DWARFDebugInfoEntry::const_iterator begin = m_die_array.begin(); DWARFDebugInfoEntry::const_iterator end = m_die_array.end(); @@ -746,6 +749,8 @@ } } + die_info.die_idx = std::distance (begin, pos); + switch (tag) { case DW_TAG_subprogram: @@ -771,9 +776,8 @@ ++method_name; // Extract the objective C basename and add it to the // accelerator tables - size_t method_name_len = name_len - (method_name - name) - 1; - ConstString method_const_str (method_name, method_name_len); - selector_name_to_function_die.Append(method_const_str.AsCString(), die.GetOffset()); + size_t method_name_len = name_len - (method_name - name) - 1; + selector_name_to_function_die.Insert (ConstString (method_name, method_name_len), die_info); } } } @@ -808,15 +812,16 @@ } } + if (is_method) - method_name_to_function_die.Append(ConstString(name).AsCString(), die.GetOffset()); + method_name_to_function_die.Insert (ConstString(name), die_info); else - base_name_to_function_die.Append(ConstString(name).AsCString(), die.GetOffset()); + base_name_to_function_die.Insert (ConstString(name), die_info); } if (mangled.GetMangledName()) - full_name_to_function_die.Append(mangled.GetMangledName().AsCString(), die.GetOffset()); + full_name_to_function_die.Insert (mangled.GetMangledName(), die_info); if (mangled.GetDemangledName()) - full_name_to_function_die.Append(mangled.GetDemangledName().AsCString(), die.GetOffset()); + full_name_to_function_die.Insert (mangled.GetDemangledName(), die_info); } break; @@ -824,11 +829,11 @@ if (has_address) { if (name) - base_name_to_function_die.Append(ConstString(name).AsCString(), die.GetOffset()); + base_name_to_function_die.Insert (ConstString(name), die_info); if (mangled.GetMangledName()) - full_name_to_function_die.Append(mangled.GetMangledName().AsCString(), die.GetOffset()); + full_name_to_function_die.Insert (mangled.GetMangledName(), die_info); if (mangled.GetDemangledName()) - full_name_to_function_die.Append(mangled.GetDemangledName().AsCString(), die.GetOffset()); + full_name_to_function_die.Insert (mangled.GetDemangledName(), die_info); } break; @@ -844,15 +849,14 @@ case DW_TAG_namespace: if (name && is_declaration == false) { - name_to_type_die.Append(ConstString(name).AsCString(), die.GetOffset()); + name_to_type_die.Insert (ConstString(name), die_info); } break; case DW_TAG_variable: if (name && has_location && is_global_or_static_variable) { - AddGlobalDIEByIndex (std::distance (begin, pos)); - name_to_global_die.Append(ConstString(name).AsCString(), die.GetOffset()); + name_to_global_die.Insert (ConstString(name), die_info); } break; Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.h?rev=113933&r1=113932&r2=113933&view=diff ============================================================================== --- lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.h (original) +++ lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.h Tue Sep 14 23:15:46 2010 @@ -13,6 +13,8 @@ #include "SymbolFileDWARF.h" #include "DWARFDebugInfoEntry.h" +class NameToDIE; + class DWARFCompileUnit { public: @@ -91,6 +93,12 @@ } DWARFDebugInfoEntry* + GetDIEAtIndexUnchecked (uint32_t idx) + { + return &m_die_array[idx]; + } + + DWARFDebugInfoEntry* GetDIEPtr (dw_offset_t die_offset); const DWARFDebugInfoEntry* @@ -101,6 +109,7 @@ static uint8_t GetDefaultAddressSize(); + static void SetDefaultAddressSize(uint8_t addr_size); @@ -117,37 +126,20 @@ } - void - AddGlobalDIEByIndex (uint32_t die_idx); - - void - AddGlobal (const DWARFDebugInfoEntry* die); - - size_t - GetNumGlobals () const - { - return m_global_die_indexes.size(); - } - - const DWARFDebugInfoEntry * - GetGlobalDIEAtIndex (uint32_t idx) - { - if (idx < m_global_die_indexes.size()) - { - uint32_t die_idx = m_global_die_indexes[idx]; - if (die_idx < m_die_array.size()) - return &m_die_array[die_idx]; - } - return NULL; - } - - void - Index (lldb_private::UniqueCStringMap& base_name_to_function_die, - lldb_private::UniqueCStringMap& full_name_to_function_die, - lldb_private::UniqueCStringMap& method_name_to_function_die, - lldb_private::UniqueCStringMap& selector_name_to_function_die, - lldb_private::UniqueCStringMap& name_to_type_die, - lldb_private::UniqueCStringMap& name_to_global_die, +// void +// AddGlobalDIEByIndex (uint32_t die_idx); +// +// void +// AddGlobal (const DWARFDebugInfoEntry* die); +// + void + Index (const uint32_t cu_idx, + NameToDIE& base_name_to_function_die, + NameToDIE& full_name_to_function_die, + NameToDIE& method_name_to_function_die, + NameToDIE& selector_name_to_function_die, + NameToDIE& name_to_global_die, + NameToDIE& name_to_type_die, const DWARFDebugRanges* debug_ranges, DWARFDebugAranges *aranges); @@ -164,7 +156,6 @@ DWARFDebugInfoEntry::collection m_die_array; // The compile unit debug information entry item std::auto_ptr m_aranges_ap; // A table similar to the .debug_aranges table, but this one points to the exact DW_TAG_subprogram DIEs - std::vector m_global_die_indexes; // Indexes to all file level global and static variables void * m_user_data; private: DISALLOW_COPY_AND_ASSIGN (DWARFCompileUnit); Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugAranges.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugAranges.cpp?rev=113933&r1=113932&r2=113933&view=diff ============================================================================== --- lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugAranges.cpp (original) +++ lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugAranges.cpp Tue Sep 14 23:15:46 2010 @@ -167,22 +167,22 @@ //---------------------------------------------------------------------- // Dump //---------------------------------------------------------------------- -void -DWARFDebugAranges::Dump(SymbolFileDWARF* dwarf2Data, Stream *s) -{ - const DataExtractor &debug_aranges_data = dwarf2Data->get_debug_aranges_data(); - if (debug_aranges_data.ValidOffset(0)) - { - uint32_t offset = 0; - - DWARFDebugArangeSet set; - while (set.Extract(debug_aranges_data, &offset)) - set.Dump(s); - } - else - s->PutCString("< EMPTY >\n"); -} - +//void +//DWARFDebugAranges::Dump(SymbolFileDWARF* dwarf2Data, Stream *s) +//{ +// const DataExtractor &debug_aranges_data = dwarf2Data->get_debug_aranges_data(); +// if (debug_aranges_data.ValidOffset(0)) +// { +// uint32_t offset = 0; +// +// DWARFDebugArangeSet set; +// while (set.Extract(debug_aranges_data, &offset)) +// set.Dump(s); +// } +// else +// s->PutCString("< EMPTY >\n"); +//} +// //---------------------------------------------------------------------- // AppendDebugRanges Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugAranges.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugAranges.h?rev=113933&r1=113932&r2=113933&view=diff ============================================================================== --- lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugAranges.h (original) +++ lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugAranges.h Tue Sep 14 23:15:46 2010 @@ -75,7 +75,7 @@ void Print() const; dw_offset_t FindAddress(dw_addr_t address) const; bool IsEmpty() const { return m_aranges.empty(); } - void Dump(lldb_private::Stream *s); +// void Dump(lldb_private::Stream *s); uint32_t NumRanges() const { return m_aranges.size(); Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugPubnames.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugPubnames.cpp?rev=113933&r1=113932&r2=113933&view=diff ============================================================================== --- lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugPubnames.cpp (original) +++ lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugPubnames.cpp Tue Sep 14 23:15:46 2010 @@ -187,8 +187,6 @@ if (add_die && (name || mangled)) { - if (is_variable) - cu->AddGlobal(die); pubnames_set.AddDescriptor(die->GetOffset() - cu_offset, mangled ? mangled : name); } } Added: lldb/trunk/source/Plugins/SymbolFile/DWARF/NameToDIE.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/NameToDIE.cpp?rev=113933&view=auto ============================================================================== --- lldb/trunk/source/Plugins/SymbolFile/DWARF/NameToDIE.cpp (added) +++ lldb/trunk/source/Plugins/SymbolFile/DWARF/NameToDIE.cpp Tue Sep 14 23:15:46 2010 @@ -0,0 +1,60 @@ +//===-- NameToDIE.cpp -------------------------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#include "NameToDIE.h" +#include "lldb/Core/Stream.h" + +size_t +NameToDIE::Find (const lldb_private::ConstString &name, std::vector &info_array) const +{ + const char *name_cstr = name.AsCString(); + const size_t initial_info_array_size = info_array.size(); + collection::const_iterator pos, end = m_collection.end(); + for (pos = m_collection.lower_bound (name_cstr); pos != end && pos->first == name_cstr; ++pos) + { + info_array.push_back (pos->second); + } + return info_array.size() - initial_info_array_size; +} + +size_t +NameToDIE::Find (const lldb_private::RegularExpression& regex, std::vector &info_array) const +{ + const size_t initial_info_array_size = info_array.size(); + collection::const_iterator pos, end = m_collection.end(); + for (pos = m_collection.begin(); pos != end; ++pos) + { + if (regex.Execute(pos->first)) + info_array.push_back (pos->second); + } + return info_array.size() - initial_info_array_size; +} + +size_t +NameToDIE::FindAllEntriesForCompileUnitWithIndex (const uint32_t cu_idx, std::vector &info_array) const +{ + const size_t initial_info_array_size = info_array.size(); + collection::const_iterator pos, end = m_collection.end(); + for (pos = m_collection.begin(); pos != end; ++pos) + { + if (cu_idx == pos->second.cu_idx) + info_array.push_back (pos->second); + } + return info_array.size() - initial_info_array_size; +} + +void +NameToDIE::Dump (lldb_private::Stream *s) +{ + collection::const_iterator pos, end = m_collection.end(); + for (pos = m_collection.begin(); pos != end; ++pos) + { + s->Printf("%p: 0x%8.8x 0x%8.8x \"%s\"\n", pos->first, pos->second.cu_idx, pos->second.die_idx, pos->first); + } +} Added: lldb/trunk/source/Plugins/SymbolFile/DWARF/NameToDIE.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/NameToDIE.h?rev=113933&view=auto ============================================================================== --- lldb/trunk/source/Plugins/SymbolFile/DWARF/NameToDIE.h (added) +++ lldb/trunk/source/Plugins/SymbolFile/DWARF/NameToDIE.h Tue Sep 14 23:15:46 2010 @@ -0,0 +1,63 @@ +//===-- NameToDIE.h ---------------------------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#ifndef SymbolFileDWARF_NameToDIE_h_ +#define SymbolFileDWARF_NameToDIE_h_ + +#include +#include "lldb/Core/ConstString.h" +#include "lldb/Core/RegularExpression.h" + +class NameToDIE +{ +public: + typedef struct Info + { + uint32_t cu_idx; + uint32_t die_idx; + } Info; + + + NameToDIE () : + m_collection () + { + } + + ~NameToDIE () + { + } + + void + Dump (lldb_private::Stream *s); + + void + Insert (const lldb_private::ConstString& name, const Info &info) + { + m_collection.insert (std::make_pair(name.AsCString(), info)); + } + + size_t + Find (const lldb_private::ConstString &name, + std::vector &info_array) const; + + size_t + Find (const lldb_private::RegularExpression& regex, + std::vector &info_array) const; + + size_t + FindAllEntriesForCompileUnitWithIndex (const uint32_t cu_idx, + std::vector &info_array) const; + +protected: + typedef std::multimap collection; + + collection m_collection; +}; + +#endif // SymbolFileDWARF_NameToDIE_h_ Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp?rev=113933&r1=113932&r2=113933&view=diff ============================================================================== --- lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp (original) +++ lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp Tue Sep 14 23:15:46 2010 @@ -26,6 +26,7 @@ #include "lldb/Core/RegularExpression.h" #include "lldb/Core/Scalar.h" #include "lldb/Core/Section.h" +#include "lldb/Core/StreamFile.h" #include "lldb/Core/Timer.h" #include "lldb/Core/Value.h" @@ -135,33 +136,24 @@ SymbolFile(ofile), m_flags(), m_data_debug_abbrev(), - m_data_debug_aranges(), m_data_debug_frame(), m_data_debug_info(), m_data_debug_line(), m_data_debug_loc(), - m_data_debug_macinfo(), - m_data_debug_pubnames(), - m_data_debug_pubtypes(), m_data_debug_ranges(), m_data_debug_str(), m_abbr(), m_aranges(), m_info(), m_line(), - m_base_name_to_function_die(), - m_full_name_to_function_die(), - m_method_name_to_function_die(), - m_selector_name_to_function_die(), - m_name_to_global_die(), - m_name_to_type_die(), + m_function_basename_index(), + m_function_fullname_index(), + m_function_method_index(), + m_function_selector_index(), + m_global_index(), + m_types_index(), m_indexed(false), -// m_pubnames(), -// m_pubbasetypes(), - m_pubtypes(), - m_ranges()//, -// m_type_fixups(), -// m_indirect_fixups() + m_ranges() { } @@ -333,12 +325,6 @@ } const DataExtractor& -SymbolFileDWARF::get_debug_aranges_data() -{ - return GetCachedSectionData (flagsGotDebugArangesData, eSectionTypeDWARFDebugAranges, m_data_debug_aranges); -} - -const DataExtractor& SymbolFileDWARF::get_debug_frame_data() { return GetCachedSectionData (flagsGotDebugFrameData, eSectionTypeDWARFDebugFrame, m_data_debug_frame); @@ -363,24 +349,6 @@ } const DataExtractor& -SymbolFileDWARF::get_debug_macinfo_data() -{ - return GetCachedSectionData (flagsGotDebugMacInfoData, eSectionTypeDWARFDebugMacInfo, m_data_debug_macinfo); -} - -const DataExtractor& -SymbolFileDWARF::get_debug_pubnames_data() -{ - return GetCachedSectionData (flagsGotDebugPubNamesData, eSectionTypeDWARFDebugPubNames, m_data_debug_pubnames); -} - -const DataExtractor& -SymbolFileDWARF::get_debug_pubtypes_data() -{ - return GetCachedSectionData (flagsGotDebugPubTypesData, eSectionTypeDWARFDebugPubTypes, m_data_debug_pubtypes); -} - -const DataExtractor& SymbolFileDWARF::get_debug_ranges_data() { return GetCachedSectionData (flagsGotDebugRangesData, eSectionTypeDWARFDebugRanges, m_data_debug_ranges); @@ -475,30 +443,6 @@ return m_info.get(); } -//DWARFDebugLine* -//SymbolFileDWARF::DebugLine() -//{ -// if (m_line.get() == NULL) -// { -// Timer scoped_timer(__PRETTY_FUNCTION__); -// const DataExtractor &debug_line_data = debug_line(); -// if (debug_line_data.GetByteSize() > 0) -// { -// m_line.reset(new DWARFDebugLine()); -// if (m_line.get()) -// m_line->Parse(debug_line_data); -// } -// } -// return m_line.get(); -//} -// -//const DWARFDebugLine* -//SymbolFileDWARF::DebugLine() const -//{ -// return m_line.get(); -//} - - DWARFCompileUnit* SymbolFileDWARF::GetDWARFCompileUnitForUID(lldb::user_id_t cu_uid) { @@ -508,37 +452,6 @@ return NULL; } -//DWARFCompileUnit* -//SymbolFileDWARF::GetNextUnparsedDWARFCompileUnit(DWARFCompileUnit* prev_cu) -//{ -// DWARFCompileUnit* cu = NULL; -// DWARFDebugInfo* info = DebugInfo(); -// if (info) -// { -// uint32_t cu_idx = 0; -// if (prev_cu != NULL) -// { -// // Find the index of the previus DWARF compile unit if one was provided -// while ((cu = info->GetCompileUnitAtIndex(cu_idx)) != NULL) -// { -// ++cu_idx; -// if (cu == prev_cu) -// break; -// } -// } -// -// // Now find the next unparsed DWARF compile unit. We do this by checking the -// // user data in the DWARFCompileUnit class that starts as NULL, and eventually -// // holds a pointer to the CompileUnit that was created for it after it has -// // been parsed. -// while ((cu = info->GetCompileUnitAtIndex(cu_idx)) != NULL) -// { -// if (cu->GetUserData() == NULL) -// break; -// } -// } -// return cu; -//} DWARFDebugRanges* SymbolFileDWARF::DebugRanges() @@ -561,88 +474,6 @@ { return m_ranges.get(); } -// -//DWARFDebugPubnames* -//SymbolFileDWARF::DebugPubnames() -//{ -// if (m_pubnames.get() == NULL) -// { -// Timer scoped_timer(__PRETTY_FUNCTION__, "%s this = %p", __PRETTY_FUNCTION__, this); -// const DataExtractor &debug_pubnames_data = get_debug_pubnames_data(); -// if (debug_pubnames_data.GetByteSize() > 0) -// { -// // Pass false to indicate this is a pubnames section -// m_pubnames.reset(new DWARFDebugPubnames()); -// if (m_pubnames.get()) -// { -// // "m_pubnames->GeneratePubnames" is costly, but needed for global variables -// m_pubnames->GeneratePubnames(this); -// -//#if 0 -// StreamFile s(stdout); -// s.Printf (".debug_pubnames for %s/%s:\n", -// m_obj_file->GetModule()->GetFileSpec().GetDirectory().AsCString(), -// m_obj_file->GetModule()->GetFileSpec().GetFilename().AsCString()); -// m_pubnames->Dump (&s); -//#endif -// // "m_pubnames->Extract" is quicker, but the pubnames don't always contain what we need. -// //m_pubnames->Extract(debug_pubnames_data); -// } -// } -// } -// return m_pubnames.get(); -//} -// -//const DWARFDebugPubnames* -//SymbolFileDWARF::DebugPubnames() const -//{ -// return m_pubnames.get(); -//} - -//DWARFDebugPubnames* -//SymbolFileDWARF::DebugPubBaseTypes() -//{ -// if (m_pubbasetypes.get() == NULL) -// { -// Timer scoped_timer(__PRETTY_FUNCTION__, "%s this = %p", __PRETTY_FUNCTION__, this); -// // Pass false to indicate this is a pubnames section -// m_pubbasetypes.reset(new DWARFDebugPubnames()); -// if (m_pubbasetypes.get()) -// m_pubbasetypes->GeneratePubBaseTypes(this); -// } -// return m_pubbasetypes.get(); -//} -// -//const DWARFDebugPubnames* -//SymbolFileDWARF::DebugPubBaseTypes() const -//{ -// return m_pubbasetypes.get(); -//} -// -//const DWARFDebugPubnames* -//SymbolFileDWARF::DebugPubtypes() const -//{ -// return m_pubtypes.get(); -//} -// -DWARFDebugPubnames* -SymbolFileDWARF::DebugPubtypes() -{ - if (m_pubtypes.get() == NULL) - { - Timer scoped_timer(__PRETTY_FUNCTION__, "%s this = %p", __PRETTY_FUNCTION__, this); - const DataExtractor &debug_pubtypes_data = get_debug_pubtypes_data(); - if (debug_pubtypes_data.GetByteSize() > 0) - { - // Pass false to indicate this is a pubnames section - m_pubtypes.reset(new DWARFDebugPubnames()); - if (m_pubtypes.get()) - m_pubtypes->Extract(debug_pubtypes_data); - } - } - return m_pubtypes.get(); -} - bool SymbolFileDWARF::ParseCompileUnit(DWARFCompileUnit* cu, CompUnitSP& compile_unit_sp) @@ -682,92 +513,12 @@ return false; } -#if defined LLDB_SYMBOL_FILE_DWARF_SHRINK_TEST - -void -SymbolFileDWARF::ShrinkDSYM(CompileUnit *dc_cu, DWARFCompileUnit *dw_cu, const FileSpec& cu_fspec, const FileSpec& base_types_fspec, FSToDIES& fs_to_dies, const DWARFDebugInfoEntry *die) -{ - while (die != NULL) - { - dw_tag_t tag = die->Tag(); - - switch (tag) - { - case DW_TAG_base_type: - // Put all base types into the base type compile unit - fs_to_dies[base_types_fspec].Insert(die); - break; - - default: - { - uint32_t decl_file = die->GetAttributeValueAsUnsigned(this, dw_cu, DW_AT_decl_file, 0); - if (decl_file) - { - fs_to_dies[dc_cu->GetSupportFiles().GetFileSpecAtIndex(decl_file)].Insert(die); - } - else - { - // add this to the current compile unit - fs_to_dies[cu_fspec].Insert(die); - } - } - break; - } - - die = die->GetSibling(); - } -} - - - -#endif - uint32_t SymbolFileDWARF::GetNumCompileUnits() { DWARFDebugInfo* info = DebugInfo(); if (info) - { -#if defined LLDB_SYMBOL_FILE_DWARF_SHRINK_TEST - uint32_t cu_idx; - FSToDIES fs_to_dies; - - FileSpec base_type_fspec("DW_TAG_base_type"); - const uint32_t num_comp_units = info->GetNumCompileUnits(); - - for (cu_idx=0; cu_idx < num_comp_units; ++cu_idx) - { - DWARFCompileUnit* cu = info->GetCompileUnitAtIndex(cu_idx); - if (cu != NULL) - { - const DWARFDebugInfoEntry *cu_die = cu->DIE(); - if (cu_die) - { - CompUnitSP dc_cu_sp; - ParseCompileUnit(cu, dc_cu_sp); - if (dc_cu_sp.get()) - { - FileSpec cu_fspec(*dc_cu_sp.get()); - - ShrinkDSYM(dc_cu_sp.get(), cu, cu_fspec, base_type_fspec, fs_to_dies, cu->DIE()->GetFirstChild()); - } - } - } - } - - Stream strm(stdout); - FSToDIES::const_iterator pos, end = fs_to_dies.end(); - for (pos = fs_to_dies.begin(); pos != end; ++pos) - { - strm << "\n\nMinimal Compile Unit: " << pos->first << ":\n"; - const DWARFDIECollection& dies = pos->second; - dies.Dump(strm, NULL); - } - return num_comp_units; -#else return info->GetNumCompileUnits(); -#endif - } return 0; } @@ -1462,24 +1213,20 @@ } Type* -SymbolFileDWARF::ResolveTypeUID(lldb::user_id_t type_uid) +SymbolFileDWARF::ResolveTypeUID (lldb::user_id_t type_uid) { DWARFDebugInfo* debug_info = DebugInfo(); if (debug_info) { - const DWARFDebugInfoEntry* type_die = debug_info->GetDIEPtr(type_uid, NULL); + DWARFCompileUnitSP cu_sp; + const DWARFDebugInfoEntry* type_die = debug_info->GetDIEPtr(type_uid, &cu_sp); if (type_die != NULL) { void *type = type_die->GetUserData(); if (type == NULL) { - DWARFCompileUnitSP cu_sp; - const DWARFDebugInfoEntry* die = debug_info->GetDIEPtr(type_uid, &cu_sp); - if (die != NULL) - { - TypeSP owning_type_sp; - TypeSP type_sp(GetTypeForDIE(cu_sp.get(), die, owning_type_sp, 0, 0)); - } + TypeSP owning_type_sp; + GetTypeForDIE(cu_sp.get(), type_die, owning_type_sp, 0, 0); type = type_die->GetUserData(); } if (type != DIE_IS_BEING_PARSED) @@ -1489,6 +1236,24 @@ return NULL; } +Type* +SymbolFileDWARF::ResolveType (DWARFCompileUnit* cu, const DWARFDebugInfoEntry* type_die) +{ + if (type_die != NULL) + { + void *type = type_die->GetUserData(); + if (type == NULL) + { + TypeSP owning_type_sp; + TypeSP type_sp(GetTypeForDIE(cu, type_die, owning_type_sp, 0, 0)); + type = type_die->GetUserData(); + } + if (type != DIE_IS_BEING_PARSED) + return (Type *)type; + } + return NULL; +} + CompileUnit* SymbolFileDWARF::GetCompUnitForDWARFCompUnit(DWARFCompileUnit* cu, uint32_t cu_idx) { @@ -1762,12 +1527,13 @@ bool clear_dies = cu->ExtractDIEsIfNeeded (false) > 1; - cu->Index (m_base_name_to_function_die, - m_full_name_to_function_die, - m_method_name_to_function_die, - m_selector_name_to_function_die, - m_name_to_global_die, - m_name_to_type_die, + cu->Index (cu_idx, + m_function_basename_index, + m_function_fullname_index, + m_function_method_index, + m_function_selector_index, + m_global_index, + m_types_index, DebugRanges(), m_aranges.get()); @@ -1777,20 +1543,27 @@ cu->ClearDIEs (true); } - m_base_name_to_function_die.Sort(); - m_full_name_to_function_die.Sort(); - m_method_name_to_function_die.Sort(); - m_selector_name_to_function_die.Sort(); - m_name_to_global_die.Sort(); - m_name_to_type_die.Sort(); m_aranges->Sort(); + +#if 0 + StreamFile s(stdout); + s.Printf("DWARF index for '%s':", GetObjectFile()->GetFileSpec().GetFilename().AsCString()); + s.Printf("\nFunction basenames:\n"); m_function_basename_index.Dump (&s); + s.Printf("\nFunction fullnames:\n"); m_function_fullname_index.Dump (&s); + s.Printf("\nFunction methods:\n"); m_function_method_index.Dump (&s); + s.Printf("\nFunction selectors:\n"); m_function_selector_index.Dump (&s); + s.Printf("\nGlobals and statics:\n"); m_global_index.Dump (&s); + s.Printf("\nTypes:\n"); m_types_index.Dump (&s); +#endif } } uint32_t SymbolFileDWARF::FindGlobalVariables (const ConstString &name, bool append, uint32_t max_matches, VariableList& variables) { - std::vector die_offsets; + DWARFDebugInfo* info = DebugInfo(); + if (info == NULL) + return 0; // If we aren't appending the results to this list, then clear the list if (!append) @@ -1804,29 +1577,31 @@ if (!m_indexed) Index (); - const UniqueCStringMap::Entry *entry; + SymbolContext sc; + sc.module_sp = m_obj_file->GetModule()->GetSP(); + assert (sc.module_sp); - for (entry = m_name_to_global_die.FindFirstValueForName (name.AsCString()); - entry != NULL; - entry = m_name_to_global_die.FindNextValueForName (name.AsCString(), entry)) + DWARFCompileUnit* cu = NULL; + DWARFCompileUnit* prev_cu = NULL; + const DWARFDebugInfoEntry* die = NULL; + std::vector die_info_array; + const size_t num_matches = m_global_index.Find(name, die_info_array); + for (size_t i=0; iGetDIEPtr (entry->value, &cu_sp); - DWARFCompileUnit* cu = cu_sp.get(); - if (die) - { - SymbolContext sc; - sc.module_sp = m_obj_file->GetModule()->GetSP(); - assert (sc.module_sp); + cu = info->GetCompileUnitAtIndex(die_info_array[i].cu_idx); + + if (cu != prev_cu) + cu->ExtractDIEsIfNeeded (false); - sc.comp_unit = GetCompUnitForDWARFCompUnit(cu, UINT32_MAX); - assert(sc.comp_unit != NULL); + die = cu->GetDIEAtIndexUnchecked(die_info_array[i].die_idx); - ParseVariables(sc, cu_sp.get(), LLDB_INVALID_ADDRESS, die, false, false, &variables); + sc.comp_unit = GetCompUnitForDWARFCompUnit(cu, UINT32_MAX); + assert(sc.comp_unit != NULL); - if (variables.GetSize() - original_size >= max_matches) - break; - } + ParseVariables(sc, cu, LLDB_INVALID_ADDRESS, die, false, false, &variables); + + if (variables.GetSize() - original_size >= max_matches) + break; } // Return the number of variable that were appended to the list @@ -1836,7 +1611,9 @@ uint32_t SymbolFileDWARF::FindGlobalVariables(const RegularExpression& regex, bool append, uint32_t max_matches, VariableList& variables) { - std::vector die_offsets; + DWARFDebugInfo* info = DebugInfo(); + if (info == NULL) + return 0; // If we aren't appending the results to this list, then clear the list if (!append) @@ -1850,33 +1627,31 @@ if (!m_indexed) Index (); - // Create the pubnames information so we can quickly lookup external symbols by name - const size_t num_entries = m_name_to_global_die.GetSize(); - for (size_t i=0; iGetModule()->GetSP(); + assert (sc.module_sp); + + DWARFCompileUnit* cu = NULL; + DWARFCompileUnit* prev_cu = NULL; + const DWARFDebugInfoEntry* die = NULL; + std::vector die_info_array; + const size_t num_matches = m_global_index.Find(regex, die_info_array); + for (size_t i=0; iGetDIEPtr (die_offset, &cu_sp); - DWARFCompileUnit* cu = cu_sp.get(); - if (die) - { - SymbolContext sc; - sc.module_sp = m_obj_file->GetModule()->GetSP(); - assert (sc.module_sp); + cu = info->GetCompileUnitAtIndex(die_info_array[i].cu_idx); + + if (cu != prev_cu) + cu->ExtractDIEsIfNeeded (false); + die = cu->GetDIEAtIndexUnchecked(die_info_array[i].die_idx); - sc.comp_unit = GetCompUnitForDWARFCompUnit(cu, UINT32_MAX); - assert(sc.comp_unit != NULL); + sc.comp_unit = GetCompUnitForDWARFCompUnit(cu, UINT32_MAX); + assert(sc.comp_unit != NULL); - ParseVariables(sc, cu_sp.get(), LLDB_INVALID_ADDRESS, die, false, false, &variables); + ParseVariables(sc, cu, LLDB_INVALID_ADDRESS, die, false, false, &variables); - if (variables.GetSize() - original_size >= max_matches) - break; - } + if (variables.GetSize() - original_size >= max_matches) + break; } // Return the number of variable that were appended to the list @@ -1888,39 +1663,95 @@ SymbolFileDWARF::FindFunctions ( const ConstString &name, - UniqueCStringMap &name_to_die, + const NameToDIE &name_to_die, SymbolContextList& sc_list ) { - const UniqueCStringMap::Entry *entry; - + DWARFDebugInfo* info = DebugInfo(); + if (info == NULL) + return; + SymbolContext sc; - for (entry = name_to_die.FindFirstValueForName (name.AsCString()); - entry != NULL; - entry = name_to_die.FindNextValueForName (name.AsCString(), entry)) + sc.module_sp = m_obj_file->GetModule()->GetSP(); + assert (sc.module_sp); + + DWARFCompileUnit* cu = NULL; + DWARFCompileUnit* prev_cu = NULL; + const DWARFDebugInfoEntry* die = NULL; + std::vector die_info_array; + const size_t num_matches = name_to_die.Find(name, die_info_array); + for (size_t i=0; iGetDIEPtr (entry->value, &cu_sp); - if (die) + cu = info->GetCompileUnitAtIndex(die_info_array[i].cu_idx); + + if (cu != prev_cu) + cu->ExtractDIEsIfNeeded (false); + + die = cu->GetDIEAtIndexUnchecked(die_info_array[i].die_idx); + if (GetFunction (cu, die, sc)) { - if (GetFunction (cu_sp.get(), die, sc)) + // We found the function, so we should find the line table + // and line table entry as well + LineTable *line_table = sc.comp_unit->GetLineTable(); + if (line_table == NULL) { - // We found the function, so we should find the line table - // and line table entry as well - LineTable *line_table = sc.comp_unit->GetLineTable(); - if (line_table == NULL) - { - if (ParseCompileUnitLineTable(sc)) - line_table = sc.comp_unit->GetLineTable(); - } - if (line_table != NULL) - line_table->FindLineEntryByAddress (sc.function->GetAddressRange().GetBaseAddress(), sc.line_entry); - - sc_list.Append(sc); + if (ParseCompileUnitLineTable(sc)) + line_table = sc.comp_unit->GetLineTable(); } + if (line_table != NULL) + line_table->FindLineEntryByAddress (sc.function->GetAddressRange().GetBaseAddress(), sc.line_entry); + + sc_list.Append(sc); } } +} + + +void +SymbolFileDWARF::FindFunctions +( + const RegularExpression ®ex, + const NameToDIE &name_to_die, + SymbolContextList& sc_list +) +{ + DWARFDebugInfo* info = DebugInfo(); + if (info == NULL) + return; + SymbolContext sc; + sc.module_sp = m_obj_file->GetModule()->GetSP(); + assert (sc.module_sp); + + DWARFCompileUnit* cu = NULL; + DWARFCompileUnit* prev_cu = NULL; + const DWARFDebugInfoEntry* die = NULL; + std::vector die_info_array; + const size_t num_matches = name_to_die.Find(regex, die_info_array); + for (size_t i=0; iGetCompileUnitAtIndex(die_info_array[i].cu_idx); + + if (cu != prev_cu) + cu->ExtractDIEsIfNeeded (false); + + die = cu->GetDIEAtIndexUnchecked(die_info_array[i].die_idx); + if (GetFunction (cu, die, sc)) + { + // We found the function, so we should find the line table + // and line table entry as well + LineTable *line_table = sc.comp_unit->GetLineTable(); + if (line_table == NULL) + { + if (ParseCompileUnitLineTable(sc)) + line_table = sc.comp_unit->GetLineTable(); + } + if (line_table != NULL) + line_table->FindLineEntryByAddress (sc.function->GetAddressRange().GetBaseAddress(), sc.line_entry); + + sc_list.Append(sc); + } + } } uint32_t @@ -1936,8 +1767,6 @@ "SymbolFileDWARF::FindFunctions (name = '%s')", name.AsCString()); - std::vector die_offsets; - // If we aren't appending the results to this list, then clear the list if (!append) sc_list.Clear(); @@ -1951,16 +1780,16 @@ Index (); if (name_type_mask & eFunctionNameTypeBase) - FindFunctions (name, m_base_name_to_function_die, sc_list); + FindFunctions (name, m_function_basename_index, sc_list); if (name_type_mask & eFunctionNameTypeFull) - FindFunctions (name, m_full_name_to_function_die, sc_list); + FindFunctions (name, m_function_fullname_index, sc_list); if (name_type_mask & eFunctionNameTypeMethod) - FindFunctions (name, m_method_name_to_function_die, sc_list); + FindFunctions (name, m_function_method_index, sc_list); if (name_type_mask & eFunctionNameTypeSelector) - FindFunctions (name, m_selector_name_to_function_die, sc_list); + FindFunctions (name, m_function_selector_index, sc_list); // Return the number of variable that were appended to the list return sc_list.GetSize() - original_size; @@ -1974,8 +1803,6 @@ "SymbolFileDWARF::FindFunctions (regex = '%s')", regex.GetText()); - std::vector die_offsets; - // If we aren't appending the results to this list, then clear the list if (!append) sc_list.Clear(); @@ -1988,35 +1815,9 @@ if (!m_indexed) Index (); - // Create the pubnames information so we can quickly lookup external symbols by name - // Create the pubnames information so we can quickly lookup external symbols by name - const size_t num_entries = m_full_name_to_function_die.GetSize(); - SymbolContext sc; - for (size_t i=0; iGetDIEPtr (die_offset, &cu_sp); - if (die) - { - if (GetFunction (cu_sp.get(), die, sc)) - { - // We found the function, so we should find the line table - // and line table entry as well - LineTable *line_table = sc.comp_unit->GetLineTable(); - - if (line_table != NULL) - line_table->FindLineEntryByAddress (sc.function->GetAddressRange().GetBaseAddress(), sc.line_entry); - + FindFunctions (regex, m_function_basename_index, sc_list); - sc_list.Append(sc); - } - } - } + FindFunctions (regex, m_function_fullname_index, sc_list); // Return the number of variable that were appended to the list return sc_list.GetSize() - original_size; @@ -2025,55 +1826,45 @@ uint32_t SymbolFileDWARF::FindTypes(const SymbolContext& sc, const ConstString &name, bool append, uint32_t max_matches, TypeList& types) { + DWARFDebugInfo* info = DebugInfo(); + if (info == NULL) + return 0; + // If we aren't appending the results to this list, then clear the list if (!append) types.Clear(); - // Create the pubnames information so we can quickly lookup external symbols by name - DWARFDebugPubnames* pubtypes = DebugPubtypes(); - if (pubtypes) + const uint32_t initial_types_size = types.GetSize(); + DWARFCompileUnit* cu = NULL; + DWARFCompileUnit* prev_cu = NULL; + const DWARFDebugInfoEntry* die = NULL; + std::vector die_info_array; + const size_t num_matches = m_types_index.Find (name, die_info_array); + for (size_t i=0; i die_offsets; - if (!pubtypes->Find(name.AsCString(), false, die_offsets)) + cu = info->GetCompileUnitAtIndex(die_info_array[i].cu_idx); + + if (cu != prev_cu) + cu->ExtractDIEsIfNeeded (false); + + die = cu->GetDIEAtIndexUnchecked(die_info_array[i].die_idx); + + Type *matching_type = ResolveType (cu, die); + if (matching_type) { -// DWARFDebugPubnames* pub_base_types = DebugPubBaseTypes(); -// if (pub_base_types && !pub_base_types->Find(name.AsCString(), false, die_offsets)) - return 0; + // We found a type pointer, now find the shared pointer form our type list + TypeSP type_sp (m_obj_file->GetModule()->GetTypeList()->FindType(matching_type->GetID())); + assert (type_sp.get() != NULL); + types.InsertUnique (type_sp); + if (types.GetSize() >= max_matches) + break; } - return FindTypes(die_offsets, max_matches, types); } - return 0; + return types.GetSize() - initial_types_size; } -//uint32_t -//SymbolFileDWARF::FindTypes(const SymbolContext& sc, const RegularExpression& regex, bool append, uint32_t max_matches, TypeList& types) -//{ -// // If we aren't appending the results to this list, then clear the list -// if (!append) -// types.Clear(); -// -// // Create the pubnames information so we can quickly lookup external symbols by name -// DWARFDebugPubnames* pubtypes = DebugPubtypes(); -// if (pubtypes) -// { -// std::vector die_offsets; -// if (!pubtypes->Find(regex, die_offsets)) -// { -// DWARFDebugPubnames* pub_base_types = DebugPubBaseTypes(); -// if (pub_base_types && !pub_base_types->Find(regex, die_offsets)) -// return 0; -// } -// -// return FindTypes(die_offsets, max_matches, encoding, udt_uid, types); -// } -// -// return 0; -//} -// - - uint32_t SymbolFileDWARF::FindTypes(std::vector die_offsets, uint32_t max_matches, TypeList& types) { @@ -3344,10 +3135,12 @@ if (!m_indexed) Index (); - const size_t num_globals = dwarf_cu->GetNumGlobals(); + + std::vector global_die_info_array; + const size_t num_globals = m_global_index.FindAllEntriesForCompileUnitWithIndex (sc.comp_unit->GetID(), global_die_info_array); for (size_t idx=0; idxGetGlobalDIEAtIndex (idx), LLDB_INVALID_ADDRESS)); + VariableSP var_sp (ParseVariableDIE(sc, dwarf_cu, dwarf_cu->GetDIEAtIndexUnchecked(global_die_info_array[idx].die_idx), LLDB_INVALID_ADDRESS)); if (var_sp) { variables->AddVariable(var_sp); Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h?rev=113933&r1=113932&r2=113933&view=diff ============================================================================== --- lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h (original) +++ lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h Tue Sep 14 23:15:46 2010 @@ -31,6 +31,7 @@ // Project includes #include "DWARFDefines.h" +#include "NameToDIE.h" //---------------------------------------------------------------------- @@ -92,7 +93,8 @@ virtual size_t ParseTypes (const lldb_private::SymbolContext& sc); virtual size_t ParseVariablesForContext (const lldb_private::SymbolContext& sc); - virtual lldb_private::Type* ResolveTypeUID(lldb::user_id_t type_uid); + virtual lldb_private::Type* ResolveTypeUID(lldb::user_id_t type_uid); + virtual lldb_private::Type* ResolveType (DWARFCompileUnit* cu, const DWARFDebugInfoEntry* type_die); virtual clang::DeclContext* GetClangDeclContextForTypeUID (lldb::user_id_t type_uid); virtual uint32_t ResolveSymbolContext (const lldb_private::Address& so_addr, uint32_t resolve_scope, lldb_private::SymbolContext& sc); @@ -134,14 +136,10 @@ //virtual CompUnitSP GetCompUnitAtIndex(size_t cu_idx) = 0; const lldb_private::DataExtractor& get_debug_abbrev_data(); - const lldb_private::DataExtractor& get_debug_aranges_data(); const lldb_private::DataExtractor& get_debug_frame_data(); const lldb_private::DataExtractor& get_debug_info_data(); const lldb_private::DataExtractor& get_debug_line_data(); const lldb_private::DataExtractor& get_debug_loc_data(); - const lldb_private::DataExtractor& get_debug_macinfo_data(); - const lldb_private::DataExtractor& get_debug_pubnames_data(); - const lldb_private::DataExtractor& get_debug_pubtypes_data(); const lldb_private::DataExtractor& get_debug_ranges_data(); const lldb_private::DataExtractor& get_debug_str_data(); @@ -154,19 +152,6 @@ DWARFDebugInfo* DebugInfo(); const DWARFDebugInfo* DebugInfo() const; -// These shouldn't be used unless we want to dump the DWARF line tables. -// DWARFDebugLine* DebugLine(); -// const DWARFDebugLine* DebugLine() const; - -// DWARFDebugPubnames* DebugPubnames(); -// const DWARFDebugPubnames* DebugPubnames() const; -// -// DWARFDebugPubnames* DebugPubBaseTypes(); -// const DWARFDebugPubnames* DebugPubBaseTypes() const; -// - DWARFDebugPubnames* DebugPubtypes(); -// const DWARFDebugPubnames* DebugPubtypes() const; - DWARFDebugRanges* DebugRanges(); const DWARFDebugRanges* DebugRanges() const; @@ -286,7 +271,12 @@ void FindFunctions( const lldb_private::ConstString &name, - lldb_private::UniqueCStringMap &name_to_die, + const NameToDIE &name_to_die, + lldb_private::SymbolContextList& sc_list); + + void FindFunctions ( + const lldb_private::RegularExpression ®ex, + const NameToDIE &name_to_die, lldb_private::SymbolContextList& sc_list); lldb_private::Type* GetUniquedTypeForDIEOffset(dw_offset_t type_die_offset, lldb::TypeSP& owning_type_sp, int32_t child_type, uint32_t idx, bool safe); @@ -298,14 +288,10 @@ lldb_private::Flags m_flags; lldb_private::DataExtractor m_dwarf_data; lldb_private::DataExtractor m_data_debug_abbrev; - lldb_private::DataExtractor m_data_debug_aranges; lldb_private::DataExtractor m_data_debug_frame; lldb_private::DataExtractor m_data_debug_info; lldb_private::DataExtractor m_data_debug_line; lldb_private::DataExtractor m_data_debug_loc; - lldb_private::DataExtractor m_data_debug_macinfo; - lldb_private::DataExtractor m_data_debug_pubnames; - lldb_private::DataExtractor m_data_debug_pubtypes; lldb_private::DataExtractor m_data_debug_ranges; lldb_private::DataExtractor m_data_debug_str; @@ -315,31 +301,19 @@ std::auto_ptr m_aranges; std::auto_ptr m_info; std::auto_ptr m_line; - lldb_private::UniqueCStringMap m_base_name_to_function_die; // All concrete functions - lldb_private::UniqueCStringMap m_full_name_to_function_die; // All concrete functions - lldb_private::UniqueCStringMap m_method_name_to_function_die; // All inlined functions - lldb_private::UniqueCStringMap m_selector_name_to_function_die; // All method names for functions of classes - lldb_private::UniqueCStringMap m_name_to_global_die; // Global and static variables - lldb_private::UniqueCStringMap m_name_to_type_die; // All type DIE offsets + NameToDIE m_function_basename_index; // All concrete functions + NameToDIE m_function_fullname_index; // All concrete functions + NameToDIE m_function_method_index; // All inlined functions + NameToDIE m_function_selector_index; // All method names for functions of classes + NameToDIE m_global_index; // Global and static variables + NameToDIE m_types_index; // All type DIE offsets bool m_indexed; -// std::auto_ptr m_pubnames; -// std::auto_ptr m_pubbasetypes; // Just like m_pubtypes, but for DW_TAG_base_type DIEs - std::auto_ptr m_pubtypes; std::auto_ptr m_ranges; typedef llvm::DenseMap DIEToDeclContextMap; DIEToDeclContextMap m_die_to_decl_ctx; -// TypeFixupColl m_type_fixups; -// std::vector m_indirect_fixups; - -//#define LLDB_SYMBOL_FILE_DWARF_SHRINK_TEST 1 -#if defined(LLDB_SYMBOL_FILE_DWARF_SHRINK_TEST) - - typedef std::map FSToDIES; - void ShrinkDSYM(CompileUnit *dc_cu, DWARFCompileUnit *dw_cu, const FileSpec& cu_fspec, const FileSpec& base_types_cu_fspec, FSToDIES& fs_to_dies, const DWARFDebugInfoEntry *die); -#endif }; #endif // liblldb_SymbolFileDWARF_h_ From gclayton at apple.com Wed Sep 15 00:19:45 2010 From: gclayton at apple.com (Greg Clayton) Date: Wed, 15 Sep 2010 05:19:45 -0000 Subject: [Lldb-commits] [lldb] r113947 - /lldb/trunk/source/Core/Communication.cpp Message-ID: <20100915051945.8A2732A6C12C@llvm.org> Author: gclayton Date: Wed Sep 15 00:19:45 2010 New Revision: 113947 URL: http://llvm.org/viewvc/llvm-project?rev=113947&view=rev Log: Fixed a race condition that was sometimes stopping our command line interpreter from working. The communication read thread could startup and immediately exit if m_read_thread_enabled was checked in the thread function before it was set by the thread that spawns the read thread. Now m_read_thread_enabled is set to true prior to spawning the read thread to avoid this issue. Hopefully this will clear up the sporatic failures in our test suite. Modified: lldb/trunk/source/Core/Communication.cpp Modified: lldb/trunk/source/Core/Communication.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/Communication.cpp?rev=113947&r1=113946&r2=113947&view=diff ============================================================================== --- lldb/trunk/source/Core/Communication.cpp (original) +++ lldb/trunk/source/Core/Communication.cpp Wed Sep 15 00:19:45 2010 @@ -211,8 +211,10 @@ char thread_name[1024]; snprintf(thread_name, sizeof(thread_name), "", m_broadcaster_name.AsCString()); + m_read_thread_enabled = true; m_read_thread = Host::ThreadCreate (thread_name, Communication::ReadThread, this, error_ptr); - m_read_thread_enabled = m_read_thread != LLDB_INVALID_HOST_THREAD; + if (m_read_thread == LLDB_INVALID_HOST_THREAD) + m_read_thread_enabled = false; return m_read_thread_enabled; } From ctice at apple.com Wed Sep 15 00:35:14 2010 From: ctice at apple.com (Caroline Tice) Date: Wed, 15 Sep 2010 05:35:14 -0000 Subject: [Lldb-commits] [lldb] r113950 - in /lldb/trunk: include/lldb/Core/UserSettingsController.h source/Core/UserSettingsController.cpp Message-ID: <20100915053514.655642A6C12C@llvm.org> Author: ctice Date: Wed Sep 15 00:35:14 2010 New Revision: 113950 URL: http://llvm.org/viewvc/llvm-project?rev=113950&view=rev Log: Remove all visible uses of "[DEFAULT]" instance name. Add ability to rename UserSettingsInstances after they have been created (via UserSettingsController::RenameInstanceSettings. Modified: lldb/trunk/include/lldb/Core/UserSettingsController.h lldb/trunk/source/Core/UserSettingsController.cpp Modified: lldb/trunk/include/lldb/Core/UserSettingsController.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/UserSettingsController.h?rev=113950&r1=113949&r2=113950&view=diff ============================================================================== --- lldb/trunk/include/lldb/Core/UserSettingsController.h (original) +++ lldb/trunk/include/lldb/Core/UserSettingsController.h Wed Sep 15 00:35:14 2010 @@ -124,6 +124,9 @@ void UnregisterInstanceSettings (InstanceSettings *instance_settings); + void + RenameInstanceSettings (const char *old_name, const char *new_name); + // ------------------------------------------------------------------------- // Public static methods // ------------------------------------------------------------------------- @@ -324,7 +327,6 @@ std::vector m_children; std::map m_pending_settings; std::map m_live_settings; // live settings should never be NULL (hence 'live') - mutable Mutex m_children_mutex; mutable Mutex m_pending_settings_mutex; mutable Mutex m_live_settings_mutex; @@ -375,13 +377,17 @@ const ConstString & GetInstanceName () { return m_instance_name; } + + void + ChangeInstanceName (const std::string &new_instance_name); + static const ConstString & GetDefaultName (); protected: UserSettingsController &m_owner; - const ConstString m_instance_name; + ConstString m_instance_name; }; Modified: lldb/trunk/source/Core/UserSettingsController.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/UserSettingsController.cpp?rev=113950&r1=113949&r2=113950&view=diff ============================================================================== --- lldb/trunk/source/Core/UserSettingsController.cpp (original) +++ lldb/trunk/source/Core/UserSettingsController.cpp Wed Sep 15 00:35:14 2010 @@ -763,11 +763,8 @@ value_string.Printf ("%s ", tmp_value.GetStringAtIndex (j)); } - if (! parent_prefix.empty()) // May need to test size() > 0 - result_stream.Printf ("%s.[DEFAULT].%s (%s) = '%s'\n", prefix, var_name.AsCString(), - UserSettingsController::GetTypeString (entry.var_type), value_string.GetData()); - else - result_stream.Printf ("[DEFAULT].%s (%s) = '%s'\n", var_name.AsCString(), + if (! parent_prefix.empty()) + result_stream.Printf ("%s.%s (%s) = '%s'\n", prefix, var_name.AsCString(), UserSettingsController::GetTypeString (entry.var_type), value_string.GetData()); } } @@ -775,7 +772,6 @@ void UserSettingsController::GetAllPendingSettingValues (StreamString &result_stream) { - //StreamString description; std::map::iterator pos; std::string parent_prefix; @@ -799,8 +795,8 @@ StreamString value_str; if (tmp_value.GetSize() == 0) - break; - if (tmp_value.GetSize() == 1) + value_str.Printf (""); + else if (tmp_value.GetSize() == 1) value_str.Printf ("%s", tmp_value.GetStringAtIndex (0)); else { @@ -864,9 +860,8 @@ StreamString tmp_value_str; if (tmp_value.GetSize() == 0) - break; - - if (tmp_value.GetSize() == 1) + tmp_value_str.Printf (""); + else if (tmp_value.GetSize() == 1) tmp_value_str.Printf ("%s", tmp_value.GetStringAtIndex (0)); else { @@ -1103,7 +1098,7 @@ { ConstString child_prefix = child->GetLevelName(); StreamString new_prefix; - if (! current_prefix.empty() ) // May need to see if size() > 0 + if (! current_prefix.empty()) new_prefix.Printf ("%s.%s", current_prefix.c_str(), child_prefix.AsCString()); else new_prefix.Printf ("%s", child_prefix.AsCString()); @@ -1130,7 +1125,7 @@ { StreamString full_var_name; SettingEntry entry = root->m_settings.global_settings[i]; - if (! current_prefix.empty()) // May need to see if size() > 0 + if (! current_prefix.empty()) full_var_name.Printf ("%s.%s", current_prefix.c_str(), entry.var_name); else full_var_name.Printf ("%s", entry.var_name); @@ -1167,7 +1162,7 @@ { ConstString child_prefix = child->GetLevelName(); StreamString new_prefix; - if (! current_prefix.empty()) // May need to see if size() > 0 + if (! current_prefix.empty()) new_prefix.Printf ("%s.%s", current_prefix.c_str(), child_prefix.AsCString()); else new_prefix.Printf ("%s", child_prefix.AsCString()); @@ -1928,6 +1923,58 @@ err.SetErrorString ("Invalid enumeration value; cannot update variable.\n"); } +void +UserSettingsController::RenameInstanceSettings (const char *old_name, const char *new_name) +{ + Mutex::Locker live_mutex (m_live_settings_mutex); + Mutex::Locker pending_mutex (m_pending_settings_mutex); + std::string old_name_key (old_name); + std::string new_name_key (new_name); + + // First, find the live instance settings for the old_name. If they don't exist in the live settings + // list, then this is not a setting that can be renamed. + + if ((old_name_key[0] != '[') || (old_name_key[old_name_key.size() -1] != ']')) + { + StreamString tmp_str; + tmp_str.Printf ("[%s]", old_name); + old_name_key = tmp_str.GetData(); + } + + if ((new_name_key[0] != '[') || (new_name_key[new_name_key.size() -1] != ']')) + { + StreamString tmp_str; + tmp_str.Printf ("[%s]", new_name); + new_name_key = tmp_str.GetData(); + } + + std::map::iterator pos; + + pos = m_live_settings.find (old_name_key); + if (pos != m_live_settings.end()) + { + InstanceSettings *live_settings = pos->second; + + // Rename the settings. + live_settings->ChangeInstanceName (new_name_key); + + // Now see if there are any pending settings for the new name; if so, copy them into live_settings. + std::map::iterator pending_pos; + pending_pos = m_pending_settings.find (new_name_key); + if (pending_pos != m_pending_settings.end()) + { + lldb::InstanceSettingsSP pending_settings_sp = pending_pos->second; + live_settings->CopyInstanceSettings (pending_settings_sp, false); + } + + // Erase the old entry (under the old name) from live settings. + m_live_settings.erase (pos); + + // Add the new entry, with the new name, into live settings. + m_live_settings[new_name_key] = live_settings; + } +} + //---------------------------------------------------------------------- // class InstanceSettings //---------------------------------------------------------------------- @@ -1954,3 +2001,11 @@ return g_default_settings_name; } + +void +InstanceSettings::ChangeInstanceName (const std::string &new_instance_name) +{ + m_instance_name.SetCString (new_instance_name.c_str()); +} + + From gclayton at apple.com Wed Sep 15 00:51:25 2010 From: gclayton at apple.com (Greg Clayton) Date: Wed, 15 Sep 2010 05:51:25 -0000 Subject: [Lldb-commits] [lldb] r113951 - in /lldb/trunk: include/lldb/Symbol/Declaration.h include/lldb/Symbol/Function.h lldb.xcodeproj/project.pbxproj source/Commands/CommandObjectDisassemble.cpp source/Core/Disassembler.cpp source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp source/Symbol/Block.cpp source/Symbol/Declaration.cpp source/Symbol/Function.cpp source/Symbol/Type.cpp source/Symbol/Variable.cpp Message-ID: <20100915055125.4AA2E2A6C12C@llvm.org> Author: gclayton Date: Wed Sep 15 00:51:24 2010 New Revision: 113951 URL: http://llvm.org/viewvc/llvm-project?rev=113951&view=rev Log: Fixed a missing newline when dumping mixed disassembly. Added a "bool show_fullpaths" to many more objects that were previously always dumping full paths. Fixed a few places where the DWARF was not indexed when we we needed it to be when making queries. Also fixed an issue where the DWARF in .o files wasn't searching all .o files for the types. Fixed an issue with the output from "image lookup --type " where the name and byte size might not be resolved and might not display. We now call the accessors so we end up seeing all of the type info. Modified: lldb/trunk/include/lldb/Symbol/Declaration.h lldb/trunk/include/lldb/Symbol/Function.h lldb/trunk/lldb.xcodeproj/project.pbxproj lldb/trunk/source/Commands/CommandObjectDisassemble.cpp lldb/trunk/source/Core/Disassembler.cpp lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp lldb/trunk/source/Symbol/Block.cpp lldb/trunk/source/Symbol/Declaration.cpp lldb/trunk/source/Symbol/Function.cpp lldb/trunk/source/Symbol/Type.cpp lldb/trunk/source/Symbol/Variable.cpp Modified: lldb/trunk/include/lldb/Symbol/Declaration.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Symbol/Declaration.h?rev=113951&r1=113950&r2=113951&view=diff ============================================================================== --- lldb/trunk/include/lldb/Symbol/Declaration.h (original) +++ lldb/trunk/include/lldb/Symbol/Declaration.h Wed Sep 15 00:51:24 2010 @@ -100,7 +100,7 @@ /// The stream to which to dump the object descripton. //------------------------------------------------------------------ void - Dump (Stream *s) const; + Dump (Stream *s, bool show_fullpaths) const; void DumpStopContext (Stream *s, bool show_fullpaths) const; Modified: lldb/trunk/include/lldb/Symbol/Function.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Symbol/Function.h?rev=113951&r1=113950&r2=113951&view=diff ============================================================================== --- lldb/trunk/include/lldb/Symbol/Function.h (original) +++ lldb/trunk/include/lldb/Symbol/Function.h Wed Sep 15 00:51:24 2010 @@ -96,7 +96,7 @@ /// The stream to which to dump the object descripton. //------------------------------------------------------------------ void - Dump (Stream *s) const; + Dump (Stream *s, bool show_fullpaths) const; //------------------------------------------------------------------ /// Get accessor for the declaration information. @@ -236,7 +236,7 @@ /// The stream to which to dump the object descripton. //------------------------------------------------------------------ void - Dump(Stream *s) const; + Dump(Stream *s, bool show_fullpaths) const; void DumpStopContext (Stream *s) const; Modified: lldb/trunk/lldb.xcodeproj/project.pbxproj URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/lldb.xcodeproj/project.pbxproj?rev=113951&r1=113950&r2=113951&view=diff ============================================================================== --- lldb/trunk/lldb.xcodeproj/project.pbxproj (original) +++ lldb/trunk/lldb.xcodeproj/project.pbxproj Wed Sep 15 00:51:24 2010 @@ -2339,7 +2339,6 @@ isa = PBXProject; buildConfigurationList = 1DEB91EF08733DB70010E9CD /* Build configuration list for PBXProject "lldb" */; compatibilityVersion = "Xcode 3.1"; - developmentRegion = English; hasScannedForEncodings = 1; knownRegions = ( en, Modified: lldb/trunk/source/Commands/CommandObjectDisassemble.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectDisassemble.cpp?rev=113951&r1=113950&r2=113951&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectDisassemble.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectDisassemble.cpp Wed Sep 15 00:51:24 2010 @@ -196,7 +196,7 @@ ExecutionContext exe_ctx(interpreter.GetDebugger().GetExecutionContext()); if (m_options.show_mixed && m_options.num_lines_context == 0) - m_options.num_lines_context = 3; + m_options.num_lines_context = 1; if (!m_options.m_func_name.empty()) { Modified: lldb/trunk/source/Core/Disassembler.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/Disassembler.cpp?rev=113951&r1=113950&r2=113951&view=diff ============================================================================== --- lldb/trunk/source/Core/Disassembler.cpp (original) +++ lldb/trunk/source/Core/Disassembler.cpp Wed Sep 15 00:51:24 2010 @@ -107,7 +107,10 @@ if (module) { if (!module->FindFunctions (name, - eFunctionNameTypeBase | eFunctionNameTypeFull | eFunctionNameTypeMethod | eFunctionNameTypeSelector, + eFunctionNameTypeBase | + eFunctionNameTypeFull | + eFunctionNameTypeMethod | + eFunctionNameTypeSelector, true, sc_list)) return false; @@ -115,7 +118,10 @@ else { if (exe_ctx.target->GetImages().FindFunctions (name, - eFunctionNameTypeBase | eFunctionNameTypeFull | eFunctionNameTypeMethod | eFunctionNameTypeSelector, + eFunctionNameTypeBase | + eFunctionNameTypeFull | + eFunctionNameTypeMethod | + eFunctionNameTypeSelector, false, sc_list)) { @@ -240,7 +246,8 @@ if (offset != 0) strm.EOL(); - sc.DumpStopContext(&strm, process, addr, true, true, false); + sc.DumpStopContext(&strm, process, addr, false, true, false); + strm.EOL(); if (sc.comp_unit && sc.line_entry.IsValid()) { Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp?rev=113951&r1=113950&r2=113951&view=diff ============================================================================== --- lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp (original) +++ lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp Wed Sep 15 00:51:24 2010 @@ -1834,6 +1834,10 @@ if (!append) types.Clear(); + // Index if we already haven't to make sure the compile units + // get indexed and make their global DIE index list + if (!m_indexed) + Index (); const uint32_t initial_types_size = types.GetSize(); DWARFCompileUnit* cu = NULL; Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp?rev=113951&r1=113950&r2=113951&view=diff ============================================================================== --- lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp (original) +++ lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp Wed Sep 15 00:51:24 2010 @@ -878,14 +878,35 @@ uint32_t -SymbolFileDWARFDebugMap::FindTypes (const SymbolContext& sc, const ConstString &name, bool append, uint32_t max_matches, TypeList& types) +SymbolFileDWARFDebugMap::FindTypes +( + const SymbolContext& sc, + const ConstString &name, + bool append, + uint32_t max_matches, + TypeList& types +) { - SymbolFileDWARF *oso_dwarf = GetSymbolFile (sc); - if (oso_dwarf) - return oso_dwarf->FindTypes (sc, name, append, max_matches, types); if (!append) types.Clear(); - return 0; + + const uint32_t initial_types_size = types.GetSize(); + SymbolFileDWARF *oso_dwarf; + + if (sc.comp_unit) + { + oso_dwarf = GetSymbolFile (sc); + if (oso_dwarf) + return oso_dwarf->FindTypes (sc, name, append, max_matches, types); + } + else + { + uint32_t oso_idx = 0; + while ((oso_dwarf = GetSymbolFileByOSOIndex (oso_idx++)) != NULL) + oso_dwarf->FindTypes (sc, name, append, max_matches, types); + } + + return types.GetSize() - initial_types_size; } // Modified: lldb/trunk/source/Symbol/Block.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/Block.cpp?rev=113951&r1=113950&r2=113951&view=diff ============================================================================== --- lldb/trunk/source/Symbol/Block.cpp (original) +++ lldb/trunk/source/Symbol/Block.cpp Wed Sep 15 00:51:24 2010 @@ -57,7 +57,10 @@ } if (m_inlineInfoSP.get() != NULL) - m_inlineInfoSP->Dump(s); + { + bool show_fullpaths = (level == eDescriptionLevelVerbose); + m_inlineInfoSP->Dump(s, show_fullpaths); + } } void @@ -83,7 +86,10 @@ s->Printf(", parent = {0x%8.8x}", parent_block->GetID()); } if (m_inlineInfoSP.get() != NULL) - m_inlineInfoSP->Dump(s); + { + bool show_fullpaths = false; + m_inlineInfoSP->Dump(s, show_fullpaths); + } if (!m_ranges.empty()) { Modified: lldb/trunk/source/Symbol/Declaration.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/Declaration.cpp?rev=113951&r1=113950&r2=113951&view=diff ============================================================================== --- lldb/trunk/source/Symbol/Declaration.cpp (original) +++ lldb/trunk/source/Symbol/Declaration.cpp Wed Sep 15 00:51:24 2010 @@ -57,11 +57,15 @@ } void -Declaration::Dump(Stream *s) const +Declaration::Dump(Stream *s, bool show_fullpaths) const { if (m_file) { - *s << ", decl = " << m_file; + *s << ", decl = "; + if (show_fullpaths) + *s << m_file; + else + *s << m_file.GetFilename(); if (m_line > 0) s->Printf(":%u", m_line); if (m_column > 0) Modified: lldb/trunk/source/Symbol/Function.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/Function.cpp?rev=113951&r1=113950&r2=113951&view=diff ============================================================================== --- lldb/trunk/source/Symbol/Function.cpp (original) +++ lldb/trunk/source/Symbol/Function.cpp Wed Sep 15 00:51:24 2010 @@ -45,11 +45,11 @@ } void -FunctionInfo::Dump(Stream *s) const +FunctionInfo::Dump(Stream *s, bool show_fullpaths) const { if (m_name) *s << ", name = \"" << m_name << "\""; - m_declaration.Dump(s); + m_declaration.Dump(s, show_fullpaths); } @@ -131,9 +131,9 @@ } void -InlineFunctionInfo::Dump(Stream *s) const +InlineFunctionInfo::Dump(Stream *s, bool show_fullpaths) const { - FunctionInfo::Dump(s); + FunctionInfo::Dump(s, show_fullpaths); if (m_mangled) m_mangled.Dump(s); } Modified: lldb/trunk/source/Symbol/Type.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/Type.cpp?rev=113951&r1=113950&r2=113951&view=diff ============================================================================== --- lldb/trunk/source/Symbol/Type.cpp (original) +++ lldb/trunk/source/Symbol/Type.cpp Wed Sep 15 00:51:24 2010 @@ -87,13 +87,15 @@ { *s << "id = " << (const UserID&)*this; - if (show_name && m_name) + // Call the name accessor to make sure we resolve the type name + if (show_name && GetName()) *s << ", name = \"" << m_name << '"'; - if (m_byte_size != 0) + // Call the get byte size accesor so we resolve our byte size + if (GetByteSize()) s->Printf(", byte-size = %zu", m_byte_size); - - m_decl.Dump(s); + bool show_fullpaths = (level == lldb::eDescriptionLevelVerbose); + m_decl.Dump(s, show_fullpaths); if (m_clang_qual_type) { @@ -138,7 +140,8 @@ s->PutCString(" )"); } - m_decl.Dump(s); + bool show_fullpaths = false; + m_decl.Dump (s,show_fullpaths); if (m_clang_qual_type) { Modified: lldb/trunk/source/Symbol/Variable.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/Variable.cpp?rev=113951&r1=113950&r2=113951&view=diff ============================================================================== --- lldb/trunk/source/Symbol/Variable.cpp (original) +++ lldb/trunk/source/Symbol/Variable.cpp Wed Sep 15 00:51:24 2010 @@ -91,7 +91,8 @@ s->PutCString(" )"); } - m_declaration.Dump(s); + bool show_fullpaths = false; + m_declaration.Dump(s, show_fullpaths); if (m_location.IsValid()) { From ctice at apple.com Wed Sep 15 01:56:39 2010 From: ctice at apple.com (Caroline Tice) Date: Wed, 15 Sep 2010 06:56:39 -0000 Subject: [Lldb-commits] [lldb] r113952 - in /lldb/trunk: include/lldb/Core/UserSettingsController.h source/Commands/CommandObjectSettings.cpp source/Commands/CommandObjectSettings.h source/Core/UserSettingsController.cpp Message-ID: <20100915065639.A04992A6C12C@llvm.org> Author: ctice Date: Wed Sep 15 01:56:39 2010 New Revision: 113952 URL: http://llvm.org/viewvc/llvm-project?rev=113952&view=rev Log: Modify "settings list" so you can specify a particular instance setting name, or a settings prefix, and it will list information about the subset of settings you requested. Also added tab-completion (now that it takes an optional argument). Modified: lldb/trunk/include/lldb/Core/UserSettingsController.h lldb/trunk/source/Commands/CommandObjectSettings.cpp lldb/trunk/source/Commands/CommandObjectSettings.h lldb/trunk/source/Core/UserSettingsController.cpp Modified: lldb/trunk/include/lldb/Core/UserSettingsController.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/UserSettingsController.h?rev=113952&r1=113951&r2=113952&view=diff ============================================================================== --- lldb/trunk/include/lldb/Core/UserSettingsController.h (original) +++ lldb/trunk/include/lldb/Core/UserSettingsController.h Wed Sep 15 01:56:39 2010 @@ -139,6 +139,14 @@ Error &err); static void + FindSettingsDescriptions (CommandInterpreter &interpreter, + lldb::UserSettingsControllerSP root, + std::string ¤t_prefix, + const char *search_name, + StreamString &result_stream, + Error &err); + + static void GetAllVariableValues (CommandInterpreter &interpreter, lldb::UserSettingsControllerSP root, std::string ¤t_prefix, Modified: lldb/trunk/source/Commands/CommandObjectSettings.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectSettings.cpp?rev=113952&r1=113951&r2=113952&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectSettings.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectSettings.cpp Wed Sep 15 01:56:39 2010 @@ -367,8 +367,8 @@ CommandObjectSettingsList::CommandObjectSettingsList () : CommandObject ("settings list", - "List all the internal debugger settings variables that are available to the user to 'set' or 'show'.", - "settings list") + "List and describe all the internal debugger settings variables that are available to the user to 'set' or 'show', or describe a particular variable or set of variables (by specifying the variable name or a common prefix).", + "settings list [ | ]") { } @@ -379,16 +379,31 @@ bool CommandObjectSettingsList::Execute (CommandInterpreter &interpreter, - Args& command, - CommandReturnObject &result) + Args& command, + CommandReturnObject &result) { UserSettingsControllerSP root_settings = Debugger::GetSettingsController (); std::string current_prefix = root_settings->GetLevelName().AsCString(); Error err; - UserSettingsController::FindAllSettingsDescriptions (interpreter, root_settings, current_prefix, - result.GetOutputStream(), err); + if (command.GetArgumentCount() == 0) + { + UserSettingsController::FindAllSettingsDescriptions (interpreter, root_settings, current_prefix, + result.GetOutputStream(), err); + } + else if (command.GetArgumentCount() == 1) + { + const char *search_name = command.GetArgumentAtIndex (0); + UserSettingsController::FindSettingsDescriptions (interpreter, root_settings, current_prefix, + search_name, result.GetOutputStream(), err); + } + else + { + result.AppendError ("Too many aguments for 'settings list' command.\n"); + result.SetStatus (eReturnStatusFailed); + return false; + } if (err.Fail ()) { @@ -403,6 +418,31 @@ return result.Succeeded(); } +int +CommandObjectSettingsList::HandleArgumentCompletion (CommandInterpreter &interpreter, + Args &input, + int &cursor_index, + int &cursor_char_position, + OptionElementVector &opt_element_vector, + int match_start_point, + int max_return_elements, + bool &word_complete, + StringList &matches) +{ + std::string completion_str (input.GetArgumentAtIndex (cursor_index)); + completion_str.erase (cursor_char_position); + + CommandCompletions::InvokeCommonCompletionCallbacks (interpreter, + CommandCompletions::eSettingsNameCompletion, + completion_str.c_str(), + match_start_point, + max_return_elements, + NULL, + word_complete, + matches); + return matches.GetSize(); +} + //------------------------------------------------------------------------- // CommandObjectSettingsRemove //------------------------------------------------------------------------- Modified: lldb/trunk/source/Commands/CommandObjectSettings.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectSettings.h?rev=113952&r1=113951&r2=113952&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectSettings.h (original) +++ lldb/trunk/source/Commands/CommandObjectSettings.h Wed Sep 15 01:56:39 2010 @@ -149,6 +149,17 @@ Args& command, CommandReturnObject &result); + virtual int + HandleArgumentCompletion (CommandInterpreter &interpreter, + Args &input, + int &cursor_index, + int &cursor_char_position, + OptionElementVector &opt_element_vector, + int match_start_point, + int max_return_elements, + bool &word_complete, + StringList &matches); + private: }; Modified: lldb/trunk/source/Core/UserSettingsController.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/UserSettingsController.cpp?rev=113952&r1=113951&r2=113952&view=diff ============================================================================== --- lldb/trunk/source/Core/UserSettingsController.cpp (original) +++ lldb/trunk/source/Core/UserSettingsController.cpp Wed Sep 15 01:56:39 2010 @@ -1110,6 +1110,209 @@ } void +UserSettingsController::FindSettingsDescriptions (CommandInterpreter &interpreter, + lldb::UserSettingsControllerSP root, + std::string ¤t_prefix, + const char *search_name, + StreamString &result_stream, + Error &err) +{ + Args names = UserSettingsController::BreakNameIntoPieces (search_name); + int num_pieces = names.GetArgumentCount (); + + if (num_pieces == 0) + return; + + if (root->GetLevelName().GetLength() > 0) + { + ConstString prefix (names.GetArgumentAtIndex (0)); + if (prefix != root->GetLevelName()) + { + std::string parent_prefix; + root->BuildParentPrefix (parent_prefix); + err.SetErrorStringWithFormat ("Cannot find match for '%s.%s'\n", parent_prefix.c_str(), + prefix.AsCString()); + return; + } + else + { + names.Shift(); + --num_pieces; + } + } + + // If there's nothing left then dump all global and instance descriptions for this root. + if (num_pieces == 0) + { + StreamString prefix_line; + StreamString description; + uint32_t max_len; + int num_entries = root->m_settings.global_settings.size(); + + max_len = FindMaxNameLength (root->m_settings.global_settings); + + result_stream.Printf ("\n'%s' variables:\n\n", search_name); + + if (num_entries > 0) + { + // Write out all "global" variables. + for (int i = 0; i < num_entries; ++i) + { + SettingEntry entry = root->m_settings.global_settings[i]; + description.Clear(); + if (entry.var_type == lldb::eSetVarTypeEnum) + { + StreamString enum_values_str; + UserSettingsController::PrintEnumValues (entry.enum_values, enum_values_str); + description.Printf ("[static, enum] %s. Valid values: {%s} (default: '%s')", entry.description, + enum_values_str.GetData(), entry.enum_values[0].string_value); + } + else if (entry.default_value != NULL) + description.Printf ("[static, %s] %s (default: '%s')", GetTypeString (entry.var_type), + entry.description, entry.default_value); + else + description.Printf ("[static, %s] %s (default: '')", GetTypeString (entry.var_type), + entry.description); + interpreter.OutputFormattedHelpText (result_stream, entry.var_name, "--", description.GetData(), + max_len); + } + } + + num_entries = root->m_settings.instance_settings.size(); + max_len = FindMaxNameLength (root->m_settings.instance_settings); + + if (num_entries > 0) + { + // Write out all instance variables. + for (int i = 0; i < num_entries; ++i) + { + SettingEntry entry = root->m_settings.instance_settings[i]; + description.Clear(); + if (entry.var_type == lldb::eSetVarTypeEnum) + { + StreamString enum_values_str; + UserSettingsController::PrintEnumValues (entry.enum_values, enum_values_str); + description.Printf ("[instance, enum] %s. Valid values: {%s} (default: '%s')", entry.description, + enum_values_str.GetData(), entry.enum_values[0].string_value); + } + else if (entry.default_value != NULL) + description.Printf ("[instance, %s] %s (default: '%s')", GetTypeString (entry.var_type), + entry.description, entry.default_value); + else + description.Printf ("[instance, %s] %s (default: '')", GetTypeString (entry.var_type), + entry.description); + interpreter.OutputFormattedHelpText (result_stream, entry.var_name, "--", description.GetData(), + max_len); + } + } + } + else if (num_pieces == 1) + { + ConstString var_name (names.GetArgumentAtIndex (0)); + bool is_global = false; + + const SettingEntry *setting_entry = root->GetGlobalEntry (var_name); + + if (setting_entry == NULL) + setting_entry = root->GetInstanceEntry (var_name); + else + is_global = true; + + // Check to see if it is a global or instance variable name. + if (setting_entry != NULL) + { + StreamString description; + if (setting_entry->var_type == lldb::eSetVarTypeEnum) + { + StreamString enum_values_str; + UserSettingsController::PrintEnumValues (setting_entry->enum_values, enum_values_str); + description.Printf ("[%s, enum] %s. Valid values: {%s} (default: '%s')", + (is_global ? "static" : "instance"), + setting_entry->description, + enum_values_str.GetData(), setting_entry->enum_values[0].string_value); + } + else if (setting_entry->default_value != NULL) + description.Printf ("[%s, %s] %s (default: '%s')", + (is_global ? "static" : "instance"), + GetTypeString (setting_entry->var_type), + setting_entry->description, setting_entry->default_value); + else + description.Printf ("[%s, %s] %s (default: '')", + (is_global ? "static" : "instance"), + GetTypeString (setting_entry->var_type), + setting_entry->description); + interpreter.OutputFormattedHelpText (result_stream, setting_entry->var_name, "--", description.GetData(), + var_name.GetLength()); + } + else + { + // It must be a child name. + int num_children = root->GetNumChildren(); + bool found = false; + for (int i = 0; i < num_children && !found; ++i) + { + lldb::UserSettingsControllerSP child = root->GetChildAtIndex (i); + if (child) + { + ConstString child_prefix = child->GetLevelName(); + if (child_prefix == var_name) + { + found = true; + UserSettingsController::FindSettingsDescriptions (interpreter, child, current_prefix, + var_name.AsCString(), result_stream, err); + } + } + } + if (!found) + { + std::string parent_prefix; + root->BuildParentPrefix (parent_prefix); + err.SetErrorStringWithFormat ("Cannot find match for '%s.%s'\n", parent_prefix.c_str(), search_name); + return; + } + } + } + else + { + // It must be a child name; find the child and call this function recursively on child. + ConstString child_name (names.GetArgumentAtIndex (0)); + + StreamString rest_of_search_name; + for (int i = 0; i < num_pieces; ++i) + { + rest_of_search_name.Printf ("%s", names.GetArgumentAtIndex (i)); + if ((i + 1) < num_pieces) + rest_of_search_name.Printf ("."); + } + + int num_children = root->GetNumChildren(); + bool found = false; + for (int i = 0; i < num_children && !found; ++i) + { + lldb::UserSettingsControllerSP child = root->GetChildAtIndex (i); + if (child) + { + ConstString child_prefix = child->GetLevelName(); + if (child_prefix == child_name) + { + found = true; + UserSettingsController::FindSettingsDescriptions (interpreter, child, current_prefix, + rest_of_search_name.GetData(), result_stream, + err); + } + } + } + if (!found) + { + std::string parent_prefix; + root->BuildParentPrefix (parent_prefix); + err.SetErrorStringWithFormat ("Cannot find match for '%s.%s'\n", parent_prefix.c_str(), search_name); + return; + } + } +} + +void UserSettingsController::GetAllVariableValues (CommandInterpreter &interpreter, lldb::UserSettingsControllerSP root, std::string ¤t_prefix, From gclayton at apple.com Wed Sep 15 03:33:30 2010 From: gclayton at apple.com (Greg Clayton) Date: Wed, 15 Sep 2010 08:33:30 -0000 Subject: [Lldb-commits] [lldb] r113961 - in /lldb/trunk: include/lldb/Core/ source/Core/ source/Plugins/SymbolFile/DWARF/ Message-ID: <20100915083330.7D2762A6C12C@llvm.org> Author: gclayton Date: Wed Sep 15 03:33:30 2010 New Revision: 113961 URL: http://llvm.org/viewvc/llvm-project?rev=113961&view=rev Log: 15-20% speed improvement when parsing DWARF. I used instruments to find the hotspots in our code when indexing the DWARF. A combination of using SmallVector to avoid collection allocations, using fixed form sizes when possible, and optimizing the hot loops contributed to the speedup. Modified: lldb/trunk/include/lldb/Core/DataExtractor.h lldb/trunk/source/Core/DataExtractor.cpp lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFAbbreviationDeclaration.h lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.h lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugPubnames.cpp lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFFormValue.cpp lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFFormValue.h lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp Modified: lldb/trunk/include/lldb/Core/DataExtractor.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/DataExtractor.h?rev=113961&r1=113960&r2=113961&view=diff ============================================================================== --- lldb/trunk/include/lldb/Core/DataExtractor.h (original) +++ lldb/trunk/include/lldb/Core/DataExtractor.h Wed Sep 15 03:33:30 2010 @@ -719,6 +719,22 @@ uint8_t GetU8 ( uint32_t *offset_ptr) const; + uint8_t + GetU8_unchecked ( uint32_t *offset_ptr) const + { + uint8_t val = m_start[*offset_ptr]; + *offset_ptr += sizeof(val); + return val; + } + + uint16_t + GetU16_unchecked (uint32_t *offset_ptr) const; + + uint32_t + GetU32_unchecked (uint32_t *offset_ptr) const; + + uint64_t + GetU64_unchecked (uint32_t *offset_ptr) const; //------------------------------------------------------------------ /// Extract \a count uint8_t values from \a *offset_ptr. /// Modified: lldb/trunk/source/Core/DataExtractor.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/DataExtractor.cpp?rev=113961&r1=113960&r2=113961&view=diff ============================================================================== --- lldb/trunk/source/Core/DataExtractor.cpp (original) +++ lldb/trunk/source/Core/DataExtractor.cpp Wed Sep 15 03:33:30 2010 @@ -471,6 +471,37 @@ return val; } +uint16_t +DataExtractor::GetU16_unchecked (uint32_t *offset_ptr) const +{ + uint16_t val = (m_byte_order == eByteOrderHost) ? + ReadInt16 (m_start, *offset_ptr) : + ReadSwapInt16(m_start, *offset_ptr); + *offset_ptr += sizeof(val); + return val; +} + +uint32_t +DataExtractor::GetU32_unchecked (uint32_t *offset_ptr) const +{ + uint32_t val = (m_byte_order == eByteOrderHost) ? + ReadInt32 (m_start, *offset_ptr) : + ReadSwapInt32 (m_start, *offset_ptr); + *offset_ptr += sizeof(val); + return val; +} + +uint64_t +DataExtractor::GetU64_unchecked (uint32_t *offset_ptr) const +{ + uint64_t val = (m_byte_order == eByteOrderHost) ? + ReadInt64 (m_start, *offset_ptr) : + ReadSwapInt64 (m_start, *offset_ptr); + *offset_ptr += sizeof(val); + return val; +} + + //---------------------------------------------------------------------- // Extract "count" uint16_t values from the binary data and update // the offset pointed to by "offset_ptr". The extracted data is Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFAbbreviationDeclaration.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFAbbreviationDeclaration.h?rev=113961&r1=113960&r2=113961&view=diff ============================================================================== --- lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFAbbreviationDeclaration.h (original) +++ lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFAbbreviationDeclaration.h Wed Sep 15 03:33:30 2010 @@ -51,6 +51,10 @@ { m_attributes[idx].get(attr, form); } + dw_form_t GetFormByIndexUnchecked (uint32_t idx) const + { + return m_attributes[idx].get_form(); + } void CopyExcludingAddressAttributes(const DWARFAbbreviationDeclaration& abbr_decl, const uint32_t idx); void CopyChangingStringToStrp( const DWARFAbbreviationDeclaration& abbr_decl, Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp?rev=113961&r1=113960&r2=113961&view=diff ============================================================================== --- lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp (original) +++ lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp Wed Sep 15 03:33:30 2010 @@ -157,7 +157,7 @@ uint32_t offset = GetFirstDIEOffset(); DWARFDebugInfoEntry die; // Keep a flat array of the DIE for binary lookup by DIE offset - Log *log = LogChannelDWARF::GetLogIfAll(DWARF_LOG_DEBUG_INFO); +// Log *log = LogChannelDWARF::GetLogIfAll(DWARF_LOG_DEBUG_INFO); // if (log) // log->Printf("0x%8.8x: Compile Unit: length = 0x%8.8x, version = 0x%4.4x, abbr_offset = 0x%8.8x, addr_size = 0x%2.2x", // cu->GetOffset(), @@ -169,17 +169,29 @@ uint32_t depth = 0; // We are in our compile unit, parse starting at the offset // we were told to parse - while (die.Extract(m_dwarf2Data, this, &offset)) + const DataExtractor& debug_info_data = m_dwarf2Data->get_debug_info_data(); + + const uint8_t *fixed_form_sizes = DWARFFormValue::GetFixedFormSizesForAddressSize (GetAddressByteSize()); + while (die.FastExtract (debug_info_data, this, fixed_form_sizes, &offset)) { - if (log) - log->Printf("0x%8.8x: %*.*s%s%s", - die.GetOffset(), - depth * 2, depth * 2, "", - DW_TAG_value_to_name (die.Tag()), - die.HasChildren() ? " *" : ""); +// if (log) +// log->Printf("0x%8.8x: %*.*s%s%s", +// die.GetOffset(), +// depth * 2, depth * 2, "", +// DW_TAG_value_to_name (die.Tag()), +// die.HasChildren() ? " *" : ""); + + if (depth == 0) + { + uint64_t base_addr = die.GetAttributeValueAsUnsigned(m_dwarf2Data, this, DW_AT_low_pc, LLDB_INVALID_ADDRESS); + if (base_addr == LLDB_INVALID_ADDRESS) + base_addr = die.GetAttributeValueAsUnsigned(m_dwarf2Data, this, DW_AT_entry_pc, 0); + SetBaseAddress (base_addr); + } + if (cu_die_only) { - AddDIE(die); + AddDIE (die); return 1; } else if (depth == 0 && initial_die_array_size == 1) @@ -188,7 +200,7 @@ } else { - AddDIE(die); + AddDIE (die); } const DWARFAbbreviationDeclaration* abbrDecl = die.GetAbbreviationDeclarationPtr(); @@ -203,7 +215,7 @@ // NULL DIE. if (depth > 0) --depth; - else + if (depth == 0) break; // We are done with this compile unit! } @@ -564,6 +576,8 @@ { const DataExtractor* debug_str = &m_dwarf2Data->get_debug_str_data(); + const uint8_t *fixed_form_sizes = DWARFFormValue::GetFixedFormSizesForAddressSize (GetAddressByteSize()); + NameToDIE::Info die_info = { cu_idx, 0 }; DWARFDebugInfoEntry::const_iterator pos; DWARFDebugInfoEntry::const_iterator begin = m_die_array.begin(); @@ -609,7 +623,7 @@ DWARFDebugRanges::RangeList ranges; dw_offset_t specification_die_offset = DW_INVALID_OFFSET; - const size_t num_attributes = die.GetAttributes(m_dwarf2Data, this, attributes); + const size_t num_attributes = die.GetAttributes(m_dwarf2Data, this, fixed_form_sizes, attributes); if (num_attributes > 0) { uint32_t i; Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp?rev=113961&r1=113960&r2=113961&view=diff ============================================================================== --- lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp (original) +++ lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp Wed Sep 15 03:33:30 2010 @@ -37,7 +37,6 @@ DWARFDebugInfoEntry::Attributes::Attributes() : m_infos() { - m_infos.reserve(20); } DWARFDebugInfoEntry::Attributes::~Attributes() @@ -48,9 +47,9 @@ uint32_t DWARFDebugInfoEntry::Attributes::FindAttributeIndex(dw_attr_t attr) const { - std::vector::const_iterator end = m_infos.end(); - std::vector::const_iterator beg = m_infos.begin(); - std::vector::const_iterator pos; + collection::const_iterator end = m_infos.end(); + collection::const_iterator beg = m_infos.begin(); + collection::const_iterator pos; for (pos = beg; pos != end; ++pos) { if (pos->attr == attr) @@ -102,6 +101,124 @@ } + +bool +DWARFDebugInfoEntry::FastExtract +( + const DataExtractor& debug_info_data, + const DWARFCompileUnit* cu, + const uint8_t *fixed_form_sizes, + uint32_t* offset_ptr +) +{ + m_offset = *offset_ptr; + + dw_uleb128_t abbrCode = debug_info_data.GetULEB128 (offset_ptr); + + assert (fixed_form_sizes); // For best performance this should be specified! + + if (abbrCode) + { + register uint32_t offset = *offset_ptr; + + m_abbrevDecl = cu->GetAbbreviations()->GetAbbreviationDeclaration(abbrCode); + + // Skip all data in the .debug_info for the attributes + const uint32_t numAttributes = m_abbrevDecl->NumAttributes(); + register uint32_t i; + register dw_form_t form; + for (i=0; iGetFormByIndexUnchecked(i); + + const uint8_t fixed_skip_size = fixed_form_sizes [form]; + if (fixed_skip_size) + offset += fixed_skip_size; + else + { + bool form_is_indirect = false; + do + { + register uint32_t form_size = 0; + switch (form) + { + // Blocks if inlined data that have a length field and the data bytes + // inlined in the .debug_info + case DW_FORM_block : form_size = debug_info_data.GetULEB128 (&offset); break; + case DW_FORM_block1 : form_size = debug_info_data.GetU8_unchecked (&offset); break; + case DW_FORM_block2 : form_size = debug_info_data.GetU16_unchecked (&offset);break; + case DW_FORM_block4 : form_size = debug_info_data.GetU32_unchecked (&offset);break; + + // Inlined NULL terminated C-strings + case DW_FORM_string : + debug_info_data.GetCStr (&offset); + break; + + // Compile unit address sized values + case DW_FORM_addr : + case DW_FORM_ref_addr : + form_size = cu->GetAddressByteSize(); + break; + + // 1 byte values + case DW_FORM_data1 : + case DW_FORM_flag : + case DW_FORM_ref1 : + form_size = 1; + break; + + // 2 byte values + case DW_FORM_data2 : + case DW_FORM_ref2 : + form_size = 2; + break; + + // 4 byte values + case DW_FORM_strp : + case DW_FORM_data4 : + case DW_FORM_ref4 : + form_size = 4; + break; + + // 8 byte values + case DW_FORM_data8 : + case DW_FORM_ref8 : + form_size = 8; + break; + + // signed or unsigned LEB 128 values + case DW_FORM_sdata : + case DW_FORM_udata : + case DW_FORM_ref_udata : + debug_info_data.Skip_LEB128 (&offset); + break; + + case DW_FORM_indirect : + form_is_indirect = true; + form = debug_info_data.GetULEB128 (&offset); + break; + + default: + *offset_ptr = m_offset; + return false; + } + offset += form_size; + + } while (form_is_indirect); + } + } + *offset_ptr = offset; + return true; + } + else + { + m_abbrevDecl = NULL; + return true; // NULL debug tag entry + } + + return false; +} + //---------------------------------------------------------------------- // Extract // @@ -502,254 +619,254 @@ // DWARFDebugInfoEntry::CompareState compare_state; // int result = DWARFDebugInfoEntry::Compare(this, 0x00017ccb, 0x0001eb2b, compare_state, false, true); //---------------------------------------------------------------------- -int -DWARFDebugInfoEntry::Compare -( - SymbolFileDWARF* dwarf2Data, - dw_offset_t a_die_offset, - dw_offset_t b_die_offset, - CompareState &compare_state, - bool compare_siblings, - bool compare_children -) -{ - if (a_die_offset == b_die_offset) - return 0; - - DWARFCompileUnitSP a_cu_sp; - DWARFCompileUnitSP b_cu_sp; - const DWARFDebugInfoEntry* a_die = dwarf2Data->DebugInfo()->GetDIEPtr(a_die_offset, &a_cu_sp); - const DWARFDebugInfoEntry* b_die = dwarf2Data->DebugInfo()->GetDIEPtr(b_die_offset, &b_cu_sp); - - return Compare(dwarf2Data, a_cu_sp.get(), a_die, b_cu_sp.get(), b_die, compare_state, compare_siblings, compare_children); -} - -int -DWARFDebugInfoEntry::Compare -( - SymbolFileDWARF* dwarf2Data, - DWARFCompileUnit* a_cu, const DWARFDebugInfoEntry* a_die, - DWARFCompileUnit* b_cu, const DWARFDebugInfoEntry* b_die, - CompareState &compare_state, - bool compare_siblings, - bool compare_children -) -{ - if (a_die == b_die) - return 0; - - if (!compare_state.AddTypePair(a_die->GetOffset(), b_die->GetOffset())) - { - // We are already comparing both of these types, so let - // compares complete for the real result - return 0; - } - - //printf("DWARFDebugInfoEntry::Compare(0x%8.8x, 0x%8.8x)\n", a_die->GetOffset(), b_die->GetOffset()); - - // Do we have two valid DIEs? - if (a_die && b_die) - { - // Both DIE are valid - int result = 0; - - const dw_tag_t a_tag = a_die->Tag(); - const dw_tag_t b_tag = b_die->Tag(); - if (a_tag == 0 && b_tag == 0) - return 0; - - //printf(" comparing tags: %s and %s\n", DW_TAG_value_to_name(a_tag), DW_TAG_value_to_name(b_tag)); - - if (a_tag < b_tag) - return -1; - else if (a_tag > b_tag) - return 1; - - DWARFDebugInfoEntry::Attributes a_attrs; - DWARFDebugInfoEntry::Attributes b_attrs; - size_t a_attr_count = a_die->GetAttributes(dwarf2Data, a_cu, a_attrs); - size_t b_attr_count = b_die->GetAttributes(dwarf2Data, b_cu, b_attrs); - if (a_attr_count != b_attr_count) - { - a_attrs.RemoveAttribute(DW_AT_sibling); - b_attrs.RemoveAttribute(DW_AT_sibling); - } - - a_attr_count = a_attrs.Size(); - b_attr_count = b_attrs.Size(); - - DWARFFormValue a_form_value; - DWARFFormValue b_form_value; - - if (a_attr_count != b_attr_count) - { - uint32_t is_decl_index = a_attrs.FindAttributeIndex(DW_AT_declaration); - uint32_t a_name_index = UINT32_MAX; - uint32_t b_name_index = UINT32_MAX; - if (is_decl_index != UINT32_MAX) - { - if (a_attr_count == 2) - { - a_name_index = a_attrs.FindAttributeIndex(DW_AT_name); - b_name_index = b_attrs.FindAttributeIndex(DW_AT_name); - } - } - else - { - is_decl_index = b_attrs.FindAttributeIndex(DW_AT_declaration); - if (is_decl_index != UINT32_MAX && a_attr_count == 2) - { - a_name_index = a_attrs.FindAttributeIndex(DW_AT_name); - b_name_index = b_attrs.FindAttributeIndex(DW_AT_name); - } - } - if (a_name_index != UINT32_MAX && b_name_index != UINT32_MAX) - { - if (a_attrs.ExtractFormValueAtIndex(dwarf2Data, a_name_index, a_form_value) && - b_attrs.ExtractFormValueAtIndex(dwarf2Data, b_name_index, b_form_value)) - { - result = DWARFFormValue::Compare (a_form_value, b_form_value, a_cu, b_cu, &dwarf2Data->get_debug_str_data()); - if (result == 0) - { - a_attr_count = b_attr_count = 0; - compare_children = false; - } - } - } - } - - if (a_attr_count < b_attr_count) - return -1; - if (a_attr_count > b_attr_count) - return 1; - - - // The number of attributes are the same... - if (a_attr_count > 0) - { - const DataExtractor* debug_str_data_ptr = &dwarf2Data->get_debug_str_data(); - - uint32_t i; - for (i=0; i b_attr) - return 1; - - switch (a_attr) - { - // Since we call a form of GetAttributes which inlines the - // attributes from DW_AT_abstract_origin and DW_AT_specification - // we don't care if their values mismatch... - case DW_AT_abstract_origin: - case DW_AT_specification: - case DW_AT_sibling: - case DW_AT_containing_type: - //printf(" action = IGNORE\n"); - result = 0; - break; // ignore - - default: - if (a_attrs.ExtractFormValueAtIndex(dwarf2Data, i, a_form_value) && - b_attrs.ExtractFormValueAtIndex(dwarf2Data, i, b_form_value)) - result = DWARFFormValue::Compare (a_form_value, b_form_value, a_cu, b_cu, debug_str_data_ptr); - break; - } - - //printf("\t result = %i\n", result); - - if (result != 0) - { - // Attributes weren't equal, lets see if we care? - switch (a_attr) - { - case DW_AT_decl_file: - // TODO: add the ability to compare files in two different compile units - if (a_cu == b_cu) - { - //printf(" action = RETURN RESULT\n"); - return result; // Only return the compare results when the compile units are the same and the decl_file attributes can be compared - } - else - { - result = 0; - //printf(" action = IGNORE\n"); - } - break; - - default: - switch (a_attrs.FormAtIndex(i)) - { - case DW_FORM_ref1: - case DW_FORM_ref2: - case DW_FORM_ref4: - case DW_FORM_ref8: - case DW_FORM_ref_udata: - case DW_FORM_ref_addr: - //printf(" action = COMPARE DIEs 0x%8.8x 0x%8.8x\n", (dw_offset_t)a_form_value.Reference(a_cu), (dw_offset_t)b_form_value.Reference(b_cu)); - // These attribute values refer to other DIEs, so lets compare those instead of their DIE offsets... - result = Compare(dwarf2Data, a_form_value.Reference(a_cu), b_form_value.Reference(b_cu), compare_state, false, true); - if (result != 0) - return result; - break; - - default: - // We do care that they were different, return this result... - //printf(" action = RETURN RESULT\n"); - return result; - } - } - } - } - } - //printf(" SUCCESS\n\t\t0x%8.8x: %s\n\t\t0x%8.8x: %s\n", a_die->GetOffset(), DW_TAG_value_to_name(a_tag), b_die->GetOffset(), DW_TAG_value_to_name(b_tag)); - - if (compare_children) - { - bool a_has_children = a_die->HasChildren(); - bool b_has_children = b_die->HasChildren(); - if (a_has_children == b_has_children) - { - // Both either have kids or don't - if (a_has_children) - result = Compare( dwarf2Data, - a_cu, a_die->GetFirstChild(), - b_cu, b_die->GetFirstChild(), - compare_state, true, compare_children); - else - result = 0; - } - else if (!a_has_children) - result = -1; // A doesn't have kids, but B does - else - result = 1; // A has kids, but B doesn't - } - - if (compare_siblings) - { - result = Compare( dwarf2Data, - a_cu, a_die->GetSibling(), - b_cu, b_die->GetSibling(), - compare_state, true, compare_children); - } - - return result; - } - - if (a_die == NULL) - return -1; // a_die is NULL, yet b_die is non-NULL - else - return 1; // a_die is non-NULL, yet b_die is NULL - -} - +//int +//DWARFDebugInfoEntry::Compare +//( +// SymbolFileDWARF* dwarf2Data, +// dw_offset_t a_die_offset, +// dw_offset_t b_die_offset, +// CompareState &compare_state, +// bool compare_siblings, +// bool compare_children +//) +//{ +// if (a_die_offset == b_die_offset) +// return 0; +// +// DWARFCompileUnitSP a_cu_sp; +// DWARFCompileUnitSP b_cu_sp; +// const DWARFDebugInfoEntry* a_die = dwarf2Data->DebugInfo()->GetDIEPtr(a_die_offset, &a_cu_sp); +// const DWARFDebugInfoEntry* b_die = dwarf2Data->DebugInfo()->GetDIEPtr(b_die_offset, &b_cu_sp); +// +// return Compare(dwarf2Data, a_cu_sp.get(), a_die, b_cu_sp.get(), b_die, compare_state, compare_siblings, compare_children); +//} +// +//int +//DWARFDebugInfoEntry::Compare +//( +// SymbolFileDWARF* dwarf2Data, +// DWARFCompileUnit* a_cu, const DWARFDebugInfoEntry* a_die, +// DWARFCompileUnit* b_cu, const DWARFDebugInfoEntry* b_die, +// CompareState &compare_state, +// bool compare_siblings, +// bool compare_children +//) +//{ +// if (a_die == b_die) +// return 0; +// +// if (!compare_state.AddTypePair(a_die->GetOffset(), b_die->GetOffset())) +// { +// // We are already comparing both of these types, so let +// // compares complete for the real result +// return 0; +// } +// +// //printf("DWARFDebugInfoEntry::Compare(0x%8.8x, 0x%8.8x)\n", a_die->GetOffset(), b_die->GetOffset()); +// +// // Do we have two valid DIEs? +// if (a_die && b_die) +// { +// // Both DIE are valid +// int result = 0; +// +// const dw_tag_t a_tag = a_die->Tag(); +// const dw_tag_t b_tag = b_die->Tag(); +// if (a_tag == 0 && b_tag == 0) +// return 0; +// +// //printf(" comparing tags: %s and %s\n", DW_TAG_value_to_name(a_tag), DW_TAG_value_to_name(b_tag)); +// +// if (a_tag < b_tag) +// return -1; +// else if (a_tag > b_tag) +// return 1; +// +// DWARFDebugInfoEntry::Attributes a_attrs; +// DWARFDebugInfoEntry::Attributes b_attrs; +// size_t a_attr_count = a_die->GetAttributes(dwarf2Data, a_cu, a_attrs); +// size_t b_attr_count = b_die->GetAttributes(dwarf2Data, b_cu, b_attrs); +// if (a_attr_count != b_attr_count) +// { +// a_attrs.RemoveAttribute(DW_AT_sibling); +// b_attrs.RemoveAttribute(DW_AT_sibling); +// } +// +// a_attr_count = a_attrs.Size(); +// b_attr_count = b_attrs.Size(); +// +// DWARFFormValue a_form_value; +// DWARFFormValue b_form_value; +// +// if (a_attr_count != b_attr_count) +// { +// uint32_t is_decl_index = a_attrs.FindAttributeIndex(DW_AT_declaration); +// uint32_t a_name_index = UINT32_MAX; +// uint32_t b_name_index = UINT32_MAX; +// if (is_decl_index != UINT32_MAX) +// { +// if (a_attr_count == 2) +// { +// a_name_index = a_attrs.FindAttributeIndex(DW_AT_name); +// b_name_index = b_attrs.FindAttributeIndex(DW_AT_name); +// } +// } +// else +// { +// is_decl_index = b_attrs.FindAttributeIndex(DW_AT_declaration); +// if (is_decl_index != UINT32_MAX && a_attr_count == 2) +// { +// a_name_index = a_attrs.FindAttributeIndex(DW_AT_name); +// b_name_index = b_attrs.FindAttributeIndex(DW_AT_name); +// } +// } +// if (a_name_index != UINT32_MAX && b_name_index != UINT32_MAX) +// { +// if (a_attrs.ExtractFormValueAtIndex(dwarf2Data, a_name_index, a_form_value) && +// b_attrs.ExtractFormValueAtIndex(dwarf2Data, b_name_index, b_form_value)) +// { +// result = DWARFFormValue::Compare (a_form_value, b_form_value, a_cu, b_cu, &dwarf2Data->get_debug_str_data()); +// if (result == 0) +// { +// a_attr_count = b_attr_count = 0; +// compare_children = false; +// } +// } +// } +// } +// +// if (a_attr_count < b_attr_count) +// return -1; +// if (a_attr_count > b_attr_count) +// return 1; +// +// +// // The number of attributes are the same... +// if (a_attr_count > 0) +// { +// const DataExtractor* debug_str_data_ptr = &dwarf2Data->get_debug_str_data(); +// +// uint32_t i; +// for (i=0; i b_attr) +// return 1; +// +// switch (a_attr) +// { +// // Since we call a form of GetAttributes which inlines the +// // attributes from DW_AT_abstract_origin and DW_AT_specification +// // we don't care if their values mismatch... +// case DW_AT_abstract_origin: +// case DW_AT_specification: +// case DW_AT_sibling: +// case DW_AT_containing_type: +// //printf(" action = IGNORE\n"); +// result = 0; +// break; // ignore +// +// default: +// if (a_attrs.ExtractFormValueAtIndex(dwarf2Data, i, a_form_value) && +// b_attrs.ExtractFormValueAtIndex(dwarf2Data, i, b_form_value)) +// result = DWARFFormValue::Compare (a_form_value, b_form_value, a_cu, b_cu, debug_str_data_ptr); +// break; +// } +// +// //printf("\t result = %i\n", result); +// +// if (result != 0) +// { +// // Attributes weren't equal, lets see if we care? +// switch (a_attr) +// { +// case DW_AT_decl_file: +// // TODO: add the ability to compare files in two different compile units +// if (a_cu == b_cu) +// { +// //printf(" action = RETURN RESULT\n"); +// return result; // Only return the compare results when the compile units are the same and the decl_file attributes can be compared +// } +// else +// { +// result = 0; +// //printf(" action = IGNORE\n"); +// } +// break; +// +// default: +// switch (a_attrs.FormAtIndex(i)) +// { +// case DW_FORM_ref1: +// case DW_FORM_ref2: +// case DW_FORM_ref4: +// case DW_FORM_ref8: +// case DW_FORM_ref_udata: +// case DW_FORM_ref_addr: +// //printf(" action = COMPARE DIEs 0x%8.8x 0x%8.8x\n", (dw_offset_t)a_form_value.Reference(a_cu), (dw_offset_t)b_form_value.Reference(b_cu)); +// // These attribute values refer to other DIEs, so lets compare those instead of their DIE offsets... +// result = Compare(dwarf2Data, a_form_value.Reference(a_cu), b_form_value.Reference(b_cu), compare_state, false, true); +// if (result != 0) +// return result; +// break; +// +// default: +// // We do care that they were different, return this result... +// //printf(" action = RETURN RESULT\n"); +// return result; +// } +// } +// } +// } +// } +// //printf(" SUCCESS\n\t\t0x%8.8x: %s\n\t\t0x%8.8x: %s\n", a_die->GetOffset(), DW_TAG_value_to_name(a_tag), b_die->GetOffset(), DW_TAG_value_to_name(b_tag)); +// +// if (compare_children) +// { +// bool a_has_children = a_die->HasChildren(); +// bool b_has_children = b_die->HasChildren(); +// if (a_has_children == b_has_children) +// { +// // Both either have kids or don't +// if (a_has_children) +// result = Compare( dwarf2Data, +// a_cu, a_die->GetFirstChild(), +// b_cu, b_die->GetFirstChild(), +// compare_state, true, compare_children); +// else +// result = 0; +// } +// else if (!a_has_children) +// result = -1; // A doesn't have kids, but B does +// else +// result = 1; // A has kids, but B doesn't +// } +// +// if (compare_siblings) +// { +// result = Compare( dwarf2Data, +// a_cu, a_die->GetSibling(), +// b_cu, b_die->GetSibling(), +// compare_state, true, compare_children); +// } +// +// return result; +// } +// +// if (a_die == NULL) +// return -1; // a_die is NULL, yet b_die is non-NULL +// else +// return 1; // a_die is non-NULL, yet b_die is NULL +// +//} +// // //int //DWARFDebugInfoEntry::Compare @@ -1208,11 +1325,14 @@ ( SymbolFileDWARF* dwarf2Data, const DWARFCompileUnit* cu, + const uint8_t *fixed_form_sizes, DWARFDebugInfoEntry::Attributes& attributes ) const { if (m_abbrevDecl) { + if (fixed_form_sizes == NULL) + fixed_form_sizes = DWARFFormValue::GetFixedFormSizesForAddressSize(cu->GetAddressByteSize()); uint32_t offset = GetOffset(); const DataExtractor& debug_info_data = dwarf2Data->get_debug_info_data(); @@ -1239,20 +1359,24 @@ { die = const_cast(cu)->GetDIEPtr(die_offset); if (die) - die->GetAttributes(dwarf2Data, cu, attributes); + die->GetAttributes(dwarf2Data, cu, fixed_form_sizes, attributes); } else { DWARFCompileUnitSP cu_sp_ptr; die = const_cast(dwarf2Data)->DebugInfo()->GetDIEPtr(die_offset, &cu_sp_ptr); if (die) - die->GetAttributes(dwarf2Data, cu_sp_ptr.get(), attributes); + die->GetAttributes(dwarf2Data, cu_sp_ptr.get(), fixed_form_sizes, attributes); } } } else { - assert(DWARFFormValue::SkipValue(form, debug_info_data, &offset, cu)); + const uint8_t fixed_skip_size = fixed_form_sizes [form]; + if (fixed_skip_size) + offset += fixed_skip_size; + else + DWARFFormValue::SkipValue(form, debug_info_data, &offset, cu); } } } Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.h?rev=113961&r1=113960&r2=113961&view=diff ============================================================================== --- lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.h (original) +++ lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.h Wed Sep 15 03:33:30 2010 @@ -11,6 +11,9 @@ #define liblldb_DWARFDebugInfoEntry_h_ #include "SymbolFileDWARF.h" + +#include "llvm/ADT/SmallVector.h" + #include "DWARFAbbreviationDeclaration.h" #include "DWARFDebugRanges.h" #include @@ -76,7 +79,9 @@ dw_attr_t attr; dw_form_t form; }; - std::vector m_infos; + + typedef llvm::SmallVector collection; + collection m_infos; }; struct CompareState @@ -116,6 +121,12 @@ const DWARFCompileUnit* cu, DWARFDebugAranges* debug_aranges) const; + bool FastExtract( + const lldb_private::DataExtractor& debug_info_data, + const DWARFCompileUnit* cu, + const uint8_t *fixed_form_sizes, + dw_offset_t* offset_ptr); + bool Extract( SymbolFileDWARF* dwarf2Data, const DWARFCompileUnit* cu, @@ -131,6 +142,7 @@ size_t GetAttributes( SymbolFileDWARF* dwarf2Data, const DWARFCompileUnit* cu, + const uint8_t *fixed_form_sizes, DWARFDebugInfoEntry::Attributes& attrs) const; dw_offset_t GetAttributeValue( @@ -196,21 +208,21 @@ const dw_offset_t die_offset, lldb_private::Stream *s); - static int Compare( - SymbolFileDWARF* dwarf2Data, - dw_offset_t a_die_offset, - dw_offset_t b_die_offset, - CompareState &compare_state, - bool compare_siblings, - bool compare_children); - - static int Compare( - SymbolFileDWARF* dwarf2Data, - DWARFCompileUnit* a_cu, const DWARFDebugInfoEntry* a_die, - DWARFCompileUnit* b_cu, const DWARFDebugInfoEntry* b_die, - CompareState &compare_state, - bool compare_siblings, - bool compare_children); +// static int Compare( +// SymbolFileDWARF* dwarf2Data, +// dw_offset_t a_die_offset, +// dw_offset_t b_die_offset, +// CompareState &compare_state, +// bool compare_siblings, +// bool compare_children); +// +// static int Compare( +// SymbolFileDWARF* dwarf2Data, +// DWARFCompileUnit* a_cu, const DWARFDebugInfoEntry* a_die, +// DWARFCompileUnit* b_cu, const DWARFDebugInfoEntry* b_die, +// CompareState &compare_state, +// bool compare_siblings, +// bool compare_children); static bool OffsetLessThan ( const DWARFDebugInfoEntry& a, Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugPubnames.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugPubnames.cpp?rev=113961&r1=113960&r2=113961&view=diff ============================================================================== --- lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugPubnames.cpp (original) +++ lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugPubnames.cpp Wed Sep 15 03:33:30 2010 @@ -85,6 +85,8 @@ DWARFCompileUnit* cu = debug_info->GetCompileUnitAtIndex(cu_idx); + const uint8_t *fixed_form_sizes = DWARFFormValue::GetFixedFormSizesForAddressSize (cu->GetAddressByteSize()); + bool clear_dies = cu->ExtractDIEsIfNeeded (false) > 1; DWARFDIECollection dies; @@ -103,7 +105,7 @@ const char *mangled = NULL; bool add_die = false; bool is_variable = false; - const size_t num_attributes = die->GetAttributes(dwarf2Data, cu, attributes); + const size_t num_attributes = die->GetAttributes(dwarf2Data, cu, fixed_form_sizes, attributes); if (num_attributes > 0) { uint32_t i; Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFFormValue.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFFormValue.cpp?rev=113961&r1=113960&r2=113961&view=diff ============================================================================== --- lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFFormValue.cpp (original) +++ lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFFormValue.cpp Wed Sep 15 03:33:30 2010 @@ -19,6 +19,73 @@ using namespace lldb_private; + +static uint8_t g_form_sizes_addr4[] = +{ + 0, // 0x00 unused + 4, // 0x01 DW_FORM_addr + 0, // 0x02 unused + 0, // 0x03 DW_FORM_block2 + 0, // 0x04 DW_FORM_block4 + 2, // 0x05 DW_FORM_data2 + 4, // 0x06 DW_FORM_data4 + 8, // 0x07 DW_FORM_data8 + 0, // 0x08 DW_FORM_string + 0, // 0x09 DW_FORM_block + 0, // 0x0a DW_FORM_block1 + 1, // 0x0b DW_FORM_data1 + 1, // 0x0c DW_FORM_flag + 0, // 0x0d DW_FORM_sdata + 4, // 0x0e DW_FORM_strp + 0, // 0x0f DW_FORM_udata + 4, // 0x10 DW_FORM_ref_addr + 1, // 0x11 DW_FORM_ref1 + 2, // 0x12 DW_FORM_ref2 + 4, // 0x13 DW_FORM_ref4 + 8, // 0x14 DW_FORM_ref8 + 0, // 0x15 DW_FORM_ref_udata + 0, // 0x16 DW_FORM_indirect +}; + +static uint8_t +g_form_sizes_addr8[] = +{ + 0, // 0x00 unused + 8, // 0x01 DW_FORM_addr + 0, // 0x02 unused + 0, // 0x03 DW_FORM_block2 + 0, // 0x04 DW_FORM_block4 + 2, // 0x05 DW_FORM_data2 + 4, // 0x06 DW_FORM_data4 + 8, // 0x07 DW_FORM_data8 + 0, // 0x08 DW_FORM_string + 0, // 0x09 DW_FORM_block + 0, // 0x0a DW_FORM_block1 + 1, // 0x0b DW_FORM_data1 + 1, // 0x0c DW_FORM_flag + 0, // 0x0d DW_FORM_sdata + 4, // 0x0e DW_FORM_strp + 0, // 0x0f DW_FORM_udata + 8, // 0x10 DW_FORM_ref_addr + 1, // 0x11 DW_FORM_ref1 + 2, // 0x12 DW_FORM_ref2 + 4, // 0x13 DW_FORM_ref4 + 8, // 0x14 DW_FORM_ref8 + 0, // 0x15 DW_FORM_ref_udata + 0, // 0x16 DW_FORM_indirect +}; + +const uint8_t * +DWARFFormValue::GetFixedFormSizesForAddressSize (uint8_t addr_size) +{ + switch (addr_size) + { + case 4: return g_form_sizes_addr4; + case 8: return g_form_sizes_addr8; + } + return NULL; +} + DWARFFormValue::DWARFFormValue(dw_form_t form) : m_form(form), m_value() Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFFormValue.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFFormValue.h?rev=113961&r1=113960&r2=113961&view=diff ============================================================================== --- lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFFormValue.h (original) +++ lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFFormValue.h Wed Sep 15 03:33:30 2010 @@ -70,7 +70,7 @@ // static bool PutUnsigned(dw_form_t form, dw_offset_t offset, uint64_t value, BinaryStreamBuf& out_buff, const DWARFCompileUnit* cu, bool fixup_cu_relative_refs); static bool IsBlockForm(const dw_form_t form); static bool IsDataForm(const dw_form_t form); - + static const uint8_t * GetFixedFormSizesForAddressSize (uint8_t addr_size); static int Compare (const DWARFFormValue& a, const DWARFFormValue& b, const DWARFCompileUnit* a_cu, const DWARFCompileUnit* b_cu, const lldb_private::DataExtractor* debug_str_data_ptr); protected: dw_form_t m_form; // Form for this value Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp?rev=113961&r1=113960&r2=113961&view=diff ============================================================================== --- lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp (original) +++ lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp Wed Sep 15 03:33:30 2010 @@ -1024,6 +1024,8 @@ size_t count = 0; const DWARFDebugInfoEntry *die; + const uint8_t *fixed_form_sizes = DWARFFormValue::GetFixedFormSizesForAddressSize (dwarf_cu->GetAddressByteSize()); + for (die = parent_die->GetFirstChild(); die != NULL; die = die->GetSibling()) { dw_tag_t tag = die->Tag(); @@ -1033,7 +1035,7 @@ case DW_TAG_member: { DWARFDebugInfoEntry::Attributes attributes; - const size_t num_attributes = die->GetAttributes(this, dwarf_cu, attributes); + const size_t num_attributes = die->GetAttributes(this, dwarf_cu, fixed_form_sizes, attributes); if (num_attributes > 0) { Declaration decl; @@ -1124,7 +1126,7 @@ default_accessibility = eAccessPrivate; // TODO: implement DW_TAG_inheritance type parsing DWARFDebugInfoEntry::Attributes attributes; - const size_t num_attributes = die->GetAttributes(this, dwarf_cu, attributes); + const size_t num_attributes = die->GetAttributes(this, dwarf_cu, fixed_form_sizes, attributes); if (num_attributes > 0) { Declaration decl; @@ -1915,6 +1917,8 @@ if (parent_die == NULL) return 0; + const uint8_t *fixed_form_sizes = DWARFFormValue::GetFixedFormSizesForAddressSize (dwarf_cu->GetAddressByteSize()); + size_t count = 0; const DWARFDebugInfoEntry *die; for (die = parent_die->GetFirstChild(); die != NULL; die = die->GetSibling()) @@ -1925,7 +1929,7 @@ case DW_TAG_formal_parameter: { DWARFDebugInfoEntry::Attributes attributes; - const size_t num_attributes = die->GetAttributes(this, dwarf_cu, attributes); + const size_t num_attributes = die->GetAttributes(this, dwarf_cu, fixed_form_sizes, attributes); if (num_attributes > 0) { const char *name = NULL; @@ -2010,13 +2014,15 @@ size_t enumerators_added = 0; const DWARFDebugInfoEntry *die; + const uint8_t *fixed_form_sizes = DWARFFormValue::GetFixedFormSizesForAddressSize (dwarf_cu->GetAddressByteSize()); + for (die = parent_die->GetFirstChild(); die != NULL; die = die->GetSibling()) { const dw_tag_t tag = die->Tag(); if (tag == DW_TAG_enumerator) { DWARFDebugInfoEntry::Attributes attributes; - const size_t num_child_attributes = die->GetAttributes(this, dwarf_cu, attributes); + const size_t num_child_attributes = die->GetAttributes(this, dwarf_cu, fixed_form_sizes, attributes); if (num_child_attributes > 0) { const char *name = NULL; @@ -2081,6 +2087,7 @@ return; const DWARFDebugInfoEntry *die; + const uint8_t *fixed_form_sizes = DWARFFormValue::GetFixedFormSizesForAddressSize (dwarf_cu->GetAddressByteSize()); for (die = parent_die->GetFirstChild(); die != NULL; die = die->GetSibling()) { const dw_tag_t tag = die->Tag(); @@ -2089,7 +2096,7 @@ case DW_TAG_enumerator: { DWARFDebugInfoEntry::Attributes attributes; - const size_t num_child_attributes = die->GetAttributes(this, dwarf_cu, attributes); + const size_t num_child_attributes = die->GetAttributes(this, dwarf_cu, fixed_form_sizes, attributes); if (num_child_attributes > 0) { const char *name = NULL; @@ -2131,7 +2138,7 @@ case DW_TAG_subrange_type: { DWARFDebugInfoEntry::Attributes attributes; - const size_t num_child_attributes = die->GetAttributes(this, dwarf_cu, attributes); + const size_t num_child_attributes = die->GetAttributes(this, dwarf_cu, fixed_form_sizes, attributes); if (num_child_attributes > 0) { const char *name = NULL; @@ -2354,7 +2361,7 @@ // Set a bit that lets us know that we are currently parsing this const_cast(die)->SetUserData(DIE_IS_BEING_PARSED); - const size_t num_attributes = die->GetAttributes(this, dwarf_cu, attributes); + const size_t num_attributes = die->GetAttributes(this, dwarf_cu, NULL, attributes); Declaration decl; uint32_t encoding = 0; size_t byte_size = 0; @@ -2482,7 +2489,7 @@ LanguageType class_language = eLanguageTypeUnknown; //bool struct_is_class = false; Declaration decl; - const size_t num_attributes = die->GetAttributes(this, dwarf_cu, attributes); + const size_t num_attributes = die->GetAttributes(this, dwarf_cu, NULL, attributes); if (num_attributes > 0) { uint32_t i; @@ -2637,7 +2644,7 @@ lldb::user_id_t encoding_uid = DW_INVALID_OFFSET; Declaration decl; - const size_t num_attributes = die->GetAttributes(this, dwarf_cu, attributes); + const size_t num_attributes = die->GetAttributes(this, dwarf_cu, NULL, attributes); if (num_attributes > 0) { uint32_t i; @@ -2712,7 +2719,7 @@ clang::FunctionDecl::StorageClass storage = clang::FunctionDecl::None;//, Extern, Static, PrivateExtern - const size_t num_attributes = die->GetAttributes(this, dwarf_cu, attributes); + const size_t num_attributes = die->GetAttributes(this, dwarf_cu, NULL, attributes); if (num_attributes > 0) { uint32_t i; @@ -2826,7 +2833,7 @@ int64_t first_index = 0; uint32_t byte_stride = 0; uint32_t bit_stride = 0; - const size_t num_attributes = die->GetAttributes(this, dwarf_cu, attributes); + const size_t num_attributes = die->GetAttributes(this, dwarf_cu, NULL, attributes); if (num_attributes > 0) { @@ -2904,7 +2911,7 @@ dw_offset_t type_die_offset = DW_INVALID_OFFSET; dw_offset_t containing_type_die_offset = DW_INVALID_OFFSET; - const size_t num_attributes = die->GetAttributes(this, dwarf_cu, attributes); + const size_t num_attributes = die->GetAttributes(this, dwarf_cu, NULL, attributes); if (num_attributes > 0) { uint32_t i; @@ -3173,7 +3180,7 @@ const dw_tag_t tag = die->Tag(); DWARFDebugInfoEntry::Attributes attributes; - const size_t num_attributes = die->GetAttributes(this, dwarf_cu, attributes); + const size_t num_attributes = die->GetAttributes(this, dwarf_cu, NULL, attributes); if (num_attributes > 0) { const char *name = NULL; From johnny.chen at apple.com Wed Sep 15 11:59:20 2010 From: johnny.chen at apple.com (Johnny Chen) Date: Wed, 15 Sep 2010 16:59:20 -0000 Subject: [Lldb-commits] [lldb] r113981 - /lldb/trunk/test/enum_types/TestEnumTypes.py Message-ID: <20100915165920.58D0E2A6C12C@llvm.org> Author: johnny Date: Wed Sep 15 11:59:20 2010 New Revision: 113981 URL: http://llvm.org/viewvc/llvm-project?rev=113981&view=rev Log: Removed the @expectedFailure decorator for test_with_dwarf() test case. It has been fixed. Modified: lldb/trunk/test/enum_types/TestEnumTypes.py Modified: lldb/trunk/test/enum_types/TestEnumTypes.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/enum_types/TestEnumTypes.py?rev=113981&r1=113980&r2=113981&view=diff ============================================================================== --- lldb/trunk/test/enum_types/TestEnumTypes.py (original) +++ lldb/trunk/test/enum_types/TestEnumTypes.py Wed Sep 15 11:59:20 2010 @@ -17,7 +17,6 @@ # rdar://problem/8394746 # 'image lookup -t days' returns nothing with dwarf debug format. - @unittest2.expectedFailure def test_with_dwarf(self): """Test 'image lookup -t days' and check for correct display.""" self.buildDwarf() From johnny.chen at apple.com Wed Sep 15 12:33:57 2010 From: johnny.chen at apple.com (Johnny Chen) Date: Wed, 15 Sep 2010 17:33:57 -0000 Subject: [Lldb-commits] [lldb] r113986 - /lldb/trunk/test/lldbtest.py Message-ID: <20100915173357.4DEE12A6C12C@llvm.org> Author: johnny Date: Wed Sep 15 12:33:57 2010 New Revision: 113986 URL: http://llvm.org/viewvc/llvm-project?rev=113986&view=rev Log: We believed the intermittent process launch failure while running the test suite has been fixed by r113947. But just in case it still fails, emits a prominent message always. Modified: lldb/trunk/test/lldbtest.py Modified: lldb/trunk/test/lldbtest.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/lldbtest.py?rev=113986&r1=113985&r2=113986&view=diff ============================================================================== --- lldb/trunk/test/lldbtest.py (original) +++ lldb/trunk/test/lldbtest.py Wed Sep 15 12:33:57 2010 @@ -362,6 +362,8 @@ if self.res.Succeeded(): break + elif running: + print >> sys.stderr, "Run (process launch) command failed!" # Modify runStarted only if "run" or "process launch" was encountered. if running: From johnny.chen at apple.com Wed Sep 15 13:00:19 2010 From: johnny.chen at apple.com (Johnny Chen) Date: Wed, 15 Sep 2010 18:00:19 -0000 Subject: [Lldb-commits] [lldb] r113989 - /lldb/trunk/test/lldbtest.py Message-ID: <20100915180019.533042A6C12C@llvm.org> Author: johnny Date: Wed Sep 15 13:00:19 2010 New Revision: 113989 URL: http://llvm.org/viewvc/llvm-project?rev=113989&view=rev Log: Changed to a more informative message. Modified: lldb/trunk/test/lldbtest.py Modified: lldb/trunk/test/lldbtest.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/lldbtest.py?rev=113989&r1=113988&r2=113989&view=diff ============================================================================== --- lldb/trunk/test/lldbtest.py (original) +++ lldb/trunk/test/lldbtest.py Wed Sep 15 13:00:19 2010 @@ -363,7 +363,7 @@ if self.res.Succeeded(): break elif running: - print >> sys.stderr, "Run (process launch) command failed!" + print >> sys.stderr, "Command '" + cmd + "' failed!" # Modify runStarted only if "run" or "process launch" was encountered. if running: From johnny.chen at apple.com Wed Sep 15 13:11:19 2010 From: johnny.chen at apple.com (Johnny Chen) Date: Wed, 15 Sep 2010 18:11:19 -0000 Subject: [Lldb-commits] [lldb] r113991 - /lldb/trunk/test/dotest.py Message-ID: <20100915181119.53E6F2A6C12C@llvm.org> Author: johnny Date: Wed Sep 15 13:11:19 2010 New Revision: 113991 URL: http://llvm.org/viewvc/llvm-project?rev=113991&view=rev Log: Also added BuildAndIntegration to the directories to search for an existing lldb.py module. The priorities to search for are Debug, Release, then BuildAndIntegration. You can always override this with a valid PYTHONPATH environment variable before running the test driver. For example: $ PYTHONPATH=/Find/My/LLDB/Module/Here ./dotest.py -v . Python runtime will try to locate the lldb.py module from /Find/My/LLDB/Module/Here first before trying the Debug, Release, and then BuildAndIntegration directories. Modified: lldb/trunk/test/dotest.py Modified: lldb/trunk/test/dotest.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/dotest.py?rev=113991&r1=113990&r2=113991&view=diff ============================================================================== --- lldb/trunk/test/dotest.py (original) +++ lldb/trunk/test/dotest.py Wed Sep 15 13:11:19 2010 @@ -99,16 +99,20 @@ 'Resources', 'Python') relPath = os.path.join(base, 'build', 'Release', 'LLDB.framework', 'Resources', 'Python') + baiPath = os.path.join(base, 'build', 'BuildAndIntegration', + 'LLDB.framework', 'Resources', 'Python') lldbPath = None if os.path.isfile(os.path.join(dbgPath, 'lldb.py')): lldbPath = dbgPath elif os.path.isfile(os.path.join(relPath, 'lldb.py')): lldbPath = relPath + elif os.path.isfile(os.path.join(baiPath, 'lldb.py')): + lldbPath = baiPath if not lldbPath: - print 'This script requires lldb.py to be in either ' + dbgPath, - print ' or' + relPath + print 'This script requires lldb.py to be in either ' + dbgPath + ',', + print relPath + ', or ' + baiPath sys.exit(-1) sys.path.append(lldbPath) From ctice at apple.com Wed Sep 15 13:29:06 2010 From: ctice at apple.com (Caroline Tice) Date: Wed, 15 Sep 2010 18:29:06 -0000 Subject: [Lldb-commits] [lldb] r113993 - in /lldb/trunk: include/lldb/API/LLDB.h include/lldb/API/SBBreakpoint.h include/lldb/API/SBCommandInterpreter.h include/lldb/API/SBDefines.h include/lldb/API/SBEvent.h include/lldb/API/SBThread.h include/lldb/API/SBValue.h lldb.xcodeproj/project.pbxproj scripts/lldb.swig source/API/SBBreakpoint.cpp source/API/SBCommandInterpreter.cpp source/API/SBEvent.cpp source/API/SBProcess.cpp source/API/SBThread.cpp source/API/SBValue.cpp Message-ID: <20100915182907.047C42A6C12C@llvm.org> Author: ctice Date: Wed Sep 15 13:29:06 2010 New Revision: 113993 URL: http://llvm.org/viewvc/llvm-project?rev=113993&view=rev Log: Remove unnecessary/inappropriate output-printing functions from the API. Modified: lldb/trunk/include/lldb/API/LLDB.h lldb/trunk/include/lldb/API/SBBreakpoint.h lldb/trunk/include/lldb/API/SBCommandInterpreter.h lldb/trunk/include/lldb/API/SBDefines.h lldb/trunk/include/lldb/API/SBEvent.h lldb/trunk/include/lldb/API/SBThread.h lldb/trunk/include/lldb/API/SBValue.h lldb/trunk/lldb.xcodeproj/project.pbxproj lldb/trunk/scripts/lldb.swig lldb/trunk/source/API/SBBreakpoint.cpp lldb/trunk/source/API/SBCommandInterpreter.cpp lldb/trunk/source/API/SBEvent.cpp lldb/trunk/source/API/SBProcess.cpp lldb/trunk/source/API/SBThread.cpp lldb/trunk/source/API/SBValue.cpp Modified: lldb/trunk/include/lldb/API/LLDB.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/LLDB.h?rev=113993&r1=113992&r2=113993&view=diff ============================================================================== --- lldb/trunk/include/lldb/API/LLDB.h (original) +++ lldb/trunk/include/lldb/API/LLDB.h Wed Sep 15 13:29:06 2010 @@ -20,7 +20,6 @@ #include "lldb/API/SBBreakpoint.h" #include "lldb/API/SBBreakpointLocation.h" #include "lldb/API/SBBroadcaster.h" -#include "lldb/API/SBCommandContext.h" #include "lldb/API/SBCommandInterpreter.h" #include "lldb/API/SBCommandReturnObject.h" #include "lldb/API/SBCommunication.h" @@ -33,11 +32,14 @@ #include "lldb/API/SBFunction.h" #include "lldb/API/SBHostOS.h" #include "lldb/API/SBInputReader.h" +#include "lldb/API/SBInstruction.h" +#include "lldb/API/SBInstructionList.h" #include "lldb/API/SBLineEntry.h" #include "lldb/API/SBListener.h" #include "lldb/API/SBModule.h" #include "lldb/API/SBProcess.h" #include "lldb/API/SBSourceManager.h" +#include "lldb/API/SBStringList.h" #include "lldb/API/SBSymbol.h" #include "lldb/API/SBSymbolContext.h" #include "lldb/API/SBTarget.h" Modified: lldb/trunk/include/lldb/API/SBBreakpoint.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBBreakpoint.h?rev=113993&r1=113992&r2=113993&view=diff ============================================================================== --- lldb/trunk/include/lldb/API/SBBreakpoint.h (original) +++ lldb/trunk/include/lldb/API/SBBreakpoint.h Wed Sep 15 13:29:06 2010 @@ -42,9 +42,6 @@ IsValid() const; void - Dump (FILE *f); - - void ClearAllBreakpointSites (); lldb::SBBreakpointLocation @@ -60,9 +57,6 @@ GetLocationAtIndex (uint32_t index); void - ListLocations (FILE *, const char *description_level = "full"); - - void SetEnabled (bool enable); bool @@ -111,7 +105,7 @@ GetNumLocations() const; void - GetDescription (FILE *, const char *description_level, bool describe_locations = false); + GetDescription (FILE *, const char *description_level); static lldb::BreakpointEventType GetBreakpointEventTypeFromEvent (const lldb::SBEvent& event); Modified: lldb/trunk/include/lldb/API/SBCommandInterpreter.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBCommandInterpreter.h?rev=113993&r1=113992&r2=113993&view=diff ============================================================================== --- lldb/trunk/include/lldb/API/SBCommandInterpreter.h (original) +++ lldb/trunk/include/lldb/API/SBCommandInterpreter.h Wed Sep 15 13:29:06 2010 @@ -36,15 +36,9 @@ bool AliasExists (const char *cmd); - bool - UserCommandExists (const char *cmd); - lldb::SBBroadcaster GetBroadcaster (); - //const char ** - //GetEnvironmentVariables (); - bool HasCommands (); @@ -52,14 +46,8 @@ HasAliases (); bool - HasUserCommands (); - - bool HasAliasOptions (); - //bool - //HasInterpreterVariables (); - lldb::SBProcess GetProcess (); Modified: lldb/trunk/include/lldb/API/SBDefines.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBDefines.h?rev=113993&r1=113992&r2=113993&view=diff ============================================================================== --- lldb/trunk/include/lldb/API/SBDefines.h (original) +++ lldb/trunk/include/lldb/API/SBDefines.h Wed Sep 15 13:29:06 2010 @@ -30,7 +30,6 @@ class SBBreakpoint; class SBBreakpointLocation; class SBBroadcaster; -class SBCommandContext; class SBCommandInterpreter; class SBCommandReturnObject; class SBCommunication; @@ -53,7 +52,6 @@ class SBStringList; class SBSymbol; class SBSymbolContext; -class SBStringList; class SBTarget; class SBThread; class SBValue; Modified: lldb/trunk/include/lldb/API/SBEvent.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBEvent.h?rev=113993&r1=113992&r2=113993&view=diff ============================================================================== --- lldb/trunk/include/lldb/API/SBEvent.h (original) +++ lldb/trunk/include/lldb/API/SBEvent.h Wed Sep 15 13:29:06 2010 @@ -32,9 +32,6 @@ bool IsValid() const; - void - Dump (FILE *f) const; - const char * GetDataFlavor (); Modified: lldb/trunk/include/lldb/API/SBThread.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBThread.h?rev=113993&r1=113992&r2=113993&view=diff ============================================================================== --- lldb/trunk/include/lldb/API/SBThread.h (original) +++ lldb/trunk/include/lldb/API/SBThread.h Wed Sep 15 13:29:06 2010 @@ -52,25 +52,6 @@ GetQueueName() const; void - DisplayFramesForSelectedContext (FILE *out, - FILE *err, - uint32_t first_frame, - uint32_t num_frames, - bool show_frame_info, - uint32_t num_frames_with_source, - uint32_t source_lines_before = 3, - uint32_t source_lines_after = 3); - - bool - DisplaySingleFrameForSelectedContext (FILE *out, - FILE *err, - lldb::SBFrame &frame, - bool show_frame_info, - bool show_source, - uint32_t source_lines_after, - uint32_t source_lines_before); - - void StepOver (lldb::RunMode stop_other_threads = lldb::eOnlyDuringStepping); void Modified: lldb/trunk/include/lldb/API/SBValue.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBValue.h?rev=113993&r1=113992&r2=113993&view=diff ============================================================================== --- lldb/trunk/include/lldb/API/SBValue.h (original) +++ lldb/trunk/include/lldb/API/SBValue.h Wed Sep 15 13:29:06 2010 @@ -26,9 +26,6 @@ bool IsValid() const; - void - Print (FILE *out_file, lldb::SBFrame *frame, bool print_type, bool print_value); - const char * GetName(); @@ -81,8 +78,6 @@ void * GetOpaqueType(); - //void - //DumpType (); lldb::SBValue Dereference (); Modified: lldb/trunk/lldb.xcodeproj/project.pbxproj URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/lldb.xcodeproj/project.pbxproj?rev=113993&r1=113992&r2=113993&view=diff ============================================================================== --- lldb/trunk/lldb.xcodeproj/project.pbxproj (original) +++ lldb/trunk/lldb.xcodeproj/project.pbxproj Wed Sep 15 13:29:06 2010 @@ -29,7 +29,6 @@ 26680219115FD13D008E1FE4 /* SBBreakpoint.h in Headers */ = {isa = PBXBuildFile; fileRef = 9AF16A9E11402D69007A7B3F /* SBBreakpoint.h */; settings = {ATTRIBUTES = (Public, ); }; }; 2668021A115FD13D008E1FE4 /* SBBreakpointLocation.h in Headers */ = {isa = PBXBuildFile; fileRef = 9AF16CC611408686007A7B3F /* SBBreakpointLocation.h */; settings = {ATTRIBUTES = (Public, ); }; }; 2668021B115FD13D008E1FE4 /* SBBroadcaster.h in Headers */ = {isa = PBXBuildFile; fileRef = 9A9830F31125FC5800A56CB0 /* SBBroadcaster.h */; settings = {ATTRIBUTES = (Public, ); }; }; - 2668021C115FD13D008E1FE4 /* SBCommandContext.h in Headers */ = {isa = PBXBuildFile; fileRef = 9A9830F51125FC5800A56CB0 /* SBCommandContext.h */; settings = {ATTRIBUTES = (Public, ); }; }; 2668021D115FD13D008E1FE4 /* SBCommandInterpreter.h in Headers */ = {isa = PBXBuildFile; fileRef = 9A9830F71125FC5800A56CB0 /* SBCommandInterpreter.h */; settings = {ATTRIBUTES = (Public, ); }; }; 2668021E115FD13D008E1FE4 /* SBCommandReturnObject.h in Headers */ = {isa = PBXBuildFile; fileRef = 9A9830F91125FC5800A56CB0 /* SBCommandReturnObject.h */; settings = {ATTRIBUTES = (Public, ); }; }; 2668021F115FD13D008E1FE4 /* SBCommunication.h in Headers */ = {isa = PBXBuildFile; fileRef = 260223E7115F06D500A601A2 /* SBCommunication.h */; settings = {ATTRIBUTES = (Public, ); }; }; @@ -62,7 +61,6 @@ 26680331116005E9008E1FE4 /* SBCommunication.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 260223E8115F06E500A601A2 /* SBCommunication.cpp */; }; 26680332116005EA008E1FE4 /* SBCommandReturnObject.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9A9830F81125FC5800A56CB0 /* SBCommandReturnObject.cpp */; }; 26680333116005EC008E1FE4 /* SBCommandInterpreter.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9A9830F61125FC5800A56CB0 /* SBCommandInterpreter.cpp */; }; - 26680334116005ED008E1FE4 /* SBCommandContext.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9A9830F41125FC5800A56CB0 /* SBCommandContext.cpp */; }; 26680335116005EE008E1FE4 /* SBBroadcaster.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9A9830F21125FC5800A56CB0 /* SBBroadcaster.cpp */; }; 26680336116005EF008E1FE4 /* SBBreakpointLocation.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9AF16CC7114086A1007A7B3F /* SBBreakpointLocation.cpp */; }; 26680337116005F1008E1FE4 /* SBBreakpoint.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9AF16A9C11402D5B007A7B3F /* SBBreakpoint.cpp */; }; @@ -1043,8 +1041,6 @@ 9A82010B10FFB49800182560 /* ScriptInterpreter.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = ScriptInterpreter.cpp; path = source/Interpreter/ScriptInterpreter.cpp; sourceTree = ""; }; 9A9830F21125FC5800A56CB0 /* SBBroadcaster.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = SBBroadcaster.cpp; path = source/API/SBBroadcaster.cpp; sourceTree = ""; }; 9A9830F31125FC5800A56CB0 /* SBBroadcaster.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SBBroadcaster.h; path = include/lldb/API/SBBroadcaster.h; sourceTree = ""; }; - 9A9830F41125FC5800A56CB0 /* SBCommandContext.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = SBCommandContext.cpp; path = source/API/SBCommandContext.cpp; sourceTree = ""; }; - 9A9830F51125FC5800A56CB0 /* SBCommandContext.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SBCommandContext.h; path = include/lldb/API/SBCommandContext.h; sourceTree = ""; }; 9A9830F61125FC5800A56CB0 /* SBCommandInterpreter.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = SBCommandInterpreter.cpp; path = source/API/SBCommandInterpreter.cpp; sourceTree = ""; }; 9A9830F71125FC5800A56CB0 /* SBCommandInterpreter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SBCommandInterpreter.h; path = include/lldb/API/SBCommandInterpreter.h; sourceTree = ""; }; 9A9830F81125FC5800A56CB0 /* SBCommandReturnObject.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = SBCommandReturnObject.cpp; path = source/API/SBCommandReturnObject.cpp; sourceTree = ""; }; @@ -1447,8 +1443,6 @@ 9AF16CC7114086A1007A7B3F /* SBBreakpointLocation.cpp */, 9A9830F31125FC5800A56CB0 /* SBBroadcaster.h */, 9A9830F21125FC5800A56CB0 /* SBBroadcaster.cpp */, - 9A9830F51125FC5800A56CB0 /* SBCommandContext.h */, - 9A9830F41125FC5800A56CB0 /* SBCommandContext.cpp */, 9A9830F71125FC5800A56CB0 /* SBCommandInterpreter.h */, 9A9830F61125FC5800A56CB0 /* SBCommandInterpreter.cpp */, 9A9830F91125FC5800A56CB0 /* SBCommandReturnObject.h */, @@ -2221,7 +2215,6 @@ 26680219115FD13D008E1FE4 /* SBBreakpoint.h in Headers */, 2668021A115FD13D008E1FE4 /* SBBreakpointLocation.h in Headers */, 2668021B115FD13D008E1FE4 /* SBBroadcaster.h in Headers */, - 2668021C115FD13D008E1FE4 /* SBCommandContext.h in Headers */, 2668021D115FD13D008E1FE4 /* SBCommandInterpreter.h in Headers */, 2668021E115FD13D008E1FE4 /* SBCommandReturnObject.h in Headers */, 2668021F115FD13D008E1FE4 /* SBCommunication.h in Headers */, @@ -2692,7 +2685,6 @@ 26680331116005E9008E1FE4 /* SBCommunication.cpp in Sources */, 26680332116005EA008E1FE4 /* SBCommandReturnObject.cpp in Sources */, 26680333116005EC008E1FE4 /* SBCommandInterpreter.cpp in Sources */, - 26680334116005ED008E1FE4 /* SBCommandContext.cpp in Sources */, 26680335116005EE008E1FE4 /* SBBroadcaster.cpp in Sources */, 26680336116005EF008E1FE4 /* SBBreakpointLocation.cpp in Sources */, 26680337116005F1008E1FE4 /* SBBreakpoint.cpp in Sources */, Modified: lldb/trunk/scripts/lldb.swig URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/scripts/lldb.swig?rev=113993&r1=113992&r2=113993&view=diff ============================================================================== --- lldb/trunk/scripts/lldb.swig (original) +++ lldb/trunk/scripts/lldb.swig Wed Sep 15 13:29:06 2010 @@ -76,7 +76,6 @@ #include "lldb/API/SBBreakpoint.h" #include "lldb/API/SBBreakpointLocation.h" #include "lldb/API/SBBroadcaster.h" -#include "lldb/API/SBCommandContext.h" #include "lldb/API/SBCommandInterpreter.h" #include "lldb/API/SBCommandReturnObject.h" #include "lldb/API/SBCompileUnit.h" @@ -130,7 +129,6 @@ %include "lldb/API/SBBreakpoint.h" %include "lldb/API/SBBreakpointLocation.h" %include "lldb/API/SBBroadcaster.h" -%include "lldb/API/SBCommandContext.h" %include "lldb/API/SBCommandInterpreter.h" %include "lldb/API/SBCommandReturnObject.h" %include "lldb/API/SBCompileUnit.h" Modified: lldb/trunk/source/API/SBBreakpoint.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBBreakpoint.cpp?rev=113993&r1=113992&r2=113993&view=diff ============================================================================== --- lldb/trunk/source/API/SBBreakpoint.cpp (original) +++ lldb/trunk/source/API/SBBreakpoint.cpp Wed Sep 15 13:29:06 2010 @@ -108,16 +108,6 @@ } void -SBBreakpoint::Dump (FILE *f) -{ - if (m_opaque_sp && f) - { - lldb_private::StreamFile str (f); - m_opaque_sp->Dump (&str); - } -} - -void SBBreakpoint::ClearAllBreakpointSites () { if (m_opaque_sp) @@ -192,34 +182,6 @@ } void -SBBreakpoint::ListLocations (FILE* f, const char *description_level) -{ - if (m_opaque_sp && f) - { - DescriptionLevel level; - if (strcmp (description_level, "brief") == 0) - level = eDescriptionLevelBrief; - else if (strcmp (description_level, "full") == 0) - level = eDescriptionLevelFull; - else if (strcmp (description_level, "verbose") == 0) - level = eDescriptionLevelVerbose; - else - level = eDescriptionLevelBrief; - - StreamFile str (f); - - str.IndentMore(); - int num_locs = m_opaque_sp->GetNumLocations(); - for (int i = 0; i < num_locs; ++i) - { - BreakpointLocation *loc = m_opaque_sp->GetLocationAtIndex (i).get(); - loc->GetDescription (&str, level); - str.EOL(); - } - } -} - -void SBBreakpoint::SetEnabled (bool enable) { if (m_opaque_sp) @@ -360,7 +322,7 @@ } void -SBBreakpoint::GetDescription (FILE *f, const char *description_level, bool describe_locations) +SBBreakpoint::GetDescription (FILE *f, const char *description_level) { if (f == NULL) return; @@ -381,18 +343,6 @@ m_opaque_sp->GetDescription (&str, level); str.EOL(); - if (describe_locations) - { - //str.IndentMore(); - // int num_locs = m_opaque_sp->GetNumLocations(); - // for (int i = 0; i < num_locs; ++i) - // { - // BreakpointLocation *loc = m_opaque_sp->FindLocationByIndex (i); - // loc->GetDescription (&str, level); - // str.EOL(); - // } - ListLocations (f, description_level); - } } } Modified: lldb/trunk/source/API/SBCommandInterpreter.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBCommandInterpreter.cpp?rev=113993&r1=113992&r2=113993&view=diff ============================================================================== --- lldb/trunk/source/API/SBCommandInterpreter.cpp (original) +++ lldb/trunk/source/API/SBCommandInterpreter.cpp Wed Sep 15 13:29:06 2010 @@ -18,7 +18,6 @@ #include "lldb/API/SBBroadcaster.h" #include "lldb/API/SBDebugger.h" #include "lldb/API/SBCommandReturnObject.h" -#include "lldb/API/SBCommandContext.h" #include "lldb/API/SBSourceManager.h" #include "lldb/API/SBCommandInterpreter.h" #include "lldb/API/SBProcess.h" @@ -62,14 +61,6 @@ return false; } -bool -SBCommandInterpreter::UserCommandExists (const char *cmd) -{ - if (m_opaque_ptr) - return m_opaque_ptr->UserCommandExists (cmd); - return false; -} - lldb::ReturnStatus SBCommandInterpreter::HandleCommand (const char *command_line, SBCommandReturnObject &result, bool add_to_history) { @@ -107,18 +98,6 @@ return num_completions; } -//const char ** -//SBCommandInterpreter::GetEnvironmentVariables () -//{ -// if (m_opaque_ptr) -// { -// //const Args *env_vars = m_opaque_ptr->GetEnvironmentVariables(); -// //if (env_vars) -// // return env_vars->GetConstArgumentVector (); -// } -// return NULL; -//} - bool SBCommandInterpreter::HasCommands () { @@ -136,14 +115,6 @@ } bool -SBCommandInterpreter::HasUserCommands () -{ - if (m_opaque_ptr) - return m_opaque_ptr->HasUserCommands (); - return false; -} - -bool SBCommandInterpreter::HasAliasOptions () { if (m_opaque_ptr) @@ -151,14 +122,6 @@ return false; } -//bool -//SBCommandInterpreter::HasInterpreterVariables () -//{ -// if (m_opaque_ptr) -// return m_opaque_ptr->HasInterpreterVariables (); -// return false; -//} - SBProcess SBCommandInterpreter::GetProcess () { Modified: lldb/trunk/source/API/SBEvent.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBEvent.cpp?rev=113993&r1=113992&r2=113993&view=diff ============================================================================== --- lldb/trunk/source/API/SBEvent.cpp (original) +++ lldb/trunk/source/API/SBEvent.cpp Wed Sep 15 13:29:06 2010 @@ -44,17 +44,6 @@ { } -void -SBEvent::Dump (FILE *f) const -{ - const Event *lldb_event = get(); - if (lldb_event) - { - StreamFile str(f); - lldb_event->Dump ((Stream *) &str); - } -} - const char * SBEvent::GetDataFlavor () { Modified: lldb/trunk/source/API/SBProcess.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBProcess.cpp?rev=113993&r1=113992&r2=113993&view=diff ============================================================================== --- lldb/trunk/source/API/SBProcess.cpp (original) +++ lldb/trunk/source/API/SBProcess.cpp Wed Sep 15 13:29:06 2010 @@ -342,13 +342,13 @@ } lldb::pid_t -SBProcess::AttachByPID (lldb::pid_t attach_pid) // DEPRECATED: will be removed in a few builds in favor of SBError AttachByPID(pid_t) +SBProcess::AttachByPID (lldb::pid_t attach_pid) // DEPRECATED: will be removed in a few builds in favor of SBError AttachByPID(pid_t) { Attach (attach_pid); return GetProcessID(); } - + SBError SBProcess::Attach (lldb::pid_t attach_pid) { Modified: lldb/trunk/source/API/SBThread.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBThread.cpp?rev=113993&r1=113992&r2=113993&view=diff ============================================================================== --- lldb/trunk/source/API/SBThread.cpp (original) +++ lldb/trunk/source/API/SBThread.cpp Wed Sep 15 13:29:06 2010 @@ -219,106 +219,6 @@ void -SBThread::DisplayFramesForSelectedContext (FILE *out, - FILE *err, - uint32_t first_frame, - uint32_t num_frames, - bool show_frame_info, - uint32_t num_frames_with_source, - uint32_t source_lines_before, - uint32_t source_lines_after) -{ - if ((out == NULL) || (err == NULL)) - return; - - if (m_opaque_sp) - { - uint32_t num_stack_frames = m_opaque_sp->GetStackFrameCount (); - StackFrameSP frame_sp; - uint32_t frame_idx = 0; - - for (frame_idx = first_frame; frame_idx < first_frame + num_frames; ++frame_idx) - { - if (frame_idx >= num_stack_frames) - break; - - frame_sp = m_opaque_sp->GetStackFrameAtIndex (frame_idx); - if (!frame_sp) - break; - - SBFrame sb_frame (frame_sp); - if (DisplaySingleFrameForSelectedContext (out, - err, - sb_frame, - show_frame_info, - num_frames_with_source > first_frame - frame_idx, - source_lines_before, - source_lines_after) == false) - break; - } - } -} - -bool -SBThread::DisplaySingleFrameForSelectedContext (FILE *out, - FILE *err, - SBFrame &frame, - bool show_frame_info, - bool show_source, - uint32_t source_lines_after, - uint32_t source_lines_before) -{ - bool success = false; - - if ((out == NULL) || (err == NULL)) - return false; - - if (m_opaque_sp && frame.IsValid()) - { - StreamFile str (out); - - SBSymbolContext sc(frame.GetSymbolContext(eSymbolContextEverything)); - - if (show_frame_info && sc.IsValid()) - { - user_id_t frame_idx = (user_id_t) frame.GetFrameID(); - lldb::addr_t pc = frame.GetPC(); - ::fprintf (out, - " frame #%u: tid = 0x%4.4x, pc = 0x%llx ", - frame_idx, - GetThreadID(), - (long long)pc); - sc->DumpStopContext (&str, &m_opaque_sp->GetProcess(), *frame.GetPCAddress(), false, true, false); - fprintf (out, "\n"); - success = true; - } - - SBCompileUnit comp_unit(sc.GetCompileUnit()); - if (show_source && comp_unit.IsValid()) - { - success = false; - SBLineEntry line_entry; - if (line_entry.IsValid()) - { - SourceManager& source_manager = m_opaque_sp->GetProcess().GetTarget().GetDebugger().GetSourceManager(); - SBFileSpec line_entry_file_spec (line_entry.GetFileSpec()); - - if (line_entry_file_spec.IsValid()) - { - source_manager.DisplaySourceLinesWithLineNumbers (line_entry_file_spec.ref(), - line_entry.GetLine(), - source_lines_after, - source_lines_before, "->", - &str); - success = true; - } - } - } - } - return success; -} - -void SBThread::StepOver (lldb::RunMode stop_other_threads) { if (m_opaque_sp) Modified: lldb/trunk/source/API/SBValue.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBValue.cpp?rev=113993&r1=113992&r2=113993&view=diff ============================================================================== --- lldb/trunk/source/API/SBValue.cpp (original) +++ lldb/trunk/source/API/SBValue.cpp Wed Sep 15 13:29:06 2010 @@ -52,81 +52,6 @@ return (m_opaque_sp.get() != NULL); } -void -SBValue::Print (FILE *out_file, SBFrame *frame, bool print_type, bool print_value) -{ - if (out_file == NULL) - return; - - if (IsValid()) - { - - SBThread sb_thread = frame->GetThread(); - SBProcess sb_process = sb_thread.GetProcess(); - - lldb_private::StackFrame *lldb_frame = frame->GetLLDBObjectPtr(); - lldb_private::Thread *lldb_thread = sb_thread.GetLLDBObjectPtr(); - lldb_private::Process *lldb_process = sb_process.get(); - - lldb_private::ExecutionContext context (lldb_process, lldb_thread, lldb_frame); - - lldb_private::StreamFile out_stream (out_file); - - out_stream.Printf ("%s ", m_opaque_sp->GetName().AsCString (NULL)); - if (! m_opaque_sp->IsInScope (lldb_frame)) - out_stream.Printf ("[out-of-scope] "); - if (print_type) - { - out_stream.Printf ("(%s) ", m_opaque_sp->GetTypeName().AsCString ("")); - } - - if (print_value) - { - ExecutionContextScope *exe_scope = frame->get(); - const char *val_cstr = m_opaque_sp->GetValueAsCString(exe_scope); - const char *err_cstr = m_opaque_sp->GetError().AsCString(); - - if (!err_cstr) - { - const char *sum_cstr = m_opaque_sp->GetSummaryAsCString(exe_scope); - const bool is_aggregate = - ClangASTContext::IsAggregateType (m_opaque_sp->GetOpaqueClangQualType()); - if (val_cstr) - out_stream.Printf ("= %s ", val_cstr); - - if (sum_cstr) - out_stream.Printf ("%s ", sum_cstr); - - if (is_aggregate) - { - out_stream.PutChar ('{'); - const uint32_t num_children = m_opaque_sp->GetNumChildren(); - if (num_children) - { - out_stream.IndentMore(); - for (uint32_t idx = 0; idx < num_children; ++idx) - { - lldb::ValueObjectSP child_sp (m_opaque_sp->GetChildAtIndex (idx, true)); - if (child_sp.get()) - { - out_stream.EOL(); - out_stream.Indent(); - out_stream.Printf ("%s (%s) = %s", child_sp.get()->GetName().AsCString (""), - child_sp.get()->GetTypeName().AsCString (""), - child_sp.get()->GetValueAsCString(exe_scope)); - } - } - out_stream.IndentLess(); - } - out_stream.EOL(); - out_stream.Indent ("}"); - } - } - } - out_stream.EOL (); - } -} - const char * SBValue::GetName() { From johnny.chen at apple.com Wed Sep 15 17:27:30 2010 From: johnny.chen at apple.com (Johnny Chen) Date: Wed, 15 Sep 2010 22:27:30 -0000 Subject: [Lldb-commits] [lldb] r114031 - in /lldb/trunk/test/settings: Makefile TestSettings.py main.cpp Message-ID: <20100915222730.2EB612A6C12C@llvm.org> Author: johnny Date: Wed Sep 15 17:27:29 2010 New Revision: 114031 URL: http://llvm.org/viewvc/llvm-project?rev=114031&view=rev Log: Added two test cases to TestSettings.py which exercise the lldb's: (lldb) settings set process.run-args A B C (lldb) settings set process.env-vars ["MY_ENV_VAR"]=YES commands. The main.cpp checks whether A, B, C is passed to main and whether the $MY_ENV_VAR env variable is defined and outputs the findings to a file. Added: lldb/trunk/test/settings/Makefile lldb/trunk/test/settings/main.cpp Modified: lldb/trunk/test/settings/TestSettings.py Added: lldb/trunk/test/settings/Makefile URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/settings/Makefile?rev=114031&view=auto ============================================================================== --- lldb/trunk/test/settings/Makefile (added) +++ lldb/trunk/test/settings/Makefile Wed Sep 15 17:27:29 2010 @@ -0,0 +1,5 @@ +LEVEL = ../make + +CXX_SOURCES := main.cpp + +include $(LEVEL)/Makefile.rules Modified: lldb/trunk/test/settings/TestSettings.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/settings/TestSettings.py?rev=114031&r1=114030&r2=114031&view=diff ============================================================================== --- lldb/trunk/test/settings/TestSettings.py (original) +++ lldb/trunk/test/settings/TestSettings.py Wed Sep 15 17:27:29 2010 @@ -39,6 +39,36 @@ self.expect("settings show", startstr = "term-width (int) = '70'") + @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin") + def test_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): + """Test that run-args and env-vars are passed to the launched process.""" + self.buildDwarf() + self.pass_run_args_and_env_vars() + + def pass_run_args_and_env_vars(self): + """Test that run-args and env-vars are passed to the launched process.""" + exe = os.path.join(os.getcwd(), "a.out") + self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) + + # Set the run-args and the env-vars. + self.runCmd('settings set process.run-args A B C') + self.runCmd('settings set process.env-vars ["MY_ENV_VAR"]=YES') + + self.runCmd("run", RUN_SUCCEEDED) + + # Read the output file produced by running the program. + output = open('/tmp/output.txt', 'r').read() + + self.assertTrue(output.startswith("argv[1] matches") and + output.find("argv[2] matches") > 0 and + output.find("argv[3] matches") > 0 and + output.find("Environment variable 'MY_ENV_VAR' successfully passed.") > 0) + if __name__ == '__main__': import atexit Added: lldb/trunk/test/settings/main.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/settings/main.cpp?rev=114031&view=auto ============================================================================== --- lldb/trunk/test/settings/main.cpp (added) +++ lldb/trunk/test/settings/main.cpp Wed Sep 15 17:27:29 2010 @@ -0,0 +1,44 @@ +//===-- 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 + +int +main(int argc, char const *argv[]) +{ + char const *cptr = NULL; + // The program writes its output to the "output.txt" file. + std::ofstream outfile("output.txt"); + + for (unsigned i = 0, e = sizeof(argv); i < e; ++i) { + if ((cptr = argv[i]) == NULL) + break; + + std::string str(cptr); + if (i == 1 && "A" == str) + outfile << "argv[1] matches\n"; + + if (i == 2 && "B" == str) + outfile << "argv[2] matches\n"; + + if (i == 3 && "C" == str) + outfile << "argv[3] matches\n"; + } + + if (::getenv("MY_ENV_VAR")) { + std::string MY_ENV_VAR(getenv("MY_ENV_VAR")); + if ("YES" == MY_ENV_VAR) { + outfile << "Environment variable 'MY_ENV_VAR' successfully passed.\n"; + } + } + + return 0; +} From johnny.chen at apple.com Wed Sep 15 17:48:40 2010 From: johnny.chen at apple.com (Johnny Chen) Date: Wed, 15 Sep 2010 22:48:40 -0000 Subject: [Lldb-commits] [lldb] r114033 - /lldb/trunk/test/settings/main.cpp Message-ID: <20100915224840.775762A6C12C@llvm.org> Author: johnny Date: Wed Sep 15 17:48:40 2010 New Revision: 114033 URL: http://llvm.org/viewvc/llvm-project?rev=114033&view=rev Log: Simplied main() and emits a message to the standard out. Modified: lldb/trunk/test/settings/main.cpp Modified: lldb/trunk/test/settings/main.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/settings/main.cpp?rev=114033&r1=114032&r2=114033&view=diff ============================================================================== --- lldb/trunk/test/settings/main.cpp (original) +++ lldb/trunk/test/settings/main.cpp Wed Sep 15 17:48:40 2010 @@ -10,26 +10,23 @@ #include #include #include +#include int main(int argc, char const *argv[]) { - char const *cptr = NULL; // The program writes its output to the "output.txt" file. std::ofstream outfile("output.txt"); - for (unsigned i = 0, e = sizeof(argv); i < e; ++i) { - if ((cptr = argv[i]) == NULL) - break; - - std::string str(cptr); - if (i == 1 && "A" == str) + for (unsigned i = 0; i < argc; ++i) { + std::string theArg(argv[i]); + if (i == 1 && "A" == theArg) outfile << "argv[1] matches\n"; - if (i == 2 && "B" == str) + if (i == 2 && "B" == theArg) outfile << "argv[2] matches\n"; - if (i == 3 && "C" == str) + if (i == 3 && "C" == theArg) outfile << "argv[3] matches\n"; } @@ -40,5 +37,7 @@ } } + std::cout << "This message should go to standard out.\n"; + return 0; } From jingham at apple.com Wed Sep 15 19:57:34 2010 From: jingham at apple.com (Jim Ingham) Date: Thu, 16 Sep 2010 00:57:34 -0000 Subject: [Lldb-commits] [lldb] r114054 - in /lldb/trunk: include/lldb/Core/FileSpec.h source/Core/FileSpec.cpp source/Plugins/SymbolFile/DWARF/DWARFDebugLine.cpp source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp Message-ID: <20100916005734.282E92A6C12C@llvm.org> Author: jingham Date: Wed Sep 15 19:57:33 2010 New Revision: 114054 URL: http://llvm.org/viewvc/llvm-project?rev=114054&view=rev Log: Add the ability to not resolve the name passed to FileSpec. Then don't resolve the names of compilation units found in DWARF. Modified: lldb/trunk/include/lldb/Core/FileSpec.h lldb/trunk/source/Core/FileSpec.cpp lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugLine.cpp lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp Modified: lldb/trunk/include/lldb/Core/FileSpec.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/FileSpec.h?rev=114054&r1=114053&r2=114054&view=diff ============================================================================== --- lldb/trunk/include/lldb/Core/FileSpec.h (original) +++ lldb/trunk/include/lldb/Core/FileSpec.h Wed Sep 15 19:57:33 2010 @@ -66,6 +66,23 @@ explicit FileSpec (const char *path); //------------------------------------------------------------------ + /// Default constructor. + /// + /// Takes an optional full path to a file. If \a path is valid, + /// this function will call FileSpec::SetFile (\a path). + /// + /// @param[in] path + /// The full or partial path to a file. + /// + /// @param[in] resolve_path + /// If \b true, then we resolve the path with realpath, + /// if \b false we trust the path is in canonical form already. + /// + /// @see FileSpec::SetFile () + //------------------------------------------------------------------ + explicit FileSpec (const char *path, bool resolve_path); + + //------------------------------------------------------------------ /// Copy constructor /// /// Makes a copy of the uniqued directory and filename strings from @@ -275,6 +292,17 @@ //------------------------------------------------------------------ bool ResolveExecutableLocation (); + + + //------------------------------------------------------------------ + /// Canonicalize this file path (basically running the static Resolve method on it). + /// Useful if you asked us not to resolve the file path when you set the file. + /// + /// @return + /// None. + //------------------------------------------------------------------ + bool + ResolvePath (); uint64_t GetByteSize() const; @@ -429,9 +457,13 @@ /// /// @param[in] path /// A full, partial, or relative path to a file. + /// + /// @param[in] resolve + /// If \b true, then we will try to resolve links the path using + /// the static FileSpec::Resolve. //------------------------------------------------------------------ void - SetFile (const char *path); + SetFile (const char *path, bool resolve = true); //------------------------------------------------------------------ /// Read the file into an array of strings, one per line. Modified: lldb/trunk/source/Core/FileSpec.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/FileSpec.cpp?rev=114054&r1=114053&r2=114054&view=diff ============================================================================== --- lldb/trunk/source/Core/FileSpec.cpp (original) +++ lldb/trunk/source/Core/FileSpec.cpp Wed Sep 15 19:57:33 2010 @@ -183,6 +183,18 @@ } //------------------------------------------------------------------ +// Default constructor that can take an optional full path to a +// file on disk. +//------------------------------------------------------------------ +FileSpec::FileSpec(const char *pathname, bool resolve_path) : + m_directory(), + m_filename() +{ + if (pathname && pathname[0]) + SetFile(pathname, resolve_path); +} + +//------------------------------------------------------------------ // Copy constructor //------------------------------------------------------------------ FileSpec::FileSpec(const FileSpec& rhs) : @@ -223,14 +235,13 @@ return *this; } - //------------------------------------------------------------------ // Update the contents of this object with a new path. The path will // be split up into a directory and filename and stored as uniqued // string values for quick comparison and efficient memory usage. //------------------------------------------------------------------ void -FileSpec::SetFile(const char *pathname) +FileSpec::SetFile(const char *pathname, bool resolve) { m_filename.Clear(); m_directory.Clear(); @@ -238,8 +249,22 @@ return; char resolved_path[PATH_MAX]; + bool path_fit = true; + + if (resolve) + { + path_fit = (FileSpec::Resolve (pathname, resolved_path, sizeof(resolved_path)) < sizeof(resolved_path) - 1); + } + else + { + if (strlen (pathname) > sizeof(resolved_path) - 1) + path_fit = false; + else + strcpy (resolved_path, pathname); + } - if (FileSpec::Resolve (pathname, resolved_path, sizeof(resolved_path)) < sizeof(resolved_path) - 1) + + if (path_fit) { char *filename = ::basename (resolved_path); if (filename) @@ -453,6 +478,17 @@ return false; } +bool +FileSpec::ResolvePath () +{ + char path_buf[PATH_MAX]; + + if (!GetPath (path_buf, PATH_MAX)) + return false; + SetFile (path_buf, true); + return true; +} + uint64_t FileSpec::GetByteSize() const { Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugLine.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugLine.cpp?rev=114054&r1=114053&r2=114054&view=diff ============================================================================== --- lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugLine.cpp (original) +++ lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugLine.cpp Wed Sep 15 19:57:33 2010 @@ -525,7 +525,9 @@ } fullpath += path; } - FileSpec file_spec(fullpath.c_str()); + + // We don't need to realpath files in the debug_line tables. + FileSpec file_spec(fullpath.c_str(), false); support_files.Append(file_spec); } } Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp?rev=114054&r1=114053&r2=114054&view=diff ============================================================================== --- lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp (original) +++ lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp Wed Sep 15 19:57:33 2010 @@ -488,9 +488,13 @@ LanguageType class_language = (LanguageType)cu_die->GetAttributeValueAsUnsigned(this, cu, DW_AT_language, 0); if (cu_die_name) { + FileSpec cu_file_spec; + if (cu_die_name[0] == '/' || cu_comp_dir == NULL && cu_comp_dir[0]) { - compile_unit_sp.reset(new CompileUnit(m_obj_file->GetModule(), cu, cu_die_name, cu->GetOffset(), class_language)); + // If we have a full path to the compile unit, we don't need to resolve + // the file. This can be expensive e.g. when the source files are NFS mounted. + cu_file_spec.SetFile (cu_die_name, false); } else { @@ -498,10 +502,10 @@ if (*fullpath.rbegin() != '/') fullpath += '/'; fullpath += cu_die_name; - - compile_unit_sp.reset(new CompileUnit(m_obj_file->GetModule(), cu, fullpath.c_str(), cu->GetOffset(), class_language)); + cu_file_spec.SetFile (fullpath.c_str(), false); } + compile_unit_sp.reset(new CompileUnit(m_obj_file->GetModule(), cu, cu_file_spec, cu->GetOffset(), class_language)); if (compile_unit_sp.get()) { cu->SetUserData(compile_unit_sp.get()); From jingham at apple.com Wed Sep 15 19:58:09 2010 From: jingham at apple.com (Jim Ingham) Date: Thu, 16 Sep 2010 00:58:09 -0000 Subject: [Lldb-commits] [lldb] r114055 - in /lldb/trunk: include/lldb/Target/ThreadPlanStepInRange.h source/Target/ThreadPlanStepInRange.cpp source/Target/ThreadPlanStepRange.cpp Message-ID: <20100916005809.35D9C2A6C12C@llvm.org> Author: jingham Date: Wed Sep 15 19:58:09 2010 New Revision: 114055 URL: http://llvm.org/viewvc/llvm-project?rev=114055&view=rev Log: Step past prologues when we step into functions. Modified: lldb/trunk/include/lldb/Target/ThreadPlanStepInRange.h lldb/trunk/source/Target/ThreadPlanStepInRange.cpp lldb/trunk/source/Target/ThreadPlanStepRange.cpp Modified: lldb/trunk/include/lldb/Target/ThreadPlanStepInRange.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/ThreadPlanStepInRange.h?rev=114055&r1=114054&r2=114055&view=diff ============================================================================== --- lldb/trunk/include/lldb/Target/ThreadPlanStepInRange.h (original) +++ lldb/trunk/include/lldb/Target/ThreadPlanStepInRange.h Wed Sep 15 19:58:09 2010 @@ -73,6 +73,8 @@ static uint32_t s_default_flag_values; std::auto_ptr m_avoid_regexp_ap; + bool m_step_past_prologue; // FIXME: For now hard-coded to true, we could put a switch in for this if there's + // demand for that. DISALLOW_COPY_AND_ASSIGN (ThreadPlanStepInRange); Modified: lldb/trunk/source/Target/ThreadPlanStepInRange.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/ThreadPlanStepInRange.cpp?rev=114055&r1=114054&r2=114055&view=diff ============================================================================== --- lldb/trunk/source/Target/ThreadPlanStepInRange.cpp (original) +++ lldb/trunk/source/Target/ThreadPlanStepInRange.cpp Wed Sep 15 19:58:09 2010 @@ -18,6 +18,7 @@ #include "lldb/Core/Log.h" #include "lldb/Core/Stream.h" #include "lldb/Symbol/Symbol.h" +#include "lldb/Symbol/Function.h" #include "lldb/Target/Process.h" #include "lldb/Target/RegisterContext.h" #include "lldb/Target/Thread.h" @@ -43,10 +44,10 @@ lldb::RunMode stop_others ) : ThreadPlanStepRange (ThreadPlan::eKindStepInRange, "Step Range stepping in", thread, range, addr_context, stop_others), - ThreadPlanShouldStopHere (this, ThreadPlanStepInRange::DefaultShouldStopHereCallback, NULL) + ThreadPlanShouldStopHere (this, ThreadPlanStepInRange::DefaultShouldStopHereCallback, NULL), + m_step_past_prologue (true) { SetFlagsToDefault (); - // SetAvoidRegexp("^std\\:\\:.*"); } ThreadPlanStepInRange::~ThreadPlanStepInRange () @@ -125,8 +126,46 @@ if (!new_plan && FrameIsYounger()) new_plan = InvokeShouldStopHereCallback(); - if (new_plan == NULL) + // If we've stepped in and we are going to stop here, check to see if we were asked to + // run past the prologue, and if so do that. + + if (new_plan == NULL && FrameIsYounger() && m_step_past_prologue) { + lldb::StackFrameSP curr_frame = m_thread.GetStackFrameAtIndex(0); + if (curr_frame) + { + size_t bytes_to_skip = 0; + lldb::addr_t curr_addr = m_thread.GetRegisterContext()->GetPC(); + Address func_start_address; + + SymbolContext sc = curr_frame->GetSymbolContext (eSymbolContextFunction | eSymbolContextSymbol); + + if (sc.function) + { + func_start_address = sc.function->GetAddressRange().GetBaseAddress(); + if (curr_addr == func_start_address.GetLoadAddress(m_thread.CalculateTarget())) + bytes_to_skip = sc.function->GetPrologueByteSize(); + } + else if (sc.symbol) + { + func_start_address = sc.symbol->GetValue(); + if (curr_addr == func_start_address.GetLoadAddress(m_thread.CalculateTarget())) + bytes_to_skip = sc.symbol->GetPrologueByteSize(); + } + + if (bytes_to_skip != 0) + { + func_start_address.Slide (bytes_to_skip); + if (log) + log->Printf ("Pushing past prologue "); + + new_plan = m_thread.QueueThreadPlanForRunToAddress(false, func_start_address,true); + } + } + } + + if (new_plan == NULL) + { m_no_more_plans = true; SetPlanComplete(); return true; Modified: lldb/trunk/source/Target/ThreadPlanStepRange.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/ThreadPlanStepRange.cpp?rev=114055&r1=114054&r2=114055&view=diff ============================================================================== --- lldb/trunk/source/Target/ThreadPlanStepRange.cpp (original) +++ lldb/trunk/source/Target/ThreadPlanStepRange.cpp Wed Sep 15 19:58:09 2010 @@ -159,6 +159,10 @@ ThreadPlanStepRange::FrameIsYounger () { Log *log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_STEP); + + // FIXME: Might be better to do this by storing the FrameID we started in and seeing if that is still above + // us on the stack. Counting the whole stack could be expensive. + uint32_t current_depth = m_thread.GetStackFrameCount(); if (current_depth == m_stack_depth) { From johnny.chen at apple.com Wed Sep 15 20:53:04 2010 From: johnny.chen at apple.com (Johnny Chen) Date: Thu, 16 Sep 2010 01:53:04 -0000 Subject: [Lldb-commits] [lldb] r114058 - in /lldb/trunk/test: lldbtest.py persistent_variables/Makefile persistent_variables/TestPersistentVariables.py persistent_variables/main.c plugins/darwin.py settings/TestSettings.py Message-ID: <20100916015304.698B12A6C12C@llvm.org> Author: johnny Date: Wed Sep 15 20:53:04 2010 New Revision: 114058 URL: http://llvm.org/viewvc/llvm-project?rev=114058&view=rev Log: Provided a mechanism for the test class to cleanup after itself once it's done. This will remove the confusion experienced when previous test runs left some files (both intermediate or by-product as a result of the test). lldbtest.TestBase defines a classmethod tearDownClass(cls) which invokes the platform-specific cleanup() function as defined by the plugin; after that, it invokes a subclass-specific function classCleanup(cls) if defined; and, finally, it restores the old working directory. An example of classCleanup(cls) is in settings/TestSettings.py: @classmethod def classCleanup(cls): system(["/bin/sh", "-c", "rm output.txt"]) where it deletes the by-product "output.txt" as a result of running a.out. Added: lldb/trunk/test/persistent_variables/Makefile lldb/trunk/test/persistent_variables/main.c Modified: lldb/trunk/test/lldbtest.py lldb/trunk/test/persistent_variables/TestPersistentVariables.py lldb/trunk/test/plugins/darwin.py lldb/trunk/test/settings/TestSettings.py Modified: lldb/trunk/test/lldbtest.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/lldbtest.py?rev=114058&r1=114057&r2=114058&view=diff ============================================================================== --- lldb/trunk/test/lldbtest.py (original) +++ lldb/trunk/test/lldbtest.py Wed Sep 15 20:53:04 2010 @@ -271,20 +271,47 @@ # Can be overridden by the LLDB_TIME_WAIT environment variable. timeWait = 1.0; - def setUp(self): - #import traceback - #traceback.print_stack() + # Keep track of the old current working directory. + oldcwd = None + @classmethod + def setUpClass(cls): # Fail fast if 'mydir' attribute is not overridden. - if not self.mydir or len(self.mydir) == 0: + if not cls.mydir or len(cls.mydir) == 0: raise Exception("Subclasses must override the 'mydir' attribute.") # Save old working directory. - self.oldcwd = os.getcwd() + cls.oldcwd = os.getcwd() # Change current working directory if ${LLDB_TEST} is defined. # See also dotest.py which sets up ${LLDB_TEST}. if ("LLDB_TEST" in os.environ): - os.chdir(os.path.join(os.environ["LLDB_TEST"], self.mydir)); + if traceAlways: + print "Change dir to:", os.path.join(os.environ["LLDB_TEST"], cls.mydir) + os.chdir(os.path.join(os.environ["LLDB_TEST"], cls.mydir)) + + @classmethod + def tearDownClass(cls): + """Do class-wide cleanup.""" + + # First, let's do the platform-specific cleanup. + module = __import__(sys.platform) + if not module.cleanup(): + raise Exception("Don't know how to do cleanup") + + # Subclass might have specific cleanup function defined. + if getattr(cls, "classCleanup", None): + if traceAlways: + print "Call class-specific cleanup function for class:", cls + cls.classCleanup() + + # Restore old working directory. + if traceAlways: + print "Restore dir to:", cls.oldcwd + os.chdir(cls.oldcwd) + + def setUp(self): + #import traceback + #traceback.print_stack() if "LLDB_MAX_LAUNCH_COUNT" in os.environ: self.maxLaunchCount = int(os.environ["LLDB_MAX_LAUNCH_COUNT"]) @@ -330,9 +357,6 @@ del self.dbg - # Restore old working directory. - os.chdir(self.oldcwd) - def runCmd(self, cmd, msg=None, check=True, trace=False, setCookie=True): """ Ask the command interpreter to handle the command and then check its Added: lldb/trunk/test/persistent_variables/Makefile URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/persistent_variables/Makefile?rev=114058&view=auto ============================================================================== --- lldb/trunk/test/persistent_variables/Makefile (added) +++ lldb/trunk/test/persistent_variables/Makefile Wed Sep 15 20:53:04 2010 @@ -0,0 +1,5 @@ +LEVEL = ../make + +C_SOURCES := main.c + +include $(LEVEL)/Makefile.rules Modified: lldb/trunk/test/persistent_variables/TestPersistentVariables.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/persistent_variables/TestPersistentVariables.py?rev=114058&r1=114057&r2=114058&view=diff ============================================================================== --- lldb/trunk/test/persistent_variables/TestPersistentVariables.py (original) +++ lldb/trunk/test/persistent_variables/TestPersistentVariables.py Wed Sep 15 20:53:04 2010 @@ -13,7 +13,9 @@ def test_persistent_variables(self): """Test that lldb persistent variables works correctly.""" - self.runCmd("file ../array_types/a.out", CURRENT_EXECUTABLE_SET) + self.buildDefault() + + self.runCmd("file a.out", CURRENT_EXECUTABLE_SET) self.runCmd("breakpoint set --name main") Added: lldb/trunk/test/persistent_variables/main.c URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/persistent_variables/main.c?rev=114058&view=auto ============================================================================== --- lldb/trunk/test/persistent_variables/main.c (added) +++ lldb/trunk/test/persistent_variables/main.c Wed Sep 15 20:53:04 2010 @@ -0,0 +1,13 @@ +//===-- main.c --------------------------------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +int main (int argc, char const *argv[]) +{ + return 0; +} Modified: lldb/trunk/test/plugins/darwin.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/plugins/darwin.py?rev=114058&r1=114057&r2=114058&view=diff ============================================================================== --- lldb/trunk/test/plugins/darwin.py (original) +++ lldb/trunk/test/plugins/darwin.py Wed Sep 15 20:53:04 2010 @@ -50,3 +50,11 @@ # True signifies that we can handle building dsym. return True + +def cleanup(): + """Do class-wide cleanup after the test.""" + if os.path.isfile("Makefile"): + lldbtest.system(["/bin/sh", "-c", "make clean"]) + + # True signifies that we can handle building dsym. + return True Modified: lldb/trunk/test/settings/TestSettings.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/settings/TestSettings.py?rev=114058&r1=114057&r2=114058&view=diff ============================================================================== --- lldb/trunk/test/settings/TestSettings.py (original) +++ lldb/trunk/test/settings/TestSettings.py Wed Sep 15 20:53:04 2010 @@ -11,6 +11,10 @@ mydir = "settings" + @classmethod + def classCleanup(cls): + system(["/bin/sh", "-c", "rm output.txt"]) + def test_set_prompt(self): """Test that 'set prompt' actually changes the prompt.""" @@ -62,7 +66,7 @@ self.runCmd("run", RUN_SUCCEEDED) # Read the output file produced by running the program. - output = open('/tmp/output.txt', 'r').read() + output = open('output.txt', 'r').read() self.assertTrue(output.startswith("argv[1] matches") and output.find("argv[2] matches") > 0 and From johnny.chen at apple.com Thu Sep 16 10:44:23 2010 From: johnny.chen at apple.com (Johnny Chen) Date: Thu, 16 Sep 2010 15:44:23 -0000 Subject: [Lldb-commits] [lldb] r114081 - in /lldb/trunk/test: conditional_break/conditional_break.py dotest.py Message-ID: <20100916154423.A8C322A6C12C@llvm.org> Author: johnny Date: Thu Sep 16 10:44:23 2010 New Revision: 114081 URL: http://llvm.org/viewvc/llvm-project?rev=114081&view=rev Log: Added some comments. Modified: lldb/trunk/test/conditional_break/conditional_break.py lldb/trunk/test/dotest.py Modified: lldb/trunk/test/conditional_break/conditional_break.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/conditional_break/conditional_break.py?rev=114081&r1=114080&r2=114081&view=diff ============================================================================== --- lldb/trunk/test/conditional_break/conditional_break.py (original) +++ lldb/trunk/test/conditional_break/conditional_break.py Thu Sep 16 10:44:23 2010 @@ -3,15 +3,27 @@ import lldbutil def stop_if_called_from_a(): + # lldb.debugger_unique_id stores the id of the debugger associated with us. dbg = lldb.SBDebugger.FindDebuggerWithID(lldb.debugger_unique_id) + + # Perform synchronous interaction with the debugger. dbg.SetAsync(False) + + # Get the command interpreter. ci = dbg.GetCommandInterpreter() + + # And the result object for ci interaction. res = lldb.SBCommandReturnObject() + # Retrieve the target, process, and the only thread. target = dbg.GetSelectedTarget() process = target.GetProcess() thread = process.GetThreadAtIndex(0) + # We check the call frames in order to stop only when the immediate caller + # of the leaf function c() is a(). If it's not the right caller, we ask the + # command interpreter to continue execution. + print >> sys.stderr, "Checking call frames..." lldbutil.PrintStackTrace(thread) if thread.GetNumFrames() >= 2: Modified: lldb/trunk/test/dotest.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/dotest.py?rev=114081&r1=114080&r2=114081&view=diff ============================================================================== --- lldb/trunk/test/dotest.py (original) +++ lldb/trunk/test/dotest.py Thu Sep 16 10:44:23 2010 @@ -12,6 +12,12 @@ To specify the directories where "Test*.py" python test scripts are located, you need to pass in a list of directory names. By default, the current working directory is searched if nothing is specified on the command line. + +Type: + +./dotest.py -h + +for available options. """ import os, signal, sys, time From benny.kra at googlemail.com Thu Sep 16 11:07:21 2010 From: benny.kra at googlemail.com (Benjamin Kramer) Date: Thu, 16 Sep 2010 16:07:21 -0000 Subject: [Lldb-commits] [lldb] r114083 - in /lldb/trunk: include/lldb/Symbol/UnwindPlan.h source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp Message-ID: <20100916160721.BDBE62A6C12C@llvm.org> Author: d0k Date: Thu Sep 16 11:07:21 2010 New Revision: 114083 URL: http://llvm.org/viewvc/llvm-project?rev=114083&view=rev Log: Unbreak build, you can't take a pointer from a "register" variable. Most compilers ignore this keyword anyways. Also remove a typedef that typedefs nothing. Modified: lldb/trunk/include/lldb/Symbol/UnwindPlan.h lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp Modified: lldb/trunk/include/lldb/Symbol/UnwindPlan.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Symbol/UnwindPlan.h?rev=114083&r1=114082&r2=114083&view=diff ============================================================================== --- lldb/trunk/include/lldb/Symbol/UnwindPlan.h (original) +++ lldb/trunk/include/lldb/Symbol/UnwindPlan.h Thu Sep 16 11:07:21 2010 @@ -44,7 +44,7 @@ { public: - typedef enum RestoreType + enum RestoreType { unspecified, // not specified, we may be able to assume this // is the same register. gcc doesn't specify all Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp?rev=114083&r1=114082&r2=114083&view=diff ============================================================================== --- lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp (original) +++ lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp Thu Sep 16 11:07:21 2010 @@ -119,7 +119,7 @@ if (abbrCode) { - register uint32_t offset = *offset_ptr; + uint32_t offset = *offset_ptr; m_abbrevDecl = cu->GetAbbreviations()->GetAbbreviationDeclaration(abbrCode); From benny.kra at googlemail.com Thu Sep 16 11:07:31 2010 From: benny.kra at googlemail.com (Benjamin Kramer) Date: Thu, 16 Sep 2010 16:07:31 -0000 Subject: [Lldb-commits] [lldb] r114084 - /lldb/trunk/include/lldb/Core/Debugger.h Message-ID: <20100916160731.8E4EF2A6C12C@llvm.org> Author: d0k Date: Thu Sep 16 11:07:31 2010 New Revision: 114084 URL: http://llvm.org/viewvc/llvm-project?rev=114084&view=rev Log: Make this method static. Bad things(tm) happen when a non-static method is called in a constructor's initializer list. Modified: lldb/trunk/include/lldb/Core/Debugger.h Modified: lldb/trunk/include/lldb/Core/Debugger.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/Debugger.h?rev=114084&r1=114083&r2=114084&view=diff ============================================================================== --- lldb/trunk/include/lldb/Core/Debugger.h (original) +++ lldb/trunk/include/lldb/Core/Debugger.h Thu Sep 16 11:07:31 2010 @@ -77,7 +77,7 @@ bool ValidTermWidthValue (const char *value, Error err); - const ConstString + static const ConstString CreateInstanceName (); static const ConstString & From benny.kra at googlemail.com Thu Sep 16 11:23:16 2010 From: benny.kra at googlemail.com (Benjamin Kramer) Date: Thu, 16 Sep 2010 16:23:16 -0000 Subject: [Lldb-commits] [lldb] r114087 - in /lldb/trunk/include/lldb/Target: Process.h Thread.h Message-ID: <20100916162316.C890F2A6C12C@llvm.org> Author: d0k Date: Thu Sep 16 11:23:16 2010 New Revision: 114087 URL: http://llvm.org/viewvc/llvm-project?rev=114087&view=rev Log: Turns out CreateInstanceName is duplicated in two other places. Make them static too, sigh. Modified: lldb/trunk/include/lldb/Target/Process.h lldb/trunk/include/lldb/Target/Thread.h Modified: lldb/trunk/include/lldb/Target/Process.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/Process.h?rev=114087&r1=114086&r2=114087&view=diff ============================================================================== --- lldb/trunk/include/lldb/Target/Process.h (original) +++ lldb/trunk/include/lldb/Target/Process.h Thu Sep 16 11:23:16 2010 @@ -81,7 +81,7 @@ CopyInstanceSettings (const lldb::InstanceSettingsSP &new_settings, bool pending); - const ConstString + static const ConstString CreateInstanceName (); static const ConstString & Modified: lldb/trunk/include/lldb/Target/Thread.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/Thread.h?rev=114087&r1=114086&r2=114087&view=diff ============================================================================== --- lldb/trunk/include/lldb/Target/Thread.h (original) +++ lldb/trunk/include/lldb/Target/Thread.h Thu Sep 16 11:23:16 2010 @@ -70,7 +70,7 @@ CopyInstanceSettings (const lldb::InstanceSettingsSP &new_settings, bool pending); - const ConstString + static const ConstString CreateInstanceName (); private: From gclayton at apple.com Thu Sep 16 12:09:23 2010 From: gclayton at apple.com (Greg Clayton) Date: Thu, 16 Sep 2010 17:09:23 -0000 Subject: [Lldb-commits] [lldb] r114092 - /lldb/trunk/source/Interpreter/CommandInterpreter.cpp Message-ID: <20100916170923.D6CEE2A6C12C@llvm.org> Author: gclayton Date: Thu Sep 16 12:09:23 2010 New Revision: 114092 URL: http://llvm.org/viewvc/llvm-project?rev=114092&view=rev Log: Added default more aliases to ease gdb converts: "b" is now aliased to "regexp-break" "p" is now aliased to "frame variable" "print" is now aliased to "frame variable" 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=114092&r1=114091&r2=114092&view=diff ============================================================================== --- lldb/trunk/source/Interpreter/CommandInterpreter.cpp (original) +++ lldb/trunk/source/Interpreter/CommandInterpreter.cpp Thu Sep 16 12:09:23 2010 @@ -86,7 +86,7 @@ result.Clear(); HandleCommand ("command alias continue process continue", false, result); result.Clear(); HandleCommand ("command alias expr expression", false, result); result.Clear(); HandleCommand ("command alias exit quit", false, result); - result.Clear(); HandleCommand ("command alias b breakpoint", false, result); + result.Clear(); HandleCommand ("command alias b regexp-break", false, result); result.Clear(); HandleCommand ("command alias bt thread backtrace", false, result); result.Clear(); HandleCommand ("command alias si thread step-inst", false, result); result.Clear(); HandleCommand ("command alias step thread step-in", false, result); @@ -97,6 +97,8 @@ result.Clear(); HandleCommand ("command alias x memory read", false, result); result.Clear(); HandleCommand ("command alias l source list", false, result); result.Clear(); HandleCommand ("command alias list source list", false, result); + result.Clear(); HandleCommand ("command alias p frame variable", false, result); + result.Clear(); HandleCommand ("command alias print frame variable", false, result); } const char * From johnny.chen at apple.com Thu Sep 16 12:11:30 2010 From: johnny.chen at apple.com (Johnny Chen) Date: Thu, 16 Sep 2010 17:11:30 -0000 Subject: [Lldb-commits] [lldb] r114094 - /lldb/trunk/test/dotest.py Message-ID: <20100916171130.BC2132A6C12C@llvm.org> Author: johnny Date: Thu Sep 16 12:11:30 2010 New Revision: 114094 URL: http://llvm.org/viewvc/llvm-project?rev=114094&view=rev Log: Cleaned up the option processing logic and added a '-i' option to ignore the build tree relative search path in order to locate the lldb.py module. When '-i' is present, the test driver relies on the PYTHONPATH environment variable to locate the lldb.py module. Modified: lldb/trunk/test/dotest.py Modified: lldb/trunk/test/dotest.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/dotest.py?rev=114094&r1=114093&r2=114094&view=diff ============================================================================== --- lldb/trunk/test/dotest.py (original) +++ lldb/trunk/test/dotest.py Thu Sep 16 12:11:30 2010 @@ -48,6 +48,9 @@ # Delay startup in order for the debugger to attach. delay = False +# Ignore the build search path relative to this script to locate the lldb.py module. +ignore = False + # Default verbosity is 0. verbose = 0 @@ -67,6 +70,8 @@ where options: -h : print this help message and exit (also --help) -d : delay startup for 10 seconds (in order for the debugger to attach) +-i : ignore (don't bailout) if 'lldb.py' module cannot be located in the build + tree relative to this script; use PYTHONPATH to locate the module -t : trace lldb command execution and result -v : do verbose mode of unittest framework @@ -75,7 +80,9 @@ if empty, search from the curret working directory, instead Running of this script also sets up the LLDB_TEST environment variable so that -individual test cases can locate their supporting files correctly. +individual test cases can locate their supporting files correctly. The script +tries to set up Python's search paths for modules by looking at the build tree +relative to this script. See also the '-i' option. Environment variables related to loggings: @@ -88,6 +95,52 @@ """ +def parseOptionsAndInitTestdirs(): + """Initialize the list of directories containing our unittest scripts. + + '-h/--help as the first option prints out usage info and exit the program. + """ + + global delay + global inore + global verbose + global testdirs + + if len(sys.argv) == 1: + return + + # Process possible trace and/or verbose flag, among other things. + index = 1 + for i in range(1, len(sys.argv)): + if not sys.argv[index].startswith('-'): + # End of option processing. + break + + if sys.argv[index].find('-h') != -1: + usage() + sys.exit(0) + elif sys.argv[index].startswith('-d'): + delay = True + index += 1 + elif sys.argv[index].startswith('-i'): + ignore = True + index += 1 + elif sys.argv[index].startswith('-t'): + os.environ["LLDB_COMMAND_TRACE"] = "YES" + index += 1 + elif sys.argv[index].startswith('-v'): + verbose = 2 + index += 1 + else: + print "Unknown option: ", sys.argv[index] + usage() + sys.exit(0) + + # Gather all the dirs passed on the command line. + if len(sys.argv) > index: + testdirs = map(os.path.abspath, sys.argv[index:]) + + def setupSysPath(): """Add LLDB.framework/Resources/Python to the search paths for modules.""" @@ -100,6 +153,16 @@ os.environ["LLDB_TEST"] = scriptPath pluginPath = os.path.join(scriptPath, 'plugins') + # Append script dir and plugin dir to the sys.path. + sys.path.append(scriptPath) + sys.path.append(pluginPath) + + global ignore + + # The '-i' option is used to skip looking for lldb.py in the build tree. + if ignore: + return + base = os.path.abspath(os.path.join(scriptPath, os.pardir)) dbgPath = os.path.join(base, 'build', 'Debug', 'LLDB.framework', 'Resources', 'Python') @@ -121,48 +184,8 @@ print relPath + ', or ' + baiPath sys.exit(-1) - sys.path.append(lldbPath) - sys.path.append(scriptPath) - sys.path.append(pluginPath) - - -def initTestdirs(): - """Initialize the list of directories containing our unittest scripts. - - '-h/--help as the first option prints out usage info and exit the program. - """ - - global delay - global verbose - global testdirs - - if len(sys.argv) == 1: - pass - elif sys.argv[1].find('-h') != -1: - # Print usage info and exit. - usage() - sys.exit(0) - else: - # Process possible trace and/or verbose flag. - index = 1 - for i in range(1, len(sys.argv)): - if not sys.argv[index].startswith('-'): - # End of option processing. - break - - if sys.argv[index].startswith('-d'): - delay = True - index += 1 - elif sys.argv[index].startswith('-t'): - os.environ["LLDB_COMMAND_TRACE"] = "YES" - index += 1 - elif sys.argv[index].startswith('-v'): - verbose = 2 - index += 1 - - # Gather all the dirs passed on the command line. - if len(sys.argv) > index: - testdirs = map(os.path.abspath, sys.argv[index:]) + # This is to locate the lldb.py module. Insert it right after sys.path[0]. + sys.path[1:1] = [lldbPath] def visit(prefix, dir, names): @@ -183,12 +206,12 @@ # -# Start the actions by first setting up the module search path for lldb, -# followed by initializing the test directories, and then walking the directory -# trees, while collecting the tests into our test suite. +# Start the actions by first parsing the options while setting up the test +# directories, followed by setting up the search paths for lldb utilities; +# then, we walk the directory trees and collect the tests into our test suite. # +parseOptionsAndInitTestdirs() setupSysPath() -initTestdirs() # # If '-d' is specified, do a delay of 10 seconds for the debugger to attach. From johnny.chen at apple.com Thu Sep 16 12:37:05 2010 From: johnny.chen at apple.com (Johnny Chen) Date: Thu, 16 Sep 2010 17:37:05 -0000 Subject: [Lldb-commits] [lldb] r114095 - in /lldb/trunk/include/lldb: Core/Debugger.h Target/Process.h Target/Thread.h Message-ID: <20100916173705.E68162A6C12C@llvm.org> Author: johnny Date: Thu Sep 16 12:37:05 2010 New Revision: 114095 URL: http://llvm.org/viewvc/llvm-project?rev=114095&view=rev Log: Undo 114084 and 114087 to unbreak the build for the time being. Modified: lldb/trunk/include/lldb/Core/Debugger.h lldb/trunk/include/lldb/Target/Process.h lldb/trunk/include/lldb/Target/Thread.h Modified: lldb/trunk/include/lldb/Core/Debugger.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/Debugger.h?rev=114095&r1=114094&r2=114095&view=diff ============================================================================== --- lldb/trunk/include/lldb/Core/Debugger.h (original) +++ lldb/trunk/include/lldb/Core/Debugger.h Thu Sep 16 12:37:05 2010 @@ -77,7 +77,7 @@ bool ValidTermWidthValue (const char *value, Error err); - static const ConstString + const ConstString CreateInstanceName (); static const ConstString & Modified: lldb/trunk/include/lldb/Target/Process.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/Process.h?rev=114095&r1=114094&r2=114095&view=diff ============================================================================== --- lldb/trunk/include/lldb/Target/Process.h (original) +++ lldb/trunk/include/lldb/Target/Process.h Thu Sep 16 12:37:05 2010 @@ -81,7 +81,7 @@ CopyInstanceSettings (const lldb::InstanceSettingsSP &new_settings, bool pending); - static const ConstString + const ConstString CreateInstanceName (); static const ConstString & Modified: lldb/trunk/include/lldb/Target/Thread.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/Thread.h?rev=114095&r1=114094&r2=114095&view=diff ============================================================================== --- lldb/trunk/include/lldb/Target/Thread.h (original) +++ lldb/trunk/include/lldb/Target/Thread.h Thu Sep 16 12:37:05 2010 @@ -70,7 +70,7 @@ CopyInstanceSettings (const lldb::InstanceSettingsSP &new_settings, bool pending); - static const ConstString + const ConstString CreateInstanceName (); private: From benny.kra at googlemail.com Thu Sep 16 12:46:39 2010 From: benny.kra at googlemail.com (Benjamin Kramer) Date: Thu, 16 Sep 2010 19:46:39 +0200 Subject: [Lldb-commits] [lldb] r114095 - in /lldb/trunk/include/lldb: Core/Debugger.h Target/Process.h Target/Thread.h In-Reply-To: <20100916173705.E68162A6C12C@llvm.org> References: <20100916173705.E68162A6C12C@llvm.org> Message-ID: On 16.09.2010, at 19:37, Johnny Chen wrote: > Author: johnny > Date: Thu Sep 16 12:37:05 2010 > New Revision: 114095 > > URL: http://llvm.org/viewvc/llvm-project?rev=114095&view=rev > Log: > Undo 114084 and 114087 to unbreak the build for the time being. Sorry for this, I tested with clang++ only, which accepted the code without any complaints. However, calling virtual methods in the ctor will blow up horribly. I can't even start lldb on the command line without getting a segfault now. From ctice at apple.com Thu Sep 16 12:54:57 2010 From: ctice at apple.com (Caroline Tice) Date: Thu, 16 Sep 2010 10:54:57 -0700 Subject: [Lldb-commits] [lldb] r114095 - in /lldb/trunk/include/lldb: Core/Debugger.h Target/Process.h Target/Thread.h In-Reply-To: References: <20100916173705.E68162A6C12C@llvm.org> Message-ID: <1F6A7075-3061-4F1A-A288-E719C6293879@apple.com> Okay I will work on re-doing the code so it doesn't have to do that. For the record, the code as is works just fine on Mac OS X; I had no idea it would die so horribly on other platforms. On Sep 16, 2010, at 10:46 AM, Benjamin Kramer wrote: > > On 16.09.2010, at 19:37, Johnny Chen wrote: > >> Author: johnny >> Date: Thu Sep 16 12:37:05 2010 >> New Revision: 114095 >> >> URL: http://llvm.org/viewvc/llvm-project?rev=114095&view=rev >> Log: >> Undo 114084 and 114087 to unbreak the build for the time being. > > Sorry for this, I tested with clang++ only, which accepted the code without any complaints. > > However, calling virtual methods in the ctor will blow up horribly. I can't even start lldb > on the command line without getting a segfault now. > _______________________________________________ > 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 Thu Sep 16 13:26:07 2010 From: johnny.chen at apple.com (Johnny Chen) Date: Thu, 16 Sep 2010 18:26:07 -0000 Subject: [Lldb-commits] [lldb] r114102 - in /lldb/trunk/test: lldbtest.py settings/TestSettings.py Message-ID: <20100916182607.22CAA2A6C12C@llvm.org> Author: johnny Date: Thu Sep 16 13:26:06 2010 New Revision: 114102 URL: http://llvm.org/viewvc/llvm-project?rev=114102&view=rev Log: Added a test case for the settings command which sets process.output-path and checks that the launched process writes its standard output there. Modified: lldb/trunk/test/lldbtest.py lldb/trunk/test/settings/TestSettings.py Modified: lldb/trunk/test/lldbtest.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/lldbtest.py?rev=114102&r1=114101&r2=114102&view=diff ============================================================================== --- lldb/trunk/test/lldbtest.py (original) +++ lldb/trunk/test/lldbtest.py Thu Sep 16 13:26:06 2010 @@ -247,7 +247,7 @@ cmd = kwargs.get("args") if cmd is None: cmd = popenargs[0] - raise CalledProcessError(retcode, cmd, output=output) + raise CalledProcessError(retcode, cmd) return output Modified: lldb/trunk/test/settings/TestSettings.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/settings/TestSettings.py?rev=114102&r1=114101&r2=114102&view=diff ============================================================================== --- lldb/trunk/test/settings/TestSettings.py (original) +++ lldb/trunk/test/settings/TestSettings.py Thu Sep 16 13:26:06 2010 @@ -14,6 +14,7 @@ @classmethod def classCleanup(cls): system(["/bin/sh", "-c", "rm output.txt"]) + #system(["/bin/sh", "-c", "rm stdout.txt"]) def test_set_prompt(self): """Test that 'set prompt' actually changes the prompt.""" @@ -73,6 +74,29 @@ output.find("argv[3] matches") > 0 and output.find("Environment variable 'MY_ENV_VAR' successfully passed.") > 0) + @unittest2.expectedFailure + # rdar://problem/8435794 + # settings set process.output-path does not seem to work + def test_set_output_path(self): + """Test that setting process.output-path for the launched process works.""" + self.buildDefault() + + exe = os.path.join(os.getcwd(), "a.out") + self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) + + # Set the output-path and verify it is set. + self.runCmd("settings set process.output-path 'stdout.txt'") + self.expect("settings show process.output-path", + startstr = "process.output-path (string) = 'stdout.txt'") + + self.runCmd("run", RUN_SUCCEEDED) + + # Read the output file produced by running the program. + output = open('stdout.txt', 'r').read() + + self.assertTrue( + output.startswith("This message should go to standard out.")) + if __name__ == '__main__': import atexit From ctice at apple.com Thu Sep 16 14:05:55 2010 From: ctice at apple.com (Caroline Tice) Date: Thu, 16 Sep 2010 19:05:55 -0000 Subject: [Lldb-commits] [lldb] r114107 - in /lldb/trunk: include/lldb/Core/UserSettingsController.h source/Core/Debugger.cpp source/Core/UserSettingsController.cpp source/Target/Process.cpp source/Target/Thread.cpp Message-ID: <20100916190555.DA6792A6C12C@llvm.org> Author: ctice Date: Thu Sep 16 14:05:55 2010 New Revision: 114107 URL: http://llvm.org/viewvc/llvm-project?rev=114107&view=rev Log: Fix issues with CreateInstanceName, a virtual function, being called in an initializer. Modified: lldb/trunk/include/lldb/Core/UserSettingsController.h lldb/trunk/source/Core/Debugger.cpp lldb/trunk/source/Core/UserSettingsController.cpp lldb/trunk/source/Target/Process.cpp lldb/trunk/source/Target/Thread.cpp Modified: lldb/trunk/include/lldb/Core/UserSettingsController.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/UserSettingsController.h?rev=114107&r1=114106&r2=114107&view=diff ============================================================================== --- lldb/trunk/include/lldb/Core/UserSettingsController.h (original) +++ lldb/trunk/include/lldb/Core/UserSettingsController.h Thu Sep 16 14:05:55 2010 @@ -392,6 +392,9 @@ static const ConstString & GetDefaultName (); + static const ConstString & + InvalidName (); + protected: UserSettingsController &m_owner; Modified: lldb/trunk/source/Core/Debugger.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/Debugger.cpp?rev=114107&r1=114106&r2=114107&view=diff ============================================================================== --- lldb/trunk/source/Core/Debugger.cpp (original) +++ lldb/trunk/source/Core/Debugger.cpp Thu Sep 16 14:05:55 2010 @@ -639,13 +639,20 @@ DebuggerInstanceSettings::DebuggerInstanceSettings (UserSettingsController &owner, bool live_instance, const char *name) : - InstanceSettings (owner, (name == NULL ? CreateInstanceName ().AsCString() : name), live_instance), + InstanceSettings (owner, (name == NULL ? InstanceSettings::InvalidName().AsCString() : name), live_instance), m_prompt (), m_script_lang () { // CopyInstanceSettings is a pure virtual function in InstanceSettings; it therefore cannot be called // until the vtables for DebuggerInstanceSettings are properly set up, i.e. AFTER all the initializers. // For this reason it has to be called here, rather than in the initializer or in the parent constructor. + // The same is true of CreateInstanceName(). + + if (GetInstanceName() == InstanceSettings::InvalidName()) + { + ChangeInstanceName (std::string (CreateInstanceName().AsCString())); + m_owner.RegisterInstanceSettings (this); + } if (live_instance) { Modified: lldb/trunk/source/Core/UserSettingsController.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/UserSettingsController.cpp?rev=114107&r1=114106&r2=114107&view=diff ============================================================================== --- lldb/trunk/source/Core/UserSettingsController.cpp (original) +++ lldb/trunk/source/Core/UserSettingsController.cpp Thu Sep 16 14:05:55 2010 @@ -2187,6 +2187,7 @@ m_instance_name (instance_name) { if ((m_instance_name != InstanceSettings::GetDefaultName()) + && (m_instance_name != InstanceSettings::InvalidName()) && live_instance) m_owner.RegisterInstanceSettings (this); } @@ -2205,6 +2206,14 @@ return g_default_settings_name; } +const ConstString & +InstanceSettings::InvalidName () +{ + static const ConstString g_invalid_name ("Invalid instance name"); + + return g_invalid_name; +} + void InstanceSettings::ChangeInstanceName (const std::string &new_instance_name) { Modified: lldb/trunk/source/Target/Process.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/Process.cpp?rev=114107&r1=114106&r2=114107&view=diff ============================================================================== --- lldb/trunk/source/Target/Process.cpp (original) +++ lldb/trunk/source/Target/Process.cpp Thu Sep 16 14:05:55 2010 @@ -1876,7 +1876,7 @@ ProcessInstanceSettings::ProcessInstanceSettings (UserSettingsController &owner, bool live_instance, const char *name) : - InstanceSettings (owner, (name == NULL ? CreateInstanceName().AsCString() : name), live_instance), + InstanceSettings (owner, (name == NULL ? InstanceSettings::InvalidName().AsCString() : name), live_instance), m_run_args (), m_env_vars (), m_input_path (), @@ -1888,6 +1888,13 @@ // CopyInstanceSettings is a pure virtual function in InstanceSettings; it therefore cannot be called // until the vtables for ProcessInstanceSettings are properly set up, i.e. AFTER all the initializers. // For this reason it has to be called here, rather than in the initializer or in the parent constructor. + // This is true for CreateInstanceName() too. + + if (GetInstanceName () == InstanceSettings::InvalidName()) + { + ChangeInstanceName (std::string (CreateInstanceName().AsCString())); + m_owner.RegisterInstanceSettings (this); + } if (live_instance) { Modified: lldb/trunk/source/Target/Thread.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/Thread.cpp?rev=114107&r1=114106&r2=114107&view=diff ============================================================================== --- lldb/trunk/source/Target/Thread.cpp (original) +++ lldb/trunk/source/Target/Thread.cpp Thu Sep 16 14:05:55 2010 @@ -967,12 +967,19 @@ //-------------------------------------------------------------- ThreadInstanceSettings::ThreadInstanceSettings (UserSettingsController &owner, bool live_instance, const char *name) : - InstanceSettings (owner, (name == NULL ? CreateInstanceName().AsCString() : name), live_instance), + InstanceSettings (owner, (name == NULL ? InstanceSettings::InvalidName().AsCString() : name), live_instance), m_avoid_regexp_ap () { // CopyInstanceSettings is a pure virtual function in InstanceSettings; it therefore cannot be called // until the vtables for ThreadInstanceSettings are properly set up, i.e. AFTER all the initializers. // For this reason it has to be called here, rather than in the initializer or in the parent constructor. + // This is true for CreateInstanceName() too. + + if (GetInstanceName() == InstanceSettings::InvalidName()) + { + ChangeInstanceName (std::string (CreateInstanceName().AsCString())); + m_owner.RegisterInstanceSettings (this); + } if (live_instance) { From scallanan at apple.com Thu Sep 16 15:01:08 2010 From: scallanan at apple.com (Sean Callanan) Date: Thu, 16 Sep 2010 20:01:08 -0000 Subject: [Lldb-commits] [lldb] r114110 - in /lldb/trunk: include/lldb/Symbol/ClangASTContext.h source/Symbol/ClangASTContext.cpp Message-ID: <20100916200108.9DCBB2A6C12C@llvm.org> Author: spyffe Date: Thu Sep 16 15:01:08 2010 New Revision: 114110 URL: http://llvm.org/viewvc/llvm-project?rev=114110&view=rev Log: Made AddFieldToRecordType a static method on ClangASTContext. Modified: lldb/trunk/include/lldb/Symbol/ClangASTContext.h lldb/trunk/source/Symbol/ClangASTContext.cpp Modified: lldb/trunk/include/lldb/Symbol/ClangASTContext.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Symbol/ClangASTContext.h?rev=114110&r1=114109&r2=114110&view=diff ============================================================================== --- lldb/trunk/include/lldb/Symbol/ClangASTContext.h (original) +++ lldb/trunk/include/lldb/Symbol/ClangASTContext.h Thu Sep 16 15:01:08 2010 @@ -153,14 +153,30 @@ clang::DeclContext *decl_ctx, lldb::LanguageType language); - bool - AddFieldToRecordType (void * record_qual_type, + static bool + AddFieldToRecordType (clang::ASTContext *ast_context, + void *record_qual_type, const char *name, - void * field_type, + void *field_type, lldb::AccessType access, uint32_t bitfield_bit_size); bool + AddFieldToRecordType (void *record_qual_type, + const char *name, + void *field_type, + lldb::AccessType access, + uint32_t bitfield_bit_size) + { + return ClangASTContext::AddFieldToRecordType(m_ast_context_ap.get(), + record_qual_type, + name, + field_type, + access, + bitfield_bit_size); + } + + bool FieldIsBitfield (clang::FieldDecl* field, uint32_t& bitfield_bit_size); @@ -184,13 +200,31 @@ bool isForwardDecl, bool isInternal); + static bool + AddObjCClassIVar (clang::ASTContext *ast_context, + void *class_opaque_type, + const char *name, + void *ivar_opaque_type, + lldb::AccessType access, + uint32_t bitfield_bit_size, + bool isSynthesized); + bool AddObjCClassIVar (void *class_opaque_type, const char *name, void *ivar_opaque_type, lldb::AccessType access, uint32_t bitfield_bit_size, - bool isSynthesized); + bool isSynthesized) + { + return ClangASTContext::AddObjCClassIVar (m_ast_context_ap.get(), + class_opaque_type, + name, + ivar_opaque_type, + access, + bitfield_bit_size, + isSynthesized); + } bool SetObjCSuperClass (void *class_clang_type, Modified: lldb/trunk/source/Symbol/ClangASTContext.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/ClangASTContext.cpp?rev=114110&r1=114109&r2=114110&view=diff ============================================================================== --- lldb/trunk/source/Symbol/ClangASTContext.cpp (original) +++ lldb/trunk/source/Symbol/ClangASTContext.cpp Thu Sep 16 15:01:08 2010 @@ -806,6 +806,7 @@ bool ClangASTContext::AddFieldToRecordType ( + clang::ASTContext *ast_context, void *record_clang_type, const char *name, void *field_type, @@ -816,8 +817,7 @@ if (record_clang_type == NULL || field_type == NULL) return false; - ASTContext *ast_context = getASTContext(); - IdentifierTable *identifier_table = getIdentifierTable(); + IdentifierTable *identifier_table = &ast_context->Idents; assert (ast_context != NULL); assert (identifier_table != NULL); @@ -866,7 +866,8 @@ if (objc_class_type) { bool isSynthesized = false; - ClangASTContext::AddObjCClassIVar (record_clang_type, + ClangASTContext::AddObjCClassIVar (ast_context, + record_clang_type, name, field_type, access, @@ -1080,6 +1081,7 @@ bool ClangASTContext::AddObjCClassIVar ( + clang::ASTContext *ast_context, void *class_opaque_type, const char *name, void *ivar_opaque_type, @@ -1091,8 +1093,7 @@ if (class_opaque_type == NULL || ivar_opaque_type == NULL) return false; - ASTContext *ast_context = getASTContext(); - IdentifierTable *identifier_table = getIdentifierTable(); + IdentifierTable *identifier_table = &ast_context->Idents; assert (ast_context != NULL); assert (identifier_table != NULL); From scallanan at apple.com Thu Sep 16 15:40:25 2010 From: scallanan at apple.com (Sean Callanan) Date: Thu, 16 Sep 2010 20:40:25 -0000 Subject: [Lldb-commits] [lldb] r114111 - in /lldb/trunk: include/lldb/Symbol/ClangASTContext.h source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp source/Symbol/ClangASTContext.cpp Message-ID: <20100916204025.9861D2A6C12C@llvm.org> Author: spyffe Date: Thu Sep 16 15:40:25 2010 New Revision: 114111 URL: http://llvm.org/viewvc/llvm-project?rev=114111&view=rev Log: Made CreateFunctionType static. Also fixed the spelling for CreateParameterDeclaration. Modified: lldb/trunk/include/lldb/Symbol/ClangASTContext.h lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp lldb/trunk/source/Symbol/ClangASTContext.cpp Modified: lldb/trunk/include/lldb/Symbol/ClangASTContext.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Symbol/ClangASTContext.h?rev=114111&r1=114110&r2=114111&view=diff ============================================================================== --- lldb/trunk/include/lldb/Symbol/ClangASTContext.h (original) +++ lldb/trunk/include/lldb/Symbol/ClangASTContext.h Thu Sep 16 15:40:25 2010 @@ -346,16 +346,32 @@ int storage, bool is_inline); + static void * + CreateFunctionType (clang::ASTContext *ast_context, + void *result_type, + void **args, + unsigned num_args, + bool is_variadic, + unsigned type_quals); + void * - CreateFunctionType (void * result_type, + CreateFunctionType (void *result_type, void **args, unsigned num_args, - bool isVariadic, - unsigned TypeQuals); + bool is_variadic, + unsigned type_quals) + { + return ClangASTContext::CreateFunctionType(m_ast_context_ap.get(), + result_type, + args, + num_args, + is_variadic, + type_quals); + } clang::ParmVarDecl * - CreateParmeterDeclaration (const char *name, - void * return_type, + CreateParameterDeclaration (const char *name, + void *param_type, int storage); void Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp?rev=114111&r1=114110&r2=114111&view=diff ============================================================================== --- lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp (original) +++ lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp Thu Sep 16 15:40:25 2010 @@ -1987,7 +1987,7 @@ { function_param_types.push_back (dc_type->GetOpaqueClangQualType()); - clang::ParmVarDecl *param_var_decl = type_list->GetClangASTContext().CreateParmeterDeclaration (name, dc_type->GetOpaqueClangQualType(), storage); + clang::ParmVarDecl *param_var_decl = type_list->GetClangASTContext().CreateParameterDeclaration (name, dc_type->GetOpaqueClangQualType(), storage); assert(param_var_decl); function_param_decls.push_back(param_var_decl); } Modified: lldb/trunk/source/Symbol/ClangASTContext.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/ClangASTContext.cpp?rev=114111&r1=114110&r2=114111&view=diff ============================================================================== --- lldb/trunk/source/Symbol/ClangASTContext.cpp (original) +++ lldb/trunk/source/Symbol/ClangASTContext.cpp Thu Sep 16 15:40:25 2010 @@ -2497,9 +2497,13 @@ } void * -ClangASTContext::CreateFunctionType (void *result_type, void **args, unsigned num_args, bool isVariadic, unsigned TypeQuals) +ClangASTContext::CreateFunctionType (clang::ASTContext *ast_context, + void *result_type, + void **args, + unsigned num_args, + bool is_variadic, + unsigned type_quals) { - ASTContext *ast_context = getASTContext(); assert (ast_context != NULL); std::vector qual_type_args; for (unsigned i=0; igetFunctionType(QualType::getFromOpaquePtr(result_type), qual_type_args.empty() ? NULL : &qual_type_args.front(), qual_type_args.size(), - isVariadic, - TypeQuals, + is_variadic, + type_quals, false, // hasExceptionSpec false, // hasAnyExceptionSpec, 0, // NumExs @@ -2519,7 +2523,7 @@ } ParmVarDecl * -ClangASTContext::CreateParmeterDeclaration (const char *name, void *return_type, int storage) +ClangASTContext::CreateParameterDeclaration (const char *name, void *param_type, int storage) { ASTContext *ast_context = getASTContext(); assert (ast_context != NULL); @@ -2527,7 +2531,7 @@ ast_context->getTranslationUnitDecl(), SourceLocation(), name && name[0] ? &ast_context->Idents.get(name) : NULL, - QualType::getFromOpaquePtr(return_type), + QualType::getFromOpaquePtr(param_type), NULL, (VarDecl::StorageClass)storage, (VarDecl::StorageClass)storage, From johnny.chen at apple.com Thu Sep 16 15:54:06 2010 From: johnny.chen at apple.com (Johnny Chen) Date: Thu, 16 Sep 2010 20:54:06 -0000 Subject: [Lldb-commits] [lldb] r114118 - in /lldb/trunk/test: foundation/Makefile foundation/TestObjCMethods.py foundation/main.m make/Makefile.rules Message-ID: <20100916205406.DB16D2A6C12C@llvm.org> Author: johnny Date: Thu Sep 16 15:54:06 2010 New Revision: 114118 URL: http://llvm.org/viewvc/llvm-project?rev=114118&view=rev Log: Added a simple test case to set breakpoints on objc class/instance methods. Modified Makefile.rules to allow for overwriting the ARCH make variable. Added: lldb/trunk/test/foundation/TestObjCMethods.py Modified: lldb/trunk/test/foundation/Makefile lldb/trunk/test/foundation/main.m lldb/trunk/test/make/Makefile.rules Modified: lldb/trunk/test/foundation/Makefile URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/foundation/Makefile?rev=114118&r1=114117&r2=114118&view=diff ============================================================================== --- lldb/trunk/test/foundation/Makefile (original) +++ lldb/trunk/test/foundation/Makefile Thu Sep 16 15:54:06 2010 @@ -1,125 +1,6 @@ -#---------------------------------------------------------------------- -# Fill in the source files to build -#---------------------------------------------------------------------- -C_SOURCES := -CXX_SOURCES := -OBJC_SOURCES :=main.m -OBJCXX_SOURCES := +LEVEL = ../make -# Uncomment line below for debugging shell commands -# SHELL = /bin/sh -x - -#---------------------------------------------------------------------- -# Change any build/tool options needed -#---------------------------------------------------------------------- -DS := /usr/bin/dsymutil -DSFLAGS = -CFLAGS ?=-arch x86_64 -g -O0 -CPLUSPLUSFLAGS +=$(CFLAGS) -CPPFLAGS +=$(CFLAGS) -LD = gcc +OBJC_SOURCES := main.m LDFLAGS = $(CFLAGS) -lobjc -framework Foundation -OBJECTS = -EXE=a.out -DSYM=$(EXE).dSYM - -#---------------------------------------------------------------------- -# Check if we have any C source files -#---------------------------------------------------------------------- -ifneq "$(strip $(C_SOURCES))" "" - OBJECTS +=$(strip $(C_SOURCES:.c=.o)) -endif - -#---------------------------------------------------------------------- -# Check if we have any C++ source files -#---------------------------------------------------------------------- -ifneq "$(strip $(CXX_SOURCES))" "" - OBJECTS +=$(strip $(CXX_SOURCES:.cpp=.o)) - LD = g++ -endif - -#---------------------------------------------------------------------- -# Check if we have any ObjC source files -#---------------------------------------------------------------------- -ifneq "$(strip $(OBJC_SOURCES))" "" - OBJECTS +=$(strip $(OBJC_SOURCES:.m=.o)) - LDFLAGS +=-lobjc -endif - -#---------------------------------------------------------------------- -# Check if we have any ObjC++ source files -#---------------------------------------------------------------------- -ifneq "$(strip $(OBJCXX_SOURCES))" "" - OBJECTS +=$(strip $(OBJCXX_SOURCES:.mm=.o)) - LD = g++ - ifeq $(findstring lobjc,$(LDFLAGS)) "" - LDFLAGS +=-lobjc - endif -endif - - -#---------------------------------------------------------------------- -# Make the dSYM file from the executable -#---------------------------------------------------------------------- -$(DSYM) : $(EXE) - $(DS) $(DSFLAGS) -o "$(DSYM)" "$(EXE)" - -#---------------------------------------------------------------------- -# Compile the executable from all the objects (default rule) with no -# dsym file. -#---------------------------------------------------------------------- -$(EXE) : $(OBJECTS) - $(LD) $(LDFLAGS) $(OBJECTS) -o "$(EXE)" - - -#---------------------------------------------------------------------- -# Automatic variables based on items already entered. Below we create -# an objects lists from the list of sources by replacing all entries -# that end with .c with .o, and we also create a list of prerequisite -# files by replacing all .c files with .d. -#---------------------------------------------------------------------- -PREREQS := $(OBJECTS:.o=.d) - -#---------------------------------------------------------------------- -# Rule for Generating Prerequisites Automatically using .d files and -# the compiler -MM option. The -M option will list all system headers, -# and the -MM option will list all non-system dependencies. -#---------------------------------------------------------------------- -%.d: %.c - @set -e; rm -f $@; \ - $(CC) -M $(CPPFLAGS) $< > $@.$$$$; \ - sed 's,\($*\)\.o[ :]*,\1.o $@ : ,g' < $@.$$$$ > $@; \ - rm -f $@.$$$$ - -%.d: %.cpp - @set -e; rm -f $@; \ - $(CC) -M $(CPPFLAGS) $< > $@.$$$$; \ - sed 's,\($*\)\.o[ :]*,\1.o $@ : ,g' < $@.$$$$ > $@; \ - rm -f $@.$$$$ - -%.d: %.m - @set -e; rm -f $@; \ - $(CC) -M $(CPPFLAGS) $< > $@.$$$$; \ - sed 's,\($*\)\.o[ :]*,\1.o $@ : ,g' < $@.$$$$ > $@; \ - rm -f $@.$$$$ - -%.d: %.mm - @set -e; rm -f $@; \ - $(CC) -M $(CPPFLAGS) $< > $@.$$$$; \ - sed 's,\($*\)\.o[ :]*,\1.o $@ : ,g' < $@.$$$$ > $@; \ - rm -f $@.$$$$ - -#---------------------------------------------------------------------- -# Include all of the makefiles for each source file so we don't have -# to manually track all of the prerequisites for each source file. -#---------------------------------------------------------------------- -sinclude $(PREREQS) - -.PHONY: clean -dsym: $(DSYM) -all: $(EXE) $(DSYM) -clean: - rm -rf "$(EXE)" "$(DSYM)" $(OBJECTS) $(PREREQS) - - +include $(LEVEL)/Makefile.rules Added: lldb/trunk/test/foundation/TestObjCMethods.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/foundation/TestObjCMethods.py?rev=114118&view=auto ============================================================================== --- lldb/trunk/test/foundation/TestObjCMethods.py (added) +++ lldb/trunk/test/foundation/TestObjCMethods.py Thu Sep 16 15:54:06 2010 @@ -0,0 +1,53 @@ +"""Set breakpoint on objective-c class and instance methods in foundation.""" + +import os, time +import unittest2 +import lldb +from lldbtest import * + + at unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin") +class FoundationTestCase(TestBase): + + mydir = "foundation" + + def test_with_dsym(self): + """Test 'image lookup -t days' and check for correct display.""" + self.buildDsym() + self.break_on_objc_methods() + + def test_with_dwarf(self): + """Test 'image lookup -t days' and check for correct display.""" + self.buildDwarf() + self.break_on_objc_methods() + + def break_on_objc_methods(self): + """Test setting objc breakpoints using regexp-break.""" + exe = os.path.join(os.getcwd(), "a.out") + self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) + + # Stop at +[NSString stringWithFormat:]. + self.expect("regexp-break +[NSString stringWithFormat:]", BREAKPOINT_CREATED, + startstr = "Breakpoint created: 1: name = '+[NSString stringWithFormat:]', locations = 1") + + # Stop at -[NSAutoreleasePool release]. + self.expect("regexp-break -[NSAutoreleasePool release]", BREAKPOINT_CREATED, + startstr = "Breakpoint created: 2: name = '-[NSAutoreleasePool release]', locations = 1") + + self.runCmd("run", RUN_SUCCEEDED) + + # First stop is +[NSString stringWithFormat:]. + self.expect("thread backtrace", "Stop at +[NSString stringWithFormat:]", + substrs = ["Foundation`+[NSString stringWithFormat:]"]) + + self.runCmd("process continue") + + # Followed by -[NSAutoreleasePool release]. + self.expect("thread backtrace", "Stop at -[NSAutoreleasePool release]", + substrs = ["Foundation`-[NSAutoreleasePool release]"]) + + +if __name__ == '__main__': + import atexit + lldb.SBDebugger.Initialize() + atexit.register(lambda: lldb.SBDebugger.Terminate()) + unittest2.main() Modified: lldb/trunk/test/foundation/main.m URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/foundation/main.m?rev=114118&r1=114117&r2=114118&view=diff ============================================================================== --- lldb/trunk/test/foundation/main.m (original) +++ lldb/trunk/test/foundation/main.m Thu Sep 16 15:54:06 2010 @@ -10,6 +10,8 @@ printf("sizeof(id) = %zu\n", sizeof(id)); printf("sizeof(Class) = %zu\n", sizeof(Class)); printf("sizeof(SEL) = %zu\n", sizeof(SEL)); + printf("[str length] = %zu\n", [str length]); + printf("str = '%s'\n", [str cStringUsingEncoding: [NSString defaultCStringEncoding]]); [pool release]; return 0; } Modified: lldb/trunk/test/make/Makefile.rules URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/make/Makefile.rules?rev=114118&r1=114117&r2=114118&view=diff ============================================================================== --- lldb/trunk/test/make/Makefile.rules (original) +++ lldb/trunk/test/make/Makefile.rules Thu Sep 16 15:54:06 2010 @@ -11,12 +11,19 @@ # SHELL = /bin/sh -x #---------------------------------------------------------------------- +# If ARCH is not defined, default to x86_64. +#---------------------------------------------------------------------- +ifeq "$(ARCH)" "" + ARCH = x86_64 +endif + +#---------------------------------------------------------------------- # Change any build/tool options needed #---------------------------------------------------------------------- DS := /usr/bin/dsymutil DSFLAGS = CC = gcc -CFLAGS ?=-arch x86_64 -gdwarf-2 -O0 +CFLAGS ?=-arch $(ARCH) -gdwarf-2 -O0 CPLUSPLUSFLAGS +=$(CFLAGS) CPPFLAGS +=$(CFLAGS) LD = $(CC) From johnny.chen at apple.com Thu Sep 16 16:01:39 2010 From: johnny.chen at apple.com (Johnny Chen) Date: Thu, 16 Sep 2010 21:01:39 -0000 Subject: [Lldb-commits] [lldb] r114120 - /lldb/trunk/test/foundation/TestObjCMethods.py Message-ID: <20100916210139.9FCDE2A6C12C@llvm.org> Author: johnny Date: Thu Sep 16 16:01:39 2010 New Revision: 114120 URL: http://llvm.org/viewvc/llvm-project?rev=114120&view=rev Log: Fixed wrong doc strings from cut-and-paste. 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=114120&r1=114119&r2=114120&view=diff ============================================================================== --- lldb/trunk/test/foundation/TestObjCMethods.py (original) +++ lldb/trunk/test/foundation/TestObjCMethods.py Thu Sep 16 16:01:39 2010 @@ -11,12 +11,12 @@ mydir = "foundation" def test_with_dsym(self): - """Test 'image lookup -t days' and check for correct display.""" + """Test setting objc breakpoints using regexp-break.""" self.buildDsym() self.break_on_objc_methods() def test_with_dwarf(self): - """Test 'image lookup -t days' and check for correct display.""" + """Test setting objc breakpoints using regexp-break.""" self.buildDwarf() self.break_on_objc_methods() From scallanan at apple.com Thu Sep 16 17:31:19 2010 From: scallanan at apple.com (Sean Callanan) Date: Thu, 16 Sep 2010 22:31:19 -0000 Subject: [Lldb-commits] [lldb] r114123 - in /lldb/trunk: include/lldb/Symbol/ClangASTContext.h source/Symbol/ClangASTContext.cpp Message-ID: <20100916223119.378D32A6C12C@llvm.org> Author: spyffe Date: Thu Sep 16 17:31:19 2010 New Revision: 114123 URL: http://llvm.org/viewvc/llvm-project?rev=114123&view=rev Log: Added AddMethodToCXXRecordType. This is not yet tested, but I'm committing because it's not used anywhere and I want to avoid conflicts. Modified: lldb/trunk/include/lldb/Symbol/ClangASTContext.h lldb/trunk/source/Symbol/ClangASTContext.cpp Modified: lldb/trunk/include/lldb/Symbol/ClangASTContext.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Symbol/ClangASTContext.h?rev=114123&r1=114122&r2=114123&view=diff ============================================================================== --- lldb/trunk/include/lldb/Symbol/ClangASTContext.h (original) +++ lldb/trunk/include/lldb/Symbol/ClangASTContext.h Thu Sep 16 17:31:19 2010 @@ -93,7 +93,13 @@ uint32_t bit_size); void * - GetBuiltInType_void(); + GetBuiltInType_void(clang::ASTContext *ast_context); + + void * + GetBuiltInType_void() + { + return ClangASTContext::GetBuiltInType_void(m_ast_context_ap.get()); + } void * GetBuiltInType_objc_id(); @@ -154,6 +160,23 @@ lldb::LanguageType language); static bool + AddMethodToCXXRecordType(clang::ASTContext *ast_context, + void *record_clang_type, + const char *name, + void *method_type); + + bool + AddMethodToCXXRecordType(void *record_clang_type, + const char *name, + void *method_type) + { + return ClangASTContext::AddMethodToCXXRecordType(ast_context, + record_clang_type, + name, + method_type); + } + + static bool AddFieldToRecordType (clang::ASTContext *ast_context, void *record_qual_type, const char *name, Modified: lldb/trunk/source/Symbol/ClangASTContext.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/ClangASTContext.cpp?rev=114123&r1=114122&r2=114123&view=diff ============================================================================== --- lldb/trunk/source/Symbol/ClangASTContext.cpp (original) +++ lldb/trunk/source/Symbol/ClangASTContext.cpp Thu Sep 16 17:31:19 2010 @@ -658,9 +658,9 @@ } void * -ClangASTContext::GetBuiltInType_void() +ClangASTContext::GetBuiltInType_void(clang::ASTContext *ast_context) { - return getASTContext()->VoidTy.getAsOpaquePtr(); + return ast_context->VoidTy.getAsOpaquePtr(); } void * @@ -804,6 +804,57 @@ } bool +ClangASTContext::AddMethodToCXXRecordType +( + clang::ASTContext *ast_context, + void *record_clang_type, + const char *name, + void *method_type +) +{ + if (!record_clang_type || !method_type || !name) + return false; + + assert(ast_context); + + IdentifierTable *identifier_table = &ast_context->Idents; + + assert(identifier_table); + + QualType record_qual_type(QualType::getFromOpaquePtr(record_clang_type)); + clang::Type *record_type(record_qual_type.getTypePtr()); + + if (!record_type) + return false; + + RecordType *record_recty(dyn_cast(record_type)); + + if (!record_recty) + return false; + + RecordDecl *record_decl = record_recty->getDecl(); + + if (!record_decl) + return false; + + CXXRecordDecl *cxx_record_decl = dyn_cast(record_decl); + + if (!cxx_record_decl) + return false; + + CXXMethodDecl *cxx_method_decl = CXXMethodDecl::Create(*ast_context, + cxx_record_decl, + SourceLocation(), + DeclarationName(&identifier_table->get(name)), + QualType::getFromOpaquePtr(method_type), + NULL); + + cxx_record_decl->addDecl(cxx_method_decl); + + return true; +} + +bool ClangASTContext::AddFieldToRecordType ( clang::ASTContext *ast_context, From scallanan at apple.com Thu Sep 16 17:32:47 2010 From: scallanan at apple.com (Sean Callanan) Date: Thu, 16 Sep 2010 22:32:47 -0000 Subject: [Lldb-commits] [lldb] r114124 - /lldb/trunk/include/lldb/Symbol/ClangASTContext.h Message-ID: <20100916223247.D0B8B2A6C12C@llvm.org> Author: spyffe Date: Thu Sep 16 17:32:47 2010 New Revision: 114124 URL: http://llvm.org/viewvc/llvm-project?rev=114124&view=rev Log: Well, it shouldn't be quite *that* obviously broken. Quick fix to AddMethodToCXXRecordType's non-static definition. Modified: lldb/trunk/include/lldb/Symbol/ClangASTContext.h Modified: lldb/trunk/include/lldb/Symbol/ClangASTContext.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Symbol/ClangASTContext.h?rev=114124&r1=114123&r2=114124&view=diff ============================================================================== --- lldb/trunk/include/lldb/Symbol/ClangASTContext.h (original) +++ lldb/trunk/include/lldb/Symbol/ClangASTContext.h Thu Sep 16 17:32:47 2010 @@ -170,7 +170,7 @@ const char *name, void *method_type) { - return ClangASTContext::AddMethodToCXXRecordType(ast_context, + return ClangASTContext::AddMethodToCXXRecordType(m_ast_context_ap.get(), record_clang_type, name, method_type); From scallanan at apple.com Thu Sep 16 17:40:36 2010 From: scallanan at apple.com (Sean Callanan) Date: Thu, 16 Sep 2010 22:40:36 -0000 Subject: [Lldb-commits] [lldb] r114125 - /lldb/trunk/include/lldb/Symbol/ClangASTContext.h Message-ID: <20100916224036.6E00B2A6C12C@llvm.org> Author: spyffe Date: Thu Sep 16 17:40:36 2010 New Revision: 114125 URL: http://llvm.org/viewvc/llvm-project?rev=114125&view=rev Log: GetBuiltInType_void(clang::ASTContext*) should be static. Modified: lldb/trunk/include/lldb/Symbol/ClangASTContext.h Modified: lldb/trunk/include/lldb/Symbol/ClangASTContext.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Symbol/ClangASTContext.h?rev=114125&r1=114124&r2=114125&view=diff ============================================================================== --- lldb/trunk/include/lldb/Symbol/ClangASTContext.h (original) +++ lldb/trunk/include/lldb/Symbol/ClangASTContext.h Thu Sep 16 17:40:36 2010 @@ -92,7 +92,7 @@ uint32_t dw_ate, uint32_t bit_size); - void * + static void * GetBuiltInType_void(clang::ASTContext *ast_context); void * From rjmccall at apple.com Thu Sep 16 18:04:24 2010 From: rjmccall at apple.com (John McCall) Date: Thu, 16 Sep 2010 16:04:24 -0700 Subject: [Lldb-commits] [lldb] r114095 - in /lldb/trunk/include/lldb: Core/Debugger.h Target/Process.h Target/Thread.h In-Reply-To: <1F6A7075-3061-4F1A-A288-E719C6293879@apple.com> References: <20100916173705.E68162A6C12C@llvm.org> <1F6A7075-3061-4F1A-A288-E719C6293879@apple.com> Message-ID: On Sep 16, 2010, at 10:54 AM, Caroline Tice wrote: > Okay I will work on re-doing the code so it doesn't have to do that. For the record, the code as is works > just fine on Mac OS X; I had no idea it would die so horribly on other platforms. It really shouldn't die horribly on any platform, although some compilers will warn about it, particularly in the initializer lists. There's something important and non-obvious to consider, though: in C++, virtual calls during the constructor will call the most-derived methods as seen from the class being constructed. For example, consider these class definitions: struct A { virtual void foo(); virtual void bar() = 0; A(); }; struct B : A { virtual void foo(); virtual void bar(); }; Now consider the constructor for A: A::A() { foo(); // calls A::foo(), not B::foo() bar(); // calls A::foo(), which is pure virtual, which causes the program to terminate } Just something to be aware of. John. From benny.kra at googlemail.com Thu Sep 16 18:19:15 2010 From: benny.kra at googlemail.com (Benjamin Kramer) Date: Fri, 17 Sep 2010 01:19:15 +0200 Subject: [Lldb-commits] [lldb] r114095 - in /lldb/trunk/include/lldb: Core/Debugger.h Target/Process.h Target/Thread.h In-Reply-To: References: <20100916173705.E68162A6C12C@llvm.org> <1F6A7075-3061-4F1A-A288-E719C6293879@apple.com> Message-ID: <8C04151D-51EB-47F3-A5DA-53879713B697@gmail.com> On 17.09.2010, at 01:04, John McCall wrote: > On Sep 16, 2010, at 10:54 AM, Caroline Tice wrote: >> Okay I will work on re-doing the code so it doesn't have to do that. For the record, the code as is works >> just fine on Mac OS X; I had no idea it would die so horribly on other platforms. > > It really shouldn't die horribly on any platform, although some compilers will warn about it, particularly in the initializer lists. It does die horribly when compiled with clang++. Maybe we have a clang bug here? Testcase: class A { public: A(int) {} virtual int foo() = 0; }; class B : public A { public: B() : A(foo()) {} virtual int foo() { return 42; } }; int main() { B b; } From rjmccall at apple.com Thu Sep 16 18:23:59 2010 From: rjmccall at apple.com (John McCall) Date: Thu, 16 Sep 2010 16:23:59 -0700 Subject: [Lldb-commits] [lldb] r114095 - in /lldb/trunk/include/lldb: Core/Debugger.h Target/Process.h Target/Thread.h In-Reply-To: <8C04151D-51EB-47F3-A5DA-53879713B697@gmail.com> References: <20100916173705.E68162A6C12C@llvm.org> <1F6A7075-3061-4F1A-A288-E719C6293879@apple.com> <8C04151D-51EB-47F3-A5DA-53879713B697@gmail.com> Message-ID: <9BEDB11E-2549-4BA9-A125-15D9064B9CE8@apple.com> On Sep 16, 2010, at 4:19 PM, Benjamin Kramer wrote: > On 17.09.2010, at 01:04, John McCall wrote: >> On Sep 16, 2010, at 10:54 AM, Caroline Tice wrote: >>> Okay I will work on re-doing the code so it doesn't have to do that. For the record, the code as is works >>> just fine on Mac OS X; I had no idea it would die so horribly on other platforms. >> >> It really shouldn't die horribly on any platform, although some compilers will warn about it, particularly in the initializer lists. > > It does die horribly when compiled with clang++. Maybe we have a clang bug here? Looks like it. That should definitely be calling B::foo(), and in fact can be devirtualized, although we can't rely on that always happening. John. From johnny.chen at apple.com Thu Sep 16 18:51:14 2010 From: johnny.chen at apple.com (Johnny Chen) Date: Thu, 16 Sep 2010 23:51:14 -0000 Subject: [Lldb-commits] [lldb] r114132 - in /lldb/trunk: include/lldb/Symbol/ClangASTContext.h source/Symbol/ClangASTContext.cpp Message-ID: <20100916235114.963B12A6C12C@llvm.org> Author: johnny Date: Thu Sep 16 18:51:14 2010 New Revision: 114132 URL: http://llvm.org/viewvc/llvm-project?rev=114132&view=rev Log: Reverted r114125, r114124, and r114123 as it broke the test suite - segfaults when running test/class_types. Modified: lldb/trunk/include/lldb/Symbol/ClangASTContext.h lldb/trunk/source/Symbol/ClangASTContext.cpp Modified: lldb/trunk/include/lldb/Symbol/ClangASTContext.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Symbol/ClangASTContext.h?rev=114132&r1=114131&r2=114132&view=diff ============================================================================== --- lldb/trunk/include/lldb/Symbol/ClangASTContext.h (original) +++ lldb/trunk/include/lldb/Symbol/ClangASTContext.h Thu Sep 16 18:51:14 2010 @@ -92,14 +92,8 @@ uint32_t dw_ate, uint32_t bit_size); - static void * - GetBuiltInType_void(clang::ASTContext *ast_context); - void * - GetBuiltInType_void() - { - return ClangASTContext::GetBuiltInType_void(m_ast_context_ap.get()); - } + GetBuiltInType_void(); void * GetBuiltInType_objc_id(); @@ -160,23 +154,6 @@ lldb::LanguageType language); static bool - AddMethodToCXXRecordType(clang::ASTContext *ast_context, - void *record_clang_type, - const char *name, - void *method_type); - - bool - AddMethodToCXXRecordType(void *record_clang_type, - const char *name, - void *method_type) - { - return ClangASTContext::AddMethodToCXXRecordType(m_ast_context_ap.get(), - record_clang_type, - name, - method_type); - } - - static bool AddFieldToRecordType (clang::ASTContext *ast_context, void *record_qual_type, const char *name, Modified: lldb/trunk/source/Symbol/ClangASTContext.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/ClangASTContext.cpp?rev=114132&r1=114131&r2=114132&view=diff ============================================================================== --- lldb/trunk/source/Symbol/ClangASTContext.cpp (original) +++ lldb/trunk/source/Symbol/ClangASTContext.cpp Thu Sep 16 18:51:14 2010 @@ -658,9 +658,9 @@ } void * -ClangASTContext::GetBuiltInType_void(clang::ASTContext *ast_context) +ClangASTContext::GetBuiltInType_void() { - return ast_context->VoidTy.getAsOpaquePtr(); + return getASTContext()->VoidTy.getAsOpaquePtr(); } void * @@ -804,57 +804,6 @@ } bool -ClangASTContext::AddMethodToCXXRecordType -( - clang::ASTContext *ast_context, - void *record_clang_type, - const char *name, - void *method_type -) -{ - if (!record_clang_type || !method_type || !name) - return false; - - assert(ast_context); - - IdentifierTable *identifier_table = &ast_context->Idents; - - assert(identifier_table); - - QualType record_qual_type(QualType::getFromOpaquePtr(record_clang_type)); - clang::Type *record_type(record_qual_type.getTypePtr()); - - if (!record_type) - return false; - - RecordType *record_recty(dyn_cast(record_type)); - - if (!record_recty) - return false; - - RecordDecl *record_decl = record_recty->getDecl(); - - if (!record_decl) - return false; - - CXXRecordDecl *cxx_record_decl = dyn_cast(record_decl); - - if (!cxx_record_decl) - return false; - - CXXMethodDecl *cxx_method_decl = CXXMethodDecl::Create(*ast_context, - cxx_record_decl, - SourceLocation(), - DeclarationName(&identifier_table->get(name)), - QualType::getFromOpaquePtr(method_type), - NULL); - - cxx_record_decl->addDecl(cxx_method_decl); - - return true; -} - -bool ClangASTContext::AddFieldToRecordType ( clang::ASTContext *ast_context, From johnny.chen at apple.com Thu Sep 16 18:57:33 2010 From: johnny.chen at apple.com (Johnny Chen) Date: Thu, 16 Sep 2010 23:57:33 -0000 Subject: [Lldb-commits] [lldb] r114134 - in /lldb/trunk/test/foundation: TestObjCMethods.py main.m Message-ID: <20100916235733.B48862A6C12C@llvm.org> Author: johnny Date: Thu Sep 16 18:57:33 2010 New Revision: 114134 URL: http://llvm.org/viewvc/llvm-project?rev=114134&view=rev Log: Added extra test scenarios to break on a selector with: (lldb) breakpoint set -S description and a compilation unit defined instance method with: (lldb) breakpoint set -n '-[MyString initWithNSString:]' Modified: lldb/trunk/test/foundation/TestObjCMethods.py lldb/trunk/test/foundation/main.m Modified: lldb/trunk/test/foundation/TestObjCMethods.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/foundation/TestObjCMethods.py?rev=114134&r1=114133&r2=114134&view=diff ============================================================================== --- lldb/trunk/test/foundation/TestObjCMethods.py (original) +++ lldb/trunk/test/foundation/TestObjCMethods.py Thu Sep 16 18:57:33 2010 @@ -11,17 +11,17 @@ mydir = "foundation" def test_with_dsym(self): - """Test setting objc breakpoints using regexp-break.""" + """Test setting objc breakpoints using 'regexp-break' and 'breakpoint set'.""" self.buildDsym() self.break_on_objc_methods() def test_with_dwarf(self): - """Test setting objc breakpoints using regexp-break.""" + """Test setting objc breakpoints using 'regexp-break' and 'breakpoint set'.""" self.buildDwarf() self.break_on_objc_methods() def break_on_objc_methods(self): - """Test setting objc breakpoints using regexp-break.""" + """Test setting objc breakpoints using 'regexp-break' and 'breakpoint set'.""" exe = os.path.join(os.getcwd(), "a.out") self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) @@ -29,9 +29,17 @@ self.expect("regexp-break +[NSString stringWithFormat:]", BREAKPOINT_CREATED, startstr = "Breakpoint created: 1: name = '+[NSString stringWithFormat:]', locations = 1") + # Stop at -[MyString initWithNSString:]. + self.expect("breakpoint set -n '-[MyString initWithNSString:]'", BREAKPOINT_CREATED, + startstr = "Breakpoint created: 2: name = '-[MyString initWithNSString:]', locations = 1") + + # Stop at the "description" selector. + self.expect("breakpoint set -S description", BREAKPOINT_CREATED, + startstr = "Breakpoint created: 3: name = 'description', locations = 1") + # Stop at -[NSAutoreleasePool release]. self.expect("regexp-break -[NSAutoreleasePool release]", BREAKPOINT_CREATED, - startstr = "Breakpoint created: 2: name = '-[NSAutoreleasePool release]', locations = 1") + startstr = "Breakpoint created: 4: name = '-[NSAutoreleasePool release]', locations = 1") self.runCmd("run", RUN_SUCCEEDED) @@ -41,6 +49,18 @@ self.runCmd("process continue") + # Followed by a.out`-[MyString initWithNSString:]. + self.expect("thread backtrace", "Stop at a.out`-[MyString initWithNSString:]", + substrs = ["a.out`-[MyString initWithNSString:]"]) + + self.runCmd("process continue") + + # Followed by -[MyString description]. + self.expect("thread backtrace", "Stop at -[MyString description]", + substrs = ["a.out`-[MyString description]"]) + + self.runCmd("process continue") + # Followed by -[NSAutoreleasePool release]. self.expect("thread backtrace", "Stop at -[NSAutoreleasePool release]", substrs = ["Foundation`-[NSAutoreleasePool release]"]) Modified: lldb/trunk/test/foundation/main.m URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/foundation/main.m?rev=114134&r1=114133&r2=114134&view=diff ============================================================================== --- lldb/trunk/test/foundation/main.m (original) +++ lldb/trunk/test/foundation/main.m Thu Sep 16 18:57:33 2010 @@ -1,9 +1,43 @@ #import + at interface MyString : NSObject { + NSString *str; + NSDate *date; +} +- (id)initWithNSString:(NSString *)string; + at end + + at implementation MyString +- (id)initWithNSString:(NSString *)string +{ + [super init]; + str = [NSString stringWithString:string]; + date = [NSDate date]; + return self; +} + +- (void)dealloc +{ + [date release]; + [str release]; + [super dealloc]; +} + +- (NSString *)description +{ + return [str stringByAppendingFormat:@" with timestamp: %@", date]; +} + at end + int main (int argc, char const *argv[]) { NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init]; - NSString *str = [NSString stringWithFormat:@"Hello from '%s'", argv[0]]; + NSString *str = [NSString stringWithFormat:@"Hello from '%s'", argv[0]]; + NSLog(@"NSString instance: %@", str); + + MyString *my = [[MyString alloc] initWithNSString:str]; + NSLog(@"MyString instance: %@", [my description]); + id str_id = str; SEL sel = @selector(length); BOOL responds = [str respondsToSelector:sel]; @@ -12,6 +46,7 @@ printf("sizeof(SEL) = %zu\n", sizeof(SEL)); printf("[str length] = %zu\n", [str length]); printf("str = '%s'\n", [str cStringUsingEncoding: [NSString defaultCStringEncoding]]); + [pool release]; return 0; } From scallanan at apple.com Thu Sep 16 21:24:29 2010 From: scallanan at apple.com (Sean Callanan) Date: Fri, 17 Sep 2010 02:24:29 -0000 Subject: [Lldb-commits] [lldb] r114152 - in /lldb/trunk: include/lldb/Symbol/ClangASTContext.h source/Symbol/ClangASTContext.cpp Message-ID: <20100917022429.62CBD2A6C12C@llvm.org> Author: spyffe Date: Thu Sep 16 21:24:29 2010 New Revision: 114152 URL: http://llvm.org/viewvc/llvm-project?rev=114152&view=rev Log: Added a static function to get the void type for an ASTContext; also added a function to get the Clang-style CVR qualifiers for a type as an unsigned int. Modified: lldb/trunk/include/lldb/Symbol/ClangASTContext.h lldb/trunk/source/Symbol/ClangASTContext.cpp Modified: lldb/trunk/include/lldb/Symbol/ClangASTContext.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Symbol/ClangASTContext.h?rev=114152&r1=114151&r2=114152&view=diff ============================================================================== --- lldb/trunk/include/lldb/Symbol/ClangASTContext.h (original) +++ lldb/trunk/include/lldb/Symbol/ClangASTContext.h Thu Sep 16 21:24:29 2010 @@ -92,8 +92,14 @@ uint32_t dw_ate, uint32_t bit_size); + static void * + GetBuiltInType_void(clang::ASTContext *ast_context); + void * - GetBuiltInType_void(); + GetBuiltInType_void() + { + return GetBuiltInType_void(getASTContext()); + } void * GetBuiltInType_objc_id(); @@ -127,7 +133,7 @@ AreTypesSame(void *type1, void *type2) { - return ClangASTContext::AreTypesSame(m_ast_context_ap.get(), type1, type2); + return ClangASTContext::AreTypesSame(getASTContext(), type1, type2); } //------------------------------------------------------------------ @@ -168,7 +174,7 @@ lldb::AccessType access, uint32_t bitfield_bit_size) { - return ClangASTContext::AddFieldToRecordType(m_ast_context_ap.get(), + return ClangASTContext::AddFieldToRecordType(getASTContext(), record_qual_type, name, field_type, @@ -217,7 +223,7 @@ uint32_t bitfield_bit_size, bool isSynthesized) { - return ClangASTContext::AddObjCClassIVar (m_ast_context_ap.get(), + return ClangASTContext::AddObjCClassIVar (getASTContext(), class_opaque_type, name, ivar_opaque_type, @@ -361,7 +367,7 @@ bool is_variadic, unsigned type_quals) { - return ClangASTContext::CreateFunctionType(m_ast_context_ap.get(), + return ClangASTContext::CreateFunctionType(getASTContext(), result_type, args, num_args, @@ -480,6 +486,11 @@ uint8_t *dst, size_t dst_size); + //------------------------------------------------------------------ + // Qualifiers + //------------------------------------------------------------------ + static unsigned + GetTypeQualifiers(void *clang_type); protected: //------------------------------------------------------------------ // Classes that inherit from ClangASTContext can see and modify these Modified: lldb/trunk/source/Symbol/ClangASTContext.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/ClangASTContext.cpp?rev=114152&r1=114151&r2=114152&view=diff ============================================================================== --- lldb/trunk/source/Symbol/ClangASTContext.cpp (original) +++ lldb/trunk/source/Symbol/ClangASTContext.cpp Thu Sep 16 21:24:29 2010 @@ -658,9 +658,9 @@ } void * -ClangASTContext::GetBuiltInType_void() +ClangASTContext::GetBuiltInType_void(clang::ASTContext *ast_context) { - return getASTContext()->VoidTy.getAsOpaquePtr(); + return ast_context->VoidTy.getAsOpaquePtr(); } void * @@ -3144,3 +3144,13 @@ } return 0; } + +unsigned +ClangASTContext::GetTypeQualifiers(void *clang_type) +{ + assert (clang_type); + + QualType qual_type (QualType::getFromOpaquePtr(clang_type)); + + return qual_type.getQualifiers().getCVRQualifiers(); +} From scallanan at apple.com Thu Sep 16 21:58:26 2010 From: scallanan at apple.com (Sean Callanan) Date: Fri, 17 Sep 2010 02:58:26 -0000 Subject: [Lldb-commits] [lldb] r114157 - in /lldb/trunk: include/lldb/Symbol/ClangASTContext.h source/Symbol/ClangASTContext.cpp Message-ID: <20100917025826.56BB12A6C12C@llvm.org> Author: spyffe Date: Thu Sep 16 21:58:26 2010 New Revision: 114157 URL: http://llvm.org/viewvc/llvm-project?rev=114157&view=rev Log: Re-committed AddMethodToCXXRecordType, now that the bug I introduced to ClangASTContext is resolved. Modified: lldb/trunk/include/lldb/Symbol/ClangASTContext.h lldb/trunk/source/Symbol/ClangASTContext.cpp Modified: lldb/trunk/include/lldb/Symbol/ClangASTContext.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Symbol/ClangASTContext.h?rev=114157&r1=114156&r2=114157&view=diff ============================================================================== --- lldb/trunk/include/lldb/Symbol/ClangASTContext.h (original) +++ lldb/trunk/include/lldb/Symbol/ClangASTContext.h Thu Sep 16 21:58:26 2010 @@ -182,6 +182,24 @@ bitfield_bit_size); } + static bool + AddMethodToCXXRecordType (clang::ASTContext *ast_context, + void *record_clang_type, + const char *name, + void *method_type); + + bool + AddMethodToCXXRecordType (void *record_clang_type, + const char *name, + void *method_type) + + { + return ClangASTContext::AddMethodToCXXRecordType(getASTContext(), + record_clang_type, + name, + method_type); + } + bool FieldIsBitfield (clang::FieldDecl* field, uint32_t& bitfield_bit_size); Modified: lldb/trunk/source/Symbol/ClangASTContext.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/ClangASTContext.cpp?rev=114157&r1=114156&r2=114157&view=diff ============================================================================== --- lldb/trunk/source/Symbol/ClangASTContext.cpp (original) +++ lldb/trunk/source/Symbol/ClangASTContext.cpp Thu Sep 16 21:58:26 2010 @@ -804,6 +804,57 @@ } bool +ClangASTContext::AddMethodToCXXRecordType +( + clang::ASTContext *ast_context, + void *record_clang_type, + const char *name, + void *method_type + ) +{ + if (!record_clang_type || !method_type || !name) + return false; + + assert(ast_context); + + IdentifierTable *identifier_table = &ast_context->Idents; + + assert(identifier_table); + + QualType record_qual_type(QualType::getFromOpaquePtr(record_clang_type)); + clang::Type *record_type(record_qual_type.getTypePtr()); + + if (!record_type) + return false; + + RecordType *record_recty(dyn_cast(record_type)); + + if (!record_recty) + return false; + + RecordDecl *record_decl = record_recty->getDecl(); + + if (!record_decl) + return false; + + CXXRecordDecl *cxx_record_decl = dyn_cast(record_decl); + + if (!cxx_record_decl) + return false; + + CXXMethodDecl *cxx_method_decl = CXXMethodDecl::Create(*ast_context, + cxx_record_decl, + SourceLocation(), + DeclarationName(&identifier_table->get(name)), + QualType::getFromOpaquePtr(method_type), + NULL); + + cxx_record_decl->addDecl(cxx_method_decl); + + return true; +} + +bool ClangASTContext::AddFieldToRecordType ( clang::ASTContext *ast_context, From gclayton at apple.com Fri Sep 17 12:42:16 2010 From: gclayton at apple.com (Greg Clayton) Date: Fri, 17 Sep 2010 17:42:16 -0000 Subject: [Lldb-commits] [lldb] r114188 - in /lldb/trunk: include/lldb/API/SBStream.h include/lldb/API/SBStringList.h include/lldb/Core/StreamFile.h lldb.xcodeproj/project.pbxproj source/API/SBStream.cpp source/Core/StreamFile.cpp Message-ID: <20100917174217.0A5E82A6C12C@llvm.org> Author: gclayton Date: Fri Sep 17 12:42:16 2010 New Revision: 114188 URL: http://llvm.org/viewvc/llvm-project?rev=114188&view=rev Log: We now have SBStream that mirrors the generic stream classes we use inside lldb (lldb_private::StreamFile, and lldb_private::StreamString). Added: lldb/trunk/include/lldb/API/SBStream.h lldb/trunk/source/API/SBStream.cpp Modified: lldb/trunk/include/lldb/API/SBStringList.h lldb/trunk/include/lldb/Core/StreamFile.h lldb/trunk/lldb.xcodeproj/project.pbxproj lldb/trunk/source/Core/StreamFile.cpp Added: lldb/trunk/include/lldb/API/SBStream.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBStream.h?rev=114188&view=auto ============================================================================== --- lldb/trunk/include/lldb/API/SBStream.h (added) +++ lldb/trunk/include/lldb/API/SBStream.h Fri Sep 17 12:42:16 2010 @@ -0,0 +1,81 @@ +//===-- SBStream.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_SBStream_h_ +#define LLDB_SBStream_h_ + +#include "lldb/API/SBDefines.h" + +namespace lldb { + +class SBStream +{ +public: + + SBStream (); + + ~SBStream (); + + bool + IsValid() const; + + // If this stream is not redirected to a file, it will maintain a local + // cache for the stream data which can be accessed using this accessor. + const char * + GetData (); + + // If this stream is not redirected to a file, it will maintain a local + // cache for the stream output whose length can be accessed using this + // accessor. + size_t + GetSize(); + + void + Printf (const char *format, ...); + + void + RedirectToFile (const char *path, bool append); + + void + RedirectToFileHandle (FILE *fh, bool transfer_fh_ownership); + + void + RedirectToFileDescriptor (int fd, bool transfer_fh_ownership); + + // If the stream is redirected to a file, forget about the file and if + // ownership of the file was transfered to this object, close the file. + // If the stream is backed by a local cache, clear this cache. + void + Clear (); + +protected: + +#ifndef SWIG + + lldb_private::Stream * + operator->(); + + lldb_private::Stream * + get(); + + lldb_private::Stream & + ref(); + +#endif + +private: + + DISALLOW_COPY_AND_ASSIGN (SBStream); + std::auto_ptr m_opaque_ap; + bool m_is_file; +}; + +} // namespace lldb + +#endif // LLDB_SBStream_h_ Modified: lldb/trunk/include/lldb/API/SBStringList.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBStringList.h?rev=114188&r1=114187&r2=114188&view=diff ============================================================================== --- lldb/trunk/include/lldb/API/SBStringList.h (original) +++ lldb/trunk/include/lldb/API/SBStringList.h Fri Sep 17 12:42:16 2010 @@ -47,6 +47,8 @@ void Clear (); +protected: + #ifndef SWIG const lldb_private::StringList * Modified: lldb/trunk/include/lldb/Core/StreamFile.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/StreamFile.h?rev=114188&r1=114187&r2=114188&view=diff ============================================================================== --- lldb/trunk/include/lldb/Core/StreamFile.h (original) +++ lldb/trunk/include/lldb/Core/StreamFile.h Fri Sep 17 12:42:16 2010 @@ -32,7 +32,7 @@ StreamFile (uint32_t flags, uint32_t addr_size, lldb::ByteOrder byte_order, FILE *f); - StreamFile (FILE *f); + StreamFile (FILE *f, bool tranfer_ownership = false); StreamFile (uint32_t flags, uint32_t addr_size, lldb::ByteOrder byte_order, const char *path, const char *permissions = "w"); Modified: lldb/trunk/lldb.xcodeproj/project.pbxproj URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/lldb.xcodeproj/project.pbxproj?rev=114188&r1=114187&r2=114188&view=diff ============================================================================== --- lldb/trunk/lldb.xcodeproj/project.pbxproj (original) +++ lldb/trunk/lldb.xcodeproj/project.pbxproj Fri Sep 17 12:42:16 2010 @@ -69,6 +69,8 @@ 268F9D55123AA16600B91E9B /* SBSymbolContextList.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 268F9D54123AA16600B91E9B /* SBSymbolContextList.cpp */; }; 26B42B1F1187A92B0079C8C8 /* lldb-include.h in Headers */ = {isa = PBXBuildFile; fileRef = 26B42B1E1187A92B0079C8C8 /* lldb-include.h */; settings = {ATTRIBUTES = (Public, ); }; }; 26B42C4D1187ABA50079C8C8 /* LLDB.h in Headers */ = {isa = PBXBuildFile; fileRef = 26B42C4C1187ABA50079C8C8 /* LLDB.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 26C72C94124322890068DC16 /* SBStream.h in Headers */ = {isa = PBXBuildFile; fileRef = 26C72C93124322890068DC16 /* SBStream.h */; }; + 26C72C961243229A0068DC16 /* SBStream.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26C72C951243229A0068DC16 /* SBStream.cpp */; }; 26D27C9F11ED3A4E0024D721 /* ELFHeader.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26D27C9D11ED3A4E0024D721 /* ELFHeader.cpp */; }; 26D27CA011ED3A4E0024D721 /* ELFHeader.h in Headers */ = {isa = PBXBuildFile; fileRef = 26D27C9E11ED3A4E0024D721 /* ELFHeader.h */; }; 26D5B06511B07550009A862E /* StoppointCallbackContext.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26BC7E0910F1B83100F91463 /* StoppointCallbackContext.cpp */; }; @@ -849,6 +851,8 @@ 26BC7F3E10F1B90C00F91463 /* ThreadList.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = ThreadList.cpp; path = source/Target/ThreadList.cpp; sourceTree = ""; }; 26BC7F3F10F1B90C00F91463 /* ThreadPlan.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = ThreadPlan.cpp; path = source/Target/ThreadPlan.cpp; sourceTree = ""; }; 26BC7F4C10F1BC1A00F91463 /* ObjectFile.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = ObjectFile.cpp; path = source/Symbol/ObjectFile.cpp; sourceTree = ""; }; + 26C72C93124322890068DC16 /* SBStream.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SBStream.h; path = include/lldb/API/SBStream.h; sourceTree = ""; }; + 26C72C951243229A0068DC16 /* SBStream.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = SBStream.cpp; path = source/API/SBStream.cpp; sourceTree = ""; }; 26C81CA411335651004BDC5A /* UUID.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = UUID.h; path = include/lldb/Core/UUID.h; sourceTree = ""; }; 26C81CA511335651004BDC5A /* UUID.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = UUID.cpp; path = source/Core/UUID.cpp; sourceTree = ""; }; 26C9DF03113C5B93006B0F94 /* lldb */ = {isa = PBXFileReference; lastKnownFileType = folder; name = lldb; path = include/lldb; sourceTree = ""; }; @@ -1481,6 +1485,8 @@ 9A9831031125FC5800A56CB0 /* SBProcess.cpp */, 9A9831061125FC5800A56CB0 /* SBSourceManager.h */, 9A9831051125FC5800A56CB0 /* SBSourceManager.cpp */, + 26C72C93124322890068DC16 /* SBStream.h */, + 26C72C951243229A0068DC16 /* SBStream.cpp */, 9A357670116E7B5200E8ED2F /* SBStringList.h */, 9A357672116E7B6400E8ED2F /* SBStringList.cpp */, 26DE205A11618FF600A093E2 /* SBSymbol.h */, @@ -2278,6 +2284,7 @@ 268F9D53123AA15200B91E9B /* SBSymbolContextList.h in Headers */, 2618D7901240115500F2B8FE /* SectionLoadList.h in Headers */, 2618D959124056C700F2B8FE /* NameToDIE.h in Headers */, + 26C72C94124322890068DC16 /* SBStream.h in Headers */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -2741,6 +2748,7 @@ 268F9D55123AA16600B91E9B /* SBSymbolContextList.cpp in Sources */, 2618D7921240116900F2B8FE /* SectionLoadList.cpp in Sources */, 2618D9EB12406FE600F2B8FE /* NameToDIE.cpp in Sources */, + 26C72C961243229A0068DC16 /* SBStream.cpp in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; Added: lldb/trunk/source/API/SBStream.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBStream.cpp?rev=114188&view=auto ============================================================================== --- lldb/trunk/source/API/SBStream.cpp (added) +++ lldb/trunk/source/API/SBStream.cpp Fri Sep 17 12:42:16 2010 @@ -0,0 +1,178 @@ +//===-- SBStream.cpp ----------------------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#include "lldb/API/SBStream.h" + +#include "lldb/Core/Stream.h" +#include "lldb/Core/StreamFile.h" +#include "lldb/Core/StreamString.h" + +using namespace lldb; +using namespace lldb_private; + +SBStream::SBStream () : + m_opaque_ap (), + m_is_file (false) +{ +} + +SBStream::~SBStream () +{ +} + +bool +SBStream::IsValid() const +{ + return (m_opaque_ap.get() != NULL); +} + +// If this stream is not redirected to a file, it will maintain a local +// cache for the stream data which can be accessed using this accessor. +const char * +SBStream::GetData () +{ + if (m_is_file || m_opaque_ap.get() == NULL) + return NULL; + + return static_cast(m_opaque_ap.get())->GetData(); +} + +// If this stream is not redirected to a file, it will maintain a local +// cache for the stream output whose length can be accessed using this +// accessor. +size_t +SBStream::GetSize() +{ + if (m_is_file || m_opaque_ap.get() == NULL) + return NULL; + + return static_cast(m_opaque_ap.get())->GetSize(); +} + +void +SBStream::Printf (const char *format, ...) +{ + va_list args; + va_start (args, format); + ref().PrintfVarArg (format, args); + va_end (args); +} + +void +SBStream::RedirectToFile (const char *path, bool append) +{ + std::string local_data; + if (m_opaque_ap.get()) + { + // See if we have any locally backed data. If so, copy it so we can then + // redirect it to the file so we don't lose the data + if (!m_is_file) + local_data.swap(static_cast(m_opaque_ap.get())->GetString()); + } + m_opaque_ap.reset (new StreamFile (path, append ? "a" : "w")); + + if (m_opaque_ap.get()) + { + m_is_file = true; + + // If we had any data locally in our StreamString, then pass that along to + // the to new file we are redirecting to. + if (!local_data.empty()) + m_opaque_ap->Write (&local_data[0], local_data.size()); + } + else + m_is_file = false; +} + +void +SBStream::RedirectToFileHandle (FILE *fh, bool transfer_fh_ownership) +{ + std::string local_data; + if (m_opaque_ap.get()) + { + // See if we have any locally backed data. If so, copy it so we can then + // redirect it to the file so we don't lose the data + if (!m_is_file) + local_data.swap(static_cast(m_opaque_ap.get())->GetString()); + } + m_opaque_ap.reset (new StreamFile (fh, transfer_fh_ownership)); + + if (m_opaque_ap.get()) + { + m_is_file = true; + + // If we had any data locally in our StreamString, then pass that along to + // the to new file we are redirecting to. + if (!local_data.empty()) + m_opaque_ap->Write (&local_data[0], local_data.size()); + } + else + m_is_file = false; +} + +void +SBStream::RedirectToFileDescriptor (int fd, bool transfer_fh_ownership) +{ + std::string local_data; + if (m_opaque_ap.get()) + { + // See if we have any locally backed data. If so, copy it so we can then + // redirect it to the file so we don't lose the data + if (!m_is_file) + local_data.swap(static_cast(m_opaque_ap.get())->GetString()); + } + + m_opaque_ap.reset (new StreamFile (::fdopen (fd, "w"), transfer_fh_ownership)); + if (m_opaque_ap.get()) + { + m_is_file = true; + + // If we had any data locally in our StreamString, then pass that along to + // the to new file we are redirecting to. + if (!local_data.empty()) + m_opaque_ap->Write (&local_data[0], local_data.size()); + } + else + m_is_file = false; + +} + +lldb_private::Stream * +SBStream::operator->() +{ + return m_opaque_ap.get(); +} + +lldb_private::Stream * +SBStream::get() +{ + return m_opaque_ap.get(); +} + +lldb_private::Stream & +SBStream::ref() +{ + if (m_opaque_ap.get() == NULL) + m_opaque_ap.reset (new StreamString()); + return *m_opaque_ap.get(); +} + +void +SBStream::Clear () +{ + if (m_opaque_ap.get()) + { + // See if we have any locally backed data. If so, copy it so we can then + // redirect it to the file so we don't lose the data + if (m_is_file) + m_opaque_ap.reset(); + else + static_cast(m_opaque_ap.get())->GetString().clear(); + } +} Modified: lldb/trunk/source/Core/StreamFile.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/StreamFile.cpp?rev=114188&r1=114187&r2=114188&view=diff ============================================================================== --- lldb/trunk/source/Core/StreamFile.cpp (original) +++ lldb/trunk/source/Core/StreamFile.cpp Fri Sep 17 12:42:16 2010 @@ -31,16 +31,16 @@ StreamFile::StreamFile(uint32_t flags, uint32_t addr_size, ByteOrder byte_order, FILE *f) : Stream (flags, addr_size, byte_order), - m_file(f), - m_close_file(false), + m_file (f), + m_close_file (false), m_path_name () { } -StreamFile::StreamFile(FILE *f) : +StreamFile::StreamFile(FILE *f, bool tranfer_ownership) : Stream (), - m_file(f), - m_close_file(false), + m_file (f), + m_close_file (tranfer_ownership), m_path_name () { } From johnny.chen at apple.com Fri Sep 17 13:39:57 2010 From: johnny.chen at apple.com (Johnny Chen) Date: Fri, 17 Sep 2010 18:39:57 -0000 Subject: [Lldb-commits] [lldb] r114194 - in /lldb/trunk: include/lldb/API/SBStringList.h source/API/SBStringList.cpp Message-ID: <20100917183957.70C5D2A6C12C@llvm.org> Author: johnny Date: Fri Sep 17 13:39:57 2010 New Revision: 114194 URL: http://llvm.org/viewvc/llvm-project?rev=114194&view=rev Log: Fixed build error of LLDBWrapPython.cpp by removing the "protected" access modifier. Modified: lldb/trunk/include/lldb/API/SBStringList.h lldb/trunk/source/API/SBStringList.cpp Modified: lldb/trunk/include/lldb/API/SBStringList.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBStringList.h?rev=114194&r1=114193&r2=114194&view=diff ============================================================================== --- lldb/trunk/include/lldb/API/SBStringList.h (original) +++ lldb/trunk/include/lldb/API/SBStringList.h Fri Sep 17 13:39:57 2010 @@ -36,7 +36,7 @@ AppendList (const char **strv, int strc); void - AppendList (lldb::SBStringList strings); + AppendList (const lldb::SBStringList &strings); uint32_t GetSize () const; @@ -47,8 +47,6 @@ void Clear (); -protected: - #ifndef SWIG const lldb_private::StringList * Modified: lldb/trunk/source/API/SBStringList.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBStringList.cpp?rev=114194&r1=114193&r2=114194&view=diff ============================================================================== --- lldb/trunk/source/API/SBStringList.cpp (original) +++ lldb/trunk/source/API/SBStringList.cpp Fri Sep 17 13:39:57 2010 @@ -94,7 +94,7 @@ } void -SBStringList::AppendList (SBStringList strings) +SBStringList::AppendList (const SBStringList &strings) { if (strings.IsValid()) { From johnny.chen at apple.com Fri Sep 17 16:14:02 2010 From: johnny.chen at apple.com (Johnny Chen) Date: Fri, 17 Sep 2010 21:14:02 -0000 Subject: [Lldb-commits] [lldb] r114210 - /lldb/trunk/test/foundation/TestObjCMethods.py Message-ID: <20100917211402.86FC92A6C12C@llvm.org> Author: johnny Date: Fri Sep 17 16:14:02 2010 New Revision: 114210 URL: http://llvm.org/viewvc/llvm-project?rev=114210&view=rev Log: Changed test case method names. 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=114210&r1=114209&r2=114210&view=diff ============================================================================== --- lldb/trunk/test/foundation/TestObjCMethods.py (original) +++ lldb/trunk/test/foundation/TestObjCMethods.py Fri Sep 17 16:14:02 2010 @@ -1,4 +1,4 @@ -"""Set breakpoint on objective-c class and instance methods in foundation.""" +"""Set breakpoints on objective-c class and instance methods in foundation.""" import os, time import unittest2 @@ -10,12 +10,12 @@ mydir = "foundation" - def test_with_dsym(self): + def test_break_with_dsym(self): """Test setting objc breakpoints using 'regexp-break' and 'breakpoint set'.""" self.buildDsym() self.break_on_objc_methods() - def test_with_dwarf(self): + def test_break_with_dwarf(self): """Test setting objc breakpoints using 'regexp-break' and 'breakpoint set'.""" self.buildDwarf() self.break_on_objc_methods() From johnny.chen at apple.com Fri Sep 17 17:28:51 2010 From: johnny.chen at apple.com (Johnny Chen) Date: Fri, 17 Sep 2010 22:28:51 -0000 Subject: [Lldb-commits] [lldb] r114228 - in /lldb/trunk/test: foundation/TestObjCMethods.py lldbtest.py Message-ID: <20100917222851.CCF682A6C12C@llvm.org> Author: johnny Date: Fri Sep 17 17:28:51 2010 New Revision: 114228 URL: http://llvm.org/viewvc/llvm-project?rev=114228&view=rev Log: Added test cases to FoundationTestCase to exercise lookup of objc data types and to evaluate expressions. Marked with @expectedFailure decorators for the time being. Enhanced the lldbtest.TestBase.expect() API to allow an additional keyword arg named "error". If the client passes "error=True", it signifies that an error while running the command is expected. The golden input is then compared against the return object's error output. Modified: lldb/trunk/test/foundation/TestObjCMethods.py lldb/trunk/test/lldbtest.py Modified: lldb/trunk/test/foundation/TestObjCMethods.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/foundation/TestObjCMethods.py?rev=114228&r1=114227&r2=114228&view=diff ============================================================================== --- lldb/trunk/test/foundation/TestObjCMethods.py (original) +++ lldb/trunk/test/foundation/TestObjCMethods.py Fri Sep 17 17:28:51 2010 @@ -1,4 +1,7 @@ -"""Set breakpoints on objective-c class and instance methods in foundation.""" +""" +Set breakpoints on objective-c class and instance methods in foundation. +Also lookup objective-c data types and evaluate expressions. +""" import os, time import unittest2 @@ -20,6 +23,18 @@ self.buildDwarf() self.break_on_objc_methods() + @unittest2.expectedFailure + def test_data_type_and_expr_with_dsym(self): + """Lookup objective-c data types and evaluate expressions.""" + self.buildDsym() + self.data_type_and_expr_objc() + + @unittest2.expectedFailure + def test_data_type_and_expr_with_dwarf(self): + """Lookup objective-c data types and evaluate expressions.""" + self.buildDwarf() + self.data_type_and_expr_objc() + def break_on_objc_methods(self): """Test setting objc breakpoints using 'regexp-break' and 'breakpoint set'.""" exe = os.path.join(os.getcwd(), "a.out") @@ -65,6 +80,56 @@ self.expect("thread backtrace", "Stop at -[NSAutoreleasePool release]", substrs = ["Foundation`-[NSAutoreleasePool release]"]) + def data_type_and_expr_objc(self): + """Lookup objective-c data types and evaluate expressions.""" + exe = os.path.join(os.getcwd(), "a.out") + self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) + + # Stop at -[MyString description]. + self.expect("breakpoint set -n '-[MyString description]", BREAKPOINT_CREATED, + startstr = "Breakpoint created: 1: name = '-[MyString description]', locations = 1") + + self.runCmd("run", RUN_SUCCEEDED) + + # The backtrace should show we stop at -[MyString description]. + self.expect("thread backtrace", "Stop at -[MyString description]", + substrs = ["a.out`-[MyString description]"]) + + # Lookup objc data type MyString and evaluate some expressions. + + self.expect("image lookup -t NSString", DATA_TYPES_DISPLAYED_CORRECTLY, + substrs = ["@interface NSString : NSObject at end"]) + + self.expect("image lookup -t MyString", DATA_TYPES_DISPLAYED_CORRECTLY, + substrs = ["@interface MyString : NSObject", + "NSString * str;", + "NSDate * date;"]) + + self.expect("frame variable -s", VARIABLES_DISPLAYED_CORRECTLY, + substrs = ["ARG: (MyString *) self", + "ARG: (struct objc_selector *) _cmd"]) + + self.expect("expr self->non_existent_member", VARIABLES_DISPLAYED_CORRECTLY, error=True, + startstr = "error: 'MyString' does not have a member named 'non_existent_member'") + + self.expect("frame variable self->str", VARIABLES_DISPLAYED_CORRECTLY, + startstr = "(NSString *) self->str") + + # rdar://problem/8447030 + # 'frame variable self->date' displays the wrong data member + self.expect("frame variable self->date", VARIABLES_DISPLAYED_CORRECTLY, + startstr = "(NSDate *) self->date") + + # TODO: use expression parser. + # (lldb) expr self->str + # error: instance variable 'str' is protected + # error: 1 errors parsing expression + # Couldn't parse the expresssion + # (lldb) expr self->date + # error: instance variable 'date' is protected + # error: 1 errors parsing expression + # Couldn't parse the expresssion + if __name__ == '__main__': import atexit Modified: lldb/trunk/test/lldbtest.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/lldbtest.py?rev=114228&r1=114227&r2=114228&view=diff ============================================================================== --- lldb/trunk/test/lldbtest.py (original) +++ lldb/trunk/test/lldbtest.py Fri Sep 17 17:28:51 2010 @@ -397,7 +397,7 @@ self.assertTrue(self.res.Succeeded(), msg if msg else CMD_MSG(cmd)) - def expect(self, cmd, msg=None, startstr=None, substrs=None, trace=False): + def expect(self, cmd, msg=None, startstr=None, substrs=None, trace=False, error=False): """ Similar to runCmd; with additional expect style output matching ability. @@ -405,14 +405,25 @@ return status. The 'msg' parameter specifies an informational assert message. We expect the output from running the command to start with 'startstr' and matches the substrings contained in 'substrs'. + + If the keyword argument error is set to True, it signifies that the API + client is expecting the command to fail. In this case, the error stream + from running the command is retrieved and compared againt the golden + input, instead. """ trace = (True if traceAlways else trace) - # First run the command. - self.runCmd(cmd, trace = (True if trace else False)) + # First run the command. If we are expecting error, set check=False. + self.runCmd(cmd, trace = (True if trace else False), check = not error) # Then compare the output against expected strings. - output = self.res.GetOutput() + output = self.res.GetError() if error else self.res.GetOutput() + + # If error is True, the API client expects the command to fail! + if error: + self.assertFalse(self.res.Succeeded(), + "Command '" + cmd + "' is expected to fail!") + matched = output.startswith(startstr) if startstr else True if startstr and trace: From johnny.chen at apple.com Fri Sep 17 17:45:27 2010 From: johnny.chen at apple.com (Johnny Chen) Date: Fri, 17 Sep 2010 22:45:27 -0000 Subject: [Lldb-commits] [lldb] r114232 - in /lldb/trunk/test: foundation/TestObjCMethods.py lldbtest.py Message-ID: <20100917224527.C1EA12A6C12C@llvm.org> Author: johnny Date: Fri Sep 17 17:45:27 2010 New Revision: 114232 URL: http://llvm.org/viewvc/llvm-project?rev=114232&view=rev Log: Fixed a typo and supplied a more appropriate assert message. Modified: lldb/trunk/test/foundation/TestObjCMethods.py lldb/trunk/test/lldbtest.py Modified: lldb/trunk/test/foundation/TestObjCMethods.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/foundation/TestObjCMethods.py?rev=114232&r1=114231&r2=114232&view=diff ============================================================================== --- lldb/trunk/test/foundation/TestObjCMethods.py (original) +++ lldb/trunk/test/foundation/TestObjCMethods.py Fri Sep 17 17:45:27 2010 @@ -109,7 +109,7 @@ substrs = ["ARG: (MyString *) self", "ARG: (struct objc_selector *) _cmd"]) - self.expect("expr self->non_existent_member", VARIABLES_DISPLAYED_CORRECTLY, error=True, + self.expect("expr self->non_existent_member", COMMAND_FAILED_AS_EXPECTED, error=True, startstr = "error: 'MyString' does not have a member named 'non_existent_member'") self.expect("frame variable self->str", VARIABLES_DISPLAYED_CORRECTLY, Modified: lldb/trunk/test/lldbtest.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/lldbtest.py?rev=114232&r1=114231&r2=114232&view=diff ============================================================================== --- lldb/trunk/test/lldbtest.py (original) +++ lldb/trunk/test/lldbtest.py Fri Sep 17 17:45:27 2010 @@ -113,6 +113,8 @@ # Some commonly used assert messages. # +COMMAND_FAILED_AS_EXPECTED = "Command has failed as expected" + CURRENT_EXECUTABLE_SET = "Current executable set successfully" PROCESS_IS_VALID = "Process is valid" @@ -408,7 +410,7 @@ If the keyword argument error is set to True, it signifies that the API client is expecting the command to fail. In this case, the error stream - from running the command is retrieved and compared againt the golden + from running the command is retrieved and compared against the golden input, instead. """ trace = (True if traceAlways else trace) From johnny.chen at apple.com Fri Sep 17 19:16:47 2010 From: johnny.chen at apple.com (Johnny Chen) Date: Sat, 18 Sep 2010 00:16:47 -0000 Subject: [Lldb-commits] [lldb] r114245 - /lldb/trunk/test/dotest.py Message-ID: <20100918001647.96C9A2A6C12C@llvm.org> Author: johnny Date: Fri Sep 17 19:16:47 2010 New Revision: 114245 URL: http://llvm.org/viewvc/llvm-project?rev=114245&view=rev Log: Added a hook for the test driver to take an optional config file to customize the running of the test suite. Right now, it doesn't do anything with the config file. Pass "-c myConfigFile" to specify the config file. Modified: lldb/trunk/test/dotest.py Modified: lldb/trunk/test/dotest.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/dotest.py?rev=114245&r1=114244&r2=114245&view=diff ============================================================================== --- lldb/trunk/test/dotest.py (original) +++ lldb/trunk/test/dotest.py Fri Sep 17 19:16:47 2010 @@ -45,6 +45,9 @@ # The test suite. suite = unittest2.TestSuite() +# The config file is optional. +configFile = None + # Delay startup in order for the debugger to attach. delay = False @@ -69,6 +72,7 @@ Usage: dotest.py [option] [args] where options: -h : print this help message and exit (also --help) +-c : read a config file specified after this option -d : delay startup for 10 seconds (in order for the debugger to attach) -i : ignore (don't bailout) if 'lldb.py' module cannot be located in the build tree relative to this script; use PYTHONPATH to locate the module @@ -93,6 +97,7 @@ 'process.gdb-remote' subsystem with a default option of 'packets' if GDB_REMOTE_LOG_OPTION is not defined. """ + sys.exit(0) def parseOptionsAndInitTestdirs(): @@ -101,6 +106,7 @@ '-h/--help as the first option prints out usage info and exit the program. """ + global configFile global delay global inore global verbose @@ -118,7 +124,16 @@ if sys.argv[index].find('-h') != -1: usage() - sys.exit(0) + elif sys.argv[index].startswith('-c'): + # Increment by 1 to fetch the config file name option argument. + index += 1 + if index >= len(sys.argv) or sys.argv[index].startswith('-'): + usage() + configFile = sys.argv[index] + if not os.path.isfile(configFile): + print "Config file:", configFile, "does not exist!" + usage() + index += 1 elif sys.argv[index].startswith('-d'): delay = True index += 1 @@ -134,7 +149,6 @@ else: print "Unknown option: ", sys.argv[index] usage() - sys.exit(0) # Gather all the dirs passed on the command line. if len(sys.argv) > index: From rjmccall at apple.com Fri Sep 17 20:17:35 2010 From: rjmccall at apple.com (John McCall) Date: Fri, 17 Sep 2010 18:17:35 -0700 Subject: [Lldb-commits] [lldb] r114095 - in /lldb/trunk/include/lldb: Core/Debugger.h Target/Process.h Target/Thread.h In-Reply-To: <8C04151D-51EB-47F3-A5DA-53879713B697@gmail.com> References: <20100916173705.E68162A6C12C@llvm.org> <1F6A7075-3061-4F1A-A288-E719C6293879@apple.com> <8C04151D-51EB-47F3-A5DA-53879713B697@gmail.com> Message-ID: On Sep 16, 2010, at 4:19 PM, Benjamin Kramer wrote: > On 17.09.2010, at 01:04, John McCall wrote: >> On Sep 16, 2010, at 10:54 AM, Caroline Tice wrote: >>> Okay I will work on re-doing the code so it doesn't have to do that. For the record, the code as is works >>> just fine on Mac OS X; I had no idea it would die so horribly on other platforms. >> >> It really shouldn't die horribly on any platform, although some compilers will warn about it, particularly in the initializer lists. > > It does die horribly when compiled with clang++. Maybe we have a clang bug here? Fixed in r 114153, by the way. John. From gclayton at apple.com Fri Sep 17 20:14:36 2010 From: gclayton at apple.com (Greg Clayton) Date: Sat, 18 Sep 2010 01:14:36 -0000 Subject: [Lldb-commits] [lldb] r114252 - in /lldb/trunk: include/lldb/API/ include/lldb/Core/ include/lldb/Interpreter/ include/lldb/Target/ lldb.xcodeproj/ source/API/ source/Commands/ source/Core/ source/Interpreter/ tools/driver/ Message-ID: <20100918011437.2B2B92A6C12C@llvm.org> Author: gclayton Date: Fri Sep 17 20:14:36 2010 New Revision: 114252 URL: http://llvm.org/viewvc/llvm-project?rev=114252&view=rev Log: Fixed the way set/show variables were being accessed to being natively accessed by the objects that own the settings. The previous approach wasn't very usable and made for a lot of unnecessary code just to access variables that were already owned by the objects. While I fixed those things, I saw that CommandObject objects should really have a reference to their command interpreter so they can access the terminal with if they want to output usaage. Fixed up all CommandObjects to take an interpreter and cleaned up the API to not need the interpreter to be passed in. Fixed the disassemble command to output the usage if no options are passed down and arguments are passed (all disassebmle variants take options, there are no "args only"). Modified: lldb/trunk/include/lldb/API/SBDebugger.h lldb/trunk/include/lldb/Core/Debugger.h lldb/trunk/include/lldb/Interpreter/CommandObject.h lldb/trunk/include/lldb/Interpreter/CommandObjectCrossref.h lldb/trunk/include/lldb/Interpreter/CommandObjectMultiword.h lldb/trunk/include/lldb/Interpreter/CommandObjectRegexCommand.h lldb/trunk/include/lldb/Interpreter/Options.h lldb/trunk/include/lldb/Interpreter/ScriptInterpreter.h lldb/trunk/include/lldb/Interpreter/ScriptInterpreterNone.h lldb/trunk/include/lldb/Interpreter/ScriptInterpreterPython.h lldb/trunk/include/lldb/Target/Process.h lldb/trunk/lldb.xcodeproj/project.pbxproj lldb/trunk/source/API/SBDebugger.cpp lldb/trunk/source/Commands/CommandObjectApropos.cpp lldb/trunk/source/Commands/CommandObjectApropos.h lldb/trunk/source/Commands/CommandObjectArgs.cpp lldb/trunk/source/Commands/CommandObjectArgs.h lldb/trunk/source/Commands/CommandObjectBreakpoint.cpp lldb/trunk/source/Commands/CommandObjectBreakpoint.h lldb/trunk/source/Commands/CommandObjectBreakpointCommand.cpp lldb/trunk/source/Commands/CommandObjectBreakpointCommand.h lldb/trunk/source/Commands/CommandObjectCall.cpp lldb/trunk/source/Commands/CommandObjectCall.h lldb/trunk/source/Commands/CommandObjectCommands.cpp lldb/trunk/source/Commands/CommandObjectCrossref.cpp lldb/trunk/source/Commands/CommandObjectDisassemble.cpp lldb/trunk/source/Commands/CommandObjectDisassemble.h lldb/trunk/source/Commands/CommandObjectExpression.cpp lldb/trunk/source/Commands/CommandObjectExpression.h lldb/trunk/source/Commands/CommandObjectFile.cpp lldb/trunk/source/Commands/CommandObjectFile.h lldb/trunk/source/Commands/CommandObjectFrame.cpp lldb/trunk/source/Commands/CommandObjectHelp.cpp lldb/trunk/source/Commands/CommandObjectHelp.h lldb/trunk/source/Commands/CommandObjectImage.cpp lldb/trunk/source/Commands/CommandObjectLog.cpp lldb/trunk/source/Commands/CommandObjectMemory.cpp lldb/trunk/source/Commands/CommandObjectMultiword.cpp lldb/trunk/source/Commands/CommandObjectProcess.cpp lldb/trunk/source/Commands/CommandObjectQuit.cpp lldb/trunk/source/Commands/CommandObjectQuit.h lldb/trunk/source/Commands/CommandObjectRegister.cpp lldb/trunk/source/Commands/CommandObjectSettings.cpp lldb/trunk/source/Commands/CommandObjectSettings.h lldb/trunk/source/Commands/CommandObjectSource.cpp lldb/trunk/source/Commands/CommandObjectSyntax.cpp lldb/trunk/source/Commands/CommandObjectSyntax.h lldb/trunk/source/Commands/CommandObjectTarget.cpp lldb/trunk/source/Commands/CommandObjectThread.cpp lldb/trunk/source/Core/Debugger.cpp lldb/trunk/source/Interpreter/CommandInterpreter.cpp lldb/trunk/source/Interpreter/CommandObject.cpp lldb/trunk/source/Interpreter/CommandObjectRegexCommand.cpp lldb/trunk/source/Interpreter/CommandObjectScript.cpp lldb/trunk/source/Interpreter/CommandObjectScript.h lldb/trunk/source/Interpreter/Options.cpp lldb/trunk/source/Interpreter/ScriptInterpreter.cpp lldb/trunk/source/Interpreter/ScriptInterpreterNone.cpp lldb/trunk/source/Interpreter/ScriptInterpreterPython.cpp lldb/trunk/tools/driver/Driver.cpp Modified: lldb/trunk/include/lldb/API/SBDebugger.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBDebugger.h?rev=114252&r1=114251&r2=114252&view=diff ============================================================================== --- lldb/trunk/include/lldb/API/SBDebugger.h (original) +++ lldb/trunk/include/lldb/API/SBDebugger.h Fri Sep 17 20:14:36 2010 @@ -154,6 +154,24 @@ static lldb::SBStringList GetInternalVariableValue (const char *var_name, const char *debugger_instance_name); + uint32_t + GetTerminalWidth () const; + + void + SetTerminalWidth (uint32_t term_width); + + const char * + GetPrompt() const; + + void + SetPrompt (const char *prompt); + + lldb::ScriptLanguage + GetScriptLanguage() const; + + void + SetScriptLanguage (lldb::ScriptLanguage script_lang); + private: #ifndef SWIG Modified: lldb/trunk/include/lldb/Core/Debugger.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/Debugger.h?rev=114252&r1=114251&r2=114252&view=diff ============================================================================== --- lldb/trunk/include/lldb/Core/Debugger.h (original) +++ lldb/trunk/include/lldb/Core/Debugger.h Fri Sep 17 20:14:36 2010 @@ -65,6 +65,45 @@ const ConstString &var_name, StringList &value); + uint32_t + GetTerminalWidth () const + { + return m_term_width; + } + + void + SetTerminalWidth (uint32_t term_width) + { + m_term_width = term_width; + } + + const char * + GetPrompt() const + { + return m_prompt.c_str(); + } + + void + SetPrompt(const char *p) + { + if (p) + m_prompt.assign (p); + else + m_prompt.assign ("(lldb) "); + } + + lldb::ScriptLanguage + GetScriptLanguage() const + { + return m_script_lang; + } + + void + SetScriptLanguage (lldb::ScriptLanguage script_lang) + { + m_script_lang = script_lang; + } + protected: void @@ -91,7 +130,7 @@ private: - int m_term_width; + uint32_t m_term_width; std::string m_prompt; lldb::ScriptLanguage m_script_lang; }; Modified: lldb/trunk/include/lldb/Interpreter/CommandObject.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Interpreter/CommandObject.h?rev=114252&r1=114251&r2=114252&view=diff ============================================================================== --- lldb/trunk/include/lldb/Interpreter/CommandObject.h (original) +++ lldb/trunk/include/lldb/Interpreter/CommandObject.h Fri Sep 17 20:14:36 2010 @@ -28,7 +28,8 @@ typedef std::map CommandMap; - CommandObject (const char *name, + CommandObject (CommandInterpreter &interpreter, + const char *name, const char *help = NULL, const char *syntax = NULL, uint32_t flags = 0); @@ -36,6 +37,12 @@ virtual ~CommandObject (); + CommandInterpreter & + GetCommandInterpreter () + { + return m_interpreter; + } + const char * GetHelp (); @@ -89,23 +96,19 @@ // Do not override this bool - ExecuteCommandString (CommandInterpreter &interpreter, - const char *command, + ExecuteCommandString (const char *command, CommandReturnObject &result); bool - ParseOptions (CommandInterpreter &interpreter, - Args& args, + ParseOptions (Args& args, CommandReturnObject &result); bool - ExecuteWithOptions (CommandInterpreter &interpreter, - Args& command, + ExecuteWithOptions (Args& command, CommandReturnObject &result); virtual bool - ExecuteRawCommandString (CommandInterpreter &interpreter, - const char *command, + ExecuteRawCommandString (const char *command, CommandReturnObject &result) { return false; @@ -113,8 +116,7 @@ virtual bool - Execute (CommandInterpreter &interpreter, - Args& command, + Execute (Args& command, CommandReturnObject &result) = 0; void @@ -169,8 +171,7 @@ /// \btrue if we were in an option, \bfalse otherwise. //------------------------------------------------------------------ virtual int - HandleCompletion (CommandInterpreter &interpreter, - Args &input, + HandleCompletion (Args &input, int &cursor_index, int &cursor_char_position, int match_start_point, @@ -219,8 +220,7 @@ //------------------------------------------------------------------ virtual int - HandleArgumentCompletion (CommandInterpreter &interpreter, - Args &input, + HandleArgumentCompletion (Args &input, int &cursor_index, int &cursor_char_position, OptionElementVector &opt_element_vector, @@ -233,7 +233,7 @@ } bool - HelpTextContainsWord (const char *search_word, CommandInterpreter &interpreter); + HelpTextContainsWord (const char *search_word); //------------------------------------------------------------------ /// The flags accessor. @@ -270,6 +270,7 @@ } protected: + CommandInterpreter &m_interpreter; std::string m_cmd_name; std::string m_cmd_help_short; std::string m_cmd_help_long; Modified: lldb/trunk/include/lldb/Interpreter/CommandObjectCrossref.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Interpreter/CommandObjectCrossref.h?rev=114252&r1=114251&r2=114252&view=diff ============================================================================== --- lldb/trunk/include/lldb/Interpreter/CommandObjectCrossref.h (original) +++ lldb/trunk/include/lldb/Interpreter/CommandObjectCrossref.h Fri Sep 17 20:14:36 2010 @@ -26,10 +26,11 @@ class CommandObjectCrossref : public CommandObject { public: - CommandObjectCrossref (const char *name, - const char *help = NULL, - const char *syntax = NULL); - + CommandObjectCrossref (CommandInterpreter &interpreter, + const char *name, + const char *help = NULL, + const char *syntax = NULL); + virtual ~CommandObjectCrossref (); @@ -37,8 +38,7 @@ GenerateHelpText (CommandReturnObject &result); virtual bool - Execute (CommandInterpreter &interpreter, - Args& command, + Execute (Args& command, CommandReturnObject &result); virtual bool Modified: lldb/trunk/include/lldb/Interpreter/CommandObjectMultiword.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Interpreter/CommandObjectMultiword.h?rev=114252&r1=114251&r2=114252&view=diff ============================================================================== --- lldb/trunk/include/lldb/Interpreter/CommandObjectMultiword.h (original) +++ lldb/trunk/include/lldb/Interpreter/CommandObjectMultiword.h Fri Sep 17 20:14:36 2010 @@ -27,7 +27,8 @@ class CommandObjectMultiword : public CommandObject { public: - CommandObjectMultiword (const char *name, + CommandObjectMultiword (CommandInterpreter &interpreter, + const char *name, const char *help = NULL, const char *syntax = NULL, uint32_t flags = 0); @@ -39,12 +40,11 @@ IsMultiwordObject () { return true; } bool - LoadSubCommand (CommandInterpreter &interpreter, - const char *cmd_name, + LoadSubCommand (const char *cmd_name, const lldb::CommandObjectSP& command_obj); void - GenerateHelpText (CommandInterpreter &interpreter, CommandReturnObject &result); + GenerateHelpText (CommandReturnObject &result); lldb::CommandObjectSP GetSubcommandSP (const char *sub_cmd, StringList *matches = NULL); @@ -53,13 +53,11 @@ GetSubcommandObject (const char *sub_cmd, StringList *matches = NULL); virtual bool - Execute (CommandInterpreter &interpreter, - Args& command, + Execute (Args& command, CommandReturnObject &result); virtual int - HandleCompletion (CommandInterpreter &interpreter, - Args &input, + HandleCompletion (Args &input, int &cursor_index, int &cursor_char_position, int match_start_point, Modified: lldb/trunk/include/lldb/Interpreter/CommandObjectRegexCommand.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Interpreter/CommandObjectRegexCommand.h?rev=114252&r1=114251&r2=114252&view=diff ============================================================================== --- lldb/trunk/include/lldb/Interpreter/CommandObjectRegexCommand.h (original) +++ lldb/trunk/include/lldb/Interpreter/CommandObjectRegexCommand.h Fri Sep 17 20:14:36 2010 @@ -29,22 +29,24 @@ { public: - CommandObjectRegexCommand (const char *name, const char *help, const char *syntax, uint32_t max_matches); - + CommandObjectRegexCommand (CommandInterpreter &interpreter, + const char *name, + const char *help, + const char *syntax, + uint32_t max_matches); + virtual ~CommandObjectRegexCommand (); virtual bool - Execute (CommandInterpreter &interpreter, - Args& command, + Execute (Args& command, CommandReturnObject &result); virtual bool WantsRawCommandString() { return true; } virtual bool - ExecuteRawCommandString (CommandInterpreter &interpreter, - const char *command, + ExecuteRawCommandString (const char *command, CommandReturnObject &result); Modified: lldb/trunk/include/lldb/Interpreter/Options.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Interpreter/Options.h?rev=114252&r1=114251&r2=114252&view=diff ============================================================================== --- lldb/trunk/include/lldb/Interpreter/Options.h (original) +++ lldb/trunk/include/lldb/Interpreter/Options.h Fri Sep 17 20:14:36 2010 @@ -157,10 +157,9 @@ uint32_t output_max_columns); void - GenerateOptionUsage (Stream &strm, - CommandObject *cmd, - const char *debugger_instance_name, - const char *program_name = NULL); + GenerateOptionUsage (CommandInterpreter &interpreter, + Stream &strm, + CommandObject *cmd); // The following two pure virtual functions must be defined by every class that inherits from // this class. Modified: lldb/trunk/include/lldb/Interpreter/ScriptInterpreter.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Interpreter/ScriptInterpreter.h?rev=114252&r1=114251&r2=114252&view=diff ============================================================================== --- lldb/trunk/include/lldb/Interpreter/ScriptInterpreter.h (original) +++ lldb/trunk/include/lldb/Interpreter/ScriptInterpreter.h Fri Sep 17 20:14:36 2010 @@ -38,15 +38,15 @@ } ReturnType; - ScriptInterpreter (lldb::ScriptLanguage script_lang); + ScriptInterpreter (CommandInterpreter &interpreter, lldb::ScriptLanguage script_lang); virtual ~ScriptInterpreter (); virtual bool - ExecuteOneLine (CommandInterpreter &interpreter, const char *command, CommandReturnObject *result) = 0; + ExecuteOneLine (const char *command, CommandReturnObject *result) = 0; virtual void - ExecuteInterpreterLoop (CommandInterpreter &interpreter) = 0; + ExecuteInterpreterLoop () = 0; virtual bool ExecuteOneLineWithReturn (const char *in_string, ReturnType return_type, void *ret_value) @@ -73,14 +73,12 @@ } virtual void - CollectDataForBreakpointCommandCallback (CommandInterpreter &interpreter, - BreakpointOptions *bp_options, + CollectDataForBreakpointCommandCallback (BreakpointOptions *bp_options, CommandReturnObject &result); /// Set a one-liner as the callback for the breakpoint. virtual void - SetBreakpointCommandCallback (CommandInterpreter &interpreter, - BreakpointOptions *bp_options, + SetBreakpointCommandCallback (BreakpointOptions *bp_options, const char *oneliner) { return; @@ -98,6 +96,9 @@ static std::string LanguageToString (lldb::ScriptLanguage); +protected: + CommandInterpreter &m_interpreter; + private: lldb::ScriptLanguage m_script_lang; Modified: lldb/trunk/include/lldb/Interpreter/ScriptInterpreterNone.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Interpreter/ScriptInterpreterNone.h?rev=114252&r1=114251&r2=114252&view=diff ============================================================================== --- lldb/trunk/include/lldb/Interpreter/ScriptInterpreterNone.h (original) +++ lldb/trunk/include/lldb/Interpreter/ScriptInterpreterNone.h Fri Sep 17 20:14:36 2010 @@ -23,10 +23,10 @@ ~ScriptInterpreterNone (); bool - ExecuteOneLine (CommandInterpreter &interpreter, const char *command, CommandReturnObject *result); + ExecuteOneLine (const char *command, CommandReturnObject *result); void - ExecuteInterpreterLoop (CommandInterpreter &interpreter); + ExecuteInterpreterLoop (); }; Modified: lldb/trunk/include/lldb/Interpreter/ScriptInterpreterPython.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Interpreter/ScriptInterpreterPython.h?rev=114252&r1=114251&r2=114252&view=diff ============================================================================== --- lldb/trunk/include/lldb/Interpreter/ScriptInterpreterPython.h (original) +++ lldb/trunk/include/lldb/Interpreter/ScriptInterpreterPython.h Fri Sep 17 20:14:36 2010 @@ -25,10 +25,10 @@ ~ScriptInterpreterPython (); bool - ExecuteOneLine (CommandInterpreter &interpreter, const char *command, CommandReturnObject *result); + ExecuteOneLine (const char *command, CommandReturnObject *result); void - ExecuteInterpreterLoop (CommandInterpreter &interpreter); + ExecuteInterpreterLoop (); bool ExecuteOneLineWithReturn (const char *in_string, @@ -58,14 +58,12 @@ lldb::user_id_t break_loc_id); void - CollectDataForBreakpointCommandCallback (CommandInterpreter &interpreter, - BreakpointOptions *bp_options, + CollectDataForBreakpointCommandCallback (BreakpointOptions *bp_options, CommandReturnObject &result); /// Set a Python one-liner as the callback for the breakpoint. void - SetBreakpointCommandCallback (CommandInterpreter &interpreter, - BreakpointOptions *bp_options, + SetBreakpointCommandCallback (BreakpointOptions *bp_options, const char *oneliner); StringList Modified: lldb/trunk/include/lldb/Target/Process.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/Process.h?rev=114252&r1=114251&r2=114252&view=diff ============================================================================== --- lldb/trunk/include/lldb/Target/Process.h (original) +++ lldb/trunk/include/lldb/Target/Process.h Fri Sep 17 20:14:36 2010 @@ -75,6 +75,107 @@ StringList &value); + const Args & + GetRunArguments () const + { + return m_run_args; + } + + void + SetRunArguments (const Args &args) + { + m_run_args = args; + } + + size_t + GetEnvironmentAsArgs (Args &env) const + { + dictionary::const_iterator pos, end = m_env_vars.end(); + for (pos = m_env_vars.begin(); pos != end; ++pos) + { + std::string env_var_equal_value (pos->first); + env_var_equal_value.append(1, '='); + env_var_equal_value.append (pos->second); + env.AppendArgument (env_var_equal_value.c_str()); + } + return env.GetArgumentCount(); + } + + const char * + GetStandardInputPath () const + { + if (m_input_path.empty()) + return NULL; + return m_input_path.c_str(); + } + + void + SetStandardInputPath (const char *path) + { + if (path && path[0]) + m_input_path.assign (path); + else + { + // Make sure we deallocate memory in string... + std::string tmp; + tmp.swap (m_input_path); + } + } + + const char * + GetStandardOutputPath () const + { + if (m_output_path.empty()) + return NULL; + return m_output_path.c_str(); + } + + void + SetStandardOutputPath (const char *path) + { + if (path && path[0]) + m_output_path.assign (path); + else + { + // Make sure we deallocate memory in string... + std::string tmp; + tmp.swap (m_output_path); + } + } + + const char * + GetStandardErrorPath () const + { + if (m_error_path.empty()) + return NULL; + return m_error_path.c_str(); + } + + void + SetStandardErrorPath (const char *path) + { + if (path && path[0]) + m_error_path.assign (path); + else + { + // Make sure we deallocate memory in string... + std::string tmp; + tmp.swap (m_error_path); + } + } + + bool + GetDisableASLR () const + { + return m_disable_aslr; + } + + void + SetDisableASLR (bool b) + { + m_disable_aslr = b; + } + protected: void @@ -108,8 +209,9 @@ private: + typedef std::map dictionary; Args m_run_args; - std::map m_env_vars; + dictionary m_env_vars; std::string m_input_path; std::string m_output_path; std::string m_error_path; Modified: lldb/trunk/lldb.xcodeproj/project.pbxproj URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/lldb.xcodeproj/project.pbxproj?rev=114252&r1=114251&r2=114252&view=diff ============================================================================== --- lldb/trunk/lldb.xcodeproj/project.pbxproj (original) +++ lldb/trunk/lldb.xcodeproj/project.pbxproj Fri Sep 17 20:14:36 2010 @@ -2339,6 +2339,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/SBDebugger.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBDebugger.cpp?rev=114252&r1=114251&r2=114252&view=diff ============================================================================== --- lldb/trunk/source/API/SBDebugger.cpp (original) +++ lldb/trunk/source/API/SBDebugger.cpp Fri Sep 17 20:14:36 2010 @@ -602,6 +602,55 @@ return ret_value; } +uint32_t +SBDebugger::GetTerminalWidth () const +{ + if (m_opaque_sp) + return m_opaque_sp->GetTerminalWidth (); + return 0; +} + +void +SBDebugger::SetTerminalWidth (uint32_t term_width) +{ + if (m_opaque_sp) + m_opaque_sp->SetTerminalWidth (term_width); +} + +const char * +SBDebugger::GetPrompt() const +{ + if (m_opaque_sp) + return m_opaque_sp->GetPrompt (); + return 0; +} + +void +SBDebugger::SetPrompt (const char *prompt) +{ + if (m_opaque_sp) + m_opaque_sp->SetPrompt (prompt); +} + + +lldb::ScriptLanguage +SBDebugger::GetScriptLanguage() const +{ + if (m_opaque_sp) + return m_opaque_sp->GetScriptLanguage (); + return eScriptLanguageNone; +} + +void +SBDebugger::SetScriptLanguage (lldb::ScriptLanguage script_lang) +{ + if (m_opaque_sp) + m_opaque_sp->SetScriptLanguage (script_lang); +} + + + + bool SBDebugger::SetUseExternalEditor (bool value) { Modified: lldb/trunk/source/Commands/CommandObjectApropos.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectApropos.cpp?rev=114252&r1=114251&r2=114252&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectApropos.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectApropos.cpp Fri Sep 17 20:14:36 2010 @@ -26,10 +26,11 @@ // CommandObjectApropos //------------------------------------------------------------------------- -CommandObjectApropos::CommandObjectApropos () : - CommandObject ("apropos", - "Find a list of debugger commands related to a particular word/subject.", - "apropos ") +CommandObjectApropos::CommandObjectApropos (CommandInterpreter &interpreter) : + CommandObject (interpreter, + "apropos", + "Find a list of debugger commands related to a particular word/subject.", + "apropos ") { } @@ -41,7 +42,6 @@ bool CommandObjectApropos::Execute ( - CommandInterpreter &interpreter, Args& args, CommandReturnObject &result ) @@ -58,7 +58,7 @@ // is private. StringList commands_found; StringList commands_help; - interpreter.FindCommandsForApropos (search_word, commands_found, commands_help); + m_interpreter.FindCommandsForApropos (search_word, commands_found, commands_help); if (commands_found.GetSize() == 0) { result.AppendMessageWithFormat ("No commands found pertaining to '%s'.", search_word); @@ -77,12 +77,12 @@ } for (size_t i = 0; i < commands_found.GetSize(); ++i) - interpreter.OutputFormattedHelpText (result.GetOutputStream(), - commands_found.GetStringAtIndex(i), - "--", commands_help. - GetStringAtIndex(i), - max_len); - + m_interpreter.OutputFormattedHelpText (result.GetOutputStream(), + commands_found.GetStringAtIndex(i), + "--", commands_help. + GetStringAtIndex(i), + max_len); + } result.SetStatus (eReturnStatusSuccessFinishNoResult); } Modified: lldb/trunk/source/Commands/CommandObjectApropos.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectApropos.h?rev=114252&r1=114251&r2=114252&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectApropos.h (original) +++ lldb/trunk/source/Commands/CommandObjectApropos.h Fri Sep 17 20:14:36 2010 @@ -26,14 +26,13 @@ { public: - CommandObjectApropos (); + CommandObjectApropos (CommandInterpreter &interpreter); virtual ~CommandObjectApropos (); virtual bool - Execute (CommandInterpreter &interpreter, - Args& command, + Execute (Args& command, CommandReturnObject &result); Modified: lldb/trunk/source/Commands/CommandObjectArgs.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectArgs.cpp?rev=114252&r1=114251&r2=114252&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectArgs.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectArgs.cpp Fri Sep 17 20:14:36 2010 @@ -77,8 +77,9 @@ return g_option_table; } -CommandObjectArgs::CommandObjectArgs () : - CommandObject ("args", +CommandObjectArgs::CommandObjectArgs (CommandInterpreter &interpreter) : + CommandObject (interpreter, + "args", "When stopped at the start of a function, reads function arguments of type (u?)int(8|16|32|64)_t, (void|char)*", "args") { @@ -97,7 +98,6 @@ bool CommandObjectArgs::Execute ( - CommandInterpreter &interpreter, Args& args, CommandReturnObject &result ) @@ -105,7 +105,7 @@ ConstString target_triple; - Process *process = interpreter.GetDebugger().GetExecutionContext().process; + Process *process = m_interpreter.GetDebugger().GetExecutionContext().process; if (!process) { result.AppendError ("Args found no process."); @@ -131,7 +131,7 @@ return false; } - Thread *thread = interpreter.GetDebugger().GetExecutionContext ().thread; + Thread *thread = m_interpreter.GetDebugger().GetExecutionContext ().thread; if (!thread) { Modified: lldb/trunk/source/Commands/CommandObjectArgs.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectArgs.h?rev=114252&r1=114251&r2=114252&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectArgs.h (original) +++ lldb/trunk/source/Commands/CommandObjectArgs.h Fri Sep 17 20:14:36 2010 @@ -47,7 +47,7 @@ static lldb::OptionDefinition g_option_table[]; }; - CommandObjectArgs (); + CommandObjectArgs (CommandInterpreter &interpreter); virtual ~CommandObjectArgs (); @@ -58,8 +58,7 @@ virtual bool - Execute (CommandInterpreter &interpreter, - Args& command, + Execute ( Args& command, CommandReturnObject &result); virtual bool Modified: lldb/trunk/source/Commands/CommandObjectBreakpoint.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectBreakpoint.cpp?rev=114252&r1=114251&r2=114252&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectBreakpoint.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectBreakpoint.cpp Fri Sep 17 20:14:36 2010 @@ -247,8 +247,10 @@ //------------------------------------------------------------------------- #pragma mark Set -CommandObjectBreakpointSet::CommandObjectBreakpointSet () : - CommandObject ("breakpoint set", "Sets a breakpoint or set of breakpoints in the executable.", +CommandObjectBreakpointSet::CommandObjectBreakpointSet (CommandInterpreter &interpreter) : + CommandObject (interpreter, + "breakpoint set", + "Sets a breakpoint or set of breakpoints in the executable.", "breakpoint set ") { } @@ -266,12 +268,11 @@ bool CommandObjectBreakpointSet::Execute ( - CommandInterpreter &interpreter, Args& command, CommandReturnObject &result ) { - Target *target = interpreter.GetDebugger().GetSelectedTarget().get(); + Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get(); if (target == NULL) { result.AppendError ("Invalid target, set executable file using 'file' command."); @@ -312,7 +313,7 @@ FileSpec file; if (m_options.m_filename.empty()) { - StackFrame *cur_frame = interpreter.GetDebugger().GetExecutionContext().frame; + StackFrame *cur_frame = m_interpreter.GetDebugger().GetExecutionContext().frame; if (cur_frame == NULL) { result.AppendError ("Attempting to set breakpoint by line number alone with no selected frame."); @@ -503,19 +504,20 @@ #pragma mark MultiwordBreakpoint CommandObjectMultiwordBreakpoint::CommandObjectMultiwordBreakpoint (CommandInterpreter &interpreter) : - CommandObjectMultiword ("breakpoint", - "A set of commands for operating on breakpoints. Also see regexp-break.", - "breakpoint []") + CommandObjectMultiword (interpreter, + "breakpoint", + "A set of commands for operating on breakpoints. Also see regexp-break.", + "breakpoint []") { bool status; - CommandObjectSP list_command_object (new CommandObjectBreakpointList ()); - CommandObjectSP delete_command_object (new CommandObjectBreakpointDelete ()); - CommandObjectSP enable_command_object (new CommandObjectBreakpointEnable ()); - CommandObjectSP disable_command_object (new CommandObjectBreakpointDisable ()); - CommandObjectSP set_command_object (new CommandObjectBreakpointSet ()); + CommandObjectSP list_command_object (new CommandObjectBreakpointList (interpreter)); + CommandObjectSP delete_command_object (new CommandObjectBreakpointDelete (interpreter)); + CommandObjectSP enable_command_object (new CommandObjectBreakpointEnable (interpreter)); + CommandObjectSP disable_command_object (new CommandObjectBreakpointDisable (interpreter)); + CommandObjectSP set_command_object (new CommandObjectBreakpointSet (interpreter)); CommandObjectSP command_command_object (new CommandObjectBreakpointCommand (interpreter)); - CommandObjectSP modify_command_object (new CommandObjectBreakpointModify()); + CommandObjectSP modify_command_object (new CommandObjectBreakpointModify(interpreter)); command_command_object->SetCommandName ("breakpoint command"); enable_command_object->SetCommandName("breakpoint enable"); @@ -524,13 +526,13 @@ modify_command_object->SetCommandName ("breakpoint modify"); set_command_object->SetCommandName("breakpoint set"); - status = LoadSubCommand (interpreter, "list", list_command_object); - status = LoadSubCommand (interpreter, "enable", enable_command_object); - status = LoadSubCommand (interpreter, "disable", disable_command_object); - status = LoadSubCommand (interpreter, "delete", delete_command_object); - status = LoadSubCommand (interpreter, "set", set_command_object); - status = LoadSubCommand (interpreter, "command", command_command_object); - status = LoadSubCommand (interpreter, "modify", modify_command_object); + status = LoadSubCommand ("list", list_command_object); + status = LoadSubCommand ("enable", enable_command_object); + status = LoadSubCommand ("disable", disable_command_object); + status = LoadSubCommand ("delete", delete_command_object); + status = LoadSubCommand ("set", set_command_object); + status = LoadSubCommand ("command", command_command_object); + status = LoadSubCommand ("modify", modify_command_object); } CommandObjectMultiwordBreakpoint::~CommandObjectMultiwordBreakpoint () @@ -679,10 +681,11 @@ //------------------------------------------------------------------------- #pragma mark List -CommandObjectBreakpointList::CommandObjectBreakpointList () : - CommandObject ("breakpoint list", - "List some or all breakpoints at configurable levels of detail.", - "breakpoint list []") +CommandObjectBreakpointList::CommandObjectBreakpointList (CommandInterpreter &interpreter) : + CommandObject (interpreter, + "breakpoint list", + "List some or all breakpoints at configurable levels of detail.", + "breakpoint list []") { } @@ -699,12 +702,11 @@ bool CommandObjectBreakpointList::Execute ( - CommandInterpreter &interpreter, Args& args, CommandReturnObject &result ) { - Target *target = interpreter.GetDebugger().GetSelectedTarget().get(); + Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get(); if (target == NULL) { result.AppendError ("Invalid target, set executable file using 'file' command."); @@ -769,10 +771,11 @@ //------------------------------------------------------------------------- #pragma mark Enable -CommandObjectBreakpointEnable::CommandObjectBreakpointEnable () : - CommandObject ("enable", - "Enable the specified disabled breakpoint(s). If no breakpoints are specified, enable all of them.", - "breakpoint enable [ | ]") +CommandObjectBreakpointEnable::CommandObjectBreakpointEnable (CommandInterpreter &interpreter) : + CommandObject (interpreter, + "enable", + "Enable the specified disabled breakpoint(s). If no breakpoints are specified, enable all of them.", + "breakpoint enable [ | ]") { // This command object can either be called via 'enable' or 'breakpoint enable'. Because it has two different // potential invocation methods, we need to be a little tricky about generating the syntax string. @@ -790,12 +793,11 @@ bool CommandObjectBreakpointEnable::Execute ( - CommandInterpreter &interpreter, Args& args, CommandReturnObject &result ) { - Target *target = interpreter.GetDebugger().GetSelectedTarget().get(); + Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get(); if (target == NULL) { result.AppendError ("Invalid target, set executable file using 'file' command."); @@ -871,8 +873,9 @@ //------------------------------------------------------------------------- #pragma mark Disable -CommandObjectBreakpointDisable::CommandObjectBreakpointDisable () : - CommandObject ("disable", +CommandObjectBreakpointDisable::CommandObjectBreakpointDisable (CommandInterpreter &interpreter) : + CommandObject (interpreter, + "disable", "Disable the specified breakpoint(s) without removing it/them. If no breakpoints are specified, disable them all.", "disable [ | ]") { @@ -890,12 +893,11 @@ bool CommandObjectBreakpointDisable::Execute ( - CommandInterpreter &interpreter, Args& args, CommandReturnObject &result ) { - Target *target = interpreter.GetDebugger().GetSelectedTarget().get(); + Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get(); if (target == NULL) { result.AppendError ("Invalid target, set executable file using 'file' command."); @@ -971,8 +973,9 @@ //------------------------------------------------------------------------- #pragma mark Delete -CommandObjectBreakpointDelete::CommandObjectBreakpointDelete() : - CommandObject ("breakpoint delete", +CommandObjectBreakpointDelete::CommandObjectBreakpointDelete(CommandInterpreter &interpreter) : + CommandObject (interpreter, + "breakpoint delete", "Delete the specified breakpoint(s). If no breakpoints are specified, delete them all.", "breakpoint delete [ | ]") { @@ -986,12 +989,11 @@ bool CommandObjectBreakpointDelete::Execute ( - CommandInterpreter &interpreter, Args& args, CommandReturnObject &result ) { - Target *target = interpreter.GetDebugger().GetSelectedTarget().get(); + Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get(); if (target == NULL) { result.AppendError ("Invalid target, set executable file using 'file' command."); @@ -1207,8 +1209,10 @@ //------------------------------------------------------------------------- #pragma mark Modify -CommandObjectBreakpointModify::CommandObjectBreakpointModify () : - CommandObject ("breakpoint modify", "Modify the options on a breakpoint or set of breakpoints in the executable.", +CommandObjectBreakpointModify::CommandObjectBreakpointModify (CommandInterpreter &interpreter) : + CommandObject (interpreter, + "breakpoint modify", + "Modify the options on a breakpoint or set of breakpoints in the executable.", "breakpoint modify [ ...]") { } @@ -1226,7 +1230,6 @@ bool CommandObjectBreakpointModify::Execute ( - CommandInterpreter &interpreter, Args& command, CommandReturnObject &result ) @@ -1238,7 +1241,7 @@ return false; } - Target *target = interpreter.GetDebugger().GetSelectedTarget().get(); + Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get(); if (target == NULL) { result.AppendError ("Invalid target, set executable file using 'file' command."); Modified: lldb/trunk/source/Commands/CommandObjectBreakpoint.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectBreakpoint.h?rev=114252&r1=114251&r2=114252&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectBreakpoint.h (original) +++ lldb/trunk/source/Commands/CommandObjectBreakpoint.h Fri Sep 17 20:14:36 2010 @@ -60,14 +60,13 @@ eSetTypeFunctionRegexp } BreakpointSetType; - CommandObjectBreakpointSet (); + CommandObjectBreakpointSet (CommandInterpreter &interpreter); virtual ~CommandObjectBreakpointSet (); virtual bool - Execute (CommandInterpreter &interpreter, - Args& command, + Execute (Args& command, CommandReturnObject &result); virtual Options * @@ -127,14 +126,13 @@ { public: - CommandObjectBreakpointModify (); + CommandObjectBreakpointModify (CommandInterpreter &interpreter); virtual ~CommandObjectBreakpointModify (); virtual bool - Execute (CommandInterpreter &interpreter, - Args& command, + Execute (Args& command, CommandReturnObject &result); virtual Options * @@ -187,14 +185,13 @@ class CommandObjectBreakpointEnable : public CommandObject { public: - CommandObjectBreakpointEnable (); + CommandObjectBreakpointEnable (CommandInterpreter &interpreter); virtual ~CommandObjectBreakpointEnable (); virtual bool - Execute (CommandInterpreter &interpreter, - Args& command, + Execute (Args& command, CommandReturnObject &result); private: @@ -207,14 +204,13 @@ class CommandObjectBreakpointDisable : public CommandObject { public: - CommandObjectBreakpointDisable (); + CommandObjectBreakpointDisable (CommandInterpreter &interpreter); virtual ~CommandObjectBreakpointDisable (); virtual bool - Execute (CommandInterpreter &interpreter, - Args& command, + Execute (Args& command, CommandReturnObject &result); private: @@ -227,14 +223,13 @@ class CommandObjectBreakpointList : public CommandObject { public: - CommandObjectBreakpointList (); + CommandObjectBreakpointList (CommandInterpreter &interpreter); virtual ~CommandObjectBreakpointList (); virtual bool - Execute (CommandInterpreter &interpreter, - Args& command, + Execute (Args& command, CommandReturnObject &result); virtual Options * @@ -280,14 +275,13 @@ class CommandObjectBreakpointDelete : public CommandObject { public: - CommandObjectBreakpointDelete (); + CommandObjectBreakpointDelete (CommandInterpreter &interpreter); virtual ~CommandObjectBreakpointDelete (); virtual bool - Execute (CommandInterpreter &interpreter, - Args& command, + Execute (Args& command, CommandReturnObject &result); private: Modified: lldb/trunk/source/Commands/CommandObjectBreakpointCommand.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectBreakpointCommand.cpp?rev=114252&r1=114251&r2=114252&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectBreakpointCommand.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectBreakpointCommand.cpp Fri Sep 17 20:14:36 2010 @@ -125,8 +125,9 @@ //------------------------------------------------------------------------- -CommandObjectBreakpointCommandAdd::CommandObjectBreakpointCommandAdd () : - CommandObject ("add", +CommandObjectBreakpointCommandAdd::CommandObjectBreakpointCommandAdd (CommandInterpreter &interpreter) : + CommandObject (interpreter, + "add", "Add a set of commands to a breakpoint, to be executed whenever the breakpoint is hit.", "breakpoint command add ") { @@ -239,12 +240,11 @@ bool CommandObjectBreakpointCommandAdd::Execute ( - CommandInterpreter &interpreter, Args& command, CommandReturnObject &result ) { - Target *target = interpreter.GetDebugger().GetSelectedTarget().get(); + Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get(); if (target == NULL) { @@ -307,24 +307,20 @@ { // Special handling for one-liner specified inline. if (m_options.m_use_one_liner) - interpreter.GetScriptInterpreter()->SetBreakpointCommandCallback (interpreter, - bp_options, - m_options.m_one_liner.c_str()); + m_interpreter.GetScriptInterpreter()->SetBreakpointCommandCallback (bp_options, + m_options.m_one_liner.c_str()); else - interpreter.GetScriptInterpreter()->CollectDataForBreakpointCommandCallback (interpreter, - bp_options, - result); + m_interpreter.GetScriptInterpreter()->CollectDataForBreakpointCommandCallback (bp_options, + result); } else { // Special handling for one-liner specified inline. if (m_options.m_use_one_liner) - SetBreakpointCommandCallback (interpreter, - bp_options, + SetBreakpointCommandCallback (bp_options, m_options.m_one_liner.c_str()); else - CollectDataForBreakpointCommandCallback (interpreter, - bp_options, + CollectDataForBreakpointCommandCallback (bp_options, result); } } @@ -345,12 +341,11 @@ void CommandObjectBreakpointCommandAdd::CollectDataForBreakpointCommandCallback ( - CommandInterpreter &interpreter, BreakpointOptions *bp_options, CommandReturnObject &result ) { - InputReaderSP reader_sp (new InputReader(interpreter.GetDebugger())); + InputReaderSP reader_sp (new InputReader(m_interpreter.GetDebugger())); std::auto_ptr data_ap(new BreakpointOptions::CommandData()); if (reader_sp && data_ap.get()) { @@ -365,7 +360,7 @@ true)); // echo input if (err.Success()) { - interpreter.GetDebugger().PushInputReader (reader_sp); + m_interpreter.GetDebugger().PushInputReader (reader_sp); result.SetStatus (eReturnStatusSuccessFinishNoResult); } else @@ -384,8 +379,7 @@ // Set a one-liner as the callback for the breakpoint. void -CommandObjectBreakpointCommandAdd::SetBreakpointCommandCallback (CommandInterpreter &interpreter, - BreakpointOptions *bp_options, +CommandObjectBreakpointCommandAdd::SetBreakpointCommandCallback (BreakpointOptions *bp_options, const char *oneliner) { std::auto_ptr data_ap(new BreakpointOptions::CommandData()); @@ -460,8 +454,9 @@ // CommandObjectBreakpointCommandRemove //------------------------------------------------------------------------- -CommandObjectBreakpointCommandRemove::CommandObjectBreakpointCommandRemove () : - CommandObject ("remove", +CommandObjectBreakpointCommandRemove::CommandObjectBreakpointCommandRemove (CommandInterpreter &interpreter) : + CommandObject (interpreter, + "remove", "Remove the set of commands from a breakpoint.", "breakpoint command remove ") { @@ -474,12 +469,11 @@ bool CommandObjectBreakpointCommandRemove::Execute ( - CommandInterpreter &interpreter, Args& command, CommandReturnObject &result ) { - Target *target = interpreter.GetDebugger().GetSelectedTarget().get(); + Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get(); if (target == NULL) { @@ -546,8 +540,9 @@ // CommandObjectBreakpointCommandList //------------------------------------------------------------------------- -CommandObjectBreakpointCommandList::CommandObjectBreakpointCommandList () : - CommandObject ("List", +CommandObjectBreakpointCommandList::CommandObjectBreakpointCommandList (CommandInterpreter &interpreter) : + CommandObject (interpreter, + "list", "List the script or set of commands to be executed when the breakpoint is hit.", "breakpoint command list ") { @@ -560,12 +555,11 @@ bool CommandObjectBreakpointCommandList::Execute ( - CommandInterpreter &interpreter, Args& command, CommandReturnObject &result ) { - Target *target = interpreter.GetDebugger().GetSelectedTarget().get(); + Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get(); if (target == NULL) { @@ -663,22 +657,23 @@ //------------------------------------------------------------------------- CommandObjectBreakpointCommand::CommandObjectBreakpointCommand (CommandInterpreter &interpreter) : - CommandObjectMultiword ("command", + CommandObjectMultiword (interpreter, + "command", "A set of commands for adding, removing and examining bits of code to be executed when the breakpoint is hit (breakpoint 'commmands').", "command [] ") { bool status; - CommandObjectSP add_command_object (new CommandObjectBreakpointCommandAdd ()); - CommandObjectSP remove_command_object (new CommandObjectBreakpointCommandRemove ()); - CommandObjectSP list_command_object (new CommandObjectBreakpointCommandList ()); + CommandObjectSP add_command_object (new CommandObjectBreakpointCommandAdd (interpreter)); + CommandObjectSP remove_command_object (new CommandObjectBreakpointCommandRemove (interpreter)); + CommandObjectSP list_command_object (new CommandObjectBreakpointCommandList (interpreter)); add_command_object->SetCommandName ("breakpoint command add"); remove_command_object->SetCommandName ("breakpoint command remove"); list_command_object->SetCommandName ("breakpoint command list"); - status = LoadSubCommand (interpreter, "add", add_command_object); - status = LoadSubCommand (interpreter, "remove", remove_command_object); - status = LoadSubCommand (interpreter, "list", list_command_object); + status = LoadSubCommand ("add", add_command_object); + status = LoadSubCommand ("remove", remove_command_object); + status = LoadSubCommand ("list", list_command_object); } Modified: lldb/trunk/source/Commands/CommandObjectBreakpointCommand.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectBreakpointCommand.h?rev=114252&r1=114251&r2=114252&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectBreakpointCommand.h (original) +++ lldb/trunk/source/Commands/CommandObjectBreakpointCommand.h Fri Sep 17 20:14:36 2010 @@ -56,28 +56,25 @@ { public: - CommandObjectBreakpointCommandAdd (); + CommandObjectBreakpointCommandAdd (CommandInterpreter &interpreter); virtual ~CommandObjectBreakpointCommandAdd (); virtual bool - Execute (CommandInterpreter &interpreter, - Args& command, + Execute (Args& command, CommandReturnObject &result); virtual Options * GetOptions (); void - CollectDataForBreakpointCommandCallback (CommandInterpreter &interpreter, - BreakpointOptions *bp_options, + CollectDataForBreakpointCommandCallback (BreakpointOptions *bp_options, CommandReturnObject &result); /// Set a one-liner as the callback for the breakpoint. void - SetBreakpointCommandCallback (CommandInterpreter &interpreter, - BreakpointOptions *bp_options, + SetBreakpointCommandCallback (BreakpointOptions *bp_options, const char *oneliner); static size_t @@ -138,14 +135,13 @@ class CommandObjectBreakpointCommandRemove : public CommandObject { public: - CommandObjectBreakpointCommandRemove (); + CommandObjectBreakpointCommandRemove (CommandInterpreter &interpreter); virtual ~CommandObjectBreakpointCommandRemove (); virtual bool - Execute (CommandInterpreter &interpreter, - Args& command, + Execute (Args& command, CommandReturnObject &result); private: @@ -158,14 +154,13 @@ class CommandObjectBreakpointCommandList : public CommandObject { public: - CommandObjectBreakpointCommandList (); + CommandObjectBreakpointCommandList (CommandInterpreter &interpreter); virtual ~CommandObjectBreakpointCommandList (); virtual bool - Execute (CommandInterpreter &interpreter, - Args& command, + Execute (Args& command, CommandReturnObject &result); private: Modified: lldb/trunk/source/Commands/CommandObjectCall.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectCall.cpp?rev=114252&r1=114251&r2=114252&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectCall.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectCall.cpp Fri Sep 17 20:14:36 2010 @@ -128,7 +128,6 @@ bool CommandObjectCall::Execute ( - CommandInterpreter &interpreter, Args &command, CommandReturnObject &result ) Modified: lldb/trunk/source/Commands/CommandObjectCall.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectCall.h?rev=114252&r1=114251&r2=114252&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectCall.h (original) +++ lldb/trunk/source/Commands/CommandObjectCall.h Fri Sep 17 20:14:36 2010 @@ -66,8 +66,7 @@ virtual bool - Execute (CommandInterpreter &interpreter, - Args& command, + Execute (Args& command, CommandReturnObject &result); virtual bool Modified: lldb/trunk/source/Commands/CommandObjectCommands.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectCommands.cpp?rev=114252&r1=114251&r2=114252&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectCommands.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectCommands.cpp Fri Sep 17 20:14:36 2010 @@ -31,10 +31,11 @@ class CommandObjectCommandsSource : public CommandObject { public: - CommandObjectCommandsSource() : - CommandObject ("commands source", - "Read in debugger commands from the file and execute them.", - "command source ") + CommandObjectCommandsSource(CommandInterpreter &interpreter) : + CommandObject (interpreter, + "commands source", + "Read in debugger commands from the file and execute them.", + "command source ") { } @@ -45,7 +46,6 @@ bool Execute ( - CommandInterpreter &interpreter, Args& args, CommandReturnObject &result ) @@ -89,8 +89,10 @@ size_t i; for (i = 0; i []") { @@ -200,7 +203,6 @@ bool Execute ( - CommandInterpreter &interpreter, Args& args, CommandReturnObject &result ) @@ -222,7 +224,7 @@ // Verify that the command is alias'able, and get the appropriate command object. - if (interpreter.CommandExists (alias_command.c_str())) + if (m_interpreter.CommandExists (alias_command.c_str())) { result.AppendErrorWithFormat ("'%s' is a permanent debugger command and cannot be redefined.\n", alias_command.c_str()); @@ -230,7 +232,7 @@ } else { - CommandObjectSP command_obj_sp(interpreter.GetCommandSPExact (actual_command.c_str(), true)); + CommandObjectSP command_obj_sp(m_interpreter.GetCommandSPExact (actual_command.c_str(), true)); CommandObjectSP subcommand_obj_sp; bool use_subcommand = false; if (command_obj_sp.get()) @@ -307,25 +309,25 @@ // Create the alias. - if (interpreter.AliasExists (alias_command.c_str()) - || interpreter.UserCommandExists (alias_command.c_str())) + if (m_interpreter.AliasExists (alias_command.c_str()) + || m_interpreter.UserCommandExists (alias_command.c_str())) { - OptionArgVectorSP tmp_option_arg_sp (interpreter.GetAliasOptions (alias_command.c_str())); + OptionArgVectorSP tmp_option_arg_sp (m_interpreter.GetAliasOptions (alias_command.c_str())); if (tmp_option_arg_sp.get()) { if (option_arg_vector->size() == 0) - interpreter.RemoveAliasOptions (alias_command.c_str()); + m_interpreter.RemoveAliasOptions (alias_command.c_str()); } result.AppendWarningWithFormat ("Overwriting existing definition for '%s'.\n", alias_command.c_str()); } if (use_subcommand) - interpreter.AddAlias (alias_command.c_str(), subcommand_obj_sp); + m_interpreter.AddAlias (alias_command.c_str(), subcommand_obj_sp); else - interpreter.AddAlias (alias_command.c_str(), command_obj_sp); + m_interpreter.AddAlias (alias_command.c_str(), command_obj_sp); if (option_arg_vector->size() > 0) - interpreter.AddOrReplaceAliasOptions (alias_command.c_str(), option_arg_vector_sp); + m_interpreter.AddOrReplaceAliasOptions (alias_command.c_str(), option_arg_vector_sp); result.SetStatus (eReturnStatusSuccessFinishNoResult); } else @@ -347,8 +349,9 @@ class CommandObjectCommandsUnalias : public CommandObject { public: - CommandObjectCommandsUnalias () : - CommandObject ("commands unalias", + CommandObjectCommandsUnalias (CommandInterpreter &interpreter) : + CommandObject (interpreter, + "commands unalias", "Allow the user to remove/delete a user-defined command abbreviation.", "unalias ") { @@ -362,7 +365,6 @@ bool Execute ( - CommandInterpreter &interpreter, Args& args, CommandReturnObject &result ) @@ -373,10 +375,10 @@ if (args.GetArgumentCount() != 0) { const char *command_name = args.GetArgumentAtIndex(0); - cmd_obj = interpreter.GetCommandObject(command_name); + cmd_obj = m_interpreter.GetCommandObject(command_name); if (cmd_obj) { - if (interpreter.CommandExists (command_name)) + if (m_interpreter.CommandExists (command_name)) { result.AppendErrorWithFormat ("'%s' is a permanent debugger command and cannot be removed.\n", command_name); @@ -385,9 +387,9 @@ else { - if (interpreter.RemoveAlias (command_name) == false) + if (m_interpreter.RemoveAlias (command_name) == false) { - if (interpreter.AliasExists (command_name)) + if (m_interpreter.AliasExists (command_name)) result.AppendErrorWithFormat ("Error occurred while attempting to unalias '%s'.\n", command_name); else @@ -423,13 +425,14 @@ //------------------------------------------------------------------------- CommandObjectMultiwordCommands::CommandObjectMultiwordCommands (CommandInterpreter &interpreter) : - CommandObjectMultiword ("commands", + CommandObjectMultiword (interpreter, + "commands", "A set of commands for managing or customizing the debugger commands.", "commands []") { - LoadSubCommand (interpreter, "source", CommandObjectSP (new CommandObjectCommandsSource ())); - LoadSubCommand (interpreter, "alias", CommandObjectSP (new CommandObjectCommandsAlias ())); - LoadSubCommand (interpreter, "unalias", CommandObjectSP (new CommandObjectCommandsUnalias ())); + LoadSubCommand ("source", CommandObjectSP (new CommandObjectCommandsSource (interpreter))); + LoadSubCommand ("alias", CommandObjectSP (new CommandObjectCommandsAlias (interpreter))); + LoadSubCommand ("unalias", CommandObjectSP (new CommandObjectCommandsUnalias (interpreter))); } CommandObjectMultiwordCommands::~CommandObjectMultiwordCommands () Modified: lldb/trunk/source/Commands/CommandObjectCrossref.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectCrossref.cpp?rev=114252&r1=114251&r2=114252&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectCrossref.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectCrossref.cpp Fri Sep 17 20:14:36 2010 @@ -24,11 +24,12 @@ CommandObjectCrossref::CommandObjectCrossref ( + CommandInterpreter &interpreter, const char *name, const char *help, const char *syntax ) : - CommandObject (name, help, syntax), + CommandObject (interpreter, name, help, syntax), m_crossref_object_types() { } @@ -40,7 +41,6 @@ bool CommandObjectCrossref::Execute ( - CommandInterpreter &interpreter, Args& command, CommandReturnObject &result ) Modified: lldb/trunk/source/Commands/CommandObjectDisassemble.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectDisassemble.cpp?rev=114252&r1=114251&r2=114252&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectDisassemble.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectDisassemble.cpp Fri Sep 17 20:14:36 2010 @@ -141,10 +141,11 @@ // CommandObjectDisassemble //------------------------------------------------------------------------- -CommandObjectDisassemble::CommandObjectDisassemble () : - CommandObject ("disassemble", - "Disassemble bytes in the current function, or elsewhere in the executable program as specified by the user.", - "disassemble []") +CommandObjectDisassemble::CommandObjectDisassemble (CommandInterpreter &interpreter) : + CommandObject (interpreter, + "disassemble", + "Disassemble bytes in the current function, or elsewhere in the executable program as specified by the user.", + "disassemble []") { } @@ -155,12 +156,11 @@ bool CommandObjectDisassemble::Execute ( - CommandInterpreter &interpreter, Args& command, CommandReturnObject &result ) { - Target *target = interpreter.GetDebugger().GetSelectedTarget().get(); + Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get(); if (target == NULL) { result.AppendError ("invalid target, set executable file using 'file' command"); @@ -189,11 +189,15 @@ if (command.GetArgumentCount() != 0) { - result.AppendErrorWithFormat ("\"disassemble\" doesn't take any arguments.\n"); + result.AppendErrorWithFormat ("\"disassemble\" arguments are specified as options.\n"); + GetOptions()->GenerateOptionUsage (m_interpreter, + result.GetErrorStream(), + this); + result.SetStatus (eReturnStatusFailed); return false; } - ExecutionContext exe_ctx(interpreter.GetDebugger().GetExecutionContext()); + ExecutionContext exe_ctx(m_interpreter.GetDebugger().GetExecutionContext()); if (m_options.show_mixed && m_options.num_lines_context == 0) m_options.num_lines_context = 1; @@ -202,7 +206,7 @@ { ConstString name(m_options.m_func_name.c_str()); - if (Disassembler::Disassemble (interpreter.GetDebugger(), + if (Disassembler::Disassemble (m_interpreter.GetDebugger(), arch, exe_ctx, name, @@ -260,7 +264,7 @@ if (range.GetByteSize() == 0) range.SetByteSize(DEFAULT_DISASM_BYTE_SIZE); - if (Disassembler::Disassemble (interpreter.GetDebugger(), + if (Disassembler::Disassemble (m_interpreter.GetDebugger(), arch, exe_ctx, range, Modified: lldb/trunk/source/Commands/CommandObjectDisassemble.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectDisassemble.h?rev=114252&r1=114251&r2=114252&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectDisassemble.h (original) +++ lldb/trunk/source/Commands/CommandObjectDisassemble.h Fri Sep 17 20:14:36 2010 @@ -54,7 +54,7 @@ static lldb::OptionDefinition g_option_table[]; }; - CommandObjectDisassemble (); + CommandObjectDisassemble (CommandInterpreter &interpreter); virtual ~CommandObjectDisassemble (); @@ -67,8 +67,7 @@ } virtual bool - Execute (CommandInterpreter &interpreter, - Args& command, + Execute (Args& command, CommandReturnObject &result); protected: Modified: lldb/trunk/source/Commands/CommandObjectExpression.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectExpression.cpp?rev=114252&r1=114251&r2=114252&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectExpression.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectExpression.cpp Fri Sep 17 20:14:36 2010 @@ -95,12 +95,12 @@ return g_option_table; } -CommandObjectExpression::CommandObjectExpression () : - CommandObject ( - "expression", - "Evaluate an Objective-C++ expression in the current program context, using variables currently in scope.", - "expression [] "), - m_expr_line_count (0), +CommandObjectExpression::CommandObjectExpression (CommandInterpreter &interpreter) : + CommandObject (interpreter, + "expression", + "Evaluate an Objective-C++ expression in the current program context, using variables currently in scope.", + "expression [] "), +m_expr_line_count (0), m_expr_lines () { SetHelpLong( @@ -125,7 +125,6 @@ bool CommandObjectExpression::Execute ( - CommandInterpreter &interpreter, Args& command, CommandReturnObject &result ) @@ -259,12 +258,11 @@ bool CommandObjectExpression::ExecuteRawCommandString ( - CommandInterpreter &interpreter, const char *command, CommandReturnObject &result ) { - m_exe_ctx = interpreter.GetDebugger().GetExecutionContext(); + m_exe_ctx = m_interpreter.GetDebugger().GetExecutionContext(); m_options.ResetOptionValues(); @@ -275,7 +273,7 @@ m_expr_lines.clear(); m_expr_line_count = 0; - InputReaderSP reader_sp (new InputReader(interpreter.GetDebugger())); + InputReaderSP reader_sp (new InputReader(m_interpreter.GetDebugger())); if (reader_sp) { Error err (reader_sp->Initialize (CommandObjectExpression::MultiLineExpressionCallback, @@ -286,7 +284,7 @@ true)); // echo input if (err.Success()) { - interpreter.GetDebugger().PushInputReader (reader_sp); + m_interpreter.GetDebugger().PushInputReader (reader_sp); result.SetStatus (eReturnStatusSuccessFinishNoResult); } else @@ -328,7 +326,7 @@ if (end_options) { Args args (command, end_options - command); - if (!ParseOptions (interpreter, args, result)) + if (!ParseOptions (args, result)) return false; } } Modified: lldb/trunk/source/Commands/CommandObjectExpression.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectExpression.h?rev=114252&r1=114251&r2=114252&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectExpression.h (original) +++ lldb/trunk/source/Commands/CommandObjectExpression.h Fri Sep 17 20:14:36 2010 @@ -54,7 +54,7 @@ bool show_summary; }; - CommandObjectExpression (); + CommandObjectExpression (CommandInterpreter &interpreter); virtual ~CommandObjectExpression (); @@ -65,16 +65,14 @@ virtual bool - Execute (CommandInterpreter &interpreter, - Args& command, + Execute (Args& command, CommandReturnObject &result); virtual bool WantsRawCommandString() { return true; } virtual bool - ExecuteRawCommandString (CommandInterpreter &interpreter, - const char *command, + ExecuteRawCommandString (const char *command, CommandReturnObject &result); protected: Modified: lldb/trunk/source/Commands/CommandObjectFile.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectFile.cpp?rev=114252&r1=114251&r2=114252&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectFile.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectFile.cpp Fri Sep 17 20:14:36 2010 @@ -85,8 +85,9 @@ // CommandObjectFile //------------------------------------------------------------------------- -CommandObjectFile::CommandObjectFile() : - CommandObject ("file", +CommandObjectFile::CommandObjectFile(CommandInterpreter &interpreter) : + CommandObject (interpreter, + "file", "Set the file to be used as the main executable by the debugger.", "file [] ") { @@ -105,7 +106,6 @@ bool CommandObjectFile::Execute ( - CommandInterpreter &interpreter, Args& command, CommandReturnObject &result ) @@ -127,7 +127,7 @@ TargetSP target_sp; ArchSpec arch = m_options.m_arch; - Debugger &debugger = interpreter.GetDebugger(); + Debugger &debugger = m_interpreter.GetDebugger(); Error error = debugger.GetTargetList().CreateTarget (debugger, file_spec, m_options.m_arch, NULL, true, target_sp); if (target_sp) @@ -152,27 +152,28 @@ } int -CommandObjectFile::HandleArgumentCompletion (CommandInterpreter &interpreter, - Args &input, - int &cursor_index, - int &cursor_char_position, - OptionElementVector &opt_element_vector, - int match_start_point, - int max_return_elements, - bool &word_complete, - StringList &matches) +CommandObjectFile::HandleArgumentCompletion +( + Args &input, + int &cursor_index, + int &cursor_char_position, + OptionElementVector &opt_element_vector, + int match_start_point, + int max_return_elements, + bool &word_complete, + StringList &matches +) { - std::string completion_str (input.GetArgumentAtIndex(cursor_index)); - completion_str.erase (cursor_char_position); + std::string completion_str (input.GetArgumentAtIndex(cursor_index)); + completion_str.erase (cursor_char_position); - CommandCompletions::InvokeCommonCompletionCallbacks (interpreter, - CommandCompletions::eDiskFileCompletion, - completion_str.c_str(), - match_start_point, - max_return_elements, - NULL, - word_complete, - matches); - return matches.GetSize(); - + CommandCompletions::InvokeCommonCompletionCallbacks (m_interpreter, + CommandCompletions::eDiskFileCompletion, + completion_str.c_str(), + match_start_point, + max_return_elements, + NULL, + word_complete, + matches); + return matches.GetSize(); } Modified: lldb/trunk/source/Commands/CommandObjectFile.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectFile.h?rev=114252&r1=114251&r2=114252&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectFile.h (original) +++ lldb/trunk/source/Commands/CommandObjectFile.h Fri Sep 17 20:14:36 2010 @@ -28,14 +28,13 @@ { public: - CommandObjectFile (); + CommandObjectFile (CommandInterpreter &interpreter); virtual ~CommandObjectFile (); virtual bool - Execute (CommandInterpreter &interpreter, - Args& command, + Execute (Args& command, CommandReturnObject &result); virtual Options * @@ -69,8 +68,7 @@ }; virtual int - HandleArgumentCompletion (CommandInterpreter &interpreter, - Args &input, + HandleArgumentCompletion (Args &input, int &cursor_index, int &cursor_char_position, OptionElementVector &opt_element_vector, Modified: lldb/trunk/source/Commands/CommandObjectFrame.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectFrame.cpp?rev=114252&r1=114251&r2=114252&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectFrame.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectFrame.cpp Fri Sep 17 20:14:36 2010 @@ -51,11 +51,12 @@ { public: - CommandObjectFrameInfo () : - CommandObject ("frame info", - "List information about the currently selected frame in the current thread.", - "frame info", - eFlagProcessMustBeLaunched | eFlagProcessMustBePaused) + CommandObjectFrameInfo (CommandInterpreter &interpreter) : + CommandObject (interpreter, + "frame info", + "List information about the currently selected frame in the current thread.", + "frame info", + eFlagProcessMustBeLaunched | eFlagProcessMustBePaused) { } @@ -64,11 +65,10 @@ } bool - Execute (CommandInterpreter &interpreter, - Args& command, + Execute (Args& command, CommandReturnObject &result) { - ExecutionContext exe_ctx(interpreter.GetDebugger().GetExecutionContext()); + ExecutionContext exe_ctx(m_interpreter.GetDebugger().GetExecutionContext()); if (exe_ctx.frame) { exe_ctx.frame->Dump (&result.GetOutputStream(), true, false); @@ -94,12 +94,12 @@ { public: - CommandObjectFrameSelect () : - CommandObject ("frame select", - //"Select the current frame by index in the current thread.", - "Select a frame by index from within the current thread and make it the current frame.", - "frame select ", - eFlagProcessMustBeLaunched | eFlagProcessMustBePaused) + CommandObjectFrameSelect (CommandInterpreter &interpreter) : + CommandObject (interpreter, + "frame select", + "Select a frame by index from within the current thread and make it the current frame.", + "frame select ", + eFlagProcessMustBeLaunched | eFlagProcessMustBePaused) { } @@ -108,11 +108,10 @@ } bool - Execute (CommandInterpreter &interpreter, - Args& command, + Execute (Args& command, CommandReturnObject &result) { - ExecutionContext exe_ctx (interpreter.GetDebugger().GetExecutionContext()); + ExecutionContext exe_ctx (m_interpreter.GetDebugger().GetExecutionContext()); if (exe_ctx.thread) { if (command.GetArgumentCount() == 1) @@ -130,14 +129,14 @@ { bool already_shown = false; SymbolContext frame_sc(exe_ctx.frame->GetSymbolContext(eSymbolContextLineEntry)); - if (interpreter.GetDebugger().UseExternalEditor() && frame_sc.line_entry.file && frame_sc.line_entry.line != 0) + if (m_interpreter.GetDebugger().UseExternalEditor() && frame_sc.line_entry.file && frame_sc.line_entry.line != 0) { already_shown = Host::OpenFileInExternalEditor (frame_sc.line_entry.file, frame_sc.line_entry.line); } if (DisplayFrameForExecutionContext (exe_ctx.thread, exe_ctx.frame, - interpreter, + m_interpreter, result.GetOutputStream(), true, !already_shown, @@ -288,11 +287,11 @@ // Instance variables to hold the values for command options. }; - CommandObjectFrameVariable () : - CommandObject ( - "frame variable", - "Show specified argument, local variable, static variable or global variable for the current frame. If none specified, list them all.", - "frame variable [] [ [...]]") + CommandObjectFrameVariable (CommandInterpreter &interpreter) : + CommandObject (interpreter, + "frame variable", + "Show specified argument, local variable, static variable or global variable for the current frame. If none specified, list them all.", + "frame variable [] [ [...]]") { } @@ -431,12 +430,11 @@ virtual bool Execute ( - CommandInterpreter &interpreter, Args& command, CommandReturnObject &result ) { - ExecutionContext exe_ctx(interpreter.GetDebugger().GetExecutionContext()); + ExecutionContext exe_ctx(m_interpreter.GetDebugger().GetExecutionContext()); if (exe_ctx.frame == NULL) { result.AppendError ("invalid frame"); @@ -789,13 +787,14 @@ //------------------------------------------------------------------------- CommandObjectMultiwordFrame::CommandObjectMultiwordFrame (CommandInterpreter &interpreter) : - CommandObjectMultiword ("frame", + CommandObjectMultiword (interpreter, + "frame", "A set of commands for operating on the current thread's frames.", "frame []") { - LoadSubCommand (interpreter, "info", CommandObjectSP (new CommandObjectFrameInfo ())); - LoadSubCommand (interpreter, "select", CommandObjectSP (new CommandObjectFrameSelect ())); - LoadSubCommand (interpreter, "variable", CommandObjectSP (new CommandObjectFrameVariable ())); + LoadSubCommand ("info", CommandObjectSP (new CommandObjectFrameInfo (interpreter))); + LoadSubCommand ("select", CommandObjectSP (new CommandObjectFrameSelect (interpreter))); + LoadSubCommand ("variable", CommandObjectSP (new CommandObjectFrameVariable (interpreter))); } CommandObjectMultiwordFrame::~CommandObjectMultiwordFrame () Modified: lldb/trunk/source/Commands/CommandObjectHelp.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectHelp.cpp?rev=114252&r1=114251&r2=114252&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectHelp.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectHelp.cpp Fri Sep 17 20:14:36 2010 @@ -25,8 +25,9 @@ // CommandObjectHelp //------------------------------------------------------------------------- -CommandObjectHelp::CommandObjectHelp () : - CommandObject ("help", +CommandObjectHelp::CommandObjectHelp (CommandInterpreter &interpreter) : + CommandObject (interpreter, + "help", "Show a list of all debugger commands, or give details about specific commands.", "help []") { @@ -38,7 +39,7 @@ bool -CommandObjectHelp::Execute (CommandInterpreter &interpreter, Args& command, CommandReturnObject &result) +CommandObjectHelp::Execute (Args& command, CommandReturnObject &result) { CommandObject::CommandMap::iterator pos; CommandObject *cmd_obj; @@ -49,13 +50,13 @@ if (argc == 0) { result.SetStatus (eReturnStatusSuccessFinishNoResult); - interpreter.GetHelp (result); // General help, for ALL commands. + m_interpreter.GetHelp (result); // General help, for ALL commands. } else { // Get command object for the first command argument. Only search built-in command dictionary. StringList matches; - cmd_obj = interpreter.GetCommandObject (command.GetArgumentAtIndex (0), &matches); + cmd_obj = m_interpreter.GetCommandObject (command.GetArgumentAtIndex (0), &matches); if (cmd_obj != NULL) { @@ -94,10 +95,9 @@ Stream &output_strm = result.GetOutputStream(); if (sub_cmd_obj->GetOptions() != NULL) { - interpreter.OutputFormattedHelpText (output_strm, "", "", sub_cmd_obj->GetHelp(), 1); + m_interpreter.OutputFormattedHelpText (output_strm, "", "", sub_cmd_obj->GetHelp(), 1); output_strm.Printf ("\nSyntax: %s\n", sub_cmd_obj->GetSyntax()); - sub_cmd_obj->GetOptions()->GenerateOptionUsage (output_strm, sub_cmd_obj, - interpreter.GetDebugger().GetInstanceName().AsCString()); + sub_cmd_obj->GetOptions()->GenerateOptionUsage (m_interpreter, output_strm, sub_cmd_obj); const char *long_help = sub_cmd_obj->GetHelpLong(); if ((long_help != NULL) && (strlen (long_help) > 0)) @@ -105,8 +105,8 @@ } else if (sub_cmd_obj->IsMultiwordObject()) { - interpreter.OutputFormattedHelpText (output_strm, "", "", sub_cmd_obj->GetHelp(), 1); - ((CommandObjectMultiword *) sub_cmd_obj)->GenerateHelpText (interpreter, result); + m_interpreter.OutputFormattedHelpText (output_strm, "", "", sub_cmd_obj->GetHelp(), 1); + ((CommandObjectMultiword *) sub_cmd_obj)->GenerateHelpText (result); } else { @@ -115,7 +115,7 @@ && (strlen (long_help) > 0)) output_strm.Printf ("\n%s", long_help); else - interpreter.OutputFormattedHelpText (output_strm, "", "", sub_cmd_obj->GetHelp(), 1); + m_interpreter.OutputFormattedHelpText (output_strm, "", "", sub_cmd_obj->GetHelp(), 1); output_strm.Printf ("\nSyntax: %s\n", sub_cmd_obj->GetSyntax()); } } @@ -145,7 +145,6 @@ int CommandObjectHelp::HandleCompletion ( - CommandInterpreter &interpreter, Args &input, int &cursor_index, int &cursor_char_position, @@ -158,15 +157,25 @@ // Return the completions of the commands in the help system: if (cursor_index == 0) { - return interpreter.HandleCompletionMatches(input, cursor_index, cursor_char_position, match_start_point, - max_return_elements, word_complete, matches); + return m_interpreter.HandleCompletionMatches (input, + cursor_index, + cursor_char_position, + match_start_point, + max_return_elements, + word_complete, + matches); } else { - CommandObject *cmd_obj = interpreter.GetCommandObject (input.GetArgumentAtIndex(0)); + CommandObject *cmd_obj = m_interpreter.GetCommandObject (input.GetArgumentAtIndex(0)); input.Shift(); cursor_index--; - return cmd_obj->HandleCompletion (interpreter, input, cursor_index, cursor_char_position, match_start_point, - max_return_elements, word_complete, matches); + return cmd_obj->HandleCompletion (input, + cursor_index, + cursor_char_position, + match_start_point, + max_return_elements, + word_complete, + matches); } } Modified: lldb/trunk/source/Commands/CommandObjectHelp.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectHelp.h?rev=114252&r1=114251&r2=114252&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectHelp.h (original) +++ lldb/trunk/source/Commands/CommandObjectHelp.h Fri Sep 17 20:14:36 2010 @@ -26,19 +26,17 @@ { public: - CommandObjectHelp (); + CommandObjectHelp (CommandInterpreter &interpreter); virtual ~CommandObjectHelp (); virtual bool - Execute (CommandInterpreter &interpreter, - Args& command, + Execute (Args& command, CommandReturnObject &result); virtual int - HandleCompletion (CommandInterpreter &interpreter, - Args &input, + HandleCompletion (Args &input, int &cursor_index, int &cursor_char_position, int match_start_point, Modified: lldb/trunk/source/Commands/CommandObjectImage.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectImage.cpp?rev=114252&r1=114251&r2=114252&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectImage.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectImage.cpp Fri Sep 17 20:14:36 2010 @@ -476,10 +476,11 @@ { public: - CommandObjectImageDumpModuleList (const char *name, + CommandObjectImageDumpModuleList (CommandInterpreter &interpreter, + const char *name, const char *help, const char *syntax) : - CommandObject (name, help, syntax) + CommandObject (interpreter, name, help, syntax) { } @@ -489,8 +490,7 @@ } virtual int - HandleArgumentCompletion (CommandInterpreter &interpreter, - Args &input, + HandleArgumentCompletion (Args &input, int &cursor_index, int &cursor_char_position, OptionElementVector &opt_element_vector, @@ -503,7 +503,7 @@ std::string completion_str (input.GetArgumentAtIndex(cursor_index)); completion_str.erase (cursor_char_position); - CommandCompletions::InvokeCommonCompletionCallbacks (interpreter, + CommandCompletions::InvokeCommonCompletionCallbacks (m_interpreter, CommandCompletions::eModuleCompletion, completion_str.c_str(), match_start_point, @@ -519,10 +519,11 @@ { public: - CommandObjectImageDumpSourceFileList (const char *name, + CommandObjectImageDumpSourceFileList (CommandInterpreter &interpreter, + const char *name, const char *help, const char *syntax) : - CommandObject (name, help, syntax) + CommandObject (interpreter, name, help, syntax) { } @@ -532,8 +533,7 @@ } virtual int - HandleArgumentCompletion (CommandInterpreter &interpreter, - Args &input, + HandleArgumentCompletion (Args &input, int &cursor_index, int &cursor_char_position, OptionElementVector &opt_element_vector, @@ -546,7 +546,7 @@ std::string completion_str (input.GetArgumentAtIndex(cursor_index)); completion_str.erase (cursor_char_position); - CommandCompletions::InvokeCommonCompletionCallbacks (interpreter, + CommandCompletions::InvokeCommonCompletionCallbacks (m_interpreter, CommandCompletions::eSourceFileCompletion, completion_str.c_str(), match_start_point, @@ -562,10 +562,11 @@ class CommandObjectImageDumpSymtab : public CommandObjectImageDumpModuleList { public: - CommandObjectImageDumpSymtab () : - CommandObjectImageDumpModuleList ("image dump symtab", - "Dump the symbol table from one or more executable images.", - "image dump symtab [ ...]") + CommandObjectImageDumpSymtab (CommandInterpreter &interpreter) : + CommandObjectImageDumpModuleList (interpreter, + "image dump symtab", + "Dump the symbol table from one or more executable images.", + "image dump symtab [ ...]") { } @@ -575,11 +576,10 @@ } virtual bool - Execute (CommandInterpreter &interpreter, - Args& command, + Execute (Args& command, CommandReturnObject &result) { - Target *target = interpreter.GetDebugger().GetSelectedTarget().get(); + Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get(); if (target == NULL) { result.AppendError ("invalid target, set executable file using 'file' command"); @@ -604,7 +604,7 @@ for (uint32_t image_idx = 0; image_idxGetImages().GetModulePointerAtIndex(image_idx)); + DumpModuleSymtab (m_interpreter, result.GetOutputStream(), target->GetImages().GetModulePointerAtIndex(image_idx)); } } else @@ -642,7 +642,7 @@ if (image_module) { num_dumped++; - DumpModuleSymtab (interpreter, result.GetOutputStream(), image_module); + DumpModuleSymtab (m_interpreter, result.GetOutputStream(), image_module); } } } @@ -670,8 +670,9 @@ class CommandObjectImageDumpSections : public CommandObjectImageDumpModuleList { public: - CommandObjectImageDumpSections () : - CommandObjectImageDumpModuleList ("image dump sections", + CommandObjectImageDumpSections (CommandInterpreter &interpreter) : + CommandObjectImageDumpModuleList (interpreter, + "image dump sections", "Dump the sections from one or more executable images.", "image dump sections [ ...]") { @@ -683,11 +684,10 @@ } virtual bool - Execute (CommandInterpreter &interpreter, - Args& command, + Execute (Args& command, CommandReturnObject &result) { - Target *target = interpreter.GetDebugger().GetSelectedTarget().get(); + Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get(); if (target == NULL) { result.AppendError ("invalid target, set executable file using 'file' command"); @@ -712,7 +712,7 @@ for (uint32_t image_idx = 0; image_idxGetImages().GetModulePointerAtIndex(image_idx)); + DumpModuleSections (m_interpreter, result.GetOutputStream(), target->GetImages().GetModulePointerAtIndex(image_idx)); } } else @@ -750,7 +750,7 @@ if (image_module) { num_dumped++; - DumpModuleSections (interpreter, result.GetOutputStream(), image_module); + DumpModuleSections (m_interpreter, result.GetOutputStream(), image_module); } } } @@ -777,10 +777,11 @@ class CommandObjectImageDumpSymfile : public CommandObjectImageDumpModuleList { public: - CommandObjectImageDumpSymfile () : - CommandObjectImageDumpModuleList ("image dump symfile", - "Dump the debug symbol file for one or more executable images.", - "image dump symfile [ ...]") + CommandObjectImageDumpSymfile (CommandInterpreter &interpreter) : + CommandObjectImageDumpModuleList (interpreter, + "image dump symfile", + "Dump the debug symbol file for one or more executable images.", + "image dump symfile [ ...]") { } @@ -790,11 +791,10 @@ } virtual bool - Execute (CommandInterpreter &interpreter, - Args& command, + Execute (Args& command, CommandReturnObject &result) { - Target *target = interpreter.GetDebugger().GetSelectedTarget().get(); + Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get(); if (target == NULL) { result.AppendError ("invalid target, set executable file using 'file' command"); @@ -884,10 +884,11 @@ class CommandObjectImageDumpLineTable : public CommandObjectImageDumpSourceFileList { public: - CommandObjectImageDumpLineTable () : - CommandObjectImageDumpSourceFileList ("image dump line-table", - "Dump the debug symbol file for one or more executable images.", - "image dump line-table [ ...]") + CommandObjectImageDumpLineTable (CommandInterpreter &interpreter) : + CommandObjectImageDumpSourceFileList (interpreter, + "image dump line-table", + "Dump the debug symbol file for one or more executable images.", + "image dump line-table [ ...]") { } @@ -897,11 +898,10 @@ } virtual bool - Execute (CommandInterpreter &interpreter, - Args& command, + Execute (Args& command, CommandReturnObject &result) { - Target *target = interpreter.GetDebugger().GetSelectedTarget().get(); + Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get(); if (target == NULL) { result.AppendError ("invalid target, set executable file using 'file' command"); @@ -910,7 +910,7 @@ } else { - ExecutionContext exe_ctx(interpreter.GetDebugger().GetExecutionContext()); + ExecutionContext exe_ctx(m_interpreter.GetDebugger().GetExecutionContext()); uint32_t total_num_dumped = 0; uint32_t addr_byte_size = target->GetArchitecture().GetAddressByteSize(); @@ -935,7 +935,7 @@ uint32_t num_dumped = 0; for (uint32_t i = 0; iGetImages().GetModulePointerAtIndex(i), file_spec, @@ -973,14 +973,15 @@ // Constructors and Destructors //------------------------------------------------------------------ CommandObjectImageDump(CommandInterpreter &interpreter) : - CommandObjectMultiword ("image dump", + CommandObjectMultiword (interpreter, + "image dump", "A set of commands for dumping information about one or more executable images; 'line-table' expects a source file name", "image dump [symtab|sections|symfile|line-table] [ ...]") { - LoadSubCommand (interpreter, "symtab", CommandObjectSP (new CommandObjectImageDumpSymtab ())); - LoadSubCommand (interpreter, "sections", CommandObjectSP (new CommandObjectImageDumpSections ())); - LoadSubCommand (interpreter, "symfile", CommandObjectSP (new CommandObjectImageDumpSymfile ())); - LoadSubCommand (interpreter, "line-table", CommandObjectSP (new CommandObjectImageDumpLineTable ())); + LoadSubCommand ("symtab", CommandObjectSP (new CommandObjectImageDumpSymtab (interpreter))); + LoadSubCommand ("sections", CommandObjectSP (new CommandObjectImageDumpSections (interpreter))); + LoadSubCommand ("symfile", CommandObjectSP (new CommandObjectImageDumpSymfile (interpreter))); + LoadSubCommand ("line-table", CommandObjectSP (new CommandObjectImageDumpLineTable (interpreter))); } virtual @@ -1045,11 +1046,11 @@ FormatWidthCollection m_format_array; }; - CommandObjectImageList () : - CommandObject ( - "image list", - "List current executable and dependent shared library images.", - "image list []") + CommandObjectImageList (CommandInterpreter &interpreter) : + CommandObject (interpreter, + "image list", + "List current executable and dependent shared library images.", + "image list []") { } @@ -1066,11 +1067,10 @@ } virtual bool - Execute (CommandInterpreter &interpreter, - Args& command, + Execute (Args& command, CommandReturnObject &result) { - Target *target = interpreter.GetDebugger().GetSelectedTarget().get(); + Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get(); if (target == NULL) { result.AppendError ("invalid target, set executable file using 'file' command"); @@ -1322,11 +1322,11 @@ }; - CommandObjectImageLookup () : - CommandObject ( - "image lookup", - "Look up information within executable and dependent shared library images.", - "image lookup [] [...]") + CommandObjectImageLookup (CommandInterpreter &interpreter) : + CommandObject (interpreter, + "image lookup", + "Look up information within executable and dependent shared library images.", + "image lookup [] [...]") { } @@ -1351,7 +1351,7 @@ case eLookupTypeAddress: if (m_options.m_addr != LLDB_INVALID_ADDRESS) { - if (LookupAddressInModule (interpreter, + if (LookupAddressInModule (m_interpreter, result.GetOutputStream(), module, eSymbolContextEverything, @@ -1368,7 +1368,7 @@ case eLookupTypeSymbol: if (!m_options.m_str.empty()) { - if (LookupSymbolInModule (interpreter, result.GetOutputStream(), module, m_options.m_str.c_str(), m_options.m_use_regex)) + if (LookupSymbolInModule (m_interpreter, result.GetOutputStream(), module, m_options.m_str.c_str(), m_options.m_use_regex)) { result.SetStatus(eReturnStatusSuccessFinishResult); return true; @@ -1380,7 +1380,7 @@ if (m_options.m_file) { - if (LookupFileAndLineInModule (interpreter, + if (LookupFileAndLineInModule (m_interpreter, result.GetOutputStream(), module, m_options.m_file, @@ -1396,7 +1396,7 @@ case eLookupTypeFunction: if (!m_options.m_str.empty()) { - if (LookupFunctionInModule (interpreter, + if (LookupFunctionInModule (m_interpreter, result.GetOutputStream(), module, m_options.m_str.c_str(), @@ -1411,7 +1411,7 @@ case eLookupTypeType: if (!m_options.m_str.empty()) { - if (LookupTypeInModule (interpreter, + if (LookupTypeInModule (m_interpreter, result.GetOutputStream(), module, m_options.m_str.c_str(), @@ -1424,7 +1424,7 @@ break; default: - m_options.GenerateOptionUsage (result.GetErrorStream(), this, interpreter.GetDebugger().GetInstanceName().AsCString()); + m_options.GenerateOptionUsage (m_interpreter, result.GetErrorStream(), this); syntax_error = true; break; } @@ -1434,11 +1434,10 @@ } virtual bool - Execute (CommandInterpreter &interpreter, - Args& command, + Execute (Args& command, CommandReturnObject &result) { - Target *target = interpreter.GetDebugger().GetSelectedTarget().get(); + Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get(); if (target == NULL) { result.AppendError ("invalid target, set executable file using 'file' command"); @@ -1463,7 +1462,7 @@ { for (i = 0; iGetImages().GetModulePointerAtIndex(i), result, syntax_error)) + if (LookupInModule (m_interpreter, target->GetImages().GetModulePointerAtIndex(i), result, syntax_error)) { result.GetOutputStream().EOL(); num_successful_lookups++; @@ -1504,7 +1503,7 @@ Module * image_module = matching_modules.GetModulePointerAtIndex(j); if (image_module) { - if (LookupInModule (interpreter, image_module, result, syntax_error)) + if (LookupInModule (m_interpreter, image_module, result, syntax_error)) { result.GetOutputStream().EOL(); num_successful_lookups++; @@ -1553,13 +1552,14 @@ // CommandObjectImage constructor //---------------------------------------------------------------------- CommandObjectImage::CommandObjectImage(CommandInterpreter &interpreter) : - CommandObjectMultiword ("image", + CommandObjectMultiword (interpreter, + "image", "A set of commands for accessing information for one or more executable images.", "image ...") { - LoadSubCommand (interpreter, "dump", CommandObjectSP (new CommandObjectImageDump (interpreter))); - LoadSubCommand (interpreter, "list", CommandObjectSP (new CommandObjectImageList ())); - LoadSubCommand (interpreter, "lookup", CommandObjectSP (new CommandObjectImageLookup ())); + LoadSubCommand ("dump", CommandObjectSP (new CommandObjectImageDump (interpreter))); + LoadSubCommand ("list", CommandObjectSP (new CommandObjectImageList (interpreter))); + LoadSubCommand ("lookup", CommandObjectSP (new CommandObjectImageLookup (interpreter))); } //---------------------------------------------------------------------- Modified: lldb/trunk/source/Commands/CommandObjectLog.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectLog.cpp?rev=114252&r1=114251&r2=114252&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectLog.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectLog.cpp Fri Sep 17 20:14:36 2010 @@ -58,8 +58,9 @@ //------------------------------------------------------------------ // Constructors and Destructors //------------------------------------------------------------------ - CommandObjectLogEnable() : - CommandObject ("log enable", + CommandObjectLogEnable(CommandInterpreter &interpreter) : + CommandObject (interpreter, + "log enable", "Enable logging for a single log channel.", "log enable [] ") { @@ -77,8 +78,7 @@ } virtual bool - Execute (CommandInterpreter &interpreter, - Args& args, + Execute (Args& args, CommandReturnObject &result) { if (args.GetArgumentCount() < 1) @@ -95,7 +95,7 @@ if (m_options.log_file.empty()) { - log_stream_sp.reset(new StreamFile(interpreter.GetDebugger().GetOutputFileHandle())); + log_stream_sp.reset(new StreamFile(m_interpreter.GetDebugger().GetOutputFileHandle())); } else { @@ -234,10 +234,11 @@ //------------------------------------------------------------------ // Constructors and Destructors //------------------------------------------------------------------ - CommandObjectLogDisable() : - CommandObject ("log disable", - "Disable one or more log channels.", - "log disable [ ...]") + CommandObjectLogDisable(CommandInterpreter &interpreter) : + CommandObject (interpreter, + "log disable", + "Disable one or more log channels.", + "log disable [ ...]") { } @@ -247,8 +248,7 @@ } virtual bool - Execute (CommandInterpreter &interpreter, - Args& args, + Execute (Args& args, CommandReturnObject &result) { const size_t argc = args.GetArgumentCount(); @@ -295,8 +295,9 @@ //------------------------------------------------------------------ // Constructors and Destructors //------------------------------------------------------------------ - CommandObjectLogList() : - CommandObject ("log list", + CommandObjectLogList(CommandInterpreter &interpreter) : + CommandObject (interpreter, + "log list", "List the log categories for one or more log channels.", "log list [ ...]") { @@ -308,8 +309,7 @@ } virtual bool - Execute (CommandInterpreter &interpreter, - Args& args, + Execute (Args& args, CommandReturnObject &result) { const size_t argc = args.GetArgumentCount(); @@ -358,8 +358,9 @@ //------------------------------------------------------------------ // Constructors and Destructors //------------------------------------------------------------------ - CommandObjectLogTimer() : - CommandObject ("log timers", + CommandObjectLogTimer(CommandInterpreter &interpreter) : + CommandObject (interpreter, + "log timers", "Enable, disable, dump, and reset LLDB internal performance timers.", "log timers < enable | disable | dump | reset >") { @@ -371,8 +372,7 @@ } virtual bool - Execute (CommandInterpreter &interpreter, - Args& args, + Execute (Args& args, CommandReturnObject &result) { const size_t argc = args.GetArgumentCount(); @@ -418,14 +418,15 @@ // CommandObjectLog constructor //---------------------------------------------------------------------- CommandObjectLog::CommandObjectLog(CommandInterpreter &interpreter) : - CommandObjectMultiword ("log", + CommandObjectMultiword (interpreter, + "log", "A set of commands for operating on logs.", "log []") { - LoadSubCommand (interpreter, "enable", CommandObjectSP (new CommandObjectLogEnable)); - LoadSubCommand (interpreter, "disable", CommandObjectSP (new CommandObjectLogDisable)); - LoadSubCommand (interpreter, "list", CommandObjectSP (new CommandObjectLogList)); - LoadSubCommand (interpreter, "timers", CommandObjectSP (new CommandObjectLogTimer)); + LoadSubCommand ("enable", CommandObjectSP (new CommandObjectLogEnable (interpreter))); + LoadSubCommand ("disable", CommandObjectSP (new CommandObjectLogDisable (interpreter))); + LoadSubCommand ("list", CommandObjectSP (new CommandObjectLogList (interpreter))); + LoadSubCommand ("timers", CommandObjectSP (new CommandObjectLogTimer (interpreter))); } //---------------------------------------------------------------------- Modified: lldb/trunk/source/Commands/CommandObjectMemory.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectMemory.cpp?rev=114252&r1=114251&r2=114252&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectMemory.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectMemory.cpp Fri Sep 17 20:14:36 2010 @@ -176,8 +176,9 @@ uint32_t m_num_per_line; }; - CommandObjectMemoryRead () : - CommandObject ("memory read", + CommandObjectMemoryRead (CommandInterpreter &interpreter) : + CommandObject (interpreter, + "memory read", "Read from the memory of the process being debugged.", "memory read [] []", eFlagProcessMustBeLaunched) @@ -196,11 +197,10 @@ } virtual bool - Execute (CommandInterpreter &interpreter, - Args& command, + Execute (Args& command, CommandReturnObject &result) { - Process *process = interpreter.GetDebugger().GetExecutionContext().process; + Process *process = m_interpreter.GetDebugger().GetExecutionContext().process; if (process == NULL) { result.AppendError("need a process to read memory"); @@ -394,8 +394,9 @@ uint32_t m_byte_size; }; - CommandObjectMemoryWrite () : - CommandObject ("memory write", + CommandObjectMemoryWrite (CommandInterpreter &interpreter) : + CommandObject (interpreter, + "memory write", "Write to the memory of the process being debugged.", "memory write [] [value1 value2 ...]", eFlagProcessMustBeLaunched) @@ -441,11 +442,10 @@ } virtual bool - Execute (CommandInterpreter &interpreter, - Args& command, + Execute (Args& command, CommandReturnObject &result) { - Process *process = interpreter.GetDebugger().GetExecutionContext().process; + Process *process = m_interpreter.GetDebugger().GetExecutionContext().process; if (process == NULL) { result.AppendError("need a process to read memory"); @@ -677,12 +677,13 @@ //------------------------------------------------------------------------- CommandObjectMemory::CommandObjectMemory (CommandInterpreter &interpreter) : - CommandObjectMultiword ("memory", + CommandObjectMultiword (interpreter, + "memory", "A set of commands for operating on memory.", "memory []") { - LoadSubCommand (interpreter, "read", CommandObjectSP (new CommandObjectMemoryRead ())); - LoadSubCommand (interpreter, "write", CommandObjectSP (new CommandObjectMemoryWrite ())); + LoadSubCommand ("read", CommandObjectSP (new CommandObjectMemoryRead (interpreter))); + LoadSubCommand ("write", CommandObjectSP (new CommandObjectMemoryWrite (interpreter))); } CommandObjectMemory::~CommandObjectMemory () Modified: lldb/trunk/source/Commands/CommandObjectMultiword.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectMultiword.cpp?rev=114252&r1=114251&r2=114252&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectMultiword.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectMultiword.cpp Fri Sep 17 20:14:36 2010 @@ -26,12 +26,13 @@ CommandObjectMultiword::CommandObjectMultiword ( + CommandInterpreter &interpreter, const char *name, const char *help, const char *syntax, uint32_t flags ) : - CommandObject (name, help, syntax, flags) + CommandObject (interpreter, name, help, syntax, flags) { } @@ -82,7 +83,6 @@ bool CommandObjectMultiword::LoadSubCommand ( - CommandInterpreter &interpreter, const char *name, const CommandObjectSP& cmd_obj ) @@ -94,7 +94,7 @@ if (pos == m_subcommand_dict.end()) { m_subcommand_dict[name] = cmd_obj; - interpreter.CrossRegisterCommand (name, GetCommandName()); + m_interpreter.CrossRegisterCommand (name, GetCommandName()); } else success = false; @@ -105,7 +105,6 @@ bool CommandObjectMultiword::Execute ( - CommandInterpreter &interpreter, Args& args, CommandReturnObject &result ) @@ -113,7 +112,7 @@ const size_t argc = args.GetArgumentCount(); if (argc == 0) { - GenerateHelpText (interpreter, result); + GenerateHelpText (result); } else { @@ -123,7 +122,7 @@ { if (::strcasecmp (sub_command, "help") == 0) { - GenerateHelpText (interpreter, result); + GenerateHelpText (result); } else if (!m_subcommand_dict.empty()) { @@ -136,7 +135,7 @@ args.Shift(); - sub_cmd_obj->ExecuteWithOptions (interpreter, args, result); + sub_cmd_obj->ExecuteWithOptions (args, result); } else { @@ -179,7 +178,7 @@ } void -CommandObjectMultiword::GenerateHelpText (CommandInterpreter &interpreter, CommandReturnObject &result) +CommandObjectMultiword::GenerateHelpText (CommandReturnObject &result) { // First time through here, generate the help text for the object and // push it to the return result object as well @@ -188,7 +187,7 @@ output_stream.PutCString ("The following subcommands are supported:\n\n"); CommandMap::iterator pos; - uint32_t max_len = interpreter.FindLongestCommandWord (m_subcommand_dict); + uint32_t max_len = m_interpreter.FindLongestCommandWord (m_subcommand_dict); if (max_len) max_len += 4; // Indent the output by 4 spaces. @@ -197,11 +196,11 @@ { std::string indented_command (" "); indented_command.append (pos->first); - interpreter.OutputFormattedHelpText (result.GetOutputStream(), - indented_command.c_str(), - "--", - pos->second->GetHelp(), - max_len); + m_interpreter.OutputFormattedHelpText (result.GetOutputStream(), + indented_command.c_str(), + "--", + pos->second->GetHelp(), + max_len); } output_stream.PutCString ("\nFor more help on any particular subcommand, type 'help '.\n"); @@ -212,7 +211,6 @@ int CommandObjectMultiword::HandleCompletion ( - CommandInterpreter &interpreter, Args &input, int &cursor_index, int &cursor_char_position, @@ -245,8 +243,8 @@ input.Shift(); cursor_char_position = 0; input.AppendArgument (""); - return cmd_obj->HandleCompletion (interpreter, - input, cursor_index, + return cmd_obj->HandleCompletion (input, + cursor_index, cursor_char_position, match_start_point, max_return_elements, @@ -273,8 +271,7 @@ matches.DeleteStringAtIndex(0); input.Shift(); cursor_index--; - return sub_command_object->HandleCompletion (interpreter, - input, + return sub_command_object->HandleCompletion (input, cursor_index, cursor_char_position, match_start_point, Modified: lldb/trunk/source/Commands/CommandObjectProcess.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectProcess.cpp?rev=114252&r1=114251&r2=114252&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectProcess.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectProcess.cpp Fri Sep 17 20:14:36 2010 @@ -101,8 +101,9 @@ }; - CommandObjectProcessLaunch () : - CommandObject ("process launch", + CommandObjectProcessLaunch (CommandInterpreter &interpreter) : + CommandObject (interpreter, + "process launch", "Launch the executable in the debugger.", "process launch [] []") { @@ -120,12 +121,11 @@ } bool - Execute (CommandInterpreter &interpreter, - Args& launch_args, + Execute (Args& launch_args, CommandReturnObject &result) { - Target *target = interpreter.GetDebugger().GetSelectedTarget().get(); - bool synchronous_execution = interpreter.GetSynchronous (); + Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get(); + bool synchronous_execution = m_interpreter.GetSynchronous (); // bool launched = false; // bool stopped_after_launch = false; @@ -141,16 +141,13 @@ Module *exe_module = target->GetExecutableModule().get(); exe_module->GetFileSpec().GetPath(filename, sizeof(filename)); - Process *process = interpreter.GetDebugger().GetExecutionContext().process; - if (process) + Process *process = m_interpreter.GetDebugger().GetExecutionContext().process; + if (process && process->IsAlive()) { - if (process->IsAlive()) - { - result.AppendErrorWithFormat ("Process %u is currently being debugged, kill the process before running again.\n", - process->GetID()); - result.SetStatus (eReturnStatusFailed); - return false; - } + result.AppendErrorWithFormat ("Process %u is currently being debugged, kill the process before running again.\n", + process->GetID()); + result.SetStatus (eReturnStatusFailed); + return false; } const char *plugin_name; @@ -159,130 +156,91 @@ else plugin_name = NULL; - process = target->CreateProcess (interpreter.GetDebugger().GetListener(), plugin_name).get(); + process = target->CreateProcess (m_interpreter.GetDebugger().GetListener(), plugin_name).get(); - const char *process_name = process->GetInstanceName().AsCString(); - const char *debugger_instance_name = interpreter.GetDebugger().GetInstanceName().AsCString(); - StreamString run_args_var_name; - StreamString env_vars_var_name; - StreamString disable_aslr_var_name; - lldb::SettableVariableType var_type; - - Args *run_args = NULL; - run_args_var_name.Printf ("process.[%s].run-args", process_name); - StringList run_args_value = Debugger::GetSettingsController()->GetVariable (run_args_var_name.GetData(), - var_type, debugger_instance_name); - - if (run_args_value.GetSize() > 0) - { - run_args = new Args; - for (unsigned i = 0, e = run_args_value.GetSize(); i != e; ++i) - run_args->AppendArgument(run_args_value.GetStringAtIndex(i)); - } - - Args *environment = NULL; - env_vars_var_name.Printf ("process.[%s].env-vars", process_name); - StringList env_vars_value = Debugger::GetSettingsController()->GetVariable (env_vars_var_name.GetData(), - var_type, debugger_instance_name); - - if (env_vars_value.GetSize() > 0) - { - environment = new Args; - for (unsigned i = 0, e = env_vars_value.GetSize(); i != e; ++i) - environment->AppendArgument (env_vars_value.GetStringAtIndex (i)); + if (process == NULL) + { + result.AppendErrorWithFormat ("Failed to find a process plugin for executable"); + result.SetStatus (eReturnStatusFailed); + return false; } - uint32_t launch_flags = eLaunchFlagNone; - disable_aslr_var_name.Printf ("process.[%s].disable-aslr", process_name); - StringList disable_aslr_value = Debugger::GetSettingsController()->GetVariable(disable_aslr_var_name.GetData(), - var_type, - debugger_instance_name); - - if (disable_aslr_value.GetSize() > 0) + // If no launch args were given on the command line, then use any that + // might have been set using the "run-args" set variable. + if (launch_args.GetArgumentCount() == 0) { - if (strcmp (disable_aslr_value.GetStringAtIndex(0), "true") == 0) - launch_flags |= eLaunchFlagDisableASLR; - + if (process->GetRunArguments().GetArgumentCount() > 0) + launch_args = process->GetRunArguments(); } + + Args environment; + + process->GetEnvironmentAsArgs (environment); + + uint32_t launch_flags = eLaunchFlagNone; + + if (process->GetDisableASLR()) + launch_flags |= eLaunchFlagDisableASLR; - // There are two possible sources of args to be passed to the process upon launching: Those the user - // typed at the run command (launch_args); or those the user pre-set in the run-args variable (run_args). + const char *archname = exe_module->GetArchitecture().AsCString(); - // If launch_args is empty, use run_args. - if (launch_args.GetArgumentCount() == 0) - { - if (run_args != NULL) - launch_args.AppendArguments (*run_args); + const char * stdin_path = NULL; + const char * stdout_path = NULL; + const char * stderr_path = NULL; + + // Were any standard input/output/error paths given on the command line? + if (m_options.stdin_path.empty() && + m_options.stdout_path.empty() && + m_options.stderr_path.empty()) + { + // No standard file handles were given on the command line, check + // with the process object in case they were give using "set settings" + stdin_path = process->GetStandardInputPath(); + stdout_path = process->GetStandardOutputPath(); + stderr_path = process->GetStandardErrorPath(); } else { - // launch-args was not empty; use that, AND re-set run-args to contains launch-args values. - std::string new_run_args; - launch_args.GetCommandString (new_run_args); - Debugger::GetSettingsController()->SetVariable (run_args_var_name.GetData(), new_run_args.c_str(), - lldb::eVarSetOperationAssign, false, - interpreter.GetDebugger().GetInstanceName().AsCString()); - } - - - if (process) + stdin_path = m_options.stdin_path.empty() ? NULL : m_options.stdin_path.c_str(); + stdout_path = m_options.stdout_path.empty() ? NULL : m_options.stdout_path.c_str(); + stderr_path = m_options.stderr_path.empty() ? NULL : m_options.stderr_path.c_str(); + } + + if (stdin_path == NULL) + stdin_path = "/dev/null"; + if (stdout_path == NULL) + stdout_path = "/dev/null"; + if (stderr_path == NULL) + stderr_path = "/dev/null"; + + Error error (process->Launch (launch_args.GetArgumentCount() ? launch_args.GetConstArgumentVector() : NULL, + environment.GetArgumentCount() ? environment.GetConstArgumentVector() : NULL, + launch_flags, + stdin_path, + stdout_path, + stderr_path)); + + if (error.Success()) { - const char *archname = exe_module->GetArchitecture().AsCString(); - - const char * stdin_path = NULL; - const char * stdout_path = NULL; - const char * stderr_path = NULL; - - if (!(m_options.stdin_path.empty() && - m_options.stdout_path.empty() && - m_options.stderr_path.empty())) - { - stdin_path = m_options.stdin_path.empty() ? "/dev/null" : m_options.stdin_path.c_str(); - stdout_path = m_options.stdout_path.empty() ? "/dev/null" : m_options.stdout_path.c_str(); - stderr_path = m_options.stderr_path.empty() ? "/dev/null" : m_options.stderr_path.c_str(); - } - - Error error (process->Launch (launch_args.GetConstArgumentVector(), - environment ? environment->GetConstArgumentVector() : NULL, - launch_flags, - stdin_path, - stdout_path, - stderr_path)); - - if (error.Success()) + result.AppendMessageWithFormat ("Launching '%s' (%s)\n", filename, archname); + result.SetStatus (eReturnStatusSuccessContinuingNoResult); + if (m_options.stop_at_entry == false) { - result.AppendMessageWithFormat ("Launching '%s' (%s)\n", filename, archname); - result.SetStatus (eReturnStatusSuccessContinuingNoResult); - if (m_options.stop_at_entry == false) - { - StateType state = process->WaitForProcessToStop (NULL); + StateType state = process->WaitForProcessToStop (NULL); - if (state == eStateStopped) - { - // Call continue_command. - CommandReturnObject continue_result; - interpreter.HandleCommand("process continue", false, continue_result); - } + if (state == eStateStopped) + { + // Call continue_command. + CommandReturnObject continue_result; + m_interpreter.HandleCommand("process continue", false, continue_result); + } - if (synchronous_execution) - { - result.SetDidChangeProcessState (true); - result.SetStatus (eReturnStatusSuccessFinishNoResult); - } + if (synchronous_execution) + { + result.SetDidChangeProcessState (true); + result.SetStatus (eReturnStatusSuccessFinishNoResult); } } - else - { - result.AppendErrorWithFormat ("Process launch failed: %s", - error.AsCString()); - result.SetStatus (eReturnStatusFailed); - } - } - else - { - result.AppendErrorWithFormat ("Process launch failed: unable to create a process object.\n"); - result.SetStatus (eReturnStatusFailed); - return false; } return result.Succeeded(); @@ -386,7 +344,7 @@ } virtual bool - HandleOptionArgumentCompletion (CommandInterpreter &interpreter, + HandleOptionArgumentCompletion (CommandInterpreter &interpeter, Args &input, int cursor_index, int char_pos, @@ -409,7 +367,7 @@ // Look to see if there is a -P argument provided, and if so use that plugin, otherwise // use the default plugin. - Process *process = interpreter.GetDebugger().GetExecutionContext().process; + Process *process = interpeter.GetDebugger().GetExecutionContext().process; bool need_to_delete_process = false; const char *partial_name = NULL; @@ -418,7 +376,7 @@ if (process && process->IsAlive()) return true; - Target *target = interpreter.GetDebugger().GetSelectedTarget().get(); + Target *target = interpeter.GetDebugger().GetSelectedTarget().get(); if (target == NULL) { // No target has been set yet, for now do host completion. Otherwise I don't know how we would @@ -429,7 +387,7 @@ } if (!process) { - process = target->CreateProcess (interpreter.GetDebugger().GetListener(), partial_name).get(); + process = target->CreateProcess (interpeter.GetDebugger().GetListener(), partial_name).get(); need_to_delete_process = true; } @@ -459,8 +417,9 @@ bool waitfor; }; - CommandObjectProcessAttach () : - CommandObject ("process attach", + CommandObjectProcessAttach (CommandInterpreter &interpreter) : + CommandObject (interpreter, + "process attach", "Attach to a process.", "process attach ") { @@ -471,13 +430,12 @@ } bool - Execute (CommandInterpreter &interpreter, - Args& command, + Execute (Args& command, CommandReturnObject &result) { - Target *target = interpreter.GetDebugger().GetSelectedTarget().get(); + Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get(); - Process *process = interpreter.GetDebugger().GetExecutionContext().process; + Process *process = m_interpreter.GetDebugger().GetExecutionContext().process; if (process) { if (process->IsAlive()) @@ -497,19 +455,19 @@ ArchSpec emptyArchSpec; Error error; - error = interpreter.GetDebugger().GetTargetList().CreateTarget(interpreter.GetDebugger(), - emptyFileSpec, - emptyArchSpec, - NULL, - false, - new_target_sp); + error = m_interpreter.GetDebugger().GetTargetList().CreateTarget (m_interpreter.GetDebugger(), + emptyFileSpec, + emptyArchSpec, + NULL, + false, + new_target_sp); target = new_target_sp.get(); if (target == NULL || error.Fail()) { result.AppendError(error.AsCString("Error creating empty target")); return false; } - interpreter.GetDebugger().GetTargetList().SetSelectedTarget(target); + m_interpreter.GetDebugger().GetTargetList().SetSelectedTarget(target); } // Record the old executable module, we want to issue a warning if the process of attaching changed the @@ -530,7 +488,7 @@ if (!m_options.plugin_name.empty()) plugin_name = m_options.plugin_name.c_str(); - process = target->CreateProcess (interpreter.GetDebugger().GetListener(), plugin_name).get(); + process = target->CreateProcess (m_interpreter.GetDebugger().GetListener(), plugin_name).get(); if (process) { @@ -562,7 +520,7 @@ return false; } - interpreter.GetDebugger().GetOutputStream().Printf("Waiting to attach to a process named \"%s\".\n", wait_name); + m_interpreter.GetDebugger().GetOutputStream().Printf("Waiting to attach to a process named \"%s\".\n", wait_name); error = process->Attach (wait_name, m_options.waitfor); if (error.Success()) { @@ -700,8 +658,9 @@ { public: - CommandObjectProcessContinue () : - CommandObject ("process continue", + CommandObjectProcessContinue (CommandInterpreter &interpreter) : + CommandObject (interpreter, + "process continue", "Continue execution of all threads in the current process.", "process continue", eFlagProcessMustBeLaunched | eFlagProcessMustBePaused) @@ -714,12 +673,11 @@ } bool - Execute (CommandInterpreter &interpreter, - Args& command, + Execute (Args& command, CommandReturnObject &result) { - Process *process = interpreter.GetDebugger().GetExecutionContext().process; - bool synchronous_execution = interpreter.GetSynchronous (); + Process *process = m_interpreter.GetDebugger().GetExecutionContext().process; + bool synchronous_execution = m_interpreter.GetSynchronous (); if (process == NULL) { @@ -787,8 +745,9 @@ { public: - CommandObjectProcessDetach () : - CommandObject ("process detach", + CommandObjectProcessDetach (CommandInterpreter &interpreter) : + CommandObject (interpreter, + "process detach", "Detach from the current process being debugged.", "process detach", eFlagProcessMustBeLaunched) @@ -800,11 +759,10 @@ } bool - Execute (CommandInterpreter &interpreter, - Args& command, + Execute (Args& command, CommandReturnObject &result) { - Process *process = interpreter.GetDebugger().GetExecutionContext().process; + Process *process = m_interpreter.GetDebugger().GetExecutionContext().process; if (process == NULL) { result.AppendError ("must have a valid process in order to detach"); @@ -835,8 +793,9 @@ { public: - CommandObjectProcessSignal () : - CommandObject ("process signal", + CommandObjectProcessSignal (CommandInterpreter &interpreter) : + CommandObject (interpreter, + "process signal", "Send a UNIX signal to the current process being debugged.", "process signal ") { @@ -847,11 +806,10 @@ } bool - Execute (CommandInterpreter &interpreter, - Args& command, + Execute (Args& command, CommandReturnObject &result) { - Process *process = interpreter.GetDebugger().GetExecutionContext().process; + Process *process = m_interpreter.GetDebugger().GetExecutionContext().process; if (process == NULL) { result.AppendError ("no process to signal"); @@ -901,8 +859,9 @@ public: - CommandObjectProcessInterrupt () : - CommandObject ("process interrupt", + CommandObjectProcessInterrupt (CommandInterpreter &interpreter) : + CommandObject (interpreter, + "process interrupt", "Interrupt the current process being debugged.", "process interrupt", eFlagProcessMustBeLaunched) @@ -914,11 +873,10 @@ } bool - Execute (CommandInterpreter &interpreter, - Args& command, + Execute (Args& command, CommandReturnObject &result) { - Process *process = interpreter.GetDebugger().GetExecutionContext().process; + Process *process = m_interpreter.GetDebugger().GetExecutionContext().process; if (process == NULL) { result.AppendError ("no process to halt"); @@ -962,8 +920,9 @@ { public: - CommandObjectProcessKill () : - CommandObject ("process kill", + CommandObjectProcessKill (CommandInterpreter &interpreter) : + CommandObject (interpreter, + "process kill", "Terminate the current process being debugged.", "process kill", eFlagProcessMustBeLaunched) @@ -975,11 +934,10 @@ } bool - Execute (CommandInterpreter &interpreter, - Args& command, + Execute (Args& command, CommandReturnObject &result) { - Process *process = interpreter.GetDebugger().GetExecutionContext().process; + Process *process = m_interpreter.GetDebugger().GetExecutionContext().process; if (process == NULL) { result.AppendError ("no process to kill"); @@ -1017,8 +975,9 @@ class CommandObjectProcessStatus : public CommandObject { public: - CommandObjectProcessStatus () : - CommandObject ("process status", + CommandObjectProcessStatus (CommandInterpreter &interpreter) : + CommandObject (interpreter, + "process status", "Show the current status and location of executing process.", "process status", 0) @@ -1033,14 +992,13 @@ bool Execute ( - CommandInterpreter &interpreter, Args& command, CommandReturnObject &result ) { StreamString &output_stream = result.GetOutputStream(); result.SetStatus (eReturnStatusSuccessFinishNoResult); - ExecutionContext exe_ctx(interpreter.GetDebugger().GetExecutionContext()); + ExecutionContext exe_ctx(m_interpreter.GetDebugger().GetExecutionContext()); if (exe_ctx.process) { const StateType state = exe_ctx.process->GetState(); @@ -1063,7 +1021,7 @@ exe_ctx.thread = exe_ctx.process->GetThreadList().GetThreadAtIndex(0).get(); if (exe_ctx.thread != NULL) { - DisplayThreadsInfo (interpreter, &exe_ctx, result, true, true); + DisplayThreadsInfo (m_interpreter, &exe_ctx, result, true, true); } else { @@ -1092,18 +1050,19 @@ //------------------------------------------------------------------------- CommandObjectMultiwordProcess::CommandObjectMultiwordProcess (CommandInterpreter &interpreter) : - CommandObjectMultiword ("process", - "A set of commands for operating on a process.", - "process []") -{ - LoadSubCommand (interpreter, "attach", CommandObjectSP (new CommandObjectProcessAttach ())); - LoadSubCommand (interpreter, "launch", CommandObjectSP (new CommandObjectProcessLaunch ())); - LoadSubCommand (interpreter, "continue", CommandObjectSP (new CommandObjectProcessContinue ())); - LoadSubCommand (interpreter, "detach", CommandObjectSP (new CommandObjectProcessDetach ())); - LoadSubCommand (interpreter, "signal", CommandObjectSP (new CommandObjectProcessSignal ())); - LoadSubCommand (interpreter, "status", CommandObjectSP (new CommandObjectProcessStatus ())); - LoadSubCommand (interpreter, "interrupt", CommandObjectSP (new CommandObjectProcessInterrupt ())); - LoadSubCommand (interpreter, "kill", CommandObjectSP (new CommandObjectProcessKill ())); + CommandObjectMultiword (interpreter, + "process", + "A set of commands for operating on a process.", + "process []") +{ + LoadSubCommand ("attach", CommandObjectSP (new CommandObjectProcessAttach (interpreter))); + LoadSubCommand ("launch", CommandObjectSP (new CommandObjectProcessLaunch (interpreter))); + LoadSubCommand ("continue", CommandObjectSP (new CommandObjectProcessContinue (interpreter))); + LoadSubCommand ("detach", CommandObjectSP (new CommandObjectProcessDetach (interpreter))); + LoadSubCommand ("signal", CommandObjectSP (new CommandObjectProcessSignal (interpreter))); + LoadSubCommand ("status", CommandObjectSP (new CommandObjectProcessStatus (interpreter))); + LoadSubCommand ("interrupt", CommandObjectSP (new CommandObjectProcessInterrupt (interpreter))); + LoadSubCommand ("kill", CommandObjectSP (new CommandObjectProcessKill (interpreter))); } CommandObjectMultiwordProcess::~CommandObjectMultiwordProcess () Modified: lldb/trunk/source/Commands/CommandObjectQuit.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectQuit.cpp?rev=114252&r1=114251&r2=114252&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectQuit.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectQuit.cpp Fri Sep 17 20:14:36 2010 @@ -23,8 +23,8 @@ // CommandObjectQuit //------------------------------------------------------------------------- -CommandObjectQuit::CommandObjectQuit () : - CommandObject ("quit", "Quit out of the LLDB debugger.", "quit") +CommandObjectQuit::CommandObjectQuit (CommandInterpreter &interpreter) : + CommandObject (interpreter, "quit", "Quit out of the LLDB debugger.", "quit") { } @@ -35,12 +35,11 @@ bool CommandObjectQuit::Execute ( - CommandInterpreter &interpreter, Args& args, CommandReturnObject &result ) { - interpreter.BroadcastEvent (CommandInterpreter::eBroadcastBitQuitCommandReceived); + m_interpreter.BroadcastEvent (CommandInterpreter::eBroadcastBitQuitCommandReceived); result.SetStatus (eReturnStatusQuit); return true; } Modified: lldb/trunk/source/Commands/CommandObjectQuit.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectQuit.h?rev=114252&r1=114251&r2=114252&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectQuit.h (original) +++ lldb/trunk/source/Commands/CommandObjectQuit.h Fri Sep 17 20:14:36 2010 @@ -22,25 +22,17 @@ // CommandObjectQuit //------------------------------------------------------------------------- -// SPECIAL NOTE!! The CommandObjectQuit is special, because the actual function to execute -// when the user types 'quit' is passed (via function pointer) to the Command Interpreter when it -// is constructed. The function pointer is then stored in this CommandObjectQuit, and is invoked -// via the CommandObjectQuit::Execute function. This is the only command object that works this -// way; it was done this way because different Command Interpreter callers may want or need different things -// to be done in order to shut down properly. - class CommandObjectQuit : public CommandObject { public: - CommandObjectQuit (); + CommandObjectQuit (CommandInterpreter &interpreter); virtual ~CommandObjectQuit (); virtual bool - Execute (CommandInterpreter &interpreter, - Args& args, + Execute (Args& args, CommandReturnObject &result); }; Modified: lldb/trunk/source/Commands/CommandObjectRegister.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectRegister.cpp?rev=114252&r1=114251&r2=114252&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectRegister.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectRegister.cpp Fri Sep 17 20:14:36 2010 @@ -31,8 +31,9 @@ class CommandObjectRegisterRead : public CommandObject { public: - CommandObjectRegisterRead () : - CommandObject ("register read", + CommandObjectRegisterRead (CommandInterpreter &interpreter) : + CommandObject (interpreter, + "register read", "Dump the contents of one or more register values from the current frame.", "register read [ [ [...]]]", eFlagProcessMustBeLaunched | eFlagProcessMustBePaused) @@ -47,14 +48,13 @@ virtual bool Execute ( - CommandInterpreter &interpreter, Args& command, CommandReturnObject &result ) { StreamString &output_stream = result.GetOutputStream(); DataExtractor reg_data; - ExecutionContext exe_ctx(interpreter.GetDebugger().GetExecutionContext()); + ExecutionContext exe_ctx(m_interpreter.GetDebugger().GetExecutionContext()); RegisterContext *reg_context = exe_ctx.GetRegisterContext (); if (reg_context) @@ -139,8 +139,9 @@ class CommandObjectRegisterWrite : public CommandObject { public: - CommandObjectRegisterWrite () : - CommandObject ("register write", + CommandObjectRegisterWrite (CommandInterpreter &interpreter) : + CommandObject (interpreter, + "register write", "Modify a single register value.", "register write ", eFlagProcessMustBeLaunched | eFlagProcessMustBePaused) @@ -155,13 +156,12 @@ virtual bool Execute ( - CommandInterpreter &interpreter, Args& command, CommandReturnObject &result ) { DataExtractor reg_data; - ExecutionContext exe_ctx(interpreter.GetDebugger().GetExecutionContext()); + ExecutionContext exe_ctx(m_interpreter.GetDebugger().GetExecutionContext()); RegisterContext *reg_context = exe_ctx.GetRegisterContext (); if (reg_context) @@ -219,12 +219,13 @@ // CommandObjectRegister constructor //---------------------------------------------------------------------- CommandObjectRegister::CommandObjectRegister(CommandInterpreter &interpreter) : - CommandObjectMultiword ("register", + CommandObjectMultiword (interpreter, + "register", "A set of commands to access thread registers.", "register [read|write] ...") { - LoadSubCommand (interpreter, "read", CommandObjectSP (new CommandObjectRegisterRead ())); - LoadSubCommand (interpreter, "write", CommandObjectSP (new CommandObjectRegisterWrite ())); + LoadSubCommand ("read", CommandObjectSP (new CommandObjectRegisterRead (interpreter))); + LoadSubCommand ("write", CommandObjectSP (new CommandObjectRegisterWrite (interpreter))); } Modified: lldb/trunk/source/Commands/CommandObjectSettings.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectSettings.cpp?rev=114252&r1=114251&r2=114252&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectSettings.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectSettings.cpp Fri Sep 17 20:14:36 2010 @@ -25,31 +25,32 @@ //------------------------------------------------------------------------- CommandObjectMultiwordSettings::CommandObjectMultiwordSettings (CommandInterpreter &interpreter) : - CommandObjectMultiword ("settings", + CommandObjectMultiword (interpreter, + "settings", "A set of commands for manipulating internal settable debugger variables.", "settings []") { bool status; - CommandObjectSP set_command_object (new CommandObjectSettingsSet ()); - CommandObjectSP show_command_object (new CommandObjectSettingsShow ()); - CommandObjectSP list_command_object (new CommandObjectSettingsList ()); - CommandObjectSP remove_command_object (new CommandObjectSettingsRemove ()); - CommandObjectSP replace_command_object (new CommandObjectSettingsReplace ()); - CommandObjectSP insert_before_command_object (new CommandObjectSettingsInsertBefore ()); - CommandObjectSP insert_after_command_object (new CommandObjectSettingsInsertAfter()); - CommandObjectSP append_command_object (new CommandObjectSettingsAppend()); - CommandObjectSP clear_command_object (new CommandObjectSettingsClear()); - - status = LoadSubCommand (interpreter, "set", set_command_object); - status = LoadSubCommand (interpreter, "show", show_command_object); - status = LoadSubCommand (interpreter, "list", list_command_object); - status = LoadSubCommand (interpreter, "remove", remove_command_object); - status = LoadSubCommand (interpreter, "replace", replace_command_object); - status = LoadSubCommand (interpreter, "insert-before", insert_before_command_object); - status = LoadSubCommand (interpreter, "insert-after", insert_after_command_object); - status = LoadSubCommand (interpreter, "append", append_command_object); - status = LoadSubCommand (interpreter, "clear", clear_command_object); + CommandObjectSP set_command_object (new CommandObjectSettingsSet (interpreter)); + CommandObjectSP show_command_object (new CommandObjectSettingsShow (interpreter)); + CommandObjectSP list_command_object (new CommandObjectSettingsList (interpreter)); + CommandObjectSP remove_command_object (new CommandObjectSettingsRemove (interpreter)); + CommandObjectSP replace_command_object (new CommandObjectSettingsReplace (interpreter)); + CommandObjectSP insert_before_command_object (new CommandObjectSettingsInsertBefore (interpreter)); + CommandObjectSP insert_after_command_object (new CommandObjectSettingsInsertAfter(interpreter)); + CommandObjectSP append_command_object (new CommandObjectSettingsAppend(interpreter)); + CommandObjectSP clear_command_object (new CommandObjectSettingsClear(interpreter)); + + status = LoadSubCommand ("set", set_command_object); + status = LoadSubCommand ("show", show_command_object); + status = LoadSubCommand ("list", list_command_object); + status = LoadSubCommand ("remove", remove_command_object); + status = LoadSubCommand ("replace", replace_command_object); + status = LoadSubCommand ("insert-before", insert_before_command_object); + status = LoadSubCommand ("insert-after", insert_after_command_object); + status = LoadSubCommand ("append", append_command_object); + status = LoadSubCommand ("clear", clear_command_object); } CommandObjectMultiwordSettings::~CommandObjectMultiwordSettings () @@ -60,8 +61,9 @@ // CommandObjectSettingsSet //------------------------------------------------------------------------- -CommandObjectSettingsSet::CommandObjectSettingsSet () : - CommandObject ("settings set", +CommandObjectSettingsSet::CommandObjectSettingsSet (CommandInterpreter &interpreter) : + CommandObject (interpreter, + "settings set", "Set or change the value of a single debugger setting variable.", "settings set [] "), m_options () @@ -74,9 +76,7 @@ bool -CommandObjectSettingsSet::Execute (CommandInterpreter &interpreter, - Args& command, - CommandReturnObject &result) +CommandObjectSettingsSet::Execute (Args& command, CommandReturnObject &result) { UserSettingsControllerSP root_settings = Debugger::GetSettingsController (); @@ -116,9 +116,11 @@ } else { - Error err = root_settings->SetVariable (var_name_string.c_str(), var_value, lldb::eVarSetOperationAssign, + Error err = root_settings->SetVariable (var_name_string.c_str(), + var_value, + lldb::eVarSetOperationAssign, m_options.m_override, - interpreter.GetDebugger().GetInstanceName().AsCString()); + m_interpreter.GetDebugger().GetInstanceName().AsCString()); if (err.Fail ()) { result.AppendError (err.AsCString()); @@ -132,8 +134,7 @@ } int -CommandObjectSettingsSet::HandleArgumentCompletion (CommandInterpreter &interpreter, - Args &input, +CommandObjectSettingsSet::HandleArgumentCompletion (Args &input, int &cursor_index, int &cursor_char_position, OptionElementVector &opt_element_vector, @@ -147,7 +148,7 @@ // Attempting to complete variable name if (cursor_index == 1) - CommandCompletions::InvokeCommonCompletionCallbacks (interpreter, + CommandCompletions::InvokeCommonCompletionCallbacks (m_interpreter, CommandCompletions::eSettingsNameCompletion, completion_str.c_str(), match_start_point, @@ -258,10 +259,11 @@ // CommandObjectSettingsShow -- Show current values //------------------------------------------------------------------------- -CommandObjectSettingsShow::CommandObjectSettingsShow () : - CommandObject ("settings show", - "Show the specified internal debugger setting variable and its value, or show all the currently set variables and their values, if nothing is specified.", - "settings show []") +CommandObjectSettingsShow::CommandObjectSettingsShow (CommandInterpreter &interpreter) : + CommandObject (interpreter, + "settings show", + "Show the specified internal debugger setting variable and its value, or show all the currently set variables and their values, if nothing is specified.", + "settings show []") { } @@ -271,8 +273,7 @@ bool -CommandObjectSettingsShow::Execute (CommandInterpreter &interpreter, - Args& command, +CommandObjectSettingsShow::Execute ( Args& command, CommandReturnObject &result) { UserSettingsControllerSP root_settings = Debugger::GetSettingsController (); @@ -286,7 +287,7 @@ lldb::SettableVariableType var_type; const char *variable_name = command.GetArgumentAtIndex (0); StringList value = root_settings->GetVariable (variable_name, var_type, - interpreter.GetDebugger().GetInstanceName().AsCString()); + m_interpreter.GetDebugger().GetInstanceName().AsCString()); if (value.GetSize() == 0) { @@ -320,8 +321,11 @@ } else { - UserSettingsController::GetAllVariableValues (interpreter, root_settings, current_prefix, - result.GetOutputStream(), err); + UserSettingsController::GetAllVariableValues (m_interpreter, + root_settings, + current_prefix, + result.GetOutputStream(), + err); if (err.Fail ()) { result.AppendError (err.AsCString()); @@ -337,8 +341,7 @@ } int -CommandObjectSettingsShow::HandleArgumentCompletion (CommandInterpreter &interpreter, - Args &input, +CommandObjectSettingsShow::HandleArgumentCompletion (Args &input, int &cursor_index, int &cursor_char_position, OptionElementVector &opt_element_vector, @@ -350,7 +353,7 @@ std::string completion_str (input.GetArgumentAtIndex (cursor_index)); completion_str.erase (cursor_char_position); - CommandCompletions::InvokeCommonCompletionCallbacks (interpreter, + CommandCompletions::InvokeCommonCompletionCallbacks (m_interpreter, CommandCompletions::eSettingsNameCompletion, completion_str.c_str(), match_start_point, @@ -365,8 +368,9 @@ // CommandObjectSettingsList //------------------------------------------------------------------------- -CommandObjectSettingsList::CommandObjectSettingsList () : - CommandObject ("settings list", +CommandObjectSettingsList::CommandObjectSettingsList (CommandInterpreter &interpreter) : + CommandObject (interpreter, + "settings list", "List and describe all the internal debugger settings variables that are available to the user to 'set' or 'show', or describe a particular variable or set of variables (by specifying the variable name or a common prefix).", "settings list [ | ]") { @@ -378,8 +382,7 @@ bool -CommandObjectSettingsList::Execute (CommandInterpreter &interpreter, - Args& command, +CommandObjectSettingsList::Execute ( Args& command, CommandReturnObject &result) { UserSettingsControllerSP root_settings = Debugger::GetSettingsController (); @@ -389,14 +392,21 @@ if (command.GetArgumentCount() == 0) { - UserSettingsController::FindAllSettingsDescriptions (interpreter, root_settings, current_prefix, - result.GetOutputStream(), err); + UserSettingsController::FindAllSettingsDescriptions (m_interpreter, + root_settings, + current_prefix, + result.GetOutputStream(), + err); } else if (command.GetArgumentCount() == 1) { const char *search_name = command.GetArgumentAtIndex (0); - UserSettingsController::FindSettingsDescriptions (interpreter, root_settings, current_prefix, - search_name, result.GetOutputStream(), err); + UserSettingsController::FindSettingsDescriptions (m_interpreter, + root_settings, + current_prefix, + search_name, + result.GetOutputStream(), + err); } else { @@ -419,8 +429,7 @@ } int -CommandObjectSettingsList::HandleArgumentCompletion (CommandInterpreter &interpreter, - Args &input, +CommandObjectSettingsList::HandleArgumentCompletion (Args &input, int &cursor_index, int &cursor_char_position, OptionElementVector &opt_element_vector, @@ -432,7 +441,7 @@ std::string completion_str (input.GetArgumentAtIndex (cursor_index)); completion_str.erase (cursor_char_position); - CommandCompletions::InvokeCommonCompletionCallbacks (interpreter, + CommandCompletions::InvokeCommonCompletionCallbacks (m_interpreter, CommandCompletions::eSettingsNameCompletion, completion_str.c_str(), match_start_point, @@ -447,8 +456,9 @@ // CommandObjectSettingsRemove //------------------------------------------------------------------------- -CommandObjectSettingsRemove::CommandObjectSettingsRemove () : - CommandObject ("settings remove", +CommandObjectSettingsRemove::CommandObjectSettingsRemove (CommandInterpreter &interpreter) : + CommandObject (interpreter, + "settings remove", "Remove the specified element from an internal debugger settings array or dictionary variable.", "settings remove [|\"key\"]") { @@ -459,8 +469,7 @@ } bool -CommandObjectSettingsRemove::Execute (CommandInterpreter &interpreter, - Args& command, +CommandObjectSettingsRemove::Execute ( Args& command, CommandReturnObject &result) { UserSettingsControllerSP root_settings = Debugger::GetSettingsController (); @@ -497,8 +506,11 @@ index_value_string = index_value; - Error err = root_settings->SetVariable (var_name_string.c_str(), NULL, lldb::eVarSetOperationRemove, - false, interpreter.GetDebugger().GetInstanceName().AsCString(), + Error err = root_settings->SetVariable (var_name_string.c_str(), + NULL, + lldb::eVarSetOperationRemove, + false, + m_interpreter.GetDebugger().GetInstanceName().AsCString(), index_value_string.c_str()); if (err.Fail ()) { @@ -512,8 +524,7 @@ } int -CommandObjectSettingsRemove::HandleArgumentCompletion (CommandInterpreter &interpreter, - Args &input, +CommandObjectSettingsRemove::HandleArgumentCompletion (Args &input, int &cursor_index, int &cursor_char_position, OptionElementVector &opt_element_vector, @@ -527,7 +538,7 @@ // Attempting to complete variable name if (cursor_index < 2) - CommandCompletions::InvokeCommonCompletionCallbacks (interpreter, + CommandCompletions::InvokeCommonCompletionCallbacks (m_interpreter, CommandCompletions::eSettingsNameCompletion, completion_str.c_str(), match_start_point, @@ -543,8 +554,9 @@ // CommandObjectSettingsReplace //------------------------------------------------------------------------- -CommandObjectSettingsReplace::CommandObjectSettingsReplace () : - CommandObject ("settings replace", +CommandObjectSettingsReplace::CommandObjectSettingsReplace (CommandInterpreter &interpreter) : + CommandObject (interpreter, + "settings replace", "Replace the specified element from an internal debugger settings array or dictionary variable with the specified new value.", "settings replace [|\"\"] ") { @@ -555,8 +567,7 @@ } bool -CommandObjectSettingsReplace::Execute (CommandInterpreter &interpreter, - Args& command, +CommandObjectSettingsReplace::Execute ( Args& command, CommandReturnObject &result) { UserSettingsControllerSP root_settings = Debugger::GetSettingsController (); @@ -607,8 +618,11 @@ } else { - Error err = root_settings->SetVariable (var_name_string.c_str(), var_value, lldb::eVarSetOperationReplace, - false, interpreter.GetDebugger().GetInstanceName().AsCString(), + Error err = root_settings->SetVariable (var_name_string.c_str(), + var_value, + lldb::eVarSetOperationReplace, + false, + m_interpreter.GetDebugger().GetInstanceName().AsCString(), index_value_string.c_str()); if (err.Fail ()) { @@ -623,8 +637,7 @@ } int -CommandObjectSettingsReplace::HandleArgumentCompletion (CommandInterpreter &interpreter, - Args &input, +CommandObjectSettingsReplace::HandleArgumentCompletion (Args &input, int &cursor_index, int &cursor_char_position, OptionElementVector &opt_element_vector, @@ -638,7 +651,7 @@ // Attempting to complete variable name if (cursor_index < 2) - CommandCompletions::InvokeCommonCompletionCallbacks (interpreter, + CommandCompletions::InvokeCommonCompletionCallbacks (m_interpreter, CommandCompletions::eSettingsNameCompletion, completion_str.c_str(), match_start_point, @@ -654,8 +667,9 @@ // CommandObjectSettingsInsertBefore //------------------------------------------------------------------------- -CommandObjectSettingsInsertBefore::CommandObjectSettingsInsertBefore () : - CommandObject ("settings insert-before", +CommandObjectSettingsInsertBefore::CommandObjectSettingsInsertBefore (CommandInterpreter &interpreter) : + CommandObject (interpreter, + "settings insert-before", "Insert value(s) into an internal debugger settings array variable, immediately before the specified element.", "settings insert-before [] ") { @@ -666,8 +680,7 @@ } bool -CommandObjectSettingsInsertBefore::Execute (CommandInterpreter &interpreter, - Args& command, +CommandObjectSettingsInsertBefore::Execute ( Args& command, CommandReturnObject &result) { UserSettingsControllerSP root_settings = Debugger::GetSettingsController (); @@ -719,8 +732,11 @@ } else { - Error err = root_settings->SetVariable (var_name_string.c_str(), var_value, lldb::eVarSetOperationInsertBefore, - false, interpreter.GetDebugger().GetInstanceName().AsCString(), + Error err = root_settings->SetVariable (var_name_string.c_str(), + var_value, + lldb::eVarSetOperationInsertBefore, + false, + m_interpreter.GetDebugger().GetInstanceName().AsCString(), index_value_string.c_str()); if (err.Fail ()) { @@ -736,8 +752,7 @@ int -CommandObjectSettingsInsertBefore::HandleArgumentCompletion (CommandInterpreter &interpreter, - Args &input, +CommandObjectSettingsInsertBefore::HandleArgumentCompletion (Args &input, int &cursor_index, int &cursor_char_position, OptionElementVector &opt_element_vector, @@ -751,7 +766,7 @@ // Attempting to complete variable name if (cursor_index < 2) - CommandCompletions::InvokeCommonCompletionCallbacks (interpreter, + CommandCompletions::InvokeCommonCompletionCallbacks (m_interpreter, CommandCompletions::eSettingsNameCompletion, completion_str.c_str(), match_start_point, @@ -767,8 +782,9 @@ // CommandObjectSettingInsertAfter //------------------------------------------------------------------------- -CommandObjectSettingsInsertAfter::CommandObjectSettingsInsertAfter () : - CommandObject ("settings insert-after", +CommandObjectSettingsInsertAfter::CommandObjectSettingsInsertAfter (CommandInterpreter &interpreter) : + CommandObject (interpreter, + "settings insert-after", "Insert value(s) into an internal debugger settings array variable, immediately after the specified element.", "settings insert-after [] ") { @@ -779,8 +795,7 @@ } bool -CommandObjectSettingsInsertAfter::Execute (CommandInterpreter &interpreter, - Args& command, +CommandObjectSettingsInsertAfter::Execute ( Args& command, CommandReturnObject &result) { UserSettingsControllerSP root_settings = Debugger::GetSettingsController (); @@ -832,8 +847,11 @@ } else { - Error err = root_settings->SetVariable (var_name_string.c_str(), var_value, lldb::eVarSetOperationInsertAfter, - false, interpreter.GetDebugger().GetInstanceName().AsCString(), + Error err = root_settings->SetVariable (var_name_string.c_str(), + var_value, + lldb::eVarSetOperationInsertAfter, + false, + m_interpreter.GetDebugger().GetInstanceName().AsCString(), index_value_string.c_str()); if (err.Fail ()) { @@ -849,8 +867,7 @@ int -CommandObjectSettingsInsertAfter::HandleArgumentCompletion (CommandInterpreter &interpreter, - Args &input, +CommandObjectSettingsInsertAfter::HandleArgumentCompletion (Args &input, int &cursor_index, int &cursor_char_position, OptionElementVector &opt_element_vector, @@ -864,7 +881,7 @@ // Attempting to complete variable name if (cursor_index < 2) - CommandCompletions::InvokeCommonCompletionCallbacks (interpreter, + CommandCompletions::InvokeCommonCompletionCallbacks (m_interpreter, CommandCompletions::eSettingsNameCompletion, completion_str.c_str(), match_start_point, @@ -880,8 +897,9 @@ // CommandObjectSettingsAppend //------------------------------------------------------------------------- -CommandObjectSettingsAppend::CommandObjectSettingsAppend () : - CommandObject ("settings append", +CommandObjectSettingsAppend::CommandObjectSettingsAppend (CommandInterpreter &interpreter) : + CommandObject (interpreter, + "settings append", "Append a new value to the end of an internal debugger settings array, dictionary or string variable.", "settings append ") { @@ -892,8 +910,7 @@ } bool -CommandObjectSettingsAppend::Execute (CommandInterpreter &interpreter, - Args& command, +CommandObjectSettingsAppend::Execute ( Args& command, CommandReturnObject &result) { UserSettingsControllerSP root_settings = Debugger::GetSettingsController (); @@ -933,8 +950,11 @@ } else { - Error err = root_settings->SetVariable (var_name_string.c_str(), var_value, lldb::eVarSetOperationAppend, - false, interpreter.GetDebugger().GetInstanceName().AsCString()); + Error err = root_settings->SetVariable (var_name_string.c_str(), + var_value, + lldb::eVarSetOperationAppend, + false, + m_interpreter.GetDebugger().GetInstanceName().AsCString()); if (err.Fail ()) { result.AppendError (err.AsCString()); @@ -949,8 +969,7 @@ int -CommandObjectSettingsAppend::HandleArgumentCompletion (CommandInterpreter &interpreter, - Args &input, +CommandObjectSettingsAppend::HandleArgumentCompletion (Args &input, int &cursor_index, int &cursor_char_position, OptionElementVector &opt_element_vector, @@ -964,7 +983,7 @@ // Attempting to complete variable name if (cursor_index < 2) - CommandCompletions::InvokeCommonCompletionCallbacks (interpreter, + CommandCompletions::InvokeCommonCompletionCallbacks (m_interpreter, CommandCompletions::eSettingsNameCompletion, completion_str.c_str(), match_start_point, @@ -980,8 +999,9 @@ // CommandObjectSettingsClear //------------------------------------------------------------------------- -CommandObjectSettingsClear::CommandObjectSettingsClear () : - CommandObject ("settings clear", +CommandObjectSettingsClear::CommandObjectSettingsClear (CommandInterpreter &interpreter) : + CommandObject (interpreter, + "settings clear", "Erase all the contents of an internal debugger settings variables; this is only valid for variables with clearable types, i.e. strings, arrays or dictionaries.", "settings clear") { @@ -992,8 +1012,7 @@ } bool -CommandObjectSettingsClear::Execute (CommandInterpreter &interpreter, - Args& command, +CommandObjectSettingsClear::Execute ( Args& command, CommandReturnObject &result) { UserSettingsControllerSP root_settings = Debugger::GetSettingsController (); @@ -1015,8 +1034,11 @@ return false; } - Error err = root_settings->SetVariable (var_name, NULL, lldb::eVarSetOperationClear, false, - interpreter.GetDebugger().GetInstanceName().AsCString()); + Error err = root_settings->SetVariable (var_name, + NULL, + lldb::eVarSetOperationClear, + false, + m_interpreter.GetDebugger().GetInstanceName().AsCString()); if (err.Fail ()) { @@ -1031,8 +1053,7 @@ int -CommandObjectSettingsClear::HandleArgumentCompletion (CommandInterpreter &interpreter, - Args &input, +CommandObjectSettingsClear::HandleArgumentCompletion (Args &input, int &cursor_index, int &cursor_char_position, OptionElementVector &opt_element_vector, @@ -1046,7 +1067,7 @@ // Attempting to complete variable name if (cursor_index < 2) - CommandCompletions::InvokeCommonCompletionCallbacks (interpreter, + CommandCompletions::InvokeCommonCompletionCallbacks (m_interpreter, CommandCompletions::eSettingsNameCompletion, completion_str.c_str(), match_start_point, Modified: lldb/trunk/source/Commands/CommandObjectSettings.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectSettings.h?rev=114252&r1=114251&r2=114252&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectSettings.h (original) +++ lldb/trunk/source/Commands/CommandObjectSettings.h Fri Sep 17 20:14:36 2010 @@ -43,14 +43,13 @@ class CommandObjectSettingsSet : public CommandObject { public: - CommandObjectSettingsSet (); + CommandObjectSettingsSet (CommandInterpreter &interpreter); virtual ~CommandObjectSettingsSet (); virtual bool - Execute (CommandInterpreter &interpreter, - Args& command, + Execute (Args& command, CommandReturnObject &result); virtual Options * @@ -86,8 +85,7 @@ }; virtual int - HandleArgumentCompletion (CommandInterpreter &interpreter, - Args &input, + HandleArgumentCompletion (Args &input, int &cursor_index, int &cursor_char_position, OptionElementVector &opt_element_vector, @@ -107,20 +105,18 @@ class CommandObjectSettingsShow : public CommandObject { public: - CommandObjectSettingsShow (); + CommandObjectSettingsShow (CommandInterpreter &interpreter); virtual ~CommandObjectSettingsShow (); virtual bool - Execute (CommandInterpreter &interpreter, - Args& command, + Execute (Args& command, CommandReturnObject &result); virtual int - HandleArgumentCompletion (CommandInterpreter &interpreter, - Args &input, + HandleArgumentCompletion (Args &input, int &cursor_index, int &cursor_char_position, OptionElementVector &opt_element_vector, @@ -139,19 +135,17 @@ class CommandObjectSettingsList : public CommandObject { public: - CommandObjectSettingsList (); + CommandObjectSettingsList (CommandInterpreter &interpreter); virtual ~CommandObjectSettingsList (); virtual bool - Execute (CommandInterpreter &interpreter, - Args& command, + Execute (Args& command, CommandReturnObject &result); virtual int - HandleArgumentCompletion (CommandInterpreter &interpreter, - Args &input, + HandleArgumentCompletion (Args &input, int &cursor_index, int &cursor_char_position, OptionElementVector &opt_element_vector, @@ -170,19 +164,17 @@ class CommandObjectSettingsRemove : public CommandObject { public: - CommandObjectSettingsRemove (); + CommandObjectSettingsRemove (CommandInterpreter &interpreter); virtual ~CommandObjectSettingsRemove (); virtual bool - Execute (CommandInterpreter &interpreter, - Args& command, + Execute (Args& command, CommandReturnObject &result); virtual int - HandleArgumentCompletion (CommandInterpreter &interpreter, - Args &input, + HandleArgumentCompletion (Args &input, int &cursor_index, int &cursor_char_position, OptionElementVector &opt_element_vector, @@ -201,19 +193,17 @@ class CommandObjectSettingsReplace : public CommandObject { public: - CommandObjectSettingsReplace (); + CommandObjectSettingsReplace (CommandInterpreter &interpreter); virtual ~CommandObjectSettingsReplace (); virtual bool - Execute (CommandInterpreter &interpreter, - Args& command, + Execute (Args& command, CommandReturnObject &result); virtual int - HandleArgumentCompletion (CommandInterpreter &interpreter, - Args &input, + HandleArgumentCompletion (Args &input, int &cursor_index, int &cursor_char_position, OptionElementVector &opt_element_vector, @@ -232,19 +222,17 @@ class CommandObjectSettingsInsertBefore : public CommandObject { public: - CommandObjectSettingsInsertBefore (); + CommandObjectSettingsInsertBefore (CommandInterpreter &interpreter); virtual ~CommandObjectSettingsInsertBefore (); virtual bool - Execute (CommandInterpreter &interpreter, - Args& command, + Execute (Args& command, CommandReturnObject &result); virtual int - HandleArgumentCompletion (CommandInterpreter &interpreter, - Args &input, + HandleArgumentCompletion (Args &input, int &cursor_index, int &cursor_char_position, OptionElementVector &opt_element_vector, @@ -263,19 +251,17 @@ class CommandObjectSettingsInsertAfter : public CommandObject { public: - CommandObjectSettingsInsertAfter (); + CommandObjectSettingsInsertAfter (CommandInterpreter &interpreter); virtual ~CommandObjectSettingsInsertAfter (); virtual bool - Execute (CommandInterpreter &interpreter, - Args& command, + Execute (Args& command, CommandReturnObject &result); virtual int - HandleArgumentCompletion (CommandInterpreter &interpreter, - Args &input, + HandleArgumentCompletion (Args &input, int &cursor_index, int &cursor_char_position, OptionElementVector &opt_element_vector, @@ -294,19 +280,17 @@ class CommandObjectSettingsAppend : public CommandObject { public: - CommandObjectSettingsAppend (); + CommandObjectSettingsAppend (CommandInterpreter &interpreter); virtual ~CommandObjectSettingsAppend (); virtual bool - Execute (CommandInterpreter &interpreter, - Args& command, + Execute (Args& command, CommandReturnObject &result); virtual int - HandleArgumentCompletion (CommandInterpreter &interpreter, - Args &input, + HandleArgumentCompletion (Args &input, int &cursor_index, int &cursor_char_position, OptionElementVector &opt_element_vector, @@ -325,19 +309,17 @@ class CommandObjectSettingsClear : public CommandObject { public: - CommandObjectSettingsClear (); + CommandObjectSettingsClear (CommandInterpreter &interpreter); virtual ~CommandObjectSettingsClear (); virtual bool - Execute (CommandInterpreter &interpreter, - Args& command, + Execute (Args& command, CommandReturnObject &result); virtual int - HandleArgumentCompletion (CommandInterpreter &interpreter, - Args &input, + HandleArgumentCompletion (Args &input, int &cursor_index, int &cursor_char_position, OptionElementVector &opt_element_vector, Modified: lldb/trunk/source/Commands/CommandObjectSource.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectSource.cpp?rev=114252&r1=114251&r2=114252&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectSource.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectSource.cpp Fri Sep 17 20:14:36 2010 @@ -96,10 +96,11 @@ }; public: - CommandObjectSourceInfo() : - CommandObject ("source info", - "Display information about the source lines from the current executable's debug info.", - "source info []") + CommandObjectSourceInfo(CommandInterpreter &interpreter) : + CommandObject (interpreter, + "source info", + "Display information about the source lines from the current executable's debug info.", + "source info []") { } @@ -118,7 +119,6 @@ bool Execute ( - CommandInterpreter &interpreter, Args& args, CommandReturnObject &result ) @@ -227,10 +227,11 @@ }; public: - CommandObjectSourceList() : - CommandObject ("source list", - "Display source code (as specified) based on the current executable's debug info.", - "source list [] []") + CommandObjectSourceList(CommandInterpreter &interpreter) : + CommandObject (interpreter, + "source list", + "Display source code (as specified) based on the current executable's debug info.", + "source list [] []") { } @@ -249,7 +250,6 @@ bool Execute ( - CommandInterpreter &interpreter, Args& args, CommandReturnObject &result ) @@ -262,12 +262,12 @@ result.SetStatus (eReturnStatusFailed); } - ExecutionContext exe_ctx(interpreter.GetDebugger().GetExecutionContext()); + ExecutionContext exe_ctx(m_interpreter.GetDebugger().GetExecutionContext()); if (!m_options.symbol_name.empty()) { // Displaying the source for a symbol: - Target *target = interpreter.GetDebugger().GetSelectedTarget().get(); + Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get(); if (target == NULL) { result.AppendError ("invalid target, set executable file using 'file' command"); @@ -400,12 +400,12 @@ char path_buf[PATH_MAX+1]; start_file.GetPath(path_buf, PATH_MAX); result.AppendMessageWithFormat("File: %s.\n", path_buf); - interpreter.GetDebugger().GetSourceManager().DisplaySourceLinesWithLineNumbers (start_file, - line_no, - 0, - m_options.num_lines, - "", - &result.GetOutputStream()); + m_interpreter.GetDebugger().GetSourceManager().DisplaySourceLinesWithLineNumbers (start_file, + line_no, + 0, + m_options.num_lines, + "", + &result.GetOutputStream()); result.SetStatus (eReturnStatusSuccessFinishResult); return true; @@ -419,14 +419,14 @@ // more likely because you typed it once, then typed it again if (m_options.start_line == 0) { - if (interpreter.GetDebugger().GetSourceManager().DisplayMoreWithLineNumbers (&result.GetOutputStream())) + if (m_interpreter.GetDebugger().GetSourceManager().DisplayMoreWithLineNumbers (&result.GetOutputStream())) { result.SetStatus (eReturnStatusSuccessFinishResult); } } else { - if (interpreter.GetDebugger().GetSourceManager().DisplaySourceLinesWithLineNumbersUsingLastFile( + if (m_interpreter.GetDebugger().GetSourceManager().DisplaySourceLinesWithLineNumbersUsingLastFile( m_options.start_line, // Line to display 0, // Lines before line to display m_options.num_lines, // Lines after line to display @@ -441,7 +441,7 @@ else { const char *filename = m_options.file_name.c_str(); - Target *target = interpreter.GetDebugger().GetSelectedTarget().get(); + Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get(); if (target == NULL) { result.AppendError ("invalid target, set executable file using 'file' command"); @@ -524,12 +524,12 @@ { if (sc.comp_unit) { - interpreter.GetDebugger().GetSourceManager().DisplaySourceLinesWithLineNumbers (sc.comp_unit, - m_options.start_line, - 0, - m_options.num_lines, - "", - &result.GetOutputStream()); + m_interpreter.GetDebugger().GetSourceManager().DisplaySourceLinesWithLineNumbers (sc.comp_unit, + m_options.start_line, + 0, + m_options.num_lines, + "", + &result.GetOutputStream()); result.SetStatus (eReturnStatusSuccessFinishResult); } @@ -574,12 +574,13 @@ //------------------------------------------------------------------------- CommandObjectMultiwordSource::CommandObjectMultiwordSource (CommandInterpreter &interpreter) : - CommandObjectMultiword ("source", + CommandObjectMultiword (interpreter, + "source", "A set of commands for accessing source file information", "source []") { - LoadSubCommand (interpreter, "info", CommandObjectSP (new CommandObjectSourceInfo ())); - LoadSubCommand (interpreter, "list", CommandObjectSP (new CommandObjectSourceList ())); + LoadSubCommand ("info", CommandObjectSP (new CommandObjectSourceInfo (interpreter))); + LoadSubCommand ("list", CommandObjectSP (new CommandObjectSourceList (interpreter))); } CommandObjectMultiwordSource::~CommandObjectMultiwordSource () Modified: lldb/trunk/source/Commands/CommandObjectSyntax.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectSyntax.cpp?rev=114252&r1=114251&r2=114252&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectSyntax.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectSyntax.cpp Fri Sep 17 20:14:36 2010 @@ -27,10 +27,11 @@ // CommandObjectSyntax //------------------------------------------------------------------------- -CommandObjectSyntax::CommandObjectSyntax () : - CommandObject ("syntax", - "Shows the correct syntax for a given debugger command.", - "syntax ") +CommandObjectSyntax::CommandObjectSyntax (CommandInterpreter &interpreter) : + CommandObject (interpreter, + "syntax", + "Shows the correct syntax for a given debugger command.", + "syntax ") { } @@ -42,7 +43,6 @@ bool CommandObjectSyntax::Execute ( - CommandInterpreter &interpreter, Args& command, CommandReturnObject &result ) @@ -53,7 +53,7 @@ if (argc > 0) { - cmd_obj = interpreter.GetCommandObject (command.GetArgumentAtIndex(0)); + cmd_obj = m_interpreter.GetCommandObject (command.GetArgumentAtIndex(0)); bool all_okay = true; for (int i = 1; i < argc; ++i) { Modified: lldb/trunk/source/Commands/CommandObjectSyntax.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectSyntax.h?rev=114252&r1=114251&r2=114252&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectSyntax.h (original) +++ lldb/trunk/source/Commands/CommandObjectSyntax.h Fri Sep 17 20:14:36 2010 @@ -26,14 +26,13 @@ { public: - CommandObjectSyntax (); + CommandObjectSyntax (CommandInterpreter &interpreter); virtual ~CommandObjectSyntax (); virtual bool - Execute (CommandInterpreter &interpreter, - Args& command, + Execute (Args& command, CommandReturnObject &result); Modified: lldb/trunk/source/Commands/CommandObjectTarget.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectTarget.cpp?rev=114252&r1=114251&r2=114252&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectTarget.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectTarget.cpp Fri Sep 17 20:14:36 2010 @@ -34,8 +34,9 @@ { public: - CommandObjectTargetImageSearchPathsAdd () : - CommandObject ("target image-search-paths add", + CommandObjectTargetImageSearchPathsAdd (CommandInterpreter &interpreter) : + CommandObject (interpreter, + "target image-search-paths add", "Add new image search paths substitution pairs to the current target.", "target image-search-paths add [ ] ...") { @@ -46,11 +47,10 @@ } bool - Execute (CommandInterpreter &interpreter, - Args& command, + Execute (Args& command, CommandReturnObject &result) { - Target *target = interpreter.GetDebugger().GetSelectedTarget().get(); + Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get(); if (target) { uint32_t argc = command.GetArgumentCount(); @@ -97,8 +97,9 @@ { public: - CommandObjectTargetImageSearchPathsClear () : - CommandObject ("target image-search-paths clear", + CommandObjectTargetImageSearchPathsClear (CommandInterpreter &interpreter) : + CommandObject (interpreter, + "target image-search-paths clear", "Clear all current image search path substitution pairs from the current target.", "target image-search-paths clear") { @@ -109,11 +110,10 @@ } bool - Execute (CommandInterpreter &interpreter, - Args& command, + Execute (Args& command, CommandReturnObject &result) { - Target *target = interpreter.GetDebugger().GetSelectedTarget().get(); + Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get(); if (target) { bool notify = true; @@ -132,8 +132,9 @@ { public: - CommandObjectTargetImageSearchPathsInsert () : - CommandObject ("target image-search-paths insert", + CommandObjectTargetImageSearchPathsInsert (CommandInterpreter &interpreter) : + CommandObject (interpreter, + "target image-search-paths insert", "Insert a new image search path substitution pair into the current target at the specified index.", "target image-search-paths insert [ ] ...") { @@ -144,11 +145,10 @@ } bool - Execute (CommandInterpreter &interpreter, - Args& command, + Execute (Args& command, CommandReturnObject &result) { - Target *target = interpreter.GetDebugger().GetSelectedTarget().get(); + Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get(); if (target) { uint32_t argc = command.GetArgumentCount(); @@ -215,8 +215,9 @@ { public: - CommandObjectTargetImageSearchPathsList () : - CommandObject ("target image-search-paths list", + CommandObjectTargetImageSearchPathsList (CommandInterpreter &interpreter) : + CommandObject (interpreter, + "target image-search-paths list", "List all current image search path substitution pairs in the current target.", "target image-search-paths list") { @@ -227,11 +228,10 @@ } bool - Execute (CommandInterpreter &interpreter, - Args& command, + Execute (Args& command, CommandReturnObject &result) { - Target *target = interpreter.GetDebugger().GetSelectedTarget().get(); + Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get(); if (target) { if (command.GetArgumentCount() != 0) @@ -256,8 +256,9 @@ { public: - CommandObjectTargetImageSearchPathsQuery () : - CommandObject ("target image-search-paths query", + CommandObjectTargetImageSearchPathsQuery (CommandInterpreter &interpreter) : + CommandObject (interpreter, + "target image-search-paths query", "Transform a path using the first applicable image search path.", "target image-search-paths query ") { @@ -268,11 +269,10 @@ } bool - Execute (CommandInterpreter &interpreter, - Args& command, + Execute (Args& command, CommandReturnObject &result) { - Target *target = interpreter.GetDebugger().GetSelectedTarget().get(); + Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get(); if (target) { if (command.GetArgumentCount() != 1) @@ -310,7 +310,8 @@ //public: // // CommandObjectTargetSelect () : -// CommandObject ("frame select", +// CommandObject (interpreter, +// frame select", // "Select the current frame by index in the current thread.", // "frame select ") // { @@ -323,7 +324,7 @@ // bool // Execute (Args& command, // Debugger *context, -// CommandInterpreter &interpreter, +// CommandInterpreter &m_interpreter, // CommandReturnObject &result) // { // ExecutionContext exe_ctx (context->GetExecutionContext()); @@ -344,7 +345,7 @@ // { // if (DisplayFrameForExecutionContext (exe_ctx.thread, // exe_ctx.frame, -// interpreter, +// m_interpreter, // result.GetOutputStream(), // true, // true, @@ -388,15 +389,16 @@ public: CommandObjectMultiwordImageSearchPaths (CommandInterpreter &interpreter) : - CommandObjectMultiword ("target image-search-paths", + CommandObjectMultiword (interpreter, + "target image-search-paths", "A set of commands for operating on debugger target image search paths.", "target image-search-paths []") { - LoadSubCommand (interpreter, "add", CommandObjectSP (new CommandObjectTargetImageSearchPathsAdd ())); - LoadSubCommand (interpreter, "clear", CommandObjectSP (new CommandObjectTargetImageSearchPathsClear ())); - LoadSubCommand (interpreter, "insert", CommandObjectSP (new CommandObjectTargetImageSearchPathsInsert ())); - LoadSubCommand (interpreter, "list", CommandObjectSP (new CommandObjectTargetImageSearchPathsList ())); - LoadSubCommand (interpreter, "query", CommandObjectSP (new CommandObjectTargetImageSearchPathsQuery ())); + LoadSubCommand ("add", CommandObjectSP (new CommandObjectTargetImageSearchPathsAdd (interpreter))); + LoadSubCommand ("clear", CommandObjectSP (new CommandObjectTargetImageSearchPathsClear (interpreter))); + LoadSubCommand ("insert", CommandObjectSP (new CommandObjectTargetImageSearchPathsInsert (interpreter))); + LoadSubCommand ("list", CommandObjectSP (new CommandObjectTargetImageSearchPathsList (interpreter))); + LoadSubCommand ("query", CommandObjectSP (new CommandObjectTargetImageSearchPathsQuery (interpreter))); } ~CommandObjectMultiwordImageSearchPaths() @@ -412,11 +414,12 @@ //------------------------------------------------------------------------- CommandObjectMultiwordTarget::CommandObjectMultiwordTarget (CommandInterpreter &interpreter) : - CommandObjectMultiword ("target", + CommandObjectMultiword (interpreter, + "target", "A set of commands for operating on debugger targets.", "target []") { - LoadSubCommand (interpreter, "image-search-paths", CommandObjectSP (new CommandObjectMultiwordImageSearchPaths (interpreter))); + LoadSubCommand ("image-search-paths", CommandObjectSP (new CommandObjectMultiwordImageSearchPaths (interpreter))); } CommandObjectMultiwordTarget::~CommandObjectMultiwordTarget () Modified: lldb/trunk/source/Commands/CommandObjectThread.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectThread.cpp?rev=114252&r1=114251&r2=114252&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectThread.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectThread.cpp Fri Sep 17 20:14:36 2010 @@ -330,8 +330,9 @@ uint32_t m_start; }; - CommandObjectThreadBacktrace () : - CommandObject ("thread backtrace", + CommandObjectThreadBacktrace (CommandInterpreter &interpreter) : + CommandObject (interpreter, + "thread backtrace", "Show the stack for one or more threads. If no threads are specified, show the currently selected thread. Use the thread-index \"all\" to see all threads.", "thread backtrace [] ...", eFlagProcessMustBeLaunched | eFlagProcessMustBePaused), @@ -350,12 +351,7 @@ } virtual bool - Execute - ( - CommandInterpreter &interpreter, - Args& command, - CommandReturnObject &result - ) + Execute (Args& command, CommandReturnObject &result) { bool show_frame_info = true; @@ -365,11 +361,11 @@ if (command.GetArgumentCount() == 0) { - ExecutionContext exe_ctx(interpreter.GetDebugger().GetExecutionContext()); + ExecutionContext exe_ctx(m_interpreter.GetDebugger().GetExecutionContext()); if (exe_ctx.thread) { if (DisplayFramesForExecutionContext (exe_ctx.thread, - interpreter, + m_interpreter, result.GetOutputStream(), m_options.m_start, m_options.m_count, @@ -389,13 +385,13 @@ } else if (command.GetArgumentCount() == 1 && ::strcmp (command.GetArgumentAtIndex(0), "all") == 0) { - Process *process = interpreter.GetDebugger().GetExecutionContext().process; + Process *process = m_interpreter.GetDebugger().GetExecutionContext().process; uint32_t num_threads = process->GetThreadList().GetSize(); for (uint32_t i = 0; i < num_threads; i++) { ThreadSP thread_sp = process->GetThreadList().GetThreadAtIndex(i); if (!DisplayFramesForExecutionContext (thread_sp.get(), - interpreter, + m_interpreter, result.GetOutputStream(), m_options.m_start, m_options.m_count, @@ -415,7 +411,7 @@ else { uint32_t num_args = command.GetArgumentCount(); - Process *process = interpreter.GetDebugger().GetExecutionContext().process; + Process *process = m_interpreter.GetDebugger().GetExecutionContext().process; std::vector thread_sps; for (uint32_t i = 0; i < num_args; i++) @@ -444,7 +440,7 @@ for (uint32_t i = 0; i < num_args; i++) { if (!DisplayFramesForExecutionContext (thread_sps[i].get(), - interpreter, + m_interpreter, result.GetOutputStream(), m_options.m_start, m_options.m_count, @@ -566,13 +562,14 @@ std::string m_avoid_regexp; }; - CommandObjectThreadStepWithTypeAndScope (const char *name, - const char *help, - const char *syntax, - uint32_t flags, - StepType step_type, - StepScope step_scope) : - CommandObject (name, help, syntax, flags), + CommandObjectThreadStepWithTypeAndScope (CommandInterpreter &interpreter, + const char *name, + const char *help, + const char *syntax, + uint32_t flags, + StepType step_type, + StepScope step_scope) : + CommandObject (interpreter, name, help, syntax, flags), m_step_type (step_type), m_step_scope (step_scope), m_options () @@ -594,13 +591,12 @@ virtual bool Execute ( - CommandInterpreter &interpreter, Args& command, CommandReturnObject &result ) { - Process *process = interpreter.GetDebugger().GetExecutionContext().process; - bool synchronous_execution = interpreter.GetSynchronous(); + Process *process = m_interpreter.GetDebugger().GetExecutionContext().process; + bool synchronous_execution = m_interpreter.GetSynchronous(); if (process == NULL) { @@ -791,8 +787,9 @@ { public: - CommandObjectThreadContinue () : - CommandObject ("thread continue", + CommandObjectThreadContinue (CommandInterpreter &interpreter) : + CommandObject (interpreter, + "thread continue", "Continue execution of one or more threads in an active process.", "thread continue [ ...]", eFlagProcessMustBeLaunched | eFlagProcessMustBePaused) @@ -808,21 +805,20 @@ virtual bool Execute ( - CommandInterpreter &interpreter, Args& command, CommandReturnObject &result ) { - bool synchronous_execution = interpreter.GetSynchronous (); + bool synchronous_execution = m_interpreter.GetSynchronous (); - if (!interpreter.GetDebugger().GetSelectedTarget().get()) + if (!m_interpreter.GetDebugger().GetSelectedTarget().get()) { result.AppendError ("invalid target, set executable file using 'file' command"); result.SetStatus (eReturnStatusFailed); return false; } - Process *process = interpreter.GetDebugger().GetExecutionContext().process; + Process *process = m_interpreter.GetDebugger().GetExecutionContext().process; if (process == NULL) { result.AppendError ("no process exists. Cannot continue"); @@ -1035,8 +1031,9 @@ // Instance variables to hold the values for command options. }; - CommandObjectThreadUntil () : - CommandObject ("thread until", + CommandObjectThreadUntil (CommandInterpreter &interpreter) : + CommandObject (interpreter, + "thread until", "Run the current or specified thread until it reaches a given line number or leaves the current function.", "thread until [] ", eFlagProcessMustBeLaunched | eFlagProcessMustBePaused), @@ -1060,14 +1057,13 @@ virtual bool Execute ( - CommandInterpreter &interpreter, Args& command, CommandReturnObject &result ) { - bool synchronous_execution = interpreter.GetSynchronous (); + bool synchronous_execution = m_interpreter.GetSynchronous (); - Target *target = interpreter.GetDebugger().GetSelectedTarget().get(); + Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get(); if (target == NULL) { result.AppendError ("invalid target, set executable file using 'file' command"); @@ -1075,7 +1071,7 @@ return false; } - Process *process = interpreter.GetDebugger().GetExecutionContext().process; + Process *process = m_interpreter.GetDebugger().GetExecutionContext().process; if (process == NULL) { result.AppendError ("need a valid process to step"); @@ -1234,11 +1230,12 @@ { public: - CommandObjectThreadSelect () : - CommandObject ("thread select", - "Select a thread as the currently active thread.", - "thread select ", - eFlagProcessMustBeLaunched | eFlagProcessMustBePaused) + CommandObjectThreadSelect (CommandInterpreter &interpreter) : + CommandObject (interpreter, + "thread select", + "Select a thread as the currently active thread.", + "thread select ", + eFlagProcessMustBeLaunched | eFlagProcessMustBePaused) { } @@ -1251,12 +1248,11 @@ virtual bool Execute ( - CommandInterpreter &interpreter, Args& command, CommandReturnObject &result ) { - Process *process = interpreter.GetDebugger().GetExecutionContext().process; + Process *process = m_interpreter.GetDebugger().GetExecutionContext().process; if (process == NULL) { result.AppendError ("no process"); @@ -1283,7 +1279,7 @@ process->GetThreadList().SetSelectedThreadByID(new_thread->GetID()); result.SetStatus (eReturnStatusSuccessFinishNoResult); - DisplayThreadInfo (interpreter, + DisplayThreadInfo (m_interpreter, result.GetOutputStream(), new_thread, false, @@ -1304,8 +1300,9 @@ public: - CommandObjectThreadList (): - CommandObject ("thread list", + CommandObjectThreadList (CommandInterpreter &interpreter): + CommandObject (interpreter, + "thread list", "Show a summary of all current threads in a process.", "thread list", eFlagProcessMustBeLaunched | eFlagProcessMustBePaused) @@ -1319,14 +1316,13 @@ bool Execute ( - CommandInterpreter &interpreter, Args& command, CommandReturnObject &result ) { StreamString &strm = result.GetOutputStream(); result.SetStatus (eReturnStatusSuccessFinishNoResult); - ExecutionContext exe_ctx(interpreter.GetDebugger().GetExecutionContext()); + ExecutionContext exe_ctx(m_interpreter.GetDebugger().GetExecutionContext()); if (exe_ctx.process) { const StateType state = exe_ctx.process->GetState(); @@ -1350,7 +1346,7 @@ exe_ctx.thread = exe_ctx.process->GetThreadList().GetThreadAtIndex(0).get(); if (exe_ctx.thread != NULL) { - DisplayThreadsInfo (interpreter, &exe_ctx, result, false, false); + DisplayThreadsInfo (m_interpreter, &exe_ctx, result, false, false); } else { @@ -1379,50 +1375,60 @@ //------------------------------------------------------------------------- CommandObjectMultiwordThread::CommandObjectMultiwordThread (CommandInterpreter &interpreter) : - CommandObjectMultiword ("thread", + CommandObjectMultiword (interpreter, + "thread", "A set of commands for operating on one or more threads within a running process.", "thread []") { - LoadSubCommand (interpreter, "backtrace", CommandObjectSP (new CommandObjectThreadBacktrace ())); - LoadSubCommand (interpreter, "continue", CommandObjectSP (new CommandObjectThreadContinue ())); - LoadSubCommand (interpreter, "list", CommandObjectSP (new CommandObjectThreadList ())); - LoadSubCommand (interpreter, "select", CommandObjectSP (new CommandObjectThreadSelect ())); - LoadSubCommand (interpreter, "until", CommandObjectSP (new CommandObjectThreadUntil ())); - LoadSubCommand (interpreter, "step-in", CommandObjectSP (new CommandObjectThreadStepWithTypeAndScope ( + LoadSubCommand ("backtrace", CommandObjectSP (new CommandObjectThreadBacktrace (interpreter))); + LoadSubCommand ("continue", CommandObjectSP (new CommandObjectThreadContinue (interpreter))); + LoadSubCommand ("list", CommandObjectSP (new CommandObjectThreadList (interpreter))); + LoadSubCommand ("select", CommandObjectSP (new CommandObjectThreadSelect (interpreter))); + LoadSubCommand ("until", CommandObjectSP (new CommandObjectThreadUntil (interpreter))); + LoadSubCommand ("step-in", CommandObjectSP (new CommandObjectThreadStepWithTypeAndScope ( + interpreter, "thread step-in", - "Source level single step in specified thread (current thread, if none specified).", - "thread step-in []", - eFlagProcessMustBeLaunched | eFlagProcessMustBePaused, - eStepTypeInto, - eStepScopeSource))); + "Source level single step in specified thread (current thread, if none specified).", + "thread step-in []", + eFlagProcessMustBeLaunched | eFlagProcessMustBePaused, + eStepTypeInto, + eStepScopeSource))); - LoadSubCommand (interpreter, "step-out", CommandObjectSP (new CommandObjectThreadStepWithTypeAndScope ("thread step-out", - "Finish executing the current fucntion and return to its call site in specified thread (current thread, if none specified).", - "thread step-out []", - eFlagProcessMustBeLaunched | eFlagProcessMustBePaused, - eStepTypeOut, - eStepScopeSource))); - - LoadSubCommand (interpreter, "step-over", CommandObjectSP (new CommandObjectThreadStepWithTypeAndScope ("thread step-over", - "Source level single step in specified thread (current thread, if none specified), stepping over calls.", - "thread step-over []", - eFlagProcessMustBeLaunched | eFlagProcessMustBePaused, - eStepTypeOver, - eStepScopeSource))); - - LoadSubCommand (interpreter, "step-inst", CommandObjectSP (new CommandObjectThreadStepWithTypeAndScope ("thread step-inst", - "Single step one instruction in specified thread (current thread, if none specified).", - "thread step-inst []", - eFlagProcessMustBeLaunched | eFlagProcessMustBePaused, - eStepTypeTrace, - eStepScopeInstruction))); - - LoadSubCommand (interpreter, "step-inst-over", CommandObjectSP (new CommandObjectThreadStepWithTypeAndScope ("thread step-inst-over", - "Single step one instruction in specified thread (current thread, if none specified), stepping over calls.", - "thread step-inst-over []", - eFlagProcessMustBeLaunched | eFlagProcessMustBePaused, - eStepTypeTraceOver, - eStepScopeInstruction))); + LoadSubCommand ("step-out", CommandObjectSP (new CommandObjectThreadStepWithTypeAndScope ( + interpreter, + "thread step-out", + "Finish executing the current fucntion and return to its call site in specified thread (current thread, if none specified).", + "thread step-out []", + eFlagProcessMustBeLaunched | eFlagProcessMustBePaused, + eStepTypeOut, + eStepScopeSource))); + + LoadSubCommand ("step-over", CommandObjectSP (new CommandObjectThreadStepWithTypeAndScope ( + interpreter, + "thread step-over", + "Source level single step in specified thread (current thread, if none specified), stepping over calls.", + "thread step-over []", + eFlagProcessMustBeLaunched | eFlagProcessMustBePaused, + eStepTypeOver, + eStepScopeSource))); + + LoadSubCommand ("step-inst", CommandObjectSP (new CommandObjectThreadStepWithTypeAndScope ( + interpreter, + "thread step-inst", + "Single step one instruction in specified thread (current thread, if none specified).", + "thread step-inst []", + eFlagProcessMustBeLaunched | eFlagProcessMustBePaused, + eStepTypeTrace, + eStepScopeInstruction))); + + LoadSubCommand ("step-inst-over", CommandObjectSP (new CommandObjectThreadStepWithTypeAndScope ( + interpreter, + "thread step-inst-over", + "Single step one instruction in specified thread (current thread, if none specified), stepping over calls.", + "thread step-inst-over []", + eFlagProcessMustBeLaunched | eFlagProcessMustBePaused, + eStepTypeTraceOver, + eStepScopeInstruction))); } CommandObjectMultiwordThread::~CommandObjectMultiwordThread () Modified: lldb/trunk/source/Core/Debugger.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/Debugger.cpp?rev=114252&r1=114251&r2=114252&view=diff ============================================================================== --- lldb/trunk/source/Core/Debugger.cpp (original) +++ lldb/trunk/source/Core/Debugger.cpp Fri Sep 17 20:14:36 2010 @@ -595,38 +595,27 @@ bool Debugger::DebuggerInstanceSettings::ValidTermWidthValue (const char *value, Error err) { - bool valid = true; + bool valid = false; // Verify we have a value string. - if (value == NULL - || strlen (value) == 0) + if (value == NULL || value[0] == '\0') { - valid = false; - err.SetErrorString ("Missing value. Can't set terminal width without a value.\n"); + err.SetErrorString ("Missing value. Can't set terminal width without a value.\n"); } - - // Verify the string consists entirely of digits. - if (valid) + else { - int len = strlen (value); - for (int i = 0; i < len; ++i) - if (! isdigit (value[i])) - { - valid = false; - err.SetErrorStringWithFormat ("'%s' is not a valid representation of an unsigned integer.\n", value); - } - } - - // Verify the term-width is 'reasonable' (e.g. 10 <= width <= 250). - if (valid) - { - int width = atoi (value); - if (width < 10 - || width > 250) + char *end = NULL; + const uint32_t width = ::strtoul (value, &end, 0); + + if (end && end == '\0') { - valid = false; - err.SetErrorString ("Invalid term-width value; value must be between 10 and 250.\n"); + if (width >= 10 || width <= 1024) + valid = true; + else + err.SetErrorString ("Invalid term-width value; value must be between 10 and 1024.\n"); } + else + err.SetErrorStringWithFormat ("'%s' is not a valid unsigned integer string.\n", value); } return valid; @@ -637,9 +626,14 @@ // class DebuggerInstanceSettings //-------------------------------------------------- -DebuggerInstanceSettings::DebuggerInstanceSettings (UserSettingsController &owner, bool live_instance, - const char *name) : +DebuggerInstanceSettings::DebuggerInstanceSettings +( + UserSettingsController &owner, + bool live_instance, + const char *name +) : InstanceSettings (owner, (name == NULL ? InstanceSettings::InvalidName().AsCString() : name), live_instance), + m_term_width (80), m_prompt (), m_script_lang () { @@ -725,7 +719,7 @@ { if (ValidTermWidthValue (value, err)) { - m_term_width = atoi (value); + m_term_width = ::strtoul (value, NULL, 0); } } } Modified: lldb/trunk/source/Interpreter/CommandInterpreter.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Interpreter/CommandInterpreter.cpp?rev=114252&r1=114251&r2=114252&view=diff ============================================================================== --- lldb/trunk/source/Interpreter/CommandInterpreter.cpp (original) +++ lldb/trunk/source/Interpreter/CommandInterpreter.cpp Fri Sep 17 20:14:36 2010 @@ -149,29 +149,30 @@ bool success; script_language = Args::StringToScriptLanguage (value.GetStringAtIndex(0), lldb::eScriptLanguageDefault, &success); - m_command_dict["apropos"] = CommandObjectSP (new CommandObjectApropos ()); + m_command_dict["apropos"] = CommandObjectSP (new CommandObjectApropos (*this)); m_command_dict["breakpoint"]= CommandObjectSP (new CommandObjectMultiwordBreakpoint (*this)); - //m_command_dict["call"] = CommandObjectSP (new CommandObjectCall ()); + //m_command_dict["call"] = CommandObjectSP (new CommandObjectCall (*this)); m_command_dict["commands"] = CommandObjectSP (new CommandObjectMultiwordCommands (*this)); - m_command_dict["disassemble"] = CommandObjectSP (new CommandObjectDisassemble ()); - m_command_dict["expression"]= CommandObjectSP (new CommandObjectExpression ()); - m_command_dict["file"] = CommandObjectSP (new CommandObjectFile ()); + m_command_dict["disassemble"] = CommandObjectSP (new CommandObjectDisassemble (*this)); + m_command_dict["expression"]= CommandObjectSP (new CommandObjectExpression (*this)); + m_command_dict["file"] = CommandObjectSP (new CommandObjectFile (*this)); m_command_dict["frame"] = CommandObjectSP (new CommandObjectMultiwordFrame (*this)); - m_command_dict["help"] = CommandObjectSP (new CommandObjectHelp ()); + m_command_dict["help"] = CommandObjectSP (new CommandObjectHelp (*this)); m_command_dict["image"] = CommandObjectSP (new CommandObjectImage (*this)); m_command_dict["log"] = CommandObjectSP (new CommandObjectLog (*this)); m_command_dict["memory"] = CommandObjectSP (new CommandObjectMemory (*this)); m_command_dict["process"] = CommandObjectSP (new CommandObjectMultiwordProcess (*this)); - m_command_dict["quit"] = CommandObjectSP (new CommandObjectQuit ()); + m_command_dict["quit"] = CommandObjectSP (new CommandObjectQuit (*this)); m_command_dict["register"] = CommandObjectSP (new CommandObjectRegister (*this)); - m_command_dict["script"] = CommandObjectSP (new CommandObjectScript (script_language)); + m_command_dict["script"] = CommandObjectSP (new CommandObjectScript (*this, script_language)); m_command_dict["settings"] = CommandObjectSP (new CommandObjectMultiwordSettings (*this)); m_command_dict["source"] = CommandObjectSP (new CommandObjectMultiwordSource (*this)); m_command_dict["target"] = CommandObjectSP (new CommandObjectMultiwordTarget (*this)); m_command_dict["thread"] = CommandObjectSP (new CommandObjectMultiwordThread (*this)); std::auto_ptr - break_regex_cmd_ap(new CommandObjectRegexCommand ("regexp-break", + break_regex_cmd_ap(new CommandObjectRegexCommand (*this, + "regexp-break", "Set a breakpoint using a regular expression to specify the location.", "regexp-break [:]\nregexp-break [
]\nregexp-break <...>", 2)); if (break_regex_cmd_ap.get()) @@ -574,14 +575,14 @@ stripped_command += strlen(command_cstr); while (isspace(*stripped_command)) ++stripped_command; - command_obj->ExecuteRawCommandString (*this, stripped_command, result); + command_obj->ExecuteRawCommandString (stripped_command, result); } } else { // Remove the command from the args. command_args.Shift(); - command_obj->ExecuteWithOptions (*this, command_args, result); + command_obj->ExecuteWithOptions (command_args, result); } } else @@ -681,8 +682,7 @@ { parsed_line.Shift(); cursor_index--; - num_command_matches = command_object->HandleCompletion (*this, - parsed_line, + num_command_matches = command_object->HandleCompletion (parsed_line, cursor_index, cursor_char_position, match_start_point, @@ -1010,7 +1010,7 @@ if (pos != m_command_dict.end()) { CommandObject *script_cmd_obj = pos->second.get(); - return ((CommandObjectScript *) script_cmd_obj)->GetInterpreter (*this); + return ((CommandObjectScript *) script_cmd_obj)->GetInterpreter (); } return NULL; } @@ -1041,15 +1041,8 @@ const char *help_text, uint32_t max_word_len) { - lldb::SettableVariableType var_type; - const char *width_value = - Debugger::GetSettingsController()->GetVariable ("term-width", var_type, - m_debugger.GetInstanceName().AsCString()).GetStringAtIndex(0); - int max_columns = atoi (width_value); - // Sanity check max_columns, to cope with emacs shell mode with TERM=dumb - // (0 rows; 0 columns;). - if (max_columns <= 0) max_columns = 80; - + const uint32_t max_columns = m_debugger.GetTerminalWidth(); + int indent_size = max_word_len + strlen (separator) + 2; strm.IndentMore (indent_size); @@ -1135,7 +1128,7 @@ complete_command_name.Printf ("%s %s", prefix, command_name); - if (sub_cmd_obj->HelpTextContainsWord (search_word, *this)) + if (sub_cmd_obj->HelpTextContainsWord (search_word)) { commands_found.AppendString (complete_command_name.GetData()); commands_help.AppendString (sub_cmd_obj->GetHelp()); @@ -1159,7 +1152,7 @@ const char *command_name = pos->first.c_str(); CommandObject *cmd_obj = pos->second.get(); - if (cmd_obj->HelpTextContainsWord (search_word, *this)) + if (cmd_obj->HelpTextContainsWord (search_word)) { commands_found.AppendString (command_name); commands_help.AppendString (cmd_obj->GetHelp()); Modified: lldb/trunk/source/Interpreter/CommandObject.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Interpreter/CommandObject.cpp?rev=114252&r1=114251&r2=114252&view=diff ============================================================================== --- lldb/trunk/source/Interpreter/CommandObject.cpp (original) +++ lldb/trunk/source/Interpreter/CommandObject.cpp Fri Sep 17 20:14:36 2010 @@ -38,7 +38,15 @@ // CommandObject //------------------------------------------------------------------------- -CommandObject::CommandObject (const char *name, const char *help, const char *syntax, uint32_t flags) : +CommandObject::CommandObject +( + CommandInterpreter &interpreter, + const char *name, + const char *help, + const char *syntax, + uint32_t flags +) : + m_interpreter (interpreter), m_cmd_name (name), m_cmd_help_short (), m_cmd_help_long (), @@ -134,19 +142,17 @@ bool CommandObject::ExecuteCommandString ( - CommandInterpreter &interpreter, const char *command_line, CommandReturnObject &result ) { Args command_args(command_line); - return ExecuteWithOptions (interpreter, command_args, result); + return ExecuteWithOptions (command_args, result); } bool CommandObject::ParseOptions ( - CommandInterpreter &interpreter, Args& args, CommandReturnObject &result ) @@ -177,8 +183,7 @@ else { // No error string, output the usage information into result - options->GenerateOptionUsage (result.GetErrorStream(), this, - interpreter.GetDebugger().GetInstanceName().AsCString()); + options->GenerateOptionUsage (m_interpreter, result.GetErrorStream(), this); } // Set the return status to failed (this was an error). result.SetStatus (eReturnStatusFailed); @@ -188,21 +193,16 @@ return true; } bool -CommandObject::ExecuteWithOptions -( - CommandInterpreter &interpreter, - Args& args, - CommandReturnObject &result -) +CommandObject::ExecuteWithOptions (Args& args, CommandReturnObject &result) { for (size_t i = 0; i < args.GetArgumentCount(); ++i) { const char *tmp_str = args.GetArgumentAtIndex (i); if (tmp_str[0] == '`') // back-quote - args.ReplaceArgumentAtIndex (i, interpreter.ProcessEmbeddedScriptCommands (tmp_str)); + args.ReplaceArgumentAtIndex (i, m_interpreter.ProcessEmbeddedScriptCommands (tmp_str)); } - Process *process = interpreter.GetDebugger().GetExecutionContext().process; + Process *process = m_interpreter.GetDebugger().GetExecutionContext().process; if (process == NULL) { if (GetFlags().IsSet(CommandObject::eFlagProcessMustBeLaunched | CommandObject::eFlagProcessMustBePaused)) @@ -248,11 +248,11 @@ } } - if (!ParseOptions (interpreter, args, result)) + if (!ParseOptions (args, result)) return false; // Call the command-specific version of 'Execute', passing it the already processed arguments. - return Execute (interpreter, args, result); + return Execute (args, result); } class CommandDictCommandPartialMatch @@ -300,7 +300,6 @@ int CommandObject::HandleCompletion ( - CommandInterpreter &interpreter, Args &input, int &cursor_index, int &cursor_char_position, @@ -341,7 +340,7 @@ input.DeleteArgumentAtIndex(input.GetArgumentCount() - 1); bool handled_by_options; - handled_by_options = cur_options->HandleOptionCompletion (interpreter, + handled_by_options = cur_options->HandleOptionCompletion (m_interpreter, input, opt_element_vector, cursor_index, @@ -355,8 +354,7 @@ } // If we got here, the last word is not an option or an option argument. - return HandleArgumentCompletion (interpreter, - input, + return HandleArgumentCompletion (input, cursor_index, cursor_char_position, opt_element_vector, @@ -397,7 +395,7 @@ } bool -CommandObject::HelpTextContainsWord (const char *search_word, CommandInterpreter &interpreter) +CommandObject::HelpTextContainsWord (const char *search_word) { const char *short_help; const char *long_help; @@ -422,7 +420,7 @@ && GetOptions() != NULL) { StreamString usage_help; - GetOptions()->GenerateOptionUsage (usage_help, this, interpreter.GetDebugger().GetInstanceName().AsCString()); + GetOptions()->GenerateOptionUsage (m_interpreter, usage_help, this); if (usage_help.GetSize() > 0) { const char *usage_text = usage_help.GetData(); Modified: lldb/trunk/source/Interpreter/CommandObjectRegexCommand.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Interpreter/CommandObjectRegexCommand.cpp?rev=114252&r1=114251&r2=114252&view=diff ============================================================================== --- lldb/trunk/source/Interpreter/CommandObjectRegexCommand.cpp (original) +++ lldb/trunk/source/Interpreter/CommandObjectRegexCommand.cpp Fri Sep 17 20:14:36 2010 @@ -24,12 +24,13 @@ //---------------------------------------------------------------------- CommandObjectRegexCommand::CommandObjectRegexCommand ( + CommandInterpreter &interpreter, const char *name, const char *help, const char *syntax, uint32_t max_matches ) : - CommandObject (name, help, syntax), + CommandObject (interpreter, name, help, syntax), m_max_matches (max_matches), m_entries () { @@ -46,7 +47,6 @@ bool CommandObjectRegexCommand::Execute ( - CommandInterpreter &interpreter, Args& command, CommandReturnObject &result ) @@ -58,7 +58,6 @@ bool CommandObjectRegexCommand::ExecuteRawCommandString ( - CommandInterpreter &interpreter, const char *command, CommandReturnObject &result ) @@ -90,7 +89,7 @@ // Interpret the new command and return this as the result! // if (m_options.verbose) // result.GetOutputStream().Printf("%s\n", new_command.c_str()); - return interpreter.HandleCommand(new_command.c_str(), true, result); + return m_interpreter.HandleCommand(new_command.c_str(), true, result); } } result.SetStatus(eReturnStatusFailed); Modified: lldb/trunk/source/Interpreter/CommandObjectScript.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Interpreter/CommandObjectScript.cpp?rev=114252&r1=114251&r2=114252&view=diff ============================================================================== --- lldb/trunk/source/Interpreter/CommandObjectScript.cpp (original) +++ lldb/trunk/source/Interpreter/CommandObjectScript.cpp Fri Sep 17 20:14:36 2010 @@ -27,8 +27,9 @@ // CommandObjectScript //------------------------------------------------------------------------- -CommandObjectScript::CommandObjectScript (ScriptLanguage script_lang) : - CommandObject ("script", +CommandObjectScript::CommandObjectScript (CommandInterpreter &interpreter, ScriptLanguage script_lang) : + CommandObject (interpreter, + "script", "Pass an expression to the script interpreter for evaluation and return the results. Drop into the interactive interpreter if no expression is given.", "script []"), m_script_lang (script_lang), @@ -43,12 +44,11 @@ bool CommandObjectScript::ExecuteRawCommandString ( - CommandInterpreter &interpreter, const char *command, CommandReturnObject &result ) { - ScriptInterpreter *script_interpreter = GetInterpreter (interpreter); + ScriptInterpreter *script_interpreter = GetInterpreter (); if (script_interpreter == NULL) { @@ -57,13 +57,13 @@ } if (command == NULL || command[0] == '\0') { - script_interpreter->ExecuteInterpreterLoop (interpreter); + script_interpreter->ExecuteInterpreterLoop (); result.SetStatus (eReturnStatusSuccessFinishNoResult); return result.Succeeded(); } // We can do better when reporting the status of one-liner script execution. - if (script_interpreter->ExecuteOneLine (interpreter, command, &result)) + if (script_interpreter->ExecuteOneLine (command, &result)) result.SetStatus(eReturnStatusSuccessFinishNoResult); else result.SetStatus(eReturnStatusFailed); @@ -80,7 +80,6 @@ bool CommandObjectScript::Execute ( - CommandInterpreter &interpreter, Args& command, CommandReturnObject &result ) @@ -91,18 +90,18 @@ ScriptInterpreter * -CommandObjectScript::GetInterpreter (CommandInterpreter &interpreter) +CommandObjectScript::GetInterpreter () { if (m_interpreter_ap.get() == NULL) { switch (m_script_lang) { case eScriptLanguagePython: - m_interpreter_ap.reset (new ScriptInterpreterPython (interpreter)); + m_interpreter_ap.reset (new ScriptInterpreterPython (m_interpreter)); break; case eScriptLanguageNone: - m_interpreter_ap.reset (new ScriptInterpreterNone (interpreter)); + m_interpreter_ap.reset (new ScriptInterpreterNone (m_interpreter)); break; } } Modified: lldb/trunk/source/Interpreter/CommandObjectScript.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Interpreter/CommandObjectScript.h?rev=114252&r1=114251&r2=114252&view=diff ============================================================================== --- lldb/trunk/source/Interpreter/CommandObjectScript.h (original) +++ lldb/trunk/source/Interpreter/CommandObjectScript.h Fri Sep 17 20:14:36 2010 @@ -26,7 +26,8 @@ { public: - CommandObjectScript (lldb::ScriptLanguage script_lang); + CommandObjectScript (CommandInterpreter &interpreter, + lldb::ScriptLanguage script_lang); virtual ~CommandObjectScript (); @@ -34,17 +35,15 @@ bool WantsRawCommandString(); virtual bool - ExecuteRawCommandString (CommandInterpreter &interpreter, - const char *command, + ExecuteRawCommandString (const char *command, CommandReturnObject &result); virtual bool - Execute (CommandInterpreter &interpreter, - Args& command, + Execute (Args& command, CommandReturnObject &result); ScriptInterpreter * - GetInterpreter (CommandInterpreter &interpreter); + GetInterpreter (); private: lldb::ScriptLanguage m_script_lang; Modified: lldb/trunk/source/Interpreter/Options.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Interpreter/Options.cpp?rev=114252&r1=114251&r2=114252&view=diff ============================================================================== --- lldb/trunk/source/Interpreter/Options.cpp (original) +++ lldb/trunk/source/Interpreter/Options.cpp Fri Sep 17 20:14:36 2010 @@ -361,27 +361,21 @@ void Options::GenerateOptionUsage ( + CommandInterpreter &interpreter, Stream &strm, - CommandObject *cmd, - const char *debugger_instance_name, - const char *program_name) + CommandObject *cmd +) { - lldb::SettableVariableType var_type; - const char *screen_width_str = - Debugger::GetSettingsController()->GetVariable ("term-width", var_type, - debugger_instance_name).GetStringAtIndex(0); - uint32_t screen_width = atoi (screen_width_str); - if (screen_width == 0) - screen_width = 80; + const uint32_t screen_width = interpreter.GetDebugger().GetTerminalWidth(); const lldb::OptionDefinition *full_options_table = GetDefinitions(); const uint32_t save_indent_level = strm.GetIndentLevel(); const char *name; if (cmd) - name = cmd->GetCommandName(); + name = cmd->GetCommandName(); else - name = program_name; + name = ""; strm.PutCString ("\nCommand Options Usage:\n"); Modified: lldb/trunk/source/Interpreter/ScriptInterpreter.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Interpreter/ScriptInterpreter.cpp?rev=114252&r1=114251&r2=114252&view=diff ============================================================================== --- lldb/trunk/source/Interpreter/ScriptInterpreter.cpp (original) +++ lldb/trunk/source/Interpreter/ScriptInterpreter.cpp Fri Sep 17 20:14:36 2010 @@ -22,7 +22,8 @@ using namespace lldb; using namespace lldb_private; -ScriptInterpreter::ScriptInterpreter (ScriptLanguage script_lang) : +ScriptInterpreter::ScriptInterpreter (CommandInterpreter &interpreter, ScriptLanguage script_lang) : + m_interpreter (interpreter), m_script_lang (script_lang), m_interpreter_pty () { @@ -54,7 +55,6 @@ void ScriptInterpreter::CollectDataForBreakpointCommandCallback ( - CommandInterpreter &interpreter, BreakpointOptions *bp_options, CommandReturnObject &result ) Modified: lldb/trunk/source/Interpreter/ScriptInterpreterNone.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Interpreter/ScriptInterpreterNone.cpp?rev=114252&r1=114251&r2=114252&view=diff ============================================================================== --- lldb/trunk/source/Interpreter/ScriptInterpreterNone.cpp (original) +++ lldb/trunk/source/Interpreter/ScriptInterpreterNone.cpp Fri Sep 17 20:14:36 2010 @@ -17,7 +17,7 @@ using namespace lldb_private; ScriptInterpreterNone::ScriptInterpreterNone (CommandInterpreter &interpreter) : - ScriptInterpreter (eScriptLanguageNone) + ScriptInterpreter (interpreter, eScriptLanguageNone) { } @@ -26,16 +26,16 @@ } bool -ScriptInterpreterNone::ExecuteOneLine (CommandInterpreter &interpreter, const char *command, CommandReturnObject *) +ScriptInterpreterNone::ExecuteOneLine (const char *command, CommandReturnObject *) { - interpreter.GetDebugger().GetErrorStream().PutCString ("error: there is no embedded script interpreter in this mode.\n"); + m_interpreter.GetDebugger().GetErrorStream().PutCString ("error: there is no embedded script interpreter in this mode.\n"); return false; } void -ScriptInterpreterNone::ExecuteInterpreterLoop (CommandInterpreter &interpreter) +ScriptInterpreterNone::ExecuteInterpreterLoop () { - interpreter.GetDebugger().GetErrorStream().PutCString ("error: there is no embedded script interpreter in this mode.\n"); + m_interpreter.GetDebugger().GetErrorStream().PutCString ("error: there is no embedded script interpreter in this mode.\n"); } Modified: lldb/trunk/source/Interpreter/ScriptInterpreterPython.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Interpreter/ScriptInterpreterPython.cpp?rev=114252&r1=114251&r2=114252&view=diff ============================================================================== --- lldb/trunk/source/Interpreter/ScriptInterpreterPython.cpp (original) +++ lldb/trunk/source/Interpreter/ScriptInterpreterPython.cpp Fri Sep 17 20:14:36 2010 @@ -144,7 +144,7 @@ } ScriptInterpreterPython::ScriptInterpreterPython (CommandInterpreter &interpreter) : - ScriptInterpreter (eScriptLanguagePython), + ScriptInterpreter (interpreter, eScriptLanguagePython), m_compiled_module (NULL), m_termios_valid (false) { @@ -254,9 +254,7 @@ } bool -ScriptInterpreterPython::ExecuteOneLine (CommandInterpreter &interpreter, - const char *command, - CommandReturnObject *result = 0) +ScriptInterpreterPython::ExecuteOneLine (const char *command, CommandReturnObject *result) { if (command) { @@ -357,11 +355,11 @@ void -ScriptInterpreterPython::ExecuteInterpreterLoop (CommandInterpreter &interpreter) +ScriptInterpreterPython::ExecuteInterpreterLoop () { Timer scoped_timer (__PRETTY_FUNCTION__, __PRETTY_FUNCTION__); - Debugger &debugger = interpreter.GetDebugger(); + Debugger &debugger = m_interpreter.GetDebugger(); // At the moment, the only time the debugger does not have an input file handle is when this is called // directly from Python, in which case it is both dangerous and unnecessary (not to mention confusing) to @@ -384,7 +382,7 @@ if (error.Success()) { debugger.PushInputReader (reader_sp); - ExecuteOneLine (interpreter, "run_python_interpreter(ConsoleDict)"); + ExecuteOneLine ("run_python_interpreter(ConsoleDict)", NULL); debugger.PopInputReader (reader_sp); } } @@ -643,11 +641,10 @@ } void -ScriptInterpreterPython::CollectDataForBreakpointCommandCallback (CommandInterpreter &interpreter, - BreakpointOptions *bp_options, +ScriptInterpreterPython::CollectDataForBreakpointCommandCallback (BreakpointOptions *bp_options, CommandReturnObject &result) { - Debugger &debugger = interpreter.GetDebugger(); + Debugger &debugger = m_interpreter.GetDebugger(); InputReaderSP reader_sp (new InputReader (debugger)); if (reader_sp) @@ -677,8 +674,7 @@ // Set a Python one-liner as the callback for the breakpoint. void -ScriptInterpreterPython::SetBreakpointCommandCallback (CommandInterpreter &interpreter, - BreakpointOptions *bp_options, +ScriptInterpreterPython::SetBreakpointCommandCallback (BreakpointOptions *bp_options, const char *oneliner) { std::auto_ptr data_ap(new BreakpointOptions::CommandData()); Modified: lldb/trunk/tools/driver/Driver.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/driver/Driver.cpp?rev=114252&r1=114251&r2=114252&view=diff ============================================================================== --- lldb/trunk/tools/driver/Driver.cpp (original) +++ lldb/trunk/tools/driver/Driver.cpp Fri Sep 17 20:14:36 2010 @@ -1105,13 +1105,8 @@ if (isatty (STDIN_FILENO) && ::ioctl (STDIN_FILENO, TIOCGWINSZ, &window_size) == 0) { - char buffer[256]; - if (window_size.ws_col > 0) - { - ::snprintf (buffer, sizeof(buffer), "settings set term-width %d", window_size.ws_col); - m_debugger.HandleCommand ((const char *) buffer); - } + m_debugger.SetTerminalWidth (window_size.ws_col); } // Since input can be redirected by the debugger, we must insert our editline From gclayton at apple.com Fri Sep 17 21:11:08 2010 From: gclayton at apple.com (Greg Clayton) Date: Sat, 18 Sep 2010 02:11:08 -0000 Subject: [Lldb-commits] [lldb] r114258 - /lldb/trunk/source/Symbol/ClangASTContext.cpp Message-ID: <20100918021108.1A4612A6C12C@llvm.org> Author: gclayton Date: Fri Sep 17 21:11:07 2010 New Revision: 114258 URL: http://llvm.org/viewvc/llvm-project?rev=114258&view=rev Log: Bug #: 8447030 Fixed an issue with ClangASTContext::GetIndexOfChildMemberWithName() where objective C ivars were not being found correctly if they were the second or higher child. Modified: lldb/trunk/source/Symbol/ClangASTContext.cpp Modified: lldb/trunk/source/Symbol/ClangASTContext.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/ClangASTContext.cpp?rev=114258&r1=114257&r2=114258&view=diff ============================================================================== --- lldb/trunk/source/Symbol/ClangASTContext.cpp (original) +++ lldb/trunk/source/Symbol/ClangASTContext.cpp Fri Sep 17 21:11:07 2010 @@ -2057,7 +2057,7 @@ ObjCInterfaceDecl::ivar_iterator ivar_pos, ivar_end = class_interface_decl->ivar_end(); ObjCInterfaceDecl *superclass_interface_decl = class_interface_decl->getSuperClass(); - for (ivar_pos = class_interface_decl->ivar_begin(); ivar_pos != ivar_end; ++ivar_pos) + for (ivar_pos = class_interface_decl->ivar_begin(); ivar_pos != ivar_end; ++ivar_pos, ++child_idx) { const ObjCIvarDecl* ivar_decl = *ivar_pos; From gclayton at apple.com Fri Sep 17 22:37:20 2010 From: gclayton at apple.com (Greg Clayton) Date: Sat, 18 Sep 2010 03:37:20 -0000 Subject: [Lldb-commits] [lldb] r114265 - in /lldb/trunk: include/lldb/Symbol/ include/lldb/Target/ source/Commands/ source/Core/ source/Interpreter/ source/Plugins/SymbolFile/DWARF/ Message-ID: <20100918033720.EA5692A6C12C@llvm.org> Author: gclayton Date: Fri Sep 17 22:37:20 2010 New Revision: 114265 URL: http://llvm.org/viewvc/llvm-project?rev=114265&view=rev Log: General command line help cleanup: - All single character options will now be printed together - Changed all options that contains underscores to contain '-' instead - Made the help come out a little flatter by showing the long and short option on the same line. - Modified the short character for "--ignore-count" options to "-i" Modified: lldb/trunk/include/lldb/Symbol/Block.h lldb/trunk/include/lldb/Symbol/ObjectFile.h lldb/trunk/include/lldb/Target/DynamicLoader.h lldb/trunk/include/lldb/Target/Process.h lldb/trunk/source/Commands/CommandObjectBreakpoint.cpp lldb/trunk/source/Commands/CommandObjectBreakpointCommand.cpp lldb/trunk/source/Commands/CommandObjectCall.cpp lldb/trunk/source/Commands/CommandObjectFrame.cpp lldb/trunk/source/Commands/CommandObjectProcess.cpp lldb/trunk/source/Commands/CommandObjectSettings.cpp lldb/trunk/source/Commands/CommandObjectSource.cpp lldb/trunk/source/Commands/CommandObjectThread.cpp lldb/trunk/source/Core/DataExtractor.cpp lldb/trunk/source/Core/DynamicLoader.cpp lldb/trunk/source/Core/ValueObject.cpp lldb/trunk/source/Interpreter/Options.cpp lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.cpp Modified: lldb/trunk/include/lldb/Symbol/Block.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Symbol/Block.h?rev=114265&r1=114264&r2=114265&view=diff ============================================================================== --- lldb/trunk/include/lldb/Symbol/Block.h (original) +++ lldb/trunk/include/lldb/Symbol/Block.h Fri Sep 17 22:37:20 2010 @@ -269,7 +269,7 @@ /// @param[in] add_inline_child_block_variables /// If this is \b false, no child variables of child blocks /// that are inlined functions will be gotten. If \b true then - /// all child variables will be added regardless of wether they + /// all child variables will be added regardless of whether they /// come from inlined functions or not. /// /// @return Modified: lldb/trunk/include/lldb/Symbol/ObjectFile.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Symbol/ObjectFile.h?rev=114265&r1=114264&r2=114265&view=diff ============================================================================== --- lldb/trunk/include/lldb/Symbol/ObjectFile.h (original) +++ lldb/trunk/include/lldb/Symbol/ObjectFile.h Fri Sep 17 22:37:20 2010 @@ -270,7 +270,7 @@ GetUUID (UUID* uuid) = 0; //------------------------------------------------------------------ - /// Gets wether endian swapping should occur when extracting data + /// Gets whether endian swapping should occur when extracting data /// from this object file. /// /// @return Modified: lldb/trunk/include/lldb/Target/DynamicLoader.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/DynamicLoader.h?rev=114265&r1=114264&r2=114265&view=diff ============================================================================== --- lldb/trunk/include/lldb/Target/DynamicLoader.h (original) +++ lldb/trunk/include/lldb/Target/DynamicLoader.h Fri Sep 17 22:37:20 2010 @@ -92,7 +92,7 @@ DidLaunch () = 0; //------------------------------------------------------------------ - /// Get wether the process should stop when images change. + /// Get whether the process should stop when images change. /// /// When images (executables and shared libraries) get loaded or /// unloaded, often debug sessions will want to try and resolve or @@ -108,7 +108,7 @@ GetStopWhenImagesChange () const; //------------------------------------------------------------------ - /// Set wether the process should stop when images change. + /// Set whether the process should stop when images change. /// /// When images (executables and shared libraries) get loaded or /// unloaded, often debug sessions will want to try and resolve or @@ -117,7 +117,7 @@ /// can be overridden using this function callback. /// /// @param[in] stop - /// Boolean value that indicates wether the process should stop + /// Boolean value that indicates whether the process should stop /// when images change. //------------------------------------------------------------------ void Modified: lldb/trunk/include/lldb/Target/Process.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/Process.h?rev=114265&r1=114264&r2=114265&view=diff ============================================================================== --- lldb/trunk/include/lldb/Target/Process.h (original) +++ lldb/trunk/include/lldb/Target/Process.h Fri Sep 17 22:37:20 2010 @@ -436,7 +436,7 @@ //------------------------------------------------------------------ /// Check if a plug-in instance can debug the file in \a module. /// - /// Each plug-in is given a chance to say wether it can debug + /// Each plug-in is given a chance to say whether it can debug /// the file in \a module. If the Process plug-in instance can /// debug a file on the current system, it should return \b true. /// Modified: lldb/trunk/source/Commands/CommandObjectBreakpoint.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectBreakpoint.cpp?rev=114265&r1=114264&r2=114265&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectBreakpoint.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectBreakpoint.cpp Fri Sep 17 22:37:20 2010 @@ -74,19 +74,19 @@ { LLDB_OPT_SET_ALL, false, "shlib", 's', required_argument, NULL, CommandCompletions::eModuleCompletion, "", "Set the breakpoint only in this shared library (can use this option multiple times for multiple shlibs)."}, - { LLDB_OPT_SET_ALL, false, "ignore_count", 'k', required_argument, NULL, 0, "", + { LLDB_OPT_SET_ALL, false, "ignore-count", 'i', required_argument, NULL, 0, "", "Set the number of times this breakpoint is sKipped before stopping." }, - { LLDB_OPT_SET_ALL, false, "thread_index", 'x', required_argument, NULL, NULL, "", - "The breakpoint stops only for the thread whose indeX matches this argument."}, + { LLDB_OPT_SET_ALL, false, "thread-index", 'x', required_argument, NULL, NULL, "", + "The breakpoint stops only for the thread whose index matches this argument."}, - { LLDB_OPT_SET_ALL, false, "thread_id", 't', required_argument, NULL, NULL, "", + { LLDB_OPT_SET_ALL, false, "thread-id", 't', required_argument, NULL, NULL, "", "The breakpoint stops only for the thread whose TID matches this argument."}, - { LLDB_OPT_SET_ALL, false, "thread_name", 'T', required_argument, NULL, NULL, "", + { LLDB_OPT_SET_ALL, false, "thread-name", 'T', required_argument, NULL, NULL, "", "The breakpoint stops only for the thread whose thread name matches this argument."}, - { LLDB_OPT_SET_ALL, false, "queue_name", 'q', required_argument, NULL, NULL, "", + { LLDB_OPT_SET_ALL, false, "queue-name", 'q', required_argument, NULL, NULL, "", "The breakpoint stops only for threads in the queue whose name is given by this argument."}, { LLDB_OPT_SET_1, false, "file", 'f', required_argument, NULL, CommandCompletions::eSourceFileCompletion, "", @@ -116,7 +116,7 @@ { LLDB_OPT_SET_6, true, "method", 'M', required_argument, NULL, 0, "", "Set the breakpoint by C++ method names." }, - { LLDB_OPT_SET_7, true, "func_regex", 'r', required_argument, NULL, 0, "", + { LLDB_OPT_SET_7, true, "func-regex", 'r', required_argument, NULL, 0, "", "Set the breakpoint by function name, evaluating a regular-expression to find the function name(s)." }, { 0, false, NULL, 0, 0, NULL, 0, NULL, NULL } @@ -186,7 +186,7 @@ m_modules.push_back (std::string (option_arg)); break; } - case 'k': + case 'i': { m_ignore_count = Args::StringToUInt32(optarg, UINT32_MAX, 0); if (m_ignore_count == UINT32_MAX) @@ -1098,29 +1098,14 @@ lldb::OptionDefinition CommandObjectBreakpointModify::CommandOptions::g_option_table[] = { - { LLDB_OPT_SET_ALL, false, "ignore_count", 'k', required_argument, NULL, 0, NULL, - "Set the number of times this breakpoint is sKipped before stopping." }, - - { LLDB_OPT_SET_ALL, false, "thread_index", 'x', required_argument, NULL, NULL, "", - "The breakpoint stops only for the thread whose indeX matches this argument."}, - - { LLDB_OPT_SET_ALL, false, "thread_id", 't', required_argument, NULL, NULL, "", - "The breakpoint stops only for the thread whose TID matches this argument."}, - - { LLDB_OPT_SET_ALL, false, "thread_name", 'T', required_argument, NULL, NULL, "", - "The breakpoint stops only for the thread whose thread name matches this argument."}, - - { LLDB_OPT_SET_ALL, false, "queue_name", 'q', required_argument, NULL, NULL, "", - "The breakpoint stops only for threads in the queue whose name is given by this argument."}, - - { LLDB_OPT_SET_1, false, "enable", 'e', no_argument, NULL, NULL, NULL, - "Enable the breakpoint."}, - - { LLDB_OPT_SET_2, false, "disable", 'd', no_argument, NULL, NULL, NULL, - "Disable the breakpoint."}, - - - { 0, false, NULL, 0, 0, NULL, 0, NULL, NULL } +{ LLDB_OPT_SET_ALL, false, "ignore-count", 'i', required_argument, NULL, NULL, "", "Set the number of times this breakpoint is skipped before stopping." }, +{ LLDB_OPT_SET_ALL, false, "thread-index", 'x', required_argument, NULL, NULL, "", "The breakpoint stops only for the thread whose indeX matches this argument."}, +{ LLDB_OPT_SET_ALL, false, "thread-id", 't', required_argument, NULL, NULL, "", "The breakpoint stops only for the thread whose TID matches this argument."}, +{ LLDB_OPT_SET_ALL, false, "thread-name", 'T', required_argument, NULL, NULL, "", "The breakpoint stops only for the thread whose thread name matches this argument."}, +{ LLDB_OPT_SET_ALL, false, "queue-name", 'q', required_argument, NULL, NULL, "", "The breakpoint stops only for threads in the queue whose name is given by this argument."}, +{ LLDB_OPT_SET_1, false, "enable", 'e', no_argument, NULL, NULL, NULL, "Enable the breakpoint."}, +{ LLDB_OPT_SET_2, false, "disable", 'd', no_argument, NULL, NULL, NULL, "Disable the breakpoint."}, +{ 0, false, NULL, 0 , 0, NULL, 0, NULL, NULL } }; const lldb::OptionDefinition* @@ -1145,7 +1130,7 @@ m_enable_passed = true; m_enable_value = true; break; - case 'k': + case 'i': { m_ignore_count = Args::StringToUInt32(optarg, UINT32_MAX, 0); if (m_ignore_count == UINT32_MAX) Modified: lldb/trunk/source/Commands/CommandObjectBreakpointCommand.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectBreakpointCommand.cpp?rev=114265&r1=114264&r2=114265&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectBreakpointCommand.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectBreakpointCommand.cpp Fri Sep 17 22:37:20 2010 @@ -48,7 +48,7 @@ lldb::OptionDefinition CommandObjectBreakpointCommandAdd::CommandOptions::g_option_table[] = { - { LLDB_OPT_SET_ALL, false, "one_liner", 'o', required_argument, NULL, 0, "", + { LLDB_OPT_SET_ALL, false, "one-liner", 'o', required_argument, NULL, 0, "", "Specify a one-liner inline." }, { LLDB_OPT_SET_1, true, "script", 's', no_argument, NULL, 0, NULL, Modified: lldb/trunk/source/Commands/CommandObjectCall.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectCall.cpp?rev=114265&r1=114264&r2=114265&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectCall.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectCall.cpp Fri Sep 17 22:37:20 2010 @@ -302,7 +302,7 @@ { 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, "useabi", 'a', no_argument, NULL, 0, NULL, "Use the ABI instead of the JIT to marshall arguments."}, +{ 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 } }; Modified: lldb/trunk/source/Commands/CommandObjectFrame.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectFrame.cpp?rev=114265&r1=114264&r2=114265&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectFrame.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectFrame.cpp Fri Sep 17 22:37:20 2010 @@ -290,7 +290,12 @@ CommandObjectFrameVariable (CommandInterpreter &interpreter) : CommandObject (interpreter, "frame variable", - "Show specified argument, local variable, static variable or global variable for the current frame. If none specified, list them all.", + "Show frame variables. All argument and local variables " + "that are in scope will be shown when no arguments are given. " + "If any arguments are specified, they can be names of " + "argument, local, file static and file global variables." + "Children of aggregate variables can be specified such as " + "'var->child.x'.", "frame variable [] [ [...]]") { } @@ -766,7 +771,7 @@ { LLDB_OPT_SET_1, false, "debug", 'D', no_argument, NULL, 0, NULL, "Enable verbose debug information."}, { LLDB_OPT_SET_1, false, "depth", 'd', required_argument, NULL, 0, "", "Set the max recurse depth when dumping aggregate types (default is infinity)."}, { LLDB_OPT_SET_1, false, "show-globals",'g', no_argument, NULL, 0, NULL, "Show the current frame source file global and static variables."}, -{ LLDB_OPT_SET_1, false, "find-global",'G', required_argument, NULL, 0, NULL, "Find a global variable by name (which might not be in the current stack frame source file)."}, +{ LLDB_OPT_SET_1, false, "find-global",'G', required_argument, NULL, 0, "", "Find a global variable by name (which might not be in the current stack frame source file)."}, { LLDB_OPT_SET_1, false, "location", 'L', no_argument, NULL, 0, NULL, "Show variable location information."}, { LLDB_OPT_SET_1, false, "show-declaration", 'c', no_argument, NULL, 0, NULL, "Show variable declaration information (source file and line where the variable was declared)."}, { LLDB_OPT_SET_1, false, "name", 'n', required_argument, NULL, 0, "", "Lookup a variable by name or regex (--regex) for the current execution context."}, Modified: lldb/trunk/source/Commands/CommandObjectProcess.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectProcess.cpp?rev=114265&r1=114264&r2=114265&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectProcess.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectProcess.cpp Fri Sep 17 22:37:20 2010 @@ -643,10 +643,10 @@ lldb::OptionDefinition CommandObjectProcessAttach::CommandOptions::g_option_table[] = { -{ LLDB_OPT_SET_ALL, false, "plugin", 'P', required_argument, NULL, 0, "", "Name of the process plugin you want to use."}, -{ LLDB_OPT_SET_1, false, "pid", 'p', required_argument, NULL, 0, "", "The process ID of an existing process to attach to."}, -{ LLDB_OPT_SET_2, false, "name", 'n', required_argument, NULL, 0, "", "The name of the process to attach to."}, -{ LLDB_OPT_SET_2, false, "waitfor", 'w', no_argument, NULL, 0, NULL, "Wait for the the process with to launch."}, +{ LLDB_OPT_SET_ALL, false, "plugin", 'P', required_argument, NULL, 0, "", "Name of the process plugin you want to use."}, +{ LLDB_OPT_SET_1, false, "pid", 'p', required_argument, NULL, 0, "", "The process ID of an existing process to attach to."}, +{ LLDB_OPT_SET_2, false, "name", 'n', required_argument, NULL, 0, "", "The name of the process to attach to."}, +{ LLDB_OPT_SET_2, false, "waitfor",'w', no_argument, NULL, 0, NULL, "Wait for the the process with to launch."}, { 0, false, NULL, 0, 0, NULL, 0, NULL, NULL } }; Modified: lldb/trunk/source/Commands/CommandObjectSettings.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectSettings.cpp?rev=114265&r1=114264&r2=114265&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectSettings.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectSettings.cpp Fri Sep 17 22:37:20 2010 @@ -207,7 +207,6 @@ CommandObjectSettingsSet::CommandOptions::g_option_table[] = { { LLDB_OPT_SET_1, false, "override", 'o', no_argument, NULL, NULL, NULL, "Causes already existing instances and pending settings to use this new value. This option only makes sense when setting default values." }, - { LLDB_OPT_SET_2, false, "reset", 'r', no_argument, NULL, NULL, NULL, "Causes value to be reset to the original default for this variable. No value needs to be specified when this option is used." }, }; Modified: lldb/trunk/source/Commands/CommandObjectSource.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectSource.cpp?rev=114265&r1=114264&r2=114265&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectSource.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectSource.cpp Fri Sep 17 22:37:20 2010 @@ -559,8 +559,7 @@ CommandObjectSourceList::CommandOptions::g_option_table[] = { { LLDB_OPT_SET_ALL, false, "count", 'c', required_argument, NULL, 0, "", "The number of source lines to display."}, -{ LLDB_OPT_SET_ALL, false, "shlib", 's', required_argument, NULL, CommandCompletions::eModuleCompletion, "", - "Look up the source file in the given shared library."}, +{ LLDB_OPT_SET_ALL, false, "shlib", 's', required_argument, NULL, CommandCompletions::eModuleCompletion, "", "Look up the source file in the given shared library."}, { LLDB_OPT_SET_1, false, "file", 'f', required_argument, NULL, CommandCompletions::eSourceFileCompletion, "", "The file from which to display source."}, { LLDB_OPT_SET_1, false, "line", 'l', required_argument, NULL, 0, "", "The line number at which to start the display source."}, { LLDB_OPT_SET_2, false, "name", 'n', required_argument, NULL, CommandCompletions::eSymbolCompletion, "", "The name of a function whose source to display."}, Modified: lldb/trunk/source/Commands/CommandObjectThread.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectThread.cpp?rev=114265&r1=114264&r2=114265&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectThread.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectThread.cpp Fri Sep 17 22:37:20 2010 @@ -467,8 +467,8 @@ lldb::OptionDefinition CommandObjectThreadBacktrace::CommandOptions::g_option_table[] = { -{ LLDB_OPT_SET_1, false, "count", 'c', required_argument, NULL, 0, "", "How many frames to display (-1 for all)"}, -{ LLDB_OPT_SET_1, false, "start", 's', required_argument, NULL, 0, "", "Frame in which to start the backtrace"}, +{ LLDB_OPT_SET_1, false, "count", 'c', required_argument, NULL, 0, "", "How many frames to display (-1 for all)"}, +{ LLDB_OPT_SET_1, false, "start", 's', required_argument, NULL, 0, "", "Frame in which to start the backtrace"}, { 0, false, NULL, 0, 0, NULL, 0, NULL, NULL } }; @@ -755,26 +755,26 @@ static lldb::OptionEnumValueElement g_tri_running_mode[] = { -{ eOnlyThisThread, "thisThread", "Run only this thread"}, -{ eAllThreads, "allThreads", "Run all threads"}, -{ eOnlyDuringStepping, "whileStepping", "Run only this thread while stepping"}, +{ eOnlyThisThread, "this-thread", "Run only this thread"}, +{ eAllThreads, "all-threads", "Run all threads"}, +{ eOnlyDuringStepping, "while-stepping", "Run only this thread while stepping"}, { 0, NULL, NULL } }; static lldb::OptionEnumValueElement g_duo_running_mode[] = { -{ eOnlyThisThread, "thisThread", "Run only this thread"}, -{ eAllThreads, "allThreads", "Run all threads"}, +{ eOnlyThisThread, "this-thread", "Run only this thread"}, +{ eAllThreads, "all-threads", "Run all threads"}, { 0, NULL, NULL } }; lldb::OptionDefinition CommandObjectThreadStepWithTypeAndScope::CommandOptions::g_option_table[] = { -{ LLDB_OPT_SET_1, false, "avoid_no_debug", 'a', required_argument, NULL, 0, "", "Should step-in step over functions with no debug information"}, -{ LLDB_OPT_SET_1, false, "run_mode", 'm', required_argument, g_tri_running_mode, 0, "", "Determine how to run other threads while stepping this one"}, -{ LLDB_OPT_SET_1, false, "regexp_to_avoid",'r', required_argument, NULL, 0, "", "Should step-in step over functions matching this regexp"}, +{ LLDB_OPT_SET_1, false, "avoid-no-debug", 'a', required_argument, NULL, 0, "", "A boolean value that sets whether step-in will step over functions with no debug information."}, +{ LLDB_OPT_SET_1, false, "run-mode", 'm', required_argument, g_tri_running_mode, 0, "","Determine how to run other threads while stepping the current thread."}, +{ LLDB_OPT_SET_1, false, "step-over-regexp",'r', required_argument, NULL, 0, "", "A regular expression that defines function names to step over."}, { 0, false, NULL, 0, 0, NULL, 0, NULL, NULL } }; @@ -1217,7 +1217,7 @@ { { LLDB_OPT_SET_1, false, "frame", 'f', required_argument, NULL, 0, "", "Frame index for until operation - defaults to 0"}, { LLDB_OPT_SET_1, false, "thread", 't', required_argument, NULL, 0, "", "Thread index for the thread for until operation"}, -{ LLDB_OPT_SET_1, false, "run_mode",'m', required_argument, g_duo_running_mode, 0, "","Determine how to run other threads while stepping this one"}, +{ LLDB_OPT_SET_1, false, "run-mode",'m', required_argument, g_duo_running_mode, 0, "","Determine how to run other threads while stepping this one"}, { 0, false, NULL, 0, 0, NULL, 0, NULL, NULL } }; Modified: lldb/trunk/source/Core/DataExtractor.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/DataExtractor.cpp?rev=114265&r1=114264&r2=114265&view=diff ============================================================================== --- lldb/trunk/source/Core/DataExtractor.cpp (original) +++ lldb/trunk/source/Core/DataExtractor.cpp Fri Sep 17 22:37:20 2010 @@ -262,7 +262,7 @@ return m_byte_order; } //------------------------------------------------------------------ -// Set wether this object will endian swap values as it extracts +// Set whether this object will endian swap values as it extracts // data. //------------------------------------------------------------------ void Modified: lldb/trunk/source/Core/DynamicLoader.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/DynamicLoader.cpp?rev=114265&r1=114264&r2=114265&view=diff ============================================================================== --- lldb/trunk/source/Core/DynamicLoader.cpp (original) +++ lldb/trunk/source/Core/DynamicLoader.cpp Fri Sep 17 22:37:20 2010 @@ -58,7 +58,7 @@ } //---------------------------------------------------------------------- -// Accessosors to the global setting as to wether to stop at image +// Accessosors to the global setting as to whether to stop at image // (shared library) loading/unloading. //---------------------------------------------------------------------- bool Modified: lldb/trunk/source/Core/ValueObject.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/ValueObject.cpp?rev=114265&r1=114264&r2=114265&view=diff ============================================================================== --- lldb/trunk/source/Core/ValueObject.cpp (original) +++ lldb/trunk/source/Core/ValueObject.cpp Fri Sep 17 22:37:20 2010 @@ -111,7 +111,7 @@ UpdateValue (exe_scope); // Update the fact that we tried to update the value for this - // value object wether or not we succeed + // value object whether or not we succeed m_update_id = stop_id; bool success = m_error.Success(); SetValueIsValid (success); Modified: lldb/trunk/source/Interpreter/Options.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Interpreter/Options.cpp?rev=114265&r1=114264&r2=114265&view=diff ============================================================================== --- lldb/trunk/source/Interpreter/Options.cpp (original) +++ lldb/trunk/source/Interpreter/Options.cpp Fri Sep 17 22:37:20 2010 @@ -402,6 +402,76 @@ strm.Printf ("\n"); strm.Indent (name); + // First go through and print all options that take no arguments as + // a single string. If a command has "-a" "-b" and "-c", this will show + // up as [-abc] + + std::set options; + std::set::const_iterator options_pos, options_end; + bool first; + for (i = 0, first = true; i < num_options; ++i) + { + if (full_options_table[i].usage_mask & opt_set_mask) + { + // Add current option to the end of out_stream. + + if (full_options_table[i].required == true && + full_options_table[i].option_has_arg == no_argument) + { + options.insert (full_options_table[i].short_option); + } + } + } + + if (options.empty() == false) + { + // We have some required options with no arguments + strm.PutCString(" -"); + for (i=0; i<2; ++i) + for (options_pos = options.begin(), options_end = options.end(); + options_pos != options_end; + ++options_pos) + { + if (i==0 && ::isupper (*options_pos)) + continue; + if (i==1 && ::islower (*options_pos)) + continue; + strm << *options_pos; + } + } + + for (i = 0, options.clear(); i < num_options; ++i) + { + if (full_options_table[i].usage_mask & opt_set_mask) + { + // Add current option to the end of out_stream. + + if (full_options_table[i].required == false && + full_options_table[i].option_has_arg == no_argument) + { + options.insert (full_options_table[i].short_option); + } + } + } + + if (options.empty() == false) + { + // We have some required options with no arguments + strm.PutCString(" [-"); + for (i=0; i<2; ++i) + for (options_pos = options.begin(), options_end = options.end(); + options_pos != options_end; + ++options_pos) + { + if (i==0 && ::isupper (*options_pos)) + continue; + if (i==1 && ::islower (*options_pos)) + continue; + strm << *options_pos; + } + strm.PutChar(']'); + } + // First go through and print the required options (list them up front). for (i = 0; i < num_options; ++i) @@ -424,8 +494,6 @@ full_options_table[i].short_option, full_options_table[i].argument_name); } - else - strm.Printf (" -%c", full_options_table[i].short_option); } } } @@ -446,8 +514,6 @@ else if (full_options_table[i].option_has_arg == optional_argument) strm.Printf (" [-%c [%s]]", full_options_table[i].short_option, full_options_table[i].argument_name); - else - strm.Printf (" [-%c]", full_options_table[i].short_option); } } } @@ -455,8 +521,7 @@ strm.Printf ("\n\n"); // Now print out all the detailed information about the various options: long form, short form and help text: - // -- long_name - // - short + // --long_name ( -short ) // help text // This variable is used to keep track of which options' info we've printed out, because some options can be in @@ -507,15 +572,13 @@ strm.EOL(); strm.Indent (); - strm.Printf ("-%c ", full_options_table[i].short_option); + strm.Printf ("--%s", full_options_table[i].long_option); if (full_options_table[i].argument_name != NULL) - strm.PutCString(full_options_table[i].argument_name); - strm.EOL(); - strm.Indent (); - strm.Printf ("--%s ", full_options_table[i].long_option); + strm.Printf (" %s", full_options_table[i].argument_name); + strm.Printf (" ( -%c", full_options_table[i].short_option); if (full_options_table[i].argument_name != NULL) - strm.PutCString(full_options_table[i].argument_name); - strm.EOL(); + strm.Printf (" %s", full_options_table[i].argument_name); + strm.PutCString(" )\n"); strm.IndentMore (5); Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.cpp?rev=114265&r1=114264&r2=114265&view=diff ============================================================================== --- lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.cpp (original) +++ lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.cpp Fri Sep 17 22:37:20 2010 @@ -891,7 +891,7 @@ // entry is successfully parsed. // // This function dump DWARF information and obey recurse depth and -// wether a single DIE is to be dumped (or all of the data). +// whether a single DIE is to be dumped (or all of the data). //---------------------------------------------------------------------- static dw_offset_t DumpCallback ( From gclayton at apple.com Fri Sep 17 23:00:06 2010 From: gclayton at apple.com (Greg Clayton) Date: Sat, 18 Sep 2010 04:00:06 -0000 Subject: [Lldb-commits] [lldb] r114266 - in /lldb/trunk/source: Commands/CommandObjectFrame.cpp Commands/CommandObjectThread.cpp Core/ValueObjectVariable.cpp Message-ID: <20100918040007.089F72A6C12C@llvm.org> Author: gclayton Date: Fri Sep 17 23:00:06 2010 New Revision: 114266 URL: http://llvm.org/viewvc/llvm-project?rev=114266&view=rev Log: Fixed an issue with: (lldb) frame variable --location Where the address of variables wasn't being formatted consistently. Modified: lldb/trunk/source/Commands/CommandObjectFrame.cpp lldb/trunk/source/Commands/CommandObjectThread.cpp lldb/trunk/source/Core/ValueObjectVariable.cpp Modified: lldb/trunk/source/Commands/CommandObjectFrame.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectFrame.cpp?rev=114266&r1=114265&r2=114266&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectFrame.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectFrame.cpp Fri Sep 17 23:00:06 2010 @@ -330,7 +330,7 @@ //const char *loc_cstr = valobj->GetLocationAsCString(); if (m_options.show_location) { - s.Printf("@ %s: ", valobj->GetLocationAsCString(exe_scope)); + s.Printf("%s: ", valobj->GetLocationAsCString(exe_scope)); } if (m_options.debug) s.Printf ("%p ValueObject{%u} ", valobj, valobj->GetID()); Modified: lldb/trunk/source/Commands/CommandObjectThread.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectThread.cpp?rev=114266&r1=114265&r2=114266&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectThread.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectThread.cpp Fri Sep 17 23:00:06 2010 @@ -772,9 +772,9 @@ lldb::OptionDefinition CommandObjectThreadStepWithTypeAndScope::CommandOptions::g_option_table[] = { -{ LLDB_OPT_SET_1, false, "avoid-no-debug", 'a', required_argument, NULL, 0, "", "A boolean value that sets whether step-in will step over functions with no debug information."}, -{ LLDB_OPT_SET_1, false, "run-mode", 'm', required_argument, g_tri_running_mode, 0, "","Determine how to run other threads while stepping the current thread."}, -{ LLDB_OPT_SET_1, false, "step-over-regexp",'r', required_argument, NULL, 0, "", "A regular expression that defines function names to step over."}, +{ LLDB_OPT_SET_1, false, "avoid-no-debug", 'a', required_argument, NULL, 0, "", "A boolean value that sets whether step-in will step over functions with no debug information."}, +{ LLDB_OPT_SET_1, false, "run-mode", 'm', required_argument, g_tri_running_mode, 0, "", "Determine how to run other threads while stepping the current thread."}, +{ LLDB_OPT_SET_1, false, "step-over-regexp",'r', required_argument, NULL, 0, "", "A regular expression that defines function names to step over."}, { 0, false, NULL, 0, 0, NULL, 0, NULL, NULL } }; Modified: lldb/trunk/source/Core/ValueObjectVariable.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/ValueObjectVariable.cpp?rev=114266&r1=114265&r2=114266&view=diff ============================================================================== --- lldb/trunk/source/Core/ValueObjectVariable.cpp (original) +++ lldb/trunk/source/Core/ValueObjectVariable.cpp Fri Sep 17 23:00:06 2010 @@ -105,6 +105,13 @@ DWARFExpression &expr = variable->LocationExpression(); lldb::addr_t loclist_base_load_addr = LLDB_INVALID_ADDRESS; ExecutionContext exe_ctx (exe_scope); + + if (exe_ctx.process) + { + m_data.SetByteOrder(exe_ctx.process->GetByteOrder()); + m_data.SetAddressByteSize(exe_ctx.process->GetAddressByteSize()); + } + if (expr.IsLocationList()) { SymbolContext sc; From gclayton at apple.com Fri Sep 17 23:06:15 2010 From: gclayton at apple.com (Greg Clayton) Date: Sat, 18 Sep 2010 04:06:15 -0000 Subject: [Lldb-commits] [lldb] r114267 - /lldb/trunk/source/Commands/CommandObjectFrame.cpp Message-ID: <20100918040615.CD4122A6C12C@llvm.org> Author: gclayton Date: Fri Sep 17 23:06:15 2010 New Revision: 114267 URL: http://llvm.org/viewvc/llvm-project?rev=114267&view=rev Log: Added a better error message to the "frame variable" when you try to view frame variables and are not stopped in a valid frame. Modified: lldb/trunk/source/Commands/CommandObjectFrame.cpp Modified: lldb/trunk/source/Commands/CommandObjectFrame.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectFrame.cpp?rev=114267&r1=114266&r2=114267&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectFrame.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectFrame.cpp Fri Sep 17 23:06:15 2010 @@ -442,7 +442,7 @@ ExecutionContext exe_ctx(m_interpreter.GetDebugger().GetExecutionContext()); if (exe_ctx.frame == NULL) { - result.AppendError ("invalid frame"); + result.AppendError ("you must be stopped in a valid stack frame to view frame variables."); result.SetStatus (eReturnStatusFailed); return false; } From johnny.chen at apple.com Sat Sep 18 21:31:54 2010 From: johnny.chen at apple.com (Johnny Chen) Date: Sun, 19 Sep 2010 02:31:54 -0000 Subject: [Lldb-commits] [lldb] r114305 - /lldb/trunk/test/foundation/TestObjCMethods.py Message-ID: <20100919023154.27EC02A6C12C@llvm.org> Author: johnny Date: Sat Sep 18 21:31:53 2010 New Revision: 114305 URL: http://llvm.org/viewvc/llvm-project?rev=114305&view=rev Log: Removed the @expectedFailure decorators; it was fixed with r114258. 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=114305&r1=114304&r2=114305&view=diff ============================================================================== --- lldb/trunk/test/foundation/TestObjCMethods.py (original) +++ lldb/trunk/test/foundation/TestObjCMethods.py Sat Sep 18 21:31:53 2010 @@ -23,13 +23,11 @@ self.buildDwarf() self.break_on_objc_methods() - @unittest2.expectedFailure def test_data_type_and_expr_with_dsym(self): """Lookup objective-c data types and evaluate expressions.""" self.buildDsym() self.data_type_and_expr_objc() - @unittest2.expectedFailure def test_data_type_and_expr_with_dwarf(self): """Lookup objective-c data types and evaluate expressions.""" self.buildDwarf() From gclayton at apple.com Sat Sep 18 21:33:57 2010 From: gclayton at apple.com (Greg Clayton) Date: Sun, 19 Sep 2010 02:33:57 -0000 Subject: [Lldb-commits] [lldb] r114306 - in /lldb/trunk: include/lldb/Core/Debugger.h include/lldb/Core/UserSettingsController.h include/lldb/Symbol/Function.h include/lldb/Symbol/Symbol.h include/lldb/Target/Process.h include/lldb/Target/Thread.h source/Core/Debugger.cpp source/Core/UserSettingsController.cpp source/Target/Process.cpp source/Target/Thread.cpp Message-ID: <20100919023358.03EAB2A6C12C@llvm.org> Author: gclayton Date: Sat Sep 18 21:33:57 2010 New Revision: 114306 URL: http://llvm.org/viewvc/llvm-project?rev=114306&view=rev Log: Added code that will allow completely customizable prompts for use in replacing the "(lldb)" prompt, the "frame #1..." displays when doing stack backtracing and the "thread #1....". This will allow you to see exactly the information that you want to see where you want to see it. This currently isn't hookup up to the prompts yet, but it will be soon. So what is the format of the prompts? Prompts can contain variables that have access to the current program state. Variables are text that appears in between a prefix of "${" and ends with a "}". Some of the interesting variables include: // The frame index (0, 1, 2, 3...) ${frame.index} // common frame registers with generic names ${frame.pc} ${frame.sp} ${frame.fp} ${frame.ra} ${frame.flags} // Access to any frame registers by name where REGNAME is any register name: ${frame.reg.REGNAME} // The current compile unit file where the frame is located ${file.basename} ${file.fullpath} // Function information ${function.name} ${function.pc-offset} // Process info ${process.file.basename} ${process.file.fullpath} ${process.id} ${process.name} // Thread info ${thread.id} ${thread.index} ${thread.name} ${thread.queue} ${thread.stop-reason} // Target information ${target.arch} // The current module for the current frame (the shared library or executable // that contains the current frame PC value): ${module.file.basename} ${module.file.fullpath} // Access to the line entry for where the current frame is when your thread // is stopped: ${line.file.basename} ${line.file.fullpath} ${line.number} ${line.start-addr} ${line.end-addr} Many times the information that you might have in your prompt might not be available and you won't want it to print out if it isn't valid. To take care of this you can enclose everything that must resolve into a scope. A scope is starts with '{' and ends with '}'. For example in order to only display the current file and line number when the information is available the format would be: "{ at {$line.file.basename}:${line.number}}" Broken down this is: start the scope: "{" format whose content will only be displayed if all information is available: "at {$line.file.basename}:${line.number}" end the scope: "}" We currently can represent the infomration we see when stopped at a frame: frame #0: 0x0000000100000e85 a.out`main + 4 at test.c:19 with the following format: "frame #${frame.index}: ${frame.pc} {${module.file.basename}`}{${function.name}{${function.pc-offset}}{ at ${line.file.basename}:${line.number}}\n" This breaks down to always print: "frame #${frame.index}: ${frame.pc} " only print the module followed by a tick if we have a valid module: "{${module.file.basename}`}" print the function name with optional offset: "{${function.name}{${function.pc-offset}}" print the line info if it is available: "{ at ${line.file.basename}:${line.number}}" then finish off with a newline: "\n" Notice you can also put newlines ("\n") and tabs and everything else you are used to putting in a format string when desensitized with the \ character. Cleaned up some of the user settings controller subclasses. All of them do not have any global settings variables and were all implementing stubs for the get/set global settings variable. Now there is a default version in UserSettingsController that will do nothing. Modified: lldb/trunk/include/lldb/Core/Debugger.h lldb/trunk/include/lldb/Core/UserSettingsController.h lldb/trunk/include/lldb/Symbol/Function.h lldb/trunk/include/lldb/Symbol/Symbol.h lldb/trunk/include/lldb/Target/Process.h lldb/trunk/include/lldb/Target/Thread.h lldb/trunk/source/Core/Debugger.cpp lldb/trunk/source/Core/UserSettingsController.cpp lldb/trunk/source/Target/Process.cpp lldb/trunk/source/Target/Thread.cpp Modified: lldb/trunk/include/lldb/Core/Debugger.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/Debugger.h?rev=114306&r1=114305&r2=114306&view=diff ============================================================================== --- lldb/trunk/include/lldb/Core/Debugger.h (original) +++ lldb/trunk/include/lldb/Core/Debugger.h Sat Sep 18 21:33:57 2010 @@ -143,26 +143,14 @@ { public: - class DebuggerSettingsController : public UserSettingsController + class SettingsController : public UserSettingsController { public: - DebuggerSettingsController (); + SettingsController (); virtual - ~DebuggerSettingsController (); - - void - UpdateGlobalVariable (const ConstString &var_name, - const char *index_value, - const char *value, - const SettingEntry &entry, - lldb::VarSetOperationType op, - Error&err); - - void - GetGlobalSettingsValue (const ConstString &var_name, - StringList &value); + ~SettingsController (); static SettingEntry global_settings_table[]; static SettingEntry instance_settings_table[]; @@ -170,13 +158,13 @@ protected: lldb::InstanceSettingsSP - CreateNewInstanceSettings (const char *instance_name); + CreateInstanceSettings (const char *instance_name); private: // Class-wide settings. - DISALLOW_COPY_AND_ASSIGN (DebuggerSettingsController); + DISALLOW_COPY_AND_ASSIGN (SettingsController); }; static lldb::UserSettingsControllerSP & @@ -304,6 +292,15 @@ static lldb::DebuggerSP FindDebuggerWithInstanceName (const ConstString &instance_name); + static bool + FormatPrompt (const char *format, + const SymbolContext *sc, + const ExecutionContext *exe_ctx, + const Address *addr, + Stream &s, + const char **end); + + protected: static void Modified: lldb/trunk/include/lldb/Core/UserSettingsController.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/UserSettingsController.h?rev=114306&r1=114305&r2=114306&view=diff ============================================================================== --- lldb/trunk/include/lldb/Core/UserSettingsController.h (original) +++ lldb/trunk/include/lldb/Core/UserSettingsController.h Sat Sep 18 21:33:57 2010 @@ -59,23 +59,28 @@ ~UserSettingsController (); // Pure virtual functions, which all sub-classes must implement. - virtual lldb::InstanceSettingsSP - CreateNewInstanceSettings (const char *instance_name) = 0; - - virtual void - UpdateGlobalVariable (const ConstString &var_name, - const char *index_value, - const char *value, - const SettingEntry &entry, - const lldb::VarSetOperationType op, - Error &err) = 0; - - virtual void - GetGlobalSettingsValue (const ConstString &var_name, - StringList &value) = 0; + CreateInstanceSettings (const char *instance_name) = 0; + // Virtual functions that you can override if you have global settings + // (not instance specific). + virtual bool + SetGlobalVariable (const ConstString &var_name, + const char *index_value, + const char *value, + const SettingEntry &entry, + const lldb::VarSetOperationType op, + Error &err); + + virtual bool + GetGlobalVariable (const ConstString &var_name, + StringList &value); + // End of pure virtual functions. + StringList + GetVariable (const char *full_dot_name, + lldb::SettableVariableType &var_type, + const char *debugger_instance_name); Error SetVariable (const char *full_dot_name, @@ -85,11 +90,6 @@ const char *debugger_instance_name, const char *index_value = NULL); - StringList - GetVariable (const char *full_dot_name, - lldb::SettableVariableType &var_type, - const char *debugger_instance_name); - const lldb::UserSettingsControllerSP & GetParent (); Modified: lldb/trunk/include/lldb/Symbol/Function.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Symbol/Function.h?rev=114306&r1=114305&r2=114306&view=diff ============================================================================== --- lldb/trunk/include/lldb/Symbol/Function.h (original) +++ lldb/trunk/include/lldb/Symbol/Function.h Sat Sep 18 21:33:57 2010 @@ -514,6 +514,12 @@ return m_frame_base; } + const ConstString & + GetName() const + { + return m_mangled.GetName(); + } + const Mangled & GetMangled() const { Modified: lldb/trunk/include/lldb/Symbol/Symbol.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Symbol/Symbol.h?rev=114306&r1=114305&r2=114306&view=diff ============================================================================== --- lldb/trunk/include/lldb/Symbol/Symbol.h (original) +++ lldb/trunk/include/lldb/Symbol/Symbol.h Sat Sep 18 21:33:57 2010 @@ -75,6 +75,9 @@ const AddressRange & GetAddressRangeRef() const { return m_addr_range; } + const ConstString & + GetName () { return m_mangled.GetName(); } + Mangled& GetMangled () { return m_mangled; } Modified: lldb/trunk/include/lldb/Target/Process.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/Process.h?rev=114306&r1=114305&r2=114306&view=diff ============================================================================== --- lldb/trunk/include/lldb/Target/Process.h (original) +++ lldb/trunk/include/lldb/Target/Process.h Sat Sep 18 21:33:57 2010 @@ -333,26 +333,14 @@ }; - class ProcessSettingsController : public UserSettingsController + class SettingsController : public UserSettingsController { public: - ProcessSettingsController (); + SettingsController (); virtual - ~ProcessSettingsController (); - - void - UpdateGlobalVariable (const ConstString &var_name, - const char *index_value, - const char *value, - const SettingEntry &entry, - lldb::VarSetOperationType op, - Error&err); - - void - GetGlobalSettingsValue (const ConstString &var_name, - StringList &value); + ~SettingsController (); static SettingEntry global_settings_table[]; static SettingEntry instance_settings_table[]; @@ -360,7 +348,7 @@ protected: lldb::InstanceSettingsSP - CreateNewInstanceSettings (const char *instance_name); + CreateInstanceSettings (const char *instance_name); static lldb::OptionEnumValueElement g_plugins[]; @@ -368,7 +356,7 @@ // Class-wide settings. - DISALLOW_COPY_AND_ASSIGN (ProcessSettingsController); + DISALLOW_COPY_AND_ASSIGN (SettingsController); }; #endif Modified: lldb/trunk/include/lldb/Target/Thread.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/Thread.h?rev=114306&r1=114305&r2=114306&view=diff ============================================================================== --- lldb/trunk/include/lldb/Target/Thread.h (original) +++ lldb/trunk/include/lldb/Target/Thread.h Sat Sep 18 21:33:57 2010 @@ -93,26 +93,14 @@ virtual ~ThreadSettingsController (); - - void - UpdateGlobalVariable (const ConstString &var_name, - const char *index_value, - const char *value, - const SettingEntry &entry, - lldb::VarSetOperationType op, - Error&err); - - void - GetGlobalSettingsValue (const ConstString &var_name, - StringList &value); - + static SettingEntry global_settings_table[]; static SettingEntry instance_settings_table[]; protected: lldb::InstanceSettingsSP - CreateNewInstanceSettings (const char *instance_name); + CreateInstanceSettings (const char *instance_name); private: Modified: lldb/trunk/source/Core/Debugger.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/Debugger.cpp?rev=114306&r1=114305&r2=114306&view=diff ============================================================================== --- lldb/trunk/source/Core/Debugger.cpp (original) +++ lldb/trunk/source/Core/Debugger.cpp Sat Sep 18 21:33:57 2010 @@ -12,20 +12,46 @@ #include "lldb/Core/Debugger.h" #include "lldb/Core/InputReader.h" #include "lldb/Core/State.h" +#include "lldb/Core/StreamString.h" #include "lldb/Core/Timer.h" #include "lldb/Interpreter/CommandInterpreter.h" #include "lldb/Target/TargetList.h" #include "lldb/Target/Process.h" +#include "lldb/Target/RegisterContext.h" +#include "lldb/Target/StopInfo.h" #include "lldb/Target/Thread.h" using namespace lldb; using namespace lldb_private; -static uint32_t g_shared_debugger_refcount = 0; +static uint32_t g_shared_debugger_refcount = 0; static lldb::user_id_t g_unique_id = 1; +#pragma mark Static Functions + +static Mutex & +GetDebuggerListMutex () +{ + static Mutex g_mutex(Mutex::eMutexTypeRecursive); + return g_mutex; +} + +typedef std::vector DebuggerList; + +static DebuggerList & +GetDebuggerList() +{ + // hide the static debugger list inside a singleton accessor to avoid + // global init contructors + static DebuggerList g_list; + return g_list; +} + + +#pragma mark Debugger + void Debugger::Initialize () { @@ -48,25 +74,6 @@ } } -typedef std::vector DebuggerList; - -static Mutex & -GetDebuggerListMutex () -{ - static Mutex g_mutex(Mutex::eMutexTypeRecursive); - return g_mutex; -} - -static DebuggerList & -GetDebuggerList() -{ - // hide the static debugger list inside a singleton accessor to avoid - // global init contructors - static DebuggerList g_list; - return g_list; -} - - DebuggerSP Debugger::CreateInstance () { @@ -547,14 +554,14 @@ lldb::UserSettingsControllerSP & Debugger::GetSettingsController (bool finish) { - static lldb::UserSettingsControllerSP g_settings_controller (new DebuggerSettingsController); + static lldb::UserSettingsControllerSP g_settings_controller (new SettingsController); static bool initialized = false; if (!initialized) { initialized = UserSettingsController::InitializeSettingsController (g_settings_controller, - Debugger::DebuggerSettingsController::global_settings_table, - Debugger::DebuggerSettingsController::instance_settings_table); + Debugger::SettingsController::global_settings_table, + Debugger::SettingsController::instance_settings_table); } if (finish) @@ -567,24 +574,659 @@ return g_settings_controller; } +static void +TestPromptFormats (StackFrame *frame) +{ + if (frame == NULL) + return; + + StreamString s; + const char *prompt_format = + "{addr = '${addr}'\n}" + "{process.id = '${process.id}'\n}" + "{process.name = '${process.name}'\n}" + "{process.file.basename = '${process.file.basename}'\n}" + "{process.file.fullpath = '${process.file.fullpath}'\n}" + "{thread.id = '${thread.id}'\n}" + "{thread.index = '${thread.index}'\n}" + "{thread.name = '${thread.name}'\n}" + "{thread.queue = '${thread.queue}'\n}" + "{thread.stop-reason = '${thread.stop-reason}'\n}" + "{target.arch = '${target.arch}'\n}" + "{module.file.basename = '${module.file.basename}'\n}" + "{module.file.fullpath = '${module.file.fullpath}'\n}" + "{file.basename = '${file.basename}'\n}" + "{file.fullpath = '${file.fullpath}'\n}" + "{frame.index = '${frame.index}'\n}" + "{frame.pc = '${frame.pc}'\n}" + "{frame.sp = '${frame.sp}'\n}" + "{frame.fp = '${frame.fp}'\n}" + "{frame.flags = '${frame.flags}'\n}" + "{frame.reg.rdi = '${frame.reg.rdi}'\n}" + "{frame.reg.rip = '${frame.reg.rip}'\n}" + "{frame.reg.rsp = '${frame.reg.rsp}'\n}" + "{frame.reg.rbp = '${frame.reg.rbp}'\n}" + "{frame.reg.rflags = '${frame.reg.rflags}'\n}" + "{frame.reg.xmm0 = '${frame.reg.xmm0}'\n}" + "{frame.reg.carp = '${frame.reg.carp}'\n}" + "{function.id = '${function.id}'\n}" + "{function.name = '${function.name}'\n}" + "{function.addr-offset = '${function.addr-offset}'\n}" + "{function.line-offset = '${function.line-offset}'\n}" + "{function.pc-offset = '${function.pc-offset}'\n}" + "{line.file.basename = '${line.file.basename}'\n}" + "{line.file.fullpath = '${line.file.fullpath}'\n}" + "{line.number = '${line.number}'\n}" + "{line.start-addr = '${line.start-addr}'\n}" + "{line.end-addr = '${line.end-addr}'\n}" +; + + SymbolContext sc (frame->GetSymbolContext(eSymbolContextEverything)); + ExecutionContext exe_ctx; + frame->Calculate(exe_ctx); + const char *end = NULL; + if (Debugger::FormatPrompt (prompt_format, &sc, &exe_ctx, &sc.line_entry.range.GetBaseAddress(), s, &end)) + { + printf("%s\n", s.GetData()); + } + else + { + printf ("error: at '%s'\n", end); + printf ("what we got: %s\n", s.GetData()); + } +} + +bool +Debugger::FormatPrompt +( + const char *format, + const SymbolContext *sc, + const ExecutionContext *exe_ctx, + const Address *addr, + Stream &s, + const char **end +) +{ + bool success = true; + const char *p; + for (p = format; *p != '\0'; ++p) + { + size_t non_special_chars = ::strcspn (p, "${}\\"); + if (non_special_chars > 0) + { + if (success) + s.Write (p, non_special_chars); + p += non_special_chars; + } + + if (*p == '\0') + { + break; + } + else if (*p == '{') + { + // Start a new scope that must have everything it needs if it is to + // to make it into the final output stream "s". If you want to make + // a format that only prints out the function or symbol name if there + // is one in the symbol context you can use: + // "{function =${function.name}}" + // The first '{' starts a new scope that end with the matching '}' at + // the end of the string. The contents "function =${function.name}" + // will then be evaluated and only be output if there is a function + // or symbol with a valid name. + StreamString sub_strm; + + ++p; // Skip the '{' + + if (FormatPrompt (p, sc, exe_ctx, addr, sub_strm, &p)) + { + // The stream had all it needed + s.Write(sub_strm.GetData(), sub_strm.GetSize()); + } + if (*p != '}') + { + success = false; + break; + } + } + else if (*p == '}') + { + // End of a enclosing scope + break; + } + else if (*p == '$') + { + // We have a prompt variable to print + ++p; + if (*p == '{') + { + ++p; + const char *var_name_begin = p; + const char *var_name_end = ::strchr (p, '}'); + + if (var_name_end && var_name_begin < var_name_end) + { + // if we have already failed to parse, skip this variable + if (success) + { + const char *cstr = NULL; + Address format_addr; + bool calculate_format_addr_function_offset = false; + // Set reg_kind and reg_num to invalid values + RegisterKind reg_kind = kNumRegisterKinds; + uint32_t reg_num = LLDB_INVALID_REGNUM; + FileSpec format_file_spec; + const lldb::RegisterInfo *reg_info = NULL; + RegisterContext *reg_ctx = NULL; + + // Each variable must set success to true below... + bool var_success = false; + switch (var_name_begin[0]) + { + case 'a': + if (::strncmp (var_name_begin, "addr}", strlen("addr}")) == 0) + { + if (addr && addr->IsValid()) + { + var_success = true; + format_addr = *addr; + } + } + break; + + case 'p': + if (::strncmp (var_name_begin, "process.", strlen("process.")) == 0) + { + if (exe_ctx && exe_ctx->process != NULL) + { + var_name_begin += ::strlen ("process."); + if (::strncmp (var_name_begin, "id}", strlen("id}")) == 0) + { + s.Printf("%i", exe_ctx->process->GetID()); + var_success = true; + } + else if ((::strncmp (var_name_begin, "name}", strlen("name}")) == 0) || + (::strncmp (var_name_begin, "file.basename}", strlen("file.basename}")) == 0) || + (::strncmp (var_name_begin, "file.fullpath}", strlen("file.fullpath}")) == 0)) + { + ModuleSP exe_module_sp (exe_ctx->process->GetTarget().GetExecutableModule()); + if (exe_module_sp) + { + if (var_name_begin[0] == 'n' || var_name_begin[5] == 'f') + { + format_file_spec.GetFilename() = exe_module_sp->GetFileSpec().GetFilename(); + var_success = format_file_spec; + } + else + { + format_file_spec = exe_module_sp->GetFileSpec(); + var_success = format_file_spec; + } + } + } + } + } + break; + + case 't': + if (::strncmp (var_name_begin, "thread.", strlen("thread.")) == 0) + { + if (exe_ctx && exe_ctx->thread) + { + var_name_begin += ::strlen ("thread."); + if (::strncmp (var_name_begin, "id}", strlen("id}")) == 0) + { + s.Printf("0x%4.4x", exe_ctx->thread->GetID()); + var_success = true; + } + else if (::strncmp (var_name_begin, "index}", strlen("index}")) == 0) + { + s.Printf("%u", exe_ctx->thread->GetIndexID()); + var_success = true; + } + else if (::strncmp (var_name_begin, "name}", strlen("name}")) == 0) + { + cstr = exe_ctx->thread->GetName(); + var_success = cstr && cstr[0]; + if (var_success) + s.PutCString(cstr); + } + else if (::strncmp (var_name_begin, "queue}", strlen("queue}")) == 0) + { + cstr = exe_ctx->thread->GetQueueName(); + var_success = cstr && cstr[0]; + if (var_success) + s.PutCString(cstr); + } + else if (::strncmp (var_name_begin, "stop-reason}", strlen("stop-reason}")) == 0) + { + lldb_private::StopInfo *stop_info = exe_ctx->thread->GetStopInfo (); + if (stop_info) + { + cstr = stop_info->GetDescription(); + if (cstr && cstr[0]) + { + s.PutCString(cstr); + var_success = true; + } + } + } + } + } + else if (::strncmp (var_name_begin, "target.", strlen("target.")) == 0) + { + if (sc->target_sp || (exe_ctx && exe_ctx->process)) + { + Target *target = sc->target_sp.get(); + if (target == NULL) + target = &exe_ctx->process->GetTarget(); + assert (target); + var_name_begin += ::strlen ("target."); + if (::strncmp (var_name_begin, "arch}", strlen("arch}")) == 0) + { + ArchSpec arch (target->GetArchitecture ()); + if (arch.IsValid()) + { + s.PutCString (arch.AsCString()); + var_success = true; + } + } + } + } + break; + + + case 'm': + if (::strncmp (var_name_begin, "module.", strlen("module.")) == 0) + { + Module *module = sc->module_sp.get(); + + if (module) + { + var_name_begin += ::strlen ("module."); + + if (::strncmp (var_name_begin, "file.", strlen("file.")) == 0) + { + if (module->GetFileSpec()) + { + var_name_begin += ::strlen ("file."); + + if (::strncmp (var_name_begin, "basename}", strlen("basename}")) == 0) + { + format_file_spec.GetFilename() = module->GetFileSpec().GetFilename(); + var_success = format_file_spec; + } + else if (::strncmp (var_name_begin, "fullpath}", strlen("fullpath}")) == 0) + { + format_file_spec = module->GetFileSpec(); + var_success = format_file_spec; + } + } + } + } + } + break; + + + case 'f': + if (::strncmp (var_name_begin, "file.", strlen("file.")) == 0) + { + if (sc && sc->comp_unit != NULL) + { + var_name_begin += ::strlen ("file."); + + if (::strncmp (var_name_begin, "basename}", strlen("basename}")) == 0) + { + format_file_spec.GetFilename() = sc->comp_unit->GetFilename(); + var_success = format_file_spec; + } + else if (::strncmp (var_name_begin, "fullpath}", strlen("fullpath}")) == 0) + { + format_file_spec = *sc->comp_unit; + var_success = format_file_spec; + } + } + } + else if (::strncmp (var_name_begin, "frame.", strlen("frame.")) == 0) + { + if (exe_ctx && exe_ctx->frame) + { + var_name_begin += ::strlen ("frame."); + if (::strncmp (var_name_begin, "index}", strlen("index}")) == 0) + { + s.Printf("%u", exe_ctx->frame->GetFrameIndex()); + var_success = true; + } + else if (::strncmp (var_name_begin, "pc}", strlen("pc}")) == 0) + { + reg_kind = eRegisterKindGeneric; + reg_num = LLDB_REGNUM_GENERIC_PC; + var_success = true; + } + else if (::strncmp (var_name_begin, "sp}", strlen("sp}")) == 0) + { + reg_kind = eRegisterKindGeneric; + reg_num = LLDB_REGNUM_GENERIC_SP; + var_success = true; + } + else if (::strncmp (var_name_begin, "fp}", strlen("fp}")) == 0) + { + reg_kind = eRegisterKindGeneric; + reg_num = LLDB_REGNUM_GENERIC_FP; + var_success = true; + } + else if (::strncmp (var_name_begin, "flags}", strlen("flags}")) == 0) + { + reg_kind = eRegisterKindGeneric; + reg_num = LLDB_REGNUM_GENERIC_FLAGS; + var_success = true; + } + else if (::strncmp (var_name_begin, "reg.", strlen ("reg.")) == 0) + { + reg_ctx = exe_ctx->frame->GetRegisterContext(); + if (reg_ctx) + { + var_name_begin += ::strlen ("reg."); + if (var_name_begin < var_name_end) + { + std::string reg_name (var_name_begin, var_name_end); + reg_info = reg_ctx->GetRegisterInfoByName (reg_name.c_str()); + if (reg_info) + var_success = true; + } + } + } + } + } + else if (::strncmp (var_name_begin, "function.", strlen("function.")) == 0) + { + if (sc && (sc->function != NULL || sc->symbol != NULL)) + { + var_name_begin += ::strlen ("function."); + if (::strncmp (var_name_begin, "id}", strlen("id}")) == 0) + { + if (sc->function) + s.Printf("function{0x%8.8x}", sc->function->GetID()); + else + s.Printf("symbol[%u]", sc->symbol->GetID()); + + var_success = true; + } + else if (::strncmp (var_name_begin, "name}", strlen("name}")) == 0) + { + if (sc->function) + cstr = sc->function->GetName().AsCString (NULL); + else if (sc->symbol) + cstr = sc->symbol->GetName().AsCString (NULL); + if (cstr) + { + s.PutCString(cstr); + var_success = true; + } + } + else if (::strncmp (var_name_begin, "addr-offset}", strlen("addr-offset}")) == 0) + { + var_success = addr != NULL; + if (var_success) + { + format_addr = *addr; + calculate_format_addr_function_offset = true; + } + } + else if (::strncmp (var_name_begin, "line-offset}", strlen("line-offset}")) == 0) + { + var_success = sc->line_entry.range.GetBaseAddress().IsValid(); + if (var_success) + { + format_addr = sc->line_entry.range.GetBaseAddress(); + calculate_format_addr_function_offset = true; + } + } + else if (::strncmp (var_name_begin, "pc-offset}", strlen("pc-offset}")) == 0) + { + var_success = exe_ctx->frame; + if (var_success) + { + format_addr = exe_ctx->frame->GetFrameCodeAddress(); + calculate_format_addr_function_offset = true; + } + } + } + } + break; + + case 'l': + if (::strncmp (var_name_begin, "line.", strlen("line.")) == 0) + { + if (sc && sc->line_entry.IsValid()) + { + var_name_begin += ::strlen ("line."); + if (::strncmp (var_name_begin, "file.", strlen("file.")) == 0) + { + var_name_begin += ::strlen ("file."); + + if (::strncmp (var_name_begin, "basename}", strlen("basename}")) == 0) + { + format_file_spec.GetFilename() = sc->line_entry.file.GetFilename(); + var_success = format_file_spec; + } + else if (::strncmp (var_name_begin, "fullpath}", strlen("fullpath}")) == 0) + { + format_file_spec = sc->line_entry.file; + var_success = format_file_spec; + } + } + else if (::strncmp (var_name_begin, "number}", strlen("number}")) == 0) + { + var_success = true; + s.Printf("%u", sc->line_entry.line); + } + else if ((::strncmp (var_name_begin, "start-addr}", strlen("start-addr}")) == 0) || + (::strncmp (var_name_begin, "end-addr}", strlen("end-addr}")) == 0)) + { + var_success = sc && sc->line_entry.range.GetBaseAddress().IsValid(); + if (var_success) + { + format_addr = sc->line_entry.range.GetBaseAddress(); + if (var_name_begin[0] == 'e') + format_addr.Slide (sc->line_entry.range.GetByteSize()); + } + } + } + } + break; + } + + if (var_success) + { + // If format addr is valid, then we need to print an address + if (reg_num != LLDB_INVALID_REGNUM) + { + // We have a register value to display... + if (reg_num == LLDB_REGNUM_GENERIC_PC && reg_kind == eRegisterKindGeneric) + { + format_addr = exe_ctx->frame->GetFrameCodeAddress(); + } + else + { + if (reg_ctx == NULL) + reg_ctx = exe_ctx->frame->GetRegisterContext(); + + if (reg_ctx) + { + if (reg_kind != kNumRegisterKinds) + reg_num = reg_ctx->ConvertRegisterKindToRegisterNumber(reg_kind, reg_num); + reg_info = reg_ctx->GetRegisterInfoAtIndex (reg_num); + var_success = reg_info != NULL; + } + } + } + + if (reg_info != NULL) + { + DataExtractor reg_data; + var_success = reg_ctx->ReadRegisterBytes (reg_info->kinds[eRegisterKindLLDB], reg_data); + { + reg_data.Dump(&s, 0, reg_info->format, reg_info->byte_size, 1, UINT32_MAX, LLDB_INVALID_ADDRESS, 0, 0); + } + } + + if (format_file_spec) + { + s << format_file_spec; + } + + // If format addr is valid, then we need to print an address + if (format_addr.IsValid()) + { + if (calculate_format_addr_function_offset) + { + Address func_addr; + if (sc->function) + func_addr = sc->function->GetAddressRange().GetBaseAddress(); + else if (sc->symbol && sc->symbol->GetAddressRangePtr()) + func_addr = sc->symbol->GetAddressRangePtr()->GetBaseAddress(); + else + var_success = false; + + if (var_success) + { + if (func_addr.GetSection() == format_addr.GetSection()) + { + addr_t func_file_addr = func_addr.GetFileAddress(); + addr_t addr_file_addr = format_addr.GetFileAddress(); + if (addr_file_addr > func_file_addr) + { + s.Printf(" + %llu", addr_file_addr - func_file_addr); + } + else if (addr_file_addr < func_file_addr) + { + s.Printf(" - %llu", func_file_addr - addr_file_addr); + } + } + else + var_success = false; + } + } + else + { + addr_t vaddr = LLDB_INVALID_ADDRESS; + if (exe_ctx && exe_ctx->process && !exe_ctx->process->GetTarget().GetSectionLoadList().IsEmpty()) + vaddr = format_addr.GetLoadAddress (&exe_ctx->process->GetTarget()); + if (vaddr == LLDB_INVALID_ADDRESS) + vaddr = format_addr.GetFileAddress (); + + if (vaddr != LLDB_INVALID_ADDRESS) + s.Printf("0x%16.16llx", vaddr); + else + var_success = false; + } + } + } + + if (var_success == false) + success = false; + } + p = var_name_end; + } + else + break; + } + else + { + // We got a dollar sign with no '{' after it, it must just be a dollar sign + s.PutChar(*p); + } + } + else if (*p == '\\') + { + ++p; // skip the slash + switch (*p) + { + case 'a': s.PutChar ('\a'); break; + case 'b': s.PutChar ('\b'); break; + case 'f': s.PutChar ('\f'); break; + case 'n': s.PutChar ('\n'); break; + case 'r': s.PutChar ('\r'); break; + case 't': s.PutChar ('\t'); break; + case 'v': s.PutChar ('\v'); break; + case '\'': s.PutChar ('\''); break; + case '\\': s.PutChar ('\\'); break; + case '0': + // 1 to 3 octal chars + { + unsigned long octal_value = 0; + ++p; + int i=0; + for (; i<3; ++i) + { + if (*p >= '0' && *p <= '7') + octal_value = octal_value << 3 + (((uint8_t)*p) - '0'); + else + break; + } + if (i>0) + s.PutChar (octal_value); + else + s.PutCString ("\\0"); + } + break; + + case 'x': + // hex number in the format + { + ++p; + + if (isxdigit(*p)) + { + char hex_str[3] = { 0,0,0 }; + hex_str[0] = *p; + ++p; + if (isxdigit(*p)) + hex_str[1] = *p; + unsigned long hex_value = strtoul (hex_str, NULL, 16); + s.PutChar (hex_value); + } + else + { + s.PutCString ("\\x"); + } + } + break; + + default: + s << '\\' << *p; + break; + + } + + } + } + if (end) + *end = p; + return success; +} + +#pragma mark Debugger::SettingsController + //-------------------------------------------------- -// class Debugger::DebuggerSettingsController +// class Debugger::SettingsController //-------------------------------------------------- -Debugger::DebuggerSettingsController::DebuggerSettingsController () : +Debugger::SettingsController::SettingsController () : UserSettingsController ("", lldb::UserSettingsControllerSP()) { m_default_settings.reset (new DebuggerInstanceSettings (*this, false, InstanceSettings::GetDefaultName().AsCString())); } -Debugger::DebuggerSettingsController::~DebuggerSettingsController () +Debugger::SettingsController::~SettingsController () { } lldb::InstanceSettingsSP -Debugger::DebuggerSettingsController::CreateNewInstanceSettings (const char *instance_name) +Debugger::SettingsController::CreateInstanceSettings (const char *instance_name) { DebuggerInstanceSettings *new_settings = new DebuggerInstanceSettings (*(Debugger::GetSettingsController().get()), false, instance_name); @@ -592,36 +1234,7 @@ return new_settings_sp; } -bool -Debugger::DebuggerInstanceSettings::ValidTermWidthValue (const char *value, Error err) -{ - bool valid = false; - - // Verify we have a value string. - if (value == NULL || value[0] == '\0') - { - err.SetErrorString ("Missing value. Can't set terminal width without a value.\n"); - } - else - { - char *end = NULL; - const uint32_t width = ::strtoul (value, &end, 0); - - if (end && end == '\0') - { - if (width >= 10 || width <= 1024) - valid = true; - else - err.SetErrorString ("Invalid term-width value; value must be between 10 and 1024.\n"); - } - else - err.SetErrorStringWithFormat ("'%s' is not a valid unsigned integer string.\n", value); - } - - return valid; -} - - +#pragma mark DebuggerInstanceSettings //-------------------------------------------------- // class DebuggerInstanceSettings //-------------------------------------------------- @@ -675,6 +1288,7 @@ { if (this != &rhs) { + m_term_width = rhs.m_term_width; m_prompt = rhs.m_prompt; m_script_lang = rhs.m_script_lang; } @@ -682,6 +1296,36 @@ return *this; } +bool +DebuggerInstanceSettings::ValidTermWidthValue (const char *value, Error err) +{ + bool valid = false; + + // Verify we have a value string. + if (value == NULL || value[0] == '\0') + { + err.SetErrorString ("Missing value. Can't set terminal width without a value.\n"); + } + else + { + char *end = NULL; + const uint32_t width = ::strtoul (value, &end, 0); + + if (end && end == '\0') + { + if (width >= 10 || width <= 1024) + valid = true; + else + err.SetErrorString ("Invalid term-width value; value must be between 10 and 1024.\n"); + } + else + err.SetErrorStringWithFormat ("'%s' is not a valid unsigned integer string.\n", value); + } + + return valid; +} + + void DebuggerInstanceSettings::UpdateInstanceSettingsVariable (const ConstString &var_name, const char *index_value, @@ -725,17 +1369,6 @@ } void -Debugger::DebuggerSettingsController::UpdateGlobalVariable (const ConstString &var_name, - const char *index_value, - const char *value, - const SettingEntry &entry, - lldb::VarSetOperationType op, - Error &err) -{ - // There should not be any global variables at the Debugger level. -} - -void DebuggerInstanceSettings::GetInstanceSettingsValue (const SettingEntry &entry, const ConstString &var_name, StringList &value) @@ -784,12 +1417,6 @@ m_script_lang = new_debugger_settings->m_script_lang; } -void -Debugger::DebuggerSettingsController::GetGlobalSettingsValue (const ConstString &var_name, - StringList &value) -{ - // There should not be any global variables at the Debugger level. -} bool DebuggerInstanceSettings::BroadcastPromptChange (const ConstString &instance_name, const char *new_prompt) @@ -866,12 +1493,12 @@ } //-------------------------------------------------- -// DebuggerSettingsController Variable Tables +// SettingsController Variable Tables //-------------------------------------------------- SettingEntry -Debugger::DebuggerSettingsController::global_settings_table[] = +Debugger::SettingsController::global_settings_table[] = { //{ "var-name", var-type, "default", enum-table, init'd, hidden, "help-text"}, // The Debugger level global table should always be empty; all Debugger settable variables should be instance @@ -882,7 +1509,7 @@ SettingEntry -Debugger::DebuggerSettingsController::instance_settings_table[] = +Debugger::SettingsController::instance_settings_table[] = { //{ "var-name", var-type , "default", enum-table, init'd, hidden, "help-text"}, { "term-width" , eSetVarTypeInt, "80" , NULL, false , false , "The maximum number of columns to use for displaying text." }, Modified: lldb/trunk/source/Core/UserSettingsController.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/UserSettingsController.cpp?rev=114306&r1=114305&r2=114306&view=diff ============================================================================== --- lldb/trunk/source/Core/UserSettingsController.cpp (original) +++ lldb/trunk/source/Core/UserSettingsController.cpp Sat Sep 18 21:33:57 2010 @@ -39,6 +39,31 @@ } bool +UserSettingsController::SetGlobalVariable +( + const ConstString &var_name, + const char *index_value, + const char *value, + const SettingEntry &entry, + const lldb::VarSetOperationType op, + Error &err +) +{ + err.SetErrorString ("UserSettingsController has no global settings"); + return false; +} + +bool +UserSettingsController::GetGlobalVariable +( + const ConstString &var_name, + StringList &value +) +{ + return false; +} + +bool UserSettingsController::InitializeSettingsController (lldb::UserSettingsControllerSP &controller_sp, SettingEntry *global_settings, SettingEntry *instance_settings) @@ -270,7 +295,7 @@ else value = entry->enum_values[0].string_value; } - UpdateGlobalVariable (const_var_name, index_value, value, *entry, op, err); + SetGlobalVariable (const_var_name, index_value, value, *entry, op, err); } else { @@ -472,8 +497,12 @@ } StringList -UserSettingsController::GetVariable (const char *full_dot_name, lldb::SettableVariableType &var_type, - const char *debugger_instance_name) +UserSettingsController::GetVariable +( + const char *full_dot_name, + lldb::SettableVariableType &var_type, + const char *debugger_instance_name +) { Args names = UserSettingsController::BreakNameIntoPieces (full_dot_name); ConstString const_var_name; @@ -589,7 +618,7 @@ else if (global_entry) { var_type = global_entry->var_type; - GetGlobalSettingsValue (const_var_name, value); + GetGlobalVariable (const_var_name, value); } else if (instance_entry) { @@ -720,18 +749,18 @@ pos = m_pending_settings.find (name_str); if (pos != m_pending_settings.end()) - { + { lldb::InstanceSettingsSP settings_sp = pos->second; return settings_sp; - } + } else - { - lldb::InstanceSettingsSP new_settings_sp = CreateNewInstanceSettings (instance_name.AsCString()); + { + lldb::InstanceSettingsSP new_settings_sp = CreateInstanceSettings (instance_name.AsCString()); CopyDefaultSettings (new_settings_sp, instance_name, true); m_pending_settings[name_str] = new_settings_sp; return new_settings_sp; - } - + } + // Should never reach this line. lldb::InstanceSettingsSP dummy; Modified: lldb/trunk/source/Target/Process.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/Process.cpp?rev=114306&r1=114305&r2=114306&view=diff ============================================================================== --- lldb/trunk/source/Target/Process.cpp (original) +++ lldb/trunk/source/Target/Process.cpp Sat Sep 18 21:33:57 2010 @@ -1826,14 +1826,14 @@ lldb::UserSettingsControllerSP Process::GetSettingsController (bool finish) { - static UserSettingsControllerSP g_settings_controller (new ProcessSettingsController); + static UserSettingsControllerSP g_settings_controller (new SettingsController); static bool initialized = false; if (!initialized) { initialized = UserSettingsController::InitializeSettingsController (g_settings_controller, - Process::ProcessSettingsController::global_settings_table, - Process::ProcessSettingsController::instance_settings_table); + Process::SettingsController::global_settings_table, + Process::SettingsController::instance_settings_table); } if (finish) @@ -1847,22 +1847,22 @@ } //-------------------------------------------------------------- -// class Process::ProcessSettingsController +// class Process::SettingsController //-------------------------------------------------------------- -Process::ProcessSettingsController::ProcessSettingsController () : +Process::SettingsController::SettingsController () : UserSettingsController ("process", Debugger::GetSettingsController()) { m_default_settings.reset (new ProcessInstanceSettings (*this, false, InstanceSettings::GetDefaultName().AsCString())); } -Process::ProcessSettingsController::~ProcessSettingsController () +Process::SettingsController::~SettingsController () { } lldb::InstanceSettingsSP -Process::ProcessSettingsController::CreateNewInstanceSettings (const char *instance_name) +Process::SettingsController::CreateInstanceSettings (const char *instance_name) { ProcessInstanceSettings *new_settings = new ProcessInstanceSettings (*(Process::GetSettingsController().get()), false, instance_name); @@ -1989,18 +1989,6 @@ } void -Process::ProcessSettingsController::UpdateGlobalVariable (const ConstString &var_name, - const char *index_value, - const char *value, - const SettingEntry &entry, - lldb::VarSetOperationType op, - Error&err) -{ - // Currently 'process' does not have any global settings. -} - - -void ProcessInstanceSettings::GetInstanceSettingsValue (const SettingEntry &entry, const ConstString &var_name, StringList &value) @@ -2053,13 +2041,6 @@ value.AppendString ("unrecognized variable name"); } -void -Process::ProcessSettingsController::GetGlobalSettingsValue (const ConstString &var_name, - StringList &value) -{ - // Currently 'process' does not have any global settings. -} - const ConstString ProcessInstanceSettings::CreateInstanceName () { @@ -2132,11 +2113,11 @@ //-------------------------------------------------- -// ProcessSettingsController Variable Tables +// SettingsController Variable Tables //-------------------------------------------------- SettingEntry -Process::ProcessSettingsController::global_settings_table[] = +Process::SettingsController::global_settings_table[] = { //{ "var-name", var-type , "default", enum-table, init'd, hidden, "help-text"}, { NULL, eSetVarTypeNone, NULL, NULL, 0, 0, NULL } @@ -2144,7 +2125,7 @@ lldb::OptionEnumValueElement -Process::ProcessSettingsController::g_plugins[] = +Process::SettingsController::g_plugins[] = { { eMacosx, "process.macosx", "Use the native MacOSX debugger plugin" }, { eRemoteDebugger, "process.gdb-remote" , "Use the GDB Remote protocol based debugger plugin" }, @@ -2152,7 +2133,7 @@ }; SettingEntry -Process::ProcessSettingsController::instance_settings_table[] = +Process::SettingsController::instance_settings_table[] = { //{ "var-name", var-type, "default", enum-table, init'd, hidden, "help-text"}, { "run-args", eSetVarTypeArray, NULL, NULL, false, false, "A list containing all the arguments to be passed to the executable when it is run." }, Modified: lldb/trunk/source/Target/Thread.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/Thread.cpp?rev=114306&r1=114305&r2=114306&view=diff ============================================================================== --- lldb/trunk/source/Target/Thread.cpp (original) +++ lldb/trunk/source/Target/Thread.cpp Sat Sep 18 21:33:57 2010 @@ -954,7 +954,7 @@ } lldb::InstanceSettingsSP -Thread::ThreadSettingsController::CreateNewInstanceSettings (const char *instance_name) +Thread::ThreadSettingsController::CreateInstanceSettings (const char *instance_name) { ThreadInstanceSettings *new_settings = new ThreadInstanceSettings (*(Thread::GetSettingsController().get()), false, instance_name); @@ -1063,18 +1063,6 @@ } void -Thread::ThreadSettingsController::UpdateGlobalVariable (const ConstString &var_name, - const char *index_value, - const char *value, - const SettingEntry &entry, - lldb::VarSetOperationType op, - Error&err) -{ - // Currently 'thread' does not have any global settings. -} - - -void ThreadInstanceSettings::GetInstanceSettingsValue (const SettingEntry &entry, const ConstString &var_name, StringList &value) @@ -1094,13 +1082,6 @@ value.AppendString ("unrecognized variable name"); } -void -Thread::ThreadSettingsController::GetGlobalSettingsValue (const ConstString &var_name, - StringList &value) -{ - // Currently 'thread' does not have any global settings. -} - const ConstString ThreadInstanceSettings::CreateInstanceName () { From johnny.chen at apple.com Sat Sep 18 21:47:18 2010 From: johnny.chen at apple.com (Johnny Chen) Date: Sun, 19 Sep 2010 02:47:18 -0000 Subject: [Lldb-commits] [lldb] r114307 - /lldb/trunk/test/settings/TestSettings.py Message-ID: <20100919024718.D64022A6C12C@llvm.org> Author: johnny Date: Sat Sep 18 21:47:18 2010 New Revision: 114307 URL: http://llvm.org/viewvc/llvm-project?rev=114307&view=rev Log: Added @expectedFailure decorator for test_set_term_width(). 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=114307&r1=114306&r2=114307&view=diff ============================================================================== --- lldb/trunk/test/settings/TestSettings.py (original) +++ lldb/trunk/test/settings/TestSettings.py Sat Sep 18 21:47:18 2010 @@ -30,6 +30,9 @@ self.expect("settings show", substrs = ["prompt (string) = 'lldb2'"]) + @unittest2.expectedFailure + # rdar://problem/8449849 + # settings test case failure (probably after r114252) def test_set_term_width(self): """Test that 'set term-width' actually changes the term-width."""