From johnny.chen at apple.com Mon May 16 13:30:01 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Mon, 16 May 2011 18:30:01 -0000 Subject: [Lldb-commits] [lldb] r131412 - /lldb/trunk/test/python_api/lldbutil/iter/TestLLDBIterator.py Message-ID: <20110516183001.17B4D2A6C12C@llvm.org> Author: johnny Date: Mon May 16 13:30:00 2011 New Revision: 131412 URL: http://llvm.org/viewvc/llvm-project?rev=131412&view=rev Log: Renamed the test cases more properly to test_lldb_iter_module/breakpoint/farme. Modified: lldb/trunk/test/python_api/lldbutil/iter/TestLLDBIterator.py Modified: lldb/trunk/test/python_api/lldbutil/iter/TestLLDBIterator.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/python_api/lldbutil/iter/TestLLDBIterator.py?rev=131412&r1=131411&r2=131412&view=diff ============================================================================== --- lldb/trunk/test/python_api/lldbutil/iter/TestLLDBIterator.py (original) +++ lldb/trunk/test/python_api/lldbutil/iter/TestLLDBIterator.py Mon May 16 13:30:00 2011 @@ -19,22 +19,22 @@ self.line1 = line_number('main.cpp', '// Set break point at this line.') self.line2 = line_number('main.cpp', '// And that line.') - def test_lldb_iter_1(self): + def test_lldb_iter_module(self): """Test module_iter works correctly for SBTarget -> SBModule.""" self.buildDefault() - self.lldb_iter_1() + self.lldb_iter_module() - def test_lldb_iter_2(self): + def test_lldb_iter_breakpoint(self): """Test breakpoint_iter works correctly for SBTarget -> SBBreakpoint.""" self.buildDefault() - self.lldb_iter_2() + self.lldb_iter_breakpoint() - def test_lldb_iter_3(self): + def test_lldb_iter_frame(self): """Test iterator works correctly for SBProcess->SBThread->SBFrame.""" self.buildDefault() - self.lldb_iter_3() + self.lldb_iter_frame() - def lldb_iter_1(self): + def lldb_iter_module(self): exe = os.path.join(os.getcwd(), "a.out") target = self.dbg.CreateTarget(exe) @@ -66,7 +66,7 @@ self.assertTrue(yours[i] == mine[i], "UUID+FileSpec of yours[{0}] and mine[{0}] matches".format(i)) - def lldb_iter_2(self): + def lldb_iter_breakpoint(self): exe = os.path.join(os.getcwd(), "a.out") target = self.dbg.CreateTarget(exe) @@ -95,7 +95,7 @@ self.assertTrue(yours[i] == mine[i], "ID of yours[{0}] and mine[{0}] matches".format(i)) - def lldb_iter_3(self): + def lldb_iter_frame(self): exe = os.path.join(os.getcwd(), "a.out") target = self.dbg.CreateTarget(exe) From cdavis at mymail.mines.edu Mon May 16 13:54:30 2011 From: cdavis at mymail.mines.edu (Charles Davis) Date: Mon, 16 May 2011 12:54:30 -0600 Subject: [Lldb-commits] [PATCH] Assorted build fixes Message-ID: <4DD172E6.3090906@mymail.mines.edu> Hi, This patch fixes some issues I encountered building with the Makefiles on Darwin (which were preventing me from finishing builds without disabling lldb support): - The last enumerator in an enumeration should not have a trailing comma. Fixed all known instances. - Add the UnwindAssembly and LanguageRuntime plugins to the makefile build. - Remove the MacOSX Process plugin from the build. It's not ready yet. - Remove leftover files from the ArchDefaultUnwindPlan/ArchVolatileRegs refactoring. Greg Clayton forgot to get rid of these. - Fix the Host/macosx Makefile build. - Fix the liblldb.dylib build. The last two are what worry me the most. To fix them, I had to add the CoreFoundation C++ part of the MacOSX Host library as a separate library. For some reason, LLVM's build system couldn't handle the fact that the sources were in a subdirectory. Is this OK to commit? (I have commit access to LLVM, so I can commit this myself.) Chip -------------- next part -------------- An embedded and charset-unspecified text was scrubbed... Name: makefile-fixes.patch Url: http://lists.cs.uiuc.edu/pipermail/lldb-commits/attachments/20110516/41bd99d8/attachment.pl From ctice at apple.com Mon May 16 14:20:50 2011 From: ctice at apple.com (Caroline Tice) Date: Mon, 16 May 2011 19:20:50 -0000 Subject: [Lldb-commits] [lldb] r131415 - in /lldb/trunk: source/Commands/CommandObjectBreakpointCommand.cpp tools/driver/Driver.cpp Message-ID: <20110516192050.ECDD92A6C12C@llvm.org> Author: ctice Date: Mon May 16 14:20:50 2011 New Revision: 131415 URL: http://llvm.org/viewvc/llvm-project?rev=131415&view=rev Log: Fix places that were writing directly to the debugger's output handles to go through the appropriate channels instead. Modified: lldb/trunk/source/Commands/CommandObjectBreakpointCommand.cpp lldb/trunk/tools/driver/Driver.cpp Modified: lldb/trunk/source/Commands/CommandObjectBreakpointCommand.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectBreakpointCommand.cpp?rev=131415&r1=131414&r2=131415&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectBreakpointCommand.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectBreakpointCommand.cpp Mon May 16 14:20:50 2011 @@ -23,6 +23,7 @@ #include "lldb/Breakpoint/BreakpointLocation.h" #include "lldb/Breakpoint/StoppointCallbackContext.h" #include "lldb/Core/State.h" +#include "lldb/Core/StreamAsynchronousIO.h" using namespace lldb; using namespace lldb_private; @@ -802,9 +803,13 @@ // 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. - result.SetImmediateOutputFile (debugger.GetOutputFile().GetStream()); - result.SetImmediateErrorFile (debugger.GetErrorFile().GetStream()); - + StreamSP output_stream (new StreamAsynchronousIO (debugger.GetCommandInterpreter(), + CommandInterpreter::eBroadcastBitAsynchronousOutputData)); + StreamSP error_stream (new StreamAsynchronousIO (debugger.GetCommandInterpreter(), + CommandInterpreter::eBroadcastBitAsynchronousErrorData)); + result.SetImmediateOutputStream (output_stream); + result.SetImmediateErrorStream (error_stream); + bool stop_on_continue = true; bool echo_commands = false; bool print_results = true; @@ -816,7 +821,9 @@ echo_commands, print_results, result); - } + result.GetImmediateOutputStream()->Flush(); + result.GetImmediateErrorStream()->Flush(); + } } return ret_value; } Modified: lldb/trunk/tools/driver/Driver.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/driver/Driver.cpp?rev=131415&r1=131414&r2=131415&view=diff ============================================================================== --- lldb/trunk/tools/driver/Driver.cpp (original) +++ lldb/trunk/tools/driver/Driver.cpp Mon May 16 14:20:50 2011 @@ -851,12 +851,17 @@ if (command_string == NULL) command_string = ""; SBCommandReturnObject result; - result.SetImmediateOutputFile (m_debugger.GetOutputFileHandle()); - result.SetImmediateErrorFile (m_debugger.GetErrorFileHandle()); - // We've set the result to dump immediately. + // We don't want the result to bypass the OutWrite function in IOChannel, as this can result in odd + // output orderings and problems with the prompt. m_debugger.GetCommandInterpreter().HandleCommand (command_string, result, true); + if (result.GetOutputSize() > 0) + m_io_channel_ap->OutWrite (result.GetOutput(), result.GetOutputSize(), NO_ASYNC); + + if (result.GetErrorSize() > 0) + m_io_channel_ap->OutWrite (result.GetError(), result.GetErrorSize(), NO_ASYNC); + // We are done getting and running our command, we can now clear the // m_waiting_for_command so we can get another one. m_waiting_for_command = false; From amitkulz at gmail.com Mon May 16 15:16:36 2011 From: amitkulz at gmail.com (Amit Kulkarni) Date: Mon, 16 May 2011 15:16:36 -0500 Subject: [Lldb-commits] [PATCH] Assorted build fixes Message-ID: This patch fixes some issues I encountered building with the Makefiles on Darwin (which were preventing me from finishing builds without disabling lldb support): - Remove leftover files from the ArchDefaultUnwindPlan/ArchVolatileRegs refactoring. Greg Clayton forgot to get rid of these. ------------------------------------------------------ Hi, I am confused, why are people posting patches to lldb-commits? Nobody reads lldb-dev? I was also hit with a bunch of these on FreeBSD 8.2 stable amd64 I had to subscribe to lldb-commits to post. Chip, thanks for your fixes, I will use them to see how far the compile goes on FreeBSD/Dragonfly amd64. Thanks, amit From johnny.chen at apple.com Mon May 16 15:31:18 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Mon, 16 May 2011 20:31:18 -0000 Subject: [Lldb-commits] [lldb] r131418 - in /lldb/trunk: scripts/Python/modify-python-lldb.py test/python_api/lldbutil/iter/TestRegistersIterator.py Message-ID: <20110516203118.EBCAE2A6C12C@llvm.org> Author: johnny Date: Mon May 16 15:31:18 2011 New Revision: 131418 URL: http://llvm.org/viewvc/llvm-project?rev=131418&view=rev Log: Add implementation of built-in function len() for those lldb containers with unambiguous iteration support. So that we could, for example: ... REGs = lldbutil.get_GPRs(frame) print "Number of general purpose registers: %d" % len(REGs) for reg in REGs: print "%s => %s" %(reg.GetName(), reg.GetValue()) ... Modified: lldb/trunk/scripts/Python/modify-python-lldb.py lldb/trunk/test/python_api/lldbutil/iter/TestRegistersIterator.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=131418&r1=131417&r2=131418&view=diff ============================================================================== --- lldb/trunk/scripts/Python/modify-python-lldb.py (original) +++ lldb/trunk/scripts/Python/modify-python-lldb.py Mon May 16 15:31:18 2011 @@ -41,6 +41,11 @@ module_iter = " def module_iter(self): return lldb_iter(self, '%s', '%s')" breakpoint_iter = " def breakpoint_iter(self): return lldb_iter(self, '%s', '%s')" # +# Called to implement the built-in function len(). +# Eligible objects are those containers with unambiguous iteration support. +# +len_def = " def __len__(self): return self.%s()" +# # This supports the rich comparison methods of __eq__ and __ne__. eq_def = " def __eq__(self, other): return isinstance(other, %s) and %s" ne_def = " def __ne__(self, other): return not self.__eq__(other)" @@ -104,7 +109,7 @@ # The pattern for recognizing the beginning of the __init__ method definition. init_pattern = re.compile("^ def __init__\(self, \*args\):") -# These define the states of our state machine. +# These define the states of our finite state machine. NORMAL = 0 DEFINING_ITERATOR = 1 DEFINING_EQUALITY = 2 @@ -140,6 +145,7 @@ else: if (state & DEFINING_ITERATOR): print >> new_content, iter_def % d[cls] + print >> new_content, len_def % d[cls][0] if (state & DEFINING_EQUALITY): print >> new_content, eq_def % (cls, list_to_frag(e[cls])) print >> new_content, ne_def Modified: lldb/trunk/test/python_api/lldbutil/iter/TestRegistersIterator.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/python_api/lldbutil/iter/TestRegistersIterator.py?rev=131418&r1=131417&r2=131418&view=diff ============================================================================== --- lldb/trunk/test/python_api/lldbutil/iter/TestRegistersIterator.py (original) +++ lldb/trunk/test/python_api/lldbutil/iter/TestRegistersIterator.py Mon May 16 15:31:18 2011 @@ -43,25 +43,45 @@ for thread in self.process: if thread.GetStopReason() == lldb.eStopReasonBreakpoint: for frame in thread: - # Dump the registers of this frame using iter_registers(). + # Dump the registers of this frame using lldbutil.get_GPRs() and friends. if self.TraceOn(): print frame + REGs = lldbutil.get_GPRs(frame) + num = len(REGs) + if self.TraceOn(): + print "\nNumber of general purpose registers: %d" % num + for reg in REGs: + self.assertTrue(reg.IsValid()) + if self.TraceOn(): + print "%s => %s" % (reg.GetName(), reg.GetValue(frame)) + + REGs = lldbutil.get_FPRs(frame) + num = len(REGs) + if self.TraceOn(): + print "\nNumber of floating point registers: %d" % num + for reg in REGs: + self.assertTrue(reg.IsValid()) + if self.TraceOn(): + print "%s => %s" % (reg.GetName(), reg.GetValue(frame)) + + REGs = lldbutil.get_ESRs(frame) + num = len(REGs) + if self.TraceOn(): + print "\nNumber of exception state registers: %d" % num + for reg in REGs: + self.assertTrue(reg.IsValid()) + if self.TraceOn(): + print "%s => %s" % (reg.GetName(), reg.GetValue(frame)) + + # And these should also work. for kind in ["General Purpose Registers", "Floating Point Registers", "Exception State Registers"]: REGs = lldbutil.get_registers(frame, kind) - if self.TraceOn(): - print "%s:" % kind - for reg in REGs: - self.assertTrue(reg.IsValid()) - if self.TraceOn(): - print "%s => %s" % (reg.GetName(), reg.GetValue(frame)) + self.assertTrue(REGs.IsValid()) - # And these should also work. - self.assertTrue(lldbutil.get_GPRs(frame)) - self.assertTrue(lldbutil.get_FPRs(frame)) - self.assertTrue(lldbutil.get_ESRs(frame)) + # We've finished dumping the registers for frame #0. break From cdavis at mymail.mines.edu Mon May 16 15:51:48 2011 From: cdavis at mymail.mines.edu (Charles Davis) Date: Mon, 16 May 2011 14:51:48 -0600 Subject: [Lldb-commits] [PATCH] Assorted build fixes In-Reply-To: References: Message-ID: <4DD18E64.5070509@mymail.mines.edu> On 5/16/11 2:16 PM, Amit Kulkarni wrote: > This patch fixes some issues I encountered building with the Makefiles > on Darwin (which were preventing me from finishing builds without > disabling lldb support): > > - Remove leftover files from the ArchDefaultUnwindPlan/ArchVolatileRegs > refactoring. Greg Clayton forgot to get rid of these. > ------------------------------------------------------ > Hi, > > I am confused, why are people posting patches to lldb-commits? Uh, because that's the list where you're supposed to post proposed patches? > I was also hit with a bunch of these on FreeBSD 8.2 > stable amd64 > > Chip, > thanks for your fixes, I will use them to see how far the compile goes > on FreeBSD/Dragonfly amd64. Good luck. You'll probably hit a build failure in liblldb.so, though, since there's no Host library for FreeBSD or DragonFly BSD. Chip From amitkulz at gmail.com Mon May 16 16:07:55 2011 From: amitkulz at gmail.com (Amit Kulkarni) Date: Mon, 16 May 2011 16:07:55 -0500 Subject: [Lldb-commits] [PATCH] Assorted build fixes In-Reply-To: <4DD18E64.5070509@mymail.mines.edu> References: <4DD18E64.5070509@mymail.mines.edu> Message-ID: >> I am confused, why are people posting patches to lldb-commits? > Uh, because that's the list where you're supposed to post proposed patches? I thought, lldb-dev is for patches, and lldb-commits is for a svn/git archive of actually committed bits. >> I was also hit with a bunch of these on FreeBSD 8.2 >> stable amd64 >> >> Chip, >> thanks for your fixes, I will use them to see how far the compile goes >> on FreeBSD/Dragonfly amd64. > Good luck. You'll probably hit a build failure in liblldb.so, though, > since there's no Host library for FreeBSD or DragonFly BSD. hitting a build failure much earlier than that in libstdc++. Now investigate how to workaround that. This is the last successful line before failure, how much left to compile successfully? Am I close to 100%? A clarification would be most welcome from anybody! llvm[4]: Building Release Archive Library liblldbUtility.a Thanks In file included from /usr/include/c++/4.2/ios:47, from /usr/include/c++/4.2/ostream:45, from /usr/include/c++/4.2/bitset:59, from /stuff/llvm/tools/lldb/tools/driver/Driver.h:16, from /stuff/llvm/tools/lldb/tools/driver/IOChannel.h:27, from /stuff/llvm/tools/lldb/tools/driver/IOChannel.cpp:10: /usr/include/c++/4.2/bits/localefwd.h:90:35: error: macro "isxdigit" passed 2 arguments, but takes just 1 In file included from /usr/include/c++/4.2/bits/basic_ios.h:44, from /usr/include/c++/4.2/ios:50, from /usr/include/c++/4.2/ostream:45, from /usr/include/c++/4.2/bitset:59, from /stuff/llvm/tools/lldb/tools/driver/Driver.h:16, from /stuff/llvm/tools/lldb/tools/driver/IOChannel.h:27, from /stuff/llvm/tools/lldb/tools/driver/IOChannel.cpp:10: /usr/include/c++/4.2/bits/locale_facets.h:4659:45: error: macro "isxdigit" passed 2 arguments, but takes just 1 In file included from /usr/include/c++/4.2/ios:47, from /usr/include/c++/4.2/ostream:45, from /usr/include/c++/4.2/bitset:59, from /stuff/llvm/tools/lldb/tools/driver/Driver.h:16, from /stuff/llvm/tools/lldb/tools/driver/IOChannel.h:27, from /stuff/llvm/tools/lldb/tools/driver/IOChannel.cpp:10: /usr/include/c++/4.2/bits/localefwd.h:90: error: 'std::isxdigit' declared as an 'inline' variable /usr/include/c++/4.2/bits/localefwd.h:90: error: template declaration of 'bool std::isxdigit' In file included from /usr/include/c++/4.2/bits/basic_ios.h:44, from /usr/include/c++/4.2/ios:50, from /usr/include/c++/4.2/ostream:45, from /usr/include/c++/4.2/bitset:59, from /stuff/llvm/tools/lldb/tools/driver/Driver.h:16, from /stuff/llvm/tools/lldb/tools/driver/IOChannel.h:27, from /stuff/llvm/tools/lldb/tools/driver/IOChannel.cpp:10: /usr/include/c++/4.2/bits/locale_facets.h:4659: error: function definition does not declare parameters From ctice at apple.com Mon May 16 16:28:44 2011 From: ctice at apple.com (Caroline Tice) Date: Mon, 16 May 2011 14:28:44 -0700 Subject: [Lldb-commits] Fwd: [PATCH] Assorted build fixes References: Message-ID: Accidentally hit reply instead of reply-all... Begin forwarded message: > From: Caroline Tice > Date: May 16, 2011 2:27:34 PM PDT > To: Amit Kulkarni > Subject: Re: [Lldb-commits] [PATCH] Assorted build fixes > > > On May 16, 2011, at 2:07 PM, Amit Kulkarni wrote: > >>>> I am confused, why are people posting patches to lldb-commits? >>> Uh, because that's the list where you're supposed to post proposed patches? >> >> I thought, lldb-dev is for patches, and lldb-commits is for a svn/git >> archive of actually committed bits. > > From the LLDB home page (http://lldb.llvm.org): > > Discussions about LLDB should go to the lldb-dev mailing list. Commit messages for the lldb SVN module are automatically sent to the lldb-commits mailing list, and this is also the preferred mailing list for patch submissions. > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.cs.uiuc.edu/pipermail/lldb-commits/attachments/20110516/fd4c77b6/attachment.html -------------- next part -------------- A non-text attachment was scrubbed... Name: smime.p7s Type: application/pkcs7-signature Size: 1587 bytes Desc: not available Url : http://lists.cs.uiuc.edu/pipermail/lldb-commits/attachments/20110516/fd4c77b6/attachment.bin From johnny.chen at apple.com Mon May 16 18:24:17 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Mon, 16 May 2011 23:24:17 -0000 Subject: [Lldb-commits] [lldb] r131433 - /lldb/trunk/test/stl/TestSTL.py Message-ID: <20110516232417.6E4DC2A6C12C@llvm.org> Author: johnny Date: Mon May 16 18:24:17 2011 New Revision: 131433 URL: http://llvm.org/viewvc/llvm-project?rev=131433&view=rev Log: Fix bad test case; not all compilers are guaranteed to step into code inlined from the STL header file. rdar://problem/8983790 Modified: lldb/trunk/test/stl/TestSTL.py Modified: lldb/trunk/test/stl/TestSTL.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/stl/TestSTL.py?rev=131433&r1=131432&r2=131433&view=diff ============================================================================== --- lldb/trunk/test/stl/TestSTL.py (original) +++ lldb/trunk/test/stl/TestSTL.py Mon May 16 18:24:17 2011 @@ -59,17 +59,14 @@ self.expect("breakpoint list -f", BREAKPOINT_HIT_ONCE, substrs = [' resolved, hit count = 1']) - # Now do 'thread step-in', we should stop on the basic_string template. - # - # This assertion currently always fails. - # This might be related: rdar://problem/8247112. - # - #self.runCmd("thread step-in", trace=True) + # Now do 'thread step-in', if we have successfully stopped, we should + # stop due to the reason of "step in". self.runCmd("thread step-in") - self.expect("thread backtrace", "We have stepped in STL", - substrs = ['[inlined]', - 'basic_string.h']) + self.runCmd("process status") + if "stopped" in self.res.GetOutput(): + self.expect("thread backtrace", "We have successfully stepped in", + substrs = ['stop reason = step in']) if __name__ == '__main__': From jingham at apple.com Mon May 16 19:24:32 2011 From: jingham at apple.com (Jim Ingham) Date: Tue, 17 May 2011 00:24:32 -0000 Subject: [Lldb-commits] [lldb] r131443 - in /lldb/trunk/test/cpp/dynamic-value: TestDynamicValue.py pass-to-base.cpp Message-ID: <20110517002432.D8A9E2A6C12C@llvm.org> Author: jingham Date: Mon May 16 19:24:32 2011 New Revision: 131443 URL: http://llvm.org/viewvc/llvm-project?rev=131443&view=rev Log: Clang makes two breakpoints for some fairly simple lines, not sure why but no need to check for this in the testsuite. Modified: lldb/trunk/test/cpp/dynamic-value/TestDynamicValue.py lldb/trunk/test/cpp/dynamic-value/pass-to-base.cpp Modified: lldb/trunk/test/cpp/dynamic-value/TestDynamicValue.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/cpp/dynamic-value/TestDynamicValue.py?rev=131443&r1=131442&r2=131443&view=diff ============================================================================== --- lldb/trunk/test/cpp/dynamic-value/TestDynamicValue.py (original) +++ lldb/trunk/test/cpp/dynamic-value/TestDynamicValue.py Mon May 16 19:24:32 2011 @@ -102,18 +102,15 @@ # Set up our breakpoints: do_something_bpt = target.BreakpointCreateByLocation('pass-to-base.cpp', self.do_something_line) - self.assertTrue(do_something_bpt.IsValid() and - do_something_bpt.GetNumLocations() == 1, + self.assertTrue(do_something_bpt.IsValid(), VALID_BREAKPOINT) first_call_bpt = target.BreakpointCreateByLocation('pass-to-base.cpp', self.main_first_call_line) - self.assertTrue(first_call_bpt.IsValid() and - first_call_bpt.GetNumLocations() == 1, + self.assertTrue(first_call_bpt.IsValid(), VALID_BREAKPOINT) second_call_bpt = target.BreakpointCreateByLocation('pass-to-base.cpp', self.main_second_call_line) - self.assertTrue(second_call_bpt.IsValid() and - second_call_bpt.GetNumLocations() == 1, + self.assertTrue(second_call_bpt.IsValid(), VALID_BREAKPOINT) # Now launch the process, and do not stop at the entry point. Modified: lldb/trunk/test/cpp/dynamic-value/pass-to-base.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/cpp/dynamic-value/pass-to-base.cpp?rev=131443&r1=131442&r2=131443&view=diff ============================================================================== --- lldb/trunk/test/cpp/dynamic-value/pass-to-base.cpp (original) +++ lldb/trunk/test/cpp/dynamic-value/pass-to-base.cpp Mon May 16 19:24:32 2011 @@ -51,12 +51,15 @@ { my_global_A_ptr = new B (100, 200); B myB (10, 20, my_global_A_ptr); - B otherB (300, 400, my_global_A_ptr); + B *second_fake_A_ptr = new B (150, 250); + B otherB (300, 400, second_fake_A_ptr); myB.doSomething(otherB); // Break here and get real addresses of myB and otherB. A reallyA (500); myB.doSomething (reallyA); // Break here and get real address of reallyA. + delete my_global_A_ptr; + return 0; } From jingham at apple.com Mon May 16 19:45:52 2011 From: jingham at apple.com (Jim Ingham) Date: Tue, 17 May 2011 00:45:52 -0000 Subject: [Lldb-commits] [lldb] r131445 - /lldb/trunk/test/cpp/dynamic-value/pass-to-base.cpp Message-ID: <20110517004552.7136C2A6C12C@llvm.org> Author: jingham Date: Mon May 16 19:45:52 2011 New Revision: 131445 URL: http://llvm.org/viewvc/llvm-project?rev=131445&view=rev Log: Fix a bug in the test case file (doesn't affect the tests.) Modified: lldb/trunk/test/cpp/dynamic-value/pass-to-base.cpp Modified: lldb/trunk/test/cpp/dynamic-value/pass-to-base.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/cpp/dynamic-value/pass-to-base.cpp?rev=131445&r1=131444&r2=131445&view=diff ============================================================================== --- lldb/trunk/test/cpp/dynamic-value/pass-to-base.cpp (original) +++ lldb/trunk/test/cpp/dynamic-value/pass-to-base.cpp Mon May 16 19:45:52 2011 @@ -17,6 +17,8 @@ A(int value) : m_a_value (value) {} A(int value, A* client_A) : m_a_value (value), m_client_A (client_A) {} + virtual ~A() {} + virtual void doSomething (A &anotherA) { @@ -40,6 +42,9 @@ public: B (int b_value, int a_value) : Extra(b_value, a_value), A(a_value), m_b_value(b_value) {} B (int b_value, int a_value, A *client_A) : Extra(b_value, a_value), A(a_value, client_A), m_b_value(b_value) {} + + virtual ~B () {} + private: int m_b_value; }; @@ -59,7 +64,5 @@ A reallyA (500); myB.doSomething (reallyA); // Break here and get real address of reallyA. - delete my_global_A_ptr; - return 0; } From jingham at apple.com Mon May 16 20:10:11 2011 From: jingham at apple.com (Jim Ingham) Date: Tue, 17 May 2011 01:10:11 -0000 Subject: [Lldb-commits] [lldb] r131448 - in /lldb/trunk: include/lldb/Target/ThreadPlan.h include/lldb/Target/ThreadPlanCallFunction.h source/Expression/ClangUserExpression.cpp source/Target/Process.cpp source/Target/ThreadPlanCallFunction.cpp Message-ID: <20110517011011.3EA4A2A6C12C@llvm.org> Author: jingham Date: Mon May 16 20:10:11 2011 New Revision: 131448 URL: http://llvm.org/viewvc/llvm-project?rev=131448&view=rev Log: Fix the error message when an expression evaluation is interrupted by a crash/breakpoint hit to give the reason for the interrupt. Also make sure it we don't want to unwind from the evaluation we print something if it is interrupted. Modified: lldb/trunk/include/lldb/Target/ThreadPlan.h lldb/trunk/include/lldb/Target/ThreadPlanCallFunction.h lldb/trunk/source/Expression/ClangUserExpression.cpp lldb/trunk/source/Target/Process.cpp lldb/trunk/source/Target/ThreadPlanCallFunction.cpp Modified: lldb/trunk/include/lldb/Target/ThreadPlan.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/ThreadPlan.h?rev=131448&r1=131447&r2=131448&view=diff ============================================================================== --- lldb/trunk/include/lldb/Target/ThreadPlan.h (original) +++ lldb/trunk/include/lldb/Target/ThreadPlan.h Mon May 16 20:10:11 2011 @@ -377,6 +377,16 @@ m_tracer_sp->Log(); } + // Some thread plans hide away the actual stop info which caused any particular stop. For + // instance the ThreadPlanCallFunction restores the original stop reason so that stopping and + // calling a few functions won't lose the history of the run. + // This call can be implemented to get you back to the real stop info. + virtual lldb::StopInfoSP + GetRealStopInfo () + { + return m_thread.GetStopInfo (); + } + protected: //------------------------------------------------------------------ // Classes that inherit from ThreadPlan can see and modify these @@ -395,7 +405,7 @@ lldb::StopInfoSP GetPrivateStopReason() { - return m_thread.GetPrivateStopReason(); + return m_thread.GetPrivateStopReason (); } void Modified: lldb/trunk/include/lldb/Target/ThreadPlanCallFunction.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/ThreadPlanCallFunction.h?rev=131448&r1=131447&r2=131448&view=diff ============================================================================== --- lldb/trunk/include/lldb/Target/ThreadPlanCallFunction.h (original) +++ lldb/trunk/include/lldb/Target/ThreadPlanCallFunction.h Mon May 16 20:10:11 2011 @@ -117,6 +117,16 @@ // thread state gets restored if the plan gets discarded. virtual void WillPop (); + + // If the thread plan stops mid-course, this will be the stop reason that interrupted us. + // Once DoTakedown is called, this will be the real stop reason at the end of the function call. + // This is needed because we want the CallFunction thread plans not to show up as the stop reason. + // But if something bad goes wrong, it is nice to be able to tell the user what really happened. + virtual lldb::StopInfoSP + GetRealStopInfo() + { + return m_real_stop_info_sp; + } protected: void ReportRegisterState (const char *message); @@ -145,6 +155,10 @@ LanguageRuntime *m_cxx_language_runtime; LanguageRuntime *m_objc_language_runtime; Thread::ThreadStateCheckpoint m_stored_thread_state; + lldb::StopInfoSP m_real_stop_info_sp; // In general we want to hide call function + // thread plans, but for reporting purposes, + // it's nice to know the real stop reason. + // This gets set in DoTakedown. lldb::ValueSP m_return_value_sp; // If this contains a valid pointer, use the ABI to extract values when complete bool m_takedown_done; // We want to ensure we only do the takedown once. This ensures that. Modified: lldb/trunk/source/Expression/ClangUserExpression.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/ClangUserExpression.cpp?rev=131448&r1=131447&r2=131448&view=diff ============================================================================== --- lldb/trunk/source/Expression/ClangUserExpression.cpp (original) +++ lldb/trunk/source/Expression/ClangUserExpression.cpp Mon May 16 20:10:11 2011 @@ -504,7 +504,7 @@ lldb::addr_t function_stack_pointer = static_cast(call_plan_sp.get())->GetFunctionStackPointer(); - call_plan_sp->SetPrivate(true); + // call_plan_sp->SetPrivate(true); uint32_t single_thread_timeout_usec = 500000; @@ -524,10 +524,23 @@ if (execution_result == eExecutionInterrupted) { + const char *error_desc = NULL; + + if (call_plan_sp) + { + lldb::StopInfoSP real_stop_info_sp = call_plan_sp->GetRealStopInfo(); + if (real_stop_info_sp) + error_desc = real_stop_info_sp->GetDescription(); + } + if (error_desc) + error_stream.Printf ("Execution was interrupted, reason: %s.", error_desc); + else + error_stream.Printf ("Execution was interrupted.", error_desc); + if (discard_on_error) - error_stream.Printf ("Expression execution was interrupted. The process has been returned to the state before execution."); + error_stream.Printf ("\nThe process has been returned to the state before execution."); else - error_stream.Printf ("Expression execution was interrupted. The process has been left at the point where it was interrupted."); + error_stream.Printf ("\nThe process has been left at the point where it was interrupted."); return execution_result; } Modified: lldb/trunk/source/Target/Process.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/Process.cpp?rev=131448&r1=131447&r2=131448&view=diff ============================================================================== --- lldb/trunk/source/Target/Process.cpp (original) +++ lldb/trunk/source/Target/Process.cpp Mon May 16 20:10:11 2011 @@ -3498,11 +3498,40 @@ switch (stop_state) { case lldb::eStateStopped: - // Yay, we're done. - if (log) - log->Printf ("Execution completed successfully."); - return_value = eExecutionCompleted; - break; + { + // Yay, we're done. Now make sure that our thread plan actually completed. + ThreadSP thread_sp = exe_ctx.process->GetThreadList().FindThreadByIndexID (tid); + if (!thread_sp) + { + // Ooh, our thread has vanished. Unlikely that this was successful execution... + if (log) + log->Printf ("Execution completed but our thread has vanished."); + return_value = eExecutionInterrupted; + } + else + { + StopInfoSP stop_info_sp = thread_sp->GetStopInfo (); + StopReason 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 (true); + return_value = eExecutionCompleted; + } + else + { + if (log) + log->Printf ("Thread plan didn't successfully complete."); + + return_value = eExecutionInterrupted; + } + } + } + break; case lldb::eStateCrashed: if (log) log->Printf ("Execution crashed."); @@ -3515,6 +3544,8 @@ default: if (log) log->Printf("Execution stopped with unexpected state: %s.", StateAsCString(stop_state)); + + errors.Printf ("Execution stopped with unexpected state."); return_value = eExecutionInterrupted; break; } Modified: lldb/trunk/source/Target/ThreadPlanCallFunction.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/ThreadPlanCallFunction.cpp?rev=131448&r1=131447&r2=131448&view=diff ============================================================================== --- lldb/trunk/source/Target/ThreadPlanCallFunction.cpp (original) +++ lldb/trunk/source/Target/ThreadPlanCallFunction.cpp Mon May 16 20:10:11 2011 @@ -282,6 +282,7 @@ if (log) log->Printf ("DoTakedown called for thread 0x%4.4x, m_valid: %d complete: %d.\n", m_thread.GetID(), m_valid, IsPlanComplete()); m_takedown_done = true; + m_real_stop_info_sp = GetPrivateStopReason(); m_thread.RestoreThreadStateFromCheckpoint(m_stored_thread_state); SetPlanComplete(); ClearBreakpoints(); @@ -327,6 +328,8 @@ bool ThreadPlanCallFunction::PlanExplainsStop () { + m_real_stop_info_sp = GetPrivateStopReason(); + // If our subplan knows why we stopped, even if it's done (which would forward the question to us) // we answer yes. if(m_subplan_sp.get() != NULL && m_subplan_sp->PlanExplainsStop()) @@ -343,11 +346,10 @@ // Otherwise, check the case where we stopped for an internal breakpoint, in that case, continue on. // If it is not an internal breakpoint, consult OkayToDiscard. - StopInfoSP stop_info_sp = GetPrivateStopReason(); - if (stop_info_sp && stop_info_sp->GetStopReason() == eStopReasonBreakpoint) + if (m_real_stop_info_sp && m_real_stop_info_sp->GetStopReason() == eStopReasonBreakpoint) { - uint64_t break_site_id = stop_info_sp->GetValue(); + uint64_t break_site_id = m_real_stop_info_sp->GetValue(); BreakpointSiteSP bp_site_sp = m_thread.GetProcess().GetBreakpointSiteList().FindByID(break_site_id); if (bp_site_sp) { From jingham at apple.com Mon May 16 20:21:41 2011 From: jingham at apple.com (Jim Ingham) Date: Tue, 17 May 2011 01:21:41 -0000 Subject: [Lldb-commits] [lldb] r131449 - /lldb/trunk/source/Commands/CommandObjectBreakpoint.cpp Message-ID: <20110517012141.5DCB22A6C12C@llvm.org> Author: jingham Date: Mon May 16 20:21:41 2011 New Revision: 131449 URL: http://llvm.org/viewvc/llvm-project?rev=131449&view=rev Log: Set the default "break list" level back to full. Modified: lldb/trunk/source/Commands/CommandObjectBreakpoint.cpp Modified: lldb/trunk/source/Commands/CommandObjectBreakpoint.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectBreakpoint.cpp?rev=131449&r1=131448&r2=131449&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectBreakpoint.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectBreakpoint.cpp Mon May 16 20:21:41 2011 @@ -702,7 +702,7 @@ void CommandObjectBreakpointList::CommandOptions::OptionParsingStarting () { - m_level = lldb::eDescriptionLevelBrief; + m_level = lldb::eDescriptionLevelFull; m_internal = false; } From gclayton at apple.com Mon May 16 22:37:42 2011 From: gclayton at apple.com (Greg Clayton) Date: Tue, 17 May 2011 03:37:42 -0000 Subject: [Lldb-commits] [lldb] r131453 - in /lldb/trunk: include/lldb/Core/State.h include/lldb/Target/Memory.h include/lldb/Target/Process.h lldb.xcodeproj/project.pbxproj source/Core/State.cpp source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp source/Target/Memory.cpp source/Target/Process.cpp Message-ID: <20110517033743.020092A6C12C@llvm.org> Author: gclayton Date: Mon May 16 22:37:42 2011 New Revision: 131453 URL: http://llvm.org/viewvc/llvm-project?rev=131453&view=rev Log: Added an allocated memory cache to avoid having to allocate memory over and over when running JITed expressions. The allocated memory cache will cache allocate memory a page at a time for each permission combination and divvy up the memory and hand it out in 16 byte increments. Added: lldb/trunk/include/lldb/Target/Memory.h lldb/trunk/source/Target/Memory.cpp Modified: lldb/trunk/include/lldb/Core/State.h lldb/trunk/include/lldb/Target/Process.h lldb/trunk/lldb.xcodeproj/project.pbxproj lldb/trunk/source/Core/State.cpp lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp lldb/trunk/source/Target/Process.cpp Modified: lldb/trunk/include/lldb/Core/State.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/State.h?rev=131453&r1=131452&r2=131453&view=diff ============================================================================== --- lldb/trunk/include/lldb/Core/State.h (original) +++ lldb/trunk/include/lldb/Core/State.h Mon May 16 22:37:42 2011 @@ -41,6 +41,9 @@ const char * GetFormatAsCString (lldb::Format format); +const char * +GetPermissionsAsCString (uint32_t permissions); + } // namespace lldb_private #endif // liblldb_State_h_ Added: lldb/trunk/include/lldb/Target/Memory.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/Memory.h?rev=131453&view=auto ============================================================================== --- lldb/trunk/include/lldb/Target/Memory.h (added) +++ lldb/trunk/include/lldb/Target/Memory.h Mon May 16 22:37:42 2011 @@ -0,0 +1,189 @@ +//===-- Memory.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_Memory_h_ +#define liblldb_Memory_h_ + +// C Includes +// C++ Includes +#include +#include + +// Other libraries and framework includes +//#include "llvm/ADT/BitVector.h" + +// Project includes +#include "lldb/lldb-private.h" +#include "lldb/Host/Mutex.h" + +namespace lldb_private { + //---------------------------------------------------------------------- + // A class to track memory that was read from a live process between + // runs. + //---------------------------------------------------------------------- + class MemoryCache + { + public: + //------------------------------------------------------------------ + // Constructors and Destructors + //------------------------------------------------------------------ + MemoryCache (Process &process); + + ~MemoryCache (); + + void + Clear(); + + void + Flush (lldb::addr_t addr, size_t size); + + size_t + Read (lldb::addr_t addr, + void *dst, + size_t dst_len, + Error &error); + + uint32_t + GetMemoryCacheLineSize() const + { + return m_cache_line_byte_size ; + } + protected: + typedef std::map collection; + //------------------------------------------------------------------ + // Classes that inherit from MemoryCache can see and modify these + //------------------------------------------------------------------ + Process &m_process; + uint32_t m_cache_line_byte_size; + Mutex m_cache_mutex; + collection m_cache; + + private: + DISALLOW_COPY_AND_ASSIGN (MemoryCache); + }; + + + class AllocatedBlock + { + public: + AllocatedBlock (lldb::addr_t addr, + uint32_t byte_size, + uint32_t permissions, + uint32_t chunk_size); + + ~AllocatedBlock (); + + lldb::addr_t + ReserveBlock (uint32_t size); + + bool + FreeBlock (lldb::addr_t addr); + + lldb::addr_t + GetBaseAddress () const + { + return m_addr; + } + + uint32_t + GetByteSize () const + { + return m_byte_size; + } + + uint32_t + GetPermissions () const + { + return m_permissions; + } + + uint32_t + GetChunkSize () const + { + return m_chunk_size; + } + + bool + Contains (lldb::addr_t addr) const + { + return ((addr >= m_addr) && addr < (m_addr + m_byte_size)); + } + protected: + uint32_t + TotalChunks () const + { + return m_byte_size / m_chunk_size; + } + + uint32_t + CalculateChunksNeededForSize (uint32_t size) const + { + return (size + m_chunk_size - 1) / m_chunk_size; + } + const lldb::addr_t m_addr; // Base address of this block of memory + const uint32_t m_byte_size; // 4GB of chunk should be enough... + const uint32_t m_permissions; // Permissions for this memory (logical OR of lldb::Permissions bits) + const uint32_t m_chunk_size; // The size of chunks that the memory at m_addr is divied up into + typedef std::map OffsetToChunkSize; + OffsetToChunkSize m_offset_to_chunk_size; + //llvm::BitVector m_allocated; + }; + + + //---------------------------------------------------------------------- + // A class that can track allocated memory and give out allocated memory + // without us having to make an allocate/deallocate call every time we + // need some memory in a process that is being debugged. + //---------------------------------------------------------------------- + class AllocatedMemoryCache + { + public: + //------------------------------------------------------------------ + // Constructors and Destructors + //------------------------------------------------------------------ + AllocatedMemoryCache (Process &process); + + ~AllocatedMemoryCache (); + + void + Clear(); + + lldb::addr_t + AllocateMemory (size_t byte_size, + uint32_t permissions, + Error &error); + + bool + DeallocateMemory (lldb::addr_t ptr); + + protected: + typedef lldb::SharedPtr::Type AllocatedBlockSP; + + AllocatedBlockSP + AllocatePage (uint32_t byte_size, + uint32_t permissions, + uint32_t chunk_size, + Error &error); + + + //------------------------------------------------------------------ + // Classes that inherit from MemoryCache can see and modify these + //------------------------------------------------------------------ + Process &m_process; + Mutex m_mutex; + typedef std::multimap PermissionsToBlockMap; + PermissionsToBlockMap m_memory_map; + + private: + DISALLOW_COPY_AND_ASSIGN (AllocatedMemoryCache); + }; + +} // namespace lldb_private + +#endif // liblldb_Memory_h_ Modified: lldb/trunk/include/lldb/Target/Process.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/Process.h?rev=131453&r1=131452&r2=131453&view=diff ============================================================================== --- lldb/trunk/include/lldb/Target/Process.h (original) +++ lldb/trunk/include/lldb/Target/Process.h Mon May 16 22:37:42 2011 @@ -37,6 +37,7 @@ #include "lldb/Interpreter/Args.h" #include "lldb/Interpreter/Options.h" #include "lldb/Target/ExecutionContextScope.h" +#include "lldb/Target/Memory.h" #include "lldb/Target/ThreadList.h" #include "lldb/Target/UnixSignals.h" @@ -2602,48 +2603,6 @@ std::string m_exit_string; }; - - class MemoryCache - { - public: - //------------------------------------------------------------------ - // Constructors and Destructors - //------------------------------------------------------------------ - MemoryCache (); - - ~MemoryCache (); - - void - Clear(); - - void - Flush (lldb::addr_t addr, size_t size); - - size_t - Read (Process *process, - lldb::addr_t addr, - void *dst, - size_t dst_len, - Error &error); - - uint32_t - GetMemoryCacheLineSize() const - { - return m_cache_line_byte_size ; - } - protected: - typedef std::map collection; - //------------------------------------------------------------------ - // Classes that inherit from MemoryCache can see and modify these - //------------------------------------------------------------------ - uint32_t m_cache_line_byte_size; - Mutex m_cache_mutex; - collection m_cache; - - private: - DISALLOW_COPY_AND_ASSIGN (MemoryCache); - }; - bool HijackPrivateProcessEvents (Listener *listener); @@ -2686,6 +2645,7 @@ lldb_private::Mutex m_stdio_communication_mutex; std::string m_stdout_data; MemoryCache m_memory_cache; + AllocatedMemoryCache m_allocated_memory_cache; typedef std::map LanguageRuntimeCollection; LanguageRuntimeCollection m_language_runtimes; Modified: lldb/trunk/lldb.xcodeproj/project.pbxproj URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/lldb.xcodeproj/project.pbxproj?rev=131453&r1=131452&r2=131453&view=diff ============================================================================== --- lldb/trunk/lldb.xcodeproj/project.pbxproj (original) +++ lldb/trunk/lldb.xcodeproj/project.pbxproj Mon May 16 22:37:42 2011 @@ -340,6 +340,7 @@ 2689FFFF13353DB600698AC0 /* BreakpointResolver.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26BC7E1210F1B83100F91463 /* BreakpointResolver.cpp */; }; 268F9D53123AA15200B91E9B /* SBSymbolContextList.h in Headers */ = {isa = PBXBuildFile; fileRef = 268F9D52123AA15200B91E9B /* SBSymbolContextList.h */; settings = {ATTRIBUTES = (Public, ); }; }; 268F9D55123AA16600B91E9B /* SBSymbolContextList.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 268F9D54123AA16600B91E9B /* SBSymbolContextList.cpp */; }; + 2690B3711381D5C300ECFBAE /* Memory.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2690B3701381D5C300ECFBAE /* Memory.cpp */; }; 2692BA15136610C100F9E14D /* UnwindAssemblyInstEmulation.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2692BA13136610C100F9E14D /* UnwindAssemblyInstEmulation.cpp */; }; 2697A54D133A6305004E4240 /* PlatformDarwin.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2697A54B133A6305004E4240 /* PlatformDarwin.cpp */; }; 26A69C5F137A17A500262477 /* RegisterValue.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26C6886E137880C400407EDF /* RegisterValue.cpp */; }; @@ -695,6 +696,8 @@ 268DA873130095ED00C9483A /* Terminal.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Terminal.cpp; sourceTree = ""; }; 268F9D52123AA15200B91E9B /* SBSymbolContextList.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SBSymbolContextList.h; path = include/lldb/API/SBSymbolContextList.h; sourceTree = ""; }; 268F9D54123AA16600B91E9B /* SBSymbolContextList.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = SBSymbolContextList.cpp; path = source/API/SBSymbolContextList.cpp; sourceTree = ""; }; + 2690B36F1381D5B600ECFBAE /* Memory.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = Memory.h; path = include/lldb/Target/Memory.h; sourceTree = ""; }; + 2690B3701381D5C300ECFBAE /* Memory.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = Memory.cpp; path = source/Target/Memory.cpp; sourceTree = ""; }; 2692BA13136610C100F9E14D /* UnwindAssemblyInstEmulation.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = UnwindAssemblyInstEmulation.cpp; sourceTree = ""; }; 2692BA14136610C100F9E14D /* UnwindAssemblyInstEmulation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = UnwindAssemblyInstEmulation.h; sourceTree = ""; }; 269416AD119A024800FF2715 /* CommandObjectTarget.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = CommandObjectTarget.cpp; path = source/Commands/CommandObjectTarget.cpp; sourceTree = ""; }; @@ -2242,6 +2245,8 @@ 26DAFD9711529BC7005A394E /* ExecutionContextScope.h */, 4CB4430912491DDA00C13DC2 /* LanguageRuntime.h */, 4CB4430A12491DDA00C13DC2 /* LanguageRuntime.cpp */, + 2690B36F1381D5B600ECFBAE /* Memory.h */, + 2690B3701381D5C300ECFBAE /* Memory.cpp */, 4CB443F612499B6E00C13DC2 /* ObjCLanguageRuntime.h */, 4CB443F212499B5000C13DC2 /* ObjCLanguageRuntime.cpp */, 495BBACF119A0DE700418BEA /* PathMappingList.h */, @@ -3187,6 +3192,7 @@ 26DB3E1C1379E7AD0080DC73 /* ABIMacOSX_i386.cpp in Sources */, 26DB3E1F1379E7AD0080DC73 /* ABISysV_x86_64.cpp in Sources */, 26A69C5F137A17A500262477 /* RegisterValue.cpp in Sources */, + 2690B3711381D5C300ECFBAE /* Memory.cpp in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; Modified: lldb/trunk/source/Core/State.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/State.cpp?rev=131453&r1=131452&r2=131453&view=diff ============================================================================== --- lldb/trunk/source/Core/State.cpp (original) +++ lldb/trunk/source/Core/State.cpp Mon May 16 22:37:42 2011 @@ -84,6 +84,31 @@ return unknown_format_string; } + +const char * +lldb_private::GetPermissionsAsCString (uint32_t permissions) +{ + switch (permissions) + { + case 0: return "---"; + case ePermissionsWritable: return "-w-"; + case ePermissionsReadable: return "r--"; + case ePermissionsExecutable: return "--x"; + case ePermissionsReadable | + ePermissionsWritable: return "rw-"; + case ePermissionsReadable | + ePermissionsExecutable: return "r-x"; + case ePermissionsWritable | + ePermissionsExecutable: return "-wx"; + case ePermissionsReadable | + ePermissionsWritable | + ePermissionsExecutable: return "rwx"; + default: + break; + } + return "???"; +} + bool lldb_private::StateIsRunningState (StateType state) { 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=131453&r1=131452&r2=131453&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp (original) +++ lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp Mon May 16 22:37:42 2011 @@ -1663,7 +1663,7 @@ } if (allocated_addr == LLDB_INVALID_ADDRESS) - error.SetErrorStringWithFormat("unable to allocate %zu bytes of memory with permissions %u", size, permissions); + error.SetErrorStringWithFormat("unable to allocate %zu bytes of memory with permissions %s", size, GetPermissionsAsCString (permissions)); else error.Clear(); return allocated_addr; Added: lldb/trunk/source/Target/Memory.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/Memory.cpp?rev=131453&view=auto ============================================================================== --- lldb/trunk/source/Target/Memory.cpp (added) +++ lldb/trunk/source/Target/Memory.cpp Mon May 16 22:37:42 2011 @@ -0,0 +1,413 @@ +//===-- Memory.cpp ----------------------------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#include "lldb/Target/Memory.h" +// C Includes +// C++ Includes +// Other libraries and framework includes +// Project includes +#include "lldb/Core/DataBufferHeap.h" +#include "lldb/Core/State.h" +#include "lldb/Core/Log.h" +#include "lldb/Target/Process.h" + +using namespace lldb; +using namespace lldb_private; + +//---------------------------------------------------------------------- +// MemoryCache constructor +//---------------------------------------------------------------------- +MemoryCache::MemoryCache(Process &process) : + m_process (process), + m_cache_line_byte_size (512), + m_cache_mutex (Mutex::eMutexTypeRecursive), + m_cache () +{ +} + +//---------------------------------------------------------------------- +// Destructor +//---------------------------------------------------------------------- +MemoryCache::~MemoryCache() +{ +} + +void +MemoryCache::Clear() +{ + Mutex::Locker locker (m_cache_mutex); + m_cache.clear(); +} + +void +MemoryCache::Flush (addr_t addr, size_t size) +{ + if (size == 0) + return; + + const uint32_t cache_line_byte_size = m_cache_line_byte_size; + const addr_t end_addr = (addr + size - 1); + const addr_t flush_start_addr = addr - (addr % cache_line_byte_size); + const addr_t flush_end_addr = end_addr - (end_addr % cache_line_byte_size); + + Mutex::Locker locker (m_cache_mutex); + if (m_cache.empty()) + return; + + assert ((flush_start_addr % cache_line_byte_size) == 0); + + for (addr_t curr_addr = flush_start_addr; curr_addr <= flush_end_addr; curr_addr += cache_line_byte_size) + { + collection::iterator pos = m_cache.find (curr_addr); + if (pos != m_cache.end()) + m_cache.erase(pos); + } +} + +size_t +MemoryCache::Read (addr_t addr, + void *dst, + size_t dst_len, + Error &error) +{ + size_t bytes_left = dst_len; + if (dst && bytes_left > 0) + { + const uint32_t cache_line_byte_size = m_cache_line_byte_size; + uint8_t *dst_buf = (uint8_t *)dst; + addr_t curr_addr = addr - (addr % cache_line_byte_size); + addr_t cache_offset = addr - curr_addr; + Mutex::Locker locker (m_cache_mutex); + + while (bytes_left > 0) + { + collection::const_iterator pos = m_cache.find (curr_addr); + collection::const_iterator end = m_cache.end (); + + if (pos != end) + { + size_t curr_read_size = cache_line_byte_size - cache_offset; + if (curr_read_size > bytes_left) + curr_read_size = bytes_left; + + memcpy (dst_buf + dst_len - bytes_left, pos->second->GetBytes() + cache_offset, curr_read_size); + + bytes_left -= curr_read_size; + curr_addr += curr_read_size + cache_offset; + cache_offset = 0; + + if (bytes_left > 0) + { + // Get sequential cache page hits + for (++pos; (pos != end) && (bytes_left > 0); ++pos) + { + assert ((curr_addr % cache_line_byte_size) == 0); + + if (pos->first != curr_addr) + break; + + curr_read_size = pos->second->GetByteSize(); + if (curr_read_size > bytes_left) + curr_read_size = bytes_left; + + memcpy (dst_buf + dst_len - bytes_left, pos->second->GetBytes(), curr_read_size); + + bytes_left -= curr_read_size; + curr_addr += curr_read_size; + + // We have a cache page that succeeded to read some bytes + // but not an entire page. If this happens, we must cap + // off how much data we are able to read... + if (pos->second->GetByteSize() != cache_line_byte_size) + return dst_len - bytes_left; + } + } + } + + // We need to read from the process + + if (bytes_left > 0) + { + assert ((curr_addr % cache_line_byte_size) == 0); + std::auto_ptr data_buffer_heap_ap(new DataBufferHeap (cache_line_byte_size, 0)); + size_t process_bytes_read = m_process.ReadMemoryFromInferior (curr_addr, + data_buffer_heap_ap->GetBytes(), + data_buffer_heap_ap->GetByteSize(), + error); + if (process_bytes_read == 0) + return dst_len - bytes_left; + + if (process_bytes_read != cache_line_byte_size) + data_buffer_heap_ap->SetByteSize (process_bytes_read); + m_cache[curr_addr] = DataBufferSP (data_buffer_heap_ap.release()); + // We have read data and put it into the cache, continue through the + // loop again to get the data out of the cache... + } + } + } + + return dst_len - bytes_left; +} + + + +AllocatedBlock::AllocatedBlock (lldb::addr_t addr, + uint32_t byte_size, + uint32_t permissions, + uint32_t chunk_size) : + m_addr (addr), + m_byte_size (byte_size), + m_permissions (permissions), + m_chunk_size (chunk_size), + m_offset_to_chunk_size () +// m_allocated (byte_size / chunk_size) +{ + assert (byte_size > chunk_size); +} + +AllocatedBlock::~AllocatedBlock () +{ +} + +lldb::addr_t +AllocatedBlock::ReserveBlock (uint32_t size) +{ + addr_t addr = LLDB_INVALID_ADDRESS; + if (size <= m_byte_size) + { + const uint32_t needed_chunks = CalculateChunksNeededForSize (size); + LogSP log (GetLogIfAllCategoriesSet (LIBLLDB_LOG_PROCESS | LIBLLDB_LOG_VERBOSE)); + + if (m_offset_to_chunk_size.empty()) + { + m_offset_to_chunk_size[0] = needed_chunks; + if (log) + log->Printf ("[1] AllocatedBlock::ReserveBlock (size = %u (0x%x)) => offset = 0x%x, %u %u bit chunks", size, size, 0, needed_chunks, m_chunk_size); + addr = m_addr; + } + else + { + uint32_t last_offset = 0; + OffsetToChunkSize::const_iterator pos = m_offset_to_chunk_size.begin(); + OffsetToChunkSize::const_iterator end = m_offset_to_chunk_size.end(); + while (pos != end) + { + if (pos->first > last_offset) + { + const uint32_t bytes_available = pos->first - last_offset; + const uint32_t num_chunks = CalculateChunksNeededForSize (bytes_available); + if (num_chunks >= needed_chunks) + { + m_offset_to_chunk_size[last_offset] = needed_chunks; + if (log) + log->Printf ("[2] AllocatedBlock::ReserveBlock (size = %u (0x%x)) => offset = 0x%x, %u %u bit chunks", size, size, last_offset, needed_chunks, m_chunk_size); + addr = m_addr + last_offset; + break; + } + } + + last_offset = pos->first + pos->second * m_chunk_size; + + if (++pos == end) + { + // Last entry... + const uint32_t chunks_left = CalculateChunksNeededForSize (m_byte_size - last_offset); + if (chunks_left >= needed_chunks) + { + m_offset_to_chunk_size[last_offset] = needed_chunks; + if (log) + log->Printf ("[3] AllocatedBlock::ReserveBlock (size = %u (0x%x)) => offset = 0x%x, %u %u bit chunks", size, size, last_offset, needed_chunks, m_chunk_size); + addr = m_addr + last_offset; + break; + } + } + } + } +// const uint32_t total_chunks = m_allocated.size (); +// uint32_t unallocated_idx = 0; +// uint32_t allocated_idx = m_allocated.find_first(); +// uint32_t first_chunk_idx = UINT32_MAX; +// uint32_t num_chunks; +// while (1) +// { +// if (allocated_idx == UINT32_MAX) +// { +// // No more bits are set starting from unallocated_idx, so we +// // either have enough chunks for the request, or we don't. +// // Eiter way we break out of the while loop... +// num_chunks = total_chunks - unallocated_idx; +// if (needed_chunks <= num_chunks) +// first_chunk_idx = unallocated_idx; +// break; +// } +// else if (allocated_idx > unallocated_idx) +// { +// // We have some allocated chunks, check if there are enough +// // free chunks to satisfy the request? +// num_chunks = allocated_idx - unallocated_idx; +// if (needed_chunks <= num_chunks) +// { +// // Yep, we have enough! +// first_chunk_idx = unallocated_idx; +// break; +// } +// } +// +// while (unallocated_idx < total_chunks) +// { +// if (m_allocated[unallocated_idx]) +// ++unallocated_idx; +// else +// break; +// } +// +// if (unallocated_idx >= total_chunks) +// break; +// +// allocated_idx = m_allocated.find_next(unallocated_idx); +// } +// +// if (first_chunk_idx != UINT32_MAX) +// { +// const uint32_t end_bit_idx = unallocated_idx + needed_chunks; +// for (uint32_t idx = first_chunk_idx; idx < end_bit_idx; ++idx) +// m_allocated.set(idx); +// return m_addr + m_chunk_size * first_chunk_idx; +// } + } + LogSP log (GetLogIfAllCategoriesSet (LIBLLDB_LOG_PROCESS | LIBLLDB_LOG_VERBOSE)); + if (log) + log->Printf ("AllocatedBlock::ReserveBlock (size = %u (0x%x)) => 0x%16.16llx", size, size, (uint64_t)addr); + return addr; +} + +bool +AllocatedBlock::FreeBlock (addr_t addr) +{ + uint32_t offset = addr - m_addr; + OffsetToChunkSize::iterator pos = m_offset_to_chunk_size.find (offset); + bool success = false; + if (pos != m_offset_to_chunk_size.end()) + { + m_offset_to_chunk_size.erase (pos); + success = true; + } + LogSP log (GetLogIfAllCategoriesSet (LIBLLDB_LOG_PROCESS | LIBLLDB_LOG_VERBOSE)); + if (log) + log->Printf ("AllocatedBlock::FreeBlock (addr = 0x%16.16llx) => %i", (uint64_t)addr, success); + return success; +} + + +AllocatedMemoryCache::AllocatedMemoryCache (Process &process) : + m_process (process), + m_mutex (Mutex::eMutexTypeRecursive), + m_memory_map() +{ +} + +AllocatedMemoryCache::~AllocatedMemoryCache () +{ +} + + +void +AllocatedMemoryCache::Clear() +{ + Mutex::Locker locker (m_mutex); + if (m_process.IsAlive()) + { + PermissionsToBlockMap::iterator pos, end = m_memory_map.end(); + for (pos = m_memory_map.begin(); pos != end; ++pos) + m_process.DoDeallocateMemory(pos->second->GetBaseAddress()); + } + m_memory_map.clear(); +} + + +AllocatedMemoryCache::AllocatedBlockSP +AllocatedMemoryCache::AllocatePage (uint32_t byte_size, + uint32_t permissions, + uint32_t chunk_size, + Error &error) +{ + AllocatedBlockSP block_sp; + const size_t page_size = 4096; + const size_t num_pages = (byte_size + page_size - 1) / page_size; + const size_t page_byte_size = num_pages * page_size; + + addr_t addr = m_process.DoAllocateMemory(page_byte_size, permissions, error); + + LogSP log (GetLogIfAllCategoriesSet (LIBLLDB_LOG_PROCESS)); + if (log) + { + log->Printf ("Process::DoAllocateMemory (byte_size = 0x%8.8zx, permissions = %s) => 0x%16.16llx", + page_byte_size, + GetPermissionsAsCString(permissions), + (uint64_t)addr); + } + + if (addr != LLDB_INVALID_ADDRESS) + { + block_sp.reset (new AllocatedBlock (addr, page_byte_size, permissions, chunk_size)); + m_memory_map.insert (std::make_pair (permissions, block_sp)); + } + return block_sp; +} + +lldb::addr_t +AllocatedMemoryCache::AllocateMemory (size_t byte_size, + uint32_t permissions, + Error &error) +{ + Mutex::Locker locker (m_mutex); + + addr_t addr = LLDB_INVALID_ADDRESS; + std::pair range = m_memory_map.equal_range (permissions); + + for (PermissionsToBlockMap::iterator pos = range.first; pos != range.second; ++pos) + { + addr = (*pos).second->ReserveBlock (byte_size); + } + + if (addr == LLDB_INVALID_ADDRESS) + { + AllocatedBlockSP block_sp (AllocatePage (byte_size, permissions, 16, error)); + + if (block_sp) + addr = block_sp->ReserveBlock (byte_size); + } + LogSP log (GetLogIfAllCategoriesSet (LIBLLDB_LOG_PROCESS)); + if (log) + log->Printf ("AllocatedMemoryCache::AllocateMemory (byte_size = 0x%8.8zx, permissions = %s) => 0x%16.16llx", byte_size, GetPermissionsAsCString(permissions), (uint64_t)addr); + return addr; +} + +bool +AllocatedMemoryCache::DeallocateMemory (lldb::addr_t addr) +{ + Mutex::Locker locker (m_mutex); + + PermissionsToBlockMap::iterator pos, end = m_memory_map.end(); + bool success = false; + for (pos = m_memory_map.begin(); pos != end; ++pos) + { + if (pos->second->Contains (addr)) + { + success = pos->second->FreeBlock (addr); + break; + } + } + LogSP log (GetLogIfAllCategoriesSet (LIBLLDB_LOG_PROCESS)); + if (log) + log->Printf("AllocatedMemoryCache::DeallocateMemory (addr = 0x%16.16llx) => %i", (uint64_t)addr, success); + return success; +} + + Modified: lldb/trunk/source/Target/Process.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/Process.cpp?rev=131453&r1=131452&r2=131453&view=diff ============================================================================== --- lldb/trunk/source/Target/Process.cpp (original) +++ lldb/trunk/source/Target/Process.cpp Mon May 16 22:37:42 2011 @@ -539,144 +539,6 @@ m_match_all_users = false; } -//---------------------------------------------------------------------- -// MemoryCache constructor -//---------------------------------------------------------------------- -Process::MemoryCache::MemoryCache() : - m_cache_line_byte_size (512), - m_cache_mutex (Mutex::eMutexTypeRecursive), - m_cache () -{ -} - -//---------------------------------------------------------------------- -// Destructor -//---------------------------------------------------------------------- -Process::MemoryCache::~MemoryCache() -{ -} - -void -Process::MemoryCache::Clear() -{ - Mutex::Locker locker (m_cache_mutex); - m_cache.clear(); -} - -void -Process::MemoryCache::Flush (addr_t addr, size_t size) -{ - if (size == 0) - return; - - const uint32_t cache_line_byte_size = m_cache_line_byte_size; - const addr_t end_addr = (addr + size - 1); - const addr_t flush_start_addr = addr - (addr % cache_line_byte_size); - const addr_t flush_end_addr = end_addr - (end_addr % cache_line_byte_size); - - Mutex::Locker locker (m_cache_mutex); - if (m_cache.empty()) - return; - - assert ((flush_start_addr % cache_line_byte_size) == 0); - - for (addr_t curr_addr = flush_start_addr; curr_addr <= flush_end_addr; curr_addr += cache_line_byte_size) - { - collection::iterator pos = m_cache.find (curr_addr); - if (pos != m_cache.end()) - m_cache.erase(pos); - } -} - -size_t -Process::MemoryCache::Read -( - Process *process, - addr_t addr, - void *dst, - size_t dst_len, - Error &error -) -{ - size_t bytes_left = dst_len; - if (dst && bytes_left > 0) - { - const uint32_t cache_line_byte_size = m_cache_line_byte_size; - uint8_t *dst_buf = (uint8_t *)dst; - addr_t curr_addr = addr - (addr % cache_line_byte_size); - addr_t cache_offset = addr - curr_addr; - Mutex::Locker locker (m_cache_mutex); - - while (bytes_left > 0) - { - collection::const_iterator pos = m_cache.find (curr_addr); - collection::const_iterator end = m_cache.end (); - - if (pos != end) - { - size_t curr_read_size = cache_line_byte_size - cache_offset; - if (curr_read_size > bytes_left) - curr_read_size = bytes_left; - - memcpy (dst_buf + dst_len - bytes_left, pos->second->GetBytes() + cache_offset, curr_read_size); - - bytes_left -= curr_read_size; - curr_addr += curr_read_size + cache_offset; - cache_offset = 0; - - if (bytes_left > 0) - { - // Get sequential cache page hits - for (++pos; (pos != end) && (bytes_left > 0); ++pos) - { - assert ((curr_addr % cache_line_byte_size) == 0); - - if (pos->first != curr_addr) - break; - - curr_read_size = pos->second->GetByteSize(); - if (curr_read_size > bytes_left) - curr_read_size = bytes_left; - - memcpy (dst_buf + dst_len - bytes_left, pos->second->GetBytes(), curr_read_size); - - bytes_left -= curr_read_size; - curr_addr += curr_read_size; - - // We have a cache page that succeeded to read some bytes - // but not an entire page. If this happens, we must cap - // off how much data we are able to read... - if (pos->second->GetByteSize() != cache_line_byte_size) - return dst_len - bytes_left; - } - } - } - - // We need to read from the process - - if (bytes_left > 0) - { - assert ((curr_addr % cache_line_byte_size) == 0); - std::auto_ptr data_buffer_heap_ap(new DataBufferHeap (cache_line_byte_size, 0)); - size_t process_bytes_read = process->ReadMemoryFromInferior (curr_addr, - data_buffer_heap_ap->GetBytes(), - data_buffer_heap_ap->GetByteSize(), - error); - if (process_bytes_read == 0) - return dst_len - bytes_left; - - if (process_bytes_read != cache_line_byte_size) - data_buffer_heap_ap->SetByteSize (process_bytes_read); - m_cache[curr_addr] = DataBufferSP (data_buffer_heap_ap.release()); - // We have read data and put it into the cache, continue through the - // loop again to get the data out of the cache... - } - } - } - - return dst_len - bytes_left; -} - Process* Process::FindPlugin (Target &target, const char *plugin_name, Listener &listener) { @@ -735,7 +597,8 @@ m_stdio_communication ("process.stdio"), m_stdio_communication_mutex (Mutex::eMutexTypeRecursive), m_stdout_data (), - m_memory_cache (), + m_memory_cache (*this), + m_allocated_memory_cache (*this), m_next_event_action_ap() { UpdateInstanceName(); @@ -1759,7 +1622,7 @@ Process::ReadMemory (addr_t addr, void *buf, size_t size, Error &error) { // Memory caching enabled, no verification - return m_memory_cache.Read (this, addr, buf, size, error); + return m_memory_cache.Read (addr, buf, size, error); } #endif // #else for #if defined (VERIFY_MEMORY_READS) @@ -1968,29 +1831,36 @@ return bytes_written; } - +#define USE_ALLOCATE_MEMORY_CACHE 1 addr_t Process::AllocateMemory(size_t size, uint32_t permissions, Error &error) { - // Fixme: we should track the blocks we've allocated, and clean them up... - // We could even do our own allocator here if that ends up being more efficient. +#if defined (USE_ALLOCATE_MEMORY_CACHE) + return m_allocated_memory_cache.AllocateMemory(size, permissions, error); +#else addr_t allocated_addr = DoAllocateMemory (size, permissions, error); LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_PROCESS)); if (log) - log->Printf("Process::AllocateMemory(size=%4zu, permissions=%c%c%c) => 0x%16.16llx (m_stop_id = %u)", + log->Printf("Process::AllocateMemory(size=%4zu, permissions=%s) => 0x%16.16llx (m_stop_id = %u)", size, - permissions & ePermissionsReadable ? 'r' : '-', - permissions & ePermissionsWritable ? 'w' : '-', - permissions & ePermissionsExecutable ? 'x' : '-', + GetPermissionsAsCString (permissions), (uint64_t)allocated_addr, m_stop_id); return allocated_addr; +#endif } Error Process::DeallocateMemory (addr_t ptr) { - Error error(DoDeallocateMemory (ptr)); + Error error; +#if defined (USE_ALLOCATE_MEMORY_CACHE) + if (!m_allocated_memory_cache.DeallocateMemory(ptr)) + { + error.SetErrorStringWithFormat ("deallocation of memory at 0x%llx failed.", (uint64_t)ptr); + } +#else + error = DoDeallocateMemory (ptr); LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_PROCESS)); if (log) @@ -1998,6 +1868,7 @@ ptr, error.AsCString("SUCCESS"), m_stop_id); +#endif return error; } From gclayton at apple.com Mon May 16 22:51:29 2011 From: gclayton at apple.com (Greg Clayton) Date: Tue, 17 May 2011 03:51:29 -0000 Subject: [Lldb-commits] [lldb] r131454 - in /lldb/trunk/source: Expression/ClangUserExpression.cpp Expression/ClangUtilityFunction.cpp Plugins/Process/gdb-remote/GDBRemoteRegisterContext.cpp Plugins/Process/gdb-remote/ProcessGDBRemote.cpp Message-ID: <20110517035129.F1D282A6C12C@llvm.org> Author: gclayton Date: Mon May 16 22:51:29 2011 New Revision: 131454 URL: http://llvm.org/viewvc/llvm-project?rev=131454&view=rev Log: Fixed the "mmap" to work on MacOSX/darwin by supplying the correct arguemnts. Modified ClangUserExpression and ClangUtilityFunction to display the actual error (if one is available) that made the JIT fail instead of a canned response. Fixed the restoring of all register values when the 'G' packet doesn't work to use the correct data. Modified: lldb/trunk/source/Expression/ClangUserExpression.cpp lldb/trunk/source/Expression/ClangUtilityFunction.cpp lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.cpp lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp Modified: lldb/trunk/source/Expression/ClangUserExpression.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/ClangUserExpression.cpp?rev=131454&r1=131453&r2=131454&view=diff ============================================================================== --- lldb/trunk/source/Expression/ClangUserExpression.cpp (original) +++ lldb/trunk/source/Expression/ClangUserExpression.cpp Mon May 16 22:51:29 2011 @@ -296,7 +296,11 @@ } else { - error_stream.Printf ("error: expression can't be interpreted or run\n", num_errors); + const char *error_cstr = jit_error.AsCString(); + if (error_cstr && error_cstr[0]) + error_stream.Printf ("error: %s\n", error_cstr); + else + error_stream.Printf ("error: expression can't be interpreted or run\n", num_errors); return false; } } Modified: lldb/trunk/source/Expression/ClangUtilityFunction.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/ClangUtilityFunction.cpp?rev=131454&r1=131453&r2=131454&view=diff ============================================================================== --- lldb/trunk/source/Expression/ClangUtilityFunction.cpp (original) +++ lldb/trunk/source/Expression/ClangUtilityFunction.cpp Mon May 16 22:51:29 2011 @@ -135,7 +135,11 @@ } else { - error_stream.Printf ("error: expression can't be interpreted or run\n", num_errors); + const char *error_cstr = jit_error.AsCString(); + if (error_cstr && error_cstr[0]) + error_stream.Printf ("error: %s\n", error_cstr); + else + error_stream.Printf ("error: expression can't be interpreted or run\n", num_errors); return false; } } Modified: lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.cpp?rev=131454&r1=131453&r2=131454&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.cpp (original) +++ lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.cpp Mon May 16 22:51:29 2011 @@ -363,12 +363,17 @@ ::snprintf (thread_id_cstr, sizeof(thread_id_cstr), ";thread:%4.4x;", m_thread.GetID()); response.GetStringRef().append (thread_id_cstr); } - data_sp.reset (new DataBufferHeap (response.GetStringRef().c_str(), - response.GetStringRef().size())); - return true; + const char *g_data = response.GetStringRef().c_str(); + size_t g_data_len = strspn(g_data, "0123456789abcdefABCDEF"); + if (g_data_len > 0) + { + data_sp.reset (new DataBufferHeap (g_data, g_data_len)); + return true; + } } } } + data_sp.reset(); return false; } @@ -403,10 +408,21 @@ uint32_t num_restored = 0; // We need to manually go through all of the registers and // restore them manually - DataExtractor data (G_packet + 1, // Skip the leading 'G' - G_packet_len - 1, - m_reg_data.GetByteOrder(), - m_reg_data.GetAddressByteSize()); + + response.GetStringRef().assign (G_packet, G_packet_len); + response.SetFilePos(1); // Skip the leading 'G' + DataBufferHeap buffer (m_reg_data.GetByteSize(), 0); + DataExtractor restore_data (buffer.GetBytes(), + buffer.GetByteSize(), + m_reg_data.GetByteOrder(), + m_reg_data.GetAddressByteSize()); + + const uint32_t bytes_extracted = response.GetHexBytes ((void *)restore_data.GetDataStart(), + restore_data.GetByteSize(), + '\xcc'); + + if (bytes_extracted < restore_data.GetByteSize()) + restore_data.SetData(restore_data.GetDataStart(), bytes_extracted, m_reg_data.GetByteOrder()); //ReadRegisterBytes (const RegisterInfo *reg_info, RegisterValue &value, DataExtractor &data) const RegisterInfo *reg_info; @@ -419,15 +435,40 @@ bool write_reg = true; const uint32_t reg_byte_offset = reg_info->byte_offset; const uint32_t reg_byte_size = reg_info->byte_size; - if (m_reg_valid[reg]) + + const char *restore_src = (const char *)restore_data.PeekData(reg_byte_offset, reg_byte_size); + if (restore_src) { - const uint8_t *current_src = m_reg_data.PeekData(reg_byte_offset, reg_byte_size); - const uint8_t *restore_src = data.PeekData(reg_byte_offset, reg_byte_size); - if (current_src && restore_src) - write_reg = memcmp (current_src, restore_src, reg_byte_size) != 0; + if (m_reg_valid[reg]) + { + const char *current_src = (const char *)m_reg_data.PeekData(reg_byte_offset, reg_byte_size); + if (current_src) + write_reg = memcmp (current_src, restore_src, reg_byte_size) != 0; + } + + if (write_reg) + { + StreamString packet; + packet.Printf ("P%x=", reg); + packet.PutBytesAsRawHex8 (restore_src, + reg_byte_size, + lldb::endian::InlHostByteOrder(), + lldb::endian::InlHostByteOrder()); + + if (thread_suffix_supported) + packet.Printf (";thread:%4.4x;", m_thread.GetID()); + + m_reg_valid[reg] = false; + if (gdb_comm.SendPacketAndWaitForResponse(packet.GetString().c_str(), + packet.GetString().size(), + response, + false)) + { + if (response.IsOKResponse()) + ++num_restored; + } + } } - if (WriteRegisterBytes(reg_info, data, reg_byte_offset)) - ++num_restored; } return num_restored > 0; } Modified: lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp?rev=131454&r1=131453&r2=131454&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp (original) +++ lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp Mon May 16 22:51:29 2011 @@ -1596,7 +1596,7 @@ addr_t arg1_addr = 0; addr_t arg2_len = size; addr_t arg3_prot = PROT_NONE; - addr_t arg4_flags = MAP_ANON; + addr_t arg4_flags = MAP_ANON | MAP_PRIVATE; addr_t arg5_fd = -1; addr_t arg6_offset = 0; if (permissions & lldb::ePermissionsReadable) From johnny.chen at apple.com Tue May 17 11:32:56 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Tue, 17 May 2011 16:32:56 -0000 Subject: [Lldb-commits] [lldb] r131465 - /lldb/trunk/Makefile Message-ID: <20110517163256.5903C2A6C12E@llvm.org> Author: johnny Date: Tue May 17 11:32:56 2011 New Revision: 131465 URL: http://llvm.org/viewvc/llvm-project?rev=131465&view=rev Log: Forgot to check in this patch for Marco Minutoli. Update to Python2.7 from Python 2.6. Modified: lldb/trunk/Makefile Modified: lldb/trunk/Makefile URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/Makefile?rev=131465&r1=131464&r2=131465&view=diff ============================================================================== --- lldb/trunk/Makefile (original) +++ lldb/trunk/Makefile Tue May 17 11:32:56 2011 @@ -29,7 +29,7 @@ include $(LEVEL)/Makefile.common # Set Python include directory -PYTHON_INC_DIR = /usr/include/python2.6 +PYTHON_INC_DIR = /usr/include/python2.7 # Set common LLDB build flags. CPP.Flags += -I$(PROJ_SRC_DIR)/$(LLDB_LEVEL)/include From gclayton at apple.com Tue May 17 11:50:15 2011 From: gclayton at apple.com (Greg Clayton) Date: Tue, 17 May 2011 16:50:15 -0000 Subject: [Lldb-commits] [lldb] r131468 - /lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.cpp Message-ID: <20110517165015.F0F062A6C12C@llvm.org> Author: gclayton Date: Tue May 17 11:50:15 2011 New Revision: 131468 URL: http://llvm.org/viewvc/llvm-project?rev=131468&view=rev Log: Fixed an issue that broke expression parsing related to backing up all register values. There is some junk that was appearing at the end of the result the 'g' packet (read all register values). This function was being called in: bool GDBRemoteRegisterContext::ReadAllRegisterValues (lldb::DataBufferSP &data_sp) Then the packet data for the 'G' packet (write all registers) was being placed into "data_sp" so the: bool GDBRemoteRegisterContext::WriteAllRegisterValues (const lldb::DataBufferSP &data_sp) could restore it. In attempting to clean up the extra junk at the end of this packet data, the packet was getting truncated. Modified: lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.cpp Modified: lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.cpp?rev=131468&r1=131467&r2=131468&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.cpp (original) +++ lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.cpp Tue May 17 11:50:15 2011 @@ -364,7 +364,7 @@ response.GetStringRef().append (thread_id_cstr); } const char *g_data = response.GetStringRef().c_str(); - size_t g_data_len = strspn(g_data, "0123456789abcdefABCDEF"); + size_t g_data_len = strspn(g_data + 1, "0123456789abcdefABCDEF"); if (g_data_len > 0) { data_sp.reset (new DataBufferHeap (g_data, g_data_len)); From gclayton at apple.com Tue May 17 12:37:43 2011 From: gclayton at apple.com (Greg Clayton) Date: Tue, 17 May 2011 17:37:43 -0000 Subject: [Lldb-commits] [lldb] r131470 - /lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugLine.cpp Message-ID: <20110517173743.C2CC32A6C12C@llvm.org> Author: gclayton Date: Tue May 17 12:37:43 2011 New Revision: 131470 URL: http://llvm.org/viewvc/llvm-project?rev=131470&view=rev Log: Removed some assertions that could crash the controlling program and turned them into warnings to stderr. Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugLine.cpp Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugLine.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugLine.cpp?rev=131470&r1=131469&r2=131470&view=diff ============================================================================== --- lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugLine.cpp (original) +++ lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugLine.cpp Tue May 17 12:37:43 2011 @@ -400,7 +400,7 @@ bool DWARFDebugLine::ParsePrologue(const DataExtractor& debug_line_data, dw_offset_t* offset_ptr, Prologue* prologue) { -// const uint32_t prologue_offset = *offset_ptr; + const uint32_t prologue_offset = *offset_ptr; //DEBUG_PRINTF("0x%8.8x: ParsePrologue()\n", *offset_ptr); @@ -453,7 +453,11 @@ break; } - assert(*offset_ptr == end_prologue_offset); + if (*offset_ptr != end_prologue_offset) + { + fprintf (stderr, "warning: parsing line table prologue at 0x%8.8x should have ended at 0x%8.8x but it ended ad 0x%8.8x\n", + prologue_offset, end_prologue_offset, *offset_ptr); + } return end_prologue_offset; } @@ -532,7 +536,11 @@ } } - assert(offset == end_prologue_offset); + if (offset != end_prologue_offset) + { + fprintf (stderr, "warning: parsing line table prologue at 0x%8.8x should have ended at 0x%8.8x but it ended ad 0x%8.8x\n", + stmt_list, end_prologue_offset, offset); + } return end_prologue_offset; } @@ -576,8 +584,6 @@ const dw_offset_t end_offset = debug_line_offset + prologue->total_length + sizeof(prologue->total_length); - assert(debug_line_data.ValidOffset(end_offset-1)); - State state(prologue, log, callback, userData); while (*offset_ptr < end_offset) From gclayton at apple.com Tue May 17 13:13:59 2011 From: gclayton at apple.com (Greg Clayton) Date: Tue, 17 May 2011 18:13:59 -0000 Subject: [Lldb-commits] [lldb] r131472 - /lldb/trunk/source/Target/SectionLoadList.cpp Message-ID: <20110517181359.75A662A6C12C@llvm.org> Author: gclayton Date: Tue May 17 13:13:59 2011 New Revision: 131472 URL: http://llvm.org/viewvc/llvm-project?rev=131472&view=rev Log: Fixed an issue where addresses would not get resolved for the last loaded section in the section load list. Modified: lldb/trunk/source/Target/SectionLoadList.cpp Modified: lldb/trunk/source/Target/SectionLoadList.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/SectionLoadList.cpp?rev=131472&r1=131471&r2=131472&view=diff ============================================================================== --- lldb/trunk/source/Target/SectionLoadList.cpp (original) +++ lldb/trunk/source/Target/SectionLoadList.cpp Tue May 17 13:13:59 2011 @@ -174,19 +174,36 @@ { // First find the top level section that this load address exists in Mutex::Locker locker(m_mutex); - addr_to_sect_collection::const_iterator pos = m_addr_to_sect.lower_bound (load_addr); - if (pos != m_addr_to_sect.end()) + if (!m_addr_to_sect.empty()) { - if (load_addr != pos->first && pos != m_addr_to_sect.begin()) - --pos; - if (load_addr >= pos->first) + addr_to_sect_collection::const_iterator pos = m_addr_to_sect.lower_bound (load_addr); + if (pos != m_addr_to_sect.end()) { - addr_t offset = load_addr - pos->first; - if (offset < pos->second->GetByteSize()) + if (load_addr != pos->first && pos != m_addr_to_sect.begin()) + --pos; + if (load_addr >= pos->first) { - // We have found the top level section, now we need to find the - // deepest child section. - return pos->second->ResolveContainedAddress (offset, so_addr); + addr_t offset = load_addr - pos->first; + if (offset < pos->second->GetByteSize()) + { + // We have found the top level section, now we need to find the + // deepest child section. + return pos->second->ResolveContainedAddress (offset, so_addr); + } + } + } + else + { + pos = m_addr_to_sect.begin(); + if (load_addr >= pos->first) + { + addr_t offset = load_addr - pos->first; + if (offset < pos->second->GetByteSize()) + { + // We have found the top level section, now we need to find the + // deepest child section. + return pos->second->ResolveContainedAddress (offset, so_addr); + } } } } From gclayton at apple.com Tue May 17 13:15:05 2011 From: gclayton at apple.com (Greg Clayton) Date: Tue, 17 May 2011 18:15:05 -0000 Subject: [Lldb-commits] [lldb] r131473 - /lldb/trunk/source/Symbol/ClangASTContext.cpp Message-ID: <20110517181505.621DB2A6C12C@llvm.org> Author: gclayton Date: Tue May 17 13:15:05 2011 New Revision: 131473 URL: http://llvm.org/viewvc/llvm-project?rev=131473&view=rev Log: Fixed an assert that could cause a crash when there was an unrecognized DW_TAG_base_type. Now it is a error printed to stderr. 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=131473&r1=131472&r2=131473&view=diff ============================================================================== --- lldb/trunk/source/Symbol/ClangASTContext.cpp (original) +++ lldb/trunk/source/Symbol/ClangASTContext.cpp Tue May 17 13:15:05 2011 @@ -862,7 +862,14 @@ } // This assert should fire for anything that we don't catch above so we know // to fix any issues we run into. - assert (!"error: ClangASTContext::GetClangTypeForDWARFEncodingAndSize() contains an unhandled encoding. Fix this ASAP!"); + if (type_name) + { + fprintf (stderr, "error: need to add support for DW_TAG_base_type '%s' encoded with DW_ATE = 0x%x, bit_size = %u\n", type_name, dw_ate, bit_size); + } + else + { + fprintf (stderr, "error: need to add support for DW_TAG_base_type encoded with DW_ATE = 0x%x, bit_size = %u\n", dw_ate, bit_size); + } return NULL; } From johnny.chen at apple.com Tue May 17 17:14:39 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Tue, 17 May 2011 22:14:39 -0000 Subject: [Lldb-commits] [lldb] r131494 - in /lldb/trunk: scripts/Python/modify-python-lldb.py test/python_api/lldbutil/frame/TestFrameUtils.py test/python_api/lldbutil/iter/TestLLDBIterator.py test/python_api/lldbutil/iter/TestRegistersIterator.py test/python_api/lldbutil/process/TestPrintStackTraces.py Message-ID: <20110517221439.6D4152A6C12C@llvm.org> Author: johnny Date: Tue May 17 17:14:39 2011 New Revision: 131494 URL: http://llvm.org/viewvc/llvm-project?rev=131494&view=rev Log: Add truth value testing to those lldb Python objects with the IsValid() method definitions. object.__nonzero__(self) is called to implement truth value testing and the built-in operation bool(), via a simple delegation to self.IsValid(). Change tests under python_api/lldbutil to utilize this mechanism. Modified: lldb/trunk/scripts/Python/modify-python-lldb.py lldb/trunk/test/python_api/lldbutil/frame/TestFrameUtils.py lldb/trunk/test/python_api/lldbutil/iter/TestLLDBIterator.py lldb/trunk/test/python_api/lldbutil/iter/TestRegistersIterator.py lldb/trunk/test/python_api/lldbutil/process/TestPrintStackTraces.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=131494&r1=131493&r2=131494&view=diff ============================================================================== --- lldb/trunk/scripts/Python/modify-python-lldb.py (original) +++ lldb/trunk/scripts/Python/modify-python-lldb.py Tue May 17 17:14:39 2011 @@ -34,22 +34,24 @@ ''' -# # This supports the iteration protocol. -# iter_def = " def __iter__(self): return lldb_iter(self, '%s', '%s')" module_iter = " def module_iter(self): return lldb_iter(self, '%s', '%s')" breakpoint_iter = " def breakpoint_iter(self): return lldb_iter(self, '%s', '%s')" -# + # Called to implement the built-in function len(). # Eligible objects are those containers with unambiguous iteration support. -# len_def = " def __len__(self): return self.%s()" -# + # This supports the rich comparison methods of __eq__ and __ne__. eq_def = " def __eq__(self, other): return isinstance(other, %s) and %s" ne_def = " def __ne__(self, other): return not self.__eq__(other)" +# Called to implement truth value testing and the built-in operation bool(); +# should return False or True, or their integer equivalents 0 or 1. +# Delegate to self.IsValid() if it is defined for the current lldb object. +nonzero_def = " def __nonzero__(self): return self.IsValid()" + # # The dictionary defines a mapping from classname to (getsize, getelem) tuple. # @@ -109,6 +111,9 @@ # The pattern for recognizing the beginning of the __init__ method definition. init_pattern = re.compile("^ def __init__\(self, \*args\):") +# The pattern for recognizing the beginning of the IsValid method definition. +isvalid_pattern = re.compile("^ def IsValid\(\*args\):") + # These define the states of our finite state machine. NORMAL = 0 DEFINING_ITERATOR = 1 @@ -117,13 +122,32 @@ # The lldb_iter_def only needs to be inserted once. lldb_iter_defined = False; +# Our FSM begins its life in the NORMAL state, and transitions to the +# DEFINING_ITERATOR and/or DEFINING_EQUALITY state whenever it encounters the +# beginning of certain class definitions, see dictionaries 'd' and 'e' above. +# +# Note that the two states DEFINING_ITERATOR and DEFINING_EQUALITY are +# orthogonal in that our FSM can be in one, the other, or both states at the +# same time. During such time, the FSM is eagerly searching for the __init__ +# method definition in order to insert the appropriate method(s) into the lldb +# module. +# +# Assuming that SWIG puts out the __init__ method definition before other method +# definitions, the FSM, while in NORMAL state, also checks the current input for +# IsValid() definition, and inserts a __nonzero__() method definition to +# implement truth value testing and the built-in operation bool(). state = NORMAL for line in content.splitlines(): if state == NORMAL: match = class_pattern.search(line) + # Inserts the lldb_iter() definition before the first class definition. if not lldb_iter_defined and match: print >> new_content, lldb_iter_def lldb_iter_defined = True + + # If we are at the beginning of the class definitions, prepare to + # transition to the DEFINING_ITERATOR/DEFINING_EQUALITY state for the + # right class names. if match: cls = match.group(1) if cls in d: @@ -132,6 +156,10 @@ if cls in e: # Adding support for eq and ne for the matched SB class. state = (state | DEFINING_EQUALITY) + # Look for 'def IsValid(*args):', and once located, add implementation + # of truth value testing for objects by delegation. + elif isvalid_pattern.search(line): + print >> new_content, nonzero_def elif state > NORMAL: match = init_pattern.search(line) if match: Modified: lldb/trunk/test/python_api/lldbutil/frame/TestFrameUtils.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/python_api/lldbutil/frame/TestFrameUtils.py?rev=131494&r1=131493&r2=131494&view=diff ============================================================================== --- lldb/trunk/test/python_api/lldbutil/frame/TestFrameUtils.py (original) +++ lldb/trunk/test/python_api/lldbutil/frame/TestFrameUtils.py Tue May 17 17:14:39 2011 @@ -27,15 +27,15 @@ exe = os.path.join(os.getcwd(), "a.out") target = self.dbg.CreateTarget(exe) - self.assertTrue(target.IsValid(), VALID_TARGET) + self.assertTrue(target, VALID_TARGET) breakpoint = target.BreakpointCreateByLocation("main.c", self.line) - self.assertTrue(breakpoint.IsValid(), VALID_BREAKPOINT) + self.assertTrue(breakpoint, VALID_BREAKPOINT) # Now launch the process, and do not stop at entry point. self.process = target.LaunchSimple(None, None, os.getcwd()) - if not self.process.IsValid(): + if not self.process: self.fail("SBTarget.LaunchProcess() failed") self.assertTrue(self.process.GetState() == lldb.eStateStopped, PROCESS_STOPPED) @@ -45,7 +45,7 @@ frame0 = thread.GetFrameAtIndex(0) frame1 = thread.GetFrameAtIndex(1) parent = lldbutil.get_parent_frame(frame0) - self.assertTrue(parent.IsValid() and parent.GetFrameID() == frame1.GetFrameID()) + self.assertTrue(parent and parent.GetFrameID() == frame1.GetFrameID()) frame0_args = lldbutil.get_args_as_string(frame0) parent_args = lldbutil.get_args_as_string(parent) self.assertTrue(frame0_args and parent_args) Modified: lldb/trunk/test/python_api/lldbutil/iter/TestLLDBIterator.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/python_api/lldbutil/iter/TestLLDBIterator.py?rev=131494&r1=131493&r2=131494&view=diff ============================================================================== --- lldb/trunk/test/python_api/lldbutil/iter/TestLLDBIterator.py (original) +++ lldb/trunk/test/python_api/lldbutil/iter/TestLLDBIterator.py Tue May 17 17:14:39 2011 @@ -38,16 +38,16 @@ exe = os.path.join(os.getcwd(), "a.out") target = self.dbg.CreateTarget(exe) - self.assertTrue(target.IsValid(), VALID_TARGET) + self.assertTrue(target, VALID_TARGET) breakpoint = target.BreakpointCreateByLocation("main.cpp", self.line1) - self.assertTrue(breakpoint.IsValid(), VALID_BREAKPOINT) + self.assertTrue(breakpoint, VALID_BREAKPOINT) # Now launch the process, and do not stop at entry point. rc = lldb.SBError() self.process = target.Launch (self.dbg.GetListener(), None, None, os.ctermid(), os.ctermid(), os.ctermid(), None, 0, False, rc) - if not rc.Success() or not self.process.IsValid(): + if not rc.Success() or not self.process: self.fail("SBTarget.LaunchProcess() failed") from lldbutil import get_description @@ -70,12 +70,12 @@ exe = os.path.join(os.getcwd(), "a.out") target = self.dbg.CreateTarget(exe) - self.assertTrue(target.IsValid(), VALID_TARGET) + self.assertTrue(target, VALID_TARGET) breakpoint = target.BreakpointCreateByLocation("main.cpp", self.line1) - self.assertTrue(breakpoint.IsValid(), VALID_BREAKPOINT) + self.assertTrue(breakpoint, VALID_BREAKPOINT) breakpoint = target.BreakpointCreateByLocation("main.cpp", self.line2) - self.assertTrue(breakpoint.IsValid(), VALID_BREAKPOINT) + self.assertTrue(breakpoint, VALID_BREAKPOINT) self.assertTrue(target.GetNumBreakpoints() == 2) @@ -99,16 +99,16 @@ exe = os.path.join(os.getcwd(), "a.out") target = self.dbg.CreateTarget(exe) - self.assertTrue(target.IsValid(), VALID_TARGET) + self.assertTrue(target, VALID_TARGET) breakpoint = target.BreakpointCreateByLocation("main.cpp", self.line1) - self.assertTrue(breakpoint.IsValid(), VALID_BREAKPOINT) + self.assertTrue(breakpoint, VALID_BREAKPOINT) # Now launch the process, and do not stop at entry point. rc = lldb.SBError() self.process = target.Launch (self.dbg.GetListener(), None, None, os.ctermid(), os.ctermid(), os.ctermid(), None, 0, False, rc) - if not rc.Success() or not self.process.IsValid(): + if not rc.Success() or not self.process: self.fail("SBTarget.LaunchProcess() failed") from lldbutil import print_stacktrace Modified: lldb/trunk/test/python_api/lldbutil/iter/TestRegistersIterator.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/python_api/lldbutil/iter/TestRegistersIterator.py?rev=131494&r1=131493&r2=131494&view=diff ============================================================================== --- lldb/trunk/test/python_api/lldbutil/iter/TestRegistersIterator.py (original) +++ lldb/trunk/test/python_api/lldbutil/iter/TestRegistersIterator.py Tue May 17 17:14:39 2011 @@ -27,16 +27,16 @@ exe = os.path.join(os.getcwd(), "a.out") target = self.dbg.CreateTarget(exe) - self.assertTrue(target.IsValid(), VALID_TARGET) + self.assertTrue(target, VALID_TARGET) breakpoint = target.BreakpointCreateByLocation("main.cpp", self.line1) - self.assertTrue(breakpoint.IsValid(), VALID_BREAKPOINT) + self.assertTrue(breakpoint, VALID_BREAKPOINT) # Now launch the process, and do not stop at entry point. rc = lldb.SBError() self.process = target.Launch (self.dbg.GetListener(), None, None, os.ctermid(), os.ctermid(), os.ctermid(), None, 0, False, rc) - if not rc.Success() or not self.process.IsValid(): + if not rc.Success() or not self.process: self.fail("SBTarget.LaunchProcess() failed") import lldbutil @@ -52,7 +52,7 @@ if self.TraceOn(): print "\nNumber of general purpose registers: %d" % num for reg in REGs: - self.assertTrue(reg.IsValid()) + self.assertTrue(reg) if self.TraceOn(): print "%s => %s" % (reg.GetName(), reg.GetValue(frame)) @@ -61,7 +61,7 @@ if self.TraceOn(): print "\nNumber of floating point registers: %d" % num for reg in REGs: - self.assertTrue(reg.IsValid()) + self.assertTrue(reg) if self.TraceOn(): print "%s => %s" % (reg.GetName(), reg.GetValue(frame)) @@ -70,7 +70,7 @@ if self.TraceOn(): print "\nNumber of exception state registers: %d" % num for reg in REGs: - self.assertTrue(reg.IsValid()) + self.assertTrue(reg) if self.TraceOn(): print "%s => %s" % (reg.GetName(), reg.GetValue(frame)) @@ -79,7 +79,7 @@ "Floating Point Registers", "Exception State Registers"]: REGs = lldbutil.get_registers(frame, kind) - self.assertTrue(REGs.IsValid()) + self.assertTrue(REGs) # We've finished dumping the registers for frame #0. break Modified: lldb/trunk/test/python_api/lldbutil/process/TestPrintStackTraces.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/python_api/lldbutil/process/TestPrintStackTraces.py?rev=131494&r1=131493&r2=131494&view=diff ============================================================================== --- lldb/trunk/test/python_api/lldbutil/process/TestPrintStackTraces.py (original) +++ lldb/trunk/test/python_api/lldbutil/process/TestPrintStackTraces.py Tue May 17 17:14:39 2011 @@ -28,16 +28,16 @@ exe = os.path.join(os.getcwd(), "a.out") target = self.dbg.CreateTarget(exe) - self.assertTrue(target.IsValid(), VALID_TARGET) + self.assertTrue(target, VALID_TARGET) breakpoint = target.BreakpointCreateByLocation("main.cpp", self.line) - self.assertTrue(breakpoint.IsValid(), VALID_BREAKPOINT) + self.assertTrue(breakpoint, VALID_BREAKPOINT) # Now launch the process, and do not stop at entry point. rc = lldb.SBError() self.process = target.Launch (self.dbg.GetListener(), None, None, os.ctermid(), os.ctermid(), os.ctermid(), None, 0, False, rc) - if not rc.Success() or not self.process.IsValid(): + if not rc.Success() or not self.process: self.fail("SBTarget.LaunchProcess() failed") import lldbutil From jingham at apple.com Tue May 17 17:24:54 2011 From: jingham at apple.com (Jim Ingham) Date: Tue, 17 May 2011 22:24:54 -0000 Subject: [Lldb-commits] [lldb] r131498 - in /lldb/trunk/source: Expression/ClangUserExpression.cpp Target/Process.cpp Message-ID: <20110517222454.9203B2A6C12C@llvm.org> Author: jingham Date: Tue May 17 17:24:54 2011 New Revision: 131498 URL: http://llvm.org/viewvc/llvm-project?rev=131498&view=rev Log: RunThreadPlan should set the plan to "not private" since it needs that, and then reset it to the original value when done. Modified: lldb/trunk/source/Expression/ClangUserExpression.cpp lldb/trunk/source/Target/Process.cpp Modified: lldb/trunk/source/Expression/ClangUserExpression.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/ClangUserExpression.cpp?rev=131498&r1=131497&r2=131498&view=diff ============================================================================== --- lldb/trunk/source/Expression/ClangUserExpression.cpp (original) +++ lldb/trunk/source/Expression/ClangUserExpression.cpp Tue May 17 17:24:54 2011 @@ -508,7 +508,7 @@ lldb::addr_t function_stack_pointer = static_cast(call_plan_sp.get())->GetFunctionStackPointer(); - // call_plan_sp->SetPrivate(true); + call_plan_sp->SetPrivate(true); uint32_t single_thread_timeout_usec = 500000; Modified: lldb/trunk/source/Target/Process.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/Process.cpp?rev=131498&r1=131497&r2=131498&view=diff ============================================================================== --- lldb/trunk/source/Target/Process.cpp (original) +++ lldb/trunk/source/Target/Process.cpp Tue May 17 17:24:54 2011 @@ -3226,6 +3226,13 @@ return eExecutionSetupError; } + // We rely on the thread plan we are running returning "PlanCompleted" if when it successfully completes. + // For that to be true the plan can't be private - since private plans suppress themselves in the + // GetCompletedPlan call. + + bool orig_plan_private = thread_plan_sp->GetPrivate(); + thread_plan_sp->SetPrivate(false); + if (m_private_state.GetValue() != eStateStopped) { errors.Printf ("RunThreadPlan called while the private state was not stopped."); @@ -3390,7 +3397,7 @@ // 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 (true); + thread_plan_sp->SetPrivate (orig_plan_private); return_value = eExecutionCompleted; } else From johnny.chen at apple.com Tue May 17 17:58:50 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Tue, 17 May 2011 22:58:50 -0000 Subject: [Lldb-commits] [lldb] r131501 - /lldb/trunk/test/dotest.py Message-ID: <20110517225850.CC0BE2A6C12C@llvm.org> Author: johnny Date: Tue May 17 17:58:50 2011 New Revision: 131501 URL: http://llvm.org/viewvc/llvm-project?rev=131501&view=rev Log: Let's also stick the svn info for the base directory into a file under the session directory, which also includes the command line used to invoke the test suite. Modified: lldb/trunk/test/dotest.py Modified: lldb/trunk/test/dotest.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/dotest.py?rev=131501&r1=131500&r2=131501&view=diff ============================================================================== --- lldb/trunk/test/dotest.py (original) +++ lldb/trunk/test/dotest.py Tue May 17 17:58:50 2011 @@ -133,6 +133,9 @@ # Set this flag if there is any session info dumped during the test run. sdir_has_content = False +# svn_info stores the output from 'svn info lldb.base.dir'. +svn_info = '' + # Default verbosity is 0. verbose = 0 @@ -506,6 +509,7 @@ global rdir global testdirs global dumpSysPath + global svn_info # Get the directory containing the current script. if "DOTEST_PROFILE" in os.environ and "DOTEST_SCRIPT_DIR" in os.environ: @@ -581,7 +585,10 @@ #print "The 'lldb' executable path is", lldbExec os.system('%s -v' % lldbExec) - os.system('svn info %s' % base) + import subprocess + pipe = subprocess.Popen(["svn", "info", base], stdout = subprocess.PIPE) + svn_info = pipe.stdout.read() + print svn_info global ignore @@ -816,6 +823,13 @@ " will go into directory '%s'\n" % sdir_name) sys.stderr.write("Command invoked: %s\n" % getMyCommandLine()) +if not os.path.isdir(sdir_name): + os.mkdir(sdir_name) +fname = os.path.join(sdir_name, "svn-info") +with open(fname, "w") as f: + print >> f, svn_info + print >> f, "Command invoked: %s\n" % getMyCommandLine() + # # Invoke the default TextTestRunner to run the test suite, possibly iterating # over different configurations. From gclayton at apple.com Tue May 17 20:58:14 2011 From: gclayton at apple.com (Greg Clayton) Date: Wed, 18 May 2011 01:58:14 -0000 Subject: [Lldb-commits] [lldb] r131517 - in /lldb/trunk: include/lldb/Core/ include/lldb/Target/ source/Core/ source/Plugins/ABI/MacOSX-arm/ source/Plugins/ABI/MacOSX-i386/ source/Plugins/Instruction/ARM/ source/Plugins/Process/Utility/ source/Plugins/Process/gdb-remote/ source/Target/ Message-ID: <20110518015815.211092A6C12C@llvm.org> Author: gclayton Date: Tue May 17 20:58:14 2011 New Revision: 131517 URL: http://llvm.org/viewvc/llvm-project?rev=131517&view=rev Log: Added a way to resolve an load address from a target: bool Address::SetLoadAddress (lldb::addr_t load_addr, Target *target); Added an == and != operator to RegisterValue. Modified the ThreadPlanTracer to use RegisterValue objects to store the register values when single stepping. Also modified the output to be a bit less wide. Fixed the ABIMacOSX_arm to not overwrite stuff on the stack. Also made the trivial function call be able to set the ARM/Thumbness of the target correctly, and also sets the return value ARM/Thumbness. Fixed the encoding on the arm s0-s31 and d16 - d31 registers when the default register set from a standard GDB server register sets. Modified: lldb/trunk/include/lldb/Core/Address.h lldb/trunk/include/lldb/Core/RegisterValue.h lldb/trunk/include/lldb/Target/Process.h lldb/trunk/include/lldb/Target/ThreadPlanTracer.h lldb/trunk/source/Core/Address.cpp lldb/trunk/source/Core/RegisterValue.cpp lldb/trunk/source/Plugins/ABI/MacOSX-arm/ABIMacOSX_arm.cpp lldb/trunk/source/Plugins/ABI/MacOSX-i386/ABIMacOSX_i386.cpp lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp lldb/trunk/source/Plugins/Process/Utility/ARMDefines.h lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.cpp lldb/trunk/source/Target/ThreadPlanTracer.cpp Modified: lldb/trunk/include/lldb/Core/Address.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/Address.h?rev=131517&r1=131516&r2=131517&view=diff ============================================================================== --- lldb/trunk/include/lldb/Core/Address.h (original) +++ lldb/trunk/include/lldb/Core/Address.h Tue May 17 20:58:14 2011 @@ -357,6 +357,33 @@ ResolveLinkedAddress (); //------------------------------------------------------------------ + /// Set the address to represent \a load_addr. + /// + /// The address will attempt to find a loaded section within + /// \a target that contains \a load_addr. If successful, this + /// address object will have a valid section and offset. Else this + /// address object will have no section (NULL) and the offset will + /// be \a load_addr. + /// + /// @param[in] load_addr + /// A load address from a current process. + /// + /// @param[in] target + /// The target to use when trying resolve the address into + /// a section + offset. The Target's SectionLoadList object + /// is used to resolve the address. + /// + /// @return + /// Returns \b true if the load address was resolved to be + /// section/offset, \b false otherwise. It is often ok for an + /// address no not resolve to a section in a module, this often + /// happens for JIT'ed code, or any load addresses on the stack + /// or heap. + //------------------------------------------------------------------ + bool + SetLoadAddress (lldb::addr_t load_addr, Target *target); + + //------------------------------------------------------------------ /// Get accessor for the module for this address. /// /// @return Modified: lldb/trunk/include/lldb/Core/RegisterValue.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/RegisterValue.h?rev=131517&r1=131516&r2=131517&view=diff ============================================================================== --- lldb/trunk/include/lldb/Core/RegisterValue.h (original) +++ lldb/trunk/include/lldb/Core/RegisterValue.h Tue May 17 20:58:14 2011 @@ -197,6 +197,12 @@ m_type = eTypeInvalid; } + bool + operator == (const RegisterValue &rhs) const; + + bool + operator != (const RegisterValue &rhs) const; + void operator = (uint8_t uint) { Modified: lldb/trunk/include/lldb/Target/Process.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/Process.h?rev=131517&r1=131516&r2=131517&view=diff ============================================================================== --- lldb/trunk/include/lldb/Target/Process.h (original) +++ lldb/trunk/include/lldb/Target/Process.h Tue May 17 20:58:14 2011 @@ -2184,6 +2184,8 @@ /// that a block that isn't set writable can still be written on from lldb, /// just not by the process itself. /// + /// @param[in/out] error + /// An error object to fill in if things go wrong. /// @return /// The address of the allocated buffer in the process, or /// LLDB_INVALID_ADDRESS if the allocation failed. Modified: lldb/trunk/include/lldb/Target/ThreadPlanTracer.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/ThreadPlanTracer.h?rev=131517&r1=131516&r2=131517&view=diff ============================================================================== --- lldb/trunk/include/lldb/Target/ThreadPlanTracer.h (original) +++ lldb/trunk/include/lldb/Target/ThreadPlanTracer.h Tue May 17 20:58:14 2011 @@ -15,6 +15,7 @@ // Other libraries and framework includes // Project includes #include "lldb/lldb-private.h" +#include "lldb/Core/RegisterValue.h" #include "lldb/Symbol/TaggedASTType.h" #include "lldb/Target/Thread.h" @@ -117,7 +118,7 @@ Disassembler *m_disassembler; const ABI *m_abi; TypeFromUser m_intptr_type; - std::vector m_register_values; + std::vector m_register_values; lldb::DataBufferSP m_buffer_sp; }; Modified: lldb/trunk/source/Core/Address.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/Address.cpp?rev=131517&r1=131516&r2=131517&view=diff ============================================================================== --- lldb/trunk/source/Core/Address.cpp (original) +++ lldb/trunk/source/Core/Address.cpp Tue May 17 20:58:14 2011 @@ -821,3 +821,14 @@ } return eAddressClassUnknown; } + +bool +Address::SetLoadAddress (lldb::addr_t load_addr, Target *target) +{ + if (target && target->GetSectionLoadList().ResolveLoadAddress(load_addr, *this)) + return true; + m_section = NULL; + m_offset = load_addr; + return false; +} + Modified: lldb/trunk/source/Core/RegisterValue.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/RegisterValue.cpp?rev=131517&r1=131516&r2=131517&view=diff ============================================================================== --- lldb/trunk/source/Core/RegisterValue.cpp (original) +++ lldb/trunk/source/Core/RegisterValue.cpp Tue May 17 20:58:14 2011 @@ -73,7 +73,7 @@ data.Dump (s, 0, // Offset in "data" format, // Format to use when dumping - reg_info->byte_size, // item_byte_size + reg_info->byte_size, // item_byte_size 1, // item_count UINT32_MAX, // num_per_line LLDB_INVALID_ADDRESS, // base_addr @@ -930,3 +930,73 @@ } } + +bool +RegisterValue::operator == (const RegisterValue &rhs) const +{ + if (m_type == rhs.m_type) + { + switch (m_type) + { + case eTypeInvalid: return true; + case eTypeUInt8: return m_data.uint8 == rhs.m_data.uint8; + case eTypeUInt16: return m_data.uint16 == rhs.m_data.uint16; + case eTypeUInt32: return m_data.uint32 == rhs.m_data.uint32; + case eTypeUInt64: return m_data.uint64 == rhs.m_data.uint64; +#if defined (ENABLE_128_BIT_SUPPORT) + case eTypeUInt128: return m_data.uint128 == rhs.m_data.uint128; +#endif + case eTypeFloat: return m_data.ieee_float == rhs.m_data.ieee_float; + case eTypeDouble: return m_data.ieee_double == rhs.m_data.ieee_double; + case eTypeLongDouble: return m_data.ieee_long_double == rhs.m_data.ieee_long_double; + case eTypeBytes: + if (m_data.buffer.length != rhs.m_data.buffer.length) + return false; + else + { + uint8_t length = m_data.buffer.length; + if (length > kMaxRegisterByteSize) + length = kMaxRegisterByteSize; + return memcmp (m_data.buffer.bytes, rhs.m_data.buffer.bytes, length) == 0; + } + break; + } + } + return false; +} + +bool +RegisterValue::operator != (const RegisterValue &rhs) const +{ + if (m_type != rhs.m_type) + return true; + switch (m_type) + { + case eTypeInvalid: return false; + case eTypeUInt8: return m_data.uint8 != rhs.m_data.uint8; + case eTypeUInt16: return m_data.uint16 != rhs.m_data.uint16; + case eTypeUInt32: return m_data.uint32 != rhs.m_data.uint32; + case eTypeUInt64: return m_data.uint64 != rhs.m_data.uint64; +#if defined (ENABLE_128_BIT_SUPPORT) + case eTypeUInt128: return m_data.uint128 != rhs.m_data.uint128; +#endif + case eTypeFloat: return m_data.ieee_float != rhs.m_data.ieee_float; + case eTypeDouble: return m_data.ieee_double != rhs.m_data.ieee_double; + case eTypeLongDouble: return m_data.ieee_long_double != rhs.m_data.ieee_long_double; + case eTypeBytes: + if (m_data.buffer.length != rhs.m_data.buffer.length) + { + return true; + } + else + { + uint8_t length = m_data.buffer.length; + if (length > kMaxRegisterByteSize) + length = kMaxRegisterByteSize; + return memcmp (m_data.buffer.bytes, rhs.m_data.buffer.bytes, length) != 0; + } + break; + } + return true; +} + 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=131517&r1=131516&r2=131517&view=diff ============================================================================== --- lldb/trunk/source/Plugins/ABI/MacOSX-arm/ABIMacOSX_arm.cpp (original) +++ lldb/trunk/source/Plugins/ABI/MacOSX-arm/ABIMacOSX_arm.cpp Tue May 17 20:58:14 2011 @@ -26,6 +26,7 @@ #include "llvm/ADT/Triple.h" #include "Utility/ARM_DWARF_Registers.h" +#include "Plugins/Process/Utility/ARMDefines.h" #include @@ -107,6 +108,9 @@ return false; if (arg5_ptr) { + // Keep the stack 8 byte aligned, not that we need to + sp -= 8; + sp &= ~(8ull-1ull); reg_value.SetUInt32(*arg5_ptr); if (reg_ctx->WriteRegisterValueToMemory (reg_info, sp, reg_info->byte_size, reg_value).Fail()) return false; @@ -121,8 +125,26 @@ } } } + + // Figure out if our return address is ARM or Thumb. We assume if we don't + // know about an address then it is ARM code. - // Set "lr" to the return address into "lr" + Target *target = &thread.GetProcess().GetTarget(); + Address so_addr; + bool ra_is_thumb = false; + if (return_addr & 3) + ra_is_thumb = true; + else if (so_addr.SetLoadAddress (return_addr, target)) + ra_is_thumb = so_addr.GetAddressClass() == eAddressClassCodeAlternateISA; + + // Set our clear bit zero for the return address if needed. We should never + // need to clear bit zero since the return address will either have bit zero + // or bit one (a thumb instruction on a two byte boundary) already set, or + // it won't and it will need it. + if (ra_is_thumb) + return_addr |= 1u; + + // Set "lr" to the return address if (!reg_ctx->WriteRegisterFromUnsigned (ra_reg_num, return_addr)) return false; @@ -130,10 +152,39 @@ if (!reg_ctx->WriteRegisterFromUnsigned (sp_reg_num, sp)) return false; + bool pc_is_thumb = false; + + // If bit zero or 1 is set, this must be a thumb function, no need to figure + // this out from the symbols. + if (function_addr & 3) + pc_is_thumb = true; + else if (so_addr.SetLoadAddress (function_addr, target)) + pc_is_thumb = so_addr.GetAddressClass() == eAddressClassCodeAlternateISA; + + + const RegisterInfo *cpsr_reg_info = reg_ctx->GetRegisterInfoByName("cpsr"); + const uint32_t curr_cpsr = reg_ctx->ReadRegisterAsUnsigned(cpsr_reg_info, 0); + + // Make a new CPSR and mask out any Thumb IT (if/then) bits + uint32_t new_cpsr = curr_cpsr & ~MASK_CPSR_IT_MASK; + // If bit zero or 1 is set, this must be thumb... + if (pc_is_thumb) + new_cpsr |= MASK_CPSR_T; // Set T bit in CPSR + else + new_cpsr &= ~MASK_CPSR_T; // Clear T bit in CPSR + + if (new_cpsr != curr_cpsr) + { + if (!reg_ctx->WriteRegisterFromUnsigned (cpsr_reg_info, new_cpsr)) + return false; + } + + function_addr &= ~1u; // clear bit zero since the CPSR will take care of the mode for us + // Set "pc" to the address requested if (!reg_ctx->WriteRegisterFromUnsigned (pc_reg_num, function_addr)) return false; - + return true; } Modified: lldb/trunk/source/Plugins/ABI/MacOSX-i386/ABIMacOSX_i386.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ABI/MacOSX-i386/ABIMacOSX_i386.cpp?rev=131517&r1=131516&r2=131517&view=diff ============================================================================== --- lldb/trunk/source/Plugins/ABI/MacOSX-i386/ABIMacOSX_i386.cpp (original) +++ lldb/trunk/source/Plugins/ABI/MacOSX-i386/ABIMacOSX_i386.cpp Tue May 17 20:58:14 2011 @@ -111,7 +111,7 @@ } // Align the SP - sp &= ~(0xfull); // 16-byte alignment + sp &= ~(16ull-1ull); // 16-byte alignment if (arg1_ptr) { @@ -362,7 +362,7 @@ // Align the SP - sp &= ~(0xfull); // 16-byte alignment + sp &= ~(16ull-1ull); // 16-byte alignment // Write the arguments on the stack 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=131517&r1=131516&r2=131517&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp (original) +++ lldb/trunk/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp Tue May 17 20:58:14 2011 @@ -1871,8 +1871,11 @@ EmulateInstruction::Context context; context.type = EmulateInstruction::eContextPushRegisterOnStack; RegisterInfo sp_reg; + RegisterInfo dwarf_reg; + GetRegisterInfo (eRegisterKindDWARF, dwarf_sp, sp_reg); - context.SetRegisterPlusOffset (sp_reg, addr - sp); + GetRegisterInfo (eRegisterKindDWARF, dwarf_r0 + Rt, dwarf_reg); + context.SetRegisterToRegisterPlusOffset ( dwarf_reg, sp_reg, addr - sp); if (Rt != 15) { uint32_t reg_value = ReadCoreReg(Rt, &success); 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=131517&r1=131516&r2=131517&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Process/Utility/ARMDefines.h (original) +++ lldb/trunk/source/Plugins/Process/Utility/ARMDefines.h Tue May 17 20:58:14 2011 @@ -89,7 +89,8 @@ #define CPSR_MODE_SYS 0x1fu // Masks for CPSR -#define MASK_CPSR_MODE_MASK (0x0000001fu) +#define MASK_CPSR_MODE_MASK (0x0000001fu) +#define MASK_CPSR_IT_MASK (0x0600fc00u) #define MASK_CPSR_T (1u << CPSR_T_POS) #define MASK_CPSR_F (1u << CPSR_F_POS) #define MASK_CPSR_I (1u << CPSR_I_POS) Modified: lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.cpp?rev=131517&r1=131516&r2=131517&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.cpp (original) +++ lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.cpp Tue May 17 20:58:14 2011 @@ -507,65 +507,65 @@ { "sp", "r13", 4, 0, eEncodingUint, eFormatHex, { gcc_sp, dwarf_sp, LLDB_REGNUM_GENERIC_SP, 13, 13 }}, { "lr", "r14", 4, 0, eEncodingUint, eFormatHex, { gcc_lr, dwarf_lr, LLDB_REGNUM_GENERIC_RA, 14, 14 }}, { "pc", "r15", 4, 0, eEncodingUint, eFormatHex, { gcc_pc, dwarf_pc, LLDB_REGNUM_GENERIC_PC, 15, 15 }}, - { "f0", NULL, 12, 0, eEncodingIEEE754, eFormatHex, { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, 16, 16 }}, - { "f1", NULL, 12, 0, eEncodingIEEE754, eFormatHex, { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, 17, 17 }}, - { "f2", NULL, 12, 0, eEncodingIEEE754, eFormatHex, { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, 18, 18 }}, - { "f3", NULL, 12, 0, eEncodingIEEE754, eFormatHex, { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, 19, 19 }}, - { "f4", NULL, 12, 0, eEncodingIEEE754, eFormatHex, { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, 20, 20 }}, - { "f5", NULL, 12, 0, eEncodingIEEE754, eFormatHex, { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, 21, 21 }}, - { "f6", NULL, 12, 0, eEncodingIEEE754, eFormatHex, { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, 22, 22 }}, - { "f7", NULL, 12, 0, eEncodingIEEE754, eFormatHex, { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, 23, 23 }}, - { "fps", NULL, 4, 0, eEncodingIEEE754, eFormatHex, { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, 24, 24 }}, + { "f0", NULL, 12, 0, eEncodingUint, eFormatHex, { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, 16, 16 }}, + { "f1", NULL, 12, 0, eEncodingUint, eFormatHex, { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, 17, 17 }}, + { "f2", NULL, 12, 0, eEncodingUint, eFormatHex, { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, 18, 18 }}, + { "f3", NULL, 12, 0, eEncodingUint, eFormatHex, { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, 19, 19 }}, + { "f4", NULL, 12, 0, eEncodingUint, eFormatHex, { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, 20, 20 }}, + { "f5", NULL, 12, 0, eEncodingUint, eFormatHex, { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, 21, 21 }}, + { "f6", NULL, 12, 0, eEncodingUint, eFormatHex, { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, 22, 22 }}, + { "f7", NULL, 12, 0, eEncodingUint, eFormatHex, { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, 23, 23 }}, + { "fps", NULL, 4, 0, eEncodingUint, eFormatHex, { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, 24, 24 }}, { "cpsr","flags", 4, 0, eEncodingUint, eFormatHex, { gcc_cpsr, dwarf_cpsr, LLDB_INVALID_REGNUM, 25, 25 }}, - { "s0", NULL, 4, 0, eEncodingIEEE754, eFormatHex, { LLDB_INVALID_REGNUM, dwarf_s0, LLDB_INVALID_REGNUM, 26, 26 }}, - { "s1", NULL, 4, 0, eEncodingIEEE754, eFormatHex, { LLDB_INVALID_REGNUM, dwarf_s1, LLDB_INVALID_REGNUM, 27, 27 }}, - { "s2", NULL, 4, 0, eEncodingIEEE754, eFormatHex, { LLDB_INVALID_REGNUM, dwarf_s2, LLDB_INVALID_REGNUM, 28, 28 }}, - { "s3", NULL, 4, 0, eEncodingIEEE754, eFormatHex, { LLDB_INVALID_REGNUM, dwarf_s3, LLDB_INVALID_REGNUM, 29, 29 }}, - { "s4", NULL, 4, 0, eEncodingIEEE754, eFormatHex, { LLDB_INVALID_REGNUM, dwarf_s4, LLDB_INVALID_REGNUM, 30, 30 }}, - { "s5", NULL, 4, 0, eEncodingIEEE754, eFormatHex, { LLDB_INVALID_REGNUM, dwarf_s5, LLDB_INVALID_REGNUM, 31, 31 }}, - { "s6", NULL, 4, 0, eEncodingIEEE754, eFormatHex, { LLDB_INVALID_REGNUM, dwarf_s6, LLDB_INVALID_REGNUM, 32, 32 }}, - { "s7", NULL, 4, 0, eEncodingIEEE754, eFormatHex, { LLDB_INVALID_REGNUM, dwarf_s7, LLDB_INVALID_REGNUM, 33, 33 }}, - { "s8", NULL, 4, 0, eEncodingIEEE754, eFormatHex, { LLDB_INVALID_REGNUM, dwarf_s8, LLDB_INVALID_REGNUM, 34, 34 }}, - { "s9", NULL, 4, 0, eEncodingIEEE754, eFormatHex, { LLDB_INVALID_REGNUM, dwarf_s9, LLDB_INVALID_REGNUM, 35, 35 }}, - { "s10", NULL, 4, 0, eEncodingIEEE754, eFormatHex, { LLDB_INVALID_REGNUM, dwarf_s10, LLDB_INVALID_REGNUM, 36, 36 }}, - { "s11", NULL, 4, 0, eEncodingIEEE754, eFormatHex, { LLDB_INVALID_REGNUM, dwarf_s11, LLDB_INVALID_REGNUM, 37, 37 }}, - { "s12", NULL, 4, 0, eEncodingIEEE754, eFormatHex, { LLDB_INVALID_REGNUM, dwarf_s12, LLDB_INVALID_REGNUM, 38, 38 }}, - { "s13", NULL, 4, 0, eEncodingIEEE754, eFormatHex, { LLDB_INVALID_REGNUM, dwarf_s13, LLDB_INVALID_REGNUM, 39, 39 }}, - { "s14", NULL, 4, 0, eEncodingIEEE754, eFormatHex, { LLDB_INVALID_REGNUM, dwarf_s14, LLDB_INVALID_REGNUM, 40, 40 }}, - { "s15", NULL, 4, 0, eEncodingIEEE754, eFormatHex, { LLDB_INVALID_REGNUM, dwarf_s15, LLDB_INVALID_REGNUM, 41, 41 }}, - { "s16", NULL, 4, 0, eEncodingIEEE754, eFormatHex, { LLDB_INVALID_REGNUM, dwarf_s16, LLDB_INVALID_REGNUM, 42, 42 }}, - { "s17", NULL, 4, 0, eEncodingIEEE754, eFormatHex, { LLDB_INVALID_REGNUM, dwarf_s17, LLDB_INVALID_REGNUM, 43, 43 }}, - { "s18", NULL, 4, 0, eEncodingIEEE754, eFormatHex, { LLDB_INVALID_REGNUM, dwarf_s18, LLDB_INVALID_REGNUM, 44, 44 }}, - { "s19", NULL, 4, 0, eEncodingIEEE754, eFormatHex, { LLDB_INVALID_REGNUM, dwarf_s19, LLDB_INVALID_REGNUM, 45, 45 }}, - { "s20", NULL, 4, 0, eEncodingIEEE754, eFormatHex, { LLDB_INVALID_REGNUM, dwarf_s20, LLDB_INVALID_REGNUM, 46, 46 }}, - { "s21", NULL, 4, 0, eEncodingIEEE754, eFormatHex, { LLDB_INVALID_REGNUM, dwarf_s21, LLDB_INVALID_REGNUM, 47, 47 }}, - { "s22", NULL, 4, 0, eEncodingIEEE754, eFormatHex, { LLDB_INVALID_REGNUM, dwarf_s22, LLDB_INVALID_REGNUM, 48, 48 }}, - { "s23", NULL, 4, 0, eEncodingIEEE754, eFormatHex, { LLDB_INVALID_REGNUM, dwarf_s23, LLDB_INVALID_REGNUM, 49, 49 }}, - { "s24", NULL, 4, 0, eEncodingIEEE754, eFormatHex, { LLDB_INVALID_REGNUM, dwarf_s24, LLDB_INVALID_REGNUM, 50, 50 }}, - { "s25", NULL, 4, 0, eEncodingIEEE754, eFormatHex, { LLDB_INVALID_REGNUM, dwarf_s25, LLDB_INVALID_REGNUM, 51, 51 }}, - { "s26", NULL, 4, 0, eEncodingIEEE754, eFormatHex, { LLDB_INVALID_REGNUM, dwarf_s26, LLDB_INVALID_REGNUM, 52, 52 }}, - { "s27", NULL, 4, 0, eEncodingIEEE754, eFormatHex, { LLDB_INVALID_REGNUM, dwarf_s27, LLDB_INVALID_REGNUM, 53, 53 }}, - { "s28", NULL, 4, 0, eEncodingIEEE754, eFormatHex, { LLDB_INVALID_REGNUM, dwarf_s28, LLDB_INVALID_REGNUM, 54, 54 }}, - { "s29", NULL, 4, 0, eEncodingIEEE754, eFormatHex, { LLDB_INVALID_REGNUM, dwarf_s29, LLDB_INVALID_REGNUM, 55, 55 }}, - { "s30", NULL, 4, 0, eEncodingIEEE754, eFormatHex, { LLDB_INVALID_REGNUM, dwarf_s30, LLDB_INVALID_REGNUM, 56, 56 }}, - { "s31", NULL, 4, 0, eEncodingIEEE754, eFormatHex, { LLDB_INVALID_REGNUM, dwarf_s31, LLDB_INVALID_REGNUM, 57, 57 }}, + { "s0", NULL, 4, 0, eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s0, LLDB_INVALID_REGNUM, 26, 26 }}, + { "s1", NULL, 4, 0, eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s1, LLDB_INVALID_REGNUM, 27, 27 }}, + { "s2", NULL, 4, 0, eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s2, LLDB_INVALID_REGNUM, 28, 28 }}, + { "s3", NULL, 4, 0, eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s3, LLDB_INVALID_REGNUM, 29, 29 }}, + { "s4", NULL, 4, 0, eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s4, LLDB_INVALID_REGNUM, 30, 30 }}, + { "s5", NULL, 4, 0, eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s5, LLDB_INVALID_REGNUM, 31, 31 }}, + { "s6", NULL, 4, 0, eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s6, LLDB_INVALID_REGNUM, 32, 32 }}, + { "s7", NULL, 4, 0, eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s7, LLDB_INVALID_REGNUM, 33, 33 }}, + { "s8", NULL, 4, 0, eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s8, LLDB_INVALID_REGNUM, 34, 34 }}, + { "s9", NULL, 4, 0, eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s9, LLDB_INVALID_REGNUM, 35, 35 }}, + { "s10", NULL, 4, 0, eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s10, LLDB_INVALID_REGNUM, 36, 36 }}, + { "s11", NULL, 4, 0, eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s11, LLDB_INVALID_REGNUM, 37, 37 }}, + { "s12", NULL, 4, 0, eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s12, LLDB_INVALID_REGNUM, 38, 38 }}, + { "s13", NULL, 4, 0, eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s13, LLDB_INVALID_REGNUM, 39, 39 }}, + { "s14", NULL, 4, 0, eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s14, LLDB_INVALID_REGNUM, 40, 40 }}, + { "s15", NULL, 4, 0, eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s15, LLDB_INVALID_REGNUM, 41, 41 }}, + { "s16", NULL, 4, 0, eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s16, LLDB_INVALID_REGNUM, 42, 42 }}, + { "s17", NULL, 4, 0, eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s17, LLDB_INVALID_REGNUM, 43, 43 }}, + { "s18", NULL, 4, 0, eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s18, LLDB_INVALID_REGNUM, 44, 44 }}, + { "s19", NULL, 4, 0, eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s19, LLDB_INVALID_REGNUM, 45, 45 }}, + { "s20", NULL, 4, 0, eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s20, LLDB_INVALID_REGNUM, 46, 46 }}, + { "s21", NULL, 4, 0, eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s21, LLDB_INVALID_REGNUM, 47, 47 }}, + { "s22", NULL, 4, 0, eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s22, LLDB_INVALID_REGNUM, 48, 48 }}, + { "s23", NULL, 4, 0, eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s23, LLDB_INVALID_REGNUM, 49, 49 }}, + { "s24", NULL, 4, 0, eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s24, LLDB_INVALID_REGNUM, 50, 50 }}, + { "s25", NULL, 4, 0, eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s25, LLDB_INVALID_REGNUM, 51, 51 }}, + { "s26", NULL, 4, 0, eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s26, LLDB_INVALID_REGNUM, 52, 52 }}, + { "s27", NULL, 4, 0, eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s27, LLDB_INVALID_REGNUM, 53, 53 }}, + { "s28", NULL, 4, 0, eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s28, LLDB_INVALID_REGNUM, 54, 54 }}, + { "s29", NULL, 4, 0, eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s29, LLDB_INVALID_REGNUM, 55, 55 }}, + { "s30", NULL, 4, 0, eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s30, LLDB_INVALID_REGNUM, 56, 56 }}, + { "s31", NULL, 4, 0, eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_s31, LLDB_INVALID_REGNUM, 57, 57 }}, { "fpscr",NULL, 4, 0, eEncodingUint, eFormatHex, { LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, 58, 58 }}, - { "d16", NULL, 8, 0, eEncodingIEEE754, eFormatHex, { LLDB_INVALID_REGNUM, dwarf_d16, LLDB_INVALID_REGNUM, 59, 59 }}, - { "d17", NULL, 8, 0, eEncodingIEEE754, eFormatHex, { LLDB_INVALID_REGNUM, dwarf_d17, LLDB_INVALID_REGNUM, 60, 60 }}, - { "d18", NULL, 8, 0, eEncodingIEEE754, eFormatHex, { LLDB_INVALID_REGNUM, dwarf_d18, LLDB_INVALID_REGNUM, 61, 61 }}, - { "d19", NULL, 8, 0, eEncodingIEEE754, eFormatHex, { LLDB_INVALID_REGNUM, dwarf_d19, LLDB_INVALID_REGNUM, 62, 62 }}, - { "d20", NULL, 8, 0, eEncodingIEEE754, eFormatHex, { LLDB_INVALID_REGNUM, dwarf_d20, LLDB_INVALID_REGNUM, 63, 63 }}, - { "d21", NULL, 8, 0, eEncodingIEEE754, eFormatHex, { LLDB_INVALID_REGNUM, dwarf_d21, LLDB_INVALID_REGNUM, 64, 64 }}, - { "d22", NULL, 8, 0, eEncodingIEEE754, eFormatHex, { LLDB_INVALID_REGNUM, dwarf_d22, LLDB_INVALID_REGNUM, 65, 65 }}, - { "d23", NULL, 8, 0, eEncodingIEEE754, eFormatHex, { LLDB_INVALID_REGNUM, dwarf_d23, LLDB_INVALID_REGNUM, 66, 66 }}, - { "d24", NULL, 8, 0, eEncodingIEEE754, eFormatHex, { LLDB_INVALID_REGNUM, dwarf_d24, LLDB_INVALID_REGNUM, 67, 67 }}, - { "d25", NULL, 8, 0, eEncodingIEEE754, eFormatHex, { LLDB_INVALID_REGNUM, dwarf_d25, LLDB_INVALID_REGNUM, 68, 68 }}, - { "d26", NULL, 8, 0, eEncodingIEEE754, eFormatHex, { LLDB_INVALID_REGNUM, dwarf_d26, LLDB_INVALID_REGNUM, 69, 69 }}, - { "d27", NULL, 8, 0, eEncodingIEEE754, eFormatHex, { LLDB_INVALID_REGNUM, dwarf_d27, LLDB_INVALID_REGNUM, 70, 70 }}, - { "d28", NULL, 8, 0, eEncodingIEEE754, eFormatHex, { LLDB_INVALID_REGNUM, dwarf_d28, LLDB_INVALID_REGNUM, 71, 71 }}, - { "d29", NULL, 8, 0, eEncodingIEEE754, eFormatHex, { LLDB_INVALID_REGNUM, dwarf_d29, LLDB_INVALID_REGNUM, 72, 72 }}, - { "d30", NULL, 8, 0, eEncodingIEEE754, eFormatHex, { LLDB_INVALID_REGNUM, dwarf_d30, LLDB_INVALID_REGNUM, 73, 73 }}, - { "d31", NULL, 8, 0, eEncodingIEEE754, eFormatHex, { LLDB_INVALID_REGNUM, dwarf_d31, LLDB_INVALID_REGNUM, 74, 74 }}, + { "d16", NULL, 8, 0, eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d16, LLDB_INVALID_REGNUM, 59, 59 }}, + { "d17", NULL, 8, 0, eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d17, LLDB_INVALID_REGNUM, 60, 60 }}, + { "d18", NULL, 8, 0, eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d18, LLDB_INVALID_REGNUM, 61, 61 }}, + { "d19", NULL, 8, 0, eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d19, LLDB_INVALID_REGNUM, 62, 62 }}, + { "d20", NULL, 8, 0, eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d20, LLDB_INVALID_REGNUM, 63, 63 }}, + { "d21", NULL, 8, 0, eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d21, LLDB_INVALID_REGNUM, 64, 64 }}, + { "d22", NULL, 8, 0, eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d22, LLDB_INVALID_REGNUM, 65, 65 }}, + { "d23", NULL, 8, 0, eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d23, LLDB_INVALID_REGNUM, 66, 66 }}, + { "d24", NULL, 8, 0, eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d24, LLDB_INVALID_REGNUM, 67, 67 }}, + { "d25", NULL, 8, 0, eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d25, LLDB_INVALID_REGNUM, 68, 68 }}, + { "d26", NULL, 8, 0, eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d26, LLDB_INVALID_REGNUM, 69, 69 }}, + { "d27", NULL, 8, 0, eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d27, LLDB_INVALID_REGNUM, 70, 70 }}, + { "d28", NULL, 8, 0, eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d28, LLDB_INVALID_REGNUM, 71, 71 }}, + { "d29", NULL, 8, 0, eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d29, LLDB_INVALID_REGNUM, 72, 72 }}, + { "d30", NULL, 8, 0, eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d30, LLDB_INVALID_REGNUM, 73, 73 }}, + { "d31", NULL, 8, 0, eEncodingIEEE754, eFormatFloat, { LLDB_INVALID_REGNUM, dwarf_d31, LLDB_INVALID_REGNUM, 74, 74 }}, }; static const uint32_t num_registers = sizeof (g_register_infos)/sizeof (RegisterInfo); Modified: lldb/trunk/source/Target/ThreadPlanTracer.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/ThreadPlanTracer.cpp?rev=131517&r1=131516&r2=131517&view=diff ============================================================================== --- lldb/trunk/source/Target/ThreadPlanTracer.cpp (original) +++ lldb/trunk/source/Target/ThreadPlanTracer.cpp Tue May 17 20:58:14 2011 @@ -137,21 +137,13 @@ RegisterContext *reg_ctx = m_thread.GetRegisterContext().get(); if (m_register_values.size() == 0) - { - for (uint32_t reg_index = 0, num_registers = reg_ctx->GetRegisterCount(); - reg_index < num_registers; - ++reg_index) - m_register_values.push_back(0); - } + m_register_values.resize (reg_ctx->GetRegisterCount()); } void ThreadPlanAssemblyTracer::TracingEnded () { - for (uint32_t reg_index = 0, num_registers = m_register_values.size(); - reg_index < num_registers; - ++reg_index) - m_register_values[reg_index] = 0; + m_register_values.clear(); } static void @@ -178,17 +170,10 @@ lldb::addr_t pc = reg_ctx->GetPC(); Address pc_addr; bool addr_valid = false; - - StreamString desc; - - int desired_width = 0; - + addr_valid = m_process.GetTarget().GetSectionLoadList().ResolveLoadAddress (pc, pc_addr); - pc_addr.Dump(&desc, &m_thread, Address::DumpStyleResolvedDescription, Address::DumpStyleModuleWithFileAddress); - - desired_width += 64; - PadOutTo(desc, desired_width); + pc_addr.Dump(stream, &m_thread, Address::DumpStyleResolvedDescription, Address::DumpStyleModuleWithFileAddress); if (m_disassembler) { @@ -213,18 +198,17 @@ if (instruction_list.GetSize()) { + const bool show_bytes = true; + const bool show_address = true; Instruction *instruction = instruction_list.GetInstructionAtIndex(0).get(); - instruction->Dump (&desc, + instruction->Dump (stream, max_opcode_byte_size, - false, - false, + show_address, + show_bytes, NULL, true); } } - - desired_width += 32; - PadOutTo(desc, desired_width); } if (m_abi && m_intptr_type.GetOpaqueQualType()) @@ -244,30 +228,35 @@ { for (int arg_index = 0; arg_index < num_args; ++arg_index) { - desc.Printf("arg[%d]=%llx", arg_index, value_list.GetValueAtIndex(arg_index)->GetScalar().ULongLong()); + stream->Printf("\n\targ[%d]=%llx", arg_index, value_list.GetValueAtIndex(arg_index)->GetScalar().ULongLong()); if (arg_index + 1 < num_args) - desc.Printf(", "); + stream->PutCString (", "); } } } - desired_width += 20; - PadOutTo(desc, desired_width); - for (uint32_t reg_index = 0, num_registers = reg_ctx->GetRegisterCount(); - reg_index < num_registers; - ++reg_index) + RegisterValue reg_value; + for (uint32_t reg_num = 0, num_registers = reg_ctx->GetRegisterCount(); + reg_num < num_registers; + ++reg_num) { - uint64_t reg_value = reg_ctx->ReadRegisterAsUnsigned(reg_index, 0x0); - - if (reg_value != m_register_values[reg_index]) + const RegisterInfo *reg_info = reg_ctx->GetRegisterInfoAtIndex(reg_num); + if (reg_ctx->ReadRegister (reg_info, reg_value)) { - desc.Printf ("%s:0x%llx->0x%llx ", reg_ctx->GetRegisterName(reg_index), m_register_values[reg_index], reg_value); - - m_register_values[reg_index] = reg_value; + assert (reg_num < m_register_values.size()); + if (m_register_values[reg_num].GetType() == RegisterValue::eTypeInvalid || + reg_value != m_register_values[reg_num]) + { + if (reg_value.GetType() != RegisterValue::eTypeInvalid) + { + stream->PutCString ("\n\t"); + reg_value.Dump(stream, reg_info, true, false, eFormatDefault); + } + } + m_register_values[reg_num] = reg_value; } } - - stream->Printf ("Single-step: %s\n", desc.GetString().c_str()); + stream->EOL(); } From jingham at apple.com Wed May 18 00:02:10 2011 From: jingham at apple.com (Jim Ingham) Date: Wed, 18 May 2011 05:02:10 -0000 Subject: [Lldb-commits] [lldb] r131526 - /lldb/trunk/source/Core/Module.cpp Message-ID: <20110518050210.ECAB72A6C12C@llvm.org> Author: jingham Date: Wed May 18 00:02:10 2011 New Revision: 131526 URL: http://llvm.org/viewvc/llvm-project?rev=131526&view=rev Log: FindFunctions was skipping the include_symbols section if it found a SymbolVendor. Modified: lldb/trunk/source/Core/Module.cpp Modified: lldb/trunk/source/Core/Module.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/Module.cpp?rev=131526&r1=131525&r2=131526&view=diff ============================================================================== --- lldb/trunk/source/Core/Module.cpp (original) +++ lldb/trunk/source/Core/Module.cpp Wed May 18 00:02:10 2011 @@ -380,7 +380,7 @@ SymbolVendor *symbols = GetSymbolVendor (); if (symbols) - return symbols->FindFunctions(regex, append, sc_list); + symbols->FindFunctions(regex, append, sc_list); // Now check our symbol table for symbols that are code symbols if requested if (include_symbols) { From jingham at apple.com Wed May 18 00:04:36 2011 From: jingham at apple.com (Jim Ingham) Date: Wed, 18 May 2011 05:04:36 -0000 Subject: [Lldb-commits] [lldb] r131527 - /lldb/trunk/source/Commands/CommandCompletions.cpp Message-ID: <20110518050436.EE6F42A6C12C@llvm.org> Author: jingham Date: Wed May 18 00:04:36 2011 New Revision: 131527 URL: http://llvm.org/viewvc/llvm-project?rev=131527&view=rev Log: Symbol may not have a demangled name, use GetName to get the best name available in this case. Modified: lldb/trunk/source/Commands/CommandCompletions.cpp Modified: lldb/trunk/source/Commands/CommandCompletions.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandCompletions.cpp?rev=131527&r1=131526&r2=131527&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandCompletions.cpp (original) +++ lldb/trunk/source/Commands/CommandCompletions.cpp Wed May 18 00:04:36 2011 @@ -633,7 +633,7 @@ } else if (sc.symbol && sc.symbol->GetAddressRangePtr()) { - m_match_set.insert (sc.symbol->GetMangled().GetDemangledName()); + m_match_set.insert (sc.symbol->GetMangled().GetName()); } } } From johnny.chen at apple.com Wed May 18 13:22:16 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Wed, 18 May 2011 18:22:16 -0000 Subject: [Lldb-commits] [lldb] r131549 - /lldb/trunk/source/Plugins/Disassembler/llvm/DisassemblerLLVM.cpp Message-ID: <20110518182216.78AFA2A6C12C@llvm.org> Author: johnny Date: Wed May 18 13:22:16 2011 New Revision: 131549 URL: http://llvm.org/viewvc/llvm-project?rev=131549&view=rev Log: If the use_thumb is set, pass llvm::Triple::thumb to the InstructionLLVM.ctor() unconditionally. Otherwise, pass m_arch.GetMachine(). Followup patch for rdar://problem/9170971. Modified: lldb/trunk/source/Plugins/Disassembler/llvm/DisassemblerLLVM.cpp Modified: lldb/trunk/source/Plugins/Disassembler/llvm/DisassemblerLLVM.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Disassembler/llvm/DisassemblerLLVM.cpp?rev=131549&r1=131548&r2=131549&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Disassembler/llvm/DisassemblerLLVM.cpp (original) +++ lldb/trunk/source/Plugins/Disassembler/llvm/DisassemblerLLVM.cpp Wed May 18 13:22:16 2011 @@ -506,7 +506,7 @@ InstructionSP inst_sp (new InstructionLLVM (inst_addr, inst_address_class, use_thumb ? m_disassembler_thumb : m_disassembler, - m_arch.GetMachine())); + use_thumb ? llvm::Triple::thumb : m_arch.GetMachine())); size_t inst_byte_size = inst_sp->Decode (*this, data, data_offset); From gclayton at apple.com Wed May 18 13:22:47 2011 From: gclayton at apple.com (Greg Clayton) Date: Wed, 18 May 2011 18:22:47 -0000 Subject: [Lldb-commits] [lldb] r131550 - /lldb/trunk/source/Target/SectionLoadList.cpp Message-ID: <20110518182247.C14EC2A6C12C@llvm.org> Author: gclayton Date: Wed May 18 13:22:47 2011 New Revision: 131550 URL: http://llvm.org/viewvc/llvm-project?rev=131550&view=rev Log: One more fix to: bool SectionLoadList::ResolveLoadAddress (addr_t load_addr, Address &so_addr) const; Where if the address is in the last map entry, we need to look it up correctly. My previous fix was incorrect where it looked in the first if there were no addresses in the map that were > load_addr. Now we correctly look in the last entry if our std::map::lower_bound search returns the end of the collection. Modified: lldb/trunk/source/Target/SectionLoadList.cpp Modified: lldb/trunk/source/Target/SectionLoadList.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/SectionLoadList.cpp?rev=131550&r1=131549&r2=131550&view=diff ============================================================================== --- lldb/trunk/source/Target/SectionLoadList.cpp (original) +++ lldb/trunk/source/Target/SectionLoadList.cpp Wed May 18 13:22:47 2011 @@ -194,15 +194,17 @@ } else { - pos = m_addr_to_sect.begin(); - if (load_addr >= pos->first) + // There are no entries that have an address that is >= load_addr, + // so we need to check the last entry on our collection. + addr_to_sect_collection::const_reverse_iterator rpos = m_addr_to_sect.rbegin(); + if (load_addr >= rpos->first) { - addr_t offset = load_addr - pos->first; - if (offset < pos->second->GetByteSize()) + addr_t offset = load_addr - rpos->first; + if (offset < rpos->second->GetByteSize()) { // We have found the top level section, now we need to find the // deepest child section. - return pos->second->ResolveContainedAddress (offset, so_addr); + return rpos->second->ResolveContainedAddress (offset, so_addr); } } } From gclayton at apple.com Wed May 18 17:01:49 2011 From: gclayton at apple.com (Greg Clayton) Date: Wed, 18 May 2011 22:01:49 -0000 Subject: [Lldb-commits] [lldb] r131588 - in /lldb/trunk: include/lldb/Core/Address.h source/Core/Address.cpp source/Expression/ClangExpressionDeclMap.cpp source/Plugins/ABI/MacOSX-arm/ABIMacOSX_arm.cpp Message-ID: <20110518220149.86C622A6C12C@llvm.org> Author: gclayton Date: Wed May 18 17:01:49 2011 New Revision: 131588 URL: http://llvm.org/viewvc/llvm-project?rev=131588&view=rev Log: Added a function to lldb_private::Address: addr_t Address::GetCallableLoadAddress (Target *target) const; This will resolve the load address in the Address object and optionally decorate the address up to be able to be called. For all non ARM targets, this just essentially returns the result of "Address::GetLoadAddress (target)". But for ARM targets, it checks if the address is Thumb, and if so, it returns an address with bit zero set to indicate a mode switch to Thumb. This is how we need function pointers to be for return addresses and when resolving function addresses for the JIT. It is also nice to centralize this in one spot to avoid having multiple copies of this code. Modified: lldb/trunk/include/lldb/Core/Address.h lldb/trunk/source/Core/Address.cpp lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp lldb/trunk/source/Plugins/ABI/MacOSX-arm/ABIMacOSX_arm.cpp Modified: lldb/trunk/include/lldb/Core/Address.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/Address.h?rev=131588&r1=131587&r2=131588&view=diff ============================================================================== --- lldb/trunk/include/lldb/Core/Address.h (original) +++ lldb/trunk/include/lldb/Core/Address.h Wed May 18 17:01:49 2011 @@ -280,6 +280,23 @@ //------------------------------------------------------------------ lldb::addr_t GetLoadAddress (Target *target) const; + + //------------------------------------------------------------------ + /// Get the load address as a callable code load address. + /// + /// This function will first resolve its address to a load address. + /// Then, if the address turns out to be in code address, return the + /// load address that would be required to call or return to. The + /// address might have extra bits set (bit zero will be set to Thumb + /// functions for an ARM target) that are required when changing the + /// program counter to setting a return address. + /// + /// @return + /// The valid load virtual address, or LLDB_INVALID_ADDRESS if + /// the address is currently not loaded. + //------------------------------------------------------------------ + lldb::addr_t + GetCallableLoadAddress (Target *target) const; //------------------------------------------------------------------ /// Get the section relative offset value. Modified: lldb/trunk/source/Core/Address.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/Address.cpp?rev=131588&r1=131587&r2=131588&view=diff ============================================================================== --- lldb/trunk/source/Core/Address.cpp (original) +++ lldb/trunk/source/Core/Address.cpp Wed May 18 17:01:49 2011 @@ -15,6 +15,8 @@ #include "lldb/Target/Process.h" #include "lldb/Target/Target.h" +#include "llvm/ADT/Triple.h" + using namespace lldb; using namespace lldb_private; @@ -294,6 +296,42 @@ return LLDB_INVALID_ADDRESS; } +addr_t +Address::GetCallableLoadAddress (Target *target) const +{ + addr_t code_addr = GetLoadAddress (target); + + if (m_section && code_addr != LLDB_INVALID_ADDRESS) + { + switch (target->GetArchitecture().GetMachine()) + { + case llvm::Triple::arm: + case llvm::Triple::thumb: + // Check if bit zero it no set? + if ((code_addr & 1ull) == 0) + { + // Bit zero isn't set, check if the address is a multiple of 2? + if (code_addr & 2ull) + { + // The address is a multiple of 2 so it must be thumb, set bit zero + code_addr |= 1ull; + } + else if (GetAddressClass() == eAddressClassCodeAlternateISA) + { + // We checked the address and the address claims to be the alternate ISA + // which means thumb, so set bit zero. + code_addr |= 1ull; + } + } + break; + + default: + break; + } + } + return code_addr; +} + bool Address::Dump (Stream *s, ExecutionContextScope *exe_scope, DumpStyle style, DumpStyle fallback_style, uint32_t addr_size) const { Modified: lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp?rev=131588&r1=131587&r2=131588&view=diff ============================================================================== --- lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp (original) +++ lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp Wed May 18 17:01:49 2011 @@ -495,7 +495,7 @@ ClangExpressionDeclMap::GetFunctionAddress ( const ConstString &name, - uint64_t &ptr + uint64_t &func_addr ) { assert (m_parser_vars.get()); @@ -543,17 +543,17 @@ SymbolContext sym_ctx; sc_list.GetContextAtIndex(0, sym_ctx); - const Address *fun_address; + const Address *func_so_addr = NULL; if (sym_ctx.function) - fun_address = &sym_ctx.function->GetAddressRange().GetBaseAddress(); + func_so_addr = &sym_ctx.function->GetAddressRange().GetBaseAddress(); else if (sym_ctx.symbol) - fun_address = &sym_ctx.symbol->GetAddressRangeRef().GetBaseAddress(); + func_so_addr = &sym_ctx.symbol->GetAddressRangeRef().GetBaseAddress(); else return false; - ptr = fun_address->GetLoadAddress (m_parser_vars->m_exe_ctx->target); - + func_addr = func_so_addr->GetCallableLoadAddress (m_parser_vars->m_exe_ctx->target); + return true; } @@ -577,7 +577,7 @@ const Address *sym_address = &sym_ctx.symbol->GetAddressRangeRef().GetBaseAddress(); - ptr = sym_address->GetLoadAddress(&target); + ptr = sym_address->GetCallableLoadAddress(&target); return true; } @@ -2294,9 +2294,9 @@ } void -ClangExpressionDeclMap::AddOneFunction(NameSearchContext &context, - Function* fun, - Symbol* symbol) +ClangExpressionDeclMap::AddOneFunction (NameSearchContext &context, + Function* fun, + Symbol* symbol) { assert (m_parser_vars.get()); @@ -2350,7 +2350,7 @@ return; } - lldb::addr_t load_addr = fun_address->GetLoadAddress(m_parser_vars->m_exe_ctx->target); + lldb::addr_t load_addr = fun_address->GetCallableLoadAddress(m_parser_vars->m_exe_ctx->target); fun_location->SetValueType(Value::eValueTypeLoadAddress); fun_location->GetScalar() = load_addr; 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=131588&r1=131587&r2=131588&view=diff ============================================================================== --- lldb/trunk/source/Plugins/ABI/MacOSX-arm/ABIMacOSX_arm.cpp (original) +++ lldb/trunk/source/Plugins/ABI/MacOSX-arm/ABIMacOSX_arm.cpp Wed May 18 17:01:49 2011 @@ -126,24 +126,16 @@ } } - // Figure out if our return address is ARM or Thumb. We assume if we don't - // know about an address then it is ARM code. Target *target = &thread.GetProcess().GetTarget(); Address so_addr; - bool ra_is_thumb = false; - if (return_addr & 3) - ra_is_thumb = true; - else if (so_addr.SetLoadAddress (return_addr, target)) - ra_is_thumb = so_addr.GetAddressClass() == eAddressClassCodeAlternateISA; - - // Set our clear bit zero for the return address if needed. We should never - // need to clear bit zero since the return address will either have bit zero - // or bit one (a thumb instruction on a two byte boundary) already set, or - // it won't and it will need it. - if (ra_is_thumb) - return_addr |= 1u; - + + // Figure out if our return address is ARM or Thumb by using the + // Address::GetCallableLoadAddress(Target*) which will figure out the ARM + // thumb-ness and set the correct address bits for us. + so_addr.SetLoadAddress (return_addr, target); + return_addr = so_addr.GetCallableLoadAddress (target); + // Set "lr" to the return address if (!reg_ctx->WriteRegisterFromUnsigned (ra_reg_num, return_addr)) return false; @@ -152,15 +144,10 @@ if (!reg_ctx->WriteRegisterFromUnsigned (sp_reg_num, sp)) return false; - bool pc_is_thumb = false; - // If bit zero or 1 is set, this must be a thumb function, no need to figure // this out from the symbols. - if (function_addr & 3) - pc_is_thumb = true; - else if (so_addr.SetLoadAddress (function_addr, target)) - pc_is_thumb = so_addr.GetAddressClass() == eAddressClassCodeAlternateISA; - + so_addr.SetLoadAddress (function_addr, target); + function_addr = so_addr.GetCallableLoadAddress (target); const RegisterInfo *cpsr_reg_info = reg_ctx->GetRegisterInfoByName("cpsr"); const uint32_t curr_cpsr = reg_ctx->ReadRegisterAsUnsigned(cpsr_reg_info, 0); @@ -168,7 +155,7 @@ // Make a new CPSR and mask out any Thumb IT (if/then) bits uint32_t new_cpsr = curr_cpsr & ~MASK_CPSR_IT_MASK; // If bit zero or 1 is set, this must be thumb... - if (pc_is_thumb) + if (function_addr & 1ull) new_cpsr |= MASK_CPSR_T; // Set T bit in CPSR else new_cpsr &= ~MASK_CPSR_T; // Clear T bit in CPSR @@ -179,7 +166,7 @@ return false; } - function_addr &= ~1u; // clear bit zero since the CPSR will take care of the mode for us + function_addr &= ~1ull; // clear bit zero since the CPSR will take care of the mode for us // Set "pc" to the address requested if (!reg_ctx->WriteRegisterFromUnsigned (pc_reg_num, function_addr)) From johnny.chen at apple.com Wed May 18 17:08:52 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Wed, 18 May 2011 22:08:52 -0000 Subject: [Lldb-commits] [lldb] r131589 - /lldb/trunk/source/Plugins/Disassembler/llvm/DisassemblerLLVM.cpp Message-ID: <20110518220852.DFEA02A6C12C@llvm.org> Author: johnny Date: Wed May 18 17:08:52 2011 New Revision: 131589 URL: http://llvm.org/viewvc/llvm-project?rev=131589&view=rev Log: Remove dead code which tests for boolan flag 'raw' and restore one indentation level. Modified: lldb/trunk/source/Plugins/Disassembler/llvm/DisassemblerLLVM.cpp Modified: lldb/trunk/source/Plugins/Disassembler/llvm/DisassemblerLLVM.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Disassembler/llvm/DisassemblerLLVM.cpp?rev=131589&r1=131588&r2=131589&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Disassembler/llvm/DisassemblerLLVM.cpp (original) +++ lldb/trunk/source/Plugins/Disassembler/llvm/DisassemblerLLVM.cpp Wed May 18 17:08:52 2011 @@ -241,64 +241,56 @@ if (EDGetToken(&token, m_inst, tokenIndex)) return; - if (raw) - { - show_token = true; - } - else - { - int operandIndex = EDOperandIndexForToken(token); + int operandIndex = EDOperandIndexForToken(token); - if (operandIndex >= 0) + if (operandIndex >= 0) + { + if (operandIndex != currentOpIndex) { - if (operandIndex != currentOpIndex) - { - show_token = true; + show_token = true; - currentOpIndex = operandIndex; - EDOperandRef operand; + currentOpIndex = operandIndex; + EDOperandRef operand; - if (!EDGetOperand(&operand, m_inst, currentOpIndex)) + if (!EDGetOperand(&operand, m_inst, currentOpIndex)) + { + if (EDOperandIsMemory(operand)) { - if (EDOperandIsMemory(operand)) - { - uint64_t operand_value; + uint64_t operand_value; - if (!EDEvaluateOperand(&operand_value, operand, IPRegisterReader, &rra)) + if (!EDEvaluateOperand(&operand_value, operand, IPRegisterReader, &rra)) + { + if (EDInstIsBranch(m_inst)) { - if (EDInstIsBranch(m_inst)) - { - operands.Printf("0x%llx ", operand_value); - show_token = false; - } - else - { - // Put the address value into the comment - comment.Printf("0x%llx ", operand_value); - } + operands.Printf("0x%llx ", operand_value); + show_token = false; + } + else + { + // Put the address value into the comment + comment.Printf("0x%llx ", operand_value); + } - lldb_private::Address so_addr; - if (exe_ctx && exe_ctx->target && !exe_ctx->target->GetSectionLoadList().IsEmpty()) + lldb_private::Address so_addr; + if (exe_ctx && exe_ctx->target && !exe_ctx->target->GetSectionLoadList().IsEmpty()) + { + if (exe_ctx->target->GetSectionLoadList().ResolveLoadAddress (operand_value, so_addr)) + so_addr.Dump(&comment, exe_scope, Address::DumpStyleResolvedDescriptionNoModule, Address::DumpStyleSectionNameOffset); + } + else + { + Module *module = GetAddress().GetModule(); + if (module) { - if (exe_ctx->target->GetSectionLoadList().ResolveLoadAddress (operand_value, so_addr)) + if (module->ResolveFileAddress (operand_value, so_addr)) so_addr.Dump(&comment, exe_scope, Address::DumpStyleResolvedDescriptionNoModule, Address::DumpStyleSectionNameOffset); } - else - { - Module *module = GetAddress().GetModule(); - if (module) - { - if (module->ResolveFileAddress (operand_value, so_addr)) - so_addr.Dump(&comment, exe_scope, Address::DumpStyleResolvedDescriptionNoModule, Address::DumpStyleSectionNameOffset); - } - } - - } // EDEvaluateOperand - } // EDOperandIsMemory - } // EDGetOperand - } // operandIndex != currentOpIndex - } // operandIndex >= 0 - } // else(raw) + } + } // EDEvaluateOperand + } // EDOperandIsMemory + } // EDGetOperand + } // operandIndex != currentOpIndex + } // operandIndex >= 0 if (show_token) { From johnny.chen at apple.com Wed May 18 17:48:41 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Wed, 18 May 2011 22:48:41 -0000 Subject: [Lldb-commits] [lldb] r131594 - /lldb/trunk/source/Plugins/Disassembler/llvm/DisassemblerLLVM.cpp Message-ID: <20110518224841.41E842A6C12C@llvm.org> Author: johnny Date: Wed May 18 17:48:41 2011 New Revision: 131594 URL: http://llvm.org/viewvc/llvm-project?rev=131594&view=rev Log: Some refactorings with respect to setting of the 'printTokenized' flag. Add some comments. Modified: lldb/trunk/source/Plugins/Disassembler/llvm/DisassemblerLLVM.cpp Modified: lldb/trunk/source/Plugins/Disassembler/llvm/DisassemblerLLVM.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Disassembler/llvm/DisassemblerLLVM.cpp?rev=131594&r1=131593&r2=131594&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Disassembler/llvm/DisassemblerLLVM.cpp (original) +++ lldb/trunk/source/Plugins/Disassembler/llvm/DisassemblerLLVM.cpp Wed May 18 17:48:41 2011 @@ -200,35 +200,31 @@ EDTokenRef token; const char *tokenStr; - if (EDGetToken(&token, m_inst, tokenIndex)) + if (EDGetToken(&token, m_inst, tokenIndex)) // 0 on success printTokenized = false; - - if (!printTokenized || !EDTokenIsOpcode(token)) + else if (!EDTokenIsOpcode(token)) printTokenized = false; - - if (!printTokenized || EDGetTokenString(&tokenStr, token)) + else if (EDGetTokenString(&tokenStr, token)) // 0 on success printTokenized = false; - // Put the token string into our opcode string - opcode.PutCString(tokenStr); - - // If anything follows, it probably starts with some whitespace. Skip it. - - tokenIndex++; - - if (printTokenized && tokenIndex < numTokens) + if (printTokenized) { - if(!printTokenized || EDGetToken(&token, m_inst, tokenIndex)) - printTokenized = false; + // Put the token string into our opcode string + opcode.PutCString(tokenStr); - if(!printTokenized || !EDTokenIsWhitespace(token)) - printTokenized = false; - } + // If anything follows, it probably starts with some whitespace. Skip it. + if (++tokenIndex < numTokens) + { + if (EDGetToken(&token, m_inst, tokenIndex)) // 0 on success + printTokenized = false; + else if (!EDTokenIsWhitespace(token)) + printTokenized = false; + } - tokenIndex++; + ++tokenIndex; + } // Handle the operands and the comment. - StreamString operands; StreamString comment; From gclayton at apple.com Wed May 18 19:17:27 2011 From: gclayton at apple.com (Greg Clayton) Date: Thu, 19 May 2011 00:17:27 -0000 Subject: [Lldb-commits] [lldb] r131610 - in /lldb/trunk: include/lldb/Core/RegisterValue.h include/lldb/Core/Scalar.h source/Core/ConnectionFileDescriptor.cpp source/Core/Scalar.cpp source/Plugins/ABI/MacOSX-arm/ABIMacOSX_arm.cpp Message-ID: <20110519001727.377842A6C12C@llvm.org> Author: gclayton Date: Wed May 18 19:17:26 2011 New Revision: 131610 URL: http://llvm.org/viewvc/llvm-project?rev=131610&view=rev Log: Added the ability to sign extend a Scalar at any bit position for integer types. Added the abilty to set a RegisterValue type via accessor and enum. Added the ability to read arguments for a function for ARM if you are on the first instruction in ABIMacOSX_arm. Fixed an issue where a file descriptor becoming invalid could cause an inifnite loop spin in the libedit thread. Modified: lldb/trunk/include/lldb/Core/RegisterValue.h lldb/trunk/include/lldb/Core/Scalar.h lldb/trunk/source/Core/ConnectionFileDescriptor.cpp lldb/trunk/source/Core/Scalar.cpp lldb/trunk/source/Plugins/ABI/MacOSX-arm/ABIMacOSX_arm.cpp Modified: lldb/trunk/include/lldb/Core/RegisterValue.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/RegisterValue.h?rev=131610&r1=131609&r2=131610&view=diff ============================================================================== --- lldb/trunk/include/lldb/Core/RegisterValue.h (original) +++ lldb/trunk/include/lldb/Core/RegisterValue.h Wed May 18 19:17:26 2011 @@ -123,6 +123,12 @@ bool CopyValue (const RegisterValue &rhs); + void + SetType (RegisterValue::Type type) + { + m_type = type; + } + RegisterValue::Type SetType (const RegisterInfo *reg_info); Modified: lldb/trunk/include/lldb/Core/Scalar.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/Scalar.h?rev=131610&r1=131609&r2=131610&view=diff ============================================================================== --- lldb/trunk/include/lldb/Core/Scalar.h (original) +++ lldb/trunk/include/lldb/Core/Scalar.h Wed May 18 19:17:26 2011 @@ -54,6 +54,9 @@ //Scalar(const RegisterValue& reg_value); virtual ~Scalar(); + bool + SignExtend (uint32_t bit_pos); + size_t GetByteSize() const; Modified: lldb/trunk/source/Core/ConnectionFileDescriptor.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/ConnectionFileDescriptor.cpp?rev=131610&r1=131609&r2=131610&view=diff ============================================================================== --- lldb/trunk/source/Core/ConnectionFileDescriptor.cpp (original) +++ lldb/trunk/source/Core/ConnectionFileDescriptor.cpp Wed May 18 19:17:26 2011 @@ -229,7 +229,6 @@ status = eConnectionStatusSuccess; return 0; - case EBADF: // fildes is not a valid file or socket descriptor open for reading. case EFAULT: // Buf points outside the allocated address space. case EINTR: // A read from a slow device was interrupted before any data arrived by the delivery of a signal. case EINVAL: // The pointer associated with fildes was negative. @@ -246,6 +245,7 @@ status = eConnectionStatusError; break; // Break to close.... + case EBADF: // fildes is not a valid file or socket descriptor open for reading. case ENXIO: // An action is requested of a device that does not exist.. // A requested action cannot be performed by the device. case ECONNRESET:// The connection is closed by the peer during a read attempt on a socket. @@ -391,6 +391,8 @@ switch (error.GetError()) { case EBADF: // One of the descriptor sets specified an invalid descriptor. + return eConnectionStatusLostConnection; + case EINVAL: // The specified time limit is invalid. One of its components is negative or too large. default: // Other unknown error return eConnectionStatusError; Modified: lldb/trunk/source/Core/Scalar.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/Scalar.cpp?rev=131610&r1=131609&r2=131610&view=diff ============================================================================== --- lldb/trunk/source/Core/Scalar.cpp (original) +++ lldb/trunk/source/Core/Scalar.cpp Wed May 18 19:17:26 2011 @@ -1922,6 +1922,74 @@ } bool +Scalar::SignExtend (uint32_t sign_bit_pos) +{ + const uint32_t max_bit_pos = GetByteSize() * 8; + + if (sign_bit_pos < max_bit_pos) + { + switch (m_type) + { + default: + case Scalar::e_void: + case Scalar::e_float: + case Scalar::e_double: + case Scalar::e_long_double: + return false; + + case Scalar::e_sint: + case Scalar::e_uint: + if (max_bit_pos == sign_bit_pos) + return true; + else if (sign_bit_pos < (max_bit_pos-1)) + { + unsigned int sign_bit = 1u << sign_bit_pos; + if (m_data.uint & sign_bit) + { + const unsigned int mask = ~(sign_bit) + 1u; + m_data.uint |= mask; + } + return true; + } + break; + + case Scalar::e_slong: + case Scalar::e_ulong: + if (max_bit_pos == sign_bit_pos) + return true; + else if (sign_bit_pos < (max_bit_pos-1)) + { + unsigned long sign_bit = 1ul << sign_bit_pos; + if (m_data.uint & sign_bit) + { + const unsigned long mask = ~(sign_bit) + 1ul; + m_data.uint |= mask; + } + return true; + } + break; + + case Scalar::e_slonglong: + case Scalar::e_ulonglong: + if (max_bit_pos == sign_bit_pos) + return true; + else if (sign_bit_pos < (max_bit_pos-1)) + { + unsigned long long sign_bit = 1ull << sign_bit_pos; + if (m_data.uint & sign_bit) + { + const unsigned long long mask = ~(sign_bit) + 1ull; + m_data.uint |= mask; + } + return true; + } + break; + } + } + return false; +} + +bool lldb_private::operator== (const Scalar& lhs, const Scalar& rhs) { // If either entry is void then we can just compare the types 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=131610&r1=131609&r2=131610&view=diff ============================================================================== --- lldb/trunk/source/Plugins/ABI/MacOSX-arm/ABIMacOSX_arm.cpp (original) +++ lldb/trunk/source/Plugins/ABI/MacOSX-arm/ABIMacOSX_arm.cpp Wed May 18 19:17:26 2011 @@ -175,161 +175,118 @@ return true; } - -static bool -ReadIntegerArgument (Scalar &scalar, - unsigned int bit_width, - bool is_signed, - Process &process, - addr_t ¤t_stack_argument) -{ -// if (bit_width > 64) -// return false; // Scalar can't hold large integer arguments -// -// uint64_t arg_contents; -// uint32_t read_data; -// Error error; -// -// if (bit_width > 32) -// { -// if (process.ReadMemory(current_stack_argument, &read_data, sizeof(read_data), error) != sizeof(read_data)) -// return false; -// -// arg_contents = read_data; -// -// if (process.ReadMemory(current_stack_argument + 4, &read_data, sizeof(read_data), error) != sizeof(read_data)) -// return false; -// -// arg_contents |= ((uint64_t)read_data) << 32; -// -// current_stack_argument += 8; -// } -// else { -// if (process.ReadMemory(current_stack_argument, &read_data, sizeof(read_data), error) != sizeof(read_data)) -// return false; -// -// arg_contents = read_data; -// -// current_stack_argument += 4; -// } -// -// if (is_signed) -// { -// switch (bit_width) -// { -// default: -// return false; -// case 8: -// scalar = (int8_t)(arg_contents & 0xff); -// break; -// case 16: -// scalar = (int16_t)(arg_contents & 0xffff); -// break; -// case 32: -// scalar = (int32_t)(arg_contents & 0xffffffff); -// break; -// case 64: -// scalar = (int64_t)arg_contents; -// break; -// } -// } -// else -// { -// switch (bit_width) -// { -// default: -// return false; -// case 8: -// scalar = (uint8_t)(arg_contents & 0xff); -// break; -// case 16: -// scalar = (uint16_t)(arg_contents & 0xffff); -// break; -// case 32: -// scalar = (uint32_t)(arg_contents & 0xffffffff); -// break; -// case 64: -// scalar = (uint64_t)arg_contents; -// break; -// } -// } -// -// return true; - return false; -} - bool ABIMacOSX_arm::GetArgumentValues (Thread &thread, ValueList &values) const { -// unsigned int num_values = values.GetSize(); -// unsigned int value_index; -// -// // Extract the Clang AST context from the PC so that we can figure out type -// // sizes -// -// clang::ASTContext *ast_context = thread.CalculateTarget()->GetScratchClangASTContext()->getASTContext(); -// -// // Get the pointer to the first stack argument so we have a place to start -// // when reading data -// -// RegisterContext *reg_ctx = thread.GetRegisterContext().get(); -// -// if (!reg_ctx) -// return false; -// -// addr_t sp = reg_ctx->GetSP(0); -// -// if (!sp) -// return false; -// -// addr_t current_stack_argument = sp + 4; // jump over return address -// -// for (value_index = 0; -// value_index < num_values; -// ++value_index) -// { -// Value *value = values.GetValueAtIndex(value_index); -// -// if (!value) -// return false; -// -// // We currently only support extracting values with Clang QualTypes. -// // Do we care about others? -// switch (value->GetContextType()) -// { -// default: -// return false; -// case Value::eContextTypeClangType: -// { -// void *value_type = value->GetClangType(); -// bool is_signed; -// -// if (ClangASTContext::IsIntegerType (value_type, is_signed)) -// { -// size_t bit_width = ClangASTType::GetClangTypeBitWidth(ast_context, value_type); -// -// ReadIntegerArgument(value->GetScalar(), -// bit_width, -// is_signed, -// thread.GetProcess(), -// current_stack_argument); -// } -// else if (ClangASTContext::IsPointerType (value_type)) -// { -// ReadIntegerArgument(value->GetScalar(), -// 32, -// false, -// thread.GetProcess(), -// current_stack_argument); -// } -// } -// break; -// } -// } -// -// return true; - return false; + uint32_t num_values = values.GetSize(); + + + // For now, assume that the types in the AST values come from the Target's + // scratch AST. + + clang::ASTContext *ast_context = thread.CalculateTarget()->GetScratchClangASTContext()->getASTContext(); + + // Extract the register context so we can read arguments from registers + + RegisterContext *reg_ctx = thread.GetRegisterContext().get(); + + if (!reg_ctx) + return false; + + bool arg_regs_exceeded = false; + + addr_t sp = reg_ctx->GetSP(0); + + if (!sp) + return false; + + for (uint32_t value_idx = 0; value_idx < num_values; ++value_idx) + { + // We currently only support extracting values with Clang QualTypes. + // Do we care about others? + Value *value = values.GetValueAtIndex(value_idx); + + if (!value) + return false; + + void *value_type = value->GetClangType(); + if (value_type) + { + bool is_signed = false; + size_t bit_width = 0; + if (ClangASTContext::IsIntegerType (value_type, is_signed)) + { + bit_width = ClangASTType::GetClangTypeBitWidth(ast_context, value_type); + } + else if (ClangASTContext::IsPointerOrReferenceType (value_type)) + { + bit_width = ClangASTType::GetClangTypeBitWidth(ast_context, value_type); + } + else + { + // We only handle integer, pointer and reference types currently... + return false; + } + + if (bit_width <= (thread.GetProcess().GetAddressByteSize() * 8)) + { + if (!arg_regs_exceeded) + { + uint32_t arg_reg_num = reg_ctx->ConvertRegisterKindToRegisterNumber (eRegisterKindGeneric, LLDB_REGNUM_GENERIC_ARG1 + value_idx); + if (arg_reg_num == LLDB_INVALID_REGNUM) + { + arg_regs_exceeded = true; + } + else + { + const RegisterInfo *arg_reg_info = reg_ctx->GetRegisterInfoAtIndex(arg_reg_num); + RegisterValue reg_value; + + if (reg_ctx->ReadRegister(arg_reg_info, reg_value)) + { + if (is_signed) + reg_value.SignExtend(bit_width); + if (!reg_value.GetScalarValue(value->GetScalar())) + return false; + continue; + } + else + { + return false; + } + } + } + + + const uint32_t arg_byte_size = (bit_width + (8-1)) / 8; + if (arg_byte_size <= sizeof(uint64_t)) + { + uint8_t arg_data[sizeof(uint64_t)]; + Error error; + thread.GetProcess().ReadMemory(sp, arg_data, sizeof(arg_data), error); + DataExtractor arg_data_extractor (arg_data, sizeof(arg_data), + thread.GetProcess().GetTarget().GetArchitecture().GetByteOrder(), + thread.GetProcess().GetTarget().GetArchitecture().GetAddressByteSize()); + uint32_t offset = 0; + if (arg_byte_size <= 4) + value->GetScalar() = arg_data_extractor.GetMaxU32 (&offset, arg_byte_size); + else if (arg_byte_size <= 8) + value->GetScalar() = arg_data_extractor.GetMaxU64 (&offset, arg_byte_size); + else + return false; + + if (offset == 0 || offset == UINT32_MAX) + return false; + + if (is_signed) + value->GetScalar().SignExtend (bit_width); + sp += arg_byte_size; + } + } + } + } + return true; } bool From gclayton at apple.com Wed May 18 19:55:50 2011 From: gclayton at apple.com (Greg Clayton) Date: Thu, 19 May 2011 00:55:50 -0000 Subject: [Lldb-commits] [lldb] r131613 - /lldb/trunk/source/Core/Scalar.cpp Message-ID: <20110519005550.D7F792A6C12C@llvm.org> Author: gclayton Date: Wed May 18 19:55:50 2011 New Revision: 131613 URL: http://llvm.org/viewvc/llvm-project?rev=131613&view=rev Log: Fixed an issue with the sign extend code so it uses the correct m_data member. Modified: lldb/trunk/source/Core/Scalar.cpp Modified: lldb/trunk/source/Core/Scalar.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/Scalar.cpp?rev=131613&r1=131612&r2=131613&view=diff ============================================================================== --- lldb/trunk/source/Core/Scalar.cpp (original) +++ lldb/trunk/source/Core/Scalar.cpp Wed May 18 19:55:50 2011 @@ -1960,10 +1960,10 @@ else if (sign_bit_pos < (max_bit_pos-1)) { unsigned long sign_bit = 1ul << sign_bit_pos; - if (m_data.uint & sign_bit) + if (m_data.ulong & sign_bit) { const unsigned long mask = ~(sign_bit) + 1ul; - m_data.uint |= mask; + m_data.ulong |= mask; } return true; } @@ -1976,10 +1976,10 @@ else if (sign_bit_pos < (max_bit_pos-1)) { unsigned long long sign_bit = 1ull << sign_bit_pos; - if (m_data.uint & sign_bit) + if (m_data.ulonglong & sign_bit) { const unsigned long long mask = ~(sign_bit) + 1ull; - m_data.uint |= mask; + m_data.ulonglong |= mask; } return true; } From johnny.chen at apple.com Wed May 18 20:05:37 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Thu, 19 May 2011 01:05:37 -0000 Subject: [Lldb-commits] [lldb] r131615 - /lldb/trunk/source/Plugins/Disassembler/llvm/DisassemblerLLVM.cpp Message-ID: <20110519010537.7DA132A6C12C@llvm.org> Author: johnny Date: Wed May 18 20:05:37 2011 New Revision: 131615 URL: http://llvm.org/viewvc/llvm-project?rev=131615&view=rev Log: Make InstructionLLVM::Dump() more robust for edis in cases when all the EDOperandIndexForToken(token) calls fail to return a meaningful operand index, resulting in both operands and comment being empty. We will use the raw disassembly string as output in these cases. There is still a known bug where llvm:tB (A8.6.16 B Encoding T2) is not being processed as a branch instruction and therefore the symbolic information is not being dumped for non-raw mode. Modified: lldb/trunk/source/Plugins/Disassembler/llvm/DisassemblerLLVM.cpp Modified: lldb/trunk/source/Plugins/Disassembler/llvm/DisassemblerLLVM.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Disassembler/llvm/DisassemblerLLVM.cpp?rev=131615&r1=131614&r2=131615&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Disassembler/llvm/DisassemblerLLVM.cpp (original) +++ lldb/trunk/source/Plugins/Disassembler/llvm/DisassemblerLLVM.cpp Wed May 18 20:05:37 2011 @@ -99,6 +99,16 @@ s->Printf("%s ", str.c_str()); } +#include "llvm/ADT/StringRef.h" +static void +StripSpaces(llvm::StringRef &Str) +{ + while (!Str.empty() && isspace(Str[0])) + Str = Str.substr(1); + while (!Str.empty() && isspace(Str.back())) + Str = Str.substr(0, Str.size()-1); +} + void InstructionLLVM::Dump ( @@ -230,7 +240,7 @@ if (printTokenized) { - bool show_token; + bool show_token = false; for (; tokenIndex < numTokens; ++tokenIndex) { @@ -300,40 +310,42 @@ } } // for (tokenIndex) - if (printTokenized) + // If both operands and comment are empty, we will just print out + // the raw disassembly. + if (operands.GetString().empty() && comment.GetString().empty()) { - if (operands.GetString().empty()) - { - s->PutCString(opcode.GetString().c_str()); - } + const char *str; + + if (EDGetInstString(&str, m_inst)) + return; + llvm::StringRef raw_disasm(str); + StripSpaces(raw_disasm); + s->PutCString(raw_disasm.str().c_str()); + } + else + { + PadString(s, opcode.GetString(), opcodeColumnWidth); + + if (comment.GetString().empty()) + s->PutCString(operands.GetString().c_str()); else { - PadString(s, opcode.GetString(), opcodeColumnWidth); + PadString(s, operands.GetString(), operandColumnWidth); - if (comment.GetString().empty()) - { - s->PutCString(operands.GetString().c_str()); - } - else - { - PadString(s, operands.GetString(), operandColumnWidth); - - s->PutCString("; "); - s->PutCString(comment.GetString().c_str()); - } // else (comment.GetString().empty()) - } // else (operands.GetString().empty()) - } // printTokenized - } // for (tokenIndex) + s->PutCString("; "); + s->PutCString(comment.GetString().c_str()); + } // else (comment.GetString().empty()) + } // else (operands.GetString().empty() && comment.GetString().empty()) + } // printTokenized } // numTokens != -1 if (!printTokenized) { const char *str; - if (EDGetInstString(&str, m_inst)) + if (EDGetInstString(&str, m_inst)) // 0 on success return; - else - s->Write(str, strlen(str) - 1); + s->Write(str, strlen(str) - 1); } } From gclayton at apple.com Wed May 18 22:54:16 2011 From: gclayton at apple.com (Greg Clayton) Date: Thu, 19 May 2011 03:54:16 -0000 Subject: [Lldb-commits] [lldb] r131628 - in /lldb/trunk/source: Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp Target/Thread.cpp Target/ThreadPlanCallFunction.cpp Message-ID: <20110519035416.71C2D2A6C12C@llvm.org> Author: gclayton Date: Wed May 18 22:54:16 2011 New Revision: 131628 URL: http://llvm.org/viewvc/llvm-project?rev=131628&view=rev Log: Fixed a crasher that was happened when a log shared pointer wasn't valid. Fixed ThreadPlanCallFunction::ReportRegisterState(...) to only dump when verbose logging is enabled and fixed the function to use the new RegisterValue method of reading registers. Fixed the GDB remote client to not send a continue packet after receiving stdout or stderr from the inferior process. Modified: lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp lldb/trunk/source/Target/Thread.cpp lldb/trunk/source/Target/ThreadPlanCallFunction.cpp Modified: lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp?rev=131628&r1=131627&r2=131628&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp (original) +++ lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp Wed May 18 22:54:16 2011 @@ -361,14 +361,21 @@ // make change if we are interrupted and we continue after an async packet... std::string continue_packet(payload, packet_length); + bool got_stdout = false; + while (state == eStateRunning) { - if (log) - log->Printf ("GDBRemoteCommunicationClient::%s () sending continue packet: %s", __FUNCTION__, continue_packet.c_str()); - if (SendPacket(continue_packet.c_str(), continue_packet.size()) == 0) - state = eStateInvalid; + if (!got_stdout) + { + if (log) + log->Printf ("GDBRemoteCommunicationClient::%s () sending continue packet: %s", __FUNCTION__, continue_packet.c_str()); + if (SendPacket(continue_packet.c_str(), continue_packet.size()) == 0) + state = eStateInvalid; + + m_private_is_running.SetValue (true, eBroadcastNever); + } - m_private_is_running.SetValue (true, eBroadcastNever); + got_stdout = false; if (log) log->Printf ("GDBRemoteCommunicationClient::%s () WaitForPacket(%.*s)", __FUNCTION__); @@ -489,6 +496,7 @@ case 'O': // STDOUT { + got_stdout = true; std::string inferior_stdout; inferior_stdout.reserve(response.GetBytesLeft () / 2); char ch; Modified: lldb/trunk/source/Target/Thread.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/Thread.cpp?rev=131628&r1=131627&r2=131628&view=diff ============================================================================== --- lldb/trunk/source/Target/Thread.cpp (original) +++ lldb/trunk/source/Target/Thread.cpp Wed May 18 22:54:16 2011 @@ -266,7 +266,7 @@ { should_stop = current_plan->ShouldStop (event_ptr); if (log) - log->Printf("Base plan says should stop: %d.", current_plan->GetName(), should_stop); + log->Printf("Base plan says should stop: %i.", should_stop); } else { Modified: lldb/trunk/source/Target/ThreadPlanCallFunction.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/ThreadPlanCallFunction.cpp?rev=131628&r1=131627&r2=131628&view=diff ============================================================================== --- lldb/trunk/source/Target/ThreadPlanCallFunction.cpp (original) +++ lldb/trunk/source/Target/ThreadPlanCallFunction.cpp Wed May 18 22:54:16 2011 @@ -197,8 +197,9 @@ m_start_addr = objectFile->GetEntryPointAddress(); if (!m_start_addr.IsValid()) { - log->Printf ("Could not find entry point address for executable module \"%s\".", - executableModuleSP->GetFileSpec().GetFilename().AsCString()); + if (log) + log->Printf ("Could not find entry point address for executable module \"%s\".", + executableModuleSP->GetFileSpec().GetFilename().AsCString()); return; } } @@ -247,22 +248,28 @@ void ThreadPlanCallFunction::ReportRegisterState (const char *message) { - LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_STEP)); + LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_STEP | LIBLLDB_LOG_VERBOSE)); if (log) { + StreamString strm; RegisterContext *reg_ctx = m_thread.GetRegisterContext().get(); log->PutCString(message); - for (uint32_t register_index = 0, num_registers = reg_ctx->GetRegisterCount(); - register_index < num_registers; - ++register_index) + RegisterValue reg_value; + + for (uint32_t reg_idx = 0, num_registers = reg_ctx->GetRegisterCount(); + reg_idx < num_registers; + ++reg_idx) { - const char *register_name = reg_ctx->GetRegisterName(register_index); - uint64_t register_value = reg_ctx->ReadRegisterAsUnsigned(register_index, LLDB_INVALID_ADDRESS); - - log->Printf(" %s = 0x%llx", register_name, register_value); + const RegisterInfo *reg_info = reg_ctx->GetRegisterInfoAtIndex (reg_idx); + if (reg_ctx->ReadRegister(reg_info, reg_value)) + { + reg_value.Dump(&strm, reg_info, true, false, eFormatDefault); + strm.EOL(); + } } + log->PutCString(strm.GetData()); } } From peter at pcc.me.uk Thu May 19 12:34:40 2011 From: peter at pcc.me.uk (Peter Collingbourne) Date: Thu, 19 May 2011 17:34:40 -0000 Subject: [Lldb-commits] [lldb] r131645 - /lldb/trunk/source/lldb.cpp Message-ID: <20110519173440.5AAE02A6C12C@llvm.org> Author: pcc Date: Thu May 19 12:34:40 2011 New Revision: 131645 URL: http://llvm.org/viewvc/llvm-project?rev=131645&view=rev Log: Initialise the Darwin ABI plugins only on Darwin Modified: lldb/trunk/source/lldb.cpp Modified: lldb/trunk/source/lldb.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/lldb.cpp?rev=131645&r1=131644&r2=131645&view=diff ============================================================================== --- lldb/trunk/source/lldb.cpp (original) +++ lldb/trunk/source/lldb.cpp Thu May 19 12:34:40 2011 @@ -22,6 +22,7 @@ #include "llvm/ADT/StringRef.h" +#include "Plugins/ABI/SysV-x86_64/ABISysV_x86_64.h" #include "Plugins/Disassembler/llvm/DisassemblerLLVM.h" #include "Plugins/Instruction/ARM/EmulateInstructionARM.h" #include "Plugins/SymbolVendor/MacOSX/SymbolVendorMacOSX.h" @@ -36,7 +37,6 @@ #if defined (__APPLE__) #include "Plugins/ABI/MacOSX-i386/ABIMacOSX_i386.h" #include "Plugins/ABI/MacOSX-arm/ABIMacOSX_arm.h" -#include "Plugins/ABI/SysV-x86_64/ABISysV_x86_64.h" #include "Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.h" #include "Plugins/LanguageRuntime/CPlusPlus/ItaniumABI/ItaniumABILanguageRuntime.h" #include "Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV1.h" @@ -77,6 +77,7 @@ Timer::Initialize (); Timer scoped_timer (__PRETTY_FUNCTION__, __PRETTY_FUNCTION__); + ABISysV_x86_64::Initialize(); DisassemblerLLVM::Initialize(); ObjectContainerBSDArchive::Initialize(); ObjectFileELF::Initialize(); @@ -85,14 +86,13 @@ UnwindAssemblyInstEmulation::Initialize(); UnwindAssembly_x86::Initialize(); EmulateInstructionARM::Initialize (); - ABIMacOSX_i386::Initialize(); - ABIMacOSX_arm::Initialize(); - ABISysV_x86_64::Initialize(); #if defined (__APPLE__) //---------------------------------------------------------------------- // Apple/Darwin hosted plugins //---------------------------------------------------------------------- + ABIMacOSX_i386::Initialize(); + ABIMacOSX_arm::Initialize(); DynamicLoaderMacOSXDYLD::Initialize(); SymbolFileDWARFDebugMap::Initialize(); ItaniumABILanguageRuntime::Initialize(); @@ -144,6 +144,7 @@ // Terminate and unload and loaded system or user LLDB plug-ins PluginManager::Terminate(); + ABISysV_x86_64::Terminate(); DisassemblerLLVM::Terminate(); ObjectContainerBSDArchive::Terminate(); ObjectFileELF::Terminate(); @@ -152,11 +153,10 @@ UnwindAssembly_x86::Terminate(); UnwindAssemblyInstEmulation::Terminate(); EmulateInstructionARM::Terminate (); - ABIMacOSX_i386::Terminate(); - ABIMacOSX_arm::Terminate(); - ABISysV_x86_64::Terminate(); #if defined (__APPLE__) + ABIMacOSX_i386::Terminate(); + ABIMacOSX_arm::Terminate(); DynamicLoaderMacOSXDYLD::Terminate(); SymbolFileDWARFDebugMap::Terminate(); ItaniumABILanguageRuntime::Terminate(); From peter at pcc.me.uk Thu May 19 12:34:44 2011 From: peter at pcc.me.uk (Peter Collingbourne) Date: Thu, 19 May 2011 17:34:44 -0000 Subject: [Lldb-commits] [lldb] r131646 - /lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp Message-ID: <20110519173444.B7CEC2A6C12D@llvm.org> Author: pcc Date: Thu May 19 12:34:44 2011 New Revision: 131646 URL: http://llvm.org/viewvc/llvm-project?rev=131646&view=rev Log: Use the portable memchr function instead of the BSD-only strnstr Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp?rev=131646&r1=131645&r2=131646&view=diff ============================================================================== --- lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp (original) +++ lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp Thu May 19 12:34:44 2011 @@ -813,10 +813,10 @@ // Also see if this is a "category" on our class. If so strip off the category name, // and add the class name without it to the basename table. - const char *first_paren = strnstr (name, "(", method_name - name); + const char *first_paren = (char *) memchr (name, '(', method_name - name); if (first_paren) { - const char *second_paren = strnstr (first_paren, ")", method_name - first_paren); + const char *second_paren = (char *) memchr (first_paren, ')', method_name - first_paren); if (second_paren) { std::string buffer (name, first_paren - name); From peter at pcc.me.uk Thu May 19 12:34:48 2011 From: peter at pcc.me.uk (Peter Collingbourne) Date: Thu, 19 May 2011 17:34:48 -0000 Subject: [Lldb-commits] [lldb] r131647 - in /lldb/trunk/source/Target: ArchDefaultUnwindPlan.cpp ArchVolatileRegs.cpp Message-ID: <20110519173448.762162A6C12C@llvm.org> Author: pcc Date: Thu May 19 12:34:48 2011 New Revision: 131647 URL: http://llvm.org/viewvc/llvm-project?rev=131647&view=rev Log: Remove some old files which should have been removed in r131193 Removed: lldb/trunk/source/Target/ArchDefaultUnwindPlan.cpp lldb/trunk/source/Target/ArchVolatileRegs.cpp Removed: lldb/trunk/source/Target/ArchDefaultUnwindPlan.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/ArchDefaultUnwindPlan.cpp?rev=131646&view=auto ============================================================================== --- lldb/trunk/source/Target/ArchDefaultUnwindPlan.cpp (original) +++ lldb/trunk/source/Target/ArchDefaultUnwindPlan.cpp (removed) @@ -1,54 +0,0 @@ -//===-- ArchDefaultUnwindPlan.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/PluginManager.h" - -#include - -#include "lldb/Core/ArchSpec.h" -#include "lldb/Core/PluginInterface.h" -#include "lldb/Host/Mutex.h" -#include "lldb/Target/ArchDefaultUnwindPlan.h" - -using namespace lldb; -using namespace lldb_private; - -ArchDefaultUnwindPlanSP -ArchDefaultUnwindPlan::FindPlugin (const ArchSpec &arch) -{ - ArchDefaultUnwindPlanCreateInstance create_callback; - typedef std::map ArchDefaultUnwindPlanMap; - static ArchDefaultUnwindPlanMap g_plugin_map; - static Mutex g_plugin_map_mutex (Mutex::eMutexTypeRecursive); - Mutex::Locker locker (g_plugin_map_mutex); - ArchDefaultUnwindPlanMap::iterator pos = g_plugin_map.find (arch); - if (pos != g_plugin_map.end()) - return pos->second; - - for (uint32_t idx = 0; - (create_callback = PluginManager::GetArchDefaultUnwindPlanCreateCallbackAtIndex(idx)) != NULL; - ++idx) - { - ArchDefaultUnwindPlanSP default_unwind_plan_sp (create_callback (arch)); - if (default_unwind_plan_sp) - { - g_plugin_map[arch] = default_unwind_plan_sp; - return default_unwind_plan_sp; - } - } - return ArchDefaultUnwindPlanSP(); -} - -ArchDefaultUnwindPlan::ArchDefaultUnwindPlan () -{ -} - -ArchDefaultUnwindPlan::~ArchDefaultUnwindPlan () -{ -} Removed: lldb/trunk/source/Target/ArchVolatileRegs.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/ArchVolatileRegs.cpp?rev=131646&view=auto ============================================================================== --- lldb/trunk/source/Target/ArchVolatileRegs.cpp (original) +++ lldb/trunk/source/Target/ArchVolatileRegs.cpp (removed) @@ -1,40 +0,0 @@ -//===-- ArchVolatileRegs.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/lldb-private.h" -#include "lldb/Core/PluginManager.h" -#include "lldb/Core/PluginInterface.h" -#include "lldb/Target/ArchVolatileRegs.h" - -using namespace lldb; -using namespace lldb_private; - -ArchVolatileRegs* -ArchVolatileRegs::FindPlugin (const ArchSpec &arch) -{ - ArchVolatileRegsCreateInstance create_callback; - - for (uint32_t idx = 0; - (create_callback = PluginManager::GetArchVolatileRegsCreateCallbackAtIndex(idx)) != NULL; - ++idx) - { - std::auto_ptr default_volatile_regs_ap (create_callback (arch)); - if (default_volatile_regs_ap.get ()) - return default_volatile_regs_ap.release (); - } - return NULL; -} - -ArchVolatileRegs::ArchVolatileRegs () -{ -} - -ArchVolatileRegs::~ArchVolatileRegs () -{ -} From peter at pcc.me.uk Thu May 19 12:34:52 2011 From: peter at pcc.me.uk (Peter Collingbourne) Date: Thu, 19 May 2011 17:34:52 -0000 Subject: [Lldb-commits] [lldb] r131648 - /lldb/trunk/source/Utility/ARM_DWARF_Registers.cpp Message-ID: <20110519173452.11C4D2A6C12D@llvm.org> Author: pcc Date: Thu May 19 12:34:51 2011 New Revision: 131648 URL: http://llvm.org/viewvc/llvm-project?rev=131648&view=rev Log: #include for memset Modified: lldb/trunk/source/Utility/ARM_DWARF_Registers.cpp Modified: lldb/trunk/source/Utility/ARM_DWARF_Registers.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Utility/ARM_DWARF_Registers.cpp?rev=131648&r1=131647&r2=131648&view=diff ============================================================================== --- lldb/trunk/source/Utility/ARM_DWARF_Registers.cpp (original) +++ lldb/trunk/source/Utility/ARM_DWARF_Registers.cpp Thu May 19 12:34:51 2011 @@ -8,6 +8,7 @@ //===----------------------------------------------------------------------===// #include "ARM_DWARF_Registers.h" +#include using namespace lldb; using namespace lldb_private; From peter at pcc.me.uk Thu May 19 12:34:58 2011 From: peter at pcc.me.uk (Peter Collingbourne) Date: Thu, 19 May 2011 17:34:58 -0000 Subject: [Lldb-commits] [lldb] r131650 - in /lldb/trunk: lib/Makefile source/Plugins/Makefile source/Plugins/UnwindAssembly/InstEmulation/Makefile source/Plugins/UnwindAssembly/x86/Makefile Message-ID: <20110519173458.DB20F2A6C12C@llvm.org> Author: pcc Date: Thu May 19 12:34:58 2011 New Revision: 131650 URL: http://llvm.org/viewvc/llvm-project?rev=131650&view=rev Log: Add UnwindAssembly plugins to makefile build Added: lldb/trunk/source/Plugins/UnwindAssembly/InstEmulation/Makefile lldb/trunk/source/Plugins/UnwindAssembly/x86/Makefile Modified: lldb/trunk/lib/Makefile lldb/trunk/source/Plugins/Makefile Modified: lldb/trunk/lib/Makefile URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/lib/Makefile?rev=131650&r1=131649&r2=131650&view=diff ============================================================================== --- lldb/trunk/lib/Makefile (original) +++ lldb/trunk/lib/Makefile Thu May 19 12:34:58 2011 @@ -39,6 +39,8 @@ lldbPluginProcessGDBRemote.a \ lldbPluginSymbolFileDWARF.a \ lldbPluginSymbolFileSymtab.a \ + lldbPluginUnwindAssemblyInstEmulation.a \ + lldbPluginUnwindAssemblyx86.a \ lldbPluginUtility.a \ lldbSymbol.a \ lldbTarget.a \ Modified: lldb/trunk/source/Plugins/Makefile URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Makefile?rev=131650&r1=131649&r2=131650&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Makefile (original) +++ lldb/trunk/source/Plugins/Makefile Thu May 19 12:34:58 2011 @@ -15,7 +15,8 @@ DIRS := ABI/MacOSX-i386 ABI/SysV-x86_64 Disassembler/llvm \ ObjectContainer/BSD-Archive ObjectFile/ELF SymbolFile/DWARF \ SymbolFile/Symtab Process/Utility DynamicLoader/Static \ - Platform Process/gdb-remote Instruction/ARM + Platform Process/gdb-remote Instruction/ARM \ + UnwindAssembly/InstEmulation UnwindAssembly/x86 ifeq ($(HOST_OS),Darwin) DIRS += DynamicLoader/MacOSX-DYLD ObjectContainer/Universal-Mach-O \ Added: lldb/trunk/source/Plugins/UnwindAssembly/InstEmulation/Makefile URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/UnwindAssembly/InstEmulation/Makefile?rev=131650&view=auto ============================================================================== --- lldb/trunk/source/Plugins/UnwindAssembly/InstEmulation/Makefile (added) +++ lldb/trunk/source/Plugins/UnwindAssembly/InstEmulation/Makefile Thu May 19 12:34:58 2011 @@ -0,0 +1,14 @@ +##==- source/Plugins/UnwindAssembly/InstEmulation/Makefile -*- Makefile -*-===## +# +# The LLVM Compiler Infrastructure +# +# This file is distributed under the University of Illinois Open Source +# License. See LICENSE.TXT for details. +# +##===----------------------------------------------------------------------===## + +LLDB_LEVEL := ../../../.. +LIBRARYNAME := lldbPluginUnwindAssemblyInstEmulation +BUILD_ARCHIVE = 1 + +include $(LLDB_LEVEL)/Makefile Added: lldb/trunk/source/Plugins/UnwindAssembly/x86/Makefile URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/UnwindAssembly/x86/Makefile?rev=131650&view=auto ============================================================================== --- lldb/trunk/source/Plugins/UnwindAssembly/x86/Makefile (added) +++ lldb/trunk/source/Plugins/UnwindAssembly/x86/Makefile Thu May 19 12:34:58 2011 @@ -0,0 +1,14 @@ +##==-- source/Plugins/UnwindAssembly/x86/Makefile ----------*- Makefile -*-===## +# +# The LLVM Compiler Infrastructure +# +# This file is distributed under the University of Illinois Open Source +# License. See LICENSE.TXT for details. +# +##===----------------------------------------------------------------------===## + +LLDB_LEVEL := ../../../.. +LIBRARYNAME := lldbPluginUnwindAssemblyx86 +BUILD_ARCHIVE = 1 + +include $(LLDB_LEVEL)/Makefile From peter at pcc.me.uk Thu May 19 12:35:02 2011 From: peter at pcc.me.uk (Peter Collingbourne) Date: Thu, 19 May 2011 17:35:02 -0000 Subject: [Lldb-commits] [lldb] r131651 - /lldb/trunk/lib/Makefile Message-ID: <20110519173502.268FB2A6C12C@llvm.org> Author: pcc Date: Thu May 19 12:35:01 2011 New Revision: 131651 URL: http://llvm.org/viewvc/llvm-project?rev=131651&view=rev Log: Link to LLVM instrumentation lib Modified: lldb/trunk/lib/Makefile Modified: lldb/trunk/lib/Makefile URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/lib/Makefile?rev=131651&r1=131650&r2=131651&view=diff ============================================================================== --- lldb/trunk/lib/Makefile (original) +++ lldb/trunk/lib/Makefile Thu May 19 12:35:01 2011 @@ -62,7 +62,7 @@ include $(LLDB_LEVEL)/../../Makefile.config LINK_COMPONENTS := $(TARGETS_TO_BUILD) asmparser bitreader bitwriter codegen \ - ipo selectiondag jit mc + ipo selectiondag jit mc instrumentation ifeq ($(HOST_OS),Darwin) USEDLIBS += lldbHostMacOSX.a \ From jingham at apple.com Thu May 19 13:03:10 2011 From: jingham at apple.com (Jim Ingham) Date: Thu, 19 May 2011 11:03:10 -0700 Subject: [Lldb-commits] [lldb] r131645 - /lldb/trunk/source/lldb.cpp In-Reply-To: <20110519173440.5AAE02A6C12C@llvm.org> References: <20110519173440.5AAE02A6C12C@llvm.org> Message-ID: Why did you have to define these out? Was it just a problem with building? We want to make it possible to build an lldb that can be any of the kinds of cross debugger that lldb currently supports, so you don't have to play the games that gdb does with building the linux-cross-arm, and linux-native, and etc, etc. debuggers. Since you need the ABI bits to make a Linux-cross-MacOS X debugger, we want to make sure these build on all the platforms lldb supports. If there's some problem building them, we should resolve that. Jim On May 19, 2011, at 10:34 AM, Peter Collingbourne wrote: > Author: pcc > Date: Thu May 19 12:34:40 2011 > New Revision: 131645 > > URL: http://llvm.org/viewvc/llvm-project?rev=131645&view=rev > Log: > Initialise the Darwin ABI plugins only on Darwin > > Modified: > lldb/trunk/source/lldb.cpp > > Modified: lldb/trunk/source/lldb.cpp > URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/lldb.cpp?rev=131645&r1=131644&r2=131645&view=diff > ============================================================================== > --- lldb/trunk/source/lldb.cpp (original) > +++ lldb/trunk/source/lldb.cpp Thu May 19 12:34:40 2011 > @@ -22,6 +22,7 @@ > > #include "llvm/ADT/StringRef.h" > > +#include "Plugins/ABI/SysV-x86_64/ABISysV_x86_64.h" > #include "Plugins/Disassembler/llvm/DisassemblerLLVM.h" > #include "Plugins/Instruction/ARM/EmulateInstructionARM.h" > #include "Plugins/SymbolVendor/MacOSX/SymbolVendorMacOSX.h" > @@ -36,7 +37,6 @@ > #if defined (__APPLE__) > #include "Plugins/ABI/MacOSX-i386/ABIMacOSX_i386.h" > #include "Plugins/ABI/MacOSX-arm/ABIMacOSX_arm.h" > -#include "Plugins/ABI/SysV-x86_64/ABISysV_x86_64.h" > #include "Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.h" > #include "Plugins/LanguageRuntime/CPlusPlus/ItaniumABI/ItaniumABILanguageRuntime.h" > #include "Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV1.h" > @@ -77,6 +77,7 @@ > Timer::Initialize (); > Timer scoped_timer (__PRETTY_FUNCTION__, __PRETTY_FUNCTION__); > > + ABISysV_x86_64::Initialize(); > DisassemblerLLVM::Initialize(); > ObjectContainerBSDArchive::Initialize(); > ObjectFileELF::Initialize(); > @@ -85,14 +86,13 @@ > UnwindAssemblyInstEmulation::Initialize(); > UnwindAssembly_x86::Initialize(); > EmulateInstructionARM::Initialize (); > - ABIMacOSX_i386::Initialize(); > - ABIMacOSX_arm::Initialize(); > - ABISysV_x86_64::Initialize(); > > #if defined (__APPLE__) > //---------------------------------------------------------------------- > // Apple/Darwin hosted plugins > //---------------------------------------------------------------------- > + ABIMacOSX_i386::Initialize(); > + ABIMacOSX_arm::Initialize(); > DynamicLoaderMacOSXDYLD::Initialize(); > SymbolFileDWARFDebugMap::Initialize(); > ItaniumABILanguageRuntime::Initialize(); > @@ -144,6 +144,7 @@ > // Terminate and unload and loaded system or user LLDB plug-ins > PluginManager::Terminate(); > > + ABISysV_x86_64::Terminate(); > DisassemblerLLVM::Terminate(); > ObjectContainerBSDArchive::Terminate(); > ObjectFileELF::Terminate(); > @@ -152,11 +153,10 @@ > UnwindAssembly_x86::Terminate(); > UnwindAssemblyInstEmulation::Terminate(); > EmulateInstructionARM::Terminate (); > - ABIMacOSX_i386::Terminate(); > - ABIMacOSX_arm::Terminate(); > - ABISysV_x86_64::Terminate(); > > #if defined (__APPLE__) > + ABIMacOSX_i386::Terminate(); > + ABIMacOSX_arm::Terminate(); > DynamicLoaderMacOSXDYLD::Terminate(); > SymbolFileDWARFDebugMap::Terminate(); > ItaniumABILanguageRuntime::Terminate(); > > > _______________________________________________ > lldb-commits mailing list > lldb-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/lldb-commits From gclayton at apple.com Thu May 19 13:17:41 2011 From: gclayton at apple.com (Greg Clayton) Date: Thu, 19 May 2011 18:17:41 -0000 Subject: [Lldb-commits] [lldb] r131658 - in /lldb/trunk: include/lldb/Breakpoint/StoppointLocation.h include/lldb/Core/Address.h source/Breakpoint/StoppointLocation.cpp source/Core/Address.cpp source/Target/Process.cpp Message-ID: <20110519181741.D2C132A6C12C@llvm.org> Author: gclayton Date: Thu May 19 13:17:41 2011 New Revision: 131658 URL: http://llvm.org/viewvc/llvm-project?rev=131658&view=rev Log: Moved a lot of simple functions from StoppointLocation.cpp to be inlined in StoppointLocation.h. Added a new lldb_private::Address function: addr_t Address::GetOpcodeLoadAddress (Target *target) const; This will strip any special bits from an address to make sure it is suitable for use in addressing an opcode. Often ARM addresses have an extra bit zero that can be set to indicate ARM vs Thumb addresses (gotten from return address registers, or symbol addresses that may be marked up specially). We need to strip these bits off prior to setting breakpoints, so we can centralized the place to do this inside the Address class. Modified: lldb/trunk/include/lldb/Breakpoint/StoppointLocation.h lldb/trunk/include/lldb/Core/Address.h lldb/trunk/source/Breakpoint/StoppointLocation.cpp lldb/trunk/source/Core/Address.cpp lldb/trunk/source/Target/Process.cpp Modified: lldb/trunk/include/lldb/Breakpoint/StoppointLocation.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Breakpoint/StoppointLocation.h?rev=131658&r1=131657&r2=131658&view=diff ============================================================================== --- lldb/trunk/include/lldb/Breakpoint/StoppointLocation.h (original) +++ lldb/trunk/include/lldb/Breakpoint/StoppointLocation.h Thu May 19 13:17:41 2011 @@ -46,37 +46,75 @@ // Methods //------------------------------------------------------------------ virtual lldb::addr_t - GetLoadAddress () const; + GetLoadAddress() const + { + return m_addr; + } + + virtual lldb::addr_t + SetLoadAddress () const + { + return m_addr; + } size_t - GetByteSize () const; + GetByteSize () const + { + return m_byte_size; + } uint32_t - GetHitCount () const; + GetHitCount () const + { + return m_hit_count; + } void IncrementHitCount (); uint32_t - GetHardwareIndex () const; + GetHardwareIndex () const + { + return m_hw_index; + } + bool - HardwarePreferred () const; + HardwarePreferred () const + { + return m_hw_preferred; + } bool - IsHardware () const; + IsHardware () const + { + return m_hw_index != LLDB_INVALID_INDEX32; + } + virtual bool - ShouldStop (StoppointCallbackContext *context); + ShouldStop (StoppointCallbackContext *context) + { + return true; + } virtual void - Dump (Stream *stream) const; + Dump (Stream *stream) const + { + } void - SetHardwareIndex (uint32_t index); + SetHardwareIndex (uint32_t index) + { + m_hw_index = index; + } + lldb::break_id_t - GetID () const; + GetID () const + { + return m_loc_id; + } protected: //------------------------------------------------------------------ Modified: lldb/trunk/include/lldb/Core/Address.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/Address.h?rev=131658&r1=131657&r2=131658&view=diff ============================================================================== --- lldb/trunk/include/lldb/Core/Address.h (original) +++ lldb/trunk/include/lldb/Core/Address.h Thu May 19 13:17:41 2011 @@ -299,6 +299,26 @@ GetCallableLoadAddress (Target *target) const; //------------------------------------------------------------------ + /// Get the load address as an opcode load address. + /// + /// This function will first resolve its address to a load address. + /// Then, if the address turns out to be in code address, return the + /// load address for a an opcode. This address object might have + /// extra bits set (bit zero will be set to Thumb functions for an + /// ARM target) that are required for changing the program counter + /// and this function will remove any bits that are intended for + /// these special purposes. The result of this function can be used + /// to safely write a software breakpoint trap to memory. + /// + /// @return + /// The valid load virtual address with extra callable bits + /// removed, or LLDB_INVALID_ADDRESS if the address is currently + /// not loaded. + //------------------------------------------------------------------ + lldb::addr_t + GetOpcodeLoadAddress (Target *target) const; + + //------------------------------------------------------------------ /// Get the section relative offset value. /// /// @return Modified: lldb/trunk/source/Breakpoint/StoppointLocation.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Breakpoint/StoppointLocation.cpp?rev=131658&r1=131657&r2=131658&view=diff ============================================================================== --- lldb/trunk/source/Breakpoint/StoppointLocation.cpp (original) +++ lldb/trunk/source/Breakpoint/StoppointLocation.cpp Thu May 19 13:17:41 2011 @@ -46,67 +46,3 @@ StoppointLocation::~StoppointLocation() { } - - -size_t -StoppointLocation::GetByteSize () const -{ - return m_byte_size; -} - -addr_t -StoppointLocation::GetLoadAddress() const -{ - return m_addr; -} - -uint32_t -StoppointLocation::GetHitCount () const -{ - return m_hit_count; -} - -bool -StoppointLocation::HardwarePreferred () const -{ - return m_hw_preferred; -} - -bool -StoppointLocation::IsHardware () const -{ - return m_hw_index != LLDB_INVALID_INDEX32; -} - -uint32_t -StoppointLocation::GetHardwareIndex () const -{ - return m_hw_index; -} - -void -StoppointLocation::SetHardwareIndex (uint32_t hw_index) -{ - m_hw_index = hw_index; -} - -// RETURNS - true if we should stop at this breakpoint, false if we -// should continue. - -bool -StoppointLocation::ShouldStop (StoppointCallbackContext *context) -{ - return true; -} - -break_id_t -StoppointLocation::GetID() const -{ - return m_loc_id; -} - -void -StoppointLocation::Dump (Stream *stream) const -{ - -} Modified: lldb/trunk/source/Core/Address.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/Address.cpp?rev=131658&r1=131657&r2=131658&view=diff ============================================================================== --- lldb/trunk/source/Core/Address.cpp (original) +++ lldb/trunk/source/Core/Address.cpp Thu May 19 13:17:41 2011 @@ -301,6 +301,8 @@ { addr_t code_addr = GetLoadAddress (target); + // Make sure we have section, otherwise the call to GetAddressClass() will + // fail because it uses the section to get to the module. if (m_section && code_addr != LLDB_INVALID_ADDRESS) { switch (target->GetArchitecture().GetMachine()) @@ -332,6 +334,28 @@ return code_addr; } +addr_t +Address::GetOpcodeLoadAddress (Target *target) const +{ + addr_t code_addr = GetLoadAddress (target); + + if (code_addr != LLDB_INVALID_ADDRESS) + { + switch (target->GetArchitecture().GetMachine()) + { + case llvm::Triple::arm: + case llvm::Triple::thumb: + // Strip bit zero to make sure we end up on an opcode boundary + return code_addr & ~(1ull); + break; + + default: + break; + } + } + return code_addr; +} + bool Address::Dump (Stream *s, ExecutionContextScope *exe_scope, DumpStyle style, DumpStyle fallback_style, uint32_t addr_size) const { Modified: lldb/trunk/source/Target/Process.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/Process.cpp?rev=131658&r1=131657&r2=131658&view=diff ============================================================================== --- lldb/trunk/source/Target/Process.cpp (original) +++ lldb/trunk/source/Target/Process.cpp Thu May 19 13:17:41 2011 @@ -1323,7 +1323,7 @@ lldb::break_id_t Process::CreateBreakpointSite (BreakpointLocationSP &owner, bool use_hardware) { - const addr_t load_addr = owner->GetAddress().GetLoadAddress (&m_target); + const addr_t load_addr = owner->GetAddress().GetOpcodeLoadAddress (&m_target); if (load_addr != LLDB_INVALID_ADDRESS) { BreakpointSiteSP bp_site_sp; @@ -3240,7 +3240,7 @@ } // Save this value for restoration of the execution context after we run - uint32_t tid = exe_ctx.thread->GetIndexID(); + const uint32_t thread_idx_id = exe_ctx.thread->GetIndexID(); // N.B. Running the target may unset the currently selected thread and frame. We don't want to do that either, // so we should arrange to reset them as well. @@ -3378,12 +3378,12 @@ case lldb::eStateStopped: { // Yay, we're done. Now make sure that our thread plan actually completed. - ThreadSP thread_sp = exe_ctx.process->GetThreadList().FindThreadByIndexID (tid); + 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 has vanished."); + log->Printf ("Execution completed but our thread (index-id=%u) has vanished.", thread_idx_id); return_value = eExecutionInterrupted; } else @@ -3733,7 +3733,7 @@ // Thread we ran the function in may have gone away because we ran the target // Check that it's still there. - exe_ctx.thread = exe_ctx.process->GetThreadList().FindThreadByIndexID(tid, true).get(); + exe_ctx.thread = exe_ctx.process->GetThreadList().FindThreadByIndexID(thread_idx_id, true).get(); if (exe_ctx.thread) exe_ctx.frame = exe_ctx.thread->GetStackFrameAtIndex(0).get(); From peter at pcc.me.uk Thu May 19 13:32:34 2011 From: peter at pcc.me.uk (Peter Collingbourne) Date: Thu, 19 May 2011 18:32:34 -0000 Subject: [Lldb-commits] [lldb] r131661 - in /lldb/trunk: lib/Makefile source/Plugins/Makefile source/lldb.cpp Message-ID: <20110519183234.42BE72A6C12C@llvm.org> Author: pcc Date: Thu May 19 13:32:34 2011 New Revision: 131661 URL: http://llvm.org/viewvc/llvm-project?rev=131661&view=rev Log: Build and initialise the Darwin ABI plugins on all platforms Modified: lldb/trunk/lib/Makefile lldb/trunk/source/Plugins/Makefile lldb/trunk/source/lldb.cpp Modified: lldb/trunk/lib/Makefile URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/lib/Makefile?rev=131661&r1=131660&r2=131661&view=diff ============================================================================== --- lldb/trunk/lib/Makefile (original) +++ lldb/trunk/lib/Makefile Thu May 19 13:32:34 2011 @@ -28,6 +28,7 @@ lldbHostCommon.a \ lldbInitAndLog.a \ lldbInterpreter.a \ + lldbPluginABIMacOSX_arm.a \ lldbPluginABIMacOSX_i386.a \ lldbPluginABISysV_x86_64.a \ lldbPluginDisassemblerLLVM.a \ Modified: lldb/trunk/source/Plugins/Makefile URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Makefile?rev=131661&r1=131660&r2=131661&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Makefile (original) +++ lldb/trunk/source/Plugins/Makefile Thu May 19 13:32:34 2011 @@ -12,7 +12,7 @@ include $(LLDB_LEVEL)/../../Makefile.config -DIRS := ABI/MacOSX-i386 ABI/SysV-x86_64 Disassembler/llvm \ +DIRS := ABI/MacOSX-arm ABI/MacOSX-i386 ABI/SysV-x86_64 Disassembler/llvm \ ObjectContainer/BSD-Archive ObjectFile/ELF SymbolFile/DWARF \ SymbolFile/Symtab Process/Utility DynamicLoader/Static \ Platform Process/gdb-remote Instruction/ARM \ Modified: lldb/trunk/source/lldb.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/lldb.cpp?rev=131661&r1=131660&r2=131661&view=diff ============================================================================== --- lldb/trunk/source/lldb.cpp (original) +++ lldb/trunk/source/lldb.cpp Thu May 19 13:32:34 2011 @@ -22,6 +22,8 @@ #include "llvm/ADT/StringRef.h" +#include "Plugins/ABI/MacOSX-i386/ABIMacOSX_i386.h" +#include "Plugins/ABI/MacOSX-arm/ABIMacOSX_arm.h" #include "Plugins/ABI/SysV-x86_64/ABISysV_x86_64.h" #include "Plugins/Disassembler/llvm/DisassemblerLLVM.h" #include "Plugins/Instruction/ARM/EmulateInstructionARM.h" @@ -35,8 +37,6 @@ #include "Plugins/UnwindAssembly/InstEmulation/UnwindAssemblyInstEmulation.h" #if defined (__APPLE__) -#include "Plugins/ABI/MacOSX-i386/ABIMacOSX_i386.h" -#include "Plugins/ABI/MacOSX-arm/ABIMacOSX_arm.h" #include "Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.h" #include "Plugins/LanguageRuntime/CPlusPlus/ItaniumABI/ItaniumABILanguageRuntime.h" #include "Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV1.h" @@ -77,6 +77,8 @@ Timer::Initialize (); Timer scoped_timer (__PRETTY_FUNCTION__, __PRETTY_FUNCTION__); + ABIMacOSX_i386::Initialize(); + ABIMacOSX_arm::Initialize(); ABISysV_x86_64::Initialize(); DisassemblerLLVM::Initialize(); ObjectContainerBSDArchive::Initialize(); @@ -91,8 +93,6 @@ //---------------------------------------------------------------------- // Apple/Darwin hosted plugins //---------------------------------------------------------------------- - ABIMacOSX_i386::Initialize(); - ABIMacOSX_arm::Initialize(); DynamicLoaderMacOSXDYLD::Initialize(); SymbolFileDWARFDebugMap::Initialize(); ItaniumABILanguageRuntime::Initialize(); @@ -144,6 +144,8 @@ // Terminate and unload and loaded system or user LLDB plug-ins PluginManager::Terminate(); + ABIMacOSX_i386::Terminate(); + ABIMacOSX_arm::Terminate(); ABISysV_x86_64::Terminate(); DisassemblerLLVM::Terminate(); ObjectContainerBSDArchive::Terminate(); @@ -155,8 +157,6 @@ EmulateInstructionARM::Terminate (); #if defined (__APPLE__) - ABIMacOSX_i386::Terminate(); - ABIMacOSX_arm::Terminate(); DynamicLoaderMacOSXDYLD::Terminate(); SymbolFileDWARFDebugMap::Terminate(); ItaniumABILanguageRuntime::Terminate(); From peter at pcc.me.uk Thu May 19 13:37:51 2011 From: peter at pcc.me.uk (Peter Collingbourne) Date: Thu, 19 May 2011 19:37:51 +0100 Subject: [Lldb-commits] [lldb] r131645 - /lldb/trunk/source/lldb.cpp In-Reply-To: References: <20110519173440.5AAE02A6C12C@llvm.org> Message-ID: <20110519183751.GC29201@pcc.me.uk> On Thu, May 19, 2011 at 11:03:10AM -0700, Jim Ingham wrote: > Why did you have to define these out? Was it just a problem with building? We want to make it possible to build an lldb that can be any of the kinds of cross debugger that lldb currently supports, so you don't have to play the games that gdb does with building the linux-cross-arm, and linux-native, and etc, etc. debuggers. Since you need the ABI bits to make a Linux-cross-MacOS X debugger, we want to make sure these build on all the platforms lldb supports. > > If there's some problem building them, we should resolve that. To fix the build error in lldb.cpp on non-Darwin platforms I resolved the inconsistency between the list of #included header files and the list of initialised plugins, apparently in the wrong direction (it wasn't immediately clear which plugins were platform independent). Since ABI/MacOSX-i386 and ABI/MacOSX-arm build fine on Linux I re-enabled them for all platforms in r131661. Thanks, -- Peter From amitkulz at gmail.com Thu May 19 14:03:41 2011 From: amitkulz at gmail.com (Amit Kulkarni) Date: Thu, 19 May 2011 14:03:41 -0500 Subject: [Lldb-commits] [lldb] r131645 - /lldb/trunk/source/lldb.cpp In-Reply-To: References: <20110519173440.5AAE02A6C12C@llvm.org> Message-ID: On Thu, May 19, 2011 at 1:03 PM, Jim Ingham wrote: > Why did you have to define these out? ?Was it just a problem with building? ?We want to make it possible to build an lldb that can be any of the kinds of cross debugger that lldb currently supports, so you don't have to play the games that gdb does with building the linux-cross-arm, and linux-native, and etc, etc. debuggers. ?Since you need the ABI bits to make a Linux-cross-MacOS X debugger, we want to make sure these build on all the platforms lldb supports. > > If there's some problem building them, we should resolve that. Err. I was having problems building on freebsd. I had sent out a diff somewghat like this a week ago. If its resolved please ignore this email. Thanks From jingham at apple.com Thu May 19 15:51:43 2011 From: jingham at apple.com (Jim Ingham) Date: Thu, 19 May 2011 13:51:43 -0700 Subject: [Lldb-commits] [lldb] r131645 - /lldb/trunk/source/lldb.cpp In-Reply-To: <20110519183751.GC29201@pcc.me.uk> References: <20110519173440.5AAE02A6C12C@llvm.org> <20110519183751.GC29201@pcc.me.uk> Message-ID: <74266208-9358-48C6-AF68-AD9634AA97AB@apple.com> Cool, thanks. All of the plugins except for the Process plugin should be buildable anywhere. You would need all of them plus the gdb-remote process plugin to implement a cross debugger. If there are any of the other plugins that are relying on non-portable headers and the like, or on stuff that is in Host for a particular OS, we need to fix that. Jim On May 19, 2011, at 11:37 AM, Peter Collingbourne wrote: > On Thu, May 19, 2011 at 11:03:10AM -0700, Jim Ingham wrote: >> Why did you have to define these out? Was it just a problem with building? We want to make it possible to build an lldb that can be any of the kinds of cross debugger that lldb currently supports, so you don't have to play the games that gdb does with building the linux-cross-arm, and linux-native, and etc, etc. debuggers. Since you need the ABI bits to make a Linux-cross-MacOS X debugger, we want to make sure these build on all the platforms lldb supports. >> >> If there's some problem building them, we should resolve that. > > To fix the build error in lldb.cpp on non-Darwin platforms I resolved > the inconsistency between the list of #included header files and the > list of initialised plugins, apparently in the wrong direction (it > wasn't immediately clear which plugins were platform independent). > Since ABI/MacOSX-i386 and ABI/MacOSX-arm build fine on Linux I > re-enabled them for all platforms in r131661. > > Thanks, > -- > Peter From johnny.chen at apple.com Thu May 19 16:28:24 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Thu, 19 May 2011 21:28:24 -0000 Subject: [Lldb-commits] [lldb] r131680 - in /lldb/trunk/test/expression_command/call-function: ./ Makefile TestCallStdStringFunction.py main.cpp Message-ID: <20110519212824.59E362A6C12C@llvm.org> Author: johnny Date: Thu May 19 16:28:24 2011 New Revision: 131680 URL: http://llvm.org/viewvc/llvm-project?rev=131680&view=rev Log: Add TestCallStdStringFunction.py which calls std::string member functions while stopped on a breakpoint. Added: lldb/trunk/test/expression_command/call-function/ lldb/trunk/test/expression_command/call-function/Makefile lldb/trunk/test/expression_command/call-function/TestCallStdStringFunction.py lldb/trunk/test/expression_command/call-function/main.cpp Added: lldb/trunk/test/expression_command/call-function/Makefile URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/expression_command/call-function/Makefile?rev=131680&view=auto ============================================================================== --- lldb/trunk/test/expression_command/call-function/Makefile (added) +++ lldb/trunk/test/expression_command/call-function/Makefile Thu May 19 16:28:24 2011 @@ -0,0 +1,5 @@ +LEVEL = ../../make + +CXX_SOURCES := main.cpp + +include $(LEVEL)/Makefile.rules Added: lldb/trunk/test/expression_command/call-function/TestCallStdStringFunction.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/expression_command/call-function/TestCallStdStringFunction.py?rev=131680&view=auto ============================================================================== --- lldb/trunk/test/expression_command/call-function/TestCallStdStringFunction.py (added) +++ lldb/trunk/test/expression_command/call-function/TestCallStdStringFunction.py Thu May 19 16:28:24 2011 @@ -0,0 +1,58 @@ +""" +Test calling std::String member functions. +""" + +import unittest2 +import lldb +import lldbutil +from lldbtest import * + +class ExprCommandCallFunctionTestCase(TestBase): + + mydir = os.path.join("expression_command", "call-function") + + def setUp(self): + # Call super's setUp(). + TestBase.setUp(self) + # Find the line number to break for main.c. + self.line = line_number('main.cpp', + '// Please test these expressions while stopped at this line:') + + @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin") + def test_with_dsym(self): + """Test calling std::String member function.""" + self.buildDsym() + self.call_function() + + @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin") + @python_api_test + def test_with_dwarf_(self): + """Test calling std::String member function.""" + self.buildDsym() + self.call_function() + + def call_function(self): + """Test calling std::String member function.""" + self.runCmd("file a.out", CURRENT_EXECUTABLE_SET) + + self.expect("breakpoint set -f main.cpp -l %d" % self.line, + BREAKPOINT_CREATED, + startstr = "Breakpoint created: 1: file ='main.cpp', line = %d" % + self.line) + + self.runCmd("run", RUN_SUCCEEDED) + + self.expect("print str", + substrs = ['Hello world']) + + # runCmd: print str.c_str() + # runCmd failed! + # error: Couldn't convert the expression to DWARF + self.expect("print str.c_str()", + substrs = ['Hello world']) + +if __name__ == '__main__': + import atexit + lldb.SBDebugger.Initialize() + atexit.register(lambda: lldb.SBDebugger.Terminate()) + unittest2.main() Added: lldb/trunk/test/expression_command/call-function/main.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/expression_command/call-function/main.cpp?rev=131680&view=auto ============================================================================== --- lldb/trunk/test/expression_command/call-function/main.cpp (added) +++ lldb/trunk/test/expression_command/call-function/main.cpp Thu May 19 16:28:24 2011 @@ -0,0 +1,15 @@ +#include +#include + +int main (int argc, char const *argv[]) +{ + std::string str = "Hello world"; + std::cout << str << std::endl; + std::cout << str.c_str() << std::endl; + // Please test these expressions while stopped at this line: +#if 0 + print str + print str.c_str() +#endif + return 0; +} From johnny.chen at apple.com Thu May 19 16:31:35 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Thu, 19 May 2011 21:31:35 -0000 Subject: [Lldb-commits] [lldb] r131681 - /lldb/trunk/test/expression_command/call-function/TestCallStdStringFunction.py Message-ID: <20110519213135.3A2062A6C12C@llvm.org> Author: johnny Date: Thu May 19 16:31:35 2011 New Revision: 131681 URL: http://llvm.org/viewvc/llvm-project?rev=131681&view=rev Log: Add radar info. Modified: lldb/trunk/test/expression_command/call-function/TestCallStdStringFunction.py Modified: lldb/trunk/test/expression_command/call-function/TestCallStdStringFunction.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/expression_command/call-function/TestCallStdStringFunction.py?rev=131681&r1=131680&r2=131681&view=diff ============================================================================== --- lldb/trunk/test/expression_command/call-function/TestCallStdStringFunction.py (original) +++ lldb/trunk/test/expression_command/call-function/TestCallStdStringFunction.py Thu May 19 16:31:35 2011 @@ -45,6 +45,7 @@ self.expect("print str", substrs = ['Hello world']) + # rdar://problem/9471744 test failure: ./dotest.py -C clang -v -w -t -p CallStdString # runCmd: print str.c_str() # runCmd failed! # error: Couldn't convert the expression to DWARF From mminutoli at gmail.com Thu May 19 16:41:29 2011 From: mminutoli at gmail.com (Marco Minutoli) Date: Thu, 19 May 2011 23:41:29 +0200 Subject: [Lldb-commits] patch series revised. Message-ID: <1305841292-24335-1-git-send-email-mminutoli@gmail.com> Hi all, the patches from Peter Collingbourne (thank you!) solve quite every build problem on linux. This little patch series should solve the rest. As suggested by Stephen I have patched Makefiles to use python-config instead of hardcoding flags in them. Any comment or suggestion is welcome. Best regards Marco From mminutoli at gmail.com Thu May 19 16:41:30 2011 From: mminutoli at gmail.com (Marco Minutoli) Date: Thu, 19 May 2011 23:41:30 +0200 Subject: [Lldb-commits] [PATCH 1/3] API fix and missing headers. In-Reply-To: <1305841292-24335-1-git-send-email-mminutoli@gmail.com> References: <1305841292-24335-1-git-send-email-mminutoli@gmail.com> Message-ID: <1305841292-24335-2-git-send-email-mminutoli@gmail.com> Host.cpp was missing Error.h and the implementation of LaunchProcess. Once againg I have added a "fake" implementation waiting for a real one. Fixed the call GetAddressRange to reflect the new interface in DynamicLoaderLinuxDYLD.cpp. Added string.h to ARM_DWARF_Registers.cpp that is needed for ::memset. --- source/Host/linux/Host.cpp | 10 ++++++++++ .../Linux-DYLD/DynamicLoaderLinuxDYLD.cpp | 2 +- source/Utility/ARM_DWARF_Registers.cpp | 2 ++ 3 files changed, 13 insertions(+), 1 deletions(-) diff --git a/source/Host/linux/Host.cpp b/source/Host/linux/Host.cpp index b0d43e8..4ebacc5 100644 --- a/source/Host/linux/Host.cpp +++ b/source/Host/linux/Host.cpp @@ -14,6 +14,7 @@ // C++ Includes // Other libraries and framework includes // Project includes +#include "lldb/Core/Error.h" #include "lldb/Host/Host.h" using namespace lldb; @@ -33,3 +34,12 @@ Host::GetOSVersion(uint32_t &major, status = sscanf(un.release, "%u.%u.%u", &major, &minor, &update); return status == 3; } + +Error +Host::LaunchProcess (ProcessLaunchInfo &launch_info) +{ + Error error; + assert(!"Not implemented yet!!!"); + return error; +} + diff --git a/source/Plugins/DynamicLoader/Linux-DYLD/DynamicLoaderLinuxDYLD.cpp b/source/Plugins/DynamicLoader/Linux-DYLD/DynamicLoaderLinuxDYLD.cpp index 1eda619..898c36e 100644 --- a/source/Plugins/DynamicLoader/Linux-DYLD/DynamicLoaderLinuxDYLD.cpp +++ b/source/Plugins/DynamicLoader/Linux-DYLD/DynamicLoaderLinuxDYLD.cpp @@ -321,7 +321,7 @@ DynamicLoaderLinuxDYLD::GetStepThroughTrampolinePlan(Thread &thread, bool stop) AddressRange range; if (target_symbols.GetContextAtIndex(i, context)) { - context.GetAddressRange(eSymbolContextEverything, range); + context.GetAddressRange(eSymbolContextEverything, 0, false, range); lldb::addr_t addr = range.GetBaseAddress().GetLoadAddress(&target); if (addr != LLDB_INVALID_ADDRESS) addrs.push_back(addr); diff --git a/source/Utility/ARM_DWARF_Registers.cpp b/source/Utility/ARM_DWARF_Registers.cpp index b8737ae..5e59c33 100644 --- a/source/Utility/ARM_DWARF_Registers.cpp +++ b/source/Utility/ARM_DWARF_Registers.cpp @@ -10,6 +10,8 @@ #include "ARM_DWARF_Registers.h" #include +#include + using namespace lldb; using namespace lldb_private; -- 1.7.3.4 From mminutoli at gmail.com Thu May 19 16:41:31 2011 From: mminutoli at gmail.com (Marco Minutoli) Date: Thu, 19 May 2011 23:41:31 +0200 Subject: [Lldb-commits] [PATCH 2/3] A bit of clean up. In-Reply-To: <1305841292-24335-1-git-send-email-mminutoli@gmail.com> References: <1305841292-24335-1-git-send-email-mminutoli@gmail.com> Message-ID: <1305841292-24335-3-git-send-email-mminutoli@gmail.com> Removed ifdeffed out functions and added the implementation of WriteRegister for x86_64 architecture. --- .../Process/Linux/RegisterContextLinux_i386.cpp | 59 +------------------- .../Process/Linux/RegisterContextLinux_x86_64.cpp | 46 ++------------- .../Process/Linux/RegisterContextLinux_x86_64.h | 17 ------ 3 files changed, 9 insertions(+), 113 deletions(-) diff --git a/source/Plugins/Process/Linux/RegisterContextLinux_i386.cpp b/source/Plugins/Process/Linux/RegisterContextLinux_i386.cpp index 0a8ec5a..cc669d5 100644 --- a/source/Plugins/Process/Linux/RegisterContextLinux_i386.cpp +++ b/source/Plugins/Process/Linux/RegisterContextLinux_i386.cpp @@ -419,71 +419,18 @@ RegisterContextLinux_i386::ReadRegister(const RegisterInfo *reg_info, return monitor.ReadRegisterValue(GetRegOffset(reg), value); } -#if 0 - -bool -RegisterContextLinux_i386::ReadRegisterValue(uint32_t reg, - Scalar &value) -{ - ProcessMonitor &monitor = GetMonitor(); - return monitor.ReadRegisterValue(GetRegOffset(reg), value); -} - -bool -RegisterContextLinux_i386::ReadRegisterBytes(uint32_t reg, - DataExtractor &data) -{ - uint8_t *buf = reinterpret_cast(&user); - bool status; - - if (IsGPR(reg)) - status = ReadGPR(); - else if (IsFPR(reg)) - status = ReadFPR(); - else - { - assert(false && "invalid register number"); - status = false; - } - - if (status) - data.SetData(buf + GetRegOffset(reg), GetRegSize(reg), lldb::endian::InlHostByteOrder()); - - return status; -} - -#endif - bool RegisterContextLinux_i386::ReadAllRegisterValues(DataBufferSP &data_sp) { return false; } -#if 0 - -bool -RegisterContextLinux_i386::WriteRegisterValue(uint32_t reg, - const Scalar &value) -{ - ProcessMonitor &monitor = GetMonitor(); - return monitor.WriteRegisterValue(GetRegOffset(reg), value); -} - -bool -RegisterContextLinux_i386::WriteRegisterBytes(uint32_t reg, - DataExtractor &data, - uint32_t data_offset) -{ - return false; -} - -#endif - bool RegisterContextLinux_i386::WriteRegister(const RegisterInfo *reg_info, const RegisterValue &value) { - return false; + const uint32_t reg = reg_info->kinds[eRegisterKindLLDB]; + ProcessMonitor &monitor = GetMonitor(); + return monitor.WriteRegisterValue(GetRegOffset(reg), value); } bool diff --git a/source/Plugins/Process/Linux/RegisterContextLinux_x86_64.cpp b/source/Plugins/Process/Linux/RegisterContextLinux_x86_64.cpp index 012690f..a3ce221 100644 --- a/source/Plugins/Process/Linux/RegisterContextLinux_x86_64.cpp +++ b/source/Plugins/Process/Linux/RegisterContextLinux_x86_64.cpp @@ -475,65 +475,31 @@ RegisterContextLinux_x86_64::GetRegisterSet(uint32_t set) return NULL; } -#if 0 bool -RegisterContextLinux_x86_64::ReadRegisterValue(uint32_t reg, - Scalar &value) +RegisterContextLinux_x86_64::ReadRegister(const RegisterInfo *reg_info, + RegisterValue &value) { + const uint32_t reg = reg_info->kinds[eRegisterKindLLDB]; ProcessMonitor &monitor = GetMonitor(); return monitor.ReadRegisterValue(GetRegOffset(reg), value); } bool -RegisterContextLinux_x86_64::ReadRegisterBytes(uint32_t reg, - DataExtractor &data) -{ - uint8_t *buf = reinterpret_cast(&user); - bool status; - - if (IsGPR(reg)) - status = ReadGPR(); - else if (IsFPR(reg)) - status = ReadFPR(); - else - { - assert(false && "invalid register number"); - status = false; - } - - if (status) - data.SetData(buf + GetRegOffset(reg), GetRegSize(reg), lldb::endian::InlHostByteOrder()); - - return status; -} - -#endif - -bool RegisterContextLinux_x86_64::ReadAllRegisterValues(DataBufferSP &data_sp) { return false; } -#if 0 bool -RegisterContextLinux_x86_64::WriteRegisterValue(uint32_t reg, - const Scalar &value) +RegisterContextLinux_x86_64::WriteRegister(const lldb_private::RegisterInfo *reg_info, + const lldb_private::RegisterValue &value) { + const uint32_t reg = reg_info->kinds[eRegisterKindLLDB]; ProcessMonitor &monitor = GetMonitor(); return monitor.WriteRegisterValue(GetRegOffset(reg), value); } bool -RegisterContextLinux_x86_64::WriteRegisterBytes(uint32_t reg, - DataExtractor &data, - uint32_t data_offset) -{ - return false; -} -#endif - -bool RegisterContextLinux_x86_64::WriteAllRegisterValues(const DataBufferSP &data) { return false; diff --git a/source/Plugins/Process/Linux/RegisterContextLinux_x86_64.h b/source/Plugins/Process/Linux/RegisterContextLinux_x86_64.h index 2d210c6..d288d53 100644 --- a/source/Plugins/Process/Linux/RegisterContextLinux_x86_64.h +++ b/source/Plugins/Process/Linux/RegisterContextLinux_x86_64.h @@ -41,14 +41,6 @@ public: const lldb_private::RegisterSet * GetRegisterSet(uint32_t set); -#if 0 - bool - ReadRegisterValue(uint32_t reg, lldb_private::Scalar &value); - - bool - ReadRegisterBytes(uint32_t reg, lldb_private::DataExtractor &data); -#endif - virtual bool ReadRegister(const lldb_private::RegisterInfo *reg_info, lldb_private::RegisterValue &value); @@ -56,15 +48,6 @@ public: bool ReadAllRegisterValues(lldb::DataBufferSP &data_sp); -#if 0 - bool - WriteRegisterValue(uint32_t reg, const lldb_private::Scalar &value); - - bool - WriteRegisterBytes(uint32_t reg, lldb_private::DataExtractor &data, - uint32_t data_offset = 0); -#endif - virtual bool WriteRegister(const lldb_private::RegisterInfo *reg_info, const lldb_private::RegisterValue &value); -- 1.7.3.4 From mminutoli at gmail.com Thu May 19 16:41:32 2011 From: mminutoli at gmail.com (Marco Minutoli) Date: Thu, 19 May 2011 23:41:32 +0200 Subject: [Lldb-commits] [PATCH 3/3] python-config in Makefiles In-Reply-To: <1305841292-24335-1-git-send-email-mminutoli@gmail.com> References: <1305841292-24335-1-git-send-email-mminutoli@gmail.com> Message-ID: <1305841292-24335-4-git-send-email-mminutoli@gmail.com> Replace python static settings of compiler flags with invocation of python-config. --- Makefile | 4 ++-- lib/Makefile | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index fc090a8..bd22515 100644 --- a/Makefile +++ b/Makefile @@ -29,14 +29,14 @@ LEVEL := $(LLDB_LEVEL)/../.. include $(LEVEL)/Makefile.common # Set Python include directory -PYTHON_INC_DIR = /usr/include/python2.7 +PYTHON_INC_DIR = $(shell python-config --includes) # Set common LLDB build flags. CPP.Flags += -I$(PROJ_SRC_DIR)/$(LLDB_LEVEL)/include CPP.Flags += -I$(PROJ_OBJ_DIR)/$(LLDB_LEVEL)/include CPP.Flags += -I$(PROJ_SRC_DIR)/$(LLDB_LEVEL)/../clang/include CPP.Flags += -I$(PROJ_OBJ_DIR)/$(LLDB_LEVEL)/../clang/include -CPP.Flags += -I$(PYTHON_INC_DIR) +CPP.Flags += $(PYTHON_INC_DIR) CPP.Flags += -I$(PROJ_SRC_DIR)/$(LLDB_LEVEL)/source CPP.Flags += -I$(PROJ_SRC_DIR)/$(LLDB_LEVEL)/source/Utility CPP.Flags += -I$(PROJ_SRC_DIR)/$(LLDB_LEVEL)/source/Plugins/Process/Utility diff --git a/lib/Makefile b/lib/Makefile index 66efb32..8328863 100644 --- a/lib/Makefile +++ b/lib/Makefile @@ -17,7 +17,7 @@ NO_BUILD_ARCHIVE = 1 LINK_LIBS_IN_SHARED = 1 SHARED_LIBRARY = 1 -PYTHON_BUILD_FLAGS = -lpython2.6 +PYTHON_BUILD_FLAGS = $(shell python-config --ldflags) # Include all archives in liblldb.a files USEDLIBS = lldbAPI.a \ -- 1.7.3.4 From cdavis at mines.edu Thu May 19 16:59:12 2011 From: cdavis at mines.edu (Charles Davis) Date: Thu, 19 May 2011 21:59:12 -0000 Subject: [Lldb-commits] [lldb] r131684 - in /lldb/trunk/source/Plugins: ABI/MacOSX-i386/ABIMacOSX_i386.h LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTrampolineHandler.h Message-ID: <20110519215912.657002A6C12C@llvm.org> Author: cdavis Date: Thu May 19 16:59:12 2011 New Revision: 131684 URL: http://llvm.org/viewvc/llvm-project?rev=131684&view=rev Log: Fix trailing commas at the end of enumerator lists. Seriously, I have no idea how you guys managed to build LLDB before. Modified: lldb/trunk/source/Plugins/ABI/MacOSX-i386/ABIMacOSX_i386.h lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTrampolineHandler.h Modified: lldb/trunk/source/Plugins/ABI/MacOSX-i386/ABIMacOSX_i386.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ABI/MacOSX-i386/ABIMacOSX_i386.h?rev=131684&r1=131683&r2=131684&view=diff ============================================================================== --- lldb/trunk/source/Plugins/ABI/MacOSX-i386/ABIMacOSX_i386.h (original) +++ lldb/trunk/source/Plugins/ABI/MacOSX-i386/ABIMacOSX_i386.h Thu May 19 16:59:12 2011 @@ -72,7 +72,7 @@ dwarf_ymm4 = dwarf_xmm4, dwarf_ymm5 = dwarf_xmm5, dwarf_ymm6 = dwarf_xmm6, - dwarf_ymm7 = dwarf_xmm7, + dwarf_ymm7 = dwarf_xmm7 }; enum Modified: lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTrampolineHandler.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTrampolineHandler.h?rev=131684&r1=131683&r2=131684&view=diff ============================================================================== --- lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTrampolineHandler.h (original) +++ lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTrampolineHandler.h Thu May 19 16:59:12 2011 @@ -74,7 +74,7 @@ { eOBJC_TRAMPOLINE_MESSAGE = (1<<0), // trampoline acts like objc_msgSend eOBJC_TRAMPOLINE_STRET = (1<<1), // trampoline is struct-returning - eOBJC_TRAMPOLINE_VTABLE = (1<<2), // trampoline is vtable dispatcher + eOBJC_TRAMPOLINE_VTABLE = (1<<2) // trampoline is vtable dispatcher }; private: From johnny.chen at apple.com Thu May 19 18:07:19 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Thu, 19 May 2011 23:07:19 -0000 Subject: [Lldb-commits] [lldb] r131695 - in /lldb/trunk/source: Host/linux/Host.cpp Plugins/DynamicLoader/Linux-DYLD/DynamicLoaderLinuxDYLD.cpp Utility/ARM_DWARF_Registers.cpp Message-ID: <20110519230719.BD8882A6C12C@llvm.org> Author: johnny Date: Thu May 19 18:07:19 2011 New Revision: 131695 URL: http://llvm.org/viewvc/llvm-project?rev=131695&view=rev Log: API fix and missing headers. Host.cpp was missing Error.h and the implementation of LaunchProcess. Once againg I have added a "fake" implementation waiting for a real one. Fixed the call GetAddressRange to reflect the new interface in DynamicLoaderLinuxDYLD.cpp. Added string.h to ARM_DWARF_Registers.cpp that is needed for ::memset. Signed-off-by: Johnny Chen Modified: lldb/trunk/source/Host/linux/Host.cpp lldb/trunk/source/Plugins/DynamicLoader/Linux-DYLD/DynamicLoaderLinuxDYLD.cpp lldb/trunk/source/Utility/ARM_DWARF_Registers.cpp Modified: lldb/trunk/source/Host/linux/Host.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/linux/Host.cpp?rev=131695&r1=131694&r2=131695&view=diff ============================================================================== --- lldb/trunk/source/Host/linux/Host.cpp (original) +++ lldb/trunk/source/Host/linux/Host.cpp Thu May 19 18:07:19 2011 @@ -14,6 +14,7 @@ // C++ Includes // Other libraries and framework includes // Project includes +#include "lldb/Core/Error.h" #include "lldb/Host/Host.h" using namespace lldb; @@ -33,3 +34,12 @@ status = sscanf(un.release, "%u.%u.%u", &major, &minor, &update); return status == 3; } + +Error +Host::LaunchProcess (ProcessLaunchInfo &launch_info) +{ + Error error; + assert(!"Not implemented yet!!!"); + return error; +} + Modified: lldb/trunk/source/Plugins/DynamicLoader/Linux-DYLD/DynamicLoaderLinuxDYLD.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/DynamicLoader/Linux-DYLD/DynamicLoaderLinuxDYLD.cpp?rev=131695&r1=131694&r2=131695&view=diff ============================================================================== --- lldb/trunk/source/Plugins/DynamicLoader/Linux-DYLD/DynamicLoaderLinuxDYLD.cpp (original) +++ lldb/trunk/source/Plugins/DynamicLoader/Linux-DYLD/DynamicLoaderLinuxDYLD.cpp Thu May 19 18:07:19 2011 @@ -321,7 +321,7 @@ AddressRange range; if (target_symbols.GetContextAtIndex(i, context)) { - context.GetAddressRange(eSymbolContextEverything, range); + context.GetAddressRange(eSymbolContextEverything, 0, false, range); lldb::addr_t addr = range.GetBaseAddress().GetLoadAddress(&target); if (addr != LLDB_INVALID_ADDRESS) addrs.push_back(addr); Modified: lldb/trunk/source/Utility/ARM_DWARF_Registers.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Utility/ARM_DWARF_Registers.cpp?rev=131695&r1=131694&r2=131695&view=diff ============================================================================== --- lldb/trunk/source/Utility/ARM_DWARF_Registers.cpp (original) +++ lldb/trunk/source/Utility/ARM_DWARF_Registers.cpp Thu May 19 18:07:19 2011 @@ -10,6 +10,8 @@ #include "ARM_DWARF_Registers.h" #include +#include + using namespace lldb; using namespace lldb_private; From johnny.chen at apple.com Thu May 19 18:08:42 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Thu, 19 May 2011 23:08:42 -0000 Subject: [Lldb-commits] [lldb] r131696 - in /lldb/trunk/source/Plugins/Process/Linux: RegisterContextLinux_i386.cpp RegisterContextLinux_x86_64.cpp RegisterContextLinux_x86_64.h Message-ID: <20110519230842.312BB2A6C12C@llvm.org> Author: johnny Date: Thu May 19 18:08:41 2011 New Revision: 131696 URL: http://llvm.org/viewvc/llvm-project?rev=131696&view=rev Log: A bit of clean up. Removed ifdeffed out functions and added the implementation of WriteRegister for x86_64 architecture. Signed-off-by: Johnny Chen Modified: lldb/trunk/source/Plugins/Process/Linux/RegisterContextLinux_i386.cpp 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/RegisterContextLinux_i386.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Linux/RegisterContextLinux_i386.cpp?rev=131696&r1=131695&r2=131696&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Process/Linux/RegisterContextLinux_i386.cpp (original) +++ lldb/trunk/source/Plugins/Process/Linux/RegisterContextLinux_i386.cpp Thu May 19 18:08:41 2011 @@ -419,71 +419,18 @@ return monitor.ReadRegisterValue(GetRegOffset(reg), value); } -#if 0 - -bool -RegisterContextLinux_i386::ReadRegisterValue(uint32_t reg, - Scalar &value) -{ - ProcessMonitor &monitor = GetMonitor(); - return monitor.ReadRegisterValue(GetRegOffset(reg), value); -} - -bool -RegisterContextLinux_i386::ReadRegisterBytes(uint32_t reg, - DataExtractor &data) -{ - uint8_t *buf = reinterpret_cast(&user); - bool status; - - if (IsGPR(reg)) - status = ReadGPR(); - else if (IsFPR(reg)) - status = ReadFPR(); - else - { - assert(false && "invalid register number"); - status = false; - } - - if (status) - data.SetData(buf + GetRegOffset(reg), GetRegSize(reg), lldb::endian::InlHostByteOrder()); - - return status; -} - -#endif - bool RegisterContextLinux_i386::ReadAllRegisterValues(DataBufferSP &data_sp) { return false; } -#if 0 - -bool -RegisterContextLinux_i386::WriteRegisterValue(uint32_t reg, - const Scalar &value) -{ - ProcessMonitor &monitor = GetMonitor(); - return monitor.WriteRegisterValue(GetRegOffset(reg), value); -} - -bool -RegisterContextLinux_i386::WriteRegisterBytes(uint32_t reg, - DataExtractor &data, - uint32_t data_offset) -{ - return false; -} - -#endif - bool RegisterContextLinux_i386::WriteRegister(const RegisterInfo *reg_info, const RegisterValue &value) { - return false; + const uint32_t reg = reg_info->kinds[eRegisterKindLLDB]; + ProcessMonitor &monitor = GetMonitor(); + return monitor.WriteRegisterValue(GetRegOffset(reg), value); } 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=131696&r1=131695&r2=131696&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Process/Linux/RegisterContextLinux_x86_64.cpp (original) +++ lldb/trunk/source/Plugins/Process/Linux/RegisterContextLinux_x86_64.cpp Thu May 19 18:08:41 2011 @@ -475,65 +475,31 @@ return NULL; } -#if 0 bool -RegisterContextLinux_x86_64::ReadRegisterValue(uint32_t reg, - Scalar &value) +RegisterContextLinux_x86_64::ReadRegister(const RegisterInfo *reg_info, + RegisterValue &value) { + const uint32_t reg = reg_info->kinds[eRegisterKindLLDB]; ProcessMonitor &monitor = GetMonitor(); return monitor.ReadRegisterValue(GetRegOffset(reg), value); } bool -RegisterContextLinux_x86_64::ReadRegisterBytes(uint32_t reg, - DataExtractor &data) -{ - uint8_t *buf = reinterpret_cast(&user); - bool status; - - if (IsGPR(reg)) - status = ReadGPR(); - else if (IsFPR(reg)) - status = ReadFPR(); - else - { - assert(false && "invalid register number"); - status = false; - } - - if (status) - data.SetData(buf + GetRegOffset(reg), GetRegSize(reg), lldb::endian::InlHostByteOrder()); - - return status; -} - -#endif - -bool RegisterContextLinux_x86_64::ReadAllRegisterValues(DataBufferSP &data_sp) { return false; } -#if 0 bool -RegisterContextLinux_x86_64::WriteRegisterValue(uint32_t reg, - const Scalar &value) +RegisterContextLinux_x86_64::WriteRegister(const lldb_private::RegisterInfo *reg_info, + const lldb_private::RegisterValue &value) { + const uint32_t reg = reg_info->kinds[eRegisterKindLLDB]; ProcessMonitor &monitor = GetMonitor(); return monitor.WriteRegisterValue(GetRegOffset(reg), value); } bool -RegisterContextLinux_x86_64::WriteRegisterBytes(uint32_t reg, - DataExtractor &data, - uint32_t data_offset) -{ - return false; -} -#endif - -bool RegisterContextLinux_x86_64::WriteAllRegisterValues(const DataBufferSP &data) { return false; 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=131696&r1=131695&r2=131696&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Process/Linux/RegisterContextLinux_x86_64.h (original) +++ lldb/trunk/source/Plugins/Process/Linux/RegisterContextLinux_x86_64.h Thu May 19 18:08:41 2011 @@ -41,14 +41,6 @@ const lldb_private::RegisterSet * GetRegisterSet(uint32_t set); -#if 0 - bool - ReadRegisterValue(uint32_t reg, lldb_private::Scalar &value); - - bool - ReadRegisterBytes(uint32_t reg, lldb_private::DataExtractor &data); -#endif - virtual bool ReadRegister(const lldb_private::RegisterInfo *reg_info, lldb_private::RegisterValue &value); @@ -56,15 +48,6 @@ bool ReadAllRegisterValues(lldb::DataBufferSP &data_sp); -#if 0 - bool - WriteRegisterValue(uint32_t reg, const lldb_private::Scalar &value); - - bool - WriteRegisterBytes(uint32_t reg, lldb_private::DataExtractor &data, - uint32_t data_offset = 0); -#endif - virtual bool WriteRegister(const lldb_private::RegisterInfo *reg_info, const lldb_private::RegisterValue &value); From johnny.chen at apple.com Thu May 19 18:09:48 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Thu, 19 May 2011 23:09:48 -0000 Subject: [Lldb-commits] [lldb] r131697 - in /lldb/trunk: Makefile lib/Makefile Message-ID: <20110519230948.B2DA82A6C12C@llvm.org> Author: johnny Date: Thu May 19 18:09:48 2011 New Revision: 131697 URL: http://llvm.org/viewvc/llvm-project?rev=131697&view=rev Log: python-config in Makefiles Replace python static settings of compiler flags with invocation of python-config. Signed-off-by: Johnny Chen Modified: lldb/trunk/Makefile lldb/trunk/lib/Makefile Modified: lldb/trunk/Makefile URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/Makefile?rev=131697&r1=131696&r2=131697&view=diff ============================================================================== --- lldb/trunk/Makefile (original) +++ lldb/trunk/Makefile Thu May 19 18:09:48 2011 @@ -29,14 +29,14 @@ include $(LEVEL)/Makefile.common # Set Python include directory -PYTHON_INC_DIR = /usr/include/python2.7 +PYTHON_INC_DIR = $(shell python-config --includes) # Set common LLDB build flags. CPP.Flags += -I$(PROJ_SRC_DIR)/$(LLDB_LEVEL)/include CPP.Flags += -I$(PROJ_OBJ_DIR)/$(LLDB_LEVEL)/include CPP.Flags += -I$(PROJ_SRC_DIR)/$(LLDB_LEVEL)/../clang/include CPP.Flags += -I$(PROJ_OBJ_DIR)/$(LLDB_LEVEL)/../clang/include -CPP.Flags += -I$(PYTHON_INC_DIR) +CPP.Flags += $(PYTHON_INC_DIR) CPP.Flags += -I$(PROJ_SRC_DIR)/$(LLDB_LEVEL)/source CPP.Flags += -I$(PROJ_SRC_DIR)/$(LLDB_LEVEL)/source/Utility CPP.Flags += -I$(PROJ_SRC_DIR)/$(LLDB_LEVEL)/source/Plugins/Process/Utility Modified: lldb/trunk/lib/Makefile URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/lib/Makefile?rev=131697&r1=131696&r2=131697&view=diff ============================================================================== --- lldb/trunk/lib/Makefile (original) +++ lldb/trunk/lib/Makefile Thu May 19 18:09:48 2011 @@ -17,7 +17,7 @@ LINK_LIBS_IN_SHARED = 1 SHARED_LIBRARY = 1 -PYTHON_BUILD_FLAGS = -lpython2.6 +PYTHON_BUILD_FLAGS = $(shell python-config --ldflags) # Include all archives in liblldb.a files USEDLIBS = lldbAPI.a \ From cdavis at mines.edu Thu May 19 18:33:46 2011 From: cdavis at mines.edu (Charles Davis) Date: Thu, 19 May 2011 23:33:46 -0000 Subject: [Lldb-commits] [lldb] r131698 - /lldb/trunk/source/Symbol/ClangASTContext.cpp Message-ID: <20110519233346.D71DA2A6C12C@llvm.org> Author: cdavis Date: Thu May 19 18:33:46 2011 New Revision: 131698 URL: http://llvm.org/viewvc/llvm-project?rev=131698&view=rev Log: Use a SmallVector here instead of a VLA. 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=131698&r1=131697&r2=131698&view=diff ============================================================================== --- lldb/trunk/source/Symbol/ClangASTContext.cpp (original) +++ lldb/trunk/source/Symbol/ClangASTContext.cpp Thu May 19 18:33:46 2011 @@ -1481,25 +1481,25 @@ // Populate the method decl with parameter decls - ParmVarDecl *params[num_params]; + llvm::SmallVector params; for (int param_index = 0; param_index < num_params; ++param_index) { - params[param_index] = ParmVarDecl::Create (*ast, - cxx_method_decl, - SourceLocation(), - SourceLocation(), - NULL, // anonymous - method_function_prototype->getArgType(param_index), - NULL, - SC_None, - SC_None, - NULL); + params.push_back (ParmVarDecl::Create (*ast, + cxx_method_decl, + SourceLocation(), + SourceLocation(), + NULL, // anonymous + method_function_prototype->getArgType(param_index), + NULL, + SC_None, + SC_None, + NULL)); } - cxx_method_decl->setParams (params, num_params); + cxx_method_decl->setParams (params.data(), num_params); cxx_record_decl->addDecl (cxx_method_decl); From cdavis at mines.edu Thu May 19 18:37:13 2011 From: cdavis at mines.edu (Charles Davis) Date: Thu, 19 May 2011 23:37:13 -0000 Subject: [Lldb-commits] [lldb] r131699 - /lldb/trunk/include/lldb/Expression/ClangExpressionVariable.h Message-ID: <20110519233713.32D4E2A6C12C@llvm.org> Author: cdavis Date: Thu May 19 18:37:13 2011 New Revision: 131699 URL: http://llvm.org/viewvc/llvm-project?rev=131699&view=rev Log: Fix a tag type mismatch (i.e. class vs. struct) warning. Modified: lldb/trunk/include/lldb/Expression/ClangExpressionVariable.h Modified: lldb/trunk/include/lldb/Expression/ClangExpressionVariable.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Expression/ClangExpressionVariable.h?rev=131699&r1=131698&r2=131699&view=diff ============================================================================== --- lldb/trunk/include/lldb/Expression/ClangExpressionVariable.h (original) +++ lldb/trunk/include/lldb/Expression/ClangExpressionVariable.h Thu May 19 18:37:13 2011 @@ -156,7 +156,7 @@ EnableJITVars() { if (!m_jit_vars.get()) - m_jit_vars.reset(new struct JITVars); + m_jit_vars.reset(new JITVars); } //---------------------------------------------------------------------- From cdavis at mines.edu Thu May 19 18:44:09 2011 From: cdavis at mines.edu (Charles Davis) Date: Thu, 19 May 2011 23:44:09 -0000 Subject: [Lldb-commits] [lldb] r131704 - in /lldb/trunk/source/Plugins: LanguageRuntime/CPlusPlus/ItaniumABI/Makefile LanguageRuntime/ObjC/AppleObjCRuntime/Makefile Makefile Message-ID: <20110519234409.717182A6C12C@llvm.org> Author: cdavis Date: Thu May 19 18:44:09 2011 New Revision: 131704 URL: http://llvm.org/viewvc/llvm-project?rev=131704&view=rev Log: Add the LanguageRuntime plugins to the makefile build, and remove the Mac OS X Process plugin from the build. I'm surprised no one caught this earlier. Am I the only one who builds with the makefiles on Mac? Added: lldb/trunk/source/Plugins/LanguageRuntime/CPlusPlus/ItaniumABI/Makefile lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/Makefile Modified: lldb/trunk/source/Plugins/Makefile Added: lldb/trunk/source/Plugins/LanguageRuntime/CPlusPlus/ItaniumABI/Makefile URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/LanguageRuntime/CPlusPlus/ItaniumABI/Makefile?rev=131704&view=auto ============================================================================== --- lldb/trunk/source/Plugins/LanguageRuntime/CPlusPlus/ItaniumABI/Makefile (added) +++ lldb/trunk/source/Plugins/LanguageRuntime/CPlusPlus/ItaniumABI/Makefile Thu May 19 18:44:09 2011 @@ -0,0 +1,14 @@ +##===- source/Plugins/LangRuntime/C++/ItaniumABI/Makefile --*- Makefile -*-===## +# +# The LLVM Compiler Infrastructure +# +# This file is distributed under the University of Illinois Open Source +# License. See LICENSE.TXT for details. +# +##===----------------------------------------------------------------------===## + +LLDB_LEVEL := ../../../../.. +LIBRARYNAME := lldbPluginLanguageRuntimeCPlusPlusItaniumABI +BUILD_ARCHIVE = 1 + +include $(LLDB_LEVEL)/Makefile Added: lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/Makefile URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/Makefile?rev=131704&view=auto ============================================================================== --- lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/Makefile (added) +++ lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/Makefile Thu May 19 18:44:09 2011 @@ -0,0 +1,14 @@ +##===- source/Plugins/LangRuntime/ObjC/AppleRT/Makefile ----*- Makefile -*-===## +# +# The LLVM Compiler Infrastructure +# +# This file is distributed under the University of Illinois Open Source +# License. See LICENSE.TXT for details. +# +##===----------------------------------------------------------------------===## + +LLDB_LEVEL := ../../../../.. +LIBRARYNAME := lldbPluginLanguageRuntimeObjCAppleObjCRuntime +BUILD_ARCHIVE = 1 + +include $(LLDB_LEVEL)/Makefile Modified: lldb/trunk/source/Plugins/Makefile URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Makefile?rev=131704&r1=131703&r2=131704&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Makefile (original) +++ lldb/trunk/source/Plugins/Makefile Thu May 19 18:44:09 2011 @@ -16,11 +16,14 @@ ObjectContainer/BSD-Archive ObjectFile/ELF SymbolFile/DWARF \ SymbolFile/Symtab Process/Utility DynamicLoader/Static \ Platform Process/gdb-remote Instruction/ARM \ - UnwindAssembly/InstEmulation UnwindAssembly/x86 + UnwindAssembly/InstEmulation UnwindAssembly/x86 \ + LanguageRuntime/CPlusPlus/ItaniumABI \ + LanguageRuntime/ObjC/AppleObjCRuntime ifeq ($(HOST_OS),Darwin) DIRS += DynamicLoader/MacOSX-DYLD ObjectContainer/Universal-Mach-O \ - ObjectFile/Mach-O SymbolVendor/MacOSX Process/MacOSX-User + ObjectFile/Mach-O SymbolVendor/MacOSX +#DIRS += Process/MacOSX-User endif ifeq ($(HOST_OS),Linux) From cdavis at mines.edu Thu May 19 18:53:23 2011 From: cdavis at mines.edu (Charles Davis) Date: Thu, 19 May 2011 23:53:23 -0000 Subject: [Lldb-commits] [lldb] r131707 - /lldb/trunk/lib/Makefile Message-ID: <20110519235324.01A342A6C12C@llvm.org> Author: cdavis Date: Thu May 19 18:53:23 2011 New Revision: 131707 URL: http://llvm.org/viewvc/llvm-project?rev=131707&view=rev Log: Add the LanguageRuntime plugins to liblldb. Fixes link errors for me; if this breaks it for you (or if the LanguageRuntime plugins break the build on your machine), please let me know and I'll revert. Also, link to CoreServices and Carbon on Mac. Yep, LLDB needs these ancient frameworks. Modified: lldb/trunk/lib/Makefile Modified: lldb/trunk/lib/Makefile URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/lib/Makefile?rev=131707&r1=131706&r2=131707&view=diff ============================================================================== --- lldb/trunk/lib/Makefile (original) +++ lldb/trunk/lib/Makefile Thu May 19 18:53:23 2011 @@ -34,6 +34,8 @@ lldbPluginDisassemblerLLVM.a \ lldbPluginDynamicLoaderStatic.a \ lldbPluginEmulateInstructionARM.a \ + lldbPluginLanguageRuntimeCPlusPlusItaniumABI.a \ + lldbPluginLanguageRuntimeObjCAppleObjCRuntime.a \ lldbPluginObjectContainerBSDArchive.a \ lldbPluginObjectFileELF.a \ lldbPluginPlatformGDBServer.a \ @@ -63,7 +65,7 @@ include $(LLDB_LEVEL)/../../Makefile.config LINK_COMPONENTS := $(TARGETS_TO_BUILD) asmparser bitreader bitwriter codegen \ - ipo selectiondag jit mc instrumentation + instrumentation ipo selectiondag jit mc ifeq ($(HOST_OS),Darwin) USEDLIBS += lldbHostMacOSX.a \ @@ -94,7 +96,8 @@ # extra options to override libtool defaults LLVMLibsOptions += -avoid-version LLVMLibsOptions += -F/System/Library/Frameworks -F/System/Library/PrivateFrameworks - LLVMLibsOptions += -framework Foundation -framework CoreFoundation + LLVMLibsOptions += -framework Foundation -framework CoreFoundation + LLVMLibsOptions += -framework CoreServices -framework Carbon LLVMLibsOptions += -framework DebugSymbols $(PYTHON_BUILD_FLAGS) -lobjc LLVMLibsOptions += -Wl,-exported_symbols_list -Wl,"$(PROJ_SRC_DIR)/$(LLDB_LEVEL)/resources/lldb-framework-exports" # Mac OS X 10.4 and earlier tools do not allow a second -install_name on command line From cdavis at mymail.mines.edu Thu May 19 19:05:40 2011 From: cdavis at mymail.mines.edu (Charles Davis) Date: Thu, 19 May 2011 18:05:40 -0600 Subject: [Lldb-commits] [PATCH] Assorted build fixes In-Reply-To: <4DD172E6.3090906@mymail.mines.edu> References: <4DD172E6.3090906@mymail.mines.edu> Message-ID: <4DD5B054.3070904@mymail.mines.edu> On 5/16/11 12:54 PM, Charles Davis wrote: > Hi, > > This patch fixes some issues I encountered building with the Makefiles > on Darwin (which were preventing me from finishing builds without > disabling lldb support): OK, since no one has said anything, I went ahead and committed some of my build fixes (subject to post-commit review). I still haven't, however, committed the Host/macosx build fixes yet. I also made the makefiles install the python modules. I haven't committed these because they seem somewhat hackish. I've posted the patch for both here, and this time I want someone to actually review the patch. I'm not going to commit either one of these until I get feedback. I reiterate: I will not commit the changes in the attached patch until someone reviews them. Chip -------------- next part -------------- An embedded and charset-unspecified text was scrubbed... Name: build-fixes.patch Url: http://lists.cs.uiuc.edu/pipermail/lldb-commits/attachments/20110519/59759a44/attachment-0001.pl From gclayton at apple.com Thu May 19 21:00:47 2011 From: gclayton at apple.com (Greg Clayton) Date: Fri, 20 May 2011 02:00:47 -0000 Subject: [Lldb-commits] [lldb] r131713 - /lldb/trunk/scripts/disasm-gdb-remote.pl Message-ID: <20110520020047.CFBF82A6C12C@llvm.org> Author: gclayton Date: Thu May 19 21:00:47 2011 New Revision: 131713 URL: http://llvm.org/viewvc/llvm-project?rev=131713&view=rev Log: Added a perl script to disassemble, into human readable form, the GDB remote packet output from "log enable gdb-remote packets". This should help people track down and see what is going wrong more easily when you have log output that includes GDB remote packets. Added: lldb/trunk/scripts/disasm-gdb-remote.pl (with props) Added: lldb/trunk/scripts/disasm-gdb-remote.pl URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/scripts/disasm-gdb-remote.pl?rev=131713&view=auto ============================================================================== --- lldb/trunk/scripts/disasm-gdb-remote.pl (added) +++ lldb/trunk/scripts/disasm-gdb-remote.pl Thu May 19 21:00:47 2011 @@ -0,0 +1,1897 @@ +#!/usr/bin/perl + +use strict; + +#---------------------------------------------------------------------- +# Globals +#---------------------------------------------------------------------- +our $unsupported_str = "UNSUPPORTED"; +our $success_str = "OK"; +our $swap = 1; +our $addr_size = 4; +our $thread_suffix_supported = 0; +our $max_bytes_per_line = 32; +our $addr_format = sprintf("0x%%%u.%ux", $addr_size*2, $addr_size*2); +our $pid_format = "%04.4x"; +our $tid_format = "%04.4x"; +our $reg8_href = { extract => \&get8, format => "0x%2.2x" }; +our $reg16_href = { extract => \&get16, format => "0x%4.4x" }; +our $reg32_href = { extract => \&get32, format => "0x%8.8x" }; +our $reg64_href = { extract => \&get64, format => "0x%s" }; +our $reg80_href = { extract => \&get80, format => "0x%s" }; +our $reg128_href = { extract => \&get128, format => "0x%s" }; +our $float32_href = { extract => \&get32, format => "0x%8.8x" }; +our $float64_href = { extract => \&get64, format => "0x%s" }; +our $float96_href = { extract => \&get96, format => "0x%s" }; +our $curr_cmd = undef; +our $reg_cmd_reg; +our %reg_map = ( + 'i386-gdb' => [ + { name => 'eax', info => $reg32_href }, + { name => 'ecx', info => $reg32_href }, + { name => 'edx', info => $reg32_href }, + { name => 'ebx', info => $reg32_href }, + { name => 'esp', info => $reg32_href }, + { name => 'ebp', info => $reg32_href }, + { name => 'esi', info => $reg32_href }, + { name => 'edi', info => $reg32_href }, + { name => 'eip', info => $reg32_href }, + { name => 'eflags', info => $reg32_href }, + { name => 'cs', info => $reg32_href }, + { name => 'ss', info => $reg32_href }, + { name => 'ds', info => $reg32_href }, + { name => 'es', info => $reg32_href }, + { name => 'fs', info => $reg32_href }, + { name => 'gs', info => $reg32_href }, + { name => 'st0', info => $reg80_href }, + { name => 'st1', info => $reg80_href }, + { name => 'st2', info => $reg80_href }, + { name => 'st3', info => $reg80_href }, + { name => 'st4', info => $reg80_href }, + { name => 'st5', info => $reg80_href }, + { name => 'st6', info => $reg80_href }, + { name => 'st7', info => $reg80_href }, + { name => 'fctrl', info => $reg32_href }, + { name => 'fstat', info => $reg32_href }, + { name => 'ftag', info => $reg32_href }, + { name => 'fiseg', info => $reg32_href }, + { name => 'fioff', info => $reg32_href }, + { name => 'foseg', info => $reg32_href }, + { name => 'fooff', info => $reg32_href }, + { name => 'fop', info => $reg32_href }, + { name => 'xmm0', info => $reg128_href }, + { name => 'xmm1', info => $reg128_href }, + { name => 'xmm2', info => $reg128_href }, + { name => 'xmm3', info => $reg128_href }, + { name => 'xmm4', info => $reg128_href }, + { name => 'xmm5', info => $reg128_href }, + { name => 'xmm6', info => $reg128_href }, + { name => 'xmm7', info => $reg128_href }, + { name => 'mxcsr', info => $reg32_href }, + { name => 'mm0', info => $reg64_href }, + { name => 'mm1', info => $reg64_href }, + { name => 'mm2', info => $reg64_href }, + { name => 'mm3', info => $reg64_href }, + { name => 'mm4', info => $reg64_href }, + { name => 'mm5', info => $reg64_href }, + { name => 'mm6', info => $reg64_href }, + { name => 'mm7', info => $reg64_href }, + ], + + 'i386-lldb' => [ + { name => 'eax', info => $reg32_href }, + { name => 'ebx', info => $reg32_href }, + { name => 'ecx', info => $reg32_href }, + { name => 'edx', info => $reg32_href }, + { name => 'edi', info => $reg32_href }, + { name => 'esi', info => $reg32_href }, + { name => 'ebp', info => $reg32_href }, + { name => 'esp', info => $reg32_href }, + { name => 'ss', info => $reg32_href }, + { name => 'eflags', info => $reg32_href }, + { name => 'eip', info => $reg32_href }, + { name => 'cs', info => $reg32_href }, + { name => 'ds', info => $reg32_href }, + { name => 'es', info => $reg32_href }, + { name => 'fs', info => $reg32_href }, + { name => 'gs', info => $reg32_href }, + { name => 'fctrl', info => $reg16_href }, + { name => 'fstat', info => $reg16_href }, + { name => 'ftag', info => $reg8_href }, + { name => 'fop', info => $reg16_href }, + { name => 'fioff', info => $reg32_href }, + { name => 'fiseg', info => $reg16_href }, + { name => 'fooff', info => $reg32_href }, + { name => 'foseg', info => $reg16_href }, + { name => 'mxcsr', info => $reg32_href }, + { name => 'mxcsrmask', info => $reg32_href }, + { name => 'stmm0', info => $reg80_href }, + { name => 'stmm1', info => $reg80_href }, + { name => 'stmm2', info => $reg80_href }, + { name => 'stmm3', info => $reg80_href }, + { name => 'stmm4', info => $reg80_href }, + { name => 'stmm5', info => $reg80_href }, + { name => 'stmm6', info => $reg80_href }, + { name => 'stmm7', info => $reg80_href }, + { name => 'xmm0', info => $reg128_href }, + { name => 'xmm1', info => $reg128_href }, + { name => 'xmm2', info => $reg128_href }, + { name => 'xmm3', info => $reg128_href }, + { name => 'xmm4', info => $reg128_href }, + { name => 'xmm5', info => $reg128_href }, + { name => 'xmm6', info => $reg128_href }, + { name => 'xmm7', info => $reg128_href }, + { name => 'trapno', info => $reg32_href }, + { name => 'err', info => $reg32_href }, + { name => 'faultvaddr', info => $reg32_href }, + ], + + 'arm-gdb' => [ + { name => 'r0' , info => $reg32_href }, + { name => 'r1' , info => $reg32_href }, + { name => 'r2' , info => $reg32_href }, + { name => 'r3' , info => $reg32_href }, + { name => 'r4' , info => $reg32_href }, + { name => 'r5' , info => $reg32_href }, + { name => 'r6' , info => $reg32_href }, + { name => 'r7' , info => $reg32_href }, + { name => 'r8' , info => $reg32_href }, + { name => 'r9' , info => $reg32_href }, + { name => 'r10' , info => $reg32_href }, + { name => 'r11' , info => $reg32_href }, + { name => 'r12' , info => $reg32_href }, + { name => 'sp' , info => $reg32_href }, + { name => 'lr' , info => $reg32_href }, + { name => 'pc' , info => $reg32_href }, + { name => 'f0' , info => $float96_href }, + { name => 'f1' , info => $float96_href }, + { name => 'f2' , info => $float96_href }, + { name => 'f3' , info => $float96_href }, + { name => 'f4' , info => $float96_href }, + { name => 'f5' , info => $float96_href }, + { name => 'f6' , info => $float96_href }, + { name => 'f7' , info => $float96_href }, + { name => 'fps' , info => $reg32_href }, + { name => 'cpsr' , info => $reg32_href }, + { name => 's0' , info => $float32_href }, + { name => 's1' , info => $float32_href }, + { name => 's2' , info => $float32_href }, + { name => 's3' , info => $float32_href }, + { name => 's4' , info => $float32_href }, + { name => 's5' , info => $float32_href }, + { name => 's6' , info => $float32_href }, + { name => 's7' , info => $float32_href }, + { name => 's8' , info => $float32_href }, + { name => 's9' , info => $float32_href }, + { name => 's10' , info => $float32_href }, + { name => 's11' , info => $float32_href }, + { name => 's12' , info => $float32_href }, + { name => 's13' , info => $float32_href }, + { name => 's14' , info => $float32_href }, + { name => 's15' , info => $float32_href }, + { name => 's16' , info => $float32_href }, + { name => 's17' , info => $float32_href }, + { name => 's18' , info => $float32_href }, + { name => 's19' , info => $float32_href }, + { name => 's20' , info => $float32_href }, + { name => 's21' , info => $float32_href }, + { name => 's22' , info => $float32_href }, + { name => 's23' , info => $float32_href }, + { name => 's24' , info => $float32_href }, + { name => 's25' , info => $float32_href }, + { name => 's26' , info => $float32_href }, + { name => 's27' , info => $float32_href }, + { name => 's28' , info => $float32_href }, + { name => 's29' , info => $float32_href }, + { name => 's30' , info => $float32_href }, + { name => 's31' , info => $float32_href }, + { name => 'fpscr' , info => $reg32_href }, + { name => 'd16' , info => $float64_href }, + { name => 'd17' , info => $float64_href }, + { name => 'd18' , info => $float64_href }, + { name => 'd19' , info => $float64_href }, + { name => 'd20' , info => $float64_href }, + { name => 'd21' , info => $float64_href }, + { name => 'd22' , info => $float64_href }, + { name => 'd23' , info => $float64_href }, + { name => 'd24' , info => $float64_href }, + { name => 'd25' , info => $float64_href }, + { name => 'd26' , info => $float64_href }, + { name => 'd27' , info => $float64_href }, + { name => 'd28' , info => $float64_href }, + { name => 'd29' , info => $float64_href }, + { name => 'd30' , info => $float64_href }, + { name => 'd31' , info => $float64_href }, + ], + + 'x86_64-gdb' => [ + { name => 'rax' , info => $reg64_href }, + { name => 'rbx' , info => $reg64_href }, + { name => 'rcx' , info => $reg64_href }, + { name => 'rdx' , info => $reg64_href }, + { name => 'rsi' , info => $reg64_href }, + { name => 'rdi' , info => $reg64_href }, + { name => 'rbp' , info => $reg64_href }, + { name => 'rsp' , info => $reg64_href }, + { name => 'r8' , info => $reg64_href }, + { name => 'r9' , info => $reg64_href }, + { name => 'r10' , info => $reg64_href }, + { name => 'r11' , info => $reg64_href }, + { name => 'r12' , info => $reg64_href }, + { name => 'r13' , info => $reg64_href }, + { name => 'r14' , info => $reg64_href }, + { name => 'r15' , info => $reg64_href }, + { name => 'rip' , info => $reg64_href }, + { name => 'eflags' , info => $reg32_href }, + { name => 'cs' , info => $reg32_href }, + { name => 'ss' , info => $reg32_href }, + { name => 'ds' , info => $reg32_href }, + { name => 'es' , info => $reg32_href }, + { name => 'fs' , info => $reg32_href }, + { name => 'gs' , info => $reg32_href }, + { name => 'stmm0' , info => $reg80_href }, + { name => 'stmm1' , info => $reg80_href }, + { name => 'stmm2' , info => $reg80_href }, + { name => 'stmm3' , info => $reg80_href }, + { name => 'stmm4' , info => $reg80_href }, + { name => 'stmm5' , info => $reg80_href }, + { name => 'stmm6' , info => $reg80_href }, + { name => 'stmm7' , info => $reg80_href }, + { name => 'fctrl' , info => $reg32_href }, + { name => 'fstat' , info => $reg32_href }, + { name => 'ftag' , info => $reg32_href }, + { name => 'fiseg' , info => $reg32_href }, + { name => 'fioff' , info => $reg32_href }, + { name => 'foseg' , info => $reg32_href }, + { name => 'fooff' , info => $reg32_href }, + { name => 'fop' , info => $reg32_href }, + { name => 'xmm0' , info => $reg128_href }, + { name => 'xmm1' , info => $reg128_href }, + { name => 'xmm2' , info => $reg128_href }, + { name => 'xmm3' , info => $reg128_href }, + { name => 'xmm4' , info => $reg128_href }, + { name => 'xmm5' , info => $reg128_href }, + { name => 'xmm6' , info => $reg128_href }, + { name => 'xmm7' , info => $reg128_href }, + { name => 'xmm8' , info => $reg128_href }, + { name => 'xmm9' , info => $reg128_href }, + { name => 'xmm10' , info => $reg128_href }, + { name => 'xmm11' , info => $reg128_href }, + { name => 'xmm12' , info => $reg128_href }, + { name => 'xmm13' , info => $reg128_href }, + { name => 'xmm14' , info => $reg128_href }, + { name => 'xmm15' , info => $reg128_href }, + { name => 'mxcsr' , info => $reg32_href }, + ], + + 'x86_64-lldb' => [ + { name => 'rax' , info => $reg64_href }, + { name => 'rbx' , info => $reg64_href }, + { name => 'rcx' , info => $reg64_href }, + { name => 'rdx' , info => $reg64_href }, + { name => 'rdi' , info => $reg64_href }, + { name => 'rsi' , info => $reg64_href }, + { name => 'rbp' , info => $reg64_href }, + { name => 'rsp' , info => $reg64_href }, + { name => 'r8 ' , info => $reg64_href }, + { name => 'r9 ' , info => $reg64_href }, + { name => 'r10' , info => $reg64_href }, + { name => 'r11' , info => $reg64_href }, + { name => 'r12' , info => $reg64_href }, + { name => 'r13' , info => $reg64_href }, + { name => 'r14' , info => $reg64_href }, + { name => 'r15' , info => $reg64_href }, + { name => 'rip' , info => $reg64_href }, + { name => 'rflags' , info => $reg64_href }, + { name => 'cs' , info => $reg64_href }, + { name => 'fs' , info => $reg64_href }, + { name => 'gs' , info => $reg64_href }, + { name => 'fctrl' , info => $reg16_href }, + { name => 'fstat' , info => $reg16_href }, + { name => 'ftag' , info => $reg8_href }, + { name => 'fop' , info => $reg16_href }, + { name => 'fioff' , info => $reg32_href }, + { name => 'fiseg' , info => $reg16_href }, + { name => 'fooff' , info => $reg32_href }, + { name => 'foseg' , info => $reg16_href }, + { name => 'mxcsr' , info => $reg32_href }, + { name => 'mxcsrmask' , info => $reg32_href }, + { name => 'stmm0' , info => $reg80_href }, + { name => 'stmm1' , info => $reg80_href }, + { name => 'stmm2' , info => $reg80_href }, + { name => 'stmm3' , info => $reg80_href }, + { name => 'stmm4' , info => $reg80_href }, + { name => 'stmm5' , info => $reg80_href }, + { name => 'stmm6' , info => $reg80_href }, + { name => 'stmm7' , info => $reg80_href }, + { name => 'xmm0' , info => $reg128_href }, + { name => 'xmm1' , info => $reg128_href }, + { name => 'xmm2' , info => $reg128_href }, + { name => 'xmm3' , info => $reg128_href }, + { name => 'xmm4' , info => $reg128_href }, + { name => 'xmm5' , info => $reg128_href }, + { name => 'xmm6' , info => $reg128_href }, + { name => 'xmm7' , info => $reg128_href }, + { name => 'xmm8' , info => $reg128_href }, + { name => 'xmm9' , info => $reg128_href }, + { name => 'xmm10' , info => $reg128_href }, + { name => 'xmm11' , info => $reg128_href }, + { name => 'xmm12' , info => $reg128_href }, + { name => 'xmm13' , info => $reg128_href }, + { name => 'xmm14' , info => $reg128_href }, + { name => 'xmm15' , info => $reg128_href }, + { name => 'trapno' , info => $reg32_href }, + { name => 'err' , info => $reg32_href }, + { name => 'faultvaddr' , info => $reg64_href }, + ] +); + +our $max_register_name_len = 0; +calculate_max_register_name_length(); +our @point_types = ( "software_bp", "hardware_bp", "write_wp", "read_wp", "access_wp" ); +our $opt_v = 0; # verbose +our $opt_g = 0; # debug +our $opt_q = 0; # quiet +our $opt_r = undef; +use Getopt::Std; +getopts('gvqr:'); + +our $registers_aref = undef; + +if (length($opt_r)) +{ + $registers_aref = $reg_map{$opt_r}; +} + +sub extract_key_value_pairs +{ + my $kv_href = {}; + my $arrayref = shift; + my $str = join('',@$arrayref); + my @kv_strs = split(/;/, $str); + foreach my $kv_str (@kv_strs) + { + my ($key, $value) = split(/:/, $kv_str); + $kv_href->{$key} = $value; + } + return $kv_href; +} + +sub get_thread_from_thread_suffix +{ + if ($thread_suffix_supported) + { + my $arrayref = shift; + # Skip leading semi-colon if needed + $$arrayref[0] == ';' and shift @$arrayref; + my $thread_href = extract_key_value_pairs ($arrayref); + if (exists $thread_href->{thread}) + { + return $thread_href->{thread}; + } + } + return undef; +} + +sub calculate_max_register_name_length +{ + $max_register_name_len = 7; + foreach my $reg_href (@$registers_aref) + { + my $name_len = length($reg_href->{name}); + if ($max_register_name_len < $name_len) + { + $max_register_name_len = $name_len; + } + } +} +#---------------------------------------------------------------------- +# Hash that maps command characters to the appropriate functions using +# the command character as the key and the value being a reference to +# the dump function for dumping the command itself. +#---------------------------------------------------------------------- +our %cmd_callbacks = +( + '?' => \&dump_last_signal_cmd, + 'H' => \&dump_set_thread_cmd, + 'T' => \&dump_thread_is_alive_cmd, + 'q' => \&dump_general_query_cmd, + 'Q' => \&dump_general_set_cmd, + 'g' => \&dump_read_regs_cmd, + 'G' => \&dump_write_regs_cmd, + 'p' => \&dump_read_single_register_cmd, + 'P' => \&dump_write_single_register_cmd, + 'm' => \&dump_read_mem_cmd, + 'M' => \&dump_write_mem_cmd, + 'X' => \&dump_write_mem_binary_cmd, + 'Z' => \&dump_bp_wp_command, + 'z' => \&dump_bp_wp_command, + 'k' => \&dump_kill_cmd, + 'A' => \&dump_A_command, + 'c' => \&dump_continue_cmd, + 'C' => \&dump_continue_with_signal_cmd, + '_M' => \&dump_allocate_memory_cmd, + '_m' => \&dump_deallocate_memory_cmd, + # extended commands + 'v' => \&dump_extended_cmd +); + +#---------------------------------------------------------------------- +# Hash that maps command characters to the appropriate functions using +# the command character as the key and the value being a reference to +# the dump function for the response to the command. +#---------------------------------------------------------------------- +our %rsp_callbacks = +( + 'c' => \&dump_stop_reply_packet, + 'C' => \&dump_stop_reply_packet, + '?' => \&dump_stop_reply_packet, + 'T' => \&dump_thread_is_alive_rsp, + 'H' => \&dump_set_thread_rsp, + 'q' => \&dump_general_query_rsp, + 'g' => \&dump_read_regs_rsp, + 'p' => \&dump_read_single_register_rsp, + 'm' => \&dump_read_mem_rsp, + '_M' => \&dump_allocate_memory_rsp, + + # extended commands + 'v' => \&dump_extended_rsp, +); + + +sub dump_register_value +{ + my $indent = shift; + my $arrayref = shift; + my $reg_num = shift; + + if ($reg_num >= @$registers_aref) + { + printf("\tinvalid register index %d\n", $reg_num); + } + + my $reg_href = $$registers_aref[$reg_num]; + my $reg_name = $reg_href->{name}; + if ($$arrayref[0] eq '#') + { + printf("\t%*s: error: EOS reached when trying to read register %d\n", $max_register_name_len, $reg_name, $reg_num); + } + + my $reg_info = $reg_href->{info}; + my $reg_extract = $reg_info->{extract}; + my $reg_format = $reg_info->{format}; + my $reg_val = &$reg_extract($arrayref); + if ($indent) { + printf("\t%*s = $reg_format", $max_register_name_len, $reg_name, $reg_val); + } else { + printf("%s = $reg_format", $reg_name, $reg_val); + } +} + +#---------------------------------------------------------------------- +# Extract the command into an array of ASCII char strings for easy +# processing +#---------------------------------------------------------------------- +sub extract_command +{ + my $cmd_str = shift; + my @cmd_chars = split(/ */, $cmd_str); + if ($cmd_chars[0] ne '$') + { + # only set the current command if it isn't a reply + $curr_cmd = $cmd_chars[0]; + } + return @cmd_chars; +} + +#---------------------------------------------------------------------- +# Strip the 3 checksum array entries after we don't need them anymore +#---------------------------------------------------------------------- +sub strip_checksum +{ + my $arrayref = shift; + splice(@$arrayref, -3); +} + +#---------------------------------------------------------------------- +# Dump all strings in array by joining them together with no space +# between them +#---------------------------------------------------------------------- +sub dump_chars +{ + print join('', at _); +} + +#---------------------------------------------------------------------- +# Check if the response is an error 'EXX' +#---------------------------------------------------------------------- +sub is_error_response +{ + if ($_[0] eq 'E') + { + shift; + print "ERROR = " . join('', at _) . "\n"; + return 1; + } + return 0; +} + +#---------------------------------------------------------------------- +# 'H' command +#---------------------------------------------------------------------- +sub dump_set_thread_cmd +{ + my $cmd = shift; + my $mod = shift; + print "set_thread ( $mod, " . join('', at _) . " )\n"; +} + +#---------------------------------------------------------------------- +# 'T' command +#---------------------------------------------------------------------- +our $T_cmd_tid = -1; +sub dump_thread_is_alive_cmd +{ + my $cmd = shift; + $T_cmd_tid = get_hex(\@_); + printf("thread_is_alive ( $tid_format )\n", $T_cmd_tid); +} + +sub dump_thread_is_alive_rsp +{ + my $rsp = join('', at _); + + printf("thread_is_alive ( $tid_format ) =>", $T_cmd_tid); + if ($rsp eq 'OK') + { + print " alive.\n"; + } + else + { + print " dead.\n"; + } +} + +#---------------------------------------------------------------------- +# 'H' response +#---------------------------------------------------------------------- +sub dump_set_thread_rsp +{ + if (!is_error_response(@_)) + { + print join('', at _) . "\n"; + } +} + +#---------------------------------------------------------------------- +# 'q' command +#---------------------------------------------------------------------- +our $gen_query_cmd; +sub dump_general_query_cmd +{ + $gen_query_cmd = join('', at _); + if ($gen_query_cmd eq 'qC') + { + print 'get_current_pid ()'; + } + elsif ($gen_query_cmd eq 'qfThreadInfo') + { + print 'get_first_active_threads ()'; + } + elsif ($gen_query_cmd eq 'qsThreadInfo') + { + print 'get_subsequent_active_threads ()'; + } + elsif (index($gen_query_cmd, 'qThreadExtraInfo') == 0) + { + # qThreadExtraInfo,id + print 'get_thread_extra_info ()'; + } + elsif (index($gen_query_cmd, 'qThreadStopInfo') == 0) + { + # qThreadStopInfoXXXX + @_ = splice(@_, length('qThreadStopInfo')); + my $tid = get_addr(\@_); + printf('get_thread_stop_info ( thread = 0x%4.4x )', $tid); + } + elsif (index($gen_query_cmd, 'qSymbol:') == 0) + { + # qCRC:addr,length + print 'gdb_ready_to_serve_symbol_lookups ()'; + } + elsif (index($gen_query_cmd, 'qCRC:') == 0) + { + # qCRC:addr,length + @_ = splice(@_, length('qCRC:')); + my $address = get_addr(\@_); + shift @_; + my $length = join('', @_); + printf("compute_crc (addr = $addr_format, length = $length)", $address); + } + elsif (index($gen_query_cmd, 'qGetTLSAddr:') == 0) + { + # qGetTLSAddr:thread-id,offset,lm + @_ = splice(@_, length('qGetTLSAddr:')); + my ($tid, $offset, $lm) = split (/,/, join('', @_)); + print "get_thread_local_storage_addr (thread-id = $tid, offset = $offset, lm = $lm)"; + } + elsif ($gen_query_cmd eq 'qOffsets') + { + print 'get_section_offsets ()'; + } + 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)"; + } + else + { + print $gen_query_cmd; + } + print "\n"; +} + +#---------------------------------------------------------------------- +# 'q' response +#---------------------------------------------------------------------- +sub dump_general_query_rsp +{ + my $gen_query_rsp = join('', at _); + + 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); + return; + } + elsif (index($gen_query_cmd, 'qRegisterInfo') == 0) + { + if (index($gen_query_rsp, 'name') == 0) + { + 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 };} + } + } + else + { + calculate_max_register_name_length(); + } + } + elsif ($gen_query_cmd =~ 'qThreadStopInfo') + { + dump_stop_reply_packet (@_); + } + if (dump_standard_response(\@_)) + { + # Do nothing... + } + else + { + print join('', at _) . "\n"; + } +} + +#---------------------------------------------------------------------- +# 'Q' command +#---------------------------------------------------------------------- +our $gen_set_cmd; +sub dump_general_set_cmd +{ + $gen_query_cmd = join('', at _); + if ($gen_query_cmd eq 'QStartNoAckMode') + { + print "StartNoAckMode ()" + } + elsif ($gen_query_cmd eq 'QThreadSuffixSupported') + { + $thread_suffix_supported = 1; + print "ThreadSuffixSupported ()" + } + elsif (index($gen_query_cmd, 'QSetMaxPayloadSize:') == 0) + { + @_ = splice(@_, length('QSetMaxPayloadSize:')); + my $max_payload_size = get_hex(\@_); + # QSetMaxPayloadSize:XXXX where XXXX is a hex length of the max + # packet payload size supported by gdb + printf("SetMaxPayloadSize ( 0x%x (%u))", $max_payload_size, $max_payload_size); + } + else + { + print $gen_query_cmd; + } + print "\n"; +} + +#---------------------------------------------------------------------- +# 'k' command +#---------------------------------------------------------------------- +sub dump_kill_cmd +{ + my $cmd = shift; + print "kill (" . join('', at _) . ")\n"; +} + +#---------------------------------------------------------------------- +# 'g' command +#---------------------------------------------------------------------- +sub dump_read_regs_cmd +{ + my $cmd = shift; + print "read_registers ()\n"; +} + +#---------------------------------------------------------------------- +# 'G' command +#---------------------------------------------------------------------- +sub dump_write_regs_cmd +{ + print "write_registers:\n"; + my $cmd = shift; + foreach my $reg_href (@$registers_aref) + { + last if ($_[0] eq '#'); + my $reg_info_href = $reg_href->{info}; + my $reg_name = $reg_href->{name}; + my $reg_extract = $reg_info_href->{extract}; + my $reg_format = $reg_info_href->{format}; + my $reg_val = &$reg_extract(\@_); + printf("\t%*s = $reg_format\n", $max_register_name_len, $reg_name, $reg_val); + } +} + +sub dump_read_regs_rsp +{ + print "read_registers () =>\n"; + if (!is_error_response(@_)) + { + # print join('', at _) . "\n"; + foreach my $reg_href (@$registers_aref) + { + last if ($_[0] eq '#'); + my $reg_info_href = $reg_href->{info}; + my $reg_name = $reg_href->{name}; + my $reg_extract = $reg_info_href->{extract}; + my $reg_format = $reg_info_href->{format}; + my $reg_val = &$reg_extract(\@_); + printf("\t%*s = $reg_format\n", $max_register_name_len, $reg_name, $reg_val); + } + } +} + +sub dump_read_single_register_rsp +{ + dump_register_value(0, \@_, $reg_cmd_reg); + print "\n"; +} + +#---------------------------------------------------------------------- +# '_M' - allocate memory command (LLDB extension) +# +# Command: '_M' +# Arg1: Hex byte size as big endian hex string +# Separator: ',' +# Arg2: permissions as string that must be a string that contains any +# combination of 'r' (readable) 'w' (writable) or 'x' (executable) +# +# Returns: The address that was allocated as a big endian hex string +# on success, else an error "EXX" where XX are hex bytes +# that indicate an error code. +# +# Examples: +# _M10,rw # allocate 16 bytes with read + write permissions +# _M100,rx # allocate 256 bytes with read + execute permissions +#---------------------------------------------------------------------- +sub dump_allocate_memory_cmd +{ + shift; shift; # shift off the '_' and the 'M' + my $byte_size = get_addr(\@_); + shift; # Skip ',' + printf("allocate_memory ( byte_size = %u (0x%x), permissions = %s)\n", $byte_size, $byte_size, join('', at _)); +} + +sub dump_allocate_memory_rsp +{ + if (@_ == 3 and $_[0] == 'E') + { + printf("allocated memory addr = ERROR (%s))\n", join('', at _)); + } + else + { + printf("allocated memory addr = 0x%s\n", join('', at _)); + } +} + + +#---------------------------------------------------------------------- +# '_m' - deallocate memory command (LLDB extension) +# +# Command: '_m' +# Arg1: Hex address as big endian hex string +# +# Returns: "OK" on success "EXX" on error +# +# Examples: +# _m201000 # Free previously allocated memory at address 0x201000 +#---------------------------------------------------------------------- +sub dump_deallocate_memory_cmd +{ + shift; shift; # shift off the '_' and the 'm' + printf("deallocate_memory ( addr = 0x%s)\n", join('', at _)); +} + + +#---------------------------------------------------------------------- +# 'p' command +#---------------------------------------------------------------------- +sub dump_read_single_register_cmd +{ + my $cmd = shift; + $reg_cmd_reg = get_hex(\@_); + my $thread = get_thread_from_thread_suffix (\@_); + if (defined $thread) + { + print "read_register ( reg = \"$$registers_aref[$reg_cmd_reg]->{name}\", thread = $thread )\n"; + } + else + { + print "read_register ( reg = \"$$registers_aref[$reg_cmd_reg]->{name}\" )\n"; + } +} + + +#---------------------------------------------------------------------- +# 'P' command +#---------------------------------------------------------------------- +sub dump_write_single_register_cmd +{ + my $cmd = shift; + my $reg_num = get_hex(\@_); + shift (@_); # Discard the '=' + + print "write_register ( "; + dump_register_value(0, \@_, $reg_num); + my $thread = get_thread_from_thread_suffix (\@_); + if (defined $thread) + { + print ", thread = $thread"; + } + print " )\n"; +} + +#---------------------------------------------------------------------- +# 'm' command +#---------------------------------------------------------------------- +our $read_mem_address = 0; +sub dump_read_mem_cmd +{ + my $cmd = shift; + $read_mem_address = get_addr(\@_); + shift; # Skip ',' + printf("read_mem ( $addr_format, %s )\n", $read_mem_address, join('', at _)); +} + +#---------------------------------------------------------------------- +# 'm' response +#---------------------------------------------------------------------- +sub dump_read_mem_rsp +{ + # If the memory read was 2 or 4 bytes, print it out in native format + # instead of just as bytes. + my $num_nibbles = @_; + if ($num_nibbles == 2) + { + printf(" 0x%2.2x", get8(\@_)); + } + elsif ($num_nibbles == 4) + { + printf(" 0x%4.4x", get16(\@_)); + } + elsif ($num_nibbles == 8) + { + printf(" 0x%8.8x", get32(\@_)); + } + elsif ($num_nibbles == 16) + { + printf(" 0x%s", get64(\@_)); + } + else + { + my $curr_address = $read_mem_address; + my $nibble; + my $nibble_offset = 0; + my $max_nibbles_per_line = 2 * $max_bytes_per_line; + foreach $nibble (@_) + { + if (($nibble_offset % $max_nibbles_per_line) == 0) + { + ($nibble_offset > 0) and print "\n "; + printf("$addr_format: ", $curr_address + $nibble_offset/2); + } + (($nibble_offset % 2) == 0) and print ' '; + print $nibble; + $nibble_offset++; + } + } + print "\n"; +} + +#---------------------------------------------------------------------- +# 'c' command +#---------------------------------------------------------------------- +sub dump_continue_cmd +{ + my $cmd = shift; + my $address = -1; + if (@_) + { + my $address = get_addr(\@_); + printf("continue ($addr_format)\n", $address); + } + else + { + printf("continue ()\n"); + } +} + +#---------------------------------------------------------------------- +# 'Css' continue (C) with signal (ss where 'ss' is two hex digits) +#---------------------------------------------------------------------- +sub dump_continue_with_signal_cmd +{ + my $cmd = shift; + my $address = -1; + my $signal = get_hex(\@_); + if (@_) + { + my $address = 0; + if (@_ && $_[0] == ';') + { + shift; + $address = get_addr(\@_); + } + } + + if ($address != -1) + { + printf("continue_with_signal (signal = 0x%2.2x, address = $addr_format)\n", $signal, $address); + } + else + { + printf("continue_with_signal (signal = 0x%2.2x)\n", $signal); + } +} + +#---------------------------------------------------------------------- +# 'A' command +#---------------------------------------------------------------------- +sub dump_A_command +{ + my $cmd = get_exptected_char(\@_, 'A') or print "error: incorrect command letter for argument packet, exptected 'A'\n"; + printf("set_program_arguments (\n"); + do + { + my $arg_len = get_uint(\@_); + get_exptected_char(\@_, ',') or die "error: missing comma after argument length...?\n"; + my $arg_idx = get_uint(\@_); + get_exptected_char(\@_, ',') or die "error: missing comma after argument number...?\n"; + + my $arg = ''; + my $num_hex8_bytes = $arg_len/2; + for (1 .. $num_hex8_bytes) + { + $arg .= sprintf("%c", get8(\@_)) + } + printf(" <%3u> argv[%u] = '%s'\n", $arg_len, $arg_idx, $arg); + if (@_ > 0) + { + get_exptected_char(\@_, ',') or die "error: missing comma after argument argument ASCII hex bytes...?\n"; + } + } while (@_ > 0); + printf(" )\n"); +} + + +#---------------------------------------------------------------------- +# 'z' and 'Z' command +#---------------------------------------------------------------------- +sub dump_bp_wp_command +{ + my $cmd = shift; + my $type = shift; + shift; # Skip ',' + my $address = get_addr(\@_); + shift; # Skip ',' + my $length = join('', at _); + if ($cmd eq 'z') + { + printf("remove $point_types[$type]($addr_format, %d)\n", $address, $length); + } + else + { + printf("insert $point_types[$type]($addr_format, %d)\n", $address, $length); + } +} + + +#---------------------------------------------------------------------- +# 'X' command +#---------------------------------------------------------------------- +sub dump_write_mem_binary_cmd +{ + my $cmd = shift; + my $address = get_addr(\@_); + shift; # Skip ',' + + my ($length, $binary) = split(/:/, join('', at _)); + printf("write_mem_binary ( $addr_format, %d, %s)\n", $address, $length, $binary); + +} + +#---------------------------------------------------------------------- +# 'M' command +#---------------------------------------------------------------------- +sub dump_write_mem_cmd +{ + my $cmd = shift; + my $address = get_addr(\@_); + shift; # Skip ',' + my ($length, $hex_bytes) = split(/:/, join('', at _)); +# printf("write_mem ( $addr_format, %d, %s)\n", $address, $length, $hex_bytes); + printf("write_mem ( addr = $addr_format, len = %d (0x%x), bytes = ", $address, $length, $length); + splice(@_, 0, length($length)+1); + + my $curr_address = $address; + my $nibble; + my $nibble_count = 0; + my $max_nibbles_per_line = 2 * $max_bytes_per_line; + foreach $nibble (@_) + { + (($nibble_count % 2) == 0) and print ' '; + print $nibble; + $nibble_count++; + } + + # If the memory to write is 2 or 4 bytes, print it out in native format + # instead of just as bytes. + if (@_ == 4) + { + printf(" ( 0x%4.4x )", get16(\@_)); + } + elsif (@_ == 8) + { + printf(" ( 0x%8.8x )", get32(\@_)); + } + print " )\n"; + +} + +#---------------------------------------------------------------------- +# 'v' command +#---------------------------------------------------------------------- +our $extended_rsp_callback = 0; +sub dump_extended_cmd +{ + $extended_rsp_callback = 0; + if (join('', @_[0..4]) eq "vCont") + { + dump_extended_continue_cmd(splice(@_,5)); + } + elsif (join('', @_[0..11]) eq 'vAttachWait;') + { + dump_attach_wait_command (splice(@_,12)); + } +} + +#---------------------------------------------------------------------- +# 'v' response +#---------------------------------------------------------------------- +sub dump_extended_rsp +{ + if ($extended_rsp_callback) + { + &$extended_rsp_callback(@_); + } + $extended_rsp_callback = 0; +} + +#---------------------------------------------------------------------- +# 'vAttachWait' command +#---------------------------------------------------------------------- +sub dump_attach_wait_command +{ +# print "dump_extended_continue_cmd ( "; +# dump_chars(@_); +# print " )\n"; + print "attach_wait ( "; + while (@_) + { + printf("%c", get8(\@_)) + } + printf " )\n"; + +} + +#---------------------------------------------------------------------- +# 'vCont' command +#---------------------------------------------------------------------- +sub dump_extended_continue_cmd +{ +# print "dump_extended_continue_cmd ( "; +# dump_chars(@_); +# print " )\n"; + print "extended_continue ( "; + my $cmd = shift; + if ($cmd eq '?') + { + print "list supported modes )\n"; + $extended_rsp_callback = \&dump_extended_continue_rsp; + } + elsif ($cmd eq ';') + { + $extended_rsp_callback = \&dump_stop_reply_packet; + my $i = 0; + while ($#_ >= 0) + { + if ($i > 0) + { + print ", "; + } + my $continue_cmd = shift; + my $tmp; + if ($continue_cmd eq 'c') + { + print "continue"; + } + elsif ($continue_cmd eq 'C') + { + print "continue with signal "; + print shift; + print shift; + } + elsif ($continue_cmd eq 's') + { + print "step"; + } + elsif ($continue_cmd eq 'S') + { + print "step with signal "; + print shift; + print shift; + } + + if ($_[0] eq ':') + { + shift; # Skip ':' + print " for thread "; + while ($#_ >= 0) + { + $tmp = shift; + if (length($tmp) > 0 && $tmp ne ';') { + print $tmp; + } else { + last; + } + } + } + $i++; + } + + printf " )\n"; + } +} + +#---------------------------------------------------------------------- +# 'vCont' response +#---------------------------------------------------------------------- +sub dump_extended_continue_rsp +{ + print "extended_continue ( " . join('', at _) . " )\n"; +} + +#---------------------------------------------------------------------- +# Dump the command ascii for any unknown commands +#---------------------------------------------------------------------- +sub dump_other_cmd +{ + print "other = " . join('', at _) . "\n"; +} + +#---------------------------------------------------------------------- +# Check to see if the response was unsupported with appropriate checksum +#---------------------------------------------------------------------- +sub rsp_is_unsupported +{ + return join('', at _) eq "#00"; +} + +#---------------------------------------------------------------------- +# Check to see if the response was "OK" with appropriate checksum +#---------------------------------------------------------------------- +sub rsp_is_OK +{ + return join('', at _) eq "OK#9a"; +} + +#---------------------------------------------------------------------- +# Dump a response for an unknown command +#---------------------------------------------------------------------- +sub dump_other_rsp +{ + print "other = " . join('', at _) . "\n"; +} + +#---------------------------------------------------------------------- +# Get a byte from the ascii string assuming that the 2 nibble ascii +# characters are in hex. +# +# The argument for this function needs to be a reference to an array +# that contains single character strings and the array will get +# updated by shifting characters off the front of it (no leading # "0x") +#---------------------------------------------------------------------- +sub get8 +{ + my $arrayref = shift; + my $val = hex(shift(@$arrayref) . shift(@$arrayref)); + return $val; +} + +#---------------------------------------------------------------------- +# Get a 16 bit integer and swap if $swap global is set to a non-zero +# value. +# +# The argument for this function needs to be a reference to an array +# that contains single character strings and the array will get +# updated by shifting characters off the front of it (no leading # "0x") +#---------------------------------------------------------------------- +sub get16 +{ + my $arrayref = shift; + my $val = 0; + if ($swap) + { + $val = get8($arrayref) | + get8($arrayref) << 8; + } + else + { + $val = get8($arrayref) << 8 | + get8($arrayref) ; + } + return $val; +} + +#---------------------------------------------------------------------- +# Get a 32 bit integer and swap if $swap global is set to a non-zero +# value. +# +# The argument for this function needs to be a reference to an array +# that contains single character strings and the array will get +# updated by shifting characters off the front of it (no leading # "0x") +#---------------------------------------------------------------------- +sub get32 +{ + my $arrayref = shift; + my $val = 0; + if ($swap) + { + $val = get8($arrayref) | + get8($arrayref) << 8 | + get8($arrayref) << 16 | + get8($arrayref) << 24 ; + } + else + { + $val = get8($arrayref) << 24 | + get8($arrayref) << 16 | + get8($arrayref) << 8 | + get8($arrayref) ; + } + return $val; +} + +#---------------------------------------------------------------------- +# Get a 64 bit hex value as a string +# +# The argument for this function needs to be a reference to an array +# that contains single character strings and the array will get +# updated by shifting characters off the front of it (no leading # "0x") +#---------------------------------------------------------------------- +sub get64 +{ + my $arrayref = shift; + my $val = ''; + my @nibbles; + if ($swap) + { + push @nibbles, splice(@$arrayref, 14, 2); + push @nibbles, splice(@$arrayref, 12, 2); + push @nibbles, splice(@$arrayref, 10, 2); + push @nibbles, splice(@$arrayref, 8, 2); + push @nibbles, splice(@$arrayref, 6, 2); + push @nibbles, splice(@$arrayref, 4, 2); + push @nibbles, splice(@$arrayref, 2, 2); + push @nibbles, splice(@$arrayref, 0, 2); + } + else + { + (@nibbles) = splice(@$arrayref, 0, 24); + } + $val = join('', @nibbles); + return $val; +} + +#---------------------------------------------------------------------- +# Get a 80 bit hex value as a string +# +# The argument for this function needs to be a reference to an array +# that contains single character strings and the array will get +# updated by shifting characters off the front of it (no leading # "0x") +#---------------------------------------------------------------------- +sub get80 +{ + my $arrayref = shift; + my $val = ''; + my @nibbles; + if ($swap) + { + push @nibbles, splice(@$arrayref, 18, 2); + push @nibbles, splice(@$arrayref, 16, 2); + push @nibbles, splice(@$arrayref, 14, 2); + push @nibbles, splice(@$arrayref, 12, 2); + push @nibbles, splice(@$arrayref, 10, 2); + push @nibbles, splice(@$arrayref, 8, 2); + push @nibbles, splice(@$arrayref, 6, 2); + push @nibbles, splice(@$arrayref, 4, 2); + push @nibbles, splice(@$arrayref, 2, 2); + push @nibbles, splice(@$arrayref, 0, 2); + } + else + { + (@nibbles) = splice(@$arrayref, 0, 24); + } + $val = join('', @nibbles); + return $val; +} + +#---------------------------------------------------------------------- +# Get a 96 bit hex value as a string +# +# The argument for this function needs to be a reference to an array +# that contains single character strings and the array will get +# updated by shifting characters off the front of it (no leading # "0x") +#---------------------------------------------------------------------- +sub get96 +{ + my $arrayref = shift; + my $val = ''; + my @nibbles; + if ($swap) + { + push @nibbles, splice(@$arrayref, 22, 2); + push @nibbles, splice(@$arrayref, 20, 2); + push @nibbles, splice(@$arrayref, 18, 2); + push @nibbles, splice(@$arrayref, 16, 2); + push @nibbles, splice(@$arrayref, 14, 2); + push @nibbles, splice(@$arrayref, 12, 2); + push @nibbles, splice(@$arrayref, 10, 2); + push @nibbles, splice(@$arrayref, 8, 2); + push @nibbles, splice(@$arrayref, 6, 2); + push @nibbles, splice(@$arrayref, 4, 2); + push @nibbles, splice(@$arrayref, 2, 2); + push @nibbles, splice(@$arrayref, 0, 2); + } + else + { + (@nibbles) = splice(@$arrayref, 0, 24); + } + $val = join('', @nibbles); + return $val; +} + +#---------------------------------------------------------------------- +# Get a 128 bit hex value as a string +# +# The argument for this function needs to be a reference to an array +# that contains single character strings and the array will get +# updated by shifting characters off the front of it (no leading # "0x") +#---------------------------------------------------------------------- +sub get128 +{ + my $arrayref = shift; + my $val = ''; + my @nibbles; + if ($swap) + { + push @nibbles, splice(@$arrayref, 30, 2); + push @nibbles, splice(@$arrayref, 28, 2); + push @nibbles, splice(@$arrayref, 26, 2); + push @nibbles, splice(@$arrayref, 24, 2); + push @nibbles, splice(@$arrayref, 22, 2); + push @nibbles, splice(@$arrayref, 20, 2); + push @nibbles, splice(@$arrayref, 18, 2); + push @nibbles, splice(@$arrayref, 16, 2); + push @nibbles, splice(@$arrayref, 14, 2); + push @nibbles, splice(@$arrayref, 12, 2); + push @nibbles, splice(@$arrayref, 10, 2); + push @nibbles, splice(@$arrayref, 8, 2); + push @nibbles, splice(@$arrayref, 6, 2); + push @nibbles, splice(@$arrayref, 4, 2); + push @nibbles, splice(@$arrayref, 2, 2); + push @nibbles, splice(@$arrayref, 0, 2); + } + else + { + (@nibbles) = splice(@$arrayref, 0, 24); + } + $val = join('', @nibbles); + return $val; +} + +#---------------------------------------------------------------------- +# Get a an unsigned integer value by grabbing items off the front of +# the array stopping when a non-digit char string is encountered. +# +# The argument for this function needs to be a reference to an array +# that contains single character strings and the array will get +# updated by shifting characters off the front of it +#---------------------------------------------------------------------- +sub get_uint +{ + my $arrayref = shift; + @$arrayref == 0 and return 0; + my $val = 0; + while ($$arrayref[0] =~ /[0-9]/) + { + $val = $val * 10 + int(shift(@$arrayref)); + } + return $val; +} + +#---------------------------------------------------------------------- +# Check the first character in the array and if it matches the expected +# character, return that character, else return undef; +# +# The argument for this function needs to be a reference to an array +# that contains single character strings and the array will get +# updated by shifting characters off the front of it. If the expected +# character doesn't match, it won't touch the array. If the first +# character does match, it will shift it off and return it. +#---------------------------------------------------------------------- +sub get_exptected_char +{ + my $arrayref = shift; + my $expected_char = shift; + if ($expected_char eq $$arrayref[0]) + { + return shift(@$arrayref); + } + return undef; +} +#---------------------------------------------------------------------- +# Get a hex value by grabbing items off the front of the array and +# stopping when a non-hex char string is encountered. +# +# The argument for this function needs to be a reference to an array +# that contains single character strings and the array will get +# updated by shifting characters off the front of it (no leading # "0x") +#---------------------------------------------------------------------- +sub get_hex +{ + my $arrayref = shift; + my $my_swap = @_ ? shift : 0; + my $shift = 0; + my $val = 0; + while ($$arrayref[0] =~ /[0-9a-fA-F]/) + { + if ($my_swap) + { + my $byte = hex(shift(@$arrayref)) << 4 | hex(shift(@$arrayref)); + $val |= $byte << $shift; + $shift += 8; + } + else + { + $val <<= 4; + $val |= hex(shift(@$arrayref)); + } + } + return $val; +} + +#---------------------------------------------------------------------- +# Get an address value by grabbing items off the front of the array. +# +# The argument for this function needs to be a reference to an array +# that contains single character strings and the array will get +# updated by shifting characters off the front of it (no leading # "0x") +#---------------------------------------------------------------------- +sub get_addr +{ + get_hex(shift); +} + +sub dump_stop_reply_data +{ + while ($#_ >= 0) + { + last unless ($_[0] ne '#'); + + + my $key = ''; + my $value = ''; + if ($_[0] =~ /[0-9a-fA-F]/ && $_[1] =~ /[0-9a-fA-F]/) + { + my $reg_num = get8(\@_); + shift(@_); # Skip ':' + if (defined ($registers_aref) && $reg_num < @$registers_aref) + { + dump_register_value(1, \@_, $reg_num); + print "\n"; + shift(@_); # Skip ';' + next; + } + $key = sprintf("reg %u", $reg_num); + } + my $char; + + if (length($key) == 0) + { + while (1) + { + $char = shift(@_); + if (length($char) == 0 or $char eq ':' or $char eq '#') { last; } + $key .= $char; + } + } + + while (1) + { + $char = shift(@_); + if (length($char) == 0 or $char eq ';' or $char eq '#') { last; } + $value .= $char; + } + printf("\t%*s = %s\n", $max_register_name_len, $key, $value); + } +} + +#---------------------------------------------------------------------- +# Dumps a Stop Reply Packet which happens in response to a step, +# continue, last signal, and probably a few other commands. +#---------------------------------------------------------------------- +sub dump_stop_reply_packet +{ + my $what = shift(@_); + if ($what eq 'S') + { + print 'signal ( 0x' . shift(@_) . shift(@_) . " )\n"; + } + elsif ($what eq 'T') + { + print 'signal ( 0x' . shift(@_) . shift(@_) . " )\n"; + dump_stop_reply_data (@_); + } + elsif ($what eq 'W') + { + print 'process_exited( ' . shift(@_) . shift(@_) . " )\n"; + } + elsif ($what eq 'X') + { + print 'process_terminated( ' . shift(@_) . shift(@_) . " )\n"; + } + elsif ($what eq 'O') + { + my $console_output = ''; + my $num_hex8_bytes = @_/2; + for (1 .. $num_hex8_bytes) + { + $console_output .= sprintf("%c", get8(\@_)) + } + + print "program_console_output('$console_output')\n"; + } +} + +#---------------------------------------------------------------------- +# '?' command +#---------------------------------------------------------------------- +sub dump_last_signal_cmd +{ + my $cmd = shift; + print 'last_signal (' . join('', at _) . ")\n"; +} + +sub dump_raw_command +{ + my $cmd_aref = shift; + my $callback_ref; + $curr_cmd = $$cmd_aref[0]; + $curr_cmd eq '_' and $curr_cmd .= $$cmd_aref[1]; + + $callback_ref = $cmd_callbacks{$curr_cmd}; + if ($callback_ref) + { + &$callback_ref(@$cmd_aref); + } + else + { + # Strip the command byte for responses since we injected that above + dump_other_cmd(@$cmd_aref); + } +} + +sub dump_standard_response +{ + my $cmd_aref = shift; + + if (@$cmd_aref == 0) + { + print "$unsupported_str\n"; + return 1; + } + + my $response = join('', @$cmd_aref); + if ($response eq 'OK') + { + print "$success_str\n"; + return 1; + } + + if (index($response, 'E') == 0) + { + print "ERROR: " . substr($response, 1) . "\n"; + return 1; + } + + return 0; +} +sub dump_raw_response +{ + my $cmd_aref = shift; + my $callback_ref; + + $callback_ref = $rsp_callbacks{$curr_cmd}; + + if ($callback_ref) + { + &$callback_ref(@$cmd_aref); + } + else + { + dump_standard_response($cmd_aref) or dump_other_rsp(@$cmd_aref); + } + +} +#---------------------------------------------------------------------- +# Dumps any command and handles simple error checking on the responses +# for commands that are unsupported or OK. +#---------------------------------------------------------------------- +sub dump_command +{ + my $cmd_str = shift; + + # Dump the original command string if verbose is on + if ($opt_v) + { + print "dump_command($cmd_str)\n "; + } + + my @cmd_chars = extract_command($cmd_str); + my $is_cmd = 1; + + my $cmd = $cmd_chars[0]; + if ($cmd eq '$') + { + $is_cmd = 0; # Note that this is a reply + $cmd = $curr_cmd; # set the command byte appropriately + shift @cmd_chars; # remove the '$' from the cmd bytes + } + + # Check for common responses across all commands and handle them + # if we can + if ( $is_cmd == 0 ) + { + if (rsp_is_unsupported(@cmd_chars)) + { + print "$unsupported_str\n"; + return; + } + elsif (rsp_is_OK(@cmd_chars)) + { + print "$success_str\n"; + return; + } + # Strip the checksum information for responses + strip_checksum(\@cmd_chars); + } + + my $callback_ref; + if ($is_cmd) { + $callback_ref = $cmd_callbacks{$cmd}; + } else { + $callback_ref = $rsp_callbacks{$cmd}; + } + + if ($callback_ref) + { + &$callback_ref(@cmd_chars); + } + else + { + # Strip the command byte for responses since we injected that above + if ($is_cmd) { + dump_other_cmd(@cmd_chars); + } else { + dump_other_rsp(@cmd_chars); + } + + } +} + + +#---------------------------------------------------------------------- +# Process a gdbserver log line by looking for getpkt and putkpt and +# tossing any other lines. +#---------------------------------------------------------------------- +sub process_log_line +{ + my $line = shift; + #($opt_v and $opt_g) and print "# $line"; + my $extract_cmd = 0; + if ($line =~ /getpkt /) + { + $extract_cmd = 1; + print "\n--> "; + } + elsif ($line =~ /putpkt /) + { + $extract_cmd = 1; + print "<-- "; + } + elsif ($line =~ /.*Sent: \[[0-9]+\.[0-9]+[:0-9]*\] (.*)/) + { + $opt_g and print "maintenance dump-packets command: $1\n"; + my @raw_cmd_bytes = split(/ */, $1); + print "\n--> "; + dump_raw_command(\@raw_cmd_bytes); + process_log_line($2); + } + elsif ($line =~ /.*Recvd: \[[0-9]+\.[0-9]+[:0-9]*\] (.*)/) + { + $opt_g and print "maintenance dump-packets reply: $1\n"; + my @raw_rsp_bytes = split(/ */, $1); + print "<-- "; + dump_raw_response(\@raw_rsp_bytes); + print "\n"; + } + elsif ($line =~ /getpkt: (.*)/) + { + if ($1 =~ /\$([^#]+)#[0-9a-fA-F]{2}/) + { + $opt_g and print "command: $1\n"; + my @raw_cmd_bytes = split(/ */, $1); + print "--> "; + dump_raw_command(\@raw_cmd_bytes); + } + elsif ($1 =~ /\+/) + { + #print "--> ACK\n"; + } + elsif ($1 =~ /-/) + { + #print "--> NACK\n"; + } + } + elsif ($line =~ /putpkt: (.*)/) + { + if ($1 =~ /\$([^#]+)#[0-9a-fA-F]{2}/) + { + $opt_g and print "response: $1\n"; + my @raw_rsp_bytes = split(/ */, $1); + print "<-- "; + dump_raw_response(\@raw_rsp_bytes); + print "\n"; + } + elsif ($1 =~ /\+/) + { + #print "<-- ACK\n"; + } + elsif ($1 =~ /-/) + { + #print "<-- NACK\n"; + } + } + elsif ($line =~ /send packet: (.*)/) + { + if ($1 =~ /\$([^#]+)#[0-9a-fA-F]{2}/) + { + $opt_g and print "command: $1\n"; + my @raw_cmd_bytes = split(/ */, $1); + print "--> "; + dump_raw_command(\@raw_cmd_bytes); + } + elsif ($1 =~ /\+/) + { + #print "--> ACK\n"; + } + elsif ($1 =~ /-/) + { + #print "--> NACK\n"; + } + } + elsif ($line =~ /read packet: (.*)/) + { + if ($1 =~ /\$([^#]+)#[0-9a-fA-F]{2}/) + { + $opt_g and print "response: $1\n"; + my @raw_rsp_bytes = split(/ */, $1); + print "<-- "; + dump_raw_response(\@raw_rsp_bytes); + print "\n"; + } + elsif ($1 =~ /\+/) + { + #print "<-- ACK\n"; + } + elsif ($1 =~ /-/) + { + #print "<-- NACK\n"; + } + } + elsif ($line =~ /Sending packet: \$([^#]+)#[0-9a-fA-F]{2}\.\.\.(.*)/) + { + $opt_g and print "command: $1\n"; + my @raw_cmd_bytes = split(/ */, $1); + print "\n--> "; + dump_raw_command(\@raw_cmd_bytes); + process_log_line($2); + } + elsif ($line =~ /Packet received: (.*)/) + { + $opt_g and print "response: $1\n"; + my @raw_rsp_bytes = split(/ */, $1); + print "<-- "; + dump_raw_response(\@raw_rsp_bytes); + print "\n"; + } + + if ($extract_cmd) + { + my $beg = index($line, '("') + 2; + my $end = rindex($line, '");'); + dump_command(substr($line, $beg, $end - $beg)); + } +} + + +our $line_num = 0; +while(<>) +{ + $line_num++; + $opt_q or printf("# %5d: $_", $line_num); + process_log_line($_); +} + + + + + + Propchange: lldb/trunk/scripts/disasm-gdb-remote.pl ------------------------------------------------------------------------------ svn:executable = * From gclayton at apple.com Thu May 19 22:15:54 2011 From: gclayton at apple.com (Greg Clayton) Date: Fri, 20 May 2011 03:15:54 -0000 Subject: [Lldb-commits] [lldb] r131715 - in /lldb/trunk: scripts/disasm-gdb-remote.pl source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV1.cpp source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.cpp Message-ID: <20110520031554.CE1042A6C12C@llvm.org> Author: gclayton Date: Thu May 19 22:15:54 2011 New Revision: 131715 URL: http://llvm.org/viewvc/llvm-project?rev=131715&view=rev Log: Fixed an issue in GDBRemoteCommunicationClient where we weren't listening to the "payload_length" argument for the "payload" packet data. This meant we could end up sending random extra data with a packet depending on how the packet was constructed. Fixed GDBRemoteRegisterContext to properly save and restore all registers. Previous fixes had been added to work around the "payload_length" issues fixed above and aren't needed anymore. Fix logging in GDBRemoteCommunication to make sure we log the correct packet data being sent by using the packet length when dumping the packet contents. Added register definitions for 'arm-lldb' in the "disasm-gdb-remote.pl" script so if you have a register dump from the GDB remote that doesn't include the qRegisterInfo packets, you can manually tell the script which registers are which. Modified: lldb/trunk/scripts/disasm-gdb-remote.pl lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV1.cpp lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.cpp Modified: lldb/trunk/scripts/disasm-gdb-remote.pl URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/scripts/disasm-gdb-remote.pl?rev=131715&r1=131714&r2=131715&view=diff ============================================================================== --- lldb/trunk/scripts/disasm-gdb-remote.pl (original) +++ lldb/trunk/scripts/disasm-gdb-remote.pl Thu May 19 22:15:54 2011 @@ -204,6 +204,95 @@ { name => 'd31' , info => $float64_href }, ], + + 'arm-lldb' => [ + { name => 'r0' , info => $reg32_href }, + { name => 'r1' , info => $reg32_href }, + { name => 'r2' , info => $reg32_href }, + { name => 'r3' , info => $reg32_href }, + { name => 'r4' , info => $reg32_href }, + { name => 'r5' , info => $reg32_href }, + { name => 'r6' , info => $reg32_href }, + { name => 'r7' , info => $reg32_href }, + { name => 'r8' , info => $reg32_href }, + { name => 'r9' , info => $reg32_href }, + { name => 'r10' , info => $reg32_href }, + { name => 'r11' , info => $reg32_href }, + { name => 'r12' , info => $reg32_href }, + { name => 'sp' , info => $reg32_href }, + { name => 'lr' , info => $reg32_href }, + { name => 'pc' , info => $reg32_href }, + { name => 'cpsr' , info => $reg32_href }, + { name => 's0' , info => $float32_href }, + { name => 's1' , info => $float32_href }, + { name => 's2' , info => $float32_href }, + { name => 's3' , info => $float32_href }, + { name => 's4' , info => $float32_href }, + { name => 's5' , info => $float32_href }, + { name => 's6' , info => $float32_href }, + { name => 's7' , info => $float32_href }, + { name => 's8' , info => $float32_href }, + { name => 's9' , info => $float32_href }, + { name => 's10' , info => $float32_href }, + { name => 's11' , info => $float32_href }, + { name => 's12' , info => $float32_href }, + { name => 's13' , info => $float32_href }, + { name => 's14' , info => $float32_href }, + { name => 's15' , info => $float32_href }, + { name => 's16' , info => $float32_href }, + { name => 's17' , info => $float32_href }, + { name => 's18' , info => $float32_href }, + { name => 's19' , info => $float32_href }, + { name => 's20' , info => $float32_href }, + { name => 's21' , info => $float32_href }, + { name => 's22' , info => $float32_href }, + { name => 's23' , info => $float32_href }, + { name => 's24' , info => $float32_href }, + { name => 's25' , info => $float32_href }, + { name => 's26' , info => $float32_href }, + { name => 's27' , info => $float32_href }, + { name => 's28' , info => $float32_href }, + { name => 's29' , info => $float32_href }, + { name => 's30' , info => $float32_href }, + { name => 's31' , info => $float32_href }, + { name => 'd0' , info => $float64_href }, + { name => 'd1' , info => $float64_href }, + { name => 'd2' , info => $float64_href }, + { name => 'd3' , info => $float64_href }, + { name => 'd4' , info => $float64_href }, + { name => 'd5' , info => $float64_href }, + { name => 'd6' , info => $float64_href }, + { name => 'd7' , info => $float64_href }, + { name => 'd8' , info => $float64_href }, + { name => 'd9' , info => $float64_href }, + { name => 'd10' , info => $float64_href }, + { name => 'd11' , info => $float64_href }, + { name => 'd12' , info => $float64_href }, + { name => 'd13' , info => $float64_href }, + { name => 'd14' , info => $float64_href }, + { name => 'd15' , info => $float64_href }, + { name => 'd16' , info => $float64_href }, + { name => 'd17' , info => $float64_href }, + { name => 'd18' , info => $float64_href }, + { name => 'd19' , info => $float64_href }, + { name => 'd20' , info => $float64_href }, + { name => 'd21' , info => $float64_href }, + { name => 'd22' , info => $float64_href }, + { name => 'd23' , info => $float64_href }, + { name => 'd24' , info => $float64_href }, + { name => 'd25' , info => $float64_href }, + { name => 'd26' , info => $float64_href }, + { name => 'd27' , info => $float64_href }, + { name => 'd28' , info => $float64_href }, + { name => 'd29' , info => $float64_href }, + { name => 'd30' , info => $float64_href }, + { name => 'd31' , info => $float64_href }, + { name => 'fpscr' , info => $reg32_href }, + { name => 'exc' , info => $reg32_href }, + { name => 'fsr' , info => $reg32_href }, + { name => 'far' , info => $reg32_href }, + ], + 'x86_64-gdb' => [ { name => 'rax' , info => $reg64_href }, { name => 'rbx' , info => $reg64_href }, Modified: lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV1.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV1.cpp?rev=131715&r1=131714&r2=131715&view=diff ============================================================================== --- lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV1.cpp (original) +++ lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV1.cpp Thu May 19 22:15:54 2011 @@ -147,7 +147,7 @@ "%s(void *$__lldb_arg_obj) \n" "{ \n" " struct __objc_object *obj = (struct __objc_object*)$__lldb_arg_obj; \n" - " strlen(obj->isa->name); \n" + " (int)strlen(obj->isa->name); \n" "} \n", name) < sizeof(buf->contents)); Modified: lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp?rev=131715&r1=131714&r2=131715&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp (original) +++ lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp Thu May 19 22:15:54 2011 @@ -138,7 +138,7 @@ LogSP log (ProcessGDBRemoteLog::GetLogIfAllCategoriesSet (GDBR_LOG_PACKETS)); if (log) - log->Printf ("send packet: %s", packet.GetData()); + log->Printf ("send packet: %.*s", (int)packet.GetSize(), packet.GetData()); ConnectionStatus status = eConnectionStatusSuccess; size_t bytes_written = Write (packet.GetData(), packet.GetSize(), status, NULL); if (bytes_written == packet.GetSize()) @@ -156,7 +156,7 @@ { LogSP log (ProcessGDBRemoteLog::GetLogIfAllCategoriesSet (GDBR_LOG_PACKETS)); if (log) - log->Printf ("error: failed to send packet: %s", packet.GetData()); + log->Printf ("error: failed to send packet: %.*s", (int)packet.GetSize(), packet.GetData()); } return bytes_written; } @@ -218,11 +218,11 @@ const EventDataBytes *event_bytes = EventDataBytes::GetEventDataFromEvent(event_sp.get()); if (event_bytes) { - const char * packet_data = (const char *)event_bytes->GetBytes(); + const char *packet_data = (const char *)event_bytes->GetBytes(); + const uint32_t packet_size = event_bytes->GetByteSize(); LogSP log (ProcessGDBRemoteLog::GetLogIfAllCategoriesSet (GDBR_LOG_PACKETS)); if (log) - log->Printf ("read packet: %s", packet_data); - const size_t packet_size = event_bytes->GetByteSize(); + log->Printf ("read packet: %.*s", packet_size, packet_data); if (packet_data && packet_size > 0) { std::string &packet_str = packet.GetStringRef(); @@ -242,9 +242,12 @@ packet_str.assign (packet_data + 1, packet_size - 4); if (GetSendAcks ()) { - char packet_checksum = strtol (&packet_data[packet_size-2], NULL, 16); - char actual_checksum = CalculcateChecksum (&packet_str[0], packet_str.size()); - checksum_error = packet_checksum != actual_checksum; + if (success) + { + char packet_checksum = strtol (&packet_data[packet_size-2], NULL, 16); + char actual_checksum = CalculcateChecksum (&packet_str[0], packet_str.size()); + checksum_error = packet_checksum != actual_checksum; + } // Send the ack or nack if needed if (checksum_error || !success) SendNack(); Modified: lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp?rev=131715&r1=131714&r2=131715&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp (original) +++ lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp Thu May 19 22:15:54 2011 @@ -252,7 +252,7 @@ if (GetSequenceMutex (locker)) { - if (SendPacketNoLock (payload, strlen(payload))) + if (SendPacketNoLock (payload, payload_length)) return WaitForPacketNoLock (response, &timeout_time); } else @@ -1597,8 +1597,8 @@ m_supports_qThreadStopInfo = false; } } - if (SetCurrentThread (tid)) - return GetStopReply (response); +// if (SetCurrentThread (tid)) +// return GetStopReply (response); return false; } Modified: lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.cpp?rev=131715&r1=131714&r2=131715&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.cpp (original) +++ lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.cpp Thu May 19 22:15:54 2011 @@ -356,18 +356,17 @@ if (response.IsErrorResponse()) return false; - response.GetStringRef().insert(0, 1, 'G'); - if (thread_suffix_supported) + std::string &response_str = response.GetStringRef(); + if (isxdigit(response_str[0])) { - char thread_id_cstr[64]; - ::snprintf (thread_id_cstr, sizeof(thread_id_cstr), ";thread:%4.4x;", m_thread.GetID()); - response.GetStringRef().append (thread_id_cstr); - } - const char *g_data = response.GetStringRef().c_str(); - size_t g_data_len = strspn(g_data + 1, "0123456789abcdefABCDEF"); - if (g_data_len > 0) - { - data_sp.reset (new DataBufferHeap (g_data, g_data_len)); + response_str.insert(0, 1, 'G'); + if (thread_suffix_supported) + { + char thread_id_cstr[64]; + ::snprintf (thread_id_cstr, sizeof(thread_id_cstr), ";thread:%4.4x;", m_thread.GetID()); + response_str.append (thread_id_cstr); + } + data_sp.reset (new DataBufferHeap (response_str.c_str(), response_str.size())); return true; } } From wilsons at start.ca Thu May 19 22:59:03 2011 From: wilsons at start.ca (Stephen Wilson) Date: Thu, 19 May 2011 23:59:03 -0400 Subject: [Lldb-commits] [PATCH] Do not parse DIE's outside a compilation units range Message-ID: <20110520035902.GA2703@wicker.gateway.2wire.net> Recently I hit a case where a lookup into the abbrev table failed. Consider the following code in DWARFDebugInfoEntry::FastExtract: if (abbrCode) { uint32_t offset = *offset_ptr; m_abbrevDecl = cu->GetAbbreviations()->GetAbbreviationDeclaration(abbrCode); // Skip all data in the .debug_info for the attributes const uint32_t numAttributes = m_abbrevDecl->NumAttributes(); The lookup fails, m_abbrevDecl is NULL, SIGSEGV... OK, we should probably check that the lookup is good to protect against the case of corrupt DWARF, but I do not think this lookup should fail in the normal case. In DWARFCompileUnit::ExtractDIEsIfNeeded we are relying on a compilation units DIEs to be terminated by a null entry. I think the standard is fairly clear that all sibling chains are to be terminated by null, but at least gcc 4.5.2 disagrees -- the top level chain drops the final entry. This results in us interpreting the next compilation unit header as a DIE, thus generating the bogus abbrCode. Regardless of whether gcc is right or wrong, we should not overstep a compilation units extent. The following patch ensures that we do not attempt to extract a DIE beyond the length specified for a given DWARFCompileUnit by ensuring our current offset is strictly less than the start of the next CU. diff --git a/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp b/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp index 966d28f..1e0431a 100644 --- a/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp +++ b/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp @@ -154,8 +154,11 @@ DWARFCompileUnit::ExtractDIEsIfNeeded (bool cu_die_only) m_offset, cu_die_only); - // Set the offset to that of the first DIE + // Set the offset to that of the first DIE and calculate the start of the + // next compilation unit header. uint32_t offset = GetFirstDIEOffset(); + uint32_t next_cu_offset = GetNextCompileUnitOffset(); + DWARFDebugInfoEntry die; // Keep a flat array of the DIE for binary lookup by DIE offset // Log *log = LogChannelDWARF::GetLogIfAll(DWARF_LOG_DEBUG_INFO); @@ -173,7 +176,8 @@ DWARFCompileUnit::ExtractDIEsIfNeeded (bool cu_die_only) const DataExtractor& debug_info_data = m_dwarf2Data->get_debug_info_data(); const uint8_t *fixed_form_sizes = DWARFFormValue::GetFixedFormSizesForAddressSize (GetAddressByteSize()); - while (die.FastExtract (debug_info_data, this, fixed_form_sizes, &offset)) + while (offset < next_cu_offset && + die.FastExtract (debug_info_data, this, fixed_form_sizes, &offset)) { // if (log) // log->Printf("0x%8.8x: %*.*s%s%s", @@ -220,18 +224,22 @@ DWARFCompileUnit::ExtractDIEsIfNeeded (bool cu_die_only) break; // We are done with this compile unit! } - if (offset > GetNextCompileUnitOffset()) + } + + // Give a little bit of info if we encounter corrupt DWARF (our offset + // should always terminate at or before the start of the next compilation + // unit header). + if (offset > next_cu_offset) + { + char path[PATH_MAX]; + ObjectFile *objfile = m_dwarf2Data->GetObjectFile(); + if (objfile) { - char path[PATH_MAX]; - ObjectFile *objfile = m_dwarf2Data->GetObjectFile(); - if (objfile) - { - objfile->GetFileSpec().GetPath(path, sizeof(path)); - } - fprintf (stderr, "warning: DWARF compile unit extends beyond its bounds cu 0x%8.8x at 0x%8.8x in '%s'\n", GetOffset(), offset, path); - break; + objfile->GetFileSpec().GetPath(path, sizeof(path)); } + fprintf (stderr, "warning: DWARF compile unit extends beyond its bounds cu 0x%8.8x at 0x%8.8x in '%s'\n", GetOffset(), offset, path); } + SetDIERelations(); return m_die_array.size(); } From gclayton at apple.com Thu May 19 23:04:13 2011 From: gclayton at apple.com (Greg Clayton) Date: Thu, 19 May 2011 21:04:13 -0700 Subject: [Lldb-commits] [PATCH] Assorted build fixes In-Reply-To: <4DD5B054.3070904@mymail.mines.edu> References: <4DD172E6.3090906@mymail.mines.edu> <4DD5B054.3070904@mymail.mines.edu> Message-ID: Looks ok to me. Feel free to commit when you get the chance! Greg Clayton On May 19, 2011, at 5:05 PM, Charles Davis wrote: > On 5/16/11 12:54 PM, Charles Davis wrote: >> Hi, >> >> This patch fixes some issues I encountered building with the Makefiles >> on Darwin (which were preventing me from finishing builds without >> disabling lldb support): > OK, since no one has said anything, I went ahead and committed some of > my build fixes (subject to post-commit review). I still haven't, > however, committed the Host/macosx build fixes yet. I also made the > makefiles install the python modules. I haven't committed these because > they seem somewhat hackish. I've posted the patch for both here, and > this time I want someone to actually review the patch. I'm not going to > commit either one of these until I get feedback. > > I reiterate: I will not commit the changes in the attached patch until > someone reviews them. > > Chip > _______________________________________________ > lldb-commits mailing list > lldb-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/lldb-commits From cdavis at mines.edu Thu May 19 23:04:17 2011 From: cdavis at mines.edu (Charles Davis) Date: Fri, 20 May 2011 04:04:17 -0000 Subject: [Lldb-commits] [lldb] r131718 - in /lldb/trunk/source/Host/macosx: Host.mm Makefile Message-ID: <20110520040418.0BDED2A6C12C@llvm.org> Author: cdavis Date: Thu May 19 23:04:17 2011 New Revision: 131718 URL: http://llvm.org/viewvc/llvm-project?rev=131718&view=rev Log: Fix the Host library build on Mac OS X with makefiles. Modified: lldb/trunk/source/Host/macosx/Host.mm lldb/trunk/source/Host/macosx/Makefile Modified: lldb/trunk/source/Host/macosx/Host.mm URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/macosx/Host.mm?rev=131718&r1=131717&r2=131718&view=diff ============================================================================== --- lldb/trunk/source/Host/macosx/Host.mm (original) +++ lldb/trunk/source/Host/macosx/Host.mm Thu May 19 23:04:17 2011 @@ -565,7 +565,7 @@ extern "C" { const char *__crashreporter_info__ = NULL; -}; +} asm(".desc ___crashreporter_info__, 0x10"); Modified: lldb/trunk/source/Host/macosx/Makefile URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/macosx/Makefile?rev=131718&r1=131717&r2=131718&view=diff ============================================================================== --- lldb/trunk/source/Host/macosx/Makefile (original) +++ lldb/trunk/source/Host/macosx/Makefile Thu May 19 23:04:17 2011 @@ -11,6 +11,14 @@ LIBRARYNAME := lldbHostMacOSX BUILD_ARCHIVE = 1 -SOURCES := $(notdir $(wildcard *.cpp *.mm)) +SOURCES = $(notdir $(wildcard $(PROJ_SRC_DIR)/*.cpp $(PROJ_SRC_DIR)/*.mm)) \ + $(addprefix cfcpp/,$(notdir $(wildcard $(PROJ_SRC_DIR)/cfcpp/*.cpp))) + +# Make sure the cfcpp output directory exists +all-local:: $(PROJ_OBJ_DIR)/$(BuildMode)/cfcpp + +$(PROJ_OBJ_DIR)/$(BuildMode)/cfcpp: + -$(Verb) $(MKDIR) $(PROJ_OBJ_DIR)/$(BuildMode)/cfcpp 2>/dev/null include $(LLDB_LEVEL)/Makefile + From gclayton at apple.com Thu May 19 23:11:03 2011 From: gclayton at apple.com (Greg Clayton) Date: Thu, 19 May 2011 21:11:03 -0700 Subject: [Lldb-commits] [PATCH] Do not parse DIE's outside a compilation units range In-Reply-To: <20110520035902.GA2703@wicker.gateway.2wire.net> References: <20110520035902.GA2703@wicker.gateway.2wire.net> Message-ID: Looks good, commit when ready. We have run into such cases as well, so this will be a good fix. I have been working on our clang and llvm compiler engineers to have the debug builds of the compiler driver include a call to a DWARF verification binary (on MacOSX "dwarfdump --verify --debug-info --eh-frame " will verify the DWARF) and flag any .o file that is produced with bad DWARF. It is very common for lexical blocks to have incorrectly scoped hi and low PC values, arrays and other types to be missing a type, and other illegal DWARF. We need to come up with a centralized place to emit errors and warnings. We should probably add a few static functions to lldb_private::Debugger so we can easily re-route the errors and warnings by changing one function instead of changing many fprintf to stderr. I am guilty of adding the same kind of code lately, but it would be good to centralize the warning and error output at some point. Greg Clayton On May 19, 2011, at 8:59 PM, Stephen Wilson wrote: > > Recently I hit a case where a lookup into the abbrev table failed. Consider > the following code in DWARFDebugInfoEntry::FastExtract: > > if (abbrCode) > { > uint32_t offset = *offset_ptr; > > m_abbrevDecl = cu->GetAbbreviations()->GetAbbreviationDeclaration(abbrCode); > > // Skip all data in the .debug_info for the attributes > const uint32_t numAttributes = m_abbrevDecl->NumAttributes(); > > The lookup fails, m_abbrevDecl is NULL, SIGSEGV... > > OK, we should probably check that the lookup is good to protect against the > case of corrupt DWARF, but I do not think this lookup should fail in the > normal case. > > > In DWARFCompileUnit::ExtractDIEsIfNeeded we are relying on a compilation units > DIEs to be terminated by a null entry. I think the standard is fairly clear > that all sibling chains are to be terminated by null, but at least gcc 4.5.2 > disagrees -- the top level chain drops the final entry. This results in us > interpreting the next compilation unit header as a DIE, thus generating the > bogus abbrCode. > > Regardless of whether gcc is right or wrong, we should not overstep a > compilation units extent. The following patch ensures that we do not attempt > to extract a DIE beyond the length specified for a given DWARFCompileUnit by > ensuring our current offset is strictly less than the start of the next CU. > > > > diff --git a/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp b/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp > index 966d28f..1e0431a 100644 > --- a/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp > +++ b/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp > @@ -154,8 +154,11 @@ DWARFCompileUnit::ExtractDIEsIfNeeded (bool cu_die_only) > m_offset, > cu_die_only); > > - // Set the offset to that of the first DIE > + // Set the offset to that of the first DIE and calculate the start of the > + // next compilation unit header. > uint32_t offset = GetFirstDIEOffset(); > + uint32_t next_cu_offset = GetNextCompileUnitOffset(); > + > DWARFDebugInfoEntry die; > // Keep a flat array of the DIE for binary lookup by DIE offset > // Log *log = LogChannelDWARF::GetLogIfAll(DWARF_LOG_DEBUG_INFO); > @@ -173,7 +176,8 @@ DWARFCompileUnit::ExtractDIEsIfNeeded (bool cu_die_only) > const DataExtractor& debug_info_data = m_dwarf2Data->get_debug_info_data(); > > const uint8_t *fixed_form_sizes = DWARFFormValue::GetFixedFormSizesForAddressSize (GetAddressByteSize()); > - while (die.FastExtract (debug_info_data, this, fixed_form_sizes, &offset)) > + while (offset < next_cu_offset && > + die.FastExtract (debug_info_data, this, fixed_form_sizes, &offset)) > { > // if (log) > // log->Printf("0x%8.8x: %*.*s%s%s", > @@ -220,18 +224,22 @@ DWARFCompileUnit::ExtractDIEsIfNeeded (bool cu_die_only) > break; // We are done with this compile unit! > } > > - if (offset > GetNextCompileUnitOffset()) > + } > + > + // Give a little bit of info if we encounter corrupt DWARF (our offset > + // should always terminate at or before the start of the next compilation > + // unit header). > + if (offset > next_cu_offset) > + { > + char path[PATH_MAX]; > + ObjectFile *objfile = m_dwarf2Data->GetObjectFile(); > + if (objfile) > { > - char path[PATH_MAX]; > - ObjectFile *objfile = m_dwarf2Data->GetObjectFile(); > - if (objfile) > - { > - objfile->GetFileSpec().GetPath(path, sizeof(path)); > - } > - fprintf (stderr, "warning: DWARF compile unit extends beyond its bounds cu 0x%8.8x at 0x%8.8x in '%s'\n", GetOffset(), offset, path); > - break; > + objfile->GetFileSpec().GetPath(path, sizeof(path)); > } > + fprintf (stderr, "warning: DWARF compile unit extends beyond its bounds cu 0x%8.8x at 0x%8.8x in '%s'\n", GetOffset(), offset, path); > } > + > SetDIERelations(); > return m_die_array.size(); > } From gclayton at apple.com Thu May 19 23:12:26 2011 From: gclayton at apple.com (Greg Clayton) Date: Thu, 19 May 2011 21:12:26 -0700 Subject: [Lldb-commits] [lldb] r131718 - in /lldb/trunk/source/Host/macosx: Host.mm Makefile In-Reply-To: <20110520040418.0BDED2A6C12C@llvm.org> References: <20110520040418.0BDED2A6C12C@llvm.org> Message-ID: <20786280-2336-4BBC-99E4-ADE3D4A174C9@apple.com> Did you miss the interpreter Makefile from your patch? On May 19, 2011, at 9:04 PM, Charles Davis wrote: > Author: cdavis > Date: Thu May 19 23:04:17 2011 > New Revision: 131718 > > URL: http://llvm.org/viewvc/llvm-project?rev=131718&view=rev > Log: > Fix the Host library build on Mac OS X with makefiles. > > Modified: > lldb/trunk/source/Host/macosx/Host.mm > lldb/trunk/source/Host/macosx/Makefile > > Modified: lldb/trunk/source/Host/macosx/Host.mm > URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/macosx/Host.mm?rev=131718&r1=131717&r2=131718&view=diff > ============================================================================== > --- lldb/trunk/source/Host/macosx/Host.mm (original) > +++ lldb/trunk/source/Host/macosx/Host.mm Thu May 19 23:04:17 2011 > @@ -565,7 +565,7 @@ > > extern "C" { > const char *__crashreporter_info__ = NULL; > -}; > +} > > asm(".desc ___crashreporter_info__, 0x10"); > > > Modified: lldb/trunk/source/Host/macosx/Makefile > URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/macosx/Makefile?rev=131718&r1=131717&r2=131718&view=diff > ============================================================================== > --- lldb/trunk/source/Host/macosx/Makefile (original) > +++ lldb/trunk/source/Host/macosx/Makefile Thu May 19 23:04:17 2011 > @@ -11,6 +11,14 @@ > LIBRARYNAME := lldbHostMacOSX > BUILD_ARCHIVE = 1 > > -SOURCES := $(notdir $(wildcard *.cpp *.mm)) > +SOURCES = $(notdir $(wildcard $(PROJ_SRC_DIR)/*.cpp $(PROJ_SRC_DIR)/*.mm)) \ > + $(addprefix cfcpp/,$(notdir $(wildcard $(PROJ_SRC_DIR)/cfcpp/*.cpp))) > + > +# Make sure the cfcpp output directory exists > +all-local:: $(PROJ_OBJ_DIR)/$(BuildMode)/cfcpp > + > +$(PROJ_OBJ_DIR)/$(BuildMode)/cfcpp: > + -$(Verb) $(MKDIR) $(PROJ_OBJ_DIR)/$(BuildMode)/cfcpp 2>/dev/null > > include $(LLDB_LEVEL)/Makefile > + > > > _______________________________________________ > lldb-commits mailing list > lldb-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/lldb-commits From cdavis at mymail.mines.edu Thu May 19 23:13:57 2011 From: cdavis at mymail.mines.edu (Charles Davis) Date: Thu, 19 May 2011 22:13:57 -0600 Subject: [Lldb-commits] [lldb] r131718 - in /lldb/trunk/source/Host/macosx: Host.mm Makefile In-Reply-To: <20786280-2336-4BBC-99E4-ADE3D4A174C9@apple.com> References: <20110520040418.0BDED2A6C12C@llvm.org> <20786280-2336-4BBC-99E4-ADE3D4A174C9@apple.com> Message-ID: <4DD5EA85.8030404@mymail.mines.edu> On 5/19/11 10:12 PM, Greg Clayton wrote: > Did you miss the interpreter Makefile from your patch? No, I'm committing that separately. It's an unrelated change, and I like to keep those separate. Chip From cdavis at mines.edu Thu May 19 23:09:55 2011 From: cdavis at mines.edu (Charles Davis) Date: Fri, 20 May 2011 04:09:55 -0000 Subject: [Lldb-commits] [lldb] r131719 - /lldb/trunk/source/Interpreter/Makefile Message-ID: <20110520040955.90CBE2A6C12C@llvm.org> Author: cdavis Date: Thu May 19 23:09:55 2011 New Revision: 131719 URL: http://llvm.org/viewvc/llvm-project?rev=131719&view=rev Log: Some makefile fixes for the Interpreter: - Make the generation of LLDBWrapPython.cpp respect the VERBOSE setting. - Use -classic mode when generating. LLDPWrapPython.cpp #errors out if -classic wasn't set when it was generated with recent Swig. - Install the Python modules. Now we shouldn't get loads of Python errors trying to run LLDB. Last of my build fixes. The LLDB that I built works, except that I can't debug anything with it until debugserver gets built. Modified: lldb/trunk/source/Interpreter/Makefile Modified: lldb/trunk/source/Interpreter/Makefile URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Interpreter/Makefile?rev=131719&r1=131718&r2=131719&view=diff ============================================================================== --- lldb/trunk/source/Interpreter/Makefile (original) +++ lldb/trunk/source/Interpreter/Makefile Thu May 19 23:09:55 2011 @@ -18,7 +18,13 @@ LLDB_PYTHON_SWIG_CPP = $(PROJ_OBJ_ROOT)/$(BuildMode)/LLDBWrapPython.cpp LLDB_BIN_DIR := $(PROJ_OBJ_ROOT)/$(BuildMode)/bin PYTHON_DIR := $(LLDB_BIN_DIR) +ifeq ($(HOST_OS),Darwin) +PYTHON_DEST_DIR := /Library/Python/$(shell python -c 'import sys; print sys.version[:3]')/site-packages +else +PYTHON_DEST_DIR := $(shell python -c 'import sys; print sys.exec_prefix')/lib/python$(shell python -c 'import sys; pritn sys.version[:3]')/site-packages +endif LLDB_SWIG_INCLUDE_DIRS:= -I"$(PROJ_SRC_DIR)/$(LLDB_LEVEL)/include" -I./. +LIBLLDB := $(PROJ_OBJ_ROOT)/$(BuildMode)/lib/liblldb$(SHLIBEXT) # We need Swig to process stdint.h, but by default it will not inspect system # include directories. The following should cover the standard locations on @@ -27,7 +33,16 @@ LLDB_SWIG_INCLUDE_DIRS += -I"/usr/include" LLDBWrapPython.cpp: - swig -c++ -shadow -python $(LLDB_SWIG_INCLUDE_DIRS) \ + $(Echo) Generating LLDBWrapPython.cpp + $(Verb) swig -c++ -classic -shadow -python $(LLDB_SWIG_INCLUDE_DIRS) \ -D__STDC_LIMIT_MACROS -outdir "$(LLDB_BIN_DIR)" \ -o LLDBWrapPython.cpp "$(PROJ_SRC_DIR)/$(LLDB_LEVEL)/scripts/lldb.swig" - cp "$(PROJ_SRC_DIR)/embedded_interpreter.py" "$(PYTHON_DIR)" + $(Verb) cp "$(PROJ_SRC_DIR)/embedded_interpreter.py" "$(PYTHON_DIR)" + +install-local:: $(PYTHON_DIR)/lldb.py $(PYTHON_DIR)/embedded_interpreter.py $(LIBLLDB) + $(Echo) Installing $(BuildMode) LLDB python modules + $(Verb) $(MKDIR) $(PYTHON_DEST_DIR)/lib-dynload + $(Verb) $(DataInstall) $(PYTHON_DIR)/lldb.py $(PYTHON_DEST_DIR)/lldb.py + $(Verb) $(DataInstall) $(PYTHON_DIR)/embedded_interpreter.py $(PYTHON_DEST_DIR)/embedded_interpreter.py + $(Verb) $(RM) -f $(PYTHON_DEST_DIR)/lib-dynload/_lldb.so + $(Verb) $(AliasTool) $(LIBLLDB) $(PYTHON_DEST_DIR)/lib-dynload/_lldb.so From cdavis at mymail.mines.edu Thu May 19 23:15:48 2011 From: cdavis at mymail.mines.edu (Charles Davis) Date: Thu, 19 May 2011 22:15:48 -0600 Subject: [Lldb-commits] [PATCH] Assorted build fixes In-Reply-To: References: <4DD172E6.3090906@mymail.mines.edu> <4DD5B054.3070904@mymail.mines.edu> Message-ID: <4DD5EAF4.6030500@mymail.mines.edu> On 5/19/11 10:04 PM, Greg Clayton wrote: > Looks ok to me. Feel free to commit when you get the chance! Thanks. Done in r131718 and r131719. Chip From wilsons at start.ca Thu May 19 23:26:39 2011 From: wilsons at start.ca (Stephen Wilson) Date: Fri, 20 May 2011 00:26:39 -0400 Subject: [Lldb-commits] [PATCH] Assorted build fixes In-Reply-To: <4DD5B054.3070904@mymail.mines.edu> References: <4DD172E6.3090906@mymail.mines.edu> <4DD5B054.3070904@mymail.mines.edu> Message-ID: <20110520042639.GA19198@wicker.gateway.2wire.net> Argg, just missed the commit :) On Thu, May 19, 2011 at 06:05:40PM -0600, Charles Davis wrote: > --- source/Interpreter/Makefile (revision 131702) > +++ source/Interpreter/Makefile (working copy) > @@ -18,7 +18,13 @@ > LLDB_PYTHON_SWIG_CPP = $(PROJ_OBJ_ROOT)/$(BuildMode)/LLDBWrapPython.cpp > LLDB_BIN_DIR := $(PROJ_OBJ_ROOT)/$(BuildMode)/bin > PYTHON_DIR := $(LLDB_BIN_DIR) > +ifeq ($(HOST_OS),Darwin) > +PYTHON_DEST_DIR := /Library/Python/$(shell python -c 'import sys; print sys.version[:3]')/site-packages > +else > +PYTHON_DEST_DIR := $(shell python -c 'import sys; print sys.exec_prefix')/lib/python$(shell python -c 'import sys; pritn sys.version[:3]')/site-packages ^^^^^ I think that "pritn" should be a "print". -- steve From cdavis at mines.edu Thu May 19 23:22:48 2011 From: cdavis at mines.edu (Charles Davis) Date: Fri, 20 May 2011 04:22:48 -0000 Subject: [Lldb-commits] [lldb] r131720 - /lldb/trunk/source/Interpreter/Makefile Message-ID: <20110520042248.C947F2A6C12C@llvm.org> Author: cdavis Date: Thu May 19 23:22:48 2011 New Revision: 131720 URL: http://llvm.org/viewvc/llvm-project?rev=131720&view=rev Log: Fix typo. Stupid 'n' key... Modified: lldb/trunk/source/Interpreter/Makefile Modified: lldb/trunk/source/Interpreter/Makefile URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Interpreter/Makefile?rev=131720&r1=131719&r2=131720&view=diff ============================================================================== --- lldb/trunk/source/Interpreter/Makefile (original) +++ lldb/trunk/source/Interpreter/Makefile Thu May 19 23:22:48 2011 @@ -21,7 +21,7 @@ ifeq ($(HOST_OS),Darwin) PYTHON_DEST_DIR := /Library/Python/$(shell python -c 'import sys; print sys.version[:3]')/site-packages else -PYTHON_DEST_DIR := $(shell python -c 'import sys; print sys.exec_prefix')/lib/python$(shell python -c 'import sys; pritn sys.version[:3]')/site-packages +PYTHON_DEST_DIR := $(shell python -c 'import sys; print sys.exec_prefix')/lib/python$(shell python -c 'import sys; print sys.version[:3]')/site-packages endif LLDB_SWIG_INCLUDE_DIRS:= -I"$(PROJ_SRC_DIR)/$(LLDB_LEVEL)/include" -I./. LIBLLDB := $(PROJ_OBJ_ROOT)/$(BuildMode)/lib/liblldb$(SHLIBEXT) From cdavis at mymail.mines.edu Thu May 19 23:28:30 2011 From: cdavis at mymail.mines.edu (Charles Davis) Date: Thu, 19 May 2011 22:28:30 -0600 Subject: [Lldb-commits] [PATCH] Assorted build fixes In-Reply-To: <20110520042639.GA19198@wicker.gateway.2wire.net> References: <4DD172E6.3090906@mymail.mines.edu> <4DD5B054.3070904@mymail.mines.edu> <20110520042639.GA19198@wicker.gateway.2wire.net> Message-ID: <4DD5EDEE.6040005@mymail.mines.edu> On 5/19/11 10:26 PM, Stephen Wilson wrote: > > > Argg, just missed the commit :) > > On Thu, May 19, 2011 at 06:05:40PM -0600, Charles Davis wrote: >> --- source/Interpreter/Makefile (revision 131702) >> +++ source/Interpreter/Makefile (working copy) >> @@ -18,7 +18,13 @@ >> LLDB_PYTHON_SWIG_CPP = $(PROJ_OBJ_ROOT)/$(BuildMode)/LLDBWrapPython.cpp >> LLDB_BIN_DIR := $(PROJ_OBJ_ROOT)/$(BuildMode)/bin >> PYTHON_DIR := $(LLDB_BIN_DIR) >> +ifeq ($(HOST_OS),Darwin) >> +PYTHON_DEST_DIR := /Library/Python/$(shell python -c 'import sys; print sys.version[:3]')/site-packages >> +else >> +PYTHON_DEST_DIR := $(shell python -c 'import sys; print sys.exec_prefix')/lib/python$(shell python -c 'import sys; pritn sys.version[:3]')/site-packages > ^^^^^ > I think that "pritn" should be a "print". Yep, you're right. Fixed in r131720. (Stupid 'n' key...) Chip From wilsons at start.ca Thu May 19 23:27:12 2011 From: wilsons at start.ca (Stephen Wilson) Date: Fri, 20 May 2011 04:27:12 -0000 Subject: [Lldb-commits] [lldb] r131721 - /lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp Message-ID: <20110520042712.4331F2A6C12C@llvm.org> Author: wilsons Date: Thu May 19 23:27:12 2011 New Revision: 131721 URL: http://llvm.org/viewvc/llvm-project?rev=131721&view=rev Log: Do not parse DIE's outside a compilation units range. In DWARFCompileUnit::ExtractDIEsIfNeeded we are relying on a compilation units DIEs to be terminated by a null entry. I think the standard is fairly clear that all sibling chains are to be terminated by null, but at least gcc 4.5.2 disagrees -- the top level chain drops the final entry. This results in us interpreting the next compilation unit header as a DIE. Regardless of whether gcc is right or wrong, we should not overstep a compilation units extent. This patch ensures that we do not attempt to extract a DIE beyond the length specified for a given DWARFCompileUnit by ensuring our current offset is strictly less than the start of the next CU. Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp?rev=131721&r1=131720&r2=131721&view=diff ============================================================================== --- lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp (original) +++ lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp Thu May 19 23:27:12 2011 @@ -154,8 +154,11 @@ m_offset, cu_die_only); - // Set the offset to that of the first DIE + // Set the offset to that of the first DIE and calculate the start of the + // next compilation unit header. uint32_t offset = GetFirstDIEOffset(); + uint32_t next_cu_offset = GetNextCompileUnitOffset(); + DWARFDebugInfoEntry die; // Keep a flat array of the DIE for binary lookup by DIE offset // Log *log = LogChannelDWARF::GetLogIfAll(DWARF_LOG_DEBUG_INFO); @@ -173,7 +176,8 @@ const DataExtractor& debug_info_data = m_dwarf2Data->get_debug_info_data(); const uint8_t *fixed_form_sizes = DWARFFormValue::GetFixedFormSizesForAddressSize (GetAddressByteSize()); - while (die.FastExtract (debug_info_data, this, fixed_form_sizes, &offset)) + while (offset < next_cu_offset && + die.FastExtract (debug_info_data, this, fixed_form_sizes, &offset)) { // if (log) // log->Printf("0x%8.8x: %*.*s%s%s", @@ -220,18 +224,22 @@ break; // We are done with this compile unit! } - if (offset > GetNextCompileUnitOffset()) + } + + // Give a little bit of info if we encounter corrupt DWARF (our offset + // should always terminate at or before the start of the next compilation + // unit header). + if (offset > next_cu_offset) + { + char path[PATH_MAX]; + ObjectFile *objfile = m_dwarf2Data->GetObjectFile(); + if (objfile) { - char path[PATH_MAX]; - ObjectFile *objfile = m_dwarf2Data->GetObjectFile(); - if (objfile) - { - objfile->GetFileSpec().GetPath(path, sizeof(path)); - } - fprintf (stderr, "warning: DWARF compile unit extends beyond its bounds cu 0x%8.8x at 0x%8.8x in '%s'\n", GetOffset(), offset, path); - break; + objfile->GetFileSpec().GetPath(path, sizeof(path)); } + fprintf (stderr, "warning: DWARF compile unit extends beyond its bounds cu 0x%8.8x at 0x%8.8x in '%s'\n", GetOffset(), offset, path); } + SetDIERelations(); return m_die_array.size(); } From johnny.chen at apple.com Fri May 20 12:27:37 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Fri, 20 May 2011 17:27:37 -0000 Subject: [Lldb-commits] [lldb] r131738 - /lldb/trunk/source/Plugins/Disassembler/llvm/DisassemblerLLVM.cpp Message-ID: <20110520172737.F07592A6C12C@llvm.org> Author: johnny Date: Fri May 20 12:27:37 2011 New Revision: 131738 URL: http://llvm.org/viewvc/llvm-project?rev=131738&view=rev Log: Workaround the issue of llvm:tB (A8.6.16 B Encoding T2) not being processed as a branch instruction and therefore the symbolic information is not being dumped for non-raw mode. The problem is that the ARMAsmParser is not recognizing the "#274" in "b #274" as a valid operand when doing disassembly in non-raw mode. Modified: lldb/trunk/source/Plugins/Disassembler/llvm/DisassemblerLLVM.cpp Modified: lldb/trunk/source/Plugins/Disassembler/llvm/DisassemblerLLVM.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Disassembler/llvm/DisassemblerLLVM.cpp?rev=131738&r1=131737&r2=131738&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Disassembler/llvm/DisassemblerLLVM.cpp (original) +++ lldb/trunk/source/Plugins/Disassembler/llvm/DisassemblerLLVM.cpp Fri May 20 12:27:37 2011 @@ -310,6 +310,30 @@ } } // for (tokenIndex) + // FIXME!!! + // Workaround for llvm::tB's operands not properly parsed by ARMAsmParser. + if (m_arch_type == llvm::Triple::thumb && opcode.GetString() == "b") { + const char *inst_str; + char *pos = NULL; + if (EDGetInstString(&inst_str, m_inst) == 0 && (pos = strstr(inst_str, "#")) != NULL) { + uint64_t operand_value = PC + atoi(++pos); + operands.Printf("0x%llx ", operand_value); + + lldb_private::Address so_addr; + if (exe_ctx && exe_ctx->target && !exe_ctx->target->GetSectionLoadList().IsEmpty()) { + if (exe_ctx->target->GetSectionLoadList().ResolveLoadAddress (operand_value, so_addr)) + so_addr.Dump(&comment, exe_scope, Address::DumpStyleResolvedDescriptionNoModule, Address::DumpStyleSectionNameOffset); + } else { + Module *module = GetAddress().GetModule(); + if (module) { + if (module->ResolveFileAddress (operand_value, so_addr)) + so_addr.Dump(&comment, exe_scope, Address::DumpStyleResolvedDescriptionNoModule, Address::DumpStyleSectionNameOffset); + } + } + } + } + // END of workaround. + // If both operands and comment are empty, we will just print out // the raw disassembly. if (operands.GetString().empty() && comment.GetString().empty()) From cdavis at mines.edu Fri May 20 13:14:38 2011 From: cdavis at mines.edu (Charles Davis) Date: Fri, 20 May 2011 18:14:38 -0000 Subject: [Lldb-commits] [lldb] r131741 - /lldb/trunk/source/Interpreter/Makefile Message-ID: <20110520181438.2564F2A6C12C@llvm.org> Author: cdavis Date: Fri May 20 13:14:37 2011 New Revision: 131741 URL: http://llvm.org/viewvc/llvm-project?rev=131741&view=rev Log: When installing the binary part of the LLDB Python modules, symlink to the installed liblldb instead of the built one. Now Python support won't break if you clean your build directories. Modified: lldb/trunk/source/Interpreter/Makefile Modified: lldb/trunk/source/Interpreter/Makefile URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Interpreter/Makefile?rev=131741&r1=131740&r2=131741&view=diff ============================================================================== --- lldb/trunk/source/Interpreter/Makefile (original) +++ lldb/trunk/source/Interpreter/Makefile Fri May 20 13:14:37 2011 @@ -24,7 +24,7 @@ PYTHON_DEST_DIR := $(shell python -c 'import sys; print sys.exec_prefix')/lib/python$(shell python -c 'import sys; print sys.version[:3]')/site-packages endif LLDB_SWIG_INCLUDE_DIRS:= -I"$(PROJ_SRC_DIR)/$(LLDB_LEVEL)/include" -I./. -LIBLLDB := $(PROJ_OBJ_ROOT)/$(BuildMode)/lib/liblldb$(SHLIBEXT) +LIBLLDB := $(DESTDIR)$(PROJ_libdir)/liblldb$(SHLIBEXT) # We need Swig to process stdint.h, but by default it will not inspect system # include directories. The following should cover the standard locations on From cdavis at mines.edu Fri May 20 13:18:09 2011 From: cdavis at mines.edu (Charles Davis) Date: Fri, 20 May 2011 18:18:09 -0000 Subject: [Lldb-commits] [lldb] r131742 - /lldb/trunk/source/Host/macosx/Makefile Message-ID: <20110520181809.DF46F2A6C12C@llvm.org> Author: cdavis Date: Fri May 20 13:18:09 2011 New Revision: 131742 URL: http://llvm.org/viewvc/llvm-project?rev=131742&view=rev Log: Better way to build the CFCPP sources as part of liblldbHostMacOSX. Modified: lldb/trunk/source/Host/macosx/Makefile Modified: lldb/trunk/source/Host/macosx/Makefile URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/macosx/Makefile?rev=131742&r1=131741&r2=131742&view=diff ============================================================================== --- lldb/trunk/source/Host/macosx/Makefile (original) +++ lldb/trunk/source/Host/macosx/Makefile Fri May 20 13:18:09 2011 @@ -11,14 +11,16 @@ LIBRARYNAME := lldbHostMacOSX BUILD_ARCHIVE = 1 -SOURCES = $(notdir $(wildcard $(PROJ_SRC_DIR)/*.cpp $(PROJ_SRC_DIR)/*.mm)) \ +CFCPP_SOURCES = \ $(addprefix cfcpp/,$(notdir $(wildcard $(PROJ_SRC_DIR)/cfcpp/*.cpp))) +SOURCES = $(notdir $(wildcard $(PROJ_SRC_DIR)/*.cpp $(PROJ_SRC_DIR)/*.mm)) \ + $(CFCPP_SOURCES) -# Make sure the cfcpp output directory exists -all-local:: $(PROJ_OBJ_DIR)/$(BuildMode)/cfcpp +include $(LLDB_LEVEL)/Makefile -$(PROJ_OBJ_DIR)/$(BuildMode)/cfcpp: - -$(Verb) $(MKDIR) $(PROJ_OBJ_DIR)/$(BuildMode)/cfcpp 2>/dev/null +CFCPP_BaseNameSources := $(sort $(basename $(CFCPP_SOURCES))) +CFCPP_OBJECTS := $(CFCPP_BaseNameSources:%=$(ObjDir)/%.o) -include $(LLDB_LEVEL)/Makefile +# Make sure the cfcpp output directory exists +$(CFCPP_OBJECTS): $(ObjDir)/cfcpp/.dir From gclayton at apple.com Fri May 20 17:07:17 2011 From: gclayton at apple.com (Greg Clayton) Date: Fri, 20 May 2011 22:07:17 -0000 Subject: [Lldb-commits] [lldb] r131762 - /lldb/trunk/source/API/SBValue.cpp Message-ID: <20110520220717.4B3842A6C12C@llvm.org> Author: gclayton Date: Fri May 20 17:07:17 2011 New Revision: 131762 URL: http://llvm.org/viewvc/llvm-project?rev=131762&view=rev Log: Now that we have dynamic values, we need to protect the GetChildAtIndex() calls with the target API mutex. Modified: lldb/trunk/source/API/SBValue.cpp Modified: lldb/trunk/source/API/SBValue.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBValue.cpp?rev=131762&r1=131761&r2=131762&view=diff ============================================================================== --- lldb/trunk/source/API/SBValue.cpp (original) +++ lldb/trunk/source/API/SBValue.cpp Fri May 20 17:07:17 2011 @@ -348,6 +348,9 @@ { lldb::ValueObjectSP child_sp; + if (m_opaque_sp->GetUpdatePoint().GetTarget()) + Mutex::Locker api_locker (m_opaque_sp->GetUpdatePoint().GetTarget()->GetAPIMutex()); + if (m_opaque_sp) { child_sp = m_opaque_sp->GetChildAtIndex (idx, true); @@ -401,6 +404,10 @@ lldb::ValueObjectSP child_sp; const ConstString str_name (name); + if (m_opaque_sp->GetUpdatePoint().GetTarget()) + Mutex::Locker api_locker (m_opaque_sp->GetUpdatePoint().GetTarget()->GetAPIMutex()); + + if (m_opaque_sp) { child_sp = m_opaque_sp->GetChildMemberWithName (str_name, true); From peter at pcc.me.uk Fri May 20 17:42:59 2011 From: peter at pcc.me.uk (Peter Collingbourne) Date: Fri, 20 May 2011 22:42:59 -0000 Subject: [Lldb-commits] [lldb] r131766 - /lldb/trunk/source/Plugins/Disassembler/llvm/DisassemblerLLVM.cpp Message-ID: <20110520224259.CBA472A6C12C@llvm.org> Author: pcc Date: Fri May 20 17:42:59 2011 New Revision: 131766 URL: http://llvm.org/viewvc/llvm-project?rev=131766&view=rev Log: Fix build error - strstr returns a const char * Modified: lldb/trunk/source/Plugins/Disassembler/llvm/DisassemblerLLVM.cpp Modified: lldb/trunk/source/Plugins/Disassembler/llvm/DisassemblerLLVM.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Disassembler/llvm/DisassemblerLLVM.cpp?rev=131766&r1=131765&r2=131766&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Disassembler/llvm/DisassemblerLLVM.cpp (original) +++ lldb/trunk/source/Plugins/Disassembler/llvm/DisassemblerLLVM.cpp Fri May 20 17:42:59 2011 @@ -314,7 +314,7 @@ // Workaround for llvm::tB's operands not properly parsed by ARMAsmParser. if (m_arch_type == llvm::Triple::thumb && opcode.GetString() == "b") { const char *inst_str; - char *pos = NULL; + const char *pos = NULL; if (EDGetInstString(&inst_str, m_inst) == 0 && (pos = strstr(inst_str, "#")) != NULL) { uint64_t operand_value = PC + atoi(++pos); operands.Printf("0x%llx ", operand_value); From gclayton at apple.com Fri May 20 18:38:13 2011 From: gclayton at apple.com (Greg Clayton) Date: Fri, 20 May 2011 23:38:13 -0000 Subject: [Lldb-commits] [lldb] r131769 - in /lldb/trunk/source/Plugins/Process/gdb-remote: GDBRemoteCommunicationClient.cpp GDBRemoteCommunicationClient.h ProcessGDBRemote.cpp Message-ID: <20110520233813.AC2C62A6C12C@llvm.org> Author: gclayton Date: Fri May 20 18:38:13 2011 New Revision: 131769 URL: http://llvm.org/viewvc/llvm-project?rev=131769&view=rev Log: Centralize the code that gathers the thread ID list from the remote GDB server so that it happens in command sequence where no other packets can sneak between. Modified: lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.h lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp Modified: lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp?rev=131769&r1=131768&r2=131769&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp (original) +++ lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp Fri May 20 18:38:13 2011 @@ -1649,3 +1649,48 @@ return UINT8_MAX; } + +size_t +GDBRemoteCommunicationClient::GetCurrentThreadIDs (std::vector &thread_ids, + bool &sequence_mutex_unavailable) +{ + Mutex::Locker locker; + thread_ids.clear(); + + if (GetSequenceMutex (locker)) + { + sequence_mutex_unavailable = false; + StringExtractorGDBRemote response; + + TimeValue timeout_time; + timeout_time = TimeValue::Now(); + timeout_time.OffsetWithSeconds (m_packet_timeout*2); // We will always send at least two packets here... + + for (SendPacketNoLock ("qfThreadInfo", strlen("qfThreadInfo")) && WaitForPacketNoLock (response, &timeout_time); + response.IsNormalResponse(); + SendPacketNoLock ("qsThreadInfo", strlen("qsThreadInfo")) && WaitForPacketNoLock (response, &timeout_time)) + { + char ch = response.GetChar(); + if (ch == 'l') + break; + if (ch == 'm') + { + do + { + tid_t tid = response.GetHexMaxU32(false, LLDB_INVALID_THREAD_ID); + + if (tid != LLDB_INVALID_THREAD_ID) + { + thread_ids.push_back (tid); + } + ch = response.GetChar(); // Skip the command separator + } while (ch == ','); // Make sure we got a comma separator + } + } + } + else + { + sequence_mutex_unavailable = true; + } + return thread_ids.size(); +} Modified: lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.h?rev=131769&r1=131768&r2=131769&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.h (original) +++ lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.h Fri May 20 18:38:13 2011 @@ -12,6 +12,8 @@ // C Includes // C++ Includes +#include + // Other libraries and framework includes // Project includes #include "lldb/Core/ArchSpec.h" @@ -311,6 +313,10 @@ return m_supports_alloc_dealloc_memory; } + size_t + GetCurrentThreadIDs (std::vector &thread_ids, + bool &sequence_mutex_unavailable); + protected: //------------------------------------------------------------------ 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=131769&r1=131768&r2=131769&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp (original) +++ lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp Fri May 20 18:38:13 2011 @@ -1052,37 +1052,26 @@ ThreadList curr_thread_list (this); curr_thread_list.SetStopID(stop_id); - Error err; - StringExtractorGDBRemote response; - for (m_gdb_comm.SendPacketAndWaitForResponse("qfThreadInfo", response, false); - response.IsNormalResponse(); - m_gdb_comm.SendPacketAndWaitForResponse("qsThreadInfo", response, false)) + std::vector thread_ids; + bool sequence_mutex_unavailable = false; + const size_t num_thread_ids = m_gdb_comm.GetCurrentThreadIDs (thread_ids, sequence_mutex_unavailable); + if (num_thread_ids > 0) { - char ch = response.GetChar(); - if (ch == 'l') - break; - if (ch == 'm') + for (size_t i=0; i Author: gclayton Date: Fri May 20 18:51:26 2011 New Revision: 131771 URL: http://llvm.org/viewvc/llvm-project?rev=131771&view=rev Log: Lock the target API mutex correctly in all cases and make sure m_opaque_sp contains a valid pointer before trying to access the target. Modified: lldb/trunk/source/API/SBValue.cpp Modified: lldb/trunk/source/API/SBValue.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBValue.cpp?rev=131771&r1=131770&r2=131771&view=diff ============================================================================== --- lldb/trunk/source/API/SBValue.cpp (original) +++ lldb/trunk/source/API/SBValue.cpp Fri May 20 18:51:26 2011 @@ -348,21 +348,20 @@ { lldb::ValueObjectSP child_sp; - if (m_opaque_sp->GetUpdatePoint().GetTarget()) - Mutex::Locker api_locker (m_opaque_sp->GetUpdatePoint().GetTarget()->GetAPIMutex()); - if (m_opaque_sp) { + if (m_opaque_sp->GetUpdatePoint().GetTarget()) + Mutex::Locker api_locker (m_opaque_sp->GetUpdatePoint().GetTarget()->GetAPIMutex()); + child_sp = m_opaque_sp->GetChildAtIndex (idx, true); - } - - if (use_dynamic != lldb::eNoDynamicValues) - { - if (child_sp) + if (use_dynamic != lldb::eNoDynamicValues) { - lldb::ValueObjectSP dynamic_sp = child_sp->GetDynamicValue (use_dynamic); - if (dynamic_sp) - child_sp = dynamic_sp; + if (child_sp) + { + lldb::ValueObjectSP dynamic_sp = child_sp->GetDynamicValue (use_dynamic); + if (dynamic_sp) + child_sp = dynamic_sp; + } } } @@ -379,7 +378,12 @@ { uint32_t idx = UINT32_MAX; if (m_opaque_sp) + { + if (m_opaque_sp->GetUpdatePoint().GetTarget()) + Mutex::Locker api_locker (m_opaque_sp->GetUpdatePoint().GetTarget()->GetAPIMutex()); + idx = m_opaque_sp->GetIndexOfChildWithName (ConstString(name)); + } LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); if (log) { @@ -404,22 +408,20 @@ lldb::ValueObjectSP child_sp; const ConstString str_name (name); - if (m_opaque_sp->GetUpdatePoint().GetTarget()) - Mutex::Locker api_locker (m_opaque_sp->GetUpdatePoint().GetTarget()->GetAPIMutex()); - if (m_opaque_sp) { + if (m_opaque_sp->GetUpdatePoint().GetTarget()) + Mutex::Locker api_locker (m_opaque_sp->GetUpdatePoint().GetTarget()->GetAPIMutex()); child_sp = m_opaque_sp->GetChildMemberWithName (str_name, true); - } - - if (use_dynamic_value != lldb::eNoDynamicValues) - { - if (child_sp) + if (use_dynamic_value != lldb::eNoDynamicValues) { - lldb::ValueObjectSP dynamic_sp = child_sp->GetDynamicValue (use_dynamic_value); - if (dynamic_sp) - child_sp = dynamic_sp; + if (child_sp) + { + lldb::ValueObjectSP dynamic_sp = child_sp->GetDynamicValue (use_dynamic_value); + if (dynamic_sp) + child_sp = dynamic_sp; + } } } @@ -439,7 +441,12 @@ uint32_t num_children = 0; if (m_opaque_sp) + { + if (m_opaque_sp->GetUpdatePoint().GetTarget()) + Mutex::Locker api_locker (m_opaque_sp->GetUpdatePoint().GetTarget()->GetAPIMutex()); + num_children = m_opaque_sp->GetNumChildren(); + } LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); if (log) @@ -455,6 +462,9 @@ SBValue sb_value; if (m_opaque_sp) { + if (m_opaque_sp->GetUpdatePoint().GetTarget()) + Mutex::Locker api_locker (m_opaque_sp->GetUpdatePoint().GetTarget()->GetAPIMutex()); + Error error; sb_value = m_opaque_sp->Dereference (error); } @@ -471,7 +481,12 @@ bool is_ptr_type = false; if (m_opaque_sp) + { + if (m_opaque_sp->GetUpdatePoint().GetTarget()) + Mutex::Locker api_locker (m_opaque_sp->GetUpdatePoint().GetTarget()->GetAPIMutex()); + is_ptr_type = m_opaque_sp->IsPointerType(); + } LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); if (log) @@ -485,7 +500,12 @@ SBValue::GetOpaqueType() { if (m_opaque_sp) + { + if (m_opaque_sp->GetUpdatePoint().GetTarget()) + Mutex::Locker api_locker (m_opaque_sp->GetUpdatePoint().GetTarget()->GetAPIMutex()); + return m_opaque_sp->GetClangType(); + } return NULL; } From johnny.chen at apple.com Fri May 20 19:44:42 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Sat, 21 May 2011 00:44:42 -0000 Subject: [Lldb-commits] [lldb] r131773 - /lldb/trunk/source/Plugins/Disassembler/llvm/DisassemblerLLVM.cpp Message-ID: <20110521004442.EC8472A6C12C@llvm.org> Author: johnny Date: Fri May 20 19:44:42 2011 New Revision: 131773 URL: http://llvm.org/viewvc/llvm-project?rev=131773&view=rev Log: When in non-raw mode and edis fails to parse the tokens of the instruction, output the raw disassembly so that the opcode aligns with the edis'ed disassembly. Modified: lldb/trunk/source/Plugins/Disassembler/llvm/DisassemblerLLVM.cpp Modified: lldb/trunk/source/Plugins/Disassembler/llvm/DisassemblerLLVM.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Disassembler/llvm/DisassemblerLLVM.cpp?rev=131773&r1=131772&r2=131773&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Disassembler/llvm/DisassemblerLLVM.cpp (original) +++ lldb/trunk/source/Plugins/Disassembler/llvm/DisassemblerLLVM.cpp Fri May 20 19:44:42 2011 @@ -369,7 +369,16 @@ if (EDGetInstString(&str, m_inst)) // 0 on success return; - s->Write(str, strlen(str) - 1); + if (raw) + s->Write(str, strlen(str) - 1); + else + { + // EDis fails to parse the tokens of this inst. Need to align this + // raw disassembly with the rest of output. + llvm::StringRef raw_disasm(str); + StripSpaces(raw_disasm); + s->PutCString(raw_disasm.str().c_str()); + } } } From johnny.chen at apple.com Fri May 20 19:55:57 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Sat, 21 May 2011 00:55:57 -0000 Subject: [Lldb-commits] [lldb] r131779 - /lldb/trunk/source/Plugins/Disassembler/llvm/DisassemblerLLVM.cpp Message-ID: <20110521005557.E01A02A6C12C@llvm.org> Author: johnny Date: Fri May 20 19:55:57 2011 New Revision: 131779 URL: http://llvm.org/viewvc/llvm-project?rev=131779&view=rev Log: A little refactoring. Modified: lldb/trunk/source/Plugins/Disassembler/llvm/DisassemblerLLVM.cpp Modified: lldb/trunk/source/Plugins/Disassembler/llvm/DisassemblerLLVM.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Disassembler/llvm/DisassemblerLLVM.cpp?rev=131779&r1=131778&r2=131779&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Disassembler/llvm/DisassemblerLLVM.cpp (original) +++ lldb/trunk/source/Plugins/Disassembler/llvm/DisassemblerLLVM.cpp Fri May 20 19:55:57 2011 @@ -108,6 +108,13 @@ while (!Str.empty() && isspace(Str.back())) Str = Str.substr(0, Str.size()-1); } +static void +Align(Stream *s, const char *str) +{ + llvm::StringRef raw_disasm(str); + StripSpaces(raw_disasm); + s->PutCString(raw_disasm.str().c_str()); +} void InstructionLLVM::Dump @@ -342,9 +349,7 @@ if (EDGetInstString(&str, m_inst)) return; - llvm::StringRef raw_disasm(str); - StripSpaces(raw_disasm); - s->PutCString(raw_disasm.str().c_str()); + Align(s, str); } else { @@ -374,10 +379,8 @@ else { // EDis fails to parse the tokens of this inst. Need to align this - // raw disassembly with the rest of output. - llvm::StringRef raw_disasm(str); - StripSpaces(raw_disasm); - s->PutCString(raw_disasm.str().c_str()); + // raw disassembly's opcode with the rest of output. + Align(s, str); } } } From gclayton at apple.com Sat May 21 23:32:55 2011 From: gclayton at apple.com (Greg Clayton) Date: Sun, 22 May 2011 04:32:55 -0000 Subject: [Lldb-commits] [lldb] r131834 - in /lldb/trunk: include/lldb/Core/Address.h source/Core/Address.cpp source/Plugins/ABI/MacOSX-arm/ABIMacOSX_arm.cpp source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTrampolineHandler.cpp source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleThreadPlanStepThroughObjCTrampoline.cpp source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp tools/debugserver/source/MacOSX/arm/DNBArchImpl.cpp tools/debugserver/source/RNBRemote.cpp Message-ID: <20110522043255.D82042A6C12C@llvm.org> Author: gclayton Date: Sat May 21 23:32:55 2011 New Revision: 131834 URL: http://llvm.org/viewvc/llvm-project?rev=131834&view=rev Log: Added functions to lldb_private::Address to set an address from a load address and set the address as an opcode address or as a callable address. This is needed in various places in the thread plans to make sure that addresses that might be found in symbols or runtime might already have extra bits set (ARM/Thumb). The new functions are: bool Address::SetCallableLoadAddress (lldb::addr_t load_addr, Target *target); bool Address::SetOpcodeLoadAddress (lldb::addr_t load_addr, Target *target); SetCallableLoadAddress will initialize a section offset address if it can, and if so it might possibly set some bits in the address to make the address callable (bit zero might get set for ARM for Thumb functions). SetOpcodeLoadAddress will initialize a section offset address using the specified target and it will strip any special address bits if needed depending on the target. Fixed the ABIMacOSX_arm::GetArgumentValues() function to require arguments 1-4 to be in the needed registers (previously this would incorrectly fallback to the stack) and return false if unable to get the register values. The function was also modified to first look for the generic argument registers and then fall back to finding the registers by name. Fixed the objective trampoline handler to use the new Address::SetOpcodeLoadAddress function when needed to avoid address mismatches when trying to complete steps into objective C methods. Make similar fixes inside the AppleThreadPlanStepThroughObjCTrampoline::ShouldStop() function. Modified ProcessGDBRemote::BuildDynamicRegisterInfo(...) to be able to deal with the new generic argument registers. Modified RNBRemote::HandlePacket_qRegisterInfo() to handle the new generic argument registers on the debugserver side. Modified DNBArchMachARM::NumSupportedHardwareBreakpoints() to be able to detect how many hardware breakpoint registers there are using a darwin sysctl. Did the same for hardware watchpoints in DNBArchMachARM::NumSupportedHardwareWatchpoints(). Modified: lldb/trunk/include/lldb/Core/Address.h lldb/trunk/source/Core/Address.cpp lldb/trunk/source/Plugins/ABI/MacOSX-arm/ABIMacOSX_arm.cpp lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTrampolineHandler.cpp lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleThreadPlanStepThroughObjCTrampoline.cpp lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp lldb/trunk/tools/debugserver/source/MacOSX/arm/DNBArchImpl.cpp lldb/trunk/tools/debugserver/source/RNBRemote.cpp Modified: lldb/trunk/include/lldb/Core/Address.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/Address.h?rev=131834&r1=131833&r2=131834&view=diff ============================================================================== --- lldb/trunk/include/lldb/Core/Address.h (original) +++ lldb/trunk/include/lldb/Core/Address.h Sat May 21 23:32:55 2011 @@ -419,6 +419,12 @@ //------------------------------------------------------------------ bool SetLoadAddress (lldb::addr_t load_addr, Target *target); + + bool + SetOpcodeLoadAddress (lldb::addr_t load_addr, Target *target); + + bool + SetCallableLoadAddress (lldb::addr_t load_addr, Target *target); //------------------------------------------------------------------ /// Get accessor for the module for this address. Modified: lldb/trunk/source/Core/Address.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/Address.cpp?rev=131834&r1=131833&r2=131834&view=diff ============================================================================== --- lldb/trunk/source/Core/Address.cpp (original) +++ lldb/trunk/source/Core/Address.cpp Sat May 21 23:32:55 2011 @@ -334,6 +334,43 @@ return code_addr; } +bool +Address::SetCallableLoadAddress (lldb::addr_t load_addr, Target *target) +{ + if (SetLoadAddress (load_addr, target)) + { + switch (target->GetArchitecture().GetMachine()) + { + case llvm::Triple::arm: + case llvm::Triple::thumb: + // Check if bit zero it no set? + if ((m_offset & 1ull) == 0) + { + // Bit zero isn't set, check if the address is a multiple of 2? + if (m_offset & 2ull) + { + // The address is a multiple of 2 so it must be thumb, set bit zero + m_offset |= 1ull; + } + else if (GetAddressClass() == eAddressClassCodeAlternateISA) + { + // We checked the address and the address claims to be the alternate ISA + // which means thumb, so set bit zero. + m_offset |= 1ull; + } + } + break; + + default: + break; + } + return true; + } + return false; +} + + + addr_t Address::GetOpcodeLoadAddress (Target *target) const { @@ -357,6 +394,27 @@ } bool +Address::SetOpcodeLoadAddress (lldb::addr_t load_addr, Target *target) +{ + if (SetLoadAddress (load_addr, target)) + { + switch (target->GetArchitecture().GetMachine()) + { + case llvm::Triple::arm: + case llvm::Triple::thumb: + // Make sure bit zero is clear + m_offset &= ~(1ull); + break; + + default: + break; + } + return true; + } + return false; +} + +bool Address::Dump (Stream *s, ExecutionContextScope *exe_scope, DumpStyle style, DumpStyle fallback_style, uint32_t addr_size) const { // If the section was NULL, only load address is going to work. 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=131834&r1=131833&r2=131834&view=diff ============================================================================== --- lldb/trunk/source/Plugins/ABI/MacOSX-arm/ABIMacOSX_arm.cpp (original) +++ lldb/trunk/source/Plugins/ABI/MacOSX-arm/ABIMacOSX_arm.cpp Sat May 21 23:32:55 2011 @@ -194,8 +194,6 @@ if (!reg_ctx) return false; - bool arg_regs_exceeded = false; - addr_t sp = reg_ctx->GetSP(0); if (!sp) @@ -231,16 +229,29 @@ if (bit_width <= (thread.GetProcess().GetAddressByteSize() * 8)) { - if (!arg_regs_exceeded) + if (value_idx < 4) { + // Arguments 1-4 are in r0-r3... + const RegisterInfo *arg_reg_info = NULL; + // Search by generic ID first, then fall back to by name uint32_t arg_reg_num = reg_ctx->ConvertRegisterKindToRegisterNumber (eRegisterKindGeneric, LLDB_REGNUM_GENERIC_ARG1 + value_idx); - if (arg_reg_num == LLDB_INVALID_REGNUM) + if (arg_reg_num != LLDB_INVALID_REGNUM) { - arg_regs_exceeded = true; + arg_reg_info = reg_ctx->GetRegisterInfoAtIndex(arg_reg_num); } else { - const RegisterInfo *arg_reg_info = reg_ctx->GetRegisterInfoAtIndex(arg_reg_num); + switch (value_idx) + { + case 0: arg_reg_info = reg_ctx->GetRegisterInfoByName("r0"); break; + case 1: arg_reg_info = reg_ctx->GetRegisterInfoByName("r1"); break; + case 2: arg_reg_info = reg_ctx->GetRegisterInfoByName("r2"); break; + case 3: arg_reg_info = reg_ctx->GetRegisterInfoByName("r3"); break; + } + } + + if (arg_reg_info) + { RegisterValue reg_value; if (reg_ctx->ReadRegister(arg_reg_info, reg_value)) @@ -251,37 +262,36 @@ return false; continue; } - else - { - return false; - } } + return false; } - - - const uint32_t arg_byte_size = (bit_width + (8-1)) / 8; - if (arg_byte_size <= sizeof(uint64_t)) + else { - uint8_t arg_data[sizeof(uint64_t)]; - Error error; - thread.GetProcess().ReadMemory(sp, arg_data, sizeof(arg_data), error); - DataExtractor arg_data_extractor (arg_data, sizeof(arg_data), - thread.GetProcess().GetTarget().GetArchitecture().GetByteOrder(), - thread.GetProcess().GetTarget().GetArchitecture().GetAddressByteSize()); - uint32_t offset = 0; - if (arg_byte_size <= 4) - value->GetScalar() = arg_data_extractor.GetMaxU32 (&offset, arg_byte_size); - else if (arg_byte_size <= 8) - value->GetScalar() = arg_data_extractor.GetMaxU64 (&offset, arg_byte_size); - else - return false; + // Arguments 5 on up are on the stack + const uint32_t arg_byte_size = (bit_width + (8-1)) / 8; + if (arg_byte_size <= sizeof(uint64_t)) + { + uint8_t arg_data[sizeof(uint64_t)]; + Error error; + thread.GetProcess().ReadMemory(sp, arg_data, sizeof(arg_data), error); + DataExtractor arg_data_extractor (arg_data, sizeof(arg_data), + thread.GetProcess().GetTarget().GetArchitecture().GetByteOrder(), + thread.GetProcess().GetTarget().GetArchitecture().GetAddressByteSize()); + uint32_t offset = 0; + if (arg_byte_size <= 4) + value->GetScalar() = arg_data_extractor.GetMaxU32 (&offset, arg_byte_size); + else if (arg_byte_size <= 8) + value->GetScalar() = arg_data_extractor.GetMaxU64 (&offset, arg_byte_size); + else + return false; - if (offset == 0 || offset == UINT32_MAX) - return false; + if (offset == 0 || offset == UINT32_MAX) + return false; - if (is_signed) - value->GetScalar().SignExtend (bit_width); - sp += arg_byte_size; + if (is_signed) + value->GetScalar().SignExtend (bit_width); + sp += arg_byte_size; + } } } } Modified: lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTrampolineHandler.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTrampolineHandler.cpp?rev=131834&r1=131833&r2=131834&view=diff ============================================================================== --- lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTrampolineHandler.cpp (original) +++ lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTrampolineHandler.cpp Sat May 21 23:32:55 2011 @@ -562,7 +562,7 @@ // Problem is we also need to lookup the dispatch function. For now we could have a side table of stret & non-stret // dispatch functions. If that's as complex as it gets, we're fine. - lldb::addr_t sym_addr = msgSend_symbol->GetValue().GetLoadAddress(target); + lldb::addr_t sym_addr = msgSend_symbol->GetValue().GetOpcodeLoadAddress(target); m_msgSend_map.insert(std::pair(sym_addr, i)); } @@ -854,7 +854,7 @@ flag_value.GetScalar() = 1; else flag_value.GetScalar() = 0; // FIXME - Set to 0 when debugging is done. - dispatch_values.PushValue (flag_value); + dispatch_values.PushValue (flag_value); // Now, if we haven't already, make and insert the function as a ClangUtilityFunction, and make and insert // it's runner ClangFunction. @@ -880,7 +880,7 @@ if (sc.symbol != NULL) impl_code_address = sc.symbol->GetValue(); - //lldb::addr_t addr = impl_code_address.GetLoadAddress (exe_ctx.target); + //lldb::addr_t addr = impl_code_address.GetOpcodeLoadAddress (exe_ctx.target); //printf ("Getting address for our_utility_function: 0x%llx.\n", addr); } else Modified: lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleThreadPlanStepThroughObjCTrampoline.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleThreadPlanStepThroughObjCTrampoline.cpp?rev=131834&r1=131833&r2=131834&view=diff ============================================================================== --- lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleThreadPlanStepThroughObjCTrampoline.cpp (original) +++ lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleThreadPlanStepThroughObjCTrampoline.cpp Sat May 21 23:32:55 2011 @@ -74,7 +74,7 @@ void AppleThreadPlanStepThroughObjCTrampoline::GetDescription (Stream *s, - lldb::DescriptionLevel level) + lldb::DescriptionLevel level) { if (level == lldb::eDescriptionLevelBrief) s->Printf("Step through ObjC trampoline"); @@ -119,7 +119,8 @@ m_impl_function->FetchFunctionResults (exc_context, m_args_addr, target_addr_value); m_impl_function->DeallocateFunctionResults(exc_context, m_args_addr); lldb::addr_t target_addr = target_addr_value.GetScalar().ULongLong(); - Address target_address(NULL, target_addr); + Address target_so_addr; + target_so_addr.SetOpcodeLoadAddress(target_addr, exc_context.target); LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_STEP)); if (target_addr == 0) { @@ -153,11 +154,11 @@ assert (objc_runtime != NULL); objc_runtime->AddToMethodCache (m_isa_addr, m_sel_addr, target_addr); if (log) - log->Printf("Adding {0x%llx, 0x%llx} = 0x%llx to cache.", m_isa_addr, m_sel_addr, target_addr); + log->Printf("Adding {isa-addr=0x%llx, sel-addr=0x%llx} = addr=0x%llx to cache.", m_isa_addr, m_sel_addr, target_addr); // Extract the target address from the value: - m_run_to_sp.reset(new ThreadPlanRunToAddress(m_thread, target_address, m_stop_others)); + m_run_to_sp.reset(new ThreadPlanRunToAddress(m_thread, target_so_addr, m_stop_others)); m_thread.QueueThreadPlan(m_run_to_sp, false); m_run_to_sp->SetPrivate(true); return false; 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=131834&r1=131833&r2=131834&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp (original) +++ lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp Sat May 21 23:32:55 2011 @@ -302,6 +302,23 @@ reg_info.kinds[eRegisterKindGeneric] = LLDB_REGNUM_GENERIC_RA; else if (value.compare("flags") == 0) reg_info.kinds[eRegisterKindGeneric] = LLDB_REGNUM_GENERIC_FLAGS; + else if (value.find("arg") == 0) + { + if (value.size() == 4) + { + switch (value[3]) + { + case '1': reg_info.kinds[eRegisterKindGeneric] = LLDB_REGNUM_GENERIC_ARG1; break; + case '2': reg_info.kinds[eRegisterKindGeneric] = LLDB_REGNUM_GENERIC_ARG2; break; + case '3': reg_info.kinds[eRegisterKindGeneric] = LLDB_REGNUM_GENERIC_ARG3; break; + case '4': reg_info.kinds[eRegisterKindGeneric] = LLDB_REGNUM_GENERIC_ARG4; break; + case '5': reg_info.kinds[eRegisterKindGeneric] = LLDB_REGNUM_GENERIC_ARG5; break; + case '6': reg_info.kinds[eRegisterKindGeneric] = LLDB_REGNUM_GENERIC_ARG6; break; + case '7': reg_info.kinds[eRegisterKindGeneric] = LLDB_REGNUM_GENERIC_ARG7; break; + case '8': reg_info.kinds[eRegisterKindGeneric] = LLDB_REGNUM_GENERIC_ARG8; break; + } + } + } } } Modified: lldb/trunk/tools/debugserver/source/MacOSX/arm/DNBArchImpl.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/debugserver/source/MacOSX/arm/DNBArchImpl.cpp?rev=131834&r1=131833&r2=131834&view=diff ============================================================================== --- lldb/trunk/tools/debugserver/source/MacOSX/arm/DNBArchImpl.cpp (original) +++ lldb/trunk/tools/debugserver/source/MacOSX/arm/DNBArchImpl.cpp Sat May 21 23:32:55 2011 @@ -2058,39 +2058,48 @@ // Set this to zero in case we can't tell if there are any HW breakpoints g_num_supported_hw_breakpoints = 0; - // Read the DBGDIDR to get the number of available hardware breakpoints - // However, in some of our current armv7 processors, hardware - // breakpoints/watchpoints were not properly connected. So detect those - // cases using a field in a sysctl. For now we are using "hw.cpusubtype" - // field to distinguish CPU architectures. This is a hack until we can - // get fixed, at which point we will switch to - // using a different sysctl string that will tell us how many BRPs - // are available to us directly without having to read DBGDIDR. - uint32_t register_DBGDIDR; - - asm("mrc p14, 0, %0, c0, c0, 0" : "=r" (register_DBGDIDR)); - uint32_t numBRPs = bits(register_DBGDIDR, 27, 24); - // Zero is reserved for the BRP count, so don't increment it if it is zero - if (numBRPs > 0) - numBRPs++; - DNBLogThreadedIf(LOG_THREAD, "DBGDIDR=0x%8.8x (number BRP pairs = %u)", register_DBGDIDR, numBRPs); - - if (numBRPs > 0) - { - uint32_t cpusubtype; - size_t len; - len = sizeof(cpusubtype); - // TODO: remove this hack and change to using hw.optional.xx when implmented - if (::sysctlbyname("hw.cpusubtype", &cpusubtype, &len, NULL, 0) == 0) - { - DNBLogThreadedIf(LOG_THREAD, "hw.cpusubtype=0x%d", cpusubtype); - if (cpusubtype == CPU_SUBTYPE_ARM_V7) - DNBLogThreadedIf(LOG_THREAD, "Hardware breakpoints disabled for armv7 (rdar://problem/6372672)"); - else - g_num_supported_hw_breakpoints = numBRPs; + size_t len; + uint32_t n = 0; + len = sizeof (n); + if (::sysctlbyname("hw.optional.breakpoint", &n, &len, NULL, 0) == 0) + { + g_num_supported_hw_breakpoints = n; + DNBLogThreadedIf(LOG_THREAD, "hw.optional.breakpoint=%u", n); + } + else + { + // Read the DBGDIDR to get the number of available hardware breakpoints + // However, in some of our current armv7 processors, hardware + // breakpoints/watchpoints were not properly connected. So detect those + // cases using a field in a sysctl. For now we are using "hw.cpusubtype" + // field to distinguish CPU architectures. This is a hack until we can + // get fixed, at which point we will switch to + // using a different sysctl string that will tell us how many BRPs + // are available to us directly without having to read DBGDIDR. + uint32_t register_DBGDIDR; + + asm("mrc p14, 0, %0, c0, c0, 0" : "=r" (register_DBGDIDR)); + uint32_t numBRPs = bits(register_DBGDIDR, 27, 24); + // Zero is reserved for the BRP count, so don't increment it if it is zero + if (numBRPs > 0) + numBRPs++; + DNBLogThreadedIf(LOG_THREAD, "DBGDIDR=0x%8.8x (number BRP pairs = %u)", register_DBGDIDR, numBRPs); + + if (numBRPs > 0) + { + uint32_t cpusubtype; + len = sizeof(cpusubtype); + // TODO: remove this hack and change to using hw.optional.xx when implmented + if (::sysctlbyname("hw.cpusubtype", &cpusubtype, &len, NULL, 0) == 0) + { + DNBLogThreadedIf(LOG_THREAD, "hw.cpusubtype=%d", cpusubtype); + if (cpusubtype == CPU_SUBTYPE_ARM_V7) + DNBLogThreadedIf(LOG_THREAD, "Hardware breakpoints disabled for armv7 (rdar://problem/6372672)"); + else + g_num_supported_hw_breakpoints = numBRPs; + } } } - } return g_num_supported_hw_breakpoints; } @@ -2106,37 +2115,49 @@ { // Set this to zero in case we can't tell if there are any HW breakpoints g_num_supported_hw_watchpoints = 0; - // Read the DBGDIDR to get the number of available hardware breakpoints - // However, in some of our current armv7 processors, hardware - // breakpoints/watchpoints were not properly connected. So detect those - // cases using a field in a sysctl. For now we are using "hw.cpusubtype" - // field to distinguish CPU architectures. This is a hack until we can - // get fixed, at which point we will switch to - // using a different sysctl string that will tell us how many WRPs - // are available to us directly without having to read DBGDIDR. - - uint32_t register_DBGDIDR; - asm("mrc p14, 0, %0, c0, c0, 0" : "=r" (register_DBGDIDR)); - uint32_t numWRPs = bits(register_DBGDIDR, 31, 28) + 1; - DNBLogThreadedIf(LOG_THREAD, "DBGDIDR=0x%8.8x (number WRP pairs = %u)", register_DBGDIDR, numWRPs); - - if (numWRPs > 0) - { - uint32_t cpusubtype; - size_t len; - len = sizeof(cpusubtype); - // TODO: remove this hack and change to using hw.optional.xx when implmented - if (::sysctlbyname("hw.cpusubtype", &cpusubtype, &len, NULL, 0) == 0) - { - DNBLogThreadedIf(LOG_THREAD, "hw.cpusubtype=0x%d", cpusubtype); - - if (cpusubtype == CPU_SUBTYPE_ARM_V7) - DNBLogThreadedIf(LOG_THREAD, "Hardware watchpoints disabled for armv7 (rdar://problem/6372672)"); - else - g_num_supported_hw_watchpoints = numWRPs; + + + size_t len; + uint32_t n = 0; + len = sizeof (n); + if (::sysctlbyname("hw.optional.watchpoint", &n, &len, NULL, 0) == 0) + { + g_num_supported_hw_watchpoints = n; + DNBLogThreadedIf(LOG_THREAD, "hw.optional.watchpoint=%u", n); + } + else + { + // Read the DBGDIDR to get the number of available hardware breakpoints + // However, in some of our current armv7 processors, hardware + // breakpoints/watchpoints were not properly connected. So detect those + // cases using a field in a sysctl. For now we are using "hw.cpusubtype" + // field to distinguish CPU architectures. This is a hack until we can + // get fixed, at which point we will switch to + // using a different sysctl string that will tell us how many WRPs + // are available to us directly without having to read DBGDIDR. + + uint32_t register_DBGDIDR; + asm("mrc p14, 0, %0, c0, c0, 0" : "=r" (register_DBGDIDR)); + uint32_t numWRPs = bits(register_DBGDIDR, 31, 28) + 1; + DNBLogThreadedIf(LOG_THREAD, "DBGDIDR=0x%8.8x (number WRP pairs = %u)", register_DBGDIDR, numWRPs); + + if (numWRPs > 0) + { + uint32_t cpusubtype; + size_t len; + len = sizeof(cpusubtype); + // TODO: remove this hack and change to using hw.optional.xx when implmented + if (::sysctlbyname("hw.cpusubtype", &cpusubtype, &len, NULL, 0) == 0) + { + DNBLogThreadedIf(LOG_THREAD, "hw.cpusubtype=0x%d", cpusubtype); + + if (cpusubtype == CPU_SUBTYPE_ARM_V7) + DNBLogThreadedIf(LOG_THREAD, "Hardware watchpoints disabled for armv7 (rdar://problem/6372672)"); + else + g_num_supported_hw_watchpoints = numWRPs; + } } } - } return g_num_supported_hw_watchpoints; } Modified: lldb/trunk/tools/debugserver/source/RNBRemote.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/debugserver/source/RNBRemote.cpp?rev=131834&r1=131833&r2=131834&view=diff ============================================================================== --- lldb/trunk/tools/debugserver/source/RNBRemote.cpp (original) +++ lldb/trunk/tools/debugserver/source/RNBRemote.cpp Sat May 21 23:32:55 2011 @@ -1453,6 +1453,14 @@ case GENERIC_REGNUM_SP: ostrm << "generic:sp;"; break; case GENERIC_REGNUM_RA: ostrm << "generic:ra;"; break; case GENERIC_REGNUM_FLAGS: ostrm << "generic:flags;"; break; + case GENERIC_REGNUM_ARG1: ostrm << "generic:arg1;"; break; + case GENERIC_REGNUM_ARG2: ostrm << "generic:arg2;"; break; + case GENERIC_REGNUM_ARG3: ostrm << "generic:arg3;"; break; + case GENERIC_REGNUM_ARG4: ostrm << "generic:arg4;"; break; + case GENERIC_REGNUM_ARG5: ostrm << "generic:arg5;"; break; + case GENERIC_REGNUM_ARG6: ostrm << "generic:arg6;"; break; + case GENERIC_REGNUM_ARG7: ostrm << "generic:arg7;"; break; + case GENERIC_REGNUM_ARG8: ostrm << "generic:arg8;"; break; default: break; } From ctice at apple.com Sun May 22 02:14:46 2011 From: ctice at apple.com (Caroline Tice) Date: Sun, 22 May 2011 07:14:46 -0000 Subject: [Lldb-commits] [lldb] r131848 - in /lldb/trunk: source/Commands/CommandObjectBreakpointCommand.cpp source/Commands/CommandObjectBreakpointCommand.h test/abbreviation_tests/TestAbbreviations.py test/breakpoint_command/TestBreakpointCommand.py Message-ID: <20110522071446.A986C2A6C12C@llvm.org> Author: ctice Date: Sun May 22 02:14:46 2011 New Revision: 131848 URL: http://llvm.org/viewvc/llvm-project?rev=131848&view=rev Log: Change the command 'breakpoint command remove' to 'breakpoint command delete', to be more consistent with other commands. Modified: lldb/trunk/source/Commands/CommandObjectBreakpointCommand.cpp lldb/trunk/source/Commands/CommandObjectBreakpointCommand.h lldb/trunk/test/abbreviation_tests/TestAbbreviations.py lldb/trunk/test/breakpoint_command/TestBreakpointCommand.py Modified: lldb/trunk/source/Commands/CommandObjectBreakpointCommand.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectBreakpointCommand.cpp?rev=131848&r1=131847&r2=131848&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectBreakpointCommand.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectBreakpointCommand.cpp Sun May 22 02:14:46 2011 @@ -520,13 +520,13 @@ //------------------------------------------------------------------------- -// CommandObjectBreakpointCommandRemove +// CommandObjectBreakpointCommandDelete //------------------------------------------------------------------------- -CommandObjectBreakpointCommandRemove::CommandObjectBreakpointCommandRemove (CommandInterpreter &interpreter) : +CommandObjectBreakpointCommandDelete::CommandObjectBreakpointCommandDelete (CommandInterpreter &interpreter) : CommandObject (interpreter, - "remove", - "Remove the set of commands from a breakpoint.", + "delete", + "Delete the set of commands from a breakpoint.", NULL) { CommandArgumentEntry arg; @@ -543,12 +543,12 @@ m_arguments.push_back (arg); } -CommandObjectBreakpointCommandRemove::~CommandObjectBreakpointCommandRemove () +CommandObjectBreakpointCommandDelete::~CommandObjectBreakpointCommandDelete () { } bool -CommandObjectBreakpointCommandRemove::Execute +CommandObjectBreakpointCommandDelete::Execute ( Args& command, CommandReturnObject &result @@ -558,7 +558,7 @@ if (target == NULL) { - result.AppendError ("There is not a current executable; there are no breakpoints from which to remove commands"); + result.AppendError ("There is not a current executable; there are no breakpoints from which to delete commands"); result.SetStatus (eReturnStatusFailed); return false; } @@ -568,14 +568,14 @@ if (num_breakpoints == 0) { - result.AppendError ("No breakpoints exist to have commands removed"); + result.AppendError ("No breakpoints exist to have commands deleted"); result.SetStatus (eReturnStatusFailed); return false; } if (command.GetArgumentCount() == 0) { - result.AppendError ("No breakpoint specified from which to remove the commands"); + result.AppendError ("No breakpoint specified from which to delete the commands"); result.SetStatus (eReturnStatusFailed); return false; } @@ -760,15 +760,15 @@ { bool status; CommandObjectSP add_command_object (new CommandObjectBreakpointCommandAdd (interpreter)); - CommandObjectSP remove_command_object (new CommandObjectBreakpointCommandRemove (interpreter)); + CommandObjectSP delete_command_object (new CommandObjectBreakpointCommandDelete (interpreter)); CommandObjectSP list_command_object (new CommandObjectBreakpointCommandList (interpreter)); add_command_object->SetCommandName ("breakpoint command add"); - remove_command_object->SetCommandName ("breakpoint command remove"); + delete_command_object->SetCommandName ("breakpoint command delete"); list_command_object->SetCommandName ("breakpoint command list"); status = LoadSubCommand ("add", add_command_object); - status = LoadSubCommand ("remove", remove_command_object); + status = LoadSubCommand ("delete", delete_command_object); status = LoadSubCommand ("list", list_command_object); } Modified: lldb/trunk/source/Commands/CommandObjectBreakpointCommand.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectBreakpointCommand.h?rev=131848&r1=131847&r2=131848&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectBreakpointCommand.h (original) +++ lldb/trunk/source/Commands/CommandObjectBreakpointCommand.h Sun May 22 02:14:46 2011 @@ -130,16 +130,16 @@ }; //------------------------------------------------------------------------- -// CommandObjectBreakpointCommandRemove +// CommandObjectBreakpointCommandDelete //------------------------------------------------------------------------- -class CommandObjectBreakpointCommandRemove : public CommandObject +class CommandObjectBreakpointCommandDelete : public CommandObject { public: - CommandObjectBreakpointCommandRemove (CommandInterpreter &interpreter); + CommandObjectBreakpointCommandDelete (CommandInterpreter &interpreter); virtual - ~CommandObjectBreakpointCommandRemove (); + ~CommandObjectBreakpointCommandDelete (); virtual bool Execute (Args& command, Modified: lldb/trunk/test/abbreviation_tests/TestAbbreviations.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/abbreviation_tests/TestAbbreviations.py?rev=131848&r1=131847&r2=131848&view=diff ============================================================================== --- lldb/trunk/test/abbreviation_tests/TestAbbreviations.py (original) +++ lldb/trunk/test/abbreviation_tests/TestAbbreviations.py Sun May 22 02:14:46 2011 @@ -94,7 +94,7 @@ "Breakpoint commands:", "print frame" ]) - self.runCmd("br co rem 1") + self.runCmd("br co del 1") self.expect("breakpoint command list 1", startstr = "Breakpoint 1 does not have an associated command.") Modified: lldb/trunk/test/breakpoint_command/TestBreakpointCommand.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/breakpoint_command/TestBreakpointCommand.py?rev=131848&r1=131847&r2=131848&view=diff ============================================================================== --- lldb/trunk/test/breakpoint_command/TestBreakpointCommand.py (original) +++ lldb/trunk/test/breakpoint_command/TestBreakpointCommand.py Sun May 22 02:14:46 2011 @@ -1,5 +1,5 @@ """ -Test lldb breakpoint command add/list/remove. +Test lldb breakpoint command add/list/delete. """ import os, time @@ -18,13 +18,13 @@ @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin") def test_with_dsym(self): - """Test a sequence of breakpoint command add, list, and remove.""" + """Test a sequence of breakpoint command add, list, and delete.""" self.buildDsym() self.breakpoint_command_sequence() self.breakpoint_command_script_parameters () def test_with_dwarf(self): - """Test a sequence of breakpoint command add, list, and remove.""" + """Test a sequence of breakpoint command add, list, and delete.""" self.buildDwarf() self.breakpoint_command_sequence() self.breakpoint_command_script_parameters () @@ -36,7 +36,7 @@ self.line = line_number('main.c', '// Set break point at this line.') def breakpoint_command_sequence(self): - """Test a sequence of breakpoint command add, list, and remove.""" + """Test a sequence of breakpoint command add, list, and delete.""" exe = os.path.join(os.getcwd(), "a.out") self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) @@ -98,7 +98,7 @@ self.runCmd("process continue") # Remove the breakpoint command associated with breakpoint 1. - self.runCmd("breakpoint command remove 1") + self.runCmd("breakpoint command delete 1") # Remove breakpoint 2. self.runCmd("breakpoint delete 2") From jingham at apple.com Sun May 22 16:45:01 2011 From: jingham at apple.com (Jim Ingham) Date: Sun, 22 May 2011 21:45:01 -0000 Subject: [Lldb-commits] [lldb] r131869 - in /lldb/trunk: include/lldb/Target/Process.h source/Target/Process.cpp Message-ID: <20110522214501.CFF1A2A6C12C@llvm.org> Author: jingham Date: Sun May 22 16:45:01 2011 New Revision: 131869 URL: http://llvm.org/viewvc/llvm-project?rev=131869&view=rev Log: Change the m_update_state to an int, and only trigger the "on removal" action the second time the event is removed (the first is the internal -> external transition, the second when it is pulled off the public event queue, and further times when it is put back because we are faking a stop reason to hide the expression evaluation stops. Modified: lldb/trunk/include/lldb/Target/Process.h lldb/trunk/source/Target/Process.cpp Modified: lldb/trunk/include/lldb/Target/Process.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/Process.h?rev=131869&r1=131868&r2=131869&view=diff ============================================================================== --- lldb/trunk/include/lldb/Target/Process.h (original) +++ lldb/trunk/include/lldb/Target/Process.h Sun May 22 16:45:01 2011 @@ -1033,7 +1033,7 @@ void SetUpdateStateOnRemoval() { - m_update_state = true; + m_update_state++; } void SetRestarted (bool new_value) @@ -1049,7 +1049,7 @@ lldb::ProcessSP m_process_sp; lldb::StateType m_state; bool m_restarted; // For "eStateStopped" events, this is true if the target was automatically restarted. - bool m_update_state; + int m_update_state; bool m_interrupted; DISALLOW_COPY_AND_ASSIGN (ProcessEventData); Modified: lldb/trunk/source/Target/Process.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/Process.cpp?rev=131869&r1=131868&r2=131869&view=diff ============================================================================== --- lldb/trunk/source/Target/Process.cpp (original) +++ lldb/trunk/source/Target/Process.cpp Sun May 22 16:45:01 2011 @@ -2812,7 +2812,7 @@ m_process_sp (), m_state (eStateInvalid), m_restarted (false), - m_update_state (false), + m_update_state (0), m_interrupted (false) { } @@ -2822,7 +2822,7 @@ m_process_sp (process_sp), m_state (state), m_restarted (false), - m_update_state (false), + m_update_state (0), m_interrupted (false) { } @@ -2848,12 +2848,13 @@ Process::ProcessEventData::DoOnRemoval (Event *event_ptr) { // This function gets called twice for each event, once when the event gets pulled - // off of the private process event queue, and once when it gets pulled off of - // the public event queue. m_update_state is used to distinguish these - // two cases; it is false when we're just pulling it off for private handling, - // and we don't want to do the breakpoint command handling then. + // off of the private process event queue, and then any number of times, first when it gets pulled off of + // the public event queue, then other times when we're pretending that this is where we stopped at the + // end of expression evaluation. m_update_state is used to distinguish these + // three cases; it is 0 when we're just pulling it off for private handling, + // and > 1 for expression evaluation, and we don't want to do the breakpoint command handling then. - if (!m_update_state) + if (m_update_state != 1) return; m_process_sp->SetPublicState (m_state); From gclayton at apple.com Sun May 22 17:46:53 2011 From: gclayton at apple.com (Greg Clayton) Date: Sun, 22 May 2011 22:46:53 -0000 Subject: [Lldb-commits] [lldb] r131878 - in /lldb/trunk: include/lldb/Core/ include/lldb/Target/ source/Breakpoint/ source/Core/ source/Expression/ source/Plugins/ABI/MacOSX-arm/ source/Plugins/ABI/MacOSX-i386/ source/Plugins/ABI/SysV-x86_64/ source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/ source/Target/ tools/debugserver/source/MacOSX/ Message-ID: <20110522224653.AE2CD2A6C12C@llvm.org> Author: gclayton Date: Sun May 22 17:46:53 2011 New Revision: 131878 URL: http://llvm.org/viewvc/llvm-project?rev=131878&view=rev Log: Added new lldb_private::Process memory read/write functions to stop a bunch of duplicated code from appearing all over LLDB: lldb::addr_t Process::ReadPointerFromMemory (lldb::addr_t vm_addr, Error &error); bool Process::WritePointerToMemory (lldb::addr_t vm_addr, lldb::addr_t ptr_value, Error &error); size_t Process::ReadScalarIntegerFromMemory (lldb::addr_t addr, uint32_t byte_size, bool is_signed, Scalar &scalar, Error &error); size_t Process::WriteScalarToMemory (lldb::addr_t vm_addr, const Scalar &scalar, uint32_t size, Error &error); in lldb_private::Process the following functions were renamed: From: uint64_t Process::ReadUnsignedInteger (lldb::addr_t load_addr, size_t byte_size, Error &error); To: uint64_t Process::ReadUnsignedIntegerFromMemory (lldb::addr_t load_addr, size_t byte_size, uint64_t fail_value, Error &error); Cleaned up a lot of code that was manually doing what the above functions do to use the functions listed above. Added the ability to get a scalar value as a buffer that can be written down to a process (byte swapping the Scalar value if needed): uint32_t Scalar::GetAsMemoryData (void *dst, uint32_t dst_len, lldb::ByteOrder dst_byte_order, Error &error) const; The "dst_len" can be smaller that the size of the scalar and the least significant bytes will be written. "dst_len" can also be larger and the most significant bytes will be padded with zeroes. Centralized the code that adds or removes address bits for callable and opcode addresses into lldb_private::Target: lldb::addr_t Target::GetCallableLoadAddress (lldb::addr_t load_addr, AddressClass addr_class) const; lldb::addr_t Target::GetOpcodeLoadAddress (lldb::addr_t load_addr, AddressClass addr_class) const; All necessary lldb_private::Address functions now use the target versions so changes should only need to happen in one place if anything needs updating. Fixed up a lot of places that were calling : addr_t Address::GetLoadAddress(Target*); to call the Address::GetCallableLoadAddress() or Address::GetOpcodeLoadAddress() as needed. There were many places in the breakpoint code where things could go wrong for ARM if these weren't used. Modified: lldb/trunk/include/lldb/Core/Scalar.h lldb/trunk/include/lldb/Target/Process.h lldb/trunk/include/lldb/Target/Target.h lldb/trunk/include/lldb/Target/ThreadPlanRunToAddress.h lldb/trunk/source/Breakpoint/BreakpointLocation.cpp lldb/trunk/source/Core/Address.cpp lldb/trunk/source/Core/DataExtractor.cpp lldb/trunk/source/Core/Scalar.cpp lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp lldb/trunk/source/Expression/ClangExpressionParser.cpp lldb/trunk/source/Expression/ClangFunction.cpp lldb/trunk/source/Plugins/ABI/MacOSX-arm/ABIMacOSX_arm.cpp lldb/trunk/source/Plugins/ABI/MacOSX-i386/ABIMacOSX_i386.cpp lldb/trunk/source/Plugins/ABI/SysV-x86_64/ABISysV_x86_64.cpp lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.cpp lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTrampolineHandler.cpp lldb/trunk/source/Target/Process.cpp lldb/trunk/source/Target/Target.cpp lldb/trunk/source/Target/ThreadPlanRunToAddress.cpp lldb/trunk/tools/debugserver/source/MacOSX/MachThread.cpp Modified: lldb/trunk/include/lldb/Core/Scalar.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/Scalar.h?rev=131878&r1=131877&r2=131878&view=diff ============================================================================== --- lldb/trunk/include/lldb/Core/Scalar.h (original) +++ lldb/trunk/include/lldb/Core/Scalar.h Sun May 22 17:46:53 2011 @@ -63,12 +63,18 @@ static size_t GetMaxByteSize() { - return std::max (sizeof(long double), sizeof (unsigned long long)); + return sizeof(ValueData); } bool GetData (DataExtractor &data, size_t limit_byte_size = UINT32_MAX) const; + uint32_t + GetAsMemoryData (void *dst, + uint32_t dst_len, + lldb::ByteOrder dst_byte_order, + Error &error) const; + bool IsZero() const; Modified: lldb/trunk/include/lldb/Target/Process.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/Process.h?rev=131878&r1=131877&r2=131878&view=diff ============================================================================== --- lldb/trunk/include/lldb/Target/Process.h (original) +++ lldb/trunk/include/lldb/Target/Process.h Sun May 22 17:46:53 2011 @@ -2083,6 +2083,9 @@ /// @param[in] byte_size /// The size in byte of the integer to read. /// + /// @param[in] fail_value + /// The value to return if we fail to read an integer. + /// /// @param[out] error /// An error that indicates the success or failure of this /// operation. If error indicates success (error.Success()), @@ -2098,9 +2101,20 @@ /// order. //------------------------------------------------------------------ uint64_t - ReadUnsignedInteger (lldb::addr_t load_addr, - size_t byte_size, - Error &error); + ReadUnsignedIntegerFromMemory (lldb::addr_t load_addr, + size_t byte_size, + uint64_t fail_value, + Error &error); + + lldb::addr_t + ReadPointerFromMemory (lldb::addr_t vm_addr, + Error &error); + + bool + WritePointerToMemory (lldb::addr_t vm_addr, + lldb::addr_t ptr_value, + Error &error); + //------------------------------------------------------------------ /// Actually do the writing of memory to a process. /// @@ -2115,6 +2129,9 @@ /// @param[in] size /// The number of bytes to write. /// + /// @param[out] error + /// An error value in case the memory write fails. + /// /// @return /// The number of bytes that were actually written. //------------------------------------------------------------------ @@ -2122,6 +2139,51 @@ DoWriteMemory (lldb::addr_t vm_addr, const void *buf, size_t size, Error &error) = 0; //------------------------------------------------------------------ + /// Write all or part of a scalar value to memory. + /// + /// The value contained in \a scalar will be swapped to match the + /// byte order of the process that is being debugged. If \a size is + /// less than the size of scalar, the least significate \a size bytes + /// from scalar will be written. If \a size is larger than the byte + /// size of scalar, then the extra space will be padded with zeros + /// and the scalar value will be placed in the least significant + /// bytes in memory. + /// + /// @param[in] vm_addr + /// A virtual load address that indicates where to start writing + /// memory to. + /// + /// @param[in] scalar + /// The scalar to write to the debugged process. + /// + /// @param[in] size + /// This value can be smaller or larger than the scalar value + /// itself. If \a size is smaller than the size of \a scalar, + /// the least significant bytes in \a scalar will be used. If + /// \a size is larger than the byte size of \a scalar, then + /// the extra space will be padded with zeros. If \a size is + /// set to UINT32_MAX, then the size of \a scalar will be used. + /// + /// @param[out] error + /// An error value in case the memory write fails. + /// + /// @return + /// The number of bytes that were actually written. + //------------------------------------------------------------------ + size_t + WriteScalarToMemory (lldb::addr_t vm_addr, + const Scalar &scalar, + uint32_t size, + Error &error); + + size_t + ReadScalarIntegerFromMemory (lldb::addr_t addr, + uint32_t byte_size, + bool is_signed, + Scalar &scalar, + Error &error); + + //------------------------------------------------------------------ /// Write memory to a process. /// /// This function will write memory to the current process's Modified: lldb/trunk/include/lldb/Target/Target.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/Target.h?rev=131878&r1=131877&r2=131878&view=diff ============================================================================== --- lldb/trunk/include/lldb/Target/Target.h (original) +++ lldb/trunk/include/lldb/Target/Target.h Sun May 22 17:46:53 2011 @@ -280,6 +280,36 @@ void ModulesDidUnload (ModuleList &module_list); + + //------------------------------------------------------------------ + /// Get \a load_addr as a callable code load address for this target + /// + /// Take \a load_addr and potentially add any address bits that are + /// needed to make the address callable. For ARM this can set bit + /// zero (if it already isn't) if \a load_addr is a thumb function. + /// If \a addr_class is set to eAddressClassInvalid, then the address + /// adjustment will always happen. If it is set to an address class + /// that doesn't have code in it, LLDB_INVALID_ADDRESS will be + /// returned. + //------------------------------------------------------------------ + lldb::addr_t + GetCallableLoadAddress (lldb::addr_t load_addr, AddressClass addr_class = lldb_private::eAddressClassInvalid) const; + + //------------------------------------------------------------------ + /// Get \a load_addr as an opcode for this target. + /// + /// Take \a load_addr and potentially strip any address bits that are + /// needed to make the address point to an opcode. For ARM this can + /// clear bit zero (if it already isn't) if \a load_addr is a + /// thumb function and load_addr is in code. + /// If \a addr_class is set to eAddressClassInvalid, then the address + /// adjustment will always happen. If it is set to an address class + /// that doesn't have code in it, LLDB_INVALID_ADDRESS will be + /// returned. + //------------------------------------------------------------------ + lldb::addr_t + GetOpcodeLoadAddress (lldb::addr_t load_addr, AddressClass addr_class = lldb_private::eAddressClassInvalid) const; + protected: void ModuleAdded (lldb::ModuleSP &module_sp); Modified: lldb/trunk/include/lldb/Target/ThreadPlanRunToAddress.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/ThreadPlanRunToAddress.h?rev=131878&r1=131877&r2=131878&view=diff ============================================================================== --- lldb/trunk/include/lldb/Target/ThreadPlanRunToAddress.h (original) +++ lldb/trunk/include/lldb/Target/ThreadPlanRunToAddress.h Sun May 22 17:46:53 2011 @@ -33,7 +33,7 @@ bool stop_others); ThreadPlanRunToAddress (Thread &thread, - std::vector &addresses, + const std::vector &addresses, bool stop_others); Modified: lldb/trunk/source/Breakpoint/BreakpointLocation.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Breakpoint/BreakpointLocation.cpp?rev=131878&r1=131877&r2=131878&view=diff ============================================================================== --- lldb/trunk/source/Breakpoint/BreakpointLocation.cpp (original) +++ lldb/trunk/source/Breakpoint/BreakpointLocation.cpp Sun May 22 17:46:53 2011 @@ -36,7 +36,7 @@ lldb::tid_t tid, bool hardware ) : - StoppointLocation (loc_id, addr.GetLoadAddress(&owner.GetTarget()), hardware), + StoppointLocation (loc_id, addr.GetOpcodeLoadAddress(&owner.GetTarget()), hardware), m_address (addr), m_owner (owner), m_options_ap (), @@ -53,7 +53,7 @@ lldb::addr_t BreakpointLocation::GetLoadAddress () const { - return m_address.GetLoadAddress(&m_owner.GetTarget()); + return m_address.GetOpcodeLoadAddress (&m_owner.GetTarget()); } Address & @@ -290,7 +290,7 @@ LogSP log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_BREAKPOINTS); if (log) log->Warning ("Tried to add breakpoint site at 0x%llx but it was already present.\n", - m_address.GetLoadAddress(&m_owner.GetTarget())); + m_address.GetOpcodeLoadAddress (&m_owner.GetTarget())); return false; } @@ -438,7 +438,7 @@ "hw_index = %i hit_count = %-4u ignore_count = %-4u", GetID(), GetOptionsNoCreate()->GetThreadSpecNoCreate()->GetTID(), - (uint64_t) m_address.GetLoadAddress (&m_owner.GetTarget()), + (uint64_t) m_address.GetOpcodeLoadAddress (&m_owner.GetTarget()), (m_options_ap.get() ? m_options_ap->IsEnabled() : m_owner.IsEnabled()) ? "enabled " : "disabled", IsHardware() ? "hardware" : "software", GetHardwareIndex(), Modified: lldb/trunk/source/Core/Address.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/Address.cpp?rev=131878&r1=131877&r2=131878&view=diff ============================================================================== --- lldb/trunk/source/Core/Address.cpp (original) +++ lldb/trunk/source/Core/Address.cpp Sun May 22 17:46:53 2011 @@ -300,37 +300,9 @@ Address::GetCallableLoadAddress (Target *target) const { addr_t code_addr = GetLoadAddress (target); - - // Make sure we have section, otherwise the call to GetAddressClass() will - // fail because it uses the section to get to the module. - if (m_section && code_addr != LLDB_INVALID_ADDRESS) - { - switch (target->GetArchitecture().GetMachine()) - { - case llvm::Triple::arm: - case llvm::Triple::thumb: - // Check if bit zero it no set? - if ((code_addr & 1ull) == 0) - { - // Bit zero isn't set, check if the address is a multiple of 2? - if (code_addr & 2ull) - { - // The address is a multiple of 2 so it must be thumb, set bit zero - code_addr |= 1ull; - } - else if (GetAddressClass() == eAddressClassCodeAlternateISA) - { - // We checked the address and the address claims to be the alternate ISA - // which means thumb, so set bit zero. - code_addr |= 1ull; - } - } - break; - - default: - break; - } - } + + if (target) + return target->GetCallableLoadAddress (code_addr, GetAddressClass()); return code_addr; } @@ -339,57 +311,19 @@ { if (SetLoadAddress (load_addr, target)) { - switch (target->GetArchitecture().GetMachine()) - { - case llvm::Triple::arm: - case llvm::Triple::thumb: - // Check if bit zero it no set? - if ((m_offset & 1ull) == 0) - { - // Bit zero isn't set, check if the address is a multiple of 2? - if (m_offset & 2ull) - { - // The address is a multiple of 2 so it must be thumb, set bit zero - m_offset |= 1ull; - } - else if (GetAddressClass() == eAddressClassCodeAlternateISA) - { - // We checked the address and the address claims to be the alternate ISA - // which means thumb, so set bit zero. - m_offset |= 1ull; - } - } - break; - - default: - break; - } + if (target) + m_offset = target->GetCallableLoadAddress(m_offset, GetAddressClass()); return true; } return false; } - - addr_t Address::GetOpcodeLoadAddress (Target *target) const { addr_t code_addr = GetLoadAddress (target); - if (code_addr != LLDB_INVALID_ADDRESS) - { - switch (target->GetArchitecture().GetMachine()) - { - case llvm::Triple::arm: - case llvm::Triple::thumb: - // Strip bit zero to make sure we end up on an opcode boundary - return code_addr & ~(1ull); - break; - - default: - break; - } - } + code_addr = target->GetOpcodeLoadAddress (code_addr, GetAddressClass()); return code_addr; } @@ -398,17 +332,8 @@ { if (SetLoadAddress (load_addr, target)) { - switch (target->GetArchitecture().GetMachine()) - { - case llvm::Triple::arm: - case llvm::Triple::thumb: - // Make sure bit zero is clear - m_offset &= ~(1ull); - break; - - default: - break; - } + if (target) + m_offset = target->GetOpcodeLoadAddress (m_offset, GetAddressClass()); return true; } return false; Modified: lldb/trunk/source/Core/DataExtractor.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/DataExtractor.cpp?rev=131878&r1=131877&r2=131878&view=diff ============================================================================== --- lldb/trunk/source/Core/DataExtractor.cpp (original) +++ lldb/trunk/source/Core/DataExtractor.cpp Sun May 22 17:46:53 2011 @@ -1063,7 +1063,7 @@ const uint8_t* src = (const uint8_t *)PeekData (src_offset, src_len); if (src) { - if (src_len >= dst_len) + if (dst_len >= src_len) { // We are copying the entire value from src into dst. // Calculate how many, if any, zeroes we need for the most Modified: lldb/trunk/source/Core/Scalar.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/Scalar.cpp?rev=131878&r1=131877&r2=131878&view=diff ============================================================================== --- lldb/trunk/source/Core/Scalar.cpp (original) +++ lldb/trunk/source/Core/Scalar.cpp Sun May 22 17:46:53 2011 @@ -1989,6 +1989,34 @@ return false; } +uint32_t +Scalar::GetAsMemoryData (void *dst, + uint32_t dst_len, + lldb::ByteOrder dst_byte_order, + Error &error) const +{ + // Get a data extractor that points to the native scalar data + DataExtractor data; + if (!GetData(data)) + { + error.SetErrorString ("invalid scalar value"); + return 0; + } + + const size_t src_len = data.GetByteSize(); + + // Prepare a memory buffer that contains some or all of the register value + const uint32_t bytes_copied = data.CopyByteOrderedData (0, // src offset + src_len, // src length + dst, // dst buffer + dst_len, // dst length + dst_byte_order); // dst byte order + if (bytes_copied == 0) + error.SetErrorString ("failed to copy data"); + + return bytes_copied; +} + bool lldb_private::operator== (const Scalar& lhs, const Scalar& rhs) { Modified: lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp?rev=131878&r1=131877&r2=131878&view=diff ============================================================================== --- lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp (original) +++ lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp Sun May 22 17:46:53 2011 @@ -680,7 +680,6 @@ { lldb::addr_t value_addr = location_value->GetScalar().ULongLong(); uint32_t address_byte_size = exe_ctx.target->GetArchitecture().GetAddressByteSize(); - lldb::ByteOrder address_byte_order = exe_ctx.process->GetByteOrder(); if (ClangASTType::GetClangTypeBitWidth(m_struct_vars->m_object_pointer_type.GetASTContext(), m_struct_vars->m_object_pointer_type.GetOpaqueQualType()) != address_byte_size * 8) @@ -689,22 +688,13 @@ return false; } - DataBufferHeap data; - data.SetByteSize(address_byte_size); Error read_error; - - if (exe_ctx.process->ReadMemory (value_addr, data.GetBytes(), address_byte_size, read_error) != address_byte_size) + object_ptr = exe_ctx.process->ReadPointerFromMemory (value_addr, read_error); + if (read_error.Fail() || object_ptr == LLDB_INVALID_ADDRESS) { err.SetErrorStringWithFormat("Coldn't read '%s' from the target: %s", object_name.GetCString(), read_error.AsCString()); return false; - } - - DataExtractor extractor(data.GetBytes(), data.GetByteSize(), address_byte_order, address_byte_size); - - uint32_t offset = 0; - - object_ptr = extractor.GetPointer(&offset); - + } return true; } case Value::eValueTypeScalar: @@ -812,16 +802,18 @@ return false; } - lldb::DataBufferSP data(new DataBufferHeap(m_struct_vars->m_struct_size, 0)); + lldb::DataBufferSP data_sp(new DataBufferHeap(m_struct_vars->m_struct_size, 0)); Error error; - if (exe_ctx.process->ReadMemory (m_material_vars->m_materialized_location, data->GetBytes(), data->GetByteSize(), error) != data->GetByteSize()) + if (exe_ctx.process->ReadMemory (m_material_vars->m_materialized_location, + data_sp->GetBytes(), + data_sp->GetByteSize(), error) != data_sp->GetByteSize()) { err.SetErrorStringWithFormat ("Couldn't read struct from the target: %s", error.AsCString()); return false; } - DataExtractor extractor(data, exe_ctx.process->GetByteOrder(), exe_ctx.target->GetArchitecture().GetAddressByteSize()); + DataExtractor extractor(data_sp, exe_ctx.process->GetByteOrder(), exe_ctx.target->GetArchitecture().GetAddressByteSize()); for (size_t member_idx = 0, num_members = m_struct_members.GetSize(); member_idx < num_members; @@ -1000,63 +992,6 @@ return true; } -static bool WriteAddressInto -( - ExecutionContext &exe_ctx, - lldb::addr_t target, - lldb::addr_t address, - Error &err -) -{ - size_t pointer_byte_size = exe_ctx.process->GetAddressByteSize(); - - StreamString str (0 | Stream::eBinary, - pointer_byte_size, - exe_ctx.process->GetByteOrder()); - - switch (pointer_byte_size) - { - default: - assert(!"Unhandled byte size"); - case 4: - { - uint32_t address32 = address & 0xffffffffll; - str.PutRawBytes(&address32, sizeof(address32), endian::InlHostByteOrder(), eByteOrderInvalid); - } - break; - case 8: - { - uint64_t address64 = address; - str.PutRawBytes(&address64, sizeof(address64), endian::InlHostByteOrder(), eByteOrderInvalid); - } - break; - } - - return (exe_ctx.process->WriteMemory (target, str.GetData(), pointer_byte_size, err) == pointer_byte_size); -} - -static lldb::addr_t ReadAddressFrom -( - ExecutionContext &exe_ctx, - lldb::addr_t source, - Error &err -) -{ - size_t pointer_byte_size = exe_ctx.process->GetAddressByteSize(); - - DataBufferHeap *buf = new DataBufferHeap(pointer_byte_size, 0); - DataBufferSP buf_sp(buf); - - if (exe_ctx.process->ReadMemory (source, buf->GetBytes(), pointer_byte_size, err) != pointer_byte_size) - return LLDB_INVALID_ADDRESS; - - DataExtractor extractor (buf_sp, exe_ctx.process->GetByteOrder(), exe_ctx.process->GetAddressByteSize()); - - uint32_t offset = 0; - - return (lldb::addr_t)extractor.GetPointer(&offset); -} - bool ClangExpressionDeclMap::DoMaterializeOnePersistentVariable ( @@ -1098,7 +1033,7 @@ // Get the location of the target out of the struct. Error read_error; - mem = ReadAddressFrom(exe_ctx, addr, read_error); + mem = exe_ctx.process->ReadPointerFromMemory (addr, read_error); if (mem == LLDB_INVALID_ADDRESS) { @@ -1243,19 +1178,19 @@ if ((var_sp->m_flags & ClangExpressionVariable::EVIsProgramReference && var_sp->m_live_sp) || var_sp->m_flags & ClangExpressionVariable::EVIsLLDBAllocated) { - mem = var_sp->m_live_sp->GetValue().GetScalar().ULongLong(); - // Now write the location of the area into the struct. - Error write_error; - if (!WriteAddressInto(exe_ctx, addr, mem, write_error)) + if (!exe_ctx.process->WriteScalarToMemory (addr, + var_sp->m_live_sp->GetValue().GetScalar(), + exe_ctx.process->GetAddressByteSize(), + write_error)) { err.SetErrorStringWithFormat ("Couldn't write %s to the target: %s", var_sp->GetName().GetCString(), write_error.AsCString()); return false; } if (log) - log->Printf("Materialized %s into 0x%llx", var_sp->GetName().GetCString(), (uint64_t)mem); + log->Printf("Materialized %s into 0x%llx", var_sp->GetName().GetCString(), var_sp->m_live_sp->GetValue().GetScalar().ULongLong()); } else if (!(var_sp->m_flags & ClangExpressionVariable::EVIsProgramReference)) { @@ -1308,7 +1243,8 @@ if (!GetSymbolAddress(*exe_ctx.target, name, location_load_addr)) { if (log) - err.SetErrorStringWithFormat("Couldn't find value for global symbol %s", name.GetCString()); + err.SetErrorStringWithFormat ("Couldn't find value for global symbol %s", + name.GetCString()); } location_value->SetValueType(Value::eValueTypeLoadAddress); @@ -1316,7 +1252,8 @@ } else { - err.SetErrorStringWithFormat("Couldn't find %s with appropriate type", name.GetCString()); + err.SetErrorStringWithFormat ("Couldn't find %s with appropriate type", + name.GetCString()); return false; } @@ -1328,7 +1265,10 @@ type.GetOpaqueQualType(), &my_stream_string); - log->Printf("%s %s with type %s", (dematerialize ? "Dematerializing" : "Materializing"), name.GetCString(), my_stream_string.GetString().c_str()); + log->Printf ("%s %s with type %s", + dematerialize ? "Dematerializing" : "Materializing", + name.GetCString(), + my_stream_string.GetString().c_str()); } if (!location_value.get()) @@ -1352,7 +1292,9 @@ location_value->Dump(&ss); - err.SetErrorStringWithFormat("%s has a value of unhandled type: %s", name.GetCString(), ss.GetString().c_str()); + err.SetErrorStringWithFormat ("%s has a value of unhandled type: %s", + name.GetCString(), + ss.GetString().c_str()); return false; } break; @@ -1360,16 +1302,16 @@ { if (!dematerialize) { - lldb::addr_t value_addr = location_value->GetScalar().ULongLong(); - - Error error; + Error write_error; - if (!WriteAddressInto(exe_ctx, - addr, - value_addr, - error)) + if (!exe_ctx.process->WriteScalarToMemory (addr, + location_value->GetScalar(), + exe_ctx.process->GetAddressByteSize(), + write_error)) { - err.SetErrorStringWithFormat ("Couldn't write %s to the target: %s", name.GetCString(), error.AsCString()); + err.SetErrorStringWithFormat ("Couldn't write %s to the target: %s", + name.GetCString(), + write_error.AsCString()); return false; } } @@ -1382,17 +1324,18 @@ StreamString ss; location_value->Dump(&ss); - err.SetErrorStringWithFormat("%s is a scalar of unhandled type: %s", name.GetCString(), ss.GetString().c_str()); + err.SetErrorStringWithFormat ("%s is a scalar of unhandled type: %s", + name.GetCString(), + ss.GetString().c_str()); return false; } - lldb::addr_t reg_addr = LLDB_INVALID_ADDRESS; // The address of a spare memory area aused to hold the variable. - RegisterInfo *reg_info = location_value->GetRegisterInfo(); if (!reg_info) { - err.SetErrorStringWithFormat("Couldn't get the register information for %s", name.GetCString()); + err.SetErrorStringWithFormat ("Couldn't get the register information for %s", + name.GetCString()); return false; } @@ -1402,7 +1345,9 @@ if (!reg_ctx) { - err.SetErrorStringWithFormat("Couldn't read register context to read %s from %s", name.GetCString(), reg_info->name); + err.SetErrorStringWithFormat ("Couldn't read register context to read %s from %s", + name.GetCString(), + reg_info->name); return false; } @@ -1424,25 +1369,32 @@ return false; } - reg_addr = expr_var->m_live_sp->GetValue().GetScalar().ULongLong(); + Scalar ®_addr = expr_var->m_live_sp->GetValue().GetScalar(); - err = reg_ctx->ReadRegisterValueFromMemory (reg_info, reg_addr, value_byte_size, reg_value); + err = reg_ctx->ReadRegisterValueFromMemory (reg_info, + reg_addr.ULongLong(), + value_byte_size, + reg_value); if (err.Fail()) return false; if (!reg_ctx->WriteRegister (reg_info, reg_value)) { - err.SetErrorStringWithFormat("Couldn't write %s to register %s", name.GetCString(), reg_info->name); + err.SetErrorStringWithFormat ("Couldn't write %s to register %s", + name.GetCString(), + reg_info->name); return false; } // Deallocate the spare area and clear the variable's live data. - Error deallocate_error = exe_ctx.process->DeallocateMemory(reg_addr); + Error deallocate_error = exe_ctx.process->DeallocateMemory(reg_addr.ULongLong()); if (!deallocate_error.Success()) { - err.SetErrorStringWithFormat("Couldn't deallocate spare memory area for %s: %s", name.GetCString(), deallocate_error.AsCString()); + err.SetErrorStringWithFormat ("Couldn't deallocate spare memory area for %s: %s", + name.GetCString(), + deallocate_error.AsCString()); return false; } @@ -1455,13 +1407,15 @@ Error allocate_error; - reg_addr = exe_ctx.process->AllocateMemory (value_byte_size, - lldb::ePermissionsReadable | lldb::ePermissionsWritable, - allocate_error); + Scalar reg_addr (exe_ctx.process->AllocateMemory (value_byte_size, + lldb::ePermissionsReadable | lldb::ePermissionsWritable, + allocate_error)); - if (reg_addr == LLDB_INVALID_ADDRESS) + if (reg_addr.ULongLong() == LLDB_INVALID_ADDRESS) { - err.SetErrorStringWithFormat("Couldn't allocate a memory area to store %s: %s", name.GetCString(), allocate_error.AsCString()); + err.SetErrorStringWithFormat ("Couldn't allocate a memory area to store %s: %s", + name.GetCString(), + allocate_error.AsCString()); return false; } @@ -1471,66 +1425,47 @@ type.GetASTContext(), type.GetOpaqueQualType(), name, - reg_addr, + reg_addr.ULongLong(), eAddressTypeLoad, value_byte_size); // Now write the location of the area into the struct. Error write_error; - if (!WriteAddressInto(exe_ctx, addr, reg_addr, write_error)) + + if (!exe_ctx.process->WriteScalarToMemory (addr, + reg_addr, + exe_ctx.process->GetAddressByteSize(), + write_error)) { - err.SetErrorStringWithFormat ("Couldn't write %s to the target: %s", name.GetCString(), write_error.AsCString()); + err.SetErrorStringWithFormat ("Couldn't write %s to the target: %s", + name.GetCString(), + write_error.AsCString()); return false; } - // Moving from a register into addr - // - // Case 1: addr_byte_size and register_byte_size are the same - // - // |AABBCCDD| Register contents - // |AABBCCDD| Address contents - // - // Case 2: addr_byte_size is bigger than register_byte_size - // - // Error! (The register should always be big enough to hold the data) - // - // Case 3: register_byte_size is bigger than addr_byte_size - // - // |AABBCCDD| Register contents - // |AABB| Address contents on little-endian hardware - // |CCDD| Address contents on big-endian hardware - if (value_byte_size > register_byte_size) { - err.SetErrorStringWithFormat("%s is too big to store in %s", name.GetCString(), reg_info->name); + err.SetErrorStringWithFormat ("%s is too big to store in %s", + name.GetCString(), + reg_info->name); return false; } - - uint32_t register_offset; - - switch (exe_ctx.process->GetByteOrder()) - { - default: - err.SetErrorStringWithFormat("%s is stored with an unhandled byte order", name.GetCString()); - return false; - case lldb::eByteOrderLittle: - register_offset = 0; - break; - case lldb::eByteOrderBig: - register_offset = register_byte_size - value_byte_size; - break; - } RegisterValue reg_value; if (!reg_ctx->ReadRegister (reg_info, reg_value)) { - err.SetErrorStringWithFormat("Couldn't read %s from %s", name.GetCString(), reg_info->name); + err.SetErrorStringWithFormat ("Couldn't read %s from %s", + name.GetCString(), + reg_info->name); return false; } - err = reg_ctx->WriteRegisterValueToMemory(reg_info, reg_addr, value_byte_size, reg_value); + err = reg_ctx->WriteRegisterValueToMemory (reg_info, + reg_addr.ULongLong(), + value_byte_size, + reg_value); if (err.Fail()) return false; } Modified: lldb/trunk/source/Expression/ClangExpressionParser.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/ClangExpressionParser.cpp?rev=131878&r1=131877&r2=131878&view=diff ============================================================================== --- lldb/trunk/source/Expression/ClangExpressionParser.cpp (original) +++ lldb/trunk/source/Expression/ClangExpressionParser.cpp Sun May 22 17:46:53 2011 @@ -654,7 +654,7 @@ if (exc_context.process->WriteMemory(cursor, (void *) lstart, size, write_error) != size) { err.SetErrorToGenericError(); - err.SetErrorStringWithFormat("Couldn't copy JITted function into the target: %s", write_error.AsCString("unknown error")); + err.SetErrorStringWithFormat("Couldn't copy JIT code for function into the target: %s", write_error.AsCString("unknown error")); return err; } Modified: lldb/trunk/source/Expression/ClangFunction.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/ClangFunction.cpp?rev=131878&r1=131877&r2=131878&view=diff ============================================================================== --- lldb/trunk/source/Expression/ClangFunction.cpp (original) +++ lldb/trunk/source/Expression/ClangFunction.cpp Sun May 22 17:46:53 2011 @@ -314,12 +314,10 @@ } } - // FIXME: This is fake, and just assumes that it matches that architecture. - // Make a data extractor and put the address into the right byte order & size. - - uint64_t fun_addr = function_address.GetLoadAddress(exe_ctx.target); + // TODO: verify fun_addr needs to be a callable address + Scalar fun_addr (function_address.GetCallableLoadAddress(exe_ctx.target)); int first_offset = m_member_offsets[0]; - process->WriteMemory(args_addr_ref + first_offset, &fun_addr, 8, error); + process->WriteScalarToMemory(args_addr_ref + first_offset, fun_addr, process->GetAddressByteSize(), error); // FIXME: We will need to extend this for Variadic functions. @@ -350,13 +348,8 @@ const Scalar &arg_scalar = arg_value->ResolveValue(&exe_ctx, m_clang_ast_context->getASTContext()); - int byte_size = arg_scalar.GetByteSize(); - std::vector buffer; - buffer.resize(byte_size); - DataExtractor value_data; - arg_scalar.GetData (value_data); - value_data.ExtractBytes(0, byte_size, process->GetByteOrder(), &buffer.front()); - process->WriteMemory(args_addr_ref + offset, &buffer.front(), byte_size, error); + if (!process->WriteScalarToMemory(args_addr_ref + offset, arg_scalar, arg_scalar.GetByteSize(), error)) + return false; } return true; @@ -420,8 +413,6 @@ // Read the return value - it is the last field in the struct: // FIXME: How does clang tell us there's no return value? We need to handle that case. - std::vector data_buffer; - data_buffer.resize(m_return_size); Process *process = exe_ctx.process; if (process == NULL) @@ -430,25 +421,13 @@ return false; Error error; - size_t bytes_read = process->ReadMemory(args_addr + m_return_offset, &data_buffer.front(), m_return_size, error); + ret_value.GetScalar() = process->ReadUnsignedIntegerFromMemory (args_addr + m_return_offset, m_return_size, 0, error); - if (bytes_read == 0) - { + if (error.Fail()) return false; - } - if (bytes_read < m_return_size) - return false; - - DataExtractor data(&data_buffer.front(), m_return_size, process->GetByteOrder(), process->GetAddressByteSize()); - // FIXME: Assuming an integer scalar for now: - - uint32_t offset = 0; - uint64_t return_integer = data.GetMaxU64(&offset, m_return_size); - ret_value.SetContext (Value::eContextTypeClangType, m_function_return_qual_type); ret_value.SetValueType(Value::eValueTypeScalar); - ret_value.GetScalar() = return_integer; return true; } Modified: lldb/trunk/source/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=131878&r1=131877&r2=131878&view=diff ============================================================================== --- lldb/trunk/source/Plugins/ABI/MacOSX-arm/ABIMacOSX_arm.cpp (original) +++ lldb/trunk/source/Plugins/ABI/MacOSX-arm/ABIMacOSX_arm.cpp Sun May 22 17:46:53 2011 @@ -269,29 +269,11 @@ { // Arguments 5 on up are on the stack const uint32_t arg_byte_size = (bit_width + (8-1)) / 8; - if (arg_byte_size <= sizeof(uint64_t)) - { - uint8_t arg_data[sizeof(uint64_t)]; - Error error; - thread.GetProcess().ReadMemory(sp, arg_data, sizeof(arg_data), error); - DataExtractor arg_data_extractor (arg_data, sizeof(arg_data), - thread.GetProcess().GetTarget().GetArchitecture().GetByteOrder(), - thread.GetProcess().GetTarget().GetArchitecture().GetAddressByteSize()); - uint32_t offset = 0; - if (arg_byte_size <= 4) - value->GetScalar() = arg_data_extractor.GetMaxU32 (&offset, arg_byte_size); - else if (arg_byte_size <= 8) - value->GetScalar() = arg_data_extractor.GetMaxU64 (&offset, arg_byte_size); - else - return false; - - if (offset == 0 || offset == UINT32_MAX) - return false; + Error error; + if (!thread.GetProcess().ReadScalarIntegerFromMemory(sp, arg_byte_size, is_signed, value->GetScalar(), error)) + return false; - if (is_signed) - value->GetScalar().SignExtend (bit_width); - sp += arg_byte_size; - } + sp += arg_byte_size; } } } Modified: lldb/trunk/source/Plugins/ABI/MacOSX-i386/ABIMacOSX_i386.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ABI/MacOSX-i386/ABIMacOSX_i386.cpp?rev=131878&r1=131877&r2=131878&view=diff ============================================================================== --- lldb/trunk/source/Plugins/ABI/MacOSX-i386/ABIMacOSX_i386.cpp (original) +++ lldb/trunk/source/Plugins/ABI/MacOSX-i386/ABIMacOSX_i386.cpp Sun May 22 17:46:53 2011 @@ -397,84 +397,22 @@ return true; } -static bool ReadIntegerArgument(Scalar &scalar, - unsigned int bit_width, - bool is_signed, - Process &process, - addr_t ¤t_stack_argument) +static bool +ReadIntegerArgument (Scalar &scalar, + unsigned int bit_width, + bool is_signed, + Process &process, + addr_t ¤t_stack_argument) { - if (bit_width > 64) - return false; // Scalar can't hold large integer arguments - uint64_t arg_contents; - uint32_t read_data; + uint32_t byte_size = (bit_width + (8-1))/8; Error error; - - if (bit_width > 32) + if (process.ReadScalarIntegerFromMemory(current_stack_argument, byte_size, is_signed, scalar, error)) { - if (process.ReadMemory(current_stack_argument, &read_data, sizeof(read_data), error) != sizeof(read_data)) - return false; - - arg_contents = read_data; - - if (process.ReadMemory(current_stack_argument + 4, &read_data, sizeof(read_data), error) != sizeof(read_data)) - return false; - - arg_contents |= ((uint64_t)read_data) << 32; - - current_stack_argument += 8; - } - else { - if (process.ReadMemory(current_stack_argument, &read_data, sizeof(read_data), error) != sizeof(read_data)) - return false; - - arg_contents = read_data; - - current_stack_argument += 4; + current_stack_argument += byte_size; + return true; } - - if (is_signed) - { - switch (bit_width) - { - default: - return false; - case 8: - scalar = (int8_t)(arg_contents & 0xff); - break; - case 16: - scalar = (int16_t)(arg_contents & 0xffff); - break; - case 32: - scalar = (int32_t)(arg_contents & 0xffffffff); - break; - case 64: - scalar = (int64_t)arg_contents; - break; - } - } - else - { - switch (bit_width) - { - default: - return false; - case 8: - scalar = (uint8_t)(arg_contents & 0xff); - break; - case 16: - scalar = (uint16_t)(arg_contents & 0xffff); - break; - case 32: - scalar = (uint32_t)(arg_contents & 0xffffffff); - break; - case 64: - scalar = (uint64_t)arg_contents; - break; - } - } - - return true; + return false; } bool Modified: lldb/trunk/source/Plugins/ABI/SysV-x86_64/ABISysV_x86_64.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ABI/SysV-x86_64/ABISysV_x86_64.cpp?rev=131878&r1=131877&r2=131878&view=diff ============================================================================== --- lldb/trunk/source/Plugins/ABI/SysV-x86_64/ABISysV_x86_64.cpp (original) +++ lldb/trunk/source/Plugins/ABI/SysV-x86_64/ABISysV_x86_64.cpp Sun May 22 17:46:53 2011 @@ -194,69 +194,24 @@ if (bit_width > 64) return false; // Scalar can't hold large integer arguments - uint64_t arg_contents; - if (current_argument_register < 6) { - arg_contents = thread.GetRegisterContext()->ReadRegisterAsUnsigned(argument_register_ids[current_argument_register], 0); + scalar = thread.GetRegisterContext()->ReadRegisterAsUnsigned(argument_register_ids[current_argument_register], 0); current_argument_register++; + if (is_signed) + scalar.SignExtend (bit_width); } else { - uint8_t arg_data[sizeof(arg_contents)]; + uint32_t byte_size = (bit_width + (8-1))/8; Error error; - thread.GetProcess().ReadMemory(current_stack_argument, arg_data, sizeof(arg_contents), error); - DataExtractor arg_data_extractor (arg_data, sizeof(arg_contents), - thread.GetProcess().GetTarget().GetArchitecture().GetByteOrder(), - thread.GetProcess().GetTarget().GetArchitecture().GetAddressByteSize()); - uint32_t offset = 0; - arg_contents = arg_data_extractor.GetMaxU64(&offset, bit_width / 8); - if (!offset) - return false; - current_stack_argument += (bit_width / 8); - } - - if (is_signed) - { - switch (bit_width) - { - default: - return false; - case 8: - scalar = (int8_t)(arg_contents & 0xff); - break; - case 16: - scalar = (int16_t)(arg_contents & 0xffff); - break; - case 32: - scalar = (int32_t)(arg_contents & 0xffffffff); - break; - case 64: - scalar = (int64_t)arg_contents; - break; - } - } - else - { - switch (bit_width) + if (thread.GetProcess().ReadScalarIntegerFromMemory(current_stack_argument, byte_size, is_signed, scalar, error)) { - default: - return false; - case 8: - scalar = (uint8_t)(arg_contents & 0xffu); - break; - case 16: - scalar = (uint16_t)(arg_contents & 0xffffu); - break; - case 32: - scalar = (uint32_t)(arg_contents & 0xffffffffu); - break; - case 64: - scalar = (uint64_t)arg_contents; - break; + current_stack_argument += byte_size; + return true; } + return false; } - return true; } Modified: lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.cpp?rev=131878&r1=131877&r2=131878&view=diff ============================================================================== --- lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.cpp (original) +++ lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.cpp Sun May 22 17:46:53 2011 @@ -64,7 +64,7 @@ } bool -AppleObjCRuntime::GetObjectDescription (Stream &str, Value &value, ExecutionContextScope *exe_scope) +AppleObjCRuntime::GetObjectDescription (Stream &strm, Value &value, ExecutionContextScope *exe_scope) { if (!m_read_objc_library) return false; @@ -88,7 +88,7 @@ clang::QualType value_type = clang::QualType::getFromOpaquePtr (value.GetClangType()); if (!value_type->isObjCObjectPointerType()) { - str.Printf ("Value doesn't point to an ObjC object.\n"); + strm.Printf ("Value doesn't point to an ObjC object.\n"); return false; } } @@ -138,35 +138,22 @@ ret); if (results != eExecutionCompleted) { - str.Printf("Error evaluating Print Object function: %d.\n", results); + strm.Printf("Error evaluating Print Object function: %d.\n", results); return false; } addr_t result_ptr = ret.GetScalar().ULongLong(LLDB_INVALID_ADDRESS); - // FIXME: poor man's strcpy - we should have a "read memory as string interface... - - Error error; - std::vector desc; - while (1) - { - char byte = '\0'; - if (exe_ctx.process->ReadMemory(result_ptr + desc.size(), &byte, 1, error) != 1) - break; - - desc.push_back(byte); - - if (byte == '\0') - break; + char buf[512]; + size_t cstr_len = 0; + size_t curr_len = sizeof(buf); + while (curr_len == sizeof(buf)) + { + curr_len = exe_ctx.process->ReadCStringFromMemory(result_ptr + cstr_len, buf, sizeof(buf)); + strm.Write (buf, curr_len); + cstr_len += curr_len; } - - if (!desc.empty()) - { - str.PutCString(&desc.front()); - return true; - } - return false; - + return cstr_len > 0; } Address * Modified: lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp?rev=131878&r1=131877&r2=131878&view=diff ============================================================================== --- lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp (original) +++ lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp Sun May 22 17:46:53 2011 @@ -220,9 +220,9 @@ bool AppleObjCRuntimeV2::GetDynamicTypeAndAddress (ValueObject &in_value, - lldb::DynamicValueType use_dynamic, - TypeAndOrName &class_type_or_name, - Address &address) + lldb::DynamicValueType use_dynamic, + TypeAndOrName &class_type_or_name, + Address &address) { // The Runtime is attached to a particular process, you shouldn't pass in a value from another process. assert (in_value.GetUpdatePoint().GetProcess() == m_process); @@ -244,9 +244,11 @@ Target *target = m_process->CalculateTarget(); char memory_buffer[16]; - DataExtractor data(memory_buffer, sizeof(memory_buffer), - m_process->GetByteOrder(), - m_process->GetAddressByteSize()); + DataExtractor data (memory_buffer, + sizeof(memory_buffer), + m_process->GetByteOrder(), + m_process->GetAddressByteSize()); + size_t address_byte_size = m_process->GetAddressByteSize(); Error error; size_t bytes_read = m_process->ReadMemory (original_ptr, @@ -258,10 +260,10 @@ return false; } - uint32_t offset_ptr = 0; - lldb::addr_t isa_addr = data.GetAddress (&offset_ptr); + uint32_t offset = 0; + lldb::addr_t isa_addr = data.GetAddress (&offset); - if (offset_ptr == 0) + if (offset == 0) return false; // Make sure the class address is readable, otherwise this is not a good object: Modified: lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTrampolineHandler.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTrampolineHandler.cpp?rev=131878&r1=131877&r2=131878&view=diff ============================================================================== --- lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTrampolineHandler.cpp (original) +++ lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTrampolineHandler.cpp Sun May 22 17:46:53 2011 @@ -340,8 +340,8 @@ if (m_objc_module_sp) { ConstString trampoline_name ("gdb_objc_trampolines"); - const Symbol *trampoline_symbol = m_objc_module_sp->FindFirstSymbolWithNameAndType(trampoline_name, - eSymbolTypeData); + const Symbol *trampoline_symbol = m_objc_module_sp->FindFirstSymbolWithNameAndType (trampoline_name, + eSymbolTypeData); if (trampoline_symbol != NULL) { if (!trampoline_symbol->GetValue().IsValid()) @@ -353,18 +353,17 @@ // Next look up the "changed" symbol and set a breakpoint on that... ConstString changed_name ("gdb_objc_trampolines_changed"); - const Symbol *changed_symbol = m_objc_module_sp->FindFirstSymbolWithNameAndType(changed_name, - eSymbolTypeCode); + const Symbol *changed_symbol = m_objc_module_sp->FindFirstSymbolWithNameAndType (changed_name, + eSymbolTypeCode); if (changed_symbol != NULL) { if (!changed_symbol->GetValue().IsValid()) return false; - lldb::addr_t changed_addr = changed_symbol->GetValue().GetLoadAddress(&target); + lldb::addr_t changed_addr = changed_symbol->GetValue().GetOpcodeLoadAddress (&target); if (changed_addr != LLDB_INVALID_ADDRESS) { - BreakpointSP trampolines_changed_bp_sp = target.CreateBreakpoint (changed_addr, - true); + BreakpointSP trampolines_changed_bp_sp = target.CreateBreakpoint (changed_addr, true); if (trampolines_changed_bp_sp != NULL) { m_trampolines_changed_bp_id = trampolines_changed_bp_sp->GetID(); @@ -427,18 +426,11 @@ m_regions.clear(); if (!InitializeVTableSymbols()) return false; - char memory_buffer[8]; - DataExtractor data(memory_buffer, sizeof(memory_buffer), - m_process_sp->GetByteOrder(), - m_process_sp->GetAddressByteSize()); Error error; - size_t bytes_read = m_process_sp->ReadMemory (m_trampoline_header, memory_buffer, m_process_sp->GetAddressByteSize(), error); - if (bytes_read != m_process_sp->GetAddressByteSize()) - return false; - - uint32_t offset_ptr = 0; - lldb::addr_t region_addr = data.GetPointer(&offset_ptr); - return ReadRegions (region_addr); + lldb::addr_t region_addr = m_process_sp->ReadPointerFromMemory (m_trampoline_header, error); + if (error.Success()) + return ReadRegions (region_addr); + return false; } bool @@ -535,13 +527,13 @@ const Symbol *msg_forward_stret = m_objc_module_sp->FindFirstSymbolWithNameAndType (msg_forward_stret_name, eSymbolTypeCode); if (class_getMethodImplementation) - m_impl_fn_addr = class_getMethodImplementation->GetValue().GetLoadAddress(target); + m_impl_fn_addr = class_getMethodImplementation->GetValue().GetOpcodeLoadAddress (target); if (class_getMethodImplementation_stret) - m_impl_stret_fn_addr = class_getMethodImplementation_stret->GetValue().GetLoadAddress(target); + m_impl_stret_fn_addr = class_getMethodImplementation_stret->GetValue().GetOpcodeLoadAddress (target); if (msg_forward) - m_msg_forward_addr = msg_forward->GetValue().GetLoadAddress(target); + m_msg_forward_addr = msg_forward->GetValue().GetOpcodeLoadAddress(target); if (msg_forward_stret) - m_msg_forward_stret_addr = msg_forward_stret->GetValue().GetLoadAddress(target); + m_msg_forward_stret_addr = msg_forward_stret->GetValue().GetOpcodeLoadAddress(target); // FIXME: Do some kind of logging here. if (m_impl_fn_addr == LLDB_INVALID_ADDRESS || m_impl_stret_fn_addr == LLDB_INVALID_ADDRESS) Modified: lldb/trunk/source/Target/Process.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/Process.cpp?rev=131878&r1=131877&r2=131878&view=diff ============================================================================== --- lldb/trunk/source/Target/Process.cpp (original) +++ lldb/trunk/source/Target/Process.cpp Sun May 22 17:46:53 2011 @@ -1708,29 +1708,36 @@ } uint64_t -Process::ReadUnsignedInteger (lldb::addr_t vm_addr, size_t integer_byte_size, Error &error) +Process::ReadUnsignedIntegerFromMemory (lldb::addr_t vm_addr, size_t integer_byte_size, uint64_t fail_value, Error &error) { - if (integer_byte_size > sizeof(uint64_t)) - { - error.SetErrorString ("unsupported integer size"); - } + Scalar scalar; + if (ReadScalarIntegerFromMemory(vm_addr, integer_byte_size, false, scalar, error)) + return scalar.ULongLong(fail_value); + return fail_value; +} + +addr_t +Process::ReadPointerFromMemory (lldb::addr_t vm_addr, Error &error) +{ + Scalar scalar; + if (ReadScalarIntegerFromMemory(vm_addr, GetAddressByteSize(), false, scalar, error)) + return scalar.ULongLong(LLDB_INVALID_ADDRESS); + return LLDB_INVALID_ADDRESS; +} + + +bool +Process::WritePointerToMemory (lldb::addr_t vm_addr, + lldb::addr_t ptr_value, + Error &error) +{ + Scalar scalar; + const uint32_t addr_byte_size = GetAddressByteSize(); + if (addr_byte_size <= 4) + scalar = (uint32_t)ptr_value; else - { - uint8_t tmp[sizeof(uint64_t)]; - DataExtractor data (tmp, - integer_byte_size, - m_target.GetArchitecture().GetByteOrder(), - m_target.GetArchitecture().GetAddressByteSize()); - if (ReadMemory (vm_addr, tmp, integer_byte_size, error) == integer_byte_size) - { - uint32_t offset = 0; - return data.GetMaxU64 (&offset, integer_byte_size); - } - } - // Any plug-in that doesn't return success a memory read with the number - // of bytes that were requested should be setting the error - assert (error.Fail()); - return 0; + scalar = ptr_value; + return WriteScalarToMemory(vm_addr, scalar, addr_byte_size, error) == addr_byte_size; } size_t @@ -1831,6 +1838,61 @@ return bytes_written; } + +size_t +Process::WriteScalarToMemory (addr_t addr, const Scalar &scalar, uint32_t byte_size, Error &error) +{ + if (byte_size == UINT32_MAX) + byte_size = scalar.GetByteSize(); + if (byte_size > 0) + { + uint8_t buf[32]; + const size_t mem_size = scalar.GetAsMemoryData (buf, byte_size, GetByteOrder(), error); + if (mem_size > 0) + return WriteMemory(addr, buf, mem_size, error); + else + error.SetErrorString ("failed to get scalar as memory data"); + } + else + { + error.SetErrorString ("invalid scalar value"); + } + return 0; +} + +size_t +Process::ReadScalarIntegerFromMemory (addr_t addr, + uint32_t byte_size, + bool is_signed, + Scalar &scalar, + Error &error) +{ + uint64_t uval; + + if (byte_size <= sizeof(uval)) + { + size_t bytes_read = ReadMemory (addr, &uval, byte_size, error); + if (bytes_read == byte_size) + { + DataExtractor data (&uval, sizeof(uval), GetByteOrder(), GetAddressByteSize()); + uint32_t offset = 0; + if (byte_size <= 4) + scalar = data.GetMaxU32 (&offset, byte_size); + else + scalar = data.GetMaxU64 (&offset, byte_size); + + if (is_signed) + scalar.SignExtend(byte_size * 8); + return bytes_read; + } + } + else + { + error.SetErrorStringWithFormat ("byte size of %u is too large for integer scalar type", byte_size); + } + return 0; +} + #define USE_ALLOCATE_MEMORY_CACHE 1 addr_t Process::AllocateMemory(size_t size, uint32_t permissions, Error &error) Modified: lldb/trunk/source/Target/Target.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/Target.cpp?rev=131878&r1=131877&r2=131878&view=diff ============================================================================== --- lldb/trunk/source/Target/Target.cpp (original) +++ lldb/trunk/source/Target/Target.cpp Sun May 22 17:46:53 2011 @@ -1014,6 +1014,81 @@ return execution_results; } +lldb::addr_t +Target::GetCallableLoadAddress (lldb::addr_t load_addr, AddressClass addr_class) const +{ + addr_t code_addr = load_addr; + switch (m_arch.GetMachine()) + { + case llvm::Triple::arm: + case llvm::Triple::thumb: + switch (addr_class) + { + case eAddressClassData: + case eAddressClassDebug: + return LLDB_INVALID_ADDRESS; + + case eAddressClassUnknown: + case eAddressClassInvalid: + case eAddressClassCode: + case eAddressClassCodeAlternateISA: + case eAddressClassRuntime: + // Check if bit zero it no set? + if ((code_addr & 1ull) == 0) + { + // Bit zero isn't set, check if the address is a multiple of 2? + if (code_addr & 2ull) + { + // The address is a multiple of 2 so it must be thumb, set bit zero + code_addr |= 1ull; + } + else if (addr_class == eAddressClassCodeAlternateISA) + { + // We checked the address and the address claims to be the alternate ISA + // which means thumb, so set bit zero. + code_addr |= 1ull; + } + } + break; + } + break; + + default: + break; + } + return code_addr; +} + +lldb::addr_t +Target::GetOpcodeLoadAddress (lldb::addr_t load_addr, AddressClass addr_class) const +{ + addr_t opcode_addr = load_addr; + switch (m_arch.GetMachine()) + { + case llvm::Triple::arm: + case llvm::Triple::thumb: + switch (addr_class) + { + case eAddressClassData: + case eAddressClassDebug: + return LLDB_INVALID_ADDRESS; + + case eAddressClassInvalid: + case eAddressClassUnknown: + case eAddressClassCode: + case eAddressClassCodeAlternateISA: + case eAddressClassRuntime: + opcode_addr &= ~(1ull); + break; + } + break; + + default: + break; + } + return opcode_addr; +} + lldb::user_id_t Target::AddStopHook (Target::StopHookSP &new_hook_sp) { Modified: lldb/trunk/source/Target/ThreadPlanRunToAddress.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/ThreadPlanRunToAddress.cpp?rev=131878&r1=131877&r2=131878&view=diff ============================================================================== --- lldb/trunk/source/Target/ThreadPlanRunToAddress.cpp (original) +++ lldb/trunk/source/Target/ThreadPlanRunToAddress.cpp Sun May 22 17:46:53 2011 @@ -39,7 +39,7 @@ m_addresses (), m_break_ids () { - m_addresses.push_back (address.GetLoadAddress(&m_thread.GetProcess().GetTarget())); + m_addresses.push_back (address.GetOpcodeLoadAddress (&m_thread.GetProcess().GetTarget())); SetInitialBreakpoints(); } @@ -54,14 +54,14 @@ m_addresses (), m_break_ids () { - m_addresses.push_back(address); + m_addresses.push_back(m_thread.GetProcess().GetTarget().GetOpcodeLoadAddress(address)); SetInitialBreakpoints(); } ThreadPlanRunToAddress::ThreadPlanRunToAddress ( Thread &thread, - std::vector &addresses, + const std::vector &addresses, bool stop_others ) : ThreadPlan (ThreadPlan::eKindRunToAddress, "Run to address plan", thread, eVoteNoOpinion, eVoteNoOpinion), @@ -69,6 +69,13 @@ m_addresses (addresses), m_break_ids () { + // Convert all addressses into opcode addresses to make sure we set + // breakpoints at the correct address. + Target &target = thread.GetProcess().GetTarget(); + std::vector::iterator pos, end = m_addresses.end(); + for (pos = m_addresses.begin(); pos != end; ++pos) + *pos = target.GetOpcodeLoadAddress (*pos); + SetInitialBreakpoints(); } Modified: lldb/trunk/tools/debugserver/source/MacOSX/MachThread.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/debugserver/source/MacOSX/MachThread.cpp?rev=131878&r1=131877&r2=131878&view=diff ============================================================================== --- lldb/trunk/tools/debugserver/source/MacOSX/MachThread.cpp (original) +++ lldb/trunk/tools/debugserver/source/MacOSX/MachThread.cpp Sun May 22 17:46:53 2011 @@ -698,70 +698,3 @@ return NULL; } - -// -//const char * -//MachThread::GetDispatchQueueName() -//{ -// if (GetIdentifierInfo ()) -// { -// if (m_ident_info.dispatch_qaddr == 0) -// return NULL; -// -// uint8_t memory_buffer[8]; -// DNBDataRef data(memory_buffer, sizeof(memory_buffer), false); -// ModuleSP module_sp(GetProcess()->GetTarget().GetImages().FindFirstModuleForFileSpec (FileSpec("libSystem.B.dylib"))); -// if (module_sp.get() == NULL) -// return NULL; -// -// lldb::addr_t dispatch_queue_offsets_addr = LLDB_INVALID_ADDRESS; -// const Symbol *dispatch_queue_offsets_symbol = module_sp->FindFirstSymbolWithNameAndType (ConstString("dispatch_queue_offsets"), eSymbolTypeData); -// if (dispatch_queue_offsets_symbol) -// dispatch_queue_offsets_addr = dispatch_queue_offsets_symbol->GetValue().GetLoadAddress(GetProcess()); -// -// if (dispatch_queue_offsets_addr == LLDB_INVALID_ADDRESS) -// return NULL; -// -// // Excerpt from src/queue_private.h -// struct dispatch_queue_offsets_s -// { -// uint16_t dqo_version; -// uint16_t dqo_label; -// uint16_t dqo_label_size; -// } dispatch_queue_offsets; -// -// -// if (GetProcess()->ReadMemory (dispatch_queue_offsets_addr, memory_buffer, sizeof(dispatch_queue_offsets)) == sizeof(dispatch_queue_offsets)) -// { -// uint32_t data_offset = 0; -// if (data.GetU16(&data_offset, &dispatch_queue_offsets.dqo_version, sizeof(dispatch_queue_offsets)/sizeof(uint16_t))) -// { -// if (GetProcess()->ReadMemory (m_ident_info.dispatch_qaddr, &memory_buffer, data.GetAddressByteSize()) == data.GetAddressByteSize()) -// { -// data_offset = 0; -// lldb::addr_t queue_addr = data.GetAddress(&data_offset); -// lldb::addr_t label_addr = queue_addr + dispatch_queue_offsets.dqo_label; -// const size_t chunk_size = 32; -// uint32_t label_pos = 0; -// m_dispatch_queue_name.resize(chunk_size, '\0'); -// while (1) -// { -// size_t bytes_read = GetProcess()->ReadMemory (label_addr + label_pos, &m_dispatch_queue_name[label_pos], chunk_size); -// -// if (bytes_read <= 0) -// break; -// -// if (m_dispatch_queue_name.find('\0', label_pos) != std::string::npos) -// break; -// label_pos += bytes_read; -// } -// m_dispatch_queue_name.erase(m_dispatch_queue_name.find('\0')); -// } -// } -// } -// } -// -// if (m_dispatch_queue_name.empty()) -// return NULL; -// return m_dispatch_queue_name.c_str(); -//}