From gclayton at apple.com Tue May 31 15:18:39 2011 From: gclayton at apple.com (Greg Clayton) Date: Tue, 31 May 2011 20:18:39 -0000 Subject: [Lldb-commits] [lldb] r132354 - /lldb/trunk/source/Core/ValueObjectDynamicValue.cpp Message-ID: <20110531201839.989F92A6C12C@llvm.org> Author: gclayton Date: Tue May 31 15:18:39 2011 New Revision: 132354 URL: http://llvm.org/viewvc/llvm-project?rev=132354&view=rev Log: Fix dynamic value objects to do the right thing when the value fails to evaluate. Modified: lldb/trunk/source/Core/ValueObjectDynamicValue.cpp Modified: lldb/trunk/source/Core/ValueObjectDynamicValue.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/ValueObjectDynamicValue.cpp?rev=132354&r1=132353&r2=132354&view=diff ============================================================================== --- lldb/trunk/source/Core/ValueObjectDynamicValue.cpp (original) +++ lldb/trunk/source/Core/ValueObjectDynamicValue.cpp Tue May 31 15:18:39 2011 @@ -60,11 +60,8 @@ ConstString ValueObjectDynamicValue::GetTypeName() { - // FIXME: Maybe cache the name, but have to clear it out if the type changes... - if (!UpdateValueIfNeeded()) - return ConstString(""); - - if (m_type_sp) + const bool success = UpdateValueIfNeeded(); + if (success && m_type_sp) return ClangASTType::GetClangTypeName (GetClangType()); else return m_parent->GetTypeName(); @@ -73,10 +70,8 @@ uint32_t ValueObjectDynamicValue::CalculateNumChildren() { - if (!UpdateValueIfNeeded()) - return 0; - - if (m_type_sp) + const bool success = UpdateValueIfNeeded(); + if (success && m_type_sp) return ClangASTContext::GetNumChildren (GetClangAST (), GetClangType(), true); else return m_parent->GetNumChildren(); @@ -85,10 +80,8 @@ clang::ASTContext * ValueObjectDynamicValue::GetClangAST () { - if (!UpdateValueIfNeeded()) - return NULL; - - if (m_type_sp) + const bool success = UpdateValueIfNeeded(); + if (success && m_type_sp) return m_type_sp->GetClangAST(); else return m_parent->GetClangAST (); @@ -97,10 +90,8 @@ size_t ValueObjectDynamicValue::GetByteSize() { - if (!UpdateValueIfNeeded()) - return 0; - - if (m_type_sp) + const bool success = UpdateValueIfNeeded(); + if (success && m_type_sp) return m_value.GetValueByteSize(GetClangAST(), NULL); else return m_parent->GetByteSize(); From johnny.chen at apple.com Tue May 31 17:16:51 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Tue, 31 May 2011 22:16:51 -0000 Subject: [Lldb-commits] [lldb] r132367 - /lldb/trunk/test/lldbtest.py Message-ID: <20110531221651.392EC2A6C12C@llvm.org> Author: johnny Date: Tue May 31 17:16:51 2011 New Revision: 132367 URL: http://llvm.org/viewvc/llvm-project?rev=132367&view=rev Log: Move some comments to the docstrings. 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=132367&r1=132366&r2=132367&view=diff ============================================================================== --- lldb/trunk/test/lldbtest.py (original) +++ lldb/trunk/test/lldbtest.py Tue May 31 17:16:51 2011 @@ -195,29 +195,21 @@ VARIABLES_DISPLAYED_CORRECTLY = "Variable(s) displayed correctly" -# -# And a generic "Command '%s' returns successfully" message generator. -# def CMD_MSG(str): + '''A generic "Command '%s' returns successfully" message generator.''' return "Command '%s' returns successfully" % str -# -# And a generic "'%s' returns expected result" message generator if exe. -# Otherwise, it's "'%s' matches expected result" -# def EXP_MSG(str, exe): + '''A generic "'%s' returns expected result" message generator if exe. + Otherwise, it generates "'%s' matches expected result" message.''' return "'%s' %s expected result" % (str, 'returns' if exe else 'matches') -# -# And a generic "Value of setting '%s' is correct" message generator. -# def SETTING_MSG(setting): + '''A generic "Value of setting '%s' is correct" message generator.''' return "Value of setting '%s' is correct" % setting -# -# Returns an env variable array from the os.environ map object. -# def EnvArray(): + """Returns an env variable array from the os.environ map object.""" return map(lambda k,v: k+"="+v, os.environ.keys(), os.environ.values()) def line_number(filename, string_to_match): From johnny.chen at apple.com Tue May 31 18:21:43 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Tue, 31 May 2011 23:21:43 -0000 Subject: [Lldb-commits] [lldb] r132372 - /lldb/trunk/test/lldbtest.py Message-ID: <20110531232143.0FCF42A6C12C@llvm.org> Author: johnny Date: Tue May 31 18:21:42 2011 New Revision: 132372 URL: http://llvm.org/viewvc/llvm-project?rev=132372&view=rev Log: Fix out-dated module docstring for lldbtest.py. Also wrap some lldb attribute references inside a try-except block in case the test is not invoked through the dotest.py test driver. 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=132372&r1=132371&r2=132372&view=diff ============================================================================== --- lldb/trunk/test/lldbtest.py (original) +++ lldb/trunk/test/lldbtest.py Tue May 31 18:21:42 2011 @@ -13,7 +13,7 @@ LLDB_TEST and PYTHONPATH environment variables, for example: $ export LLDB_TEST=$PWD -$ export PYTHONPATH=/Volumes/data/lldb/svn/trunk/build/Debug/LLDB.framework/Resources/Python:$LLDB_TEST:$LLDB_TEST/plugins +$ export PYTHONPATH=/Volumes/data/lldb/svn/trunk/build/Debug/LLDB.framework/Resources/Python:$LLDB_TEST:$LLDB_TEST/plugins:$LLDB_TEST/pexpect-2.4 $ echo $LLDB_TEST /Volumes/data/lldb/svn/trunk/test $ echo $PYTHONPATH @@ -234,8 +234,11 @@ raise Exception("@python_api_test can only be used to decorate a test method") @wraps(func) def wrapper(self, *args, **kwargs): - if lldb.dont_do_python_api_test: - self.skipTest("Skip Python API tests") + try: + if lldb.dont_do_python_api_test: + self.skipTest("Skip Python API tests") + except AttributeError: + pass return func(self, *args, **kwargs) # Mark this function as such to separate them from lldb command line tests. @@ -477,23 +480,29 @@ if "LLDB_EXEC" in os.environ: self.lldbExec = os.environ["LLDB_EXEC"] - if lldb.blacklist: - className = self.__class__.__name__ - classAndMethodName = "%s.%s" % (className, self._testMethodName) - if className in lldb.blacklist: - self.skipTest(lldb.blacklist.get(className)) - elif classAndMethodName in lldb.blacklist: - self.skipTest(lldb.blacklist.get(classAndMethodName)) + try: + if lldb.blacklist: + className = self.__class__.__name__ + classAndMethodName = "%s.%s" % (className, self._testMethodName) + if className in lldb.blacklist: + self.skipTest(lldb.blacklist.get(className)) + elif classAndMethodName in lldb.blacklist: + self.skipTest(lldb.blacklist.get(classAndMethodName)) + except AttributeError: + pass # Python API only test is decorated with @python_api_test, # which also sets the "__python_api_test__" attribute of the # function object to True. - if lldb.just_do_python_api_test: - testMethod = getattr(self, self._testMethodName) - if getattr(testMethod, "__python_api_test__", False): - pass - else: - self.skipTest("Skip lldb command line test") + try: + if lldb.just_do_python_api_test: + testMethod = getattr(self, self._testMethodName) + if getattr(testMethod, "__python_api_test__", False): + pass + else: + self.skipTest("Skip lldb command line test") + except AttributeError: + pass if ("LLDB_WAIT_BETWEEN_TEST_CASES" in os.environ and os.environ["LLDB_WAIT_BETWEEN_TEST_CASES"] == 'YES'): From cdavis at mymail.mines.edu Tue May 31 21:21:46 2011 From: cdavis at mymail.mines.edu (Charles Davis) Date: Tue, 31 May 2011 20:21:46 -0600 Subject: [Lldb-commits] [PATCH] Fix python issues with Makefile build Message-ID: <4DE5A23A.40005@mymail.mines.edu> Hi, My last patch to fix the python build issues with the Makefile system had some issues of its own, and this patch fixes them. - The Swig post-processing scripts are now run. - edit-swig-python-wrapper-file.py has been modified so it can be run from the Makefile. - The issue that prompted me to pass -classic to swig is fixed by this, so -classic isn't passed anymore. Python shouldn't complain anymore about a missing method 'FindDebuggerByID' on the SBDebugger object whenever lldb is run. OK to commit? Chip -------------- next part -------------- An embedded and charset-unspecified text was scrubbed... Name: fix-python-issues.patch Url: http://lists.cs.uiuc.edu/pipermail/lldb-commits/attachments/20110531/ff5efebe/attachment.pl From gclayton at apple.com Tue May 31 21:27:56 2011 From: gclayton at apple.com (Greg Clayton) Date: Tue, 31 May 2011 19:27:56 -0700 Subject: [Lldb-commits] [PATCH] Fix python issues with Makefile build In-Reply-To: <4DE5A23A.40005@mymail.mines.edu> References: <4DE5A23A.40005@mymail.mines.edu> Message-ID: <116E0A4A-88CB-4E31-A047-A5797F39052D@apple.com> Looks good. On May 31, 2011, at 7:21 PM, Charles Davis wrote: > From cdavis at mines.edu Tue May 31 21:33:12 2011 From: cdavis at mines.edu (Charles Davis) Date: Wed, 01 Jun 2011 02:33:12 -0000 Subject: [Lldb-commits] [lldb] r132383 - in /lldb/trunk: scripts/Python/edit-swig-python-wrapper-file.py source/Interpreter/Makefile Message-ID: <20110601023312.CE2472A6C12C@llvm.org> Author: cdavis Date: Tue May 31 21:33:12 2011 New Revision: 132383 URL: http://llvm.org/viewvc/llvm-project?rev=132383&view=rev Log: Fix remaining Python issues leftover from my previous patch. - The Swig post-processing scripts are now run. - edit-swig-python-wrapper-file.py has been modified so it can be run from the Makefile. - The issue that prompted me to pass -classic to swig is fixed by this, so -classic isn't passed anymore. Python shouldn't complain anymore about a missing method 'FindDebuggerByID' on the SBDebugger object whenever lldb is run. Modified: lldb/trunk/scripts/Python/edit-swig-python-wrapper-file.py lldb/trunk/source/Interpreter/Makefile Modified: lldb/trunk/scripts/Python/edit-swig-python-wrapper-file.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/scripts/Python/edit-swig-python-wrapper-file.py?rev=132383&r1=132382&r2=132383&view=diff ============================================================================== --- lldb/trunk/scripts/Python/edit-swig-python-wrapper-file.py (original) +++ lldb/trunk/scripts/Python/edit-swig-python-wrapper-file.py Tue May 31 21:33:12 2011 @@ -20,7 +20,7 @@ # That's what this python script does. # -import os +import os, sys include_python = '#include ' include_python_ifdef = '''#if defined (__APPLE__) @@ -30,8 +30,12 @@ #endif ''' -input_dir_name = os.environ["SRCROOT"] -full_input_name = input_dir_name + "/source/LLDBWrapPython.cpp" +if len (sys.argv) > 1: + input_dir_name = sys.argv[1] + full_input_name = input_dir_name + "/LLDBWrapPython.cpp" +else: + input_dir_name = os.environ["SRCROOT"] + full_input_name = input_dir_name + "/source/LLDBWrapPython.cpp" full_output_name = full_input_name + ".edited" with open(full_input_name, 'r') as f_in: Modified: lldb/trunk/source/Interpreter/Makefile URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Interpreter/Makefile?rev=132383&r1=132382&r2=132383&view=diff ============================================================================== --- lldb/trunk/source/Interpreter/Makefile (original) +++ lldb/trunk/source/Interpreter/Makefile Tue May 31 21:33:12 2011 @@ -34,9 +34,16 @@ LLDBWrapPython.cpp: $(Echo) Generating LLDBWrapPython.cpp - $(Verb) swig -c++ -classic -shadow -python $(LLDB_SWIG_INCLUDE_DIRS) \ + $(Verb) swig -c++ -shadow -python $(LLDB_SWIG_INCLUDE_DIRS) \ -D__STDC_LIMIT_MACROS -outdir "$(LLDB_BIN_DIR)" \ -o LLDBWrapPython.cpp "$(PROJ_SRC_DIR)/$(LLDB_LEVEL)/scripts/lldb.swig" + $(Verb) python "$(PROJ_SRC_DIR)/$(LLDB_LEVEL)/scripts/Python/modify-python-lldb.py" \ + "$(LLDB_BIN_DIR)" + $(Verb) python "$(PROJ_SRC_DIR)/$(LLDB_LEVEL)/scripts/Python/edit-swig-python-wrapper-file.py" \ + "$(PROJ_OBJ_DIR)" + $(Verb) if test -f "$(PROJ_OBJ_DIR)/LLDBWrapPython.cpp.edited"; then \ + mv "$(PROJ_OBJ_DIR)/LLDBWrapPython.cpp.edited" \ + "$(PROJ_OBJ_DIR)/LLDBWrapPython.cpp"; fi $(Verb) cp "$(PROJ_SRC_DIR)/embedded_interpreter.py" "$(PYTHON_DIR)" install-local:: $(PYTHON_DIR)/lldb.py $(PYTHON_DIR)/embedded_interpreter.py $(LIBLLDB) From cdavis at mymail.mines.edu Tue May 31 21:41:29 2011 From: cdavis at mymail.mines.edu (Charles Davis) Date: Tue, 31 May 2011 20:41:29 -0600 Subject: [Lldb-commits] [PATCH] Fix python issues with Makefile build In-Reply-To: <116E0A4A-88CB-4E31-A047-A5797F39052D@apple.com> References: <4DE5A23A.40005@mymail.mines.edu> <116E0A4A-88CB-4E31-A047-A5797F39052D@apple.com> Message-ID: <4DE5A6D9.3040709@mymail.mines.edu> On 5/31/11 8:27 PM, Greg Clayton wrote: > Looks good. Thanks, committed in r132383. > > On May 31, 2011, at 7:21 PM, Charles Davis wrote: > >> > From johnny.chen at apple.com Wed Jun 1 13:40:11 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Wed, 01 Jun 2011 18:40:11 -0000 Subject: [Lldb-commits] [lldb] r132412 - /lldb/trunk/scripts/Python/modify-python-lldb.py Message-ID: <20110601184011.EE4DF2A6C12C@llvm.org> Author: johnny Date: Wed Jun 1 13:40:11 2011 New Revision: 132412 URL: http://llvm.org/viewvc/llvm-project?rev=132412&view=rev Log: Fix comment. Modified: lldb/trunk/scripts/Python/modify-python-lldb.py Modified: lldb/trunk/scripts/Python/modify-python-lldb.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/scripts/Python/modify-python-lldb.py?rev=132412&r1=132411&r2=132412&view=diff ============================================================================== --- lldb/trunk/scripts/Python/modify-python-lldb.py (original) +++ lldb/trunk/scripts/Python/modify-python-lldb.py Wed Jun 1 13:40:11 2011 @@ -20,7 +20,7 @@ # print "output_name is '" + output_name + "'" # -# lldb_iter() should appear before the our first SB* class definition. +# lldb_iter() should appear before our first SB* class definition. # lldb_iter_def = ''' # =================================== From johnny.chen at apple.com Wed Jun 1 14:21:08 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Wed, 01 Jun 2011 19:21:08 -0000 Subject: [Lldb-commits] [lldb] r132417 - /lldb/trunk/scripts/Python/modify-python-lldb.py Message-ID: <20110601192108.D81282A6C12C@llvm.org> Author: johnny Date: Wed Jun 1 14:21:08 2011 New Revision: 132417 URL: http://llvm.org/viewvc/llvm-project?rev=132417&view=rev Log: Make it clear that the Python script modify-python-lldb.py is responsible for post-processing the SWIG-generated lldb.py module by adding comments in the post-processed file in order to facilitate reading of the code. Modified: lldb/trunk/scripts/Python/modify-python-lldb.py Modified: lldb/trunk/scripts/Python/modify-python-lldb.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/scripts/Python/modify-python-lldb.py?rev=132417&r1=132416&r2=132417&view=diff ============================================================================== --- lldb/trunk/scripts/Python/modify-python-lldb.py (original) +++ lldb/trunk/scripts/Python/modify-python-lldb.py Wed Jun 1 14:21:08 2011 @@ -33,6 +33,14 @@ for i in range(size()): yield elem(i) +# ============================================================================== +# The modify-python-lldb.py script is responsible for post-processing this SWIG- +# generated lldb.py module. It is responsible for adding the above lldb_iter() +# function definition as well as the supports, in the following, for iteration +# protocol: __iter__, rich comparison methods: __eq__ and __ne__, truth value +# testing (and built-in operation bool()): __nonzero__, and built-in function +# len(): __len__. +# ============================================================================== ''' # This supports the iteration protocol. From johnny.chen at apple.com Wed Jun 1 17:12:27 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Wed, 01 Jun 2011 22:12:27 -0000 Subject: [Lldb-commits] [lldb] r132430 - in /lldb/trunk/utils/test: main.c run-until-faulted.py Message-ID: <20110601221228.006EC2A6C12C@llvm.org> Author: johnny Date: Wed Jun 1 17:12:27 2011 New Revision: 132430 URL: http://llvm.org/viewvc/llvm-project?rev=132430&view=rev Log: Make 'run-until-faulted.py' script more interesting by modifying the example main.c program to seg fault randomly instead of deterministically. Example: [15:10:43] johnny:/Volumes/data/lldb/svn/trunk/utils/test $ clang -g main.c [15:10:46] johnny:/Volumes/data/lldb/svn/trunk/utils/test $ ./run-until-faulted.py -l $PWD/../../build/Debug/lldb -e a.out lldb command: /Volumes/data/lldb/svn/trunk/utils/test/../../build/Debug/lldb executable: a.out executable options: (lldb) sending 'file a.out' command... file a.out Current executable set to 'a.out' (x86_64). (lldb) sending 'process launch -- ' command... (iteration: 0) process launch -- Process 63630 launched: '/Volumes/data/lldb/svn/trunk/utils/test/a.out' (x86_64) Hello, fault! val=9 Better luck next time! Process 63630 exited with status = 0 (0x00000000) (lldb) sending 'process launch -- ' command... (iteration: 1) process launch -- Process 63633 launched: '/Volumes/data/lldb/svn/trunk/utils/test/a.out' (x86_64) Process 63633 exited with status = 0 (0x00000000) sending 'process launch -- ' command... (iteration: 2) Hello, fault! val=0 Better luck next time! (lldb) process launch -- Process 63637 launched: '/Volumes/data/lldb/svn/trunk/utils/test/a.out' (x86_64) Hello, fault! val=15 Better luck next time! Process 63637 exited with status = 0 (0x00000000) (lldb) sending 'process launch -- ' command... (iteration: 3) process launch -- Process 63640 launched: '/Volumes/data/lldb/svn/trunk/utils/test/a.out' (x86_64) Hello, fault! val=2 Better luck next time! Process 63640 exited with status = 0 (0x00000000) sending 'process launch -- ' command... (iteration: 4) (lldb) process launch -- Process 63643 launched: '/Volumes/data/lldb/svn/trunk/utils/test/a.out' (x86_64) Process 63643 stopped * thread #1: tid = 0x2d03, 0x0000000100000e93 a.out`main + 99 at main.c:11, stop reason = EXC_BAD_ACCESS (code=1, address=0x0) frame #0: 0x0000000100000e93 a.out`main + 99 at main.c:11 8 u_int32_t val = (arc4random() & 0x0f); 9 printf("val=%u\n", val); 10 if (val == 0x07) // Lucky 7 :-) -> 11 printf("Now segfault %d\n", *null_ptr); 12 else 13 printf("Better luck next time!\n"); 14 } (lldb) * thread #1: tid = 0x2d03, 0x0000000100000e93 a.out`main + 99 at main.c:11, stop reason = EXC_BAD_ACCESS (code=1, address=0x0) frame #0: 0x0000000100000e93 a.out`main + 99 at main.c:11 8 u_int32_t val = (arc4random() & 0x0f); 9 printf("val=%u\n", val); 10 if (val == 0x07) // Lucky 7 :-) -> 11 printf("Now segfault %d\n", *null_ptr); 12 else 13 printf("Better luck next time!\n"); 14 } Hello, fault! val=7 (lldb) Modified: lldb/trunk/utils/test/main.c lldb/trunk/utils/test/run-until-faulted.py Modified: lldb/trunk/utils/test/main.c URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/utils/test/main.c?rev=132430&r1=132429&r2=132430&view=diff ============================================================================== --- lldb/trunk/utils/test/main.c (original) +++ lldb/trunk/utils/test/main.c Wed Jun 1 17:12:27 2011 @@ -1,8 +1,14 @@ #include +#include int main(int argc, const char* argv[]) { int *null_ptr = 0; printf("Hello, fault!\n"); - printf("Now segfault %d\n", *null_ptr); + u_int32_t val = (arc4random() & 0x0f); + printf("val=%u\n", val); + if (val == 0x07) // Lucky 7 :-) + printf("Now segfault %d\n", *null_ptr); + else + printf("Better luck next time!\n"); } Modified: lldb/trunk/utils/test/run-until-faulted.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/utils/test/run-until-faulted.py?rev=132430&r1=132429&r2=132430&view=diff ============================================================================== --- lldb/trunk/utils/test/run-until-faulted.py (original) +++ lldb/trunk/utils/test/run-until-faulted.py Wed Jun 1 17:12:27 2011 @@ -33,31 +33,25 @@ prompt = "\(lldb\) " lldb = pexpect.spawn(lldb_command) # Turn on logging for what lldb sends back. - #lldb.logfile_read = sys.stdout + lldb.logfile_read = sys.stdout lldb.expect(prompt) # Now issue the file command. - print "sending file command...." + print "sending 'file %s' command..." % exe lldb.sendline('file %s' % exe) lldb.expect(prompt) - #print "lldb.buffer:--->", lldb.buffer, "<---" - #print "lldb.before:--->", lldb.before, "<---" - #print "lldb.after:--->", lldb.buffer, "<----" # Loop until it faults.... count = 0 #while True: # count = count + 1 - for i in range(10): + for i in range(100): count = i - print "sending process launch -- %s (iteration: %d)" % (exe_options, count) + print "sending 'process launch -- %s' command... (iteration: %d)" % (exe_options, count) lldb.sendline('process launch -- %s' % exe_options) index = lldb.expect(['Process .* exited with status', 'Process .* stopped', pexpect.TIMEOUT]) - #print "lldb.buffer:--->", lldb.buffer, "<---" - #print "lldb.before:--->", lldb.before, "<----" - #print "lldb.after:--->", lldb.buffer, "<----" if index == 0: # We'll try again later. time.sleep(3) @@ -78,10 +72,9 @@ sys.path.append(os.path.join(scriptPath, os.pardir, os.pardir, 'test', 'pexpect-2.4')) parser = OptionParser(usage="""\ +%prog [options] Run a program via lldb until it fails. -The lldb executable is located via your PATH env variable, if not specified. - -Usage: %prog [options] +The lldb executable is located via your PATH env variable, if not specified.\ """) parser.add_option('-l', '--lldb-command', type='string', action='store', metavar='LLDB_COMMAND', From johnny.chen at apple.com Wed Jun 1 18:19:52 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Wed, 01 Jun 2011 23:19:52 -0000 Subject: [Lldb-commits] [lldb] r132435 - /lldb/trunk/source/Commands/CommandObjectThread.cpp Message-ID: <20110601231952.DF6042A6C12C@llvm.org> Author: johnny Date: Wed Jun 1 18:19:52 2011 New Revision: 132435 URL: http://llvm.org/viewvc/llvm-project?rev=132435&view=rev Log: The 'thread backtrace all' logical branch had the if (thread->GetStatus()) condition inverted. rdar://problem/9530511 Modified: lldb/trunk/source/Commands/CommandObjectThread.cpp Modified: lldb/trunk/source/Commands/CommandObjectThread.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectThread.cpp?rev=132435&r1=132434&r2=132435&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectThread.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectThread.cpp Wed Jun 1 18:19:52 2011 @@ -186,10 +186,10 @@ for (uint32_t i = 0; i < num_threads; i++) { ThreadSP thread_sp = process->GetThreadList().GetThreadAtIndex(i); - if (thread_sp->GetStatus (strm, - m_options.m_start, - m_options.m_count, - num_frames_with_source)) + if (!thread_sp->GetStatus (strm, + m_options.m_start, + m_options.m_count, + num_frames_with_source)) { result.AppendErrorWithFormat ("error displaying backtrace for thread: \"0x%4.4x\"\n", i); result.SetStatus (eReturnStatusFailed); From johnny.chen at apple.com Wed Jun 1 18:35:20 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Wed, 01 Jun 2011 23:35:20 -0000 Subject: [Lldb-commits] [lldb] r132438 - /lldb/trunk/test/inferior-crashing/TestInferiorCrashing.py Message-ID: <20110601233520.E1DFC2A6C12C@llvm.org> Author: johnny Date: Wed Jun 1 18:35:20 2011 New Revision: 132438 URL: http://llvm.org/viewvc/llvm-project?rev=132438&view=rev Log: Exercise the 'thread backtrace all' command instead of the currently 'thread backtrace' command. This serves as a regression test against rdar://problem/9530511. Modified: lldb/trunk/test/inferior-crashing/TestInferiorCrashing.py Modified: lldb/trunk/test/inferior-crashing/TestInferiorCrashing.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/inferior-crashing/TestInferiorCrashing.py?rev=132438&r1=132437&r2=132438&view=diff ============================================================================== --- lldb/trunk/test/inferior-crashing/TestInferiorCrashing.py (original) +++ lldb/trunk/test/inferior-crashing/TestInferiorCrashing.py Wed Jun 1 18:35:20 2011 @@ -45,7 +45,7 @@ 'stop reason = EXC_BAD_ACCESS']) # And it should report the correct line number. - self.expect("thread backtrace", + self.expect("thread backtrace all", substrs = ['stop reason = EXC_BAD_ACCESS', 'main.c:%d' % self.line]) From jingham at apple.com Wed Jun 1 18:52:04 2011 From: jingham at apple.com (Jim Ingham) Date: Wed, 01 Jun 2011 23:52:04 -0000 Subject: [Lldb-commits] [lldb] r132439 - /lldb/trunk/lldb.xcodeproj/xcshareddata/xcschemes/lldb-tool.xcscheme Message-ID: <20110601235204.5EE452A6C12C@llvm.org> Author: jingham Date: Wed Jun 1 18:52:04 2011 New Revision: 132439 URL: http://llvm.org/viewvc/llvm-project?rev=132439&view=rev Log: Remove the "a.out" argument from somewhere on Greg's machine in the lldb-tool run scheme. Modified: lldb/trunk/lldb.xcodeproj/xcshareddata/xcschemes/lldb-tool.xcscheme Modified: lldb/trunk/lldb.xcodeproj/xcshareddata/xcschemes/lldb-tool.xcscheme URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/lldb.xcodeproj/xcshareddata/xcschemes/lldb-tool.xcscheme?rev=132439&r1=132438&r2=132439&view=diff ============================================================================== --- lldb/trunk/lldb.xcodeproj/xcshareddata/xcschemes/lldb-tool.xcscheme (original) +++ lldb/trunk/lldb.xcodeproj/xcshareddata/xcschemes/lldb-tool.xcscheme Wed Jun 1 18:52:04 2011 @@ -78,7 +78,8 @@ useCustomWorkingDirectory = "NO" customWorkingDirectory = "/Volumes/work/gclayton/Documents/devb/attach" buildConfiguration = "Debug" - ignoresPersistentStateOnLaunch = "YES"> + ignoresPersistentStateOnLaunch = "YES" + enablesOpenGLESFrameCapture = "YES"> - - - - Author: jingham Date: Wed Jun 1 18:52:47 2011 New Revision: 132440 URL: http://llvm.org/viewvc/llvm-project?rev=132440&view=rev Log: If somebody has deleted the breakpoint while we are testing the condition, then just continue. Modified: lldb/trunk/source/Target/ThreadPlanTestCondition.cpp Modified: lldb/trunk/source/Target/ThreadPlanTestCondition.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/ThreadPlanTestCondition.cpp?rev=132440&r1=132439&r2=132440&view=diff ============================================================================== --- lldb/trunk/source/Target/ThreadPlanTestCondition.cpp (original) +++ lldb/trunk/source/Target/ThreadPlanTestCondition.cpp Wed Jun 1 18:52:47 2011 @@ -15,6 +15,7 @@ // Project includes #include "lldb/lldb-private-log.h" +#include "lldb/Breakpoint/Breakpoint.h" #include "lldb/Breakpoint/BreakpointLocation.h" #include "lldb/Core/Log.h" #include "lldb/Core/Stream.h" @@ -109,22 +110,31 @@ m_did_stop = true; } - // Now we have to change the event to a breakpoint event and mark it up appropriately: - Process::ProcessEventData *new_data = new Process::ProcessEventData (m_thread.GetProcess().GetSP(), eStateStopped); - event_ptr->SetData(new_data); - event_ptr->SetType(Process::eBroadcastBitStateChanged); - SetStopInfo(StopInfo::CreateStopReasonWithBreakpointSiteID (m_thread, - m_break_loc_sp->GetBreakpointSite()->GetID(), - m_did_stop)); - if (m_did_stop) + // One tricky bit, somebody might have disabled/deleted the breakpoint while we were running this condition, if so we + // should just continue. If the breakpoint gets disabled, then its "site" will be null'ed out, so we can't report + // this as a breakpoint event any more, since we can't reconstruct it's site. So just pass the event on. + if (!m_break_loc_sp->IsEnabled()) { - Process::ProcessEventData::SetRestartedInEvent (event_ptr, false); + m_did_stop = false; } else { - Process::ProcessEventData::SetRestartedInEvent (event_ptr, true); + // Now we have to change the event to a breakpoint event and mark it up appropriately: + Process::ProcessEventData *new_data = new Process::ProcessEventData (m_thread.GetProcess().GetSP(), eStateStopped); + event_ptr->SetData(new_data); + event_ptr->SetType(Process::eBroadcastBitStateChanged); + SetStopInfo(StopInfo::CreateStopReasonWithBreakpointSiteID (m_thread, + m_break_loc_sp->GetBreakpointSite()->GetID(), + m_did_stop)); + if (m_did_stop) + { + Process::ProcessEventData::SetRestartedInEvent (event_ptr, false); + } + else + { + Process::ProcessEventData::SetRestartedInEvent (event_ptr, true); + } } - SetPlanComplete(); return m_did_stop; } From johnny.chen at apple.com Wed Jun 1 18:53:57 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Wed, 01 Jun 2011 23:53:57 -0000 Subject: [Lldb-commits] [lldb] r132441 - /lldb/trunk/utils/test/run-until-faulted.py Message-ID: <20110601235357.868B02A6C12C@llvm.org> Author: johnny Date: Wed Jun 1 18:53:57 2011 New Revision: 132441 URL: http://llvm.org/viewvc/llvm-project?rev=132441&view=rev Log: Turn off printing of command sent to the pexpect-spawned child process to make the script more robotic. Modified: lldb/trunk/utils/test/run-until-faulted.py Modified: lldb/trunk/utils/test/run-until-faulted.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/utils/test/run-until-faulted.py?rev=132441&r1=132440&r2=132441&view=diff ============================================================================== --- lldb/trunk/utils/test/run-until-faulted.py (original) +++ lldb/trunk/utils/test/run-until-faulted.py Wed Jun 1 18:53:57 2011 @@ -37,7 +37,7 @@ lldb.expect(prompt) # Now issue the file command. - print "sending 'file %s' command..." % exe + #print "sending 'file %s' command..." % exe lldb.sendline('file %s' % exe) lldb.expect(prompt) @@ -47,7 +47,7 @@ # count = count + 1 for i in range(100): count = i - print "sending 'process launch -- %s' command... (iteration: %d)" % (exe_options, count) + #print "sending 'process launch -- %s' command... (iteration: %d)" % (exe_options, count) lldb.sendline('process launch -- %s' % exe_options) index = lldb.expect(['Process .* exited with status', 'Process .* stopped', From gclayton at apple.com Wed Jun 1 20:26:44 2011 From: gclayton at apple.com (Greg Clayton) Date: Thu, 02 Jun 2011 01:26:44 -0000 Subject: [Lldb-commits] [lldb] r132449 - /lldb/trunk/source/Symbol/ClangASTContext.cpp Message-ID: <20110602012644.B8B962A6C12C@llvm.org> Author: gclayton Date: Wed Jun 1 20:26:44 2011 New Revision: 132449 URL: http://llvm.org/viewvc/llvm-project?rev=132449&view=rev Log: Use the correct accessor on CXXRecordDecl to know when a C++ class is dynamic. 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=132449&r1=132448&r2=132449&view=diff ============================================================================== --- lldb/trunk/source/Symbol/ClangASTContext.cpp (original) +++ lldb/trunk/source/Symbol/ClangASTContext.cpp Wed Jun 1 20:26:44 2011 @@ -4070,7 +4070,7 @@ { if (GetCompleteQualType (ast, pointee_qual_type)) { - success = cxx_record_decl->isPolymorphic() || cxx_record_decl->isAbstract(); + success = cxx_record_decl->isDynamicClass(); } else { From johnny.chen at apple.com Thu Jun 2 13:02:15 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Thu, 02 Jun 2011 18:02:15 -0000 Subject: [Lldb-commits] [lldb] r132470 - /lldb/trunk/source/Commands/CommandObjectThread.cpp Message-ID: <20110602180215.850072A6C12C@llvm.org> Author: johnny Date: Thu Jun 2 13:02:15 2011 New Revision: 132470 URL: http://llvm.org/viewvc/llvm-project?rev=132470&view=rev Log: Add comment about Thread::GetStatus(), which returns the number of frames shown. Modified: lldb/trunk/source/Commands/CommandObjectThread.cpp Modified: lldb/trunk/source/Commands/CommandObjectThread.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectThread.cpp?rev=132470&r1=132469&r2=132470&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectThread.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectThread.cpp Thu Jun 2 13:02:15 2011 @@ -165,6 +165,7 @@ ExecutionContext exe_ctx(m_interpreter.GetExecutionContext()); if (exe_ctx.thread) { + // Thread::GetStatus() returns the number of frames shown. if (exe_ctx.thread->GetStatus (strm, m_options.m_start, m_options.m_count, From ctice at apple.com Thu Jun 2 14:18:56 2011 From: ctice at apple.com (Caroline Tice) Date: Thu, 02 Jun 2011 19:18:56 -0000 Subject: [Lldb-commits] [lldb] r132475 - in /lldb/trunk: include/lldb/Core/Debugger.h include/lldb/Core/InputReaderStack.h lldb.xcodeproj/project.pbxproj source/Core/Debugger.cpp source/Core/InputReaderStack.cpp Message-ID: <20110602191856.2872B2A6C12C@llvm.org> Author: ctice Date: Thu Jun 2 14:18:55 2011 New Revision: 132475 URL: http://llvm.org/viewvc/llvm-project?rev=132475&view=rev Log: Create new class, InputReaderStack, to better handle mutexes around input readers and prevent deadlocking; modify Debugger to use the new class. Added: lldb/trunk/include/lldb/Core/InputReaderStack.h lldb/trunk/source/Core/InputReaderStack.cpp Modified: lldb/trunk/include/lldb/Core/Debugger.h lldb/trunk/lldb.xcodeproj/project.pbxproj lldb/trunk/source/Core/Debugger.cpp Modified: lldb/trunk/include/lldb/Core/Debugger.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/Debugger.h?rev=132475&r1=132474&r2=132475&view=diff ============================================================================== --- lldb/trunk/include/lldb/Core/Debugger.h (original) +++ lldb/trunk/include/lldb/Core/Debugger.h Thu Jun 2 14:18:55 2011 @@ -18,6 +18,7 @@ #include #include "lldb/Core/Communication.h" +#include "lldb/Core/InputReaderStack.h" #include "lldb/Core/Listener.h" #include "lldb/Core/StreamFile.h" #include "lldb/Core/SourceManager.h" @@ -451,8 +452,7 @@ SourceManager m_source_manager; std::auto_ptr m_command_interpreter_ap; - Mutex m_input_readers_mutex; - std::stack m_input_readers; + InputReaderStack m_input_reader_stack; std::string m_input_reader_data; private: Added: lldb/trunk/include/lldb/Core/InputReaderStack.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/InputReaderStack.h?rev=132475&view=auto ============================================================================== --- lldb/trunk/include/lldb/Core/InputReaderStack.h (added) +++ lldb/trunk/include/lldb/Core/InputReaderStack.h Thu Jun 2 14:18:55 2011 @@ -0,0 +1,58 @@ +//===-- InputReaderStack.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_InputReaderStack_h_ +#define liblldb_InputReaderStack_h_ + +#include + +#include "lldb/lldb-private.h" +#include "lldb/Host/Mutex.h" + +namespace lldb_private { + +class InputReaderStack +{ +public: + + InputReaderStack (); + + ~InputReaderStack (); + + size_t + GetSize () const; + + void + Push (const lldb::InputReaderSP& reader_sp); + + bool + IsEmpty () const; + + lldb::InputReaderSP + Top (); + + void + Pop (); + + Mutex & + GetStackMutex (); + +protected: + + std::stack m_input_readers; + mutable Mutex m_input_readers_mutex; + +private: + + DISALLOW_COPY_AND_ASSIGN (InputReaderStack); +}; + +} // namespace lldb_private + +#endif // liblldb_InputReaderStack_h_ Modified: lldb/trunk/lldb.xcodeproj/project.pbxproj URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/lldb.xcodeproj/project.pbxproj?rev=132475&r1=132474&r2=132475&view=diff ============================================================================== --- lldb/trunk/lldb.xcodeproj/project.pbxproj (original) +++ lldb/trunk/lldb.xcodeproj/project.pbxproj Thu Jun 2 14:18:55 2011 @@ -409,6 +409,8 @@ 9A3576A8116E9AB700E8ED2F /* SBHostOS.h in Headers */ = {isa = PBXBuildFile; fileRef = 9A3576A7116E9AB700E8ED2F /* SBHostOS.h */; settings = {ATTRIBUTES = (Public, ); }; }; 9A3576AA116E9AC700E8ED2F /* SBHostOS.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9A3576A9116E9AC700E8ED2F /* SBHostOS.cpp */; }; 9A4F35101368A51A00823F52 /* StreamAsynchronousIO.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9A4F350F1368A51A00823F52 /* StreamAsynchronousIO.cpp */; }; + 9A9E1EFF1398086D005AC039 /* InputReaderStack.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9A9E1EFE1398086D005AC039 /* InputReaderStack.cpp */; }; + 9A9E1F0113980943005AC039 /* InputReaderStack.h in Headers */ = {isa = PBXBuildFile; fileRef = 9A9E1F0013980943005AC039 /* InputReaderStack.h */; }; 9AA69DA61188F52100D753A0 /* PseudoTerminal.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2682F16A115EDA0D00CCFF99 /* PseudoTerminal.cpp */; }; 9AA69DAF118A023300D753A0 /* SBInputReader.h in Headers */ = {isa = PBXBuildFile; fileRef = 9AA69DAE118A023300D753A0 /* SBInputReader.h */; settings = {ATTRIBUTES = (Public, ); }; }; 9AA69DB1118A024600D753A0 /* SBInputReader.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9AA69DB0118A024600D753A0 /* SBInputReader.cpp */; }; @@ -1200,6 +1202,8 @@ 9A9831081125FC5800A56CB0 /* SBTarget.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SBTarget.h; path = include/lldb/API/SBTarget.h; sourceTree = ""; }; 9A9831091125FC5800A56CB0 /* SBThread.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = SBThread.cpp; path = source/API/SBThread.cpp; sourceTree = ""; }; 9A98310A1125FC5800A56CB0 /* SBThread.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SBThread.h; path = include/lldb/API/SBThread.h; sourceTree = ""; }; + 9A9E1EFE1398086D005AC039 /* InputReaderStack.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = InputReaderStack.cpp; path = source/Core/InputReaderStack.cpp; sourceTree = ""; }; + 9A9E1F0013980943005AC039 /* InputReaderStack.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = InputReaderStack.h; path = include/lldb/Core/InputReaderStack.h; sourceTree = ""; }; 9AA69DAE118A023300D753A0 /* SBInputReader.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SBInputReader.h; path = include/lldb/API/SBInputReader.h; sourceTree = ""; }; 9AA69DB0118A024600D753A0 /* SBInputReader.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = SBInputReader.cpp; path = source/API/SBInputReader.cpp; sourceTree = ""; }; 9AA69DB5118A027A00D753A0 /* InputReader.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = InputReader.cpp; path = source/Core/InputReader.cpp; sourceTree = ""; }; @@ -1889,6 +1893,8 @@ 26BC7D6410F1B77400F91463 /* Flags.h */, 9AA69DBB118A029E00D753A0 /* InputReader.h */, 9AA69DB5118A027A00D753A0 /* InputReader.cpp */, + 9A9E1F0013980943005AC039 /* InputReaderStack.h */, + 9A9E1EFE1398086D005AC039 /* InputReaderStack.cpp */, 26BC7D6510F1B77400F91463 /* IOStreamMacros.h */, 26BC7D6610F1B77400F91463 /* Language.h */, 26BC7E7D10F1B85900F91463 /* Language.cpp */, @@ -2619,6 +2625,7 @@ isa = PBXHeadersBuildPhase; buildActionMask = 2147483647; files = ( + 9A9E1F0113980943005AC039 /* InputReaderStack.h in Headers */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -3201,6 +3208,7 @@ 26DB3E1F1379E7AD0080DC73 /* ABISysV_x86_64.cpp in Sources */, 26A69C5F137A17A500262477 /* RegisterValue.cpp in Sources */, 2690B3711381D5C300ECFBAE /* Memory.cpp in Sources */, + 9A9E1EFF1398086D005AC039 /* InputReaderStack.cpp in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; Modified: lldb/trunk/source/Core/Debugger.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/Debugger.cpp?rev=132475&r1=132474&r2=132475&view=diff ============================================================================== --- lldb/trunk/source/Core/Debugger.cpp (original) +++ lldb/trunk/source/Core/Debugger.cpp Thu Jun 2 14:18:55 2011 @@ -230,8 +230,7 @@ m_listener ("lldb.Debugger"), m_source_manager (), m_command_interpreter_ap (new CommandInterpreter (*this, eScriptLanguageDefault, false)), - m_input_readers_mutex (Mutex::eMutexTypeRecursive), - m_input_readers (), + m_input_reader_stack (), m_input_reader_data () { m_command_interpreter_ap->Initialize (); @@ -357,14 +356,13 @@ { InputReaderSP reader_sp; - Mutex::Locker locker (m_input_readers_mutex); - if (!m_input_readers.empty()) + if (!m_input_reader_stack.IsEmpty()) { // Clear any finished readers from the stack while (CheckIfTopInputReaderIsDone()) ; - if (!m_input_readers.empty()) - reader_sp = m_input_readers.top(); + if (!m_input_reader_stack.IsEmpty()) + reader_sp = m_input_reader_stack.Top(); } return reader_sp; @@ -424,9 +422,8 @@ { m_input_reader_data.clear(); - Mutex::Locker locker (m_input_readers_mutex); // The bottom input reader should be the main debugger input reader. We do not want to close that one here. - while (m_input_readers.size() > 1) + while (m_input_reader_stack.GetSize() > 1) { InputReaderSP reader_sp (GetCurrentInputReader ()); if (reader_sp) @@ -479,8 +476,7 @@ if (m_input_reader_data.empty()) return; - Mutex::Locker locker (m_input_readers_mutex); - while (!m_input_readers.empty() && !m_input_reader_data.empty()) + while (!m_input_reader_stack.IsEmpty() && !m_input_reader_data.empty()) { // Get the input reader from the top of the stack InputReaderSP reader_sp (GetCurrentInputReader ()); @@ -519,8 +515,7 @@ if (top_reader_sp) top_reader_sp->Notify (eInputReaderDeactivate); - Mutex::Locker locker (m_input_readers_mutex); - m_input_readers.push (reader_sp); + m_input_reader_stack.Push (reader_sp); reader_sp->Notify (eInputReaderActivate); ActivateInputReader (reader_sp); } @@ -532,22 +527,21 @@ // The reader on the stop of the stack is done, so let the next // read on the stack referesh its prompt and if there is one... - Mutex::Locker locker (m_input_readers_mutex); - if (!m_input_readers.empty()) + if (!m_input_reader_stack.IsEmpty()) { // Cannot call GetCurrentInputReader here, as that would cause an infinite loop. - InputReaderSP reader_sp(m_input_readers.top()); + InputReaderSP reader_sp(m_input_reader_stack.Top()); if (!pop_reader_sp || pop_reader_sp.get() == reader_sp.get()) { - m_input_readers.pop (); + m_input_reader_stack.Pop (); reader_sp->Notify (eInputReaderDeactivate); reader_sp->Notify (eInputReaderDone); result = true; - if (!m_input_readers.empty()) + if (!m_input_reader_stack.IsEmpty()) { - reader_sp = m_input_readers.top(); + reader_sp = m_input_reader_stack.Top(); if (reader_sp) { ActivateInputReader (reader_sp); @@ -563,11 +557,10 @@ Debugger::CheckIfTopInputReaderIsDone () { bool result = false; - Mutex::Locker locker (m_input_readers_mutex); - if (!m_input_readers.empty()) + if (!m_input_reader_stack.IsEmpty()) { // Cannot call GetCurrentInputReader here, as that would cause an infinite loop. - InputReaderSP reader_sp(m_input_readers.top()); + InputReaderSP reader_sp(m_input_reader_stack.Top()); if (reader_sp && reader_sp->IsDone()) { Added: lldb/trunk/source/Core/InputReaderStack.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/InputReaderStack.cpp?rev=132475&view=auto ============================================================================== --- lldb/trunk/source/Core/InputReaderStack.cpp (added) +++ lldb/trunk/source/Core/InputReaderStack.cpp Thu Jun 2 14:18:55 2011 @@ -0,0 +1,80 @@ +//===-- InputReaderStack.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/Core/InputReaderStack.h" + +// C Includes +// C++ Includes +// Other libraries and framework includes +// Project includes + + +using namespace lldb; +using namespace lldb_private; + +InputReaderStack::InputReaderStack () : + m_input_readers (), + m_input_readers_mutex (Mutex::eMutexTypeRecursive) +{ +} + +InputReaderStack::~InputReaderStack () +{ +} + +size_t +InputReaderStack::GetSize () const +{ + Mutex::Locker locker (m_input_readers_mutex); + return m_input_readers.size(); +} + +void +InputReaderStack::Push (const lldb::InputReaderSP& reader_sp) +{ + if (reader_sp) + { + Mutex::Locker locker (m_input_readers_mutex); + m_input_readers.push (reader_sp); + } +} + +bool +InputReaderStack::IsEmpty () const +{ + Mutex::Locker locker (m_input_readers_mutex); + return m_input_readers.empty(); +} + +InputReaderSP +InputReaderStack::Top () +{ + InputReaderSP input_reader_sp; + { + Mutex::Locker locker (m_input_readers_mutex); + if (!m_input_readers.empty()) + input_reader_sp = m_input_readers.top(); + } + + return input_reader_sp; +} + +void +InputReaderStack::Pop () +{ + Mutex::Locker locker (m_input_readers_mutex); + if (!m_input_readers.empty()) + m_input_readers.pop(); +} + +Mutex & +InputReaderStack::GetStackMutex () +{ + return m_input_readers_mutex; +} From johnny.chen at apple.com Thu Jun 2 16:00:34 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Thu, 02 Jun 2011 21:00:34 -0000 Subject: [Lldb-commits] [lldb] r132484 - /lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp Message-ID: <20110602210034.61F3D2A6C12C@llvm.org> Author: johnny Date: Thu Jun 2 16:00:34 2011 New Revision: 132484 URL: http://llvm.org/viewvc/llvm-project?rev=132484&view=rev Log: EmulateShiftReg() also accepts shifter type of SRType_ROR. Modified: lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp Modified: lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp?rev=132484&r1=132483&r2=132484&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp (original) +++ lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp Thu Jun 2 16:00:34 2011 @@ -3198,7 +3198,10 @@ bool EmulateInstructionARM::EmulateShiftReg (const uint32_t opcode, const ARMEncoding encoding, ARM_ShifterType shift_type) { - assert(shift_type == SRType_ASR || shift_type == SRType_LSL || shift_type == SRType_LSR); + assert(shift_type == SRType_ASR + || shift_type == SRType_LSL + || shift_type == SRType_LSR + || shift_type == SRType_ROR); bool success = false; From ctice at apple.com Thu Jun 2 17:09:43 2011 From: ctice at apple.com (Caroline Tice) Date: Thu, 02 Jun 2011 22:09:43 -0000 Subject: [Lldb-commits] [lldb] r132492 - /lldb/trunk/source/Interpreter/ScriptInterpreterPython.cpp Message-ID: <20110602220943.4582D2A6C12C@llvm.org> Author: ctice Date: Thu Jun 2 17:09:43 2011 New Revision: 132492 URL: http://llvm.org/viewvc/llvm-project?rev=132492&view=rev Log: Use Py_InitializeEx(0) instead of Py_Initialize, to prevent Python from installing its own signal handlers. Modified: lldb/trunk/source/Interpreter/ScriptInterpreterPython.cpp Modified: lldb/trunk/source/Interpreter/ScriptInterpreterPython.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Interpreter/ScriptInterpreterPython.cpp?rev=132492&r1=132491&r2=132492&view=diff ============================================================================== --- lldb/trunk/source/Interpreter/ScriptInterpreterPython.cpp (original) +++ lldb/trunk/source/Interpreter/ScriptInterpreterPython.cpp Thu Jun 2 17:09:43 2011 @@ -1540,7 +1540,7 @@ } PyEval_InitThreads (); - Py_Initialize (); + Py_InitializeEx (0); PyObject *compiled_module = Py_CompileString (embedded_interpreter_string, "embedded_interpreter.py", From gclayton at apple.com Thu Jun 2 17:21:38 2011 From: gclayton at apple.com (Greg Clayton) Date: Thu, 02 Jun 2011 22:21:38 -0000 Subject: [Lldb-commits] [lldb] r132498 - /lldb/trunk/scripts/disasm-gdb-remote.pl Message-ID: <20110602222138.AE3EB2A6C12C@llvm.org> Author: gclayton Date: Thu Jun 2 17:21:38 2011 New Revision: 132498 URL: http://llvm.org/viewvc/llvm-project?rev=132498&view=rev Log: Update the handle many of the packets that our current LLDB debugserver handles. Also fixed a case where the packet wouldn't be dumped if it returned the unimplemented packet. Modified: lldb/trunk/scripts/disasm-gdb-remote.pl Modified: lldb/trunk/scripts/disasm-gdb-remote.pl URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/scripts/disasm-gdb-remote.pl?rev=132498&r1=132497&r2=132498&view=diff ============================================================================== --- lldb/trunk/scripts/disasm-gdb-remote.pl (original) +++ lldb/trunk/scripts/disasm-gdb-remote.pl Thu Jun 2 17:21:38 2011 @@ -5,7 +5,7 @@ #---------------------------------------------------------------------- # Globals #---------------------------------------------------------------------- -our $unsupported_str = "UNSUPPORTED"; +our $unimplemented_str = "UNIMPLEMENTED"; our $success_str = "OK"; our $swap = 1; our $addr_size = 4; @@ -429,7 +429,14 @@ if (length($opt_r)) { - $registers_aref = $reg_map{$opt_r}; + if (exists $reg_map{$opt_r}) + { + $registers_aref = $reg_map{$opt_r}; + } + else + { + die "Can't get registers group for '$opt_r'\n"; + } } sub extract_key_value_pairs @@ -656,6 +663,7 @@ # 'q' command #---------------------------------------------------------------------- our $gen_query_cmd; +our $qRegisterInfo_reg_num = -1; sub dump_general_query_cmd { $gen_query_cmd = join('', at _); @@ -711,10 +719,9 @@ elsif (index($gen_query_cmd, 'qRegisterInfo') == 0) { @_ = splice(@_, length('qRegisterInfo')); - my $reg = get_hex(\@_); - $reg == 0 and $registers_aref = []; - - printf "get_dynamic_register_info ($reg)"; + $qRegisterInfo_reg_num = get_hex(\@_); + + printf "get_dynamic_register_info ($qRegisterInfo_reg_num)"; } else { @@ -729,41 +736,50 @@ sub dump_general_query_rsp { my $gen_query_rsp = join('', at _); - + my $gen_query_rsp_len = length ($gen_query_rsp); if ($gen_query_cmd eq 'qC' and index($gen_query_rsp, 'QC') == 0) { shift @_; shift @_; my $pid = get_hex(\@_); - printf("get_current_pid () => $pid_format\n", $pid); + printf("pid = $pid_format\n", $pid); return; } elsif (index($gen_query_cmd, 'qRegisterInfo') == 0) { - if (index($gen_query_rsp, 'name') == 0) + if ($gen_query_rsp_len == 0) { - my @name_and_values = split (/;/, $gen_query_rsp); - - my $reg_name = undef; - my $byte_size = 0; - foreach (@name_and_values) + print "$unimplemented_str\n"; + } + else + { + if (index($gen_query_rsp, 'name') == 0) { - my ($name, $value) = split /:/; - if ($name eq "name") { $reg_name = $value; } - elsif ($name eq "bitsize") { $byte_size = $value / 8; last; } + $qRegisterInfo_reg_num == 0 and $registers_aref = []; + + my @name_and_values = split (/;/, $gen_query_rsp); + + my $reg_name = undef; + my $byte_size = 0; + foreach (@name_and_values) + { + my ($name, $value) = split /:/; + if ($name eq "name") { $reg_name = $value; } + elsif ($name eq "bitsize") { $byte_size = $value / 8; last; } + } + if (defined $reg_name and $byte_size > 0) + { + if ($byte_size == 4) {push @$registers_aref, { name => $reg_name, info => $reg32_href };} + elsif ($byte_size == 8) {push @$registers_aref, { name => $reg_name, info => $reg64_href };} + elsif ($byte_size == 10) {push @$registers_aref, { name => $reg_name, info => $reg80_href };} + elsif ($byte_size == 12) {push @$registers_aref, { name => $reg_name, info => $float96_href };} + elsif ($byte_size == 16) {push @$registers_aref, { name => $reg_name, info => $reg128_href };} + } } - if (defined $reg_name and $byte_size > 0) + elsif ($gen_query_rsp_len == 3 and index($gen_query_rsp, 'E') == 0) { - if ($byte_size == 4) {push @$registers_aref, { name => $reg_name, info => $reg32_href };} - elsif ($byte_size == 8) {push @$registers_aref, { name => $reg_name, info => $reg64_href };} - elsif ($byte_size == 10) {push @$registers_aref, { name => $reg_name, info => $reg80_href };} - elsif ($byte_size == 12) {push @$registers_aref, { name => $reg_name, info => $float96_href };} - elsif ($byte_size == 16) {push @$registers_aref, { name => $reg_name, info => $reg128_href };} + calculate_max_register_name_length(); } } - else - { - calculate_max_register_name_length(); - } } elsif ($gen_query_cmd =~ 'qThreadStopInfo') { @@ -803,6 +819,21 @@ # packet payload size supported by gdb printf("SetMaxPayloadSize ( 0x%x (%u))", $max_payload_size, $max_payload_size); } + elsif (index ($gen_query_cmd, 'QSetSTDIN:') == 0) + { + @_ = splice(@_, length('QSetSTDIN:')); + printf ("SetSTDIN (path ='%s')\n", get_hex_string (\@_)); + } + elsif (index ($gen_query_cmd, 'QSetSTDOUT:') == 0) + { + @_ = splice(@_, length('QSetSTDOUT:')); + printf ("SetSTDOUT (path ='%s')\n", get_hex_string (\@_)); + } + elsif (index ($gen_query_cmd, 'QSetSTDERR:') == 0) + { + @_ = splice(@_, length('QSetSTDERR:')); + printf ("SetSTDERR (path ='%s')\n", get_hex_string (\@_)); + } else { print $gen_query_cmd; @@ -909,7 +940,6 @@ } } - #---------------------------------------------------------------------- # '_m' - deallocate memory command (LLDB extension) # @@ -934,15 +964,17 @@ sub dump_read_single_register_cmd { my $cmd = shift; - $reg_cmd_reg = get_hex(\@_); + my $reg_num = get_hex(\@_); my $thread = get_thread_from_thread_suffix (\@_); + my $reg_href = $$registers_aref[$reg_num]; + if (defined $thread) { - print "read_register ( reg = \"$$registers_aref[$reg_cmd_reg]->{name}\", thread = $thread )\n"; + print "read_register ( reg = \"$reg_href->{name}\", thread = $thread )\n"; } else { - print "read_register ( reg = \"$$registers_aref[$reg_cmd_reg]->{name}\" )\n"; + print "read_register ( reg = \"$reg_href->{name}\" )\n"; } } @@ -1207,9 +1239,6 @@ #---------------------------------------------------------------------- sub dump_attach_wait_command { -# print "dump_extended_continue_cmd ( "; -# dump_chars(@_); -# print " )\n"; print "attach_wait ( "; while (@_) { @@ -1224,9 +1253,6 @@ #---------------------------------------------------------------------- sub dump_extended_continue_cmd { -# print "dump_extended_continue_cmd ( "; -# dump_chars(@_); -# print " )\n"; print "extended_continue ( "; my $cmd = shift; if ($cmd eq '?') @@ -1293,7 +1319,14 @@ #---------------------------------------------------------------------- sub dump_extended_continue_rsp { - print "extended_continue ( " . join('', at _) . " )\n"; + if (scalar(@_) == 0) + { + print "$unimplemented_str\n"; + } + else + { + print "extended_continue supports " . join('', at _) . "\n"; + } } #---------------------------------------------------------------------- @@ -1618,6 +1651,20 @@ get_hex(shift); } +sub get_hex_string +{ + my $arrayref = shift; + my $str = ''; + while ($$arrayref[0] =~ /[0-9a-fA-F]/ and $$arrayref[1] =~ /[0-9a-fA-F]/) + { + my $hi_nibble = hex(shift(@$arrayref)); + my $lo_nibble = hex(shift(@$arrayref)); + my $byte = ($hi_nibble << 4) | $lo_nibble; + $str .= chr($byte); + } + return $str; +} + sub dump_stop_reply_data { while ($#_ >= 0) @@ -1731,9 +1778,10 @@ { my $cmd_aref = shift; - if (@$cmd_aref == 0) + my $cmd_len = scalar(@$cmd_aref); + if ($cmd_len == 0) { - print "$unsupported_str\n"; + print "$unimplemented_str\n"; return 1; } @@ -1744,7 +1792,7 @@ return 1; } - if (index($response, 'E') == 0) + if ($cmd_len == 3 and index($response, 'E') == 0) { print "ERROR: " . substr($response, 1) . "\n"; return 1; @@ -1800,7 +1848,7 @@ { if (rsp_is_unsupported(@cmd_chars)) { - print "$unsupported_str\n"; + print "$unimplemented_str\n"; return; } elsif (rsp_is_OK(@cmd_chars)) @@ -1928,7 +1976,7 @@ } elsif ($line =~ /read packet: (.*)/) { - if ($1 =~ /\$([^#]+)#[0-9a-fA-F]{2}/) + if ($1 =~ /\$([^#]*)#[0-9a-fA-F]{2}/) { $opt_g and print "response: $1\n"; my @raw_rsp_bytes = split(/ */, $1); From gclayton at apple.com Thu Jun 2 17:22:38 2011 From: gclayton at apple.com (Greg Clayton) Date: Thu, 02 Jun 2011 22:22:38 -0000 Subject: [Lldb-commits] [lldb] r132499 - in /lldb/trunk/source/Plugins/Process/gdb-remote: ProcessGDBRemote.cpp ProcessGDBRemote.h Message-ID: <20110602222238.77A512A6C12C@llvm.org> Author: gclayton Date: Thu Jun 2 17:22:38 2011 New Revision: 132499 URL: http://llvm.org/viewvc/llvm-project?rev=132499&view=rev Log: Make sure we don't lose our stop reply packet in the case where the other GDB server doesn't support the LLDB specific qThreadStopInfo packet. Modified: lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h Modified: lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp?rev=132499&r1=132498&r2=132499&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp (original) +++ lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp Thu Jun 2 17:22:38 2011 @@ -391,10 +391,9 @@ // We have a valid process SetID (pid); UpdateThreadListIfNeeded (); - StringExtractorGDBRemote response; - if (m_gdb_comm.SendPacketAndWaitForResponse("?", 1, response, false)) + if (m_gdb_comm.SendPacketAndWaitForResponse("?", 1, m_last_stop_packet, false)) { - const StateType state = SetThreadStopInfo (response); + const StateType state = SetThreadStopInfo (m_last_stop_packet); if (state == eStateStopped) { SetPrivateState (state); @@ -550,10 +549,9 @@ return error; } - StringExtractorGDBRemote response; - if (m_gdb_comm.SendPacketAndWaitForResponse("?", 1, response, false)) + if (m_gdb_comm.SendPacketAndWaitForResponse("?", 1, m_last_stop_packet, false)) { - SetPrivateState (SetThreadStopInfo (response)); + SetPrivateState (SetThreadStopInfo (m_last_stop_packet)); if (!disable_stdio) { @@ -1097,6 +1095,7 @@ StateType ProcessGDBRemote::SetThreadStopInfo (StringExtractor& stop_packet) { + stop_packet.SetFilePos (0); const char stop_type = stop_packet.GetChar(); switch (stop_type) { @@ -1245,22 +1244,10 @@ void ProcessGDBRemote::RefreshStateAfterStop () { - // FIXME - add a variable to tell that we're in the middle of attaching if we - // need to know that. - // We must be attaching if we don't already have a valid architecture -// if (!GetTarget().GetArchitecture().IsValid()) -// { -// Module *exe_module = GetTarget().GetExecutableModule().get(); -// if (exe_module) -// m_arch_spec = exe_module->GetArchitecture(); -// } - // Let all threads recover from stopping and do any clean up based // on the previous thread state (if any). m_thread_list.RefreshStateAfterStop(); - - // Discover new threads: - UpdateThreadListIfNeeded (); + SetThreadStopInfo (m_last_stop_packet); } Error @@ -2342,13 +2329,11 @@ case eStateCrashed: case eStateSuspended: process->m_last_stop_packet = response; - process->m_last_stop_packet.SetFilePos (0); process->SetPrivateState (stop_state); break; case eStateExited: process->m_last_stop_packet = response; - process->m_last_stop_packet.SetFilePos (0); response.SetFilePos(1); process->SetExitStatus(response.GetHexU8(), NULL); done = true; Modified: lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h?rev=132499&r1=132498&r2=132499&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h (original) +++ lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h Thu Jun 2 17:22:38 2011 @@ -297,7 +297,7 @@ GDBRemoteCommunicationClient m_gdb_comm; lldb::pid_t m_debugserver_pid; lldb::thread_t m_debugserver_thread; - StringExtractor m_last_stop_packet; + StringExtractorGDBRemote m_last_stop_packet; GDBRemoteDynamicRegisterInfo m_register_info; lldb_private::Broadcaster m_async_broadcaster; lldb::thread_t m_async_thread; From gclayton at apple.com Thu Jun 2 17:23:36 2011 From: gclayton at apple.com (Greg Clayton) Date: Thu, 02 Jun 2011 22:23:36 -0000 Subject: [Lldb-commits] [lldb] r132501 - in /lldb/trunk/source/Plugins: Instruction/ARM/EmulateInstructionARM.cpp Process/Utility/ARMDefines.h Process/Utility/ARMUtils.h Message-ID: <20110602222336.495692A6C12C@llvm.org> Author: gclayton Date: Thu Jun 2 17:23:35 2011 New Revision: 132501 URL: http://llvm.org/viewvc/llvm-project?rev=132501&view=rev Log: Remove asserts that will crash LLDB. These should be changed to return true/false in an extra boolean parameter and not cause the the binary that us using the LLDB framework to crash. Modified: lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp lldb/trunk/source/Plugins/Process/Utility/ARMDefines.h lldb/trunk/source/Plugins/Process/Utility/ARMUtils.h Modified: lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp?rev=132501&r1=132500&r2=132501&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp (original) +++ lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp Thu Jun 2 17:23:35 2011 @@ -81,7 +81,7 @@ // Update ITState if necessary. void ITSession::ITAdvance() { - assert(ITCounter); + //assert(ITCounter); --ITCounter; if (ITCounter == 0) ITState = 0; @@ -3113,11 +3113,11 @@ bool EmulateInstructionARM::EmulateShiftImm (const uint32_t opcode, const ARMEncoding encoding, ARM_ShifterType shift_type) { - assert(shift_type == SRType_ASR - || shift_type == SRType_LSL - || shift_type == SRType_LSR - || shift_type == SRType_ROR - || shift_type == SRType_RRX); +// assert(shift_type == SRType_ASR +// || shift_type == SRType_LSL +// || shift_type == SRType_LSR +// || shift_type == SRType_ROR +// || shift_type == SRType_RRX); bool success = false; @@ -3142,7 +3142,7 @@ switch (use_encoding) { case eEncodingT1: // Due to the above special case handling! - assert(shift_type != SRType_ROR); + //assert(shift_type != SRType_ROR); Rd = Bits32(opcode, 2, 0); Rm = Bits32(opcode, 5, 3); @@ -3151,7 +3151,7 @@ break; case eEncodingT2: // A8.6.141 RRX - assert(shift_type != SRType_RRX); + //assert(shift_type != SRType_RRX); Rd = Bits32(opcode, 11, 8); Rm = Bits32(opcode, 3, 0); @@ -3198,10 +3198,10 @@ bool EmulateInstructionARM::EmulateShiftReg (const uint32_t opcode, const ARMEncoding encoding, ARM_ShifterType shift_type) { - assert(shift_type == SRType_ASR - || shift_type == SRType_LSL - || shift_type == SRType_LSR - || shift_type == SRType_ROR); + // assert(shift_type == SRType_ASR + // || shift_type == SRType_LSL + // || shift_type == SRType_LSR + // || shift_type == SRType_ROR); bool success = false; @@ -12877,7 +12877,7 @@ } else { - assert (byte_size == 4); + //assert (byte_size == 4); if (Bits32(opcode, 31, 27) == 0x1e && Bits32(opcode, 15, 14) == 0x02 && Bits32(opcode, 12, 12) == 0x00 && @@ -13153,7 +13153,7 @@ } else { - assert(0 && "Invalid register number"); + //assert(0 && "Invalid register number"); *success = false; return UINT32_MAX; } Modified: lldb/trunk/source/Plugins/Process/Utility/ARMDefines.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Utility/ARMDefines.h?rev=132501&r1=132500&r2=132501&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Process/Utility/ARMDefines.h (original) +++ lldb/trunk/source/Plugins/Process/Utility/ARMDefines.h Thu Jun 2 17:23:35 2011 @@ -21,7 +21,8 @@ SRType_LSR, SRType_ASR, SRType_ROR, - SRType_RRX + SRType_RRX, + SRType_Invalid } ARM_ShifterType; // ARM conditions // Meaning (integer) Meaning (floating-point) Condition flags Modified: lldb/trunk/source/Plugins/Process/Utility/ARMUtils.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Utility/ARMUtils.h?rev=132501&r1=132500&r2=132501&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Process/Utility/ARMUtils.h (original) +++ lldb/trunk/source/Plugins/Process/Utility/ARMUtils.h Thu Jun 2 17:23:35 2011 @@ -27,7 +27,8 @@ { switch (type) { default: - assert(0 && "Invalid shift type"); + //assert(0 && "Invalid shift type"); + return UINT32_MAX; case 0: shift_t = SRType_LSL; return imm5; @@ -75,7 +76,8 @@ { switch (type) { default: - assert(0 && "Invalid shift type"); + //assert(0 && "Invalid shift type"); + return SRType_Invalid; case 0: return SRType_LSL; case 1: @@ -89,14 +91,14 @@ static inline uint32_t LSL_C(const uint32_t value, const uint32_t amount, uint32_t &carry_out) { - assert(amount > 0); + //assert(amount > 0); carry_out = amount <= 32 ? Bit32(value, 32 - amount) : 0; return value << amount; } static inline uint32_t LSL(const uint32_t value, const uint32_t amount) { - assert(amount >= 0); + //assert(amount >= 0); if (amount == 0) return value; uint32_t dont_care; @@ -105,14 +107,14 @@ static inline uint32_t LSR_C(const uint32_t value, const uint32_t amount, uint32_t &carry_out) { - assert(amount > 0); + //assert(amount > 0); carry_out = amount <= 32 ? Bit32(value, amount - 1) : 0; return value >> amount; } static inline uint32_t LSR(const uint32_t value, const uint32_t amount) { - assert(amount >= 0); + //assert(amount >= 0); if (amount == 0) return value; uint32_t dont_care; @@ -121,7 +123,7 @@ static inline uint32_t ASR_C(const uint32_t value, const uint32_t amount, uint32_t &carry_out) { - assert(amount > 0 && amount <= 32); + //assert(amount > 0 && amount <= 32); bool negative = BitIsSet(value, 31); if (amount <= 32) { @@ -138,7 +140,7 @@ static inline uint32_t ASR(const uint32_t value, const uint32_t amount) { - assert(amount >= 0); + //assert(amount >= 0); if (amount == 0) return value; uint32_t dont_care; @@ -147,7 +149,7 @@ static inline uint32_t ROR_C(const uint32_t value, const uint32_t amount, uint32_t &carry_out) { - assert(amount > 0); + //assert(amount > 0); uint32_t amt = amount % 32; uint32_t result = Rotr32(value, amt); carry_out = Bit32(value, 31); @@ -156,7 +158,7 @@ static inline uint32_t ROR(const uint32_t value, const uint32_t amount) { - assert(amount >= 0); + //assert(amount >= 0); if (amount == 0) return value; uint32_t dont_care; @@ -178,7 +180,7 @@ static inline uint32_t Shift_C(const uint32_t value, ARM_ShifterType type, const uint32_t amount, const uint32_t carry_in, uint32_t &carry_out) { - assert(type != SRType_RRX || amount == 1); + //assert(type != SRType_RRX || amount == 1); if (amount == 0) { carry_out = carry_in; From gclayton at apple.com Thu Jun 2 17:25:27 2011 From: gclayton at apple.com (Greg Clayton) Date: Thu, 02 Jun 2011 22:25:27 -0000 Subject: [Lldb-commits] [lldb] r132502 - in /lldb/trunk: lldb.xcodeproj/project.pbxproj resources/LLDB-Info.plist Message-ID: <20110602222527.AECE92A6C12C@llvm.org> Author: gclayton Date: Thu Jun 2 17:25:27 2011 New Revision: 132502 URL: http://llvm.org/viewvc/llvm-project?rev=132502&view=rev Log: Bumped Xcode project version for lldb-60. Modified: lldb/trunk/lldb.xcodeproj/project.pbxproj lldb/trunk/resources/LLDB-Info.plist Modified: lldb/trunk/lldb.xcodeproj/project.pbxproj URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/lldb.xcodeproj/project.pbxproj?rev=132502&r1=132501&r2=132502&view=diff ============================================================================== --- lldb/trunk/lldb.xcodeproj/project.pbxproj (original) +++ lldb/trunk/lldb.xcodeproj/project.pbxproj Thu Jun 2 17:25:27 2011 @@ -3382,10 +3382,10 @@ buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; COPY_PHASE_STRIP = NO; - CURRENT_PROJECT_VERSION = 59; + CURRENT_PROJECT_VERSION = 60; DEBUG_INFORMATION_FORMAT = dwarf; DYLIB_COMPATIBILITY_VERSION = 1; - DYLIB_CURRENT_VERSION = 59; + DYLIB_CURRENT_VERSION = 60; EXPORTED_SYMBOLS_FILE = "resources/lldb-framework-exports"; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", @@ -3431,11 +3431,11 @@ buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; COPY_PHASE_STRIP = NO; - CURRENT_PROJECT_VERSION = 59; + CURRENT_PROJECT_VERSION = 60; DEAD_CODE_STRIPPING = YES; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; DYLIB_COMPATIBILITY_VERSION = 1; - DYLIB_CURRENT_VERSION = 59; + DYLIB_CURRENT_VERSION = 60; EXPORTED_SYMBOLS_FILE = "resources/lldb-framework-exports"; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", @@ -3479,8 +3479,8 @@ isa = XCBuildConfiguration; buildSettings = { COPY_PHASE_STRIP = NO; - CURRENT_PROJECT_VERSION = 59; - DYLIB_CURRENT_VERSION = 59; + CURRENT_PROJECT_VERSION = 60; + DYLIB_CURRENT_VERSION = 60; EXECUTABLE_EXTENSION = a; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", @@ -3518,9 +3518,9 @@ isa = XCBuildConfiguration; buildSettings = { COPY_PHASE_STRIP = NO; - CURRENT_PROJECT_VERSION = 59; + CURRENT_PROJECT_VERSION = 60; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; - DYLIB_CURRENT_VERSION = 59; + DYLIB_CURRENT_VERSION = 60; EXECUTABLE_EXTENSION = a; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", @@ -3558,9 +3558,9 @@ isa = XCBuildConfiguration; buildSettings = { COPY_PHASE_STRIP = NO; - CURRENT_PROJECT_VERSION = 59; + CURRENT_PROJECT_VERSION = 60; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; - DYLIB_CURRENT_VERSION = 59; + DYLIB_CURRENT_VERSION = 60; EXECUTABLE_EXTENSION = a; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", @@ -3628,7 +3628,7 @@ isa = XCBuildConfiguration; buildSettings = { COPY_PHASE_STRIP = YES; - CURRENT_PROJECT_VERSION = 59; + CURRENT_PROJECT_VERSION = 60; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", @@ -3659,11 +3659,11 @@ buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; COPY_PHASE_STRIP = YES; - CURRENT_PROJECT_VERSION = 59; + CURRENT_PROJECT_VERSION = 60; DEAD_CODE_STRIPPING = YES; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; DYLIB_COMPATIBILITY_VERSION = 1; - DYLIB_CURRENT_VERSION = 59; + DYLIB_CURRENT_VERSION = 60; EXPORTED_SYMBOLS_FILE = "resources/lldb-framework-exports"; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", @@ -3785,7 +3785,7 @@ isa = XCBuildConfiguration; buildSettings = { COPY_PHASE_STRIP = NO; - CURRENT_PROJECT_VERSION = 59; + CURRENT_PROJECT_VERSION = 60; DEBUG_INFORMATION_FORMAT = dwarf; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", @@ -3817,7 +3817,7 @@ isa = XCBuildConfiguration; buildSettings = { COPY_PHASE_STRIP = YES; - CURRENT_PROJECT_VERSION = 59; + CURRENT_PROJECT_VERSION = 60; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", Modified: lldb/trunk/resources/LLDB-Info.plist URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/resources/LLDB-Info.plist?rev=132502&r1=132501&r2=132502&view=diff ============================================================================== --- lldb/trunk/resources/LLDB-Info.plist (original) +++ lldb/trunk/resources/LLDB-Info.plist Thu Jun 2 17:25:27 2011 @@ -17,7 +17,7 @@ CFBundleSignature ???? CFBundleVersion - 59 + 60 CFBundleName ${EXECUTABLE_NAME} From gclayton at apple.com Thu Jun 2 17:25:57 2011 From: gclayton at apple.com (Greg Clayton) Date: Thu, 02 Jun 2011 22:25:57 -0000 Subject: [Lldb-commits] [lldb] r132503 - /lldb/tags/lldb-60/ Message-ID: <20110602222558.0165B2A6C12C@llvm.org> Author: gclayton Date: Thu Jun 2 17:25:57 2011 New Revision: 132503 URL: http://llvm.org/viewvc/llvm-project?rev=132503&view=rev Log: lldb-60 Added: lldb/tags/lldb-60/ - copied from r132502, lldb/trunk/ From johnny.chen at apple.com Thu Jun 2 17:50:51 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Thu, 02 Jun 2011 22:50:51 -0000 Subject: [Lldb-commits] [lldb] r132506 - in /lldb/trunk/source/Plugins: Instruction/ARM/EmulateInstructionARM.cpp Process/Utility/ARMUtils.h Message-ID: <20110602225051.638B62A6C12C@llvm.org> Author: johnny Date: Thu Jun 2 17:50:51 2011 New Revision: 132506 URL: http://llvm.org/viewvc/llvm-project?rev=132506&view=rev Log: When emulating an ill-formed instruction, we should bail out instead of asserting and bringing down the whole process. Modified: lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp lldb/trunk/source/Plugins/Process/Utility/ARMUtils.h Modified: lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp?rev=132506&r1=132505&r2=132506&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp (original) +++ lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp Thu Jun 2 17:50:51 2011 @@ -1121,7 +1121,9 @@ if (!success) return false; - uint32_t shifted = Shift_C(value, shift_t, shift_n, APSR_C, carry); + uint32_t shifted = Shift_C(value, shift_t, shift_n, APSR_C, carry, &success); + if (!success) + return false; uint32_t result = ~shifted; // The context specifies that an immediate is to be moved into Rd. @@ -2628,7 +2630,9 @@ if (!success) return false; - uint32_t shifted = Shift(val2, shift_t, shift_n, APSR_C); + uint32_t shifted = Shift(val2, shift_t, shift_n, APSR_C, &success); + if (!success) + return false; AddWithCarryResult res = AddWithCarry(val1, shifted, 0); EmulateInstruction::Context context; @@ -2751,7 +2755,9 @@ if (!success) return false; - uint32_t shifted = Shift(val2, shift_t, shift_n, APSR_C); + uint32_t shifted = Shift(val2, shift_t, shift_n, APSR_C, &success); + if (!success) + return false; AddWithCarryResult res = AddWithCarry(val1, shifted, 0); EmulateInstruction::Context context; @@ -2875,7 +2881,9 @@ if (!success) return false; - uint32_t shifted = Shift(val2, shift_t, shift_n, APSR_C); + uint32_t shifted = Shift(val2, shift_t, shift_n, APSR_C, &success); + if (!success) + return false; AddWithCarryResult res = AddWithCarry(val1, ~shifted, 1); EmulateInstruction::Context context; @@ -3182,7 +3190,9 @@ // Decode the shift amount if not RRX. uint32_t amt = (shift_type == SRType_RRX ? 1 : DecodeImmShift(shift_type, imm5)); - uint32_t result = Shift_C(value, shift_type, amt, APSR_C, carry); + uint32_t result = Shift_C(value, shift_type, amt, APSR_C, carry, &success); + if (!success) + return false; // The context specifies that an immediate is to be moved into Rd. EmulateInstruction::Context context; @@ -3251,7 +3261,9 @@ // Get the shift amount. uint32_t amt = Bits32(val, 7, 0); - uint32_t result = Shift_C(value, shift_type, amt, APSR_C, carry); + uint32_t result = Shift_C(value, shift_type, amt, APSR_C, carry, &success); + if (!success) + return false; // The context specifies that an immediate is to be moved into Rd. EmulateInstruction::Context context; @@ -4771,7 +4783,9 @@ return false; // offset = Shift(R[m], shift_t, shift_n, APSR.C); - offset = Shift (Rm_data, shift_t, shift_n, APSR_C); + offset = Shift (Rm_data, shift_t, shift_n, APSR_C, &success); + if (!success) + return false; // offset_addr = if add then (R[n] + offset) else (R[n] - offset); if (add) @@ -5085,7 +5099,9 @@ return false; // offset = Shift(R[m], shift_t, shift_n, APSR.C); - uint32_t offset = Shift (Rm, shift_t, shift_n, APSR_C); + uint32_t offset = Shift (Rm, shift_t, shift_n, APSR_C, &success); + if (!success) + return false; // offset_addr = if add then (R[n] + offset) else (R[n] - offset); addr_t offset_addr; @@ -5289,7 +5305,9 @@ if (!success) return false; - uint32_t shifted = Shift(val2, shift_t, shift_n, APSR_C); + uint32_t shifted = Shift(val2, shift_t, shift_n, APSR_C, &success); + if (!success) + return false; AddWithCarryResult res = AddWithCarry(val1, shifted, APSR_C); EmulateInstruction::Context context; @@ -5515,7 +5533,9 @@ if (!success) return false; - uint32_t shifted = Shift_C(val2, shift_t, shift_n, APSR_C, carry); + uint32_t shifted = Shift_C(val2, shift_t, shift_n, APSR_C, carry, &success); + if (!success) + return false; uint32_t result = val1 & shifted; EmulateInstruction::Context context; @@ -5674,7 +5694,9 @@ if (!success) return false; - uint32_t shifted = Shift_C(val2, shift_t, shift_n, APSR_C, carry); + uint32_t shifted = Shift_C(val2, shift_t, shift_n, APSR_C, carry, &success); + if (!success) + return false; uint32_t result = val1 & ~shifted; EmulateInstruction::Context context; @@ -5813,7 +5835,9 @@ else { // R[t] = ROR(data, 8*UInt(address<1:0>)); - data = ROR (data, Bits32 (address, 1, 0)); + data = ROR (data, Bits32 (address, 1, 0), &success); + if (!success) + return false; context.type = eContextRegisterLoad; context.SetImmediate (data); if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, dwarf_r0 + t, data)) @@ -5954,7 +5978,9 @@ addr_t address; // offset = Shift(R[m], shift_t, shift_n, APSR.C); -- Note "The APSR is an application level alias for the CPSR". - addr_t offset = Shift (Rm, shift_t, shift_n, Bit32 (m_opcode_cpsr, APSR_C)); + addr_t offset = Shift (Rm, shift_t, shift_n, Bit32 (m_opcode_cpsr, APSR_C), &success); + if (!success) + return false; // offset_addr = if add then (R[n] + offset) else (R[n] - offset); if (add) @@ -6017,7 +6043,9 @@ if (CurrentInstrSet () == eModeARM) { // R[t] = ROR(data, 8*UInt(address<1:0>)); - data = ROR (data, Bits32 (address, 1, 0)); + data = ROR (data, Bits32 (address, 1, 0), &success); + if (!success) + return false; context.type = eContextRegisterLoad; context.SetImmediate (data); if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, dwarf_r0 + t, data)) @@ -6357,7 +6385,9 @@ if (!success) return false; - addr_t offset = Shift (Rm, shift_t, shift_n, APSR_C); + addr_t offset = Shift (Rm, shift_t, shift_n, APSR_C, &success); + if (!success) + return false; // offset_addr = if add then (R[n] + offset) else (R[n] - offset); uint32_t Rn = ReadRegisterUnsigned (eRegisterKindDWARF, dwarf_r0 + n, 0, &success); @@ -6771,7 +6801,9 @@ if (!success) return false; - addr_t offset = Shift (Rm, shift_t, shift_n, APSR_C); + addr_t offset = Shift (Rm, shift_t, shift_n, APSR_C, &success); + if (!success) + return false; addr_t offset_addr; addr_t address; @@ -7176,7 +7208,9 @@ return false; // offset = Shift(R[m], shift_t, shift_n, APSR.C); - addr_t offset = Shift (Rm, shift_t, shift_n, APSR_C); + addr_t offset = Shift (Rm, shift_t, shift_n, APSR_C, &success); + if (!success) + return false; addr_t offset_addr; addr_t address; @@ -7607,7 +7641,9 @@ return false; // offset = Shift(R[m], shift_t, shift_n, APSR.C); - addr_t offset = Shift (Rm, shift_t, shift_n, APSR_C); + addr_t offset = Shift (Rm, shift_t, shift_n, APSR_C, &success); + if (!success) + return false; addr_t offset_addr; addr_t address; @@ -7732,7 +7768,9 @@ return false; // rotated = ROR(R[m], rotation); - uint64_t rotated = ROR (Rm, rotation); + uint64_t rotated = ROR (Rm, rotation, &success); + if (!success) + return false; // R[d] = SignExtend(rotated<7:0>, 32); int64_t data = llvm::SignExtend64<8>(rotated); @@ -7814,7 +7852,9 @@ return false; // rotated = ROR(R[m], rotation); - uint64_t rotated = ROR (Rm, rotation); + uint64_t rotated = ROR (Rm, rotation, &success); + if (!success) + return false; // R[d] = SignExtend(rotated<15:0>, 32); RegisterInfo source_reg; @@ -7896,7 +7936,9 @@ return false; // rotated = ROR(R[m], rotation); - uint64_t rotated = ROR (Rm, rotation); + uint64_t rotated = ROR (Rm, rotation, &success); + if (!success) + return false; // R[d] = ZeroExtend(rotated<7:0>, 32); RegisterInfo source_reg; @@ -7975,7 +8017,9 @@ return false; // rotated = ROR(R[m], rotation); - uint64_t rotated = ROR (Rm, rotation); + uint64_t rotated = ROR (Rm, rotation, &success); + if (!success) + return false; // R[d] = ZeroExtend(rotated<15:0>, 32); RegisterInfo source_reg; @@ -8290,7 +8334,9 @@ if (!success) return false; - uint32_t shifted = Shift_C(val2, shift_t, shift_n, APSR_C, carry); + uint32_t shifted = Shift_C(val2, shift_t, shift_n, APSR_C, carry, &success); + if (!success) + return false; uint32_t result = val1 ^ shifted; EmulateInstruction::Context context; @@ -8453,7 +8499,9 @@ if (!success) return false; - uint32_t shifted = Shift_C(val2, shift_t, shift_n, APSR_C, carry); + uint32_t shifted = Shift_C(val2, shift_t, shift_n, APSR_C, carry, &success); + if (!success) + return false; uint32_t result = val1 | shifted; EmulateInstruction::Context context; @@ -8603,7 +8651,9 @@ if (!success) return false; - uint32_t shifted = Shift(val2, shift_t, shift_n, APSR_C); + uint32_t shifted = Shift(val2, shift_t, shift_n, APSR_C, &success); + if (!success) + return false; AddWithCarryResult res = AddWithCarry(~val1, shifted, 1); EmulateInstruction::Context context; @@ -8730,7 +8780,9 @@ if (!success) return false; - uint32_t shifted = Shift(val2, shift_t, shift_n, APSR_C); + uint32_t shifted = Shift(val2, shift_t, shift_n, APSR_C, &success); + if (!success) + return false; AddWithCarryResult res = AddWithCarry(~val1, shifted, APSR_C); EmulateInstruction::Context context; @@ -8881,7 +8933,9 @@ if (!success) return false; - uint32_t shifted = Shift(val2, shift_t, shift_n, APSR_C); + uint32_t shifted = Shift(val2, shift_t, shift_n, APSR_C, &success); + if (!success) + return false; AddWithCarryResult res = AddWithCarry(val1, ~shifted, APSR_C); EmulateInstruction::Context context; @@ -9160,7 +9214,9 @@ if (!success) return false; - uint32_t shifted = Shift_C(val2, shift_t, shift_n, APSR_C, carry); + uint32_t shifted = Shift_C(val2, shift_t, shift_n, APSR_C, carry, &success); + if (!success) + return false; uint32_t result = val1 ^ shifted; EmulateInstruction::Context context; @@ -9288,7 +9344,9 @@ if (!success) return false; - uint32_t shifted = Shift_C(val2, shift_t, shift_n, APSR_C, carry); + uint32_t shifted = Shift_C(val2, shift_t, shift_n, APSR_C, carry, &success); + if (!success) + return false; uint32_t result = val1 & shifted; EmulateInstruction::Context context; @@ -9374,7 +9432,9 @@ if (!success) return false; - uint32_t shifted = Shift (Rm, shift_t, shift_n, APSR_C); + uint32_t shifted = Shift (Rm, shift_t, shift_n, APSR_C, &success); + if (!success) + return false; // (result, carry, overflow) = AddWithCarry(SP, NOT(shifted), ?1?); uint32_t sp_val = ReadCoreReg (SP_REG, &success); @@ -9461,8 +9521,10 @@ if (!success) return false; - uint32_t shifted = Shift (Rm, shift_t, shift_n, APSR_C); - + uint32_t shifted = Shift (Rm, shift_t, shift_n, APSR_C, &success); + if (!success) + return false; + // (result, carry, overflow) = AddWithCarry(R[n], shifted, ?0?); uint32_t Rn = ReadCoreReg (n, &success); if (!success) @@ -9584,7 +9646,9 @@ if (!success) return false; - uint32_t shifted = Shift (Rm, shift_t, shift_n, APSR_C); + uint32_t shifted = Shift (Rm, shift_t, shift_n, APSR_C, &success); + if (!success) + return false; // (result, carry, overflow) = AddWithCarry(R[n], NOT(shifted), ?1?); uint32_t Rn = ReadCoreReg (n, &success); @@ -12019,8 +12083,9 @@ if (!success) return false; - operand2 = Shift (Rm, shift_t, shift_n, APSR_C); - + operand2 = Shift (Rm, shift_t, shift_n, APSR_C, &success); + if (!success) + return false; } else { Modified: lldb/trunk/source/Plugins/Process/Utility/ARMUtils.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Utility/ARMUtils.h?rev=132506&r1=132505&r2=132506&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Process/Utility/ARMUtils.h (original) +++ lldb/trunk/source/Plugins/Process/Utility/ARMUtils.h Thu Jun 2 17:50:51 2011 @@ -89,41 +89,61 @@ } } -static inline uint32_t LSL_C(const uint32_t value, const uint32_t amount, uint32_t &carry_out) +static inline uint32_t LSL_C(const uint32_t value, const uint32_t amount, uint32_t &carry_out, bool *success) { - //assert(amount > 0); + if (amount == 0) { + *success = false; + return 0; + } + *success = true; carry_out = amount <= 32 ? Bit32(value, 32 - amount) : 0; return value << amount; } -static inline uint32_t LSL(const uint32_t value, const uint32_t amount) +static inline uint32_t LSL(const uint32_t value, const uint32_t amount, bool *success) { - //assert(amount >= 0); + *success = true; if (amount == 0) return value; uint32_t dont_care; - return LSL_C(value, amount, dont_care); + uint32_t result = LSL_C(value, amount, dont_care, success); + if (*success) + return result; + else + return 0; } -static inline uint32_t LSR_C(const uint32_t value, const uint32_t amount, uint32_t &carry_out) +static inline uint32_t LSR_C(const uint32_t value, const uint32_t amount, uint32_t &carry_out, bool *success) { - //assert(amount > 0); + if (amount == 0) { + *success = false; + return 0; + } + *success = true; carry_out = amount <= 32 ? Bit32(value, amount - 1) : 0; return value >> amount; } -static inline uint32_t LSR(const uint32_t value, const uint32_t amount) +static inline uint32_t LSR(const uint32_t value, const uint32_t amount, bool *success) { - //assert(amount >= 0); + *success = true; if (amount == 0) return value; uint32_t dont_care; - return LSR_C(value, amount, dont_care); + uint32_t result = LSR_C(value, amount, dont_care, success); + if (*success) + return result; + else + return 0; } -static inline uint32_t ASR_C(const uint32_t value, const uint32_t amount, uint32_t &carry_out) +static inline uint32_t ASR_C(const uint32_t value, const uint32_t amount, uint32_t &carry_out, bool *success) { - //assert(amount > 0 && amount <= 32); + if (amount == 0 || amount > 32) { + *success = false; + return 0; + } + *success = true; bool negative = BitIsSet(value, 31); if (amount <= 32) { @@ -138,81 +158,113 @@ } } -static inline uint32_t ASR(const uint32_t value, const uint32_t amount) +static inline uint32_t ASR(const uint32_t value, const uint32_t amount, bool *success) { - //assert(amount >= 0); + *success = true; if (amount == 0) return value; uint32_t dont_care; - return ASR_C(value, amount, dont_care); + uint32_t result = ASR_C(value, amount, dont_care, success); + if (*success) + return result; + else + return 0; } -static inline uint32_t ROR_C(const uint32_t value, const uint32_t amount, uint32_t &carry_out) +static inline uint32_t ROR_C(const uint32_t value, const uint32_t amount, uint32_t &carry_out, bool *success) { - //assert(amount > 0); + if (amount == 0) { + *success = false; + return 0; + } + *success = true; uint32_t amt = amount % 32; uint32_t result = Rotr32(value, amt); carry_out = Bit32(value, 31); return result; } -static inline uint32_t ROR(const uint32_t value, const uint32_t amount) +static inline uint32_t ROR(const uint32_t value, const uint32_t amount, bool *success) { - //assert(amount >= 0); + *success = true; if (amount == 0) return value; uint32_t dont_care; - return ROR_C(value, amount, dont_care); + uint32_t result = ROR_C(value, amount, dont_care, success); + if (*success) + return result; + else + return 0; } -static inline uint32_t RRX_C(const uint32_t value, const uint32_t carry_in, uint32_t &carry_out) +static inline uint32_t RRX_C(const uint32_t value, const uint32_t carry_in, uint32_t &carry_out, bool *success) { + *success = true; carry_out = Bit32(value, 0); return Bit32(carry_in, 0) << 31 | Bits32(value, 31, 1); } -static inline uint32_t RRX(const uint32_t value, const uint32_t carry_in) +static inline uint32_t RRX(const uint32_t value, const uint32_t carry_in, bool *success) { + *success = true; uint32_t dont_care; - return RRX_C(value, carry_in, dont_care); + uint32_t result = RRX_C(value, carry_in, dont_care, success); + if (*success) + return result; + else + return 0; } static inline uint32_t Shift_C(const uint32_t value, ARM_ShifterType type, const uint32_t amount, - const uint32_t carry_in, uint32_t &carry_out) + const uint32_t carry_in, uint32_t &carry_out, bool *success) { - //assert(type != SRType_RRX || amount == 1); - if (amount == 0) - { + if (type == SRType_RRX && amount != 1) { + *success = false; + return 0; + } + *success = true; + + if (amount == 0) { carry_out = carry_in; return value; } uint32_t result; switch (type) { case SRType_LSL: - result = LSL_C(value, amount, carry_out); + result = LSL_C(value, amount, carry_out, success); break; case SRType_LSR: - result = LSR_C(value, amount, carry_out); + result = LSR_C(value, amount, carry_out, success); break; case SRType_ASR: - result = ASR_C(value, amount, carry_out); + result = ASR_C(value, amount, carry_out, success); break; case SRType_ROR: - result = ROR_C(value, amount, carry_out); + result = ROR_C(value, amount, carry_out, success); break; case SRType_RRX: - result = RRX_C(value, carry_in, carry_out); + result = RRX_C(value, carry_in, carry_out, success); + break; + default: + *success = false; break; } - return result; + if (*success) + return result; + else + return 0; } static inline uint32_t Shift(const uint32_t value, ARM_ShifterType type, const uint32_t amount, - const uint32_t carry_in) + const uint32_t carry_in, bool *success) { // Don't care about carry out in this case. uint32_t dont_care; - return Shift_C(value, type, amount, carry_in, dont_care); + uint32_t result = Shift_C(value, type, amount, carry_in, dont_care, success); + if (*success) + return result; + else + return 0; } static inline uint32_t bits(const uint32_t val, const uint32_t msbit, const uint32_t lsbit) From johnny.chen at apple.com Thu Jun 2 18:07:03 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Thu, 02 Jun 2011 23:07:03 -0000 Subject: [Lldb-commits] [lldb] r132507 - /lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp Message-ID: <20110602230703.B356C2A6C12C@llvm.org> Author: johnny Date: Thu Jun 2 18:07:03 2011 New Revision: 132507 URL: http://llvm.org/viewvc/llvm-project?rev=132507&view=rev Log: Turn the commented-out assert()'s into appropriate bail-out actions. Modified: lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp Modified: lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp?rev=132507&r1=132506&r2=132507&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp (original) +++ lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp Thu Jun 2 18:07:03 2011 @@ -3150,7 +3150,8 @@ switch (use_encoding) { case eEncodingT1: // Due to the above special case handling! - //assert(shift_type != SRType_ROR); + if (shift_type == SRType_ROR) + return false; Rd = Bits32(opcode, 2, 0); Rm = Bits32(opcode, 5, 3); @@ -3159,7 +3160,9 @@ break; case eEncodingT2: // A8.6.141 RRX - //assert(shift_type != SRType_RRX); + // There's no imm form of RRX instructions. + if (shift_type == SRType_RRX) + return false; Rd = Bits32(opcode, 11, 8); Rm = Bits32(opcode, 3, 0); From johnny.chen at apple.com Thu Jun 2 18:19:06 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Thu, 02 Jun 2011 23:19:06 -0000 Subject: [Lldb-commits] [lldb] r132511 - /lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp Message-ID: <20110602231906.825FD2A6C12C@llvm.org> Author: johnny Date: Thu Jun 2 18:19:06 2011 New Revision: 132511 URL: http://llvm.org/viewvc/llvm-project?rev=132511&view=rev Log: Bail out if we have an invalid thumb instruction. Modified: lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp Modified: lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp?rev=132511&r1=132510&r2=132511&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp (original) +++ lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp Thu Jun 2 18:19:06 2011 @@ -12943,9 +12943,8 @@ if (Bits32(opcode, 15, 12) == 0x0d && Bits32(opcode, 11, 7) != 0x0f) return Bits32(opcode, 11, 7); } - else + else if (byte_size == 4) { - //assert (byte_size == 4); if (Bits32(opcode, 31, 27) == 0x1e && Bits32(opcode, 15, 14) == 0x02 && Bits32(opcode, 12, 12) == 0x00 && @@ -12954,6 +12953,9 @@ return Bits32(opcode, 25, 22); } } + else + // We have an invalid thumb instruction, let's bail out. + break; return m_it_session.GetCond(); } From ctice at apple.com Thu Jun 2 18:23:47 2011 From: ctice at apple.com (Caroline Tice) Date: Thu, 02 Jun 2011 23:23:47 -0000 Subject: [Lldb-commits] [lldb] r132512 - in /lldb/trunk/examples/scripting: ./ dictionary.c tree_utils.py Message-ID: <20110602232347.62C1D2A6C12C@llvm.org> Author: ctice Date: Thu Jun 2 18:23:47 2011 New Revision: 132512 URL: http://llvm.org/viewvc/llvm-project?rev=132512&view=rev Log: Add source files for Python scripting example (coming soon). Added: lldb/trunk/examples/scripting/ lldb/trunk/examples/scripting/dictionary.c lldb/trunk/examples/scripting/tree_utils.py (with props) Added: lldb/trunk/examples/scripting/dictionary.c URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/examples/scripting/dictionary.c?rev=132512&view=auto ============================================================================== --- lldb/trunk/examples/scripting/dictionary.c (added) +++ lldb/trunk/examples/scripting/dictionary.c Thu Jun 2 18:23:47 2011 @@ -0,0 +1,200 @@ +//===-- dictionary.c ---------------------------------------------*- C -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===---------------------------------------------------------------------===// +#include +#include +#include +#include + +typedef struct tree_node +{ + const char *word; + struct tree_node *left; + struct tree_node *right; +} tree_node; + +/* Given a char*, returns a substring that starts at the first + alphabet character and ends at the last alphabet character, i.e. it + strips off beginning or ending quotes, punctuation, etc. */ + +char * +strip (char **word) +{ + char *start = *word; + int len = strlen (start); + char *end = start + len - 1; + + while ((start < end) && (!isalpha (start[0]))) + start++; + + while ((end > start) && (!isalpha (end[0]))) + end--; + + if (start > end) + return NULL; + + end[1] = '\0'; + *word = start; + + return start; +} + +/* Given a binary search tree (sorted alphabetically by the word at + each node), and a new word, inserts the word at the appropriate + place in the tree. */ + +void +insert (tree_node *root, char *word) +{ + if (root == NULL) + return; + + int compare_value = strcmp (word, root->word); + + if (compare_value == 0) + return; + + if (compare_value < 0) + { + if (root->left != NULL) + insert (root->left, word); + else + { + tree_node *new_node = (tree_node *) malloc (sizeof (tree_node)); + new_node->word = strdup (word); + new_node->left = NULL; + new_node->right = NULL; + root->left = new_node; + } + } + else + { + if (root->right != NULL) + insert (root->right, word); + else + { + tree_node *new_node = (tree_node *) malloc (sizeof (tree_node)); + new_node->word = strdup (word); + new_node->left = NULL; + new_node->right = NULL; + root->right = new_node; + } + } +} + +/* Read in a text file and storea all the words from the file in a + binary search tree. */ + +void +populate_dictionary (tree_node **dictionary, char *filename) +{ + FILE *in_file; + char word[1024]; + + in_file = fopen (filename, "r"); + if (in_file) + { + while (fscanf (in_file, "%s", word) == 1) + { + char *new_word = (strdup (word)); + new_word = strip (&new_word); + if (*dictionary == NULL) + { + tree_node *new_node = (tree_node *) malloc (sizeof (tree_node)); + new_node->word = new_word; + new_node->left = NULL; + new_node->right = NULL; + *dictionary = new_node; + } + else + insert (*dictionary, new_word); + } + } +} + +/* Given a binary search tree and a word, search for the word + in the binary search tree. */ + +int +find_word (tree_node *dictionary, char *word) +{ + if (!word || !dictionary) + return 0; + + int compare_value = strcmp (word, dictionary->word); + + if (compare_value == 0) + return 1; + else if (compare_value < 0) + return find_word (dictionary->left, word); + else + return find_word (dictionary->right, word); +} + +/* Print out the words in the binary search tree, in sorted order. */ + +void +print_tree (tree_node *dictionary) +{ + if (!dictionary) + return; + + if (dictionary->left) + print_tree (dictionary->left); + + printf ("%s\n", dictionary->word); + + + if (dictionary->right) + print_tree (dictionary->right); +} + + +int +main (int argc, char **argv) +{ + tree_node *dictionary = NULL; + char buffer[1024]; + char *filename; + int done = 0; + + if (argc == 2) + filename = argv[1]; + + if (!filename) + return -1; + + populate_dictionary (&dictionary, filename); + fprintf (stdout, "Dictionary loaded.\nEnter search word: "); + while (!done && fgets (buffer, sizeof(buffer), stdin)) + { + char *word = buffer; + int len = strlen (word); + int i; + + for (i = 0; i < len; ++i) + word[i] = tolower (word[i]); + + if ((len > 0) && (word[len-1] == '\n')) + { + word[len-1] = '\0'; + len = len - 1; + } + + if (find_word (dictionary, word)) + fprintf (stdout, "Yes!\n"); + else + fprintf (stdout, "No!\n"); + + fprintf (stdout, "Enter search word: "); + } + + fprintf (stdout, "\n"); + return 0; +} + Added: lldb/trunk/examples/scripting/tree_utils.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/examples/scripting/tree_utils.py?rev=132512&view=auto ============================================================================== --- lldb/trunk/examples/scripting/tree_utils.py (added) +++ lldb/trunk/examples/scripting/tree_utils.py Thu Jun 2 18:23:47 2011 @@ -0,0 +1,118 @@ +""" +# ===-- tree_utils.py ---------------------------------------*- Python -*-===// +# +# The LLVM Compiler Infrastructure +# +# This file is distributed under the University of Illinois Open Source +# License. See LICENSE.TXT for details. +# +# ===---------------------------------------------------------------------===// + +tree_utils.py - A set of functions for examining binary +search trees, based on the example search tree defined in +dictionary.c. These functions contain calls to LLDB API +functions, and assume that the LLDB Python module has been +imported. + +For a thorough explanation of how the DFS function works, and +for more information about dictionary.c go to +http://lldb.llvm.org/scripting.html +""" + + +def DFS (root, word, cur_path): + """ + Recursively traverse a binary search tree containing + words sorted alphabetically, searching for a particular + word in the tree. Also maintains a string representing + the path from the root of the tree to the current node. + If the word is found in the tree, return the path string. + Otherwise return an empty string. + + This function assumes the binary search tree is + the one defined in dictionary.c It uses LLDB API + functions to examine and traverse the tree nodes. + """ + + # Get pointer field values out of node 'root' + + root_word_ptr = root.GetChildMemberWithName ("word") + left_child_ptr = root.GetChildMemberWithName ("left") + right_child_ptr = root.GetChildMemberWithName ("right") + + # Get the word out of the word pointer and strip off + # surrounding quotes (added by call to GetSummary). + + root_word = root_word_ptr.GetSummary() + end = len (root_word) - 1 + if root_word[0] == '"' and root_word[end] == '"': + root_word = root_word[1:end] + end = len (root_word) - 1 + if root_word[0] == '\'' and root_word[end] == '\'': + root_word = root_word[1:end] + + # Main depth first search + + if root_word == word: + return cur_path + elif word < root_word: + + # Check to see if left child is NULL + + if left_child_ptr.GetValue() == None: + return "" + else: + cur_path = cur_path + "L" + return DFS (left_child_ptr, word, cur_path) + else: + + # Check to see if right child is NULL + + if right_child_ptr.GetValue() == None: + return "" + else: + cur_path = cur_path + "R" + return DFS (right_child_ptr, word, cur_path) + + +def tree_size (root): + """ + Recursively traverse a binary search tree, counting + the nodes in the tree. Returns the final count. + + This function assumes the binary search tree is + the one defined in dictionary.c It uses LLDB API + functions to examine and traverse the tree nodes. + """ + if (root.GetValue == None): + return 0 + + if (int (root.GetValue(), 16) == 0): + return 0 + + left_size = tree_size (root.GetChildAtIndex(1)); + right_size = tree_size (root.GetChildAtIndex(2)); + + total_size = left_size + right_size + 1 + return total_size + + +def print_tree (root): + """ + Recursively traverse a binary search tree, printing out + the words at the nodes in alphabetical order (the + search order for the binary tree). + + This function assumes the binary search tree is + the one defined in dictionary.c It uses LLDB API + functions to examine and traverse the tree nodes. + """ + if (root.GetChildAtIndex(1).GetValue() != None) and (int (root.GetChildAtIndex(1).GetValue(), 16) != 0): + print_tree (root.GetChildAtIndex(1)) + + print root.GetChildAtIndex(0).GetSummary() + + if (root.GetChildAtIndex(2).GetValue() != None) and (int (root.GetChildAtIndex(2).GetValue(), 16) != 0): + print_tree (root.GetChildAtIndex(2)) + + Propchange: lldb/trunk/examples/scripting/tree_utils.py ------------------------------------------------------------------------------ svn:executable = * From ctice at apple.com Thu Jun 2 18:40:56 2011 From: ctice at apple.com (Caroline Tice) Date: Thu, 02 Jun 2011 23:40:56 -0000 Subject: [Lldb-commits] [lldb] r132513 - /lldb/trunk/www/scripting.html Message-ID: <20110602234056.544292A6C12C@llvm.org> Author: ctice Date: Thu Jun 2 18:40:56 2011 New Revision: 132513 URL: http://llvm.org/viewvc/llvm-project?rev=132513&view=rev Log: Add the web page for the 'Using Python Scripting to Debug a Program in LLDB' example. Added: lldb/trunk/www/scripting.html (with props) Added: lldb/trunk/www/scripting.html URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/www/scripting.html?rev=132513&view=auto ============================================================================== --- lldb/trunk/www/scripting.html (added) +++ lldb/trunk/www/scripting.html Thu Jun 2 18:40:56 2011 @@ -0,0 +1,570 @@ + + + + + +LLDB Example - Python Scripting to Debug a Problem + + + +
+ Example - Using Scripting and Python to Debug in LLDB +
+ +
+
+ +
+
+

The Test Program and Input

+
+ +

We have a simple C program (dictionary.c) that reads in a text file, and + stores all the words from the file in a Binary Search Tree, sorted + alphabetically. It then enters a loop prompting the user for a word, searching + for the word in the tree (using Binary Search), and reporting to the user + whether or not it found the word in the tree.

+ +

The input text file we are using to test our program contains the text for + William Shakespeare's famous tragedy "Romeo and Juliet".

+ +
+ + +
+

The Bug

+
+ +

When we try running our program, we find there is a problem. While it + successfully finds some of the words we would expect to find, such as "love" + or "sun", it fails to find the word "Romeo", which MUST be in the input text + file:

+ + + % ./dictionary Romeo-and-Juliet.txt
+ Dictionary loaded.
+ Enter search word: love
+ Yes!
+ Enter search word: sun
+ Yes!
+ Enter search word: Romeo
+ No!
+ Enter search word: ^D
+ %
+
+ +
+ + + +
+

Is the word in our tree: Using Depth First Search

+
+ +

Our first job is to determine if the word "Romeo" actually got inserted into + the tree or not. Since "Romeo and Juliet" has thousands of words, trying to + examine our binary search tree by hand is completely impractical. Therefore we + will write a Python script to search the tree for us. We will write a recursive + Depth First Search function that traverses the entire tree searching for a word, + and maintaining information about the path from the root of the tree to the + current node. If it finds the word in the tree, it returns the path from the + root to the node containing the word. This is what our DFS function in Python + would look like, with line numbers added for easy reference in later + explanations:

+ + +

+ 1: def DFS (root, word, cur_path):
+ 2:     root_word_ptr = root.GetChildMemberWithName ("word")
+ 3:     left_child_ptr = root.GetChildMemberWithName ("left")
+ 4:     right_child_ptr = root.GetChildMemberWithName ("right")
+ 5:     root_word = root_word_ptr.GetSummary()
+ 6:     end = len (root_word) - 1
+ 7:     if root_word[0] == '"' and root_word[end] == '"':
+ 8:         root_word = root_word[1:end]
+ 9:     end = len (root_word) - 1
+10:     if root_word[0] == '\'' and root_word[end] == '\'':
+11:        root_word = root_word[1:end]
+12:     if root_word == word:
+13:         return cur_path
+14:     elif word < root_word:
+15:         if left_child_ptr.GetValue() == None:
+16:             return ""
+17:         else:
+18:             cur_path = cur_path + "L"
+19:             return DFS (left_child_ptr, word, cur_path)
+20:     else:
+21:         if right_child_ptr.GetValue() == None:
+22:             return ""
+23:         else:
+24:             cur_path = cur_path + "R"
+25:             return DFS (right_child_ptr, word, cur_path)
+
+
+ +
+ + + +
+

Accessing & Manipulating Program Variables in Python +

+
+ +

Before we can call any Python function on any of our program's variables, we + need to get the variable into a form that Python can access. To show you how to + do this we will look at the parameters for the DFS function. The first + parameter is going to be a node in our binary search tree, put into a Python + variable. The second parameter is the word we are searching for (a string), and + the third parameter is a string representing the path from the root of the tree + to our current node.

+ +

The most interesting parameter is the first one, the Python variable that + needs to contain a node in our search tree. How can we take a variable out of + our program and put it into a Python variable? What kind of Python variable + will it be? The answers are to use the LLDB API functions, provided as part of + the LLDB Python module. Running Python from inside LLDB, LLDB will + automatically give us our current frame object as a Python variable, + "lldb.frame". This variable has the type "SBFrame" (see the LLDB API for + more information about SBFrame objects). One of the things we can do with a + frame object, is to ask it to find and return its local variable. We will call + the API function "FindVariable" on the lldb.frame object to give us our + dictionary variable as a Python variable:

+ + + root = lldb.frame.FindVariable ("dictionary") + + +

The line above, executed in the Python script interpreter in LLDB, asks the + current frame to find the variable named "dictionary" and return it. We then + store the returned value in the Python variable named "root". This answers the + question of HOW to get the variable, but it still doesn't explain WHAT actually + gets put into "root". If you examine the LLDB API, you will find that the + SBFrame method "FindVariable" returns an object of type SBValue. SBValue + objects are used, among other things, to wrap up program variables and values. + There are many useful methods defined in the SBValue class to allow you to get + information or children values out of SBValues. For complete information, see + the header file SBValue.h. The + SBValue methods that we use in our DFS function are + GetChildMemberWithName(), + GetSummary(), and GetValue().

+ +
+ + + +
+

Explaining Depth First Search Script in Detail

+
+ +

"DFS" Overview. Before diving into the details of this + code, it would be best to give a high-level overview of what it does. The nodes + in our binary search tree were defined to have type tree_node *, + which is defined as: + + +

typedef struct tree_node
+{
+  const char *word;
+  struct tree_node *left;
+  struct tree_node *right;
+} tree_node;
+ +

Lines 2-11 of DFS are getting data out of the current tree node and getting + ready to do the actual search; lines 12-25 are the actual depth-first search. + Lines 2-4 of our DFS function get the word, left and + right fields out of the current node and store them in Python + variables. Since root_word_ptr is a pointer to our word, and we + want the actual word, line 5 calls GetSummary() to get a string + containing the value out of the pointer. Since GetSummary() adds + quotes around its result, lines 6-11 strip surrounding quotes off the word.

+ +

Line 12 checks to see if the word in the current node is the one we are + searching for. If so, we are done, and line 13 returns the current path. + Otherwise, line 14 checks to see if we should go left (search word comes before + the current word). If we decide to go left, line 15 checks to see if the left + pointer child is NULL ("None" is the Python equivalent of NULL). If the left + pointer is NULL, then the word is not in this tree and we return an empty path + (line 16). Otherwise, we add an "L" to the end of our current path string, to + indicate we are going left (line 18), and then recurse on the left child (line + 19). Lines 20-25 are the same as lines 14-19, except for going right rather + than going left.

+ +

One other note: Typing something as long as our DFS function directly into + the interpreter can be difficult, as making a single typing mistake means having + to start all over. Therefore we recommend doing as we have done: Writing your + longer, more complicated script functions in a separate file (in this case + tree_utils.py) and then importing it into your LLDB Python interpreter.

+ +
+ + + +
+

Seeing the DFS Script in Action

+
+ + +

At this point we are ready to use the DFS function to see if the word "Romeo" + is in our tree or not. To actually use it in LLDB on our dictionary program, + you would do something like this:

+ + + % lldb
+ (lldb) process attach -n "dictionary"
+ Architecture set to: x86_64.
+ Process 521 stopped
+ * thread #1: tid = 0x2c03, 0x00007fff86c8bea0 libSystem.B.dylib`read$NOCANCEL + 8, stop reason = signal SIGSTOP
+ frame #0: 0x00007fff86c8bea0 libSystem.B.dylib`read$NOCANCEL + 8
+ (lldb) br s -n find_word
+ Breakpoint created: 1: name = 'find_word', locations = 1, resolved = 1
+ (lldb) c
+ Process 521 resuming
+ Process 521 stopped
+ * thread #1: tid = 0x2c03, 0x0000000100001830 dictionary`find_word + 16
+ at dictionary.c:105, stop reason = breakpoint 1.1
+ frame #0: 0x0000000100001830 dictionary`find_word + 16 at dictionary.c:105
+ 102 int
+ 103 find_word (tree_node *dictionary, char *word)
+ 104 {
+ -> 105 if (!word || !dictionary)
+ 106 return 0;
+ 107
+ 108 int compare_value = strcmp (word, dictionary->word);
+ (lldb) script
+ Python Interactive Interpreter. To exit, type 'quit()', 'exit()' or Ctrl-D.
+ >>> import tree_utils
+ >>> root = lldb.frame.FindVariable ("dictionary")
+ >>> current_path = ""
+ >>> path = tree_utils.DFS (root, "Romeo", current_path)
+ >>> print path
+ LLRRL
+ >>> ^D
+ (lldb)
+
+ +

The first bit of code above shows starting lldb, attaching to the dictionary + program, and getting to the find_word function in LLDB. The interesting part + (as far as this example is concerned) begins when we enter the + script command and drop into the embedded interactive Python + interpreter. We will go over this Python code line by line. The first line

+ + + import tree_utils + + +

imports the file where we our DFS function, tree_utils.py, into Python. + Notice that to import the file we leave off the ".py" extension. We can now + call any function in that file, giving it the prefix "tree_utils.", so that + Python knows where to look for the function. The line

+ + + root = lldb.frame.FindVariable ("dictionary") + + +

gets our program variable "dictionary" (which contains the binary search + tree) and puts it into the Python variable "root". See + Accessing & Manipulating Program Variables in Python + above for more details about how this works. The next line is

+ + + current_path = "" + + +

This line initializes the current_path from the root of the tree to our + current node. Since we are starting at the root of the tree, our current path + starts as an empty string. As we go right and left through the tree, the DFS + function will append an 'R' or an 'L' to the current path, as appropriate. The + line

+ + + path = tree_utils.DFS (root, "Romeo", current_path) + + +

calls our DFS function (prefixing it with the module name so that Python can + find it). We pass in our binary tree stored in the variable root, + the word we are searching for, and our current path. We assign whatever path + the DFS function returns to the Python variable path.

+ + +

Finally, we want to see if the word was found or not, and if so we want to + see the path through the tree to the word. So we do

+ + + print path + + +

From this we can see that the word "Romeo" was indeed found in the tree, and + the path from the root of the tree to the node containing "Romeo" is + left-left-right-right-left.

+ +
+ + + +
+

What next? Using Breakpoint Command Scripts...

+
+ +

We are halfway to figuring out what the problem is. We know the word we are + looking for is in the binary tree, and we know exactly where it is in the binary + tree. Now we need to figure out why our binary search algorithm is not finding + the word. We will do this using breakpoint command scripts.

+ + +

The idea is as follows. The binary search algorithm has two main decision + points: the decision to follow the right branch; and, the decision to follow + the left branch. We will set a breakpoint at each of these decision points, and + attach a Python breakpoint command script to each breakpoint. The breakpoint + commands will use the global path Python variable that we got from + our DFS function. Each time one of these decision breakpoints is hit, the script + will compare the actual decision with the decision the front of the + path variable says should be made (the first character of the + path). If the actual decision and the path agree, then the front character is + stripped off the path, and execution is resumed. In this case the user never + even sees the breakpoint being hit. But if the decision differs from what the + path says it should be, then the script prints out a message and does NOT resume + execution, leaving the user sitting at the first point where a wrong decision is + being made.

+ +
+ + + +
+

Side Note: Python Breakpoint Command Scripts are NOT What They Seem

+
+ +
+ + +

What do we mean by that? When you enter a Python breakpoint command in LLDB, + it appears that you are entering one or more plain lines of Python. BUT LLDB + then takes what you entered and wraps it into a Python FUNCTION (just like using + the "def" Python command). It automatically gives the function an obscure, + unique, hard-to-stumble-across function name, and gives it two parameters: + frame and bp_loc. When the breakpoint gets hit, LLDB + wraps up the frame object where the breakpoint was hit, and the breakpoint + location object for the breakpoint that was hit, and puts them into Python + variables for you. It then calls the Python function that was created for the + breakpoint command, and passes in the frame and breakpoint location objects.

+ +

So, being practical, what does this mean for you when you write your Python + breakpoint commands? It means that there are two things you need to keep in + mind: 1. If you want to access any Python variables created outside your script, + you must declare such variables to be global. If you do not + declare them as global, then the Python function will treat them as local + variables, and you will get unexpected behavior. 2. All Python + breakpoint command scripts automatically have a frame and a + bp_loc variable. The variables are pre-loaded by LLDB + with the correct context for the breakpoint. You do not have to use these + variables, but they are there if you want them.

+ +
+ + + +
+

The Decision Point Breakpoint Commands

+
+ +

This is what the Python breakpoint command script would look like for the + decision to go right:

+ +


+global path
+if path[0] == 'R':
+    path = path[1:]
+    thread = frame.GetThread()
+    process = thread.GetProcess()
+    process.Continue()
+else:
+    print "Here is the problem; going right, should go left!"
+
+ +

Just as a reminder, LLDB is going to take this script and wrap it up in a + function, like this:

+ +

+def some_unique_and_obscure_function_name (frame, bp_loc):
+    global path
+    if path[0] == 'R':
+        path = path[1:]
+        thread = frame.GetThread()
+        process = thread.GetProcess()
+        process.Continue()
+    else:
+        print "Here is the problem; going right, should go left!"
+
+ +

LLDB will call the function, passing in the correct frame and breakpoint + location whenever the breakpoint gets hit. There are several things to notice + about this function. The first one is that we are accessing and updating a + piece of state (the path variable), and actually conditioning our + behavior based upon this variable. Since the variable was defined outside of + our script (and therefore outside of the corresponding function) we need to tell + Python that we are accessing a global variable. That is what the first line of + the script does. Next we check where the path says we should go and compare it to + our decision (recall that we are at the breakpoint for the decision to go + right). If the path agrees with our decision, then we strip the first character + off of the path.

+ +

Since the decision matched the path, we want to resume execution. To do this + we make use of the frame parameter that LLDB guarantees will be + there for us. We use LLDB API functions to get the current thread from the + current frame, and then to get the process from the thread. Once we have the + process, we tell it to resume execution (using the Continue() API + function).

+ +

If the decision to go right does not agree with the path, then we do not + resume execution. We allow the breakpoint to remain stopped (by doing nothing), + and we print an informational message telling the user we have found the + problem, and what the problem is.

+ +
+ + +
+

Actually Using the Breakpoint Commands

+
+ +

Now we will look at what happens when we actually use these breakpoint + commands on our program. Doing a source list -n find_word shows + us the function containing our two decision points. Looking at the code below, + we see that we want to set our breakpoints on lines 113 and 115:

+ +

+(lldb) source list -n find_word
+File: /Volumes/Data/HD2/carolinetice/Desktop/LLDB-Web-Examples/dictionary.c.
+101 
+102 int
+103 find_word (tree_node *dictionary, char *word)
+104 {
+105   if (!word || !dictionary)
+106     return 0;
+107 
+108   int compare_value = strcmp (word, dictionary->word);
+109 
+110   if (compare_value == 0)
+111     return 1;
+112   else if (compare_value < 0)
+113     return find_word (dictionary->left, word);
+114   else
+115     return find_word (dictionary->right, word);
+116 }
+117 
+
+ +

So, we set our breakpoints, enter our breakpoint command scripts, and see + what happens:

+ +


+(lldb) breakpoint set -l 113
+Breakpoint created: 2: file ='dictionary.c', line = 113, locations = 1, resolved = 1
+(lldb) breakpoint set -l 115
+Breakpoint created: 3: file ='dictionary.c', line = 115, locations = 1, resolved = 1
+(lldb) breakpoint command add -s python 2
+Enter your Python command(s). Type 'DONE' to end.
+> global path
+> if (path[0] == 'L'):
+>     path = path[1:]
+>     thread = frame.GetThread()
+>     process = thread.GetProcess()
+>     process.Continue()
+> else:
+>     print "Here is the problem. Going left, should go right!"
+> DONE
+(lldb) breakpoint command add -s python 3
+Enter your Python command(s). Type 'DONE' to end.
+> global path
+> if (path[0] == 'R'):
+>     path = path[1:]
+>     thread = frame.GetThread()
+>     process = thread.GetProcess()
+>     process.Continue()
+> else:
+>     print "Here is the problem. Going right, should go left!"
+> DONE
+(lldb) continue
+Process 696 resuming
+Here is the problem. Going right, should go left!
+Process 696 stopped
+* thread #1: tid = 0x2d03, 0x000000010000189f dictionary`find_word + 127 at dictionary.c:115, stop reason = breakpoint 3.1
+  frame #0: 0x000000010000189f dictionary`find_word + 127 at dictionary.c:115
+    112   else if (compare_value < 0)
+    113     return find_word (dictionary->left, word);
+    114   else
+ -> 115     return find_word (dictionary->right, word);
+    116 }
+    117 
+    118 void
+(lldb)
+
+ + +

After setting our breakpoints, adding our breakpoint commands and continuing, + we run for a little bit and then hit one of our breakpoints, printing out the + error message from the breakpoint command. Apparently at this point the the + tree, our search algorithm decided to go right, but our path says the node we + want is to the left. Examining the word at the node where we stopped, and our + search word, we see:

+ + + (lldb) expr dictionary->word
+ (const char *) $1 = 0x0000000100100080 "dramatis"
+ (lldb) expr word
+ (char *) $2 = 0x00007fff5fbff108 "romeo"
+
+ +

So the word at our current node is "dramatis", and the word we are searching + for is "romeo". "romeo" comes after "dramatis" alphabetically, so it seems like + going right would be the correct decision. Let's ask Python what it thinks the + path from the current node to our word is:

+ + + (lldb) script print path
+ LLRRL
+
+ +

According to Python we need to go left-left-right-right-left from our current + node to find the word we are looking for. Let's double check our tree, and see + what word it has at that node:

+ + + (lldb) expr dictionary->left->left->right->right->left->word
+ (const char *) $4 = 0x0000000100100880 "Romeo"
+
+ +

So the word we are searching for is "romeo" and the word at our DFS location + is "Romeo". Aha! One is uppercase and the other is lowercase: We seem to have + a case conversion problem somewhere in our program (we do).

+ +

This is the end of our example on how you might use Python scripting in LLDB + to help you find bugs in your program.

+ +
+ + +
+

Source Files for The Example

+
+ + +
+ + +

The complete code for the Dictionary program (with case-conversion bug), + the DFS function and other Python script examples (tree_utils.py) used for this + example are available via following file links:

+ +tree_utils.py - Example Python functions using LLDB's API, including DFS
+dictionary.c - Sample dictionary program, with bug
+ +

The text for "Romeo and Juliet" can be obtained from the Gutenberg Project + (http://www.gutenberg.org).

+
+
+
+
+ + Propchange: lldb/trunk/www/scripting.html ------------------------------------------------------------------------------ svn:executable = * From gclayton at apple.com Thu Jun 2 18:50:04 2011 From: gclayton at apple.com (Greg Clayton) Date: Thu, 02 Jun 2011 23:50:04 -0000 Subject: [Lldb-commits] [lldb] r132515 - /lldb/trunk/www/sidebar.incl Message-ID: <20110602235004.C284F2A6C12C@llvm.org> Author: gclayton Date: Thu Jun 2 18:50:04 2011 New Revision: 132515 URL: http://llvm.org/viewvc/llvm-project?rev=132515&view=rev Log: Cleanup the sidebar and include a link to the new python scripting tutorial. Modified: lldb/trunk/www/sidebar.incl Modified: lldb/trunk/www/sidebar.incl URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/www/sidebar.incl?rev=132515&r1=132514&r2=132515&view=diff ============================================================================== --- lldb/trunk/www/sidebar.incl (original) +++ lldb/trunk/www/sidebar.incl Thu Jun 2 18:50:04 2011 @@ -8,8 +8,6 @@
  • Goals
  • Features
  • Status
  • -
  • Tutorial
  • -
  • LLDB and GDB
  • From jingham at apple.com Thu Jun 2 18:58:26 2011 From: jingham at apple.com (Jim Ingham) Date: Thu, 02 Jun 2011 23:58:26 -0000 Subject: [Lldb-commits] [lldb] r132517 - in /lldb/trunk: include/lldb/Core/Debugger.h source/Breakpoint/BreakpointLocation.cpp source/Commands/CommandObjectBreakpointCommand.cpp source/Core/Debugger.cpp source/Target/Target.cpp Message-ID: <20110602235826.957952A6C12C@llvm.org> Author: jingham Date: Thu Jun 2 18:58:26 2011 New Revision: 132517 URL: http://llvm.org/viewvc/llvm-project?rev=132517&view=rev Log: Added Debugger::GetAsync{Output/Error}Stream, and use it to print parse errors when we go to run a breakpoint condition. Modified: lldb/trunk/include/lldb/Core/Debugger.h lldb/trunk/source/Breakpoint/BreakpointLocation.cpp lldb/trunk/source/Commands/CommandObjectBreakpointCommand.cpp lldb/trunk/source/Core/Debugger.cpp lldb/trunk/source/Target/Target.cpp Modified: lldb/trunk/include/lldb/Core/Debugger.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/Debugger.h?rev=132517&r1=132516&r2=132517&view=diff ============================================================================== --- lldb/trunk/include/lldb/Core/Debugger.h (original) +++ lldb/trunk/include/lldb/Core/Debugger.h Thu Jun 2 18:58:26 2011 @@ -321,6 +321,12 @@ return m_error_file; } + lldb::StreamSP + GetAsyncOutputStream (); + + lldb::StreamSP + GetAsyncErrorStream (); + CommandInterpreter & GetCommandInterpreter () { Modified: lldb/trunk/source/Breakpoint/BreakpointLocation.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Breakpoint/BreakpointLocation.cpp?rev=132517&r1=132516&r2=132517&view=diff ============================================================================== --- lldb/trunk/source/Breakpoint/BreakpointLocation.cpp (original) +++ lldb/trunk/source/Breakpoint/BreakpointLocation.cpp Thu Jun 2 18:58:26 2011 @@ -16,6 +16,7 @@ #include "lldb/Breakpoint/BreakpointLocation.h" #include "lldb/Breakpoint/BreakpointID.h" #include "lldb/Breakpoint/StoppointCallbackContext.h" +#include "lldb/Core/Debugger.h" #include "lldb/Core/Log.h" #include "lldb/Target/Target.h" #include "lldb/Target/ThreadPlan.h" @@ -219,9 +220,6 @@ if (m_hit_count <= GetIgnoreCount()) return false; - // Next in order of importance is the condition. See if it is true: - StreamString errors; - // We only run synchronous callbacks in ShouldStop: context->is_synchronous = true; should_stop = InvokeCallback (context); @@ -230,29 +228,40 @@ if (should_stop) { + // We need to make sure the user sees any parse errors in their condition, so we'll hook the + // constructor errors up to the debugger's Async I/O. + + StreamString errors; ThreadPlanSP condition_plan_sp(GetThreadPlanToTestCondition(context->exe_ctx, errors)); - log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_BREAKPOINTS); - if (log && errors.GetSize() > 0) + + if (condition_plan_sp == NULL) { - log->Printf("Error evaluating condition: \"%s\".\n", errors.GetData()); + if (log) + log->Printf("Error evaluating condition: \"%s\"\n", errors.GetData()); + + Debugger &debugger = context->exe_ctx.target->GetDebugger(); + StreamSP error_sp = debugger.GetAsyncErrorStream (); + error_sp->PutCString ("Error parsing breakpoint condition:\n"); + error_sp->PutCString (errors.GetData()); + error_sp->EOL(); + error_sp->Flush(); + } - else if (condition_plan_sp != NULL) + else { + // Queue our condition, then continue so that we can run it. context->exe_ctx.thread->QueueThreadPlan(condition_plan_sp, false); - return false; + should_stop = false; } } - if (should_stop) + if (log) { - log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_BREAKPOINTS); - if (log) - { - StreamString s; - GetDescription (&s, lldb::eDescriptionLevelVerbose); - log->Printf ("Hit breakpoint location: %s\n", s.GetData()); - } + StreamString s; + GetDescription (&s, lldb::eDescriptionLevelVerbose); + log->Printf ("Hit breakpoint location: %s, %s.\n", s.GetData(), should_stop ? "stopping" : "continuing"); } + return should_stop; } Modified: lldb/trunk/source/Commands/CommandObjectBreakpointCommand.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectBreakpointCommand.cpp?rev=132517&r1=132516&r2=132517&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectBreakpointCommand.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectBreakpointCommand.cpp Thu Jun 2 18:58:26 2011 @@ -803,10 +803,8 @@ // Rig up the results secondary output stream to the debugger's, so the output will come out synchronously // if the debugger is set up that way. - StreamSP output_stream (new StreamAsynchronousIO (debugger.GetCommandInterpreter(), - CommandInterpreter::eBroadcastBitAsynchronousOutputData)); - StreamSP error_stream (new StreamAsynchronousIO (debugger.GetCommandInterpreter(), - CommandInterpreter::eBroadcastBitAsynchronousErrorData)); + StreamSP output_stream (debugger.GetAsyncOutputStream()); + StreamSP error_stream (debugger.GetAsyncErrorStream()); result.SetImmediateOutputStream (output_stream); result.SetImmediateErrorStream (error_stream); Modified: lldb/trunk/source/Core/Debugger.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/Debugger.cpp?rev=132517&r1=132516&r2=132517&view=diff ============================================================================== --- lldb/trunk/source/Core/Debugger.cpp (original) +++ lldb/trunk/source/Core/Debugger.cpp Thu Jun 2 18:58:26 2011 @@ -13,6 +13,7 @@ #include "lldb/Core/InputReader.h" #include "lldb/Core/RegisterValue.h" #include "lldb/Core/State.h" +#include "lldb/Core/StreamAsynchronousIO.h" #include "lldb/Core/StreamString.h" #include "lldb/Core/Timer.h" #include "lldb/Host/Terminal.h" @@ -600,6 +601,20 @@ } } +StreamSP +Debugger::GetAsyncOutputStream () +{ + return StreamSP (new StreamAsynchronousIO (GetCommandInterpreter(), + CommandInterpreter::eBroadcastBitAsynchronousOutputData)); +} + +StreamSP +Debugger::GetAsyncErrorStream () +{ + return StreamSP (new StreamAsynchronousIO (GetCommandInterpreter(), + CommandInterpreter::eBroadcastBitAsynchronousErrorData)); +} + DebuggerSP Debugger::FindDebuggerWithID (lldb::user_id_t id) { Modified: lldb/trunk/source/Target/Target.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/Target.cpp?rev=132517&r1=132516&r2=132517&view=diff ============================================================================== --- lldb/trunk/source/Target/Target.cpp (original) +++ lldb/trunk/source/Target/Target.cpp Thu Jun 2 18:58:26 2011 @@ -1199,12 +1199,8 @@ if (num_exe_ctx == 0) return; - StreamSP output_stream (new StreamAsynchronousIO (m_debugger.GetCommandInterpreter(), - CommandInterpreter::eBroadcastBitAsynchronousOutputData)); - StreamSP error_stream (new StreamAsynchronousIO (m_debugger.GetCommandInterpreter(), - CommandInterpreter::eBroadcastBitAsynchronousErrorData)); - result.SetImmediateOutputStream (output_stream); - result.SetImmediateErrorStream (error_stream); + result.SetImmediateOutputStream (m_debugger.GetAsyncOutputStream()); + result.SetImmediateErrorStream (m_debugger.GetAsyncErrorStream()); bool keep_going = true; bool hooks_ran = false; From ctice at apple.com Fri Jun 3 11:38:17 2011 From: ctice at apple.com (Caroline Tice) Date: Fri, 03 Jun 2011 16:38:17 -0000 Subject: [Lldb-commits] [lldb] r132554 - /lldb/trunk/www/scripting.html Message-ID: <20110603163817.C985C2A6C12C@llvm.org> Author: ctice Date: Fri Jun 3 11:38:17 2011 New Revision: 132554 URL: http://llvm.org/viewvc/llvm-project?rev=132554&view=rev Log: Make a few minor changes/corrections to scripting example on the web. Modified: lldb/trunk/www/scripting.html Modified: lldb/trunk/www/scripting.html URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/www/scripting.html?rev=132554&r1=132553&r2=132554&view=diff ============================================================================== --- lldb/trunk/www/scripting.html (original) +++ lldb/trunk/www/scripting.html Fri Jun 3 11:38:17 2011 @@ -210,15 +210,15 @@ you would do something like this:

    - % lldb
    - (lldb) process attach -n "dictionary"
    + % lldb
    + (lldb) process attach -n "dictionary"
    Architecture set to: x86_64.
    Process 521 stopped
    * thread #1: tid = 0x2c03, 0x00007fff86c8bea0 libSystem.B.dylib`read$NOCANCEL + 8, stop reason = signal SIGSTOP
    frame #0: 0x00007fff86c8bea0 libSystem.B.dylib`read$NOCANCEL + 8
    - (lldb) br s -n find_word
    + (lldb) breakpoint set -n find_word
    Breakpoint created: 1: name = 'find_word', locations = 1, resolved = 1
    - (lldb) c
    + (lldb) continue
    Process 521 resuming
    Process 521 stopped
    * thread #1: tid = 0x2c03, 0x0000000100001830 dictionary`find_word + 16
    @@ -231,15 +231,15 @@ 106 return 0;
    107
    108 int compare_value = strcmp (word, dictionary->word);
    - (lldb) script
    + (lldb) script
    Python Interactive Interpreter. To exit, type 'quit()', 'exit()' or Ctrl-D.
    - >>> import tree_utils
    - >>> root = lldb.frame.FindVariable ("dictionary")
    - >>> current_path = ""
    - >>> path = tree_utils.DFS (root, "Romeo", current_path)
    - >>> print path
    + >>> import tree_utils
    + >>> root = lldb.frame.FindVariable ("dictionary")
    + >>> current_path = ""
    + >>> path = tree_utils.DFS (root, "Romeo", current_path)
    + >>> print path
    LLRRL
    - >>> ^D
    + >>> ^D
    (lldb)
    @@ -253,7 +253,7 @@ import tree_utils -

    imports the file where we our DFS function, tree_utils.py, into Python. +

    imports the file where we wrote our DFS function, tree_utils.py, into Python. Notice that to import the file we leave off the ".py" extension. We can now call any function in that file, giving it the prefix "tree_utils.", so that Python knows where to look for the function. The line

    From peter at pcc.me.uk Fri Jun 3 15:39:58 2011 From: peter at pcc.me.uk (Peter Collingbourne) Date: Fri, 03 Jun 2011 20:39:58 -0000 Subject: [Lldb-commits] [lldb] r132582 - /lldb/trunk/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp Message-ID: <20110603203958.357262A6C12C@llvm.org> Author: pcc Date: Fri Jun 3 15:39:58 2011 New Revision: 132582 URL: http://llvm.org/viewvc/llvm-project?rev=132582&view=rev Log: Scan dynamic symbol table of ELF object files Modified: lldb/trunk/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp Modified: lldb/trunk/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp?rev=132582&r1=132581&r2=132582&view=diff ============================================================================== --- lldb/trunk/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp (original) +++ lldb/trunk/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp Fri Jun 3 15:39:58 2011 @@ -1085,7 +1085,7 @@ for (SectionHeaderCollIter I = m_section_headers.begin(); I != m_section_headers.end(); ++I) { - if (I->sh_type == SHT_SYMTAB) + if (I->sh_type == SHT_SYMTAB || I->sh_type == SHT_DYNSYM) { const ELFSectionHeader &symtab_header = *I; user_id_t section_id = SectionIndex(I); From peter at pcc.me.uk Fri Jun 3 15:40:12 2011 From: peter at pcc.me.uk (Peter Collingbourne) Date: Fri, 03 Jun 2011 20:40:12 -0000 Subject: [Lldb-commits] [lldb] r132583 - /lldb/trunk/source/Expression/ClangExpressionParser.cpp Message-ID: <20110603204012.EFAF62A6C12C@llvm.org> Author: pcc Date: Fri Jun 3 15:40:12 2011 New Revision: 132583 URL: http://llvm.org/viewvc/llvm-project?rev=132583&view=rev Log: Disable MCJIT on non-Darwin platforms Currently the runtime dynamic linker lacks object file support for anything other than Mach-O. Modified: lldb/trunk/source/Expression/ClangExpressionParser.cpp Modified: lldb/trunk/source/Expression/ClangExpressionParser.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/ClangExpressionParser.cpp?rev=132583&r1=132582&r2=132583&view=diff ============================================================================== --- lldb/trunk/source/Expression/ClangExpressionParser.cpp (original) +++ lldb/trunk/source/Expression/ClangExpressionParser.cpp Fri Jun 3 15:40:12 2011 @@ -52,7 +52,10 @@ #include "llvm/ADT/StringRef.h" #include "llvm/ExecutionEngine/ExecutionEngine.h" -//#define USE_STANDARD_JIT +#if !defined(__APPLE__) +#define USE_STANDARD_JIT +#endif + #if defined (USE_STANDARD_JIT) #include "llvm/ExecutionEngine/JIT.h" #else From peter at pcc.me.uk Fri Jun 3 15:40:38 2011 From: peter at pcc.me.uk (Peter Collingbourne) Date: Fri, 03 Jun 2011 20:40:38 -0000 Subject: [Lldb-commits] [lldb] r132584 - in /lldb/trunk/source/Plugins/Process: Utility/InferiorCallPOSIX.cpp Utility/InferiorCallPOSIX.h gdb-remote/ProcessGDBRemote.cpp Message-ID: <20110603204038.C3C4A2A6C12C@llvm.org> Author: pcc Date: Fri Jun 3 15:40:38 2011 New Revision: 132584 URL: http://llvm.org/viewvc/llvm-project?rev=132584&view=rev Log: Move inferior mmap/munmap call code into their own functions in utility lib Added: lldb/trunk/source/Plugins/Process/Utility/InferiorCallPOSIX.cpp lldb/trunk/source/Plugins/Process/Utility/InferiorCallPOSIX.h Modified: lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp Added: lldb/trunk/source/Plugins/Process/Utility/InferiorCallPOSIX.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Utility/InferiorCallPOSIX.cpp?rev=132584&view=auto ============================================================================== --- lldb/trunk/source/Plugins/Process/Utility/InferiorCallPOSIX.cpp (added) +++ lldb/trunk/source/Plugins/Process/Utility/InferiorCallPOSIX.cpp Fri Jun 3 15:40:38 2011 @@ -0,0 +1,179 @@ +#include "InferiorCallPOSIX.h" +#include "lldb/Core/StreamFile.h" +#include "lldb/Core/Value.h" +#include "lldb/Symbol/SymbolContext.h" +#include "lldb/Target/ExecutionContext.h" +#include "lldb/Target/Process.h" +#include "lldb/Target/Target.h" +#include "lldb/Target/ThreadPlanCallFunction.h" + +#include + +using namespace lldb; +using namespace lldb_private; + +bool lldb_private::InferiorCallMmap(Process *process, addr_t &allocated_addr, + addr_t addr, addr_t length, unsigned prot, + unsigned flags, addr_t fd, addr_t offset) { + Thread *thread = process->GetThreadList().GetSelectedThread().get(); + if (thread == NULL) + thread = process->GetThreadList().GetThreadAtIndex(0).get(); + + const bool append = true; + const bool include_symbols = true; + SymbolContextList sc_list; + const uint32_t count + = process->GetTarget().GetImages().FindFunctions (ConstString ("mmap"), + eFunctionNameTypeFull, + include_symbols, + append, + sc_list); + if (count > 0) + { + SymbolContext sc; + if (sc_list.GetContextAtIndex(0, sc)) + { + const uint32_t range_scope = eSymbolContextFunction | eSymbolContextSymbol; + const bool use_inline_block_range = false; + const bool stop_other_threads = true; + const bool discard_on_error = true; + const bool try_all_threads = true; + const uint32_t single_thread_timeout_usec = 500000; + + addr_t prot_arg, flags_arg = 0; + if (prot == eMmapProtNone) + prot_arg = PROT_NONE; + else { + prot_arg = 0; + if (prot & eMmapProtExec) + prot_arg |= PROT_EXEC; + if (prot & eMmapProtRead) + prot_arg |= PROT_READ; + if (prot & eMmapProtWrite) + prot_arg |= PROT_WRITE; + } + + if (flags & eMmapFlagsPrivate) + flags_arg |= MAP_PRIVATE; + if (flags & eMmapFlagsAnon) + flags_arg |= MAP_ANON; + + AddressRange mmap_range; + if (sc.GetAddressRange(range_scope, 0, use_inline_block_range, mmap_range)) + { + ThreadPlanCallFunction *call_function_thread_plan + = new ThreadPlanCallFunction (*thread, + mmap_range.GetBaseAddress(), + stop_other_threads, + discard_on_error, + &addr, + &length, + &prot_arg, + &flags_arg, + &fd, + &offset); + lldb::ThreadPlanSP call_plan_sp (call_function_thread_plan); + if (call_plan_sp) + { + ValueSP return_value_sp (new Value); + ClangASTContext *clang_ast_context = process->GetTarget().GetScratchClangASTContext(); + lldb::clang_type_t clang_void_ptr_type = clang_ast_context->GetVoidPtrType(false); + return_value_sp->SetValueType (Value::eValueTypeScalar); + return_value_sp->SetContext (Value::eContextTypeClangType, clang_void_ptr_type); + call_function_thread_plan->RequestReturnValue (return_value_sp); + + StreamFile error_strm; + StackFrame *frame = thread->GetStackFrameAtIndex (0).get(); + if (frame) + { + ExecutionContext exe_ctx; + frame->CalculateExecutionContext (exe_ctx); + ExecutionResults result = process->RunThreadPlan (exe_ctx, + call_plan_sp, + stop_other_threads, + try_all_threads, + discard_on_error, + single_thread_timeout_usec, + error_strm); + if (result == eExecutionCompleted) + { + allocated_addr = return_value_sp->GetScalar().ULongLong(); + if (process->GetAddressByteSize() == 4) + { + if (allocated_addr == UINT32_MAX) + return false; + } + return true; + } + } + } + } + } + } + + return false; +} + +bool lldb_private::InferiorCallMunmap(Process *process, addr_t addr, + addr_t length) { + Thread *thread = process->GetThreadList().GetSelectedThread().get(); + if (thread == NULL) + thread = process->GetThreadList().GetThreadAtIndex(0).get(); + + const bool append = true; + const bool include_symbols = true; + SymbolContextList sc_list; + const uint32_t count + = process->GetTarget().GetImages().FindFunctions (ConstString ("munmap"), + eFunctionNameTypeFull, + include_symbols, + append, + sc_list); + if (count > 0) + { + SymbolContext sc; + if (sc_list.GetContextAtIndex(0, sc)) + { + const uint32_t range_scope = eSymbolContextFunction | eSymbolContextSymbol; + const bool use_inline_block_range = false; + const bool stop_other_threads = true; + const bool discard_on_error = true; + const bool try_all_threads = true; + const uint32_t single_thread_timeout_usec = 500000; + + AddressRange munmap_range; + if (sc.GetAddressRange(range_scope, 0, use_inline_block_range, munmap_range)) + { + lldb::ThreadPlanSP call_plan_sp (new ThreadPlanCallFunction (*thread, + munmap_range.GetBaseAddress(), + stop_other_threads, + discard_on_error, + &addr, + &length)); + if (call_plan_sp) + { + StreamFile error_strm; + StackFrame *frame = thread->GetStackFrameAtIndex (0).get(); + if (frame) + { + ExecutionContext exe_ctx; + frame->CalculateExecutionContext (exe_ctx); + ExecutionResults result = process->RunThreadPlan (exe_ctx, + call_plan_sp, + stop_other_threads, + try_all_threads, + discard_on_error, + single_thread_timeout_usec, + error_strm); + if (result == eExecutionCompleted) + { + return true; + } + } + } + } + } + } + + return false; +} Added: lldb/trunk/source/Plugins/Process/Utility/InferiorCallPOSIX.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Utility/InferiorCallPOSIX.h?rev=132584&view=auto ============================================================================== --- lldb/trunk/source/Plugins/Process/Utility/InferiorCallPOSIX.h (added) +++ lldb/trunk/source/Plugins/Process/Utility/InferiorCallPOSIX.h Fri Jun 3 15:40:38 2011 @@ -0,0 +1,41 @@ +//===-- InferiorCallPOSIX.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_InferiorCallPOSIX_h_ +#define lldb_InferiorCallPOSIX_h_ + +// Inferior execution of POSIX functions. + +#include "lldb/lldb-types.h" + +namespace lldb_private { + +class Process; + +enum MmapProt { + eMmapProtNone = 0, + eMmapProtExec = 1, + eMmapProtRead = 2, + eMmapProtWrite = 4 +}; + +enum MmapFlags { + eMmapFlagsPrivate = 1, + eMmapFlagsAnon = 2 +}; + +bool InferiorCallMmap(Process *proc, lldb::addr_t &allocated_addr, + lldb::addr_t addr, lldb::addr_t length, unsigned prot, + unsigned flags, lldb::addr_t fd, lldb::addr_t offset); + +bool InferiorCallMunmap(Process *proc, lldb::addr_t addr, lldb::addr_t length); + +} // namespace lldb_private + +#endif // lldb_InferiorCallPOSIX_h_ Modified: lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp?rev=132584&r1=132583&r2=132584&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp (original) +++ lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp Fri Jun 3 15:40:38 2011 @@ -45,6 +45,7 @@ // Project includes #include "lldb/Host/Host.h" +#include "Plugins/Process/Utility/InferiorCallPOSIX.h" #include "Utility/StringExtractorGDBRemote.h" #include "GDBRemoteRegisterContext.h" #include "ProcessGDBRemote.h" @@ -1561,97 +1562,20 @@ return allocated_addr; case eLazyBoolNo: - // Call mmap() to create executable memory in the inferior.. - { - Thread *thread = GetThreadList().GetSelectedThread().get(); - if (thread == NULL) - thread = GetThreadList().GetThreadAtIndex(0).get(); - - const bool append = true; - const bool include_symbols = true; - SymbolContextList sc_list; - const uint32_t count = m_target.GetImages().FindFunctions (ConstString ("mmap"), - eFunctionNameTypeFull, - include_symbols, - append, - sc_list); - if (count > 0) - { - SymbolContext sc; - if (sc_list.GetContextAtIndex(0, sc)) - { - const uint32_t range_scope = eSymbolContextFunction | eSymbolContextSymbol; - const bool use_inline_block_range = false; - const bool stop_other_threads = true; - const bool discard_on_error = true; - const bool try_all_threads = true; - const uint32_t single_thread_timeout_usec = 500000; - addr_t arg1_addr = 0; - addr_t arg2_len = size; - addr_t arg3_prot = PROT_NONE; - addr_t arg4_flags = MAP_ANON | MAP_PRIVATE; - addr_t arg5_fd = -1; - addr_t arg6_offset = 0; - if (permissions & lldb::ePermissionsReadable) - arg3_prot |= PROT_READ; - if (permissions & lldb::ePermissionsWritable) - arg3_prot |= PROT_WRITE; - if (permissions & lldb::ePermissionsExecutable) - arg3_prot |= PROT_EXEC; - - AddressRange mmap_range; - if (sc.GetAddressRange(range_scope, 0, use_inline_block_range, mmap_range)) - { - ThreadPlanCallFunction *call_function_thread_plan = new ThreadPlanCallFunction (*thread, - mmap_range.GetBaseAddress(), - stop_other_threads, - discard_on_error, - &arg1_addr, - &arg2_len, - &arg3_prot, - &arg4_flags, - &arg5_fd, - &arg6_offset); - lldb::ThreadPlanSP call_plan_sp (call_function_thread_plan); - if (call_plan_sp) - { - ValueSP return_value_sp (new Value); - ClangASTContext *clang_ast_context = m_target.GetScratchClangASTContext(); - lldb::clang_type_t clang_void_ptr_type = clang_ast_context->GetVoidPtrType(false); - return_value_sp->SetValueType (Value::eValueTypeScalar); - return_value_sp->SetContext (Value::eContextTypeClangType, clang_void_ptr_type); - call_function_thread_plan->RequestReturnValue (return_value_sp); - - StreamFile error_strm; - StackFrame *frame = thread->GetStackFrameAtIndex (0).get(); - if (frame) - { - ExecutionContext exe_ctx; - frame->CalculateExecutionContext (exe_ctx); - ExecutionResults result = RunThreadPlan (exe_ctx, - call_plan_sp, - stop_other_threads, - try_all_threads, - discard_on_error, - single_thread_timeout_usec, - error_strm); - if (result == eExecutionCompleted) - { - allocated_addr = return_value_sp->GetScalar().ULongLong(); - if (GetAddressByteSize() == 4) - { - if (allocated_addr == UINT32_MAX) - allocated_addr = LLDB_INVALID_ADDRESS; - } - if (allocated_addr != LLDB_INVALID_ADDRESS) - m_addr_to_mmap_size[allocated_addr] = size; - } - } - } - } - } - } - } + // Call mmap() to create memory in the inferior.. + unsigned prot = 0; + if (permissions & lldb::ePermissionsReadable) + prot |= eMmapProtRead; + if (permissions & lldb::ePermissionsWritable) + prot |= eMmapProtWrite; + if (permissions & lldb::ePermissionsExecutable) + prot |= eMmapProtExec; + + if (InferiorCallMmap(this, allocated_addr, 0, size, prot, + eMmapFlagsAnon | eMmapFlagsPrivate, -1, 0)) + m_addr_to_mmap_size[allocated_addr] = size; + else + allocated_addr = LLDB_INVALID_ADDRESS; break; } @@ -1682,71 +1606,14 @@ break; case eLazyBoolNo: - // Call munmap() to create executable memory in the inferior.. + // Call munmap() to deallocate memory in the inferior.. { MMapMap::iterator pos = m_addr_to_mmap_size.find(addr); - if (pos != m_addr_to_mmap_size.end()) - { - Thread *thread = GetThreadList().GetSelectedThread().get(); - if (thread == NULL) - thread = GetThreadList().GetThreadAtIndex(0).get(); - - const bool append = true; - const bool include_symbols = true; - SymbolContextList sc_list; - const uint32_t count = m_target.GetImages().FindFunctions (ConstString ("munmap"), - eFunctionNameTypeFull, - include_symbols, - append, - sc_list); - if (count > 0) - { - SymbolContext sc; - if (sc_list.GetContextAtIndex(0, sc)) - { - const uint32_t range_scope = eSymbolContextFunction | eSymbolContextSymbol; - const bool use_inline_block_range = false; - const bool stop_other_threads = true; - const bool discard_on_error = true; - const bool try_all_threads = true; - const uint32_t single_thread_timeout_usec = 500000; - addr_t arg1_addr = addr; - addr_t arg2_len = pos->second; - - AddressRange munmap_range; - if (sc.GetAddressRange(range_scope, 0, use_inline_block_range, munmap_range)) - { - lldb::ThreadPlanSP call_plan_sp (new ThreadPlanCallFunction (*thread, - munmap_range.GetBaseAddress(), - stop_other_threads, - discard_on_error, - &arg1_addr, - &arg2_len)); - if (call_plan_sp) - { - StreamFile error_strm; - StackFrame *frame = thread->GetStackFrameAtIndex (0).get(); - if (frame) - { - ExecutionContext exe_ctx; - frame->CalculateExecutionContext (exe_ctx); - ExecutionResults result = RunThreadPlan (exe_ctx, - call_plan_sp, - stop_other_threads, - try_all_threads, - discard_on_error, - single_thread_timeout_usec, - error_strm); - if (result == eExecutionCompleted) - { - m_addr_to_mmap_size.erase (pos); - } - } - } - } - } - } - } + if (pos != m_addr_to_mmap_size.end() && + InferiorCallMunmap(this, addr, pos->second)) + m_addr_to_mmap_size.erase (pos); + else + error.SetErrorStringWithFormat("unable to deallocate memory at 0x%llx", addr); } break; } From peter at pcc.me.uk Fri Jun 3 15:40:44 2011 From: peter at pcc.me.uk (Peter Collingbourne) Date: Fri, 03 Jun 2011 20:40:44 -0000 Subject: [Lldb-commits] [lldb] r132585 - in /lldb/trunk/source/Plugins/Process/Linux: ProcessLinux.cpp ProcessLinux.h Message-ID: <20110603204044.9B1862A6C12D@llvm.org> Author: pcc Date: Fri Jun 3 15:40:44 2011 New Revision: 132585 URL: http://llvm.org/viewvc/llvm-project?rev=132585&view=rev Log: Implement ProcessLinux::Do{Allocate,Deallocate}Memory using inferior mmap/munmap calls Modified: lldb/trunk/source/Plugins/Process/Linux/ProcessLinux.cpp lldb/trunk/source/Plugins/Process/Linux/ProcessLinux.h Modified: lldb/trunk/source/Plugins/Process/Linux/ProcessLinux.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Linux/ProcessLinux.cpp?rev=132585&r1=132584&r2=132585&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Process/Linux/ProcessLinux.cpp (original) +++ lldb/trunk/source/Plugins/Process/Linux/ProcessLinux.cpp Fri Jun 3 15:40:44 2011 @@ -13,12 +13,14 @@ // C++ Includes // Other libraries and framework includes #include "lldb/Core/PluginManager.h" +#include "lldb/Core/State.h" #include "lldb/Host/Host.h" #include "lldb/Symbol/ObjectFile.h" #include "lldb/Target/DynamicLoader.h" #include "lldb/Target/Target.h" #include "ProcessLinux.h" +#include "Plugins/Process/Utility/InferiorCallPOSIX.h" #include "ProcessMonitor.h" #include "LinuxThread.h" @@ -345,19 +347,40 @@ ProcessLinux::DoAllocateMemory(size_t size, uint32_t permissions, Error &error) { - return 0; -} + addr_t allocated_addr = LLDB_INVALID_ADDRESS; -addr_t -ProcessLinux::AllocateMemory(size_t size, uint32_t permissions, Error &error) -{ - return 0; + unsigned prot = 0; + if (permissions & lldb::ePermissionsReadable) + prot |= eMmapProtRead; + if (permissions & lldb::ePermissionsWritable) + prot |= eMmapProtWrite; + if (permissions & lldb::ePermissionsExecutable) + prot |= eMmapProtExec; + + if (InferiorCallMmap(this, allocated_addr, 0, size, prot, + eMmapFlagsAnon | eMmapFlagsPrivate, -1, 0)) { + m_addr_to_mmap_size[allocated_addr] = size; + error.Clear(); + } else { + allocated_addr = LLDB_INVALID_ADDRESS; + error.SetErrorStringWithFormat("unable to allocate %zu bytes of memory with permissions %s", size, GetPermissionsAsCString (permissions)); + } + + return allocated_addr; } Error -ProcessLinux::DoDeallocateMemory(lldb::addr_t ptr) +ProcessLinux::DoDeallocateMemory(lldb::addr_t addr) { - return Error(1, eErrorTypeGeneric); + Error error; + MMapMap::iterator pos = m_addr_to_mmap_size.find(addr); + if (pos != m_addr_to_mmap_size.end() && + InferiorCallMunmap(this, addr, pos->second)) + m_addr_to_mmap_size.erase (pos); + else + error.SetErrorStringWithFormat("unable to deallocate memory at 0x%llx", addr); + + return error; } size_t Modified: lldb/trunk/source/Plugins/Process/Linux/ProcessLinux.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Linux/ProcessLinux.h?rev=132585&r1=132584&r2=132585&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Process/Linux/ProcessLinux.h (original) +++ lldb/trunk/source/Plugins/Process/Linux/ProcessLinux.h Fri Jun 3 15:40:44 2011 @@ -114,10 +114,6 @@ DoAllocateMemory(size_t size, uint32_t permissions, lldb_private::Error &error); - lldb::addr_t - AllocateMemory(size_t size, uint32_t permissions, - lldb_private::Error &error); - virtual lldb_private::Error DoDeallocateMemory(lldb::addr_t ptr); @@ -220,6 +216,9 @@ /// Returns true if the process is stopped. bool IsStopped(); + + typedef std::map MMapMap; + MMapMap m_addr_to_mmap_size; }; #endif // liblldb_MacOSXProcess_H_ From peter at pcc.me.uk Fri Jun 3 15:40:54 2011 From: peter at pcc.me.uk (Peter Collingbourne) Date: Fri, 03 Jun 2011 20:40:54 -0000 Subject: [Lldb-commits] [lldb] r132586 - in /lldb/trunk: include/lldb/Target/Thread.h source/Plugins/Process/Linux/LinuxThread.cpp source/Plugins/Process/Linux/LinuxThread.h source/Plugins/Process/MacOSX-User/source/ThreadMacOSX.cpp source/Plugins/Process/MacOSX-User/source/ThreadMacOSX.h source/Plugins/Process/gdb-remote/ThreadGDBRemote.cpp source/Plugins/Process/gdb-remote/ThreadGDBRemote.h source/Target/Thread.cpp Message-ID: <20110603204055.07EAC2A6C12C@llvm.org> Author: pcc Date: Fri Jun 3 15:40:54 2011 New Revision: 132586 URL: http://llvm.org/viewvc/llvm-project?rev=132586&view=rev Log: Move SaveFrameZeroState and RestoreSaveFrameZero implementations to Thread base class Modified: lldb/trunk/include/lldb/Target/Thread.h lldb/trunk/source/Plugins/Process/Linux/LinuxThread.cpp lldb/trunk/source/Plugins/Process/Linux/LinuxThread.h lldb/trunk/source/Plugins/Process/MacOSX-User/source/ThreadMacOSX.cpp lldb/trunk/source/Plugins/Process/MacOSX-User/source/ThreadMacOSX.h lldb/trunk/source/Plugins/Process/gdb-remote/ThreadGDBRemote.cpp lldb/trunk/source/Plugins/Process/gdb-remote/ThreadGDBRemote.h lldb/trunk/source/Target/Thread.cpp Modified: lldb/trunk/include/lldb/Target/Thread.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/Thread.h?rev=132586&r1=132585&r2=132586&view=diff ============================================================================== --- lldb/trunk/include/lldb/Target/Thread.h (original) +++ lldb/trunk/include/lldb/Target/Thread.h Fri Jun 3 15:40:54 2011 @@ -751,10 +751,10 @@ SetStopInfo (const lldb::StopInfoSP &stop_info_sp); virtual bool - SaveFrameZeroState (RegisterCheckpoint &checkpoint) = 0; + SaveFrameZeroState (RegisterCheckpoint &checkpoint); virtual bool - RestoreSaveFrameZero (const RegisterCheckpoint &checkpoint) = 0; + RestoreSaveFrameZero (const RegisterCheckpoint &checkpoint); virtual lldb_private::Unwind * GetUnwinder () = 0; Modified: lldb/trunk/source/Plugins/Process/Linux/LinuxThread.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Linux/LinuxThread.cpp?rev=132586&r1=132585&r2=132586&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Process/Linux/LinuxThread.cpp (original) +++ lldb/trunk/source/Plugins/Process/Linux/LinuxThread.cpp Fri Jun 3 15:40:54 2011 @@ -85,18 +85,6 @@ return m_reg_context_sp; } -bool -LinuxThread::SaveFrameZeroState(RegisterCheckpoint &checkpoint) -{ - return false; -} - -bool -LinuxThread::RestoreSaveFrameZero(const RegisterCheckpoint &checkpoint) -{ - return false; -} - lldb::RegisterContextSP LinuxThread::CreateRegisterContextForFrame(lldb_private::StackFrame *frame) { Modified: lldb/trunk/source/Plugins/Process/Linux/LinuxThread.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Linux/LinuxThread.h?rev=132586&r1=132585&r2=132586&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Process/Linux/LinuxThread.h (original) +++ lldb/trunk/source/Plugins/Process/Linux/LinuxThread.h Fri Jun 3 15:40:54 2011 @@ -54,13 +54,6 @@ void Notify(const ProcessMessage &message); -protected: - virtual bool - SaveFrameZeroState(RegisterCheckpoint &checkpoint); - - virtual bool - RestoreSaveFrameZero(const RegisterCheckpoint &checkpoint); - private: RegisterContextLinux * GetRegisterContextLinux () 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=132586&r1=132585&r2=132586&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Process/MacOSX-User/source/ThreadMacOSX.cpp (original) +++ lldb/trunk/source/Plugins/Process/MacOSX-User/source/ThreadMacOSX.cpp Fri Jun 3 15:40:54 2011 @@ -633,35 +633,6 @@ bool -ThreadMacOSX::SaveFrameZeroState (RegisterCheckpoint &checkpoint) -{ - lldb::StackFrameSP frame_sp(GetStackFrameAtIndex (0)); - if (frame_sp) - { - checkpoint.SetStackID(frame_sp->GetStackID()); - return frame_sp->GetRegisterContext()->ReadAllRegisterValues (checkpoint.GetData()); - } - return false; -} - -bool -ThreadMacOSX::RestoreSaveFrameZero (const RegisterCheckpoint &checkpoint) -{ - lldb::StackFrameSP frame_sp(GetStackFrameAtIndex (0)); - if (frame_sp) - { - bool ret = frame_sp->GetRegisterContext()->WriteAllRegisterValues (checkpoint.GetData()); - - // Clear out all stack frames as our world just changed. - ClearStackFrames(); - frame_sp->GetRegisterContext()->InvalidateIfNeeded(true); - - return ret; - } - return false; -} - -bool ThreadMacOSX::ClearHardwareBreakpoint (const BreakpointSite *bp) { if (bp != NULL && bp->IsHardware()) Modified: lldb/trunk/source/Plugins/Process/MacOSX-User/source/ThreadMacOSX.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/MacOSX-User/source/ThreadMacOSX.h?rev=132586&r1=132585&r2=132586&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Process/MacOSX-User/source/ThreadMacOSX.h (original) +++ lldb/trunk/source/Plugins/Process/MacOSX-User/source/ThreadMacOSX.h Fri Jun 3 15:40:54 2011 @@ -118,12 +118,6 @@ GetPrivateStopReason (); protected: - virtual bool - SaveFrameZeroState (RegisterCheckpoint &checkpoint); - - virtual bool - RestoreSaveFrameZero (const RegisterCheckpoint &checkpoint); - bool GetIdentifierInfo (); Modified: lldb/trunk/source/Plugins/Process/gdb-remote/ThreadGDBRemote.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/gdb-remote/ThreadGDBRemote.cpp?rev=132586&r1=132585&r2=132586&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Process/gdb-remote/ThreadGDBRemote.cpp (original) +++ lldb/trunk/source/Plugins/Process/gdb-remote/ThreadGDBRemote.cpp Fri Jun 3 15:40:54 2011 @@ -221,32 +221,6 @@ return gdb_reg_ctx->PrivateSetRegisterValue (reg, response); } -bool -ThreadGDBRemote::SaveFrameZeroState (RegisterCheckpoint &checkpoint) -{ - lldb::StackFrameSP frame_sp(GetStackFrameAtIndex (0)); - if (frame_sp) - { - checkpoint.SetStackID(frame_sp->GetStackID()); - return frame_sp->GetRegisterContext()->ReadAllRegisterValues (checkpoint.GetData()); - } - return false; -} - -bool -ThreadGDBRemote::RestoreSaveFrameZero (const RegisterCheckpoint &checkpoint) -{ - lldb::StackFrameSP frame_sp(GetStackFrameAtIndex (0)); - if (frame_sp) - { - bool ret = frame_sp->GetRegisterContext()->WriteAllRegisterValues (checkpoint.GetData()); - frame_sp->GetRegisterContext()->InvalidateIfNeeded(true); - ClearStackFrames(); - return ret; - } - return false; -} - lldb::StopInfoSP ThreadGDBRemote::GetPrivateStopReason () { Modified: lldb/trunk/source/Plugins/Process/gdb-remote/ThreadGDBRemote.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/gdb-remote/ThreadGDBRemote.h?rev=132586&r1=132585&r2=132586&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Process/gdb-remote/ThreadGDBRemote.h (original) +++ lldb/trunk/source/Plugins/Process/gdb-remote/ThreadGDBRemote.h Fri Jun 3 15:40:54 2011 @@ -99,12 +99,6 @@ friend class ProcessGDBRemote; - virtual bool - SaveFrameZeroState (RegisterCheckpoint &checkpoint); - - virtual bool - RestoreSaveFrameZero (const RegisterCheckpoint &checkpoint); - bool PrivateSetRegisterValue (uint32_t reg, StringExtractor &response); Modified: lldb/trunk/source/Target/Thread.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/Thread.cpp?rev=132586&r1=132585&r2=132586&view=diff ============================================================================== --- lldb/trunk/source/Target/Thread.cpp (original) +++ lldb/trunk/source/Target/Thread.cpp Fri Jun 3 15:40:54 2011 @@ -1156,7 +1156,34 @@ source_lines_after); } +bool +Thread::SaveFrameZeroState (RegisterCheckpoint &checkpoint) +{ + lldb::StackFrameSP frame_sp(GetStackFrameAtIndex (0)); + if (frame_sp) + { + checkpoint.SetStackID(frame_sp->GetStackID()); + return frame_sp->GetRegisterContext()->ReadAllRegisterValues (checkpoint.GetData()); + } + return false; +} + +bool +Thread::RestoreSaveFrameZero (const RegisterCheckpoint &checkpoint) +{ + lldb::StackFrameSP frame_sp(GetStackFrameAtIndex (0)); + if (frame_sp) + { + bool ret = frame_sp->GetRegisterContext()->WriteAllRegisterValues (checkpoint.GetData()); + // Clear out all stack frames as our world just changed. + ClearStackFrames(); + frame_sp->GetRegisterContext()->InvalidateIfNeeded(true); + + return ret; + } + return false; +} #pragma mark "Thread::SettingsController" //-------------------------------------------------------------- From peter at pcc.me.uk Fri Jun 3 15:41:02 2011 From: peter at pcc.me.uk (Peter Collingbourne) Date: Fri, 03 Jun 2011 20:41:02 -0000 Subject: [Lldb-commits] [lldb] r132587 - in /lldb/trunk/source/Plugins/Process/Linux: ProcessMonitor.cpp ProcessMonitor.h RegisterContextLinux_x86_64.cpp RegisterContextLinux_x86_64.h Message-ID: <20110603204102.D16502A6C12C@llvm.org> Author: pcc Date: Fri Jun 3 15:41:02 2011 New Revision: 132587 URL: http://llvm.org/viewvc/llvm-project?rev=132587&view=rev Log: Implement RegisterContextLinux_x86_64::{Read,Write}AllRegisterValues Modified: lldb/trunk/source/Plugins/Process/Linux/ProcessMonitor.cpp lldb/trunk/source/Plugins/Process/Linux/ProcessMonitor.h lldb/trunk/source/Plugins/Process/Linux/RegisterContextLinux_x86_64.cpp lldb/trunk/source/Plugins/Process/Linux/RegisterContextLinux_x86_64.h Modified: lldb/trunk/source/Plugins/Process/Linux/ProcessMonitor.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Linux/ProcessMonitor.cpp?rev=132587&r1=132586&r2=132587&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Process/Linux/ProcessMonitor.cpp (original) +++ lldb/trunk/source/Plugins/Process/Linux/ProcessMonitor.cpp Fri Jun 3 15:41:02 2011 @@ -334,6 +334,58 @@ } //------------------------------------------------------------------------------ +/// @class WriteGPROperation +/// @brief Implements ProcessMonitor::WriteGPR. +class WriteGPROperation : public Operation +{ +public: + WriteGPROperation(void *buf, bool &result) + : m_buf(buf), m_result(result) + { } + + void Execute(ProcessMonitor *monitor); + +private: + void *m_buf; + bool &m_result; +}; + +void +WriteGPROperation::Execute(ProcessMonitor *monitor) +{ + if (ptrace(PTRACE_SETREGS, monitor->GetPID(), NULL, m_buf) < 0) + m_result = false; + else + m_result = true; +} + +//------------------------------------------------------------------------------ +/// @class WriteFPROperation +/// @brief Implements ProcessMonitor::WriteFPR. +class WriteFPROperation : public Operation +{ +public: + WriteFPROperation(void *buf, bool &result) + : m_buf(buf), m_result(result) + { } + + void Execute(ProcessMonitor *monitor); + +private: + void *m_buf; + bool &m_result; +}; + +void +WriteFPROperation::Execute(ProcessMonitor *monitor) +{ + if (ptrace(PTRACE_SETFPREGS, monitor->GetPID(), NULL, m_buf) < 0) + m_result = false; + else + m_result = true; +} + +//------------------------------------------------------------------------------ /// @class ResumeOperation /// @brief Implements ProcessMonitor::Resume. class ResumeOperation : public Operation @@ -1134,6 +1186,24 @@ } bool +ProcessMonitor::WriteGPR(void *buf) +{ + bool result; + WriteGPROperation op(buf, result); + DoOperation(&op); + return result; +} + +bool +ProcessMonitor::WriteFPR(void *buf) +{ + bool result; + WriteFPROperation op(buf, result); + DoOperation(&op); + return result; +} + +bool ProcessMonitor::Resume(lldb::tid_t tid, uint32_t signo) { bool result; Modified: lldb/trunk/source/Plugins/Process/Linux/ProcessMonitor.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Linux/ProcessMonitor.h?rev=132587&r1=132586&r2=132587&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Process/Linux/ProcessMonitor.h (original) +++ lldb/trunk/source/Plugins/Process/Linux/ProcessMonitor.h Fri Jun 3 15:41:02 2011 @@ -117,6 +117,14 @@ bool ReadFPR(void *buf); + /// Writes all general purpose registers into the specified buffer. + bool + WriteGPR(void *buf); + + /// Writes all floating point registers into the specified buffer. + bool + WriteFPR(void *buf); + /// Writes a siginfo_t structure corresponding to the given thread ID to the /// memory region pointed to by @p siginfo. bool Modified: lldb/trunk/source/Plugins/Process/Linux/RegisterContextLinux_x86_64.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Linux/RegisterContextLinux_x86_64.cpp?rev=132587&r1=132586&r2=132587&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Process/Linux/RegisterContextLinux_x86_64.cpp (original) +++ lldb/trunk/source/Plugins/Process/Linux/RegisterContextLinux_x86_64.cpp Fri Jun 3 15:41:02 2011 @@ -11,6 +11,7 @@ #include #include +#include "lldb/Core/DataBufferHeap.h" #include "lldb/Core/DataExtractor.h" #include "lldb/Core/Scalar.h" #include "lldb/Target/Thread.h" @@ -324,6 +325,8 @@ { gcc_dwarf_fpu_##reg##i, gcc_dwarf_fpu_##reg##i, \ LLDB_INVALID_REGNUM, gdb_fpu_##reg##i, fpu_##reg##i } } +#define REG_CONTEXT_SIZE (sizeof(RegisterContextLinux_x86_64::GPR) + sizeof(RegisterContextLinux_x86_64::FPU)) + static RegisterInfo g_register_infos[k_num_registers] = { @@ -487,6 +490,16 @@ bool RegisterContextLinux_x86_64::ReadAllRegisterValues(DataBufferSP &data_sp) { + data_sp.reset (new DataBufferHeap (REG_CONTEXT_SIZE, 0)); + if (data_sp && ReadGPR () && ReadFPR ()) + { + uint8_t *dst = data_sp->GetBytes(); + ::memcpy (dst, &user.regs, sizeof(user.regs)); + dst += sizeof(user.regs); + + ::memcpy (dst, &user.i387, sizeof(user.i387)); + return true; + } return false; } @@ -500,8 +513,17 @@ } bool -RegisterContextLinux_x86_64::WriteAllRegisterValues(const DataBufferSP &data) +RegisterContextLinux_x86_64::WriteAllRegisterValues(const DataBufferSP &data_sp) { + if (data_sp && data_sp->GetByteSize() == REG_CONTEXT_SIZE) + { + const uint8_t *src = data_sp->GetBytes(); + ::memcpy (&user.regs, src, sizeof(user.regs)); + src += sizeof(user.regs); + + ::memcpy (&user.i387, src, sizeof(user.i387)); + return WriteGPR() & WriteFPR(); + } return false; } @@ -699,3 +721,17 @@ ProcessMonitor &monitor = GetMonitor(); return monitor.ReadFPR(&user.i387); } + +bool +RegisterContextLinux_x86_64::WriteGPR() +{ + ProcessMonitor &monitor = GetMonitor(); + return monitor.WriteGPR(&user.regs); +} + +bool +RegisterContextLinux_x86_64::WriteFPR() +{ + ProcessMonitor &monitor = GetMonitor(); + return monitor.WriteFPR(&user.i387); +} Modified: lldb/trunk/source/Plugins/Process/Linux/RegisterContextLinux_x86_64.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Linux/RegisterContextLinux_x86_64.h?rev=132587&r1=132586&r2=132587&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Process/Linux/RegisterContextLinux_x86_64.h (original) +++ lldb/trunk/source/Plugins/Process/Linux/RegisterContextLinux_x86_64.h Fri Jun 3 15:41:02 2011 @@ -151,6 +151,9 @@ bool ReadGPR(); bool ReadFPR(); + + bool WriteGPR(); + bool WriteFPR(); }; #endif // #ifndef liblldb_RegisterContextLinux_x86_64_H_ From peter at pcc.me.uk Fri Jun 3 15:41:09 2011 From: peter at pcc.me.uk (Peter Collingbourne) Date: Fri, 03 Jun 2011 20:41:09 -0000 Subject: [Lldb-commits] [lldb] r132588 - in /lldb/trunk: include/lldb/Utility/SharedCluster.h source/Target/ThreadPlanCallFunction.cpp Message-ID: <20110603204109.67DE42A6C12D@llvm.org> Author: pcc Date: Fri Jun 3 15:41:09 2011 New Revision: 132588 URL: http://llvm.org/viewvc/llvm-project?rev=132588&view=rev Log: Fix some order-of-initialisation warnings Modified: lldb/trunk/include/lldb/Utility/SharedCluster.h lldb/trunk/source/Target/ThreadPlanCallFunction.cpp Modified: lldb/trunk/include/lldb/Utility/SharedCluster.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Utility/SharedCluster.h?rev=132588&r1=132587&r2=132588&view=diff ============================================================================== --- lldb/trunk/include/lldb/Utility/SharedCluster.h (original) +++ lldb/trunk/include/lldb/Utility/SharedCluster.h Fri Jun 3 15:41:09 2011 @@ -21,7 +21,7 @@ class shared_ptr_refcount : public lldb_private::imp::shared_count { public: - template shared_ptr_refcount (Y *in) : manager(in), shared_count (0) {} + template shared_ptr_refcount (Y *in) : shared_count (0), manager(in) {} shared_ptr_refcount() : shared_count (0) {} @@ -44,8 +44,8 @@ { public: ClusterManager () : - m_external_ref(0), m_objects(), + m_external_ref(0), m_mutex(Mutex::eMutexTypeNormal) {} ~ClusterManager () Modified: lldb/trunk/source/Target/ThreadPlanCallFunction.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/ThreadPlanCallFunction.cpp?rev=132588&r1=132587&r2=132588&view=diff ============================================================================== --- lldb/trunk/source/Target/ThreadPlanCallFunction.cpp (original) +++ lldb/trunk/source/Target/ThreadPlanCallFunction.cpp Fri Jun 3 15:41:09 2011 @@ -45,10 +45,10 @@ ThreadPlan (ThreadPlan::eKindCallFunction, "Call function plan", thread, eVoteNoOpinion, eVoteNoOpinion), m_valid (false), m_stop_other_threads (stop_other_threads), + m_function_sp (NULL), m_process (thread.GetProcess()), m_thread (thread), - m_takedown_done (false), - m_function_sp (NULL) + m_takedown_done (false) { SetOkayToDiscard (discard_on_error); @@ -158,10 +158,10 @@ ThreadPlan (ThreadPlan::eKindCallFunction, "Call function plan", thread, eVoteNoOpinion, eVoteNoOpinion), m_valid (false), m_stop_other_threads (stop_other_threads), + m_function_sp(NULL), m_process (thread.GetProcess()), m_thread (thread), - m_takedown_done (false), - m_function_sp(NULL) + m_takedown_done (false) { SetOkayToDiscard (discard_on_error); From gclayton at apple.com Fri Jun 3 15:55:38 2011 From: gclayton at apple.com (Greg Clayton) Date: Fri, 03 Jun 2011 13:55:38 -0700 Subject: [Lldb-commits] [lldb] r132582 - /lldb/trunk/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp In-Reply-To: <20110603203958.357262A6C12C@llvm.org> References: <20110603203958.357262A6C12C@llvm.org> Message-ID: A few quick ELF questions: - Will the content of SHT_SYMTAB always contain the all the same symbols found in SHT_DYNSYM? If so, why parse the SHT_DYNSYM as well? Shouldn't we just parse the SHT_DYNSYM and fall back to the SHT_DYNSYM if there is no SHT_DYNSYM? On Jun 3, 2011, at 1:39 PM, Peter Collingbourne wrote: > Author: pcc > Date: Fri Jun 3 15:39:58 2011 > New Revision: 132582 > > URL: http://llvm.org/viewvc/llvm-project?rev=132582&view=rev > Log: > Scan dynamic symbol table of ELF object files > > Modified: > lldb/trunk/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp > > Modified: lldb/trunk/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp > URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp?rev=132582&r1=132581&r2=132582&view=diff > ============================================================================== > --- lldb/trunk/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp (original) > +++ lldb/trunk/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp Fri Jun 3 15:39:58 2011 > @@ -1085,7 +1085,7 @@ > for (SectionHeaderCollIter I = m_section_headers.begin(); > I != m_section_headers.end(); ++I) > { > - if (I->sh_type == SHT_SYMTAB) > + if (I->sh_type == SHT_SYMTAB || I->sh_type == SHT_DYNSYM) > { > const ELFSectionHeader &symtab_header = *I; > user_id_t section_id = SectionIndex(I); > > > _______________________________________________ > lldb-commits mailing list > lldb-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/lldb-commits From gclayton at apple.com Fri Jun 3 16:03:09 2011 From: gclayton at apple.com (Greg Clayton) Date: Fri, 03 Jun 2011 14:03:09 -0700 Subject: [Lldb-commits] [lldb] r132582 - /lldb/trunk/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp In-Reply-To: References: <20110603203958.357262A6C12C@llvm.org> Message-ID: <3571CC2D-495F-4F1B-A7F9-E84B1C4A5A77@apple.com> Yikes, copy/paste errors abound in my previous reply. This should have read: - Will the content of SHT_SYMTAB always contain the all the same symbols found in SHT_DYNSYM? If so, why parse the SHT_DYNSYM as well? Shouldn't we just parse the SHT_SYMTAB and fall back to the SHT_DYNSYM if there is no SHT_SYMTAB? On Jun 3, 2011, at 1:55 PM, Greg Clayton wrote: > A few quick ELF questions: > > - Will the content of SHT_SYMTAB always contain the all the same symbols found in SHT_DYNSYM? If so, why parse the SHT_DYNSYM as well? > Shouldn't we just parse the SHT_DYNSYM and fall back to the SHT_DYNSYM if there is no SHT_DYNSYM? > > > > > On Jun 3, 2011, at 1:39 PM, Peter Collingbourne wrote: > >> Author: pcc >> Date: Fri Jun 3 15:39:58 2011 >> New Revision: 132582 >> >> URL: http://llvm.org/viewvc/llvm-project?rev=132582&view=rev >> Log: >> Scan dynamic symbol table of ELF object files >> >> Modified: >> lldb/trunk/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp >> >> Modified: lldb/trunk/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp >> URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp?rev=132582&r1=132581&r2=132582&view=diff >> ============================================================================== >> --- lldb/trunk/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp (original) >> +++ lldb/trunk/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp Fri Jun 3 15:39:58 2011 >> @@ -1085,7 +1085,7 @@ >> for (SectionHeaderCollIter I = m_section_headers.begin(); >> I != m_section_headers.end(); ++I) >> { >> - if (I->sh_type == SHT_SYMTAB) >> + if (I->sh_type == SHT_SYMTAB || I->sh_type == SHT_DYNSYM) >> { >> const ELFSectionHeader &symtab_header = *I; >> user_id_t section_id = SectionIndex(I); >> >> >> _______________________________________________ >> lldb-commits mailing list >> lldb-commits at cs.uiuc.edu >> http://lists.cs.uiuc.edu/mailman/listinfo/lldb-commits > > _______________________________________________ > lldb-commits mailing list > lldb-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/lldb-commits From gclayton at apple.com Fri Jun 3 16:08:58 2011 From: gclayton at apple.com (Greg Clayton) Date: Fri, 03 Jun 2011 14:08:58 -0700 Subject: [Lldb-commits] [lldb] r132582 - /lldb/trunk/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp In-Reply-To: <3571CC2D-495F-4F1B-A7F9-E84B1C4A5A77@apple.com> References: <20110603203958.357262A6C12C@llvm.org> <3571CC2D-495F-4F1B-A7F9-E84B1C4A5A77@apple.com> Message-ID: <333C44C2-643C-441D-B052-ED2B62C91641@apple.com> Another clarification I meant to initially convey, so one more time: Will the content of SHT_SYMTAB always contain the all the same symbols found in SHT_DYNSYM and more symbol (symbols that aren't required by the dynamic loader)? Or do the symbols for the dynamic loader only get put into the SHT_DYNSYM sections, and any other symbols get put into the SHT_SYMTAB sections? Shouldn't we just parse the SHT_SYMTAB sections and fall back to the SHT_DYNSYM section(s) if there are no SHT_SYMTAB sections? On Jun 3, 2011, at 2:03 PM, Greg Clayton wrote: > Yikes, copy/paste errors abound in my previous reply. This should have read: > > - Will the content of SHT_SYMTAB always contain the all the same symbols found in SHT_DYNSYM? If so, why parse the SHT_DYNSYM as well? > Shouldn't we just parse the SHT_SYMTAB and fall back to the SHT_DYNSYM if there is no SHT_SYMTAB? > > On Jun 3, 2011, at 1:55 PM, Greg Clayton wrote: > >> A few quick ELF questions: >> >> - Will the content of SHT_SYMTAB always contain the all the same symbols found in SHT_DYNSYM? If so, why parse the SHT_DYNSYM as well? >> Shouldn't we just parse the SHT_DYNSYM and fall back to the SHT_DYNSYM if there is no SHT_DYNSYM? >> >> >> >> >> On Jun 3, 2011, at 1:39 PM, Peter Collingbourne wrote: >> >>> Author: pcc >>> Date: Fri Jun 3 15:39:58 2011 >>> New Revision: 132582 >>> >>> URL: http://llvm.org/viewvc/llvm-project?rev=132582&view=rev >>> Log: >>> Scan dynamic symbol table of ELF object files >>> >>> Modified: >>> lldb/trunk/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp >>> >>> Modified: lldb/trunk/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp >>> URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp?rev=132582&r1=132581&r2=132582&view=diff >>> ============================================================================== >>> --- lldb/trunk/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp (original) >>> +++ lldb/trunk/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp Fri Jun 3 15:39:58 2011 >>> @@ -1085,7 +1085,7 @@ >>> for (SectionHeaderCollIter I = m_section_headers.begin(); >>> I != m_section_headers.end(); ++I) >>> { >>> - if (I->sh_type == SHT_SYMTAB) >>> + if (I->sh_type == SHT_SYMTAB || I->sh_type == SHT_DYNSYM) >>> { >>> const ELFSectionHeader &symtab_header = *I; >>> user_id_t section_id = SectionIndex(I); >>> >>> >>> _______________________________________________ >>> lldb-commits mailing list >>> lldb-commits at cs.uiuc.edu >>> http://lists.cs.uiuc.edu/mailman/listinfo/lldb-commits >> >> _______________________________________________ >> 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 Fri Jun 3 16:27:29 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Fri, 03 Jun 2011 21:27:29 -0000 Subject: [Lldb-commits] [lldb] r132594 - /lldb/trunk/lldb.xcodeproj/project.pbxproj Message-ID: <20110603212729.1C5C22A6C12C@llvm.org> Author: johnny Date: Fri Jun 3 16:27:28 2011 New Revision: 132594 URL: http://llvm.org/viewvc/llvm-project?rev=132594&view=rev Log: Add InferiorCallPOSIX.cpp/.h into the xcode project file to fix build error. Modified: lldb/trunk/lldb.xcodeproj/project.pbxproj Modified: lldb/trunk/lldb.xcodeproj/project.pbxproj URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/lldb.xcodeproj/project.pbxproj?rev=132594&r1=132593&r2=132594&view=diff ============================================================================== --- lldb/trunk/lldb.xcodeproj/project.pbxproj (original) +++ lldb/trunk/lldb.xcodeproj/project.pbxproj Fri Jun 3 16:27:28 2011 @@ -418,6 +418,7 @@ 9AC70390117675270086C050 /* SBInstructionList.h in Headers */ = {isa = PBXBuildFile; fileRef = 9AC7038F117675270086C050 /* SBInstructionList.h */; settings = {ATTRIBUTES = (Public, ); }; }; 9AC703AF117675410086C050 /* SBInstruction.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9AC703AE117675410086C050 /* SBInstruction.cpp */; }; 9AC703B1117675490086C050 /* SBInstructionList.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9AC703B0117675490086C050 /* SBInstructionList.cpp */; }; + B28058A1139988B0002D96D0 /* InferiorCallPOSIX.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B28058A0139988B0002D96D0 /* InferiorCallPOSIX.cpp */; }; /* End PBXBuildFile section */ /* Begin PBXContainerItemProxy section */ @@ -1228,6 +1229,8 @@ AF68D3301255A110002FF25B /* UnwindLLDB.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = UnwindLLDB.h; path = Utility/UnwindLLDB.h; sourceTree = ""; }; AF94005711C03F6500085DB9 /* SymbolVendor.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = SymbolVendor.cpp; path = source/Symbol/SymbolVendor.cpp; sourceTree = ""; }; B23DD24F12EDFAC1000C3894 /* ARMUtils.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ARMUtils.h; path = Utility/ARMUtils.h; sourceTree = ""; }; + B28058A0139988B0002D96D0 /* InferiorCallPOSIX.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = InferiorCallPOSIX.cpp; path = Utility/InferiorCallPOSIX.cpp; sourceTree = ""; }; + B28058A2139988C6002D96D0 /* InferiorCallPOSIX.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = InferiorCallPOSIX.h; path = Utility/InferiorCallPOSIX.h; sourceTree = ""; }; B287E63E12EFAE2C00C9BEFE /* ARMDefines.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ARMDefines.h; path = Utility/ARMDefines.h; sourceTree = ""; }; B296983412C2FB2B002D92C3 /* CommandObjectVersion.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = CommandObjectVersion.cpp; path = source/Commands/CommandObjectVersion.cpp; sourceTree = ""; }; B296983512C2FB2B002D92C3 /* CommandObjectVersion.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CommandObjectVersion.h; path = source/Commands/CommandObjectVersion.h; sourceTree = ""; }; @@ -1822,6 +1825,8 @@ B2D3033612EFA5C500F84EB3 /* InstructionUtils.h */, B287E63E12EFAE2C00C9BEFE /* ARMDefines.h */, B23DD24F12EDFAC1000C3894 /* ARMUtils.h */, + B28058A0139988B0002D96D0 /* InferiorCallPOSIX.cpp */, + B28058A2139988C6002D96D0 /* InferiorCallPOSIX.h */, AF68D32F1255A110002FF25B /* UnwindLLDB.cpp */, AF68D3301255A110002FF25B /* UnwindLLDB.h */, AF68D2541255416E002FF25B /* RegisterContextLLDB.cpp */, @@ -3209,6 +3214,7 @@ 26A69C5F137A17A500262477 /* RegisterValue.cpp in Sources */, 2690B3711381D5C300ECFBAE /* Memory.cpp in Sources */, 9A9E1EFF1398086D005AC039 /* InputReaderStack.cpp in Sources */, + B28058A1139988B0002D96D0 /* InferiorCallPOSIX.cpp in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; From gclayton at apple.com Fri Jun 3 17:08:57 2011 From: gclayton at apple.com (Greg Clayton) Date: Fri, 03 Jun 2011 22:08:57 -0000 Subject: [Lldb-commits] [lldb] r132597 - /lldb/trunk/tools/debugserver/debugserver.xcodeproj/project.pbxproj Message-ID: <20110603220857.1F9362A6C12C@llvm.org> Author: gclayton Date: Fri Jun 3 17:08:56 2011 New Revision: 132597 URL: http://llvm.org/viewvc/llvm-project?rev=132597&view=rev Log: Don't codesign with lldb_codesign for non MacOSX SDKs. Modified: lldb/trunk/tools/debugserver/debugserver.xcodeproj/project.pbxproj Modified: lldb/trunk/tools/debugserver/debugserver.xcodeproj/project.pbxproj URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/debugserver/debugserver.xcodeproj/project.pbxproj?rev=132597&r1=132596&r2=132597&view=diff ============================================================================== --- lldb/trunk/tools/debugserver/debugserver.xcodeproj/project.pbxproj (original) +++ lldb/trunk/tools/debugserver/debugserver.xcodeproj/project.pbxproj Fri Jun 3 17:08:56 2011 @@ -565,7 +565,7 @@ isa = XCBuildConfiguration; buildSettings = { "CODE_SIGN_ENTITLEMENTS[sdk=iphoneos*]" = "source/debugserver-entitlements.plist"; - CODE_SIGN_IDENTITY = lldb_codesign; + "CODE_SIGN_IDENTITY[sdk=macosx*]" = lldb_codesign; COPY_PHASE_STRIP = YES; CURRENT_PROJECT_VERSION = 139; FRAMEWORK_SEARCH_PATHS = $SDKROOT/System/Library/PrivateFrameworks; @@ -595,7 +595,7 @@ ); OTHER_MIGFLAGS = "-I$(DERIVED_FILE_DIR)"; PRODUCT_NAME = debugserver; - PROVISIONING_PROFILE = ""; + "PROVISIONING_PROFILE[sdk=macosx*]" = ""; USER_HEADER_SEARCH_PATHS = "./source ../../source $(DERIVED_SOURCES_DIR)"; ZERO_LINK = NO; }; @@ -605,7 +605,7 @@ isa = XCBuildConfiguration; buildSettings = { "CODE_SIGN_ENTITLEMENTS[sdk=iphoneos*]" = "source/debugserver-entitlements.plist"; - CODE_SIGN_IDENTITY = lldb_codesign; + "CODE_SIGN_IDENTITY[sdk=macosx*]" = lldb_codesign; COPY_PHASE_STRIP = YES; CURRENT_PROJECT_VERSION = 139; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; @@ -635,7 +635,7 @@ ); OTHER_MIGFLAGS = "-I$(DERIVED_FILE_DIR)"; PRODUCT_NAME = debugserver; - PROVISIONING_PROFILE = ""; + "PROVISIONING_PROFILE[sdk=macosx*]" = ""; USER_HEADER_SEARCH_PATHS = "./source ../../source $(DERIVED_SOURCES_DIR)"; ZERO_LINK = NO; }; From gclayton at apple.com Fri Jun 3 17:12:43 2011 From: gclayton at apple.com (Greg Clayton) Date: Fri, 03 Jun 2011 22:12:43 -0000 Subject: [Lldb-commits] [lldb] r132599 - /lldb/trunk/source/Target/Process.cpp Message-ID: <20110603221243.281A42A6C12C@llvm.org> Author: gclayton Date: Fri Jun 3 17:12:42 2011 New Revision: 132599 URL: http://llvm.org/viewvc/llvm-project?rev=132599&view=rev Log: Make sure we are ok to stop in a thread plan and have no stop reason for the thread we were running on (other thread crashed or had exceptional stop reason). 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=132599&r1=132598&r2=132599&view=diff ============================================================================== --- lldb/trunk/source/Target/Process.cpp (original) +++ lldb/trunk/source/Target/Process.cpp Fri Jun 3 17:12:42 2011 @@ -3439,49 +3439,54 @@ switch (stop_state) { case lldb::eStateStopped: - { - // Yay, we're done. Now make sure that our thread plan actually completed. - ThreadSP thread_sp = exe_ctx.process->GetThreadList().FindThreadByIndexID (thread_idx_id); - if (!thread_sp) - { - // Ooh, our thread has vanished. Unlikely that this was successful execution... - if (log) - log->Printf ("Execution completed but our thread (index-id=%u) has vanished.", thread_idx_id); - return_value = eExecutionInterrupted; - } - else { - StopInfoSP stop_info_sp = thread_sp->GetStopInfo (); - StopReason stop_reason = stop_info_sp->GetStopReason(); - if (stop_reason == eStopReasonPlanComplete) + // Yay, we're done. Now make sure that our thread plan actually completed. + ThreadSP thread_sp = exe_ctx.process->GetThreadList().FindThreadByIndexID (thread_idx_id); + if (!thread_sp) { + // Ooh, our thread has vanished. Unlikely that this was successful execution... if (log) - log->Printf ("Execution completed successfully."); - // Now mark this plan as private so it doesn't get reported as the stop reason - // after this point. - if (thread_plan_sp) - thread_plan_sp->SetPrivate (orig_plan_private); - return_value = eExecutionCompleted; + log->Printf ("Execution completed but our thread (index-id=%u) has vanished.", thread_idx_id); + return_value = eExecutionInterrupted; } else { - if (log) - log->Printf ("Thread plan didn't successfully complete."); - - return_value = eExecutionInterrupted; + StopInfoSP stop_info_sp (thread_sp->GetStopInfo ()); + StopReason stop_reason = eStopReasonInvalid; + if (stop_info_sp) + stop_reason = stop_info_sp->GetStopReason(); + if (stop_reason == eStopReasonPlanComplete) + { + if (log) + log->Printf ("Execution completed successfully."); + // Now mark this plan as private so it doesn't get reported as the stop reason + // after this point. + if (thread_plan_sp) + thread_plan_sp->SetPrivate (orig_plan_private); + return_value = eExecutionCompleted; + } + else + { + if (log) + log->Printf ("Thread plan didn't successfully complete."); + + return_value = eExecutionInterrupted; + } } - } - } - break; + } + break; + case lldb::eStateCrashed: if (log) log->Printf ("Execution crashed."); return_value = eExecutionInterrupted; break; + case lldb::eStateRunning: do_resume = false; keep_going = true; break; + default: if (log) log->Printf("Execution stopped with unexpected state: %s.", StateAsCString(stop_state)); From gclayton at apple.com Fri Jun 3 20:26:30 2011 From: gclayton at apple.com (Greg Clayton) Date: Sat, 04 Jun 2011 01:26:30 -0000 Subject: [Lldb-commits] [lldb] r132615 - in /lldb/trunk: include/lldb/Target/StopInfo.h source/Core/EmulateInstruction.cpp source/Plugins/ABI/MacOSX-arm/ABIMacOSX_arm.cpp source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp source/Target/StopInfo.cpp Message-ID: <20110604012630.2148C2A6C12C@llvm.org> Author: gclayton Date: Fri Jun 3 20:26:29 2011 New Revision: 132615 URL: http://llvm.org/viewvc/llvm-project?rev=132615&view=rev Log: Created a std::string in the base StopInfo class for the description and cleaned up all base classes that had their own copy. Added a SetDescription accessor to the StopInfo class. Modified: lldb/trunk/include/lldb/Target/StopInfo.h lldb/trunk/source/Core/EmulateInstruction.cpp lldb/trunk/source/Plugins/ABI/MacOSX-arm/ABIMacOSX_arm.cpp lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp lldb/trunk/source/Target/StopInfo.cpp Modified: lldb/trunk/include/lldb/Target/StopInfo.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/StopInfo.h?rev=132615&r1=132614&r2=132615&view=diff ============================================================================== --- lldb/trunk/include/lldb/Target/StopInfo.h (original) +++ lldb/trunk/include/lldb/Target/StopInfo.h Fri Jun 3 20:26:29 2011 @@ -12,6 +12,8 @@ // C Includes // C++ Includes +#include + // Other libraries and framework includes // Project includes #include "lldb/lldb-public.h" @@ -92,8 +94,19 @@ } virtual const char * - GetDescription () = 0; + GetDescription () + { + return m_description.c_str(); + } + virtual void + SetDescription (const char *desc_cstr) + { + if (desc_cstr && desc_cstr[0]) + m_description.assign (desc_cstr); + else + m_description.clear(); + } static lldb::StopInfoSP CreateStopReasonWithBreakpointSiteID (Thread &thread, lldb::break_id_t break_id); @@ -114,6 +127,9 @@ static lldb::StopInfoSP CreateStopReasonWithPlan (lldb::ThreadPlanSP &plan); + static lldb::StopInfoSP + CreateStopReasonWithException (Thread &thread, const char *description); + protected: //------------------------------------------------------------------ // Classes that inherit from StackID can see and modify these @@ -121,6 +137,7 @@ Thread & m_thread; // The thread corresponding to the stop reason. uint32_t m_stop_id; // The process stop ID for which this stop info is valid uint64_t m_value; // A generic value that can be used for things pertaining to this stop info + std::string m_description; // A textual description describing this stop. private: friend class Thread; Modified: lldb/trunk/source/Core/EmulateInstruction.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/EmulateInstruction.cpp?rev=132615&r1=132614&r2=132615&view=diff ============================================================================== --- lldb/trunk/source/Core/EmulateInstruction.cpp (original) +++ lldb/trunk/source/Core/EmulateInstruction.cpp Fri Jun 3 20:26:29 2011 @@ -454,6 +454,10 @@ strm.PutCString ("adjust sp"); break; + case eContextSetFramePointer: + strm.PutCString ("set frame pointer"); + break; + case eContextAdjustBaseRegister: strm.PutCString ("adjusting (writing value back to) a base register"); break; Modified: lldb/trunk/source/Plugins/ABI/MacOSX-arm/ABIMacOSX_arm.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ABI/MacOSX-arm/ABIMacOSX_arm.cpp?rev=132615&r1=132614&r2=132615&view=diff ============================================================================== --- lldb/trunk/source/Plugins/ABI/MacOSX-arm/ABIMacOSX_arm.cpp (original) +++ lldb/trunk/source/Plugins/ABI/MacOSX-arm/ABIMacOSX_arm.cpp Fri Jun 3 20:26:29 2011 @@ -391,9 +391,6 @@ pc_reg_num == LLDB_INVALID_REGNUM) return false; - unwind_plan.Clear(); - unwind_plan.SetRegisterKind (eRegisterKindDWARF); - UnwindPlan::Row row; // Our previous Call Frame Address is the stack pointer @@ -439,7 +436,7 @@ return false; UnwindPlan::Row row; - const int32_t ptr_size = 8; + const int32_t ptr_size = 4; unwind_plan.SetRegisterKind (eRegisterKindGeneric); row.SetCFARegister (fp_reg_num); 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=132615&r1=132614&r2=132615&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp (original) +++ lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp Fri Jun 3 20:26:29 2011 @@ -1120,6 +1120,8 @@ std::string name; std::string value; std::string thread_name; + std::string reason; + std::string description; uint32_t exc_type = 0; std::vector exc_data; uint32_t tid = LLDB_INVALID_THREAD_ID; @@ -1174,6 +1176,18 @@ { thread_dispatch_qaddr = Args::StringToUInt64 (value.c_str(), 0, 16); } + else if (name.compare("reason") == 0) + { + reason.swap(value); + } + else if (name.compare("description") == 0) + { + StringExtractor desc_extractor; + // Swap "value" over into "name_extractor" + desc_extractor.GetStringRef().swap(value); + // Now convert the HEX bytes into a string value + desc_extractor.GetHexByteString (thread_name); + } else if (name.size() == 2 && ::isxdigit(name[0]) && ::isxdigit(name[1])) { // We have a register number that contains an expedited @@ -1218,8 +1232,83 @@ exc_data_size >= 1 ? exc_data[0] : 0, exc_data_size >= 2 ? exc_data[1] : 0)); } - else if (signo) + else { + bool handled = false; + if (!reason.empty()) + { + if (reason.compare("trace") == 0) + { + gdb_thread->SetStopInfo (StopInfo::CreateStopReasonToTrace (*thread_sp)); + handled = true; + } + else if (reason.compare("breakpoint") == 0) + { + addr_t pc = gdb_thread->GetRegisterContext()->GetPC(); + lldb::BreakpointSiteSP bp_site_sp = gdb_thread->GetProcess().GetBreakpointSiteList().FindByAddress(pc); + if (bp_site_sp) + { + // If the breakpoint is for this thread, then we'll report the hit, but if it is for another thread, + // we can just report no reason. We don't need to worry about stepping over the breakpoint here, that + // will be taken care of when the thread resumes and notices that there's a breakpoint under the pc. + if (bp_site_sp->ValidForThisThread (gdb_thread)) + { + gdb_thread->SetStopInfo (StopInfo::CreateStopReasonWithBreakpointSiteID (*thread_sp, bp_site_sp->GetID())); + handled = true; + } + } + + if (!handled) + { + gdb_thread->SetStopInfo (StopInfo::CreateStopReasonToTrace (*thread_sp)); + } + } + else if (reason.compare("trap") == 0) + { + // Let the trap just use the standard signal stop reason below... + } + else if (reason.compare("watchpoint") == 0) + { + break_id_t watch_id = LLDB_INVALID_WATCH_ID; + // TODO: locate the watchpoint somehow... + gdb_thread->SetStopInfo (StopInfo::CreateStopReasonWithWatchpointID (*thread_sp, watch_id)); + handled = true; + } + else if (reason.compare("exception") == 0) + { + gdb_thread->SetStopInfo (StopInfo::CreateStopReasonWithException(*thread_sp, description.c_str())); + handled = true; + } + } + + if (signo) + { + if (signo == SIGTRAP) + { + // Currently we are going to assume SIGTRAP means we are either + // hitting a breakpoint or hardware single stepping. + addr_t pc = gdb_thread->GetRegisterContext()->GetPC(); + lldb::BreakpointSiteSP bp_site_sp = gdb_thread->GetProcess().GetBreakpointSiteList().FindByAddress(pc); + if (bp_site_sp) + { + // If the breakpoint is for this thread, then we'll report the hit, but if it is for another thread, + // we can just report no reason. We don't need to worry about stepping over the breakpoint here, that + // will be taken care of when the thread resumes and notices that there's a breakpoint under the pc. + if (bp_site_sp->ValidForThisThread (gdb_thread)) + { + gdb_thread->SetStopInfo (StopInfo::CreateStopReasonWithBreakpointSiteID (*thread_sp, bp_site_sp->GetID())); + handled = true; + } + } + if (!handled) + { + // TODO: check for breakpoint or trap opcode in case there is a hard + // coded software trap + gdb_thread->SetStopInfo (StopInfo::CreateStopReasonToTrace (*thread_sp)); + handled = true; + } + } + if (!handled) gdb_thread->SetStopInfo (StopInfo::CreateStopReasonWithSignal (*thread_sp, signo)); } else @@ -1227,6 +1316,20 @@ StopInfoSP invalid_stop_info_sp; gdb_thread->SetStopInfo (invalid_stop_info_sp); } + + if (!description.empty()) + { + lldb::StopInfoSP stop_info_sp (gdb_thread->GetStopInfo ()); + if (stop_info_sp) + { + stop_info_sp->SetDescription (description.c_str()); + } + else + { + gdb_thread->SetStopInfo (StopInfo::CreateStopReasonWithException (*thread_sp, description.c_str())); + } + } + } } return eStateStopped; } Modified: lldb/trunk/source/Target/StopInfo.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/StopInfo.cpp?rev=132615&r1=132614&r2=132615&view=diff ============================================================================== --- lldb/trunk/source/Target/StopInfo.cpp (original) +++ lldb/trunk/source/Target/StopInfo.cpp Fri Jun 3 20:26:29 2011 @@ -253,8 +253,7 @@ public: StopInfoUnixSignal (Thread &thread, int signo) : - StopInfo (thread, signo), - m_description() + StopInfo (thread, signo) { } @@ -306,9 +305,6 @@ } return m_description.c_str(); } - -private: - std::string m_description; }; //---------------------------------------------------------------------- @@ -337,7 +333,47 @@ virtual const char * GetDescription () { + if (m_description.empty()) return "trace"; + else + return m_description.c_str(); + } +}; + + +//---------------------------------------------------------------------- +// StopInfoException +//---------------------------------------------------------------------- + +class StopInfoException : public StopInfo +{ +public: + + StopInfoException (Thread &thread, const char *description) : + StopInfo (thread, LLDB_INVALID_UID) + { + if (description) + SetDescription (description); + } + + virtual + ~StopInfoException () + { + } + + virtual StopReason + GetStopReason () const + { + return eStopReasonException; + } + + virtual const char * + GetDescription () + { + if (m_description.empty()) + return "exception"; + else + return m_description.c_str(); } }; @@ -380,7 +416,6 @@ private: ThreadPlanSP m_plan_sp; - std::string m_description; }; StopInfoSP @@ -418,3 +453,9 @@ { return StopInfoSP (new StopInfoThreadPlan (plan_sp)); } + +StopInfoSP +StopInfo::CreateStopReasonWithException (Thread &thread, const char *description) +{ + return StopInfoSP (new StopInfoException (thread, description)); +} From peter at pcc.me.uk Sun Jun 5 11:35:29 2011 From: peter at pcc.me.uk (Peter Collingbourne) Date: Sun, 5 Jun 2011 17:35:29 +0100 Subject: [Lldb-commits] [lldb] r132582 - /lldb/trunk/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp In-Reply-To: <333C44C2-643C-441D-B052-ED2B62C91641@apple.com> References: <20110603203958.357262A6C12C@llvm.org> <3571CC2D-495F-4F1B-A7F9-E84B1C4A5A77@apple.com> <333C44C2-643C-441D-B052-ED2B62C91641@apple.com> Message-ID: <20110605163529.GA1543@pcc.me.uk> On Fri, Jun 03, 2011 at 02:08:58PM -0700, Greg Clayton wrote: > Another clarification I meant to initially convey, so one more time: > > Will the content of SHT_SYMTAB always contain the all the same symbols found in SHT_DYNSYM and more symbol (symbols that aren't required by the dynamic loader)? Or do the symbols for the dynamic loader only get put into the SHT_DYNSYM sections, and any other symbols get put into the SHT_SYMTAB sections? > > Shouldn't we just parse the SHT_SYMTAB sections and fall back to the SHT_DYNSYM section(s) if there are no SHT_SYMTAB sections? Hi Greg, Generally .dynsym is a subset of .symtab (if present), and this does seem to be an implicit rule in the ELF specification [1]. However, in practice this rule is not always adhered to (I have at least one (shared) object file on my system in which both .dynsym and .symtab are present but .dynsym is not a subset of .symtab). So I think the safest thing to do is to parse both symbol tables, under the "be lenient in what you accept" principle. Is it a problem to have duplicate symbols in Symtab? If we do this, should we be filtering out duplicates somehow? Thanks, -- Peter [1] http://www.skyfree.org/linux/references/ELF_Format.pdf page 1-10