From gclayton at apple.com Mon Nov 14 11:57:30 2011 From: gclayton at apple.com (Greg Clayton) Date: Mon, 14 Nov 2011 17:57:30 -0000 Subject: [Lldb-commits] [lldb] r144539 - /lldb/trunk/test/lang/cpp/stl/Makefile Message-ID: <20111114175731.008D32A6C131@llvm.org> Author: gclayton Date: Mon Nov 14 11:57:30 2011 New Revision: 144539 URL: http://llvm.org/viewvc/llvm-project?rev=144539&view=rev Log: Don't build optimized unless we are trying to test inlining. Modified: lldb/trunk/test/lang/cpp/stl/Makefile Modified: lldb/trunk/test/lang/cpp/stl/Makefile URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/lang/cpp/stl/Makefile?rev=144539&r1=144538&r2=144539&view=diff ============================================================================== --- lldb/trunk/test/lang/cpp/stl/Makefile (original) +++ lldb/trunk/test/lang/cpp/stl/Makefile Mon Nov 14 11:57:30 2011 @@ -1,6 +1,6 @@ LEVEL = ../../../make CXX_SOURCES := main.cpp -CFLAGS :=-arch x86_64 -gdwarf-2 -Os +CFLAGS :=-arch x86_64 -gdwarf-2 -O0 include $(LEVEL)/Makefile.rules From scallanan at apple.com Mon Nov 14 12:29:47 2011 From: scallanan at apple.com (Sean Callanan) Date: Mon, 14 Nov 2011 18:29:47 -0000 Subject: [Lldb-commits] [lldb] r144544 - /lldb/trunk/source/Expression/ClangASTSource.cpp Message-ID: <20111114182947.2922B2A6C131@llvm.org> Author: spyffe Date: Mon Nov 14 12:29:46 2011 New Revision: 144544 URL: http://llvm.org/viewvc/llvm-project?rev=144544&view=rev Log: Fixed Objective-C method lookup for methods with a single argument. We assumed that the : was omitted from the selector name, but actually Clang adds the : in the one-argument case. Modified: lldb/trunk/source/Expression/ClangASTSource.cpp Modified: lldb/trunk/source/Expression/ClangASTSource.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/ClangASTSource.cpp?rev=144544&r1=144543&r2=144544&view=diff ============================================================================== --- lldb/trunk/source/Expression/ClangASTSource.cpp (original) +++ lldb/trunk/source/Expression/ClangASTSource.cpp Mon Nov 14 12:29:46 2011 @@ -487,7 +487,7 @@ } else if (decl_name.isObjCOneArgSelector()) { - ss.Printf("%s:", decl_name.getAsString().c_str()); + ss.Printf("%s", decl_name.getAsString().c_str()); } else { From johnny.chen at apple.com Mon Nov 14 12:33:39 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Mon, 14 Nov 2011 18:33:39 -0000 Subject: [Lldb-commits] [lldb] r144545 - /lldb/trunk/test/lang/cpp/stl/TestSTL.py Message-ID: <20111114183339.8D8662A6C131@llvm.org> Author: johnny Date: Mon Nov 14 12:33:39 2011 New Revision: 144545 URL: http://llvm.org/viewvc/llvm-project?rev=144545&view=rev Log: Add more info on the failure. Modified: lldb/trunk/test/lang/cpp/stl/TestSTL.py Modified: lldb/trunk/test/lang/cpp/stl/TestSTL.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/lang/cpp/stl/TestSTL.py?rev=144545&r1=144544&r2=144545&view=diff ============================================================================== --- lldb/trunk/test/lang/cpp/stl/TestSTL.py (original) +++ lldb/trunk/test/lang/cpp/stl/TestSTL.py Mon Nov 14 12:33:39 2011 @@ -11,6 +11,7 @@ mydir = os.path.join("lang", "cpp", "stl") + # rdar://problem/10400981 @unittest2.expectedFailure @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin") def test_with_dsym(self): @@ -18,6 +19,7 @@ self.buildDsym() self.step_stl_exprs() + # rdar://problem/10400981 @unittest2.expectedFailure def test_with_dwarf(self): """Test some expressions involving STL data types.""" @@ -64,6 +66,7 @@ self.runCmd('expr for (int i = 0; i < hello_world.length(); ++i) { (void)printf("%c\\n", hello_world[i]); }') # rdar://problem/10373783 + # rdar://problem/10400981 self.expect('expr associative_array.size()', substrs = [' = 3']) self.expect('expr associative_array.count(hello_world)', From johnny.chen at apple.com Mon Nov 14 12:37:49 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Mon, 14 Nov 2011 18:37:49 -0000 Subject: [Lldb-commits] [lldb] r144546 - /lldb/trunk/test/make/Makefile.rules Message-ID: <20111114183749.9E58A2A6C131@llvm.org> Author: johnny Date: Mon Nov 14 12:37:49 2011 New Revision: 144546 URL: http://llvm.org/viewvc/llvm-project?rev=144546&view=rev Log: Dependency file for dylib source was not being cleaned up. Modified: lldb/trunk/test/make/Makefile.rules Modified: lldb/trunk/test/make/Makefile.rules URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/make/Makefile.rules?rev=144546&r1=144545&r2=144546&view=diff ============================================================================== --- lldb/trunk/test/make/Makefile.rules (original) +++ lldb/trunk/test/make/Makefile.rules Mon Nov 14 12:37:49 2011 @@ -203,7 +203,7 @@ ifeq "$(DYLIB_NAME)" "" rm -rf "$(EXE)" "$(DSYM)" $(OBJECTS) $(PREREQS) else - rm -rf "$(EXE)" "$(DSYM)" $(OBJECTS) $(PREREQS) $(DYLIB_OBJECTS) $(DYLIB_FILENAME) $(DYLIB_FILENAME).dSYM + rm -rf "$(EXE)" "$(DSYM)" $(OBJECTS) $(PREREQS) $(DYLIB_OBJECTS) $(DYLIB_PREREQS) $(DYLIB_FILENAME) $(DYLIB_FILENAME).dSYM endif #---------------------------------------------------------------------- From jingham at apple.com Mon Nov 14 14:02:01 2011 From: jingham at apple.com (Jim Ingham) Date: Mon, 14 Nov 2011 20:02:01 -0000 Subject: [Lldb-commits] [lldb] r144562 - in /lldb/trunk: lldb.xcodeproj/project.pbxproj source/Interpreter/CommandInterpreter.cpp Message-ID: <20111114200202.379602A6C131@llvm.org> Author: jingham Date: Mon Nov 14 14:02:01 2011 New Revision: 144562 URL: http://llvm.org/viewvc/llvm-project?rev=144562&view=rev Log: Confirm should accept both "Y" and "y" in case somebody confuses the "default answer" indicator for a directive to enter a capital letter. Modified: lldb/trunk/lldb.xcodeproj/project.pbxproj lldb/trunk/source/Interpreter/CommandInterpreter.cpp Modified: lldb/trunk/lldb.xcodeproj/project.pbxproj URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/lldb.xcodeproj/project.pbxproj?rev=144562&r1=144561&r2=144562&view=diff ============================================================================== --- lldb/trunk/lldb.xcodeproj/project.pbxproj (original) +++ lldb/trunk/lldb.xcodeproj/project.pbxproj Mon Nov 14 14:02:01 2011 @@ -3621,7 +3621,7 @@ GCC_WARN_UNUSED_VARIABLE = YES; LLVM_BUILD_DIR = "$(SRCROOT)/llvm-build/$(LLVM_CONFIGURATION)"; LLVM_BUILD_DIR_ARCH = "$(CURRENT_ARCH)/"; - LLVM_CONFIGURATION = Release; + LLVM_CONFIGURATION = "Debug+Asserts"; LLVM_SOURCE_DIR = "$(SRCROOT)/llvm"; ONLY_ACTIVE_ARCH = YES; OTHER_CFLAGS = ( Modified: lldb/trunk/source/Interpreter/CommandInterpreter.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Interpreter/CommandInterpreter.cpp?rev=144562&r1=144561&r2=144562&view=diff ============================================================================== --- lldb/trunk/source/Interpreter/CommandInterpreter.cpp (original) +++ lldb/trunk/source/Interpreter/CommandInterpreter.cpp Mon Nov 14 14:02:01 2011 @@ -1793,12 +1793,12 @@ { reader.SetIsDone(true); } - else if (bytes[0] == 'y') + else if (bytes[0] == 'y' || bytes[0] == 'Y') { *response_ptr = true; reader.SetIsDone(true); } - else if (bytes[0] == 'n') + else if (bytes[0] == 'n' || bytes[0] == 'N') { *response_ptr = false; reader.SetIsDone(true); @@ -1807,7 +1807,7 @@ { if (out_file.IsValid() && !reader.IsDone() && reader.GetPrompt()) { - out_file.Printf ("Please answer \"y\" or \"n\"\n%s", reader.GetPrompt()); + out_file.Printf ("Please answer \"y\" or \"Y\" or \"n\" or \"N\"\n%s", reader.GetPrompt()); out_file.Flush (); } } From clattner at apple.com Mon Nov 14 14:39:33 2011 From: clattner at apple.com (Chris Lattner) Date: Mon, 14 Nov 2011 12:39:33 -0800 Subject: [Lldb-commits] [lldb] r144562 - in /lldb/trunk: lldb.xcodeproj/project.pbxproj source/Interpreter/CommandInterpreter.cpp In-Reply-To: <20111114200202.379602A6C131@llvm.org> References: <20111114200202.379602A6C131@llvm.org> Message-ID: On Nov 14, 2011, at 12:02 PM, Jim Ingham wrote: > URL: http://llvm.org/viewvc/llvm-project?rev=144562&view=rev > Log: > Confirm should accept both "Y" and "y" in case somebody confuses the "default answer" indicator for a > directive to enter a capital letter. Thanks Jim, > +++ lldb/trunk/lldb.xcodeproj/project.pbxproj Mon Nov 14 14:02:01 2011 > @@ -3621,7 +3621,7 @@ > GCC_WARN_UNUSED_VARIABLE = YES; > LLVM_BUILD_DIR = "$(SRCROOT)/llvm-build/$(LLVM_CONFIGURATION)"; > LLVM_BUILD_DIR_ARCH = "$(CURRENT_ARCH)/"; > - LLVM_CONFIGURATION = Release; > + LLVM_CONFIGURATION = "Debug+Asserts"; Was this intentional? > @@ -1807,7 +1807,7 @@ > { > if (out_file.IsValid() && !reader.IsDone() && reader.GetPrompt()) > { > - out_file.Printf ("Please answer \"y\" or \"n\"\n%s", reader.GetPrompt()); > + out_file.Printf ("Please answer \"y\" or \"Y\" or \"n\" or \"N\"\n%s", reader.GetPrompt()); > out_file.Flush (); > } There is no need to be exhaustive here, just ask for y/n and accept both cases. -Chris From jingham at apple.com Mon Nov 14 14:47:07 2011 From: jingham at apple.com (Jim Ingham) Date: Mon, 14 Nov 2011 12:47:07 -0800 Subject: [Lldb-commits] [lldb] r144562 - in /lldb/trunk: lldb.xcodeproj/project.pbxproj source/Interpreter/CommandInterpreter.cpp In-Reply-To: References: <20111114200202.379602A6C131@llvm.org> Message-ID: On Nov 14, 2011, at 12:39 PM, Chris Lattner wrote: > On Nov 14, 2011, at 12:02 PM, Jim Ingham wrote: >> URL: http://llvm.org/viewvc/llvm-project?rev=144562&view=rev >> Log: >> Confirm should accept both "Y" and "y" in case somebody confuses the "default answer" indicator for a >> directive to enter a capital letter. > > Thanks Jim, > >> +++ lldb/trunk/lldb.xcodeproj/project.pbxproj Mon Nov 14 14:02:01 2011 >> @@ -3621,7 +3621,7 @@ >> GCC_WARN_UNUSED_VARIABLE = YES; >> LLVM_BUILD_DIR = "$(SRCROOT)/llvm-build/$(LLVM_CONFIGURATION)"; >> LLVM_BUILD_DIR_ARCH = "$(CURRENT_ARCH)/"; >> - LLVM_CONFIGURATION = Release; >> + LLVM_CONFIGURATION = "Debug+Asserts"; > > Was this intentional? The curse of a shared Scheme is you fight over incidental settings like this... I'm not sure why you would want to build a Debug version of lldb against the Release version of the LLVM libraries, so I think my setting is more useful. Whoever likes the Release version better will probably overwrite my setting the next time they commit ;-) Jim > >> @@ -1807,7 +1807,7 @@ >> { >> if (out_file.IsValid() && !reader.IsDone() && reader.GetPrompt()) >> { >> - out_file.Printf ("Please answer \"y\" or \"n\"\n%s", reader.GetPrompt()); >> + out_file.Printf ("Please answer \"y\" or \"Y\" or \"n\" or \"N\"\n%s", reader.GetPrompt()); >> out_file.Flush (); >> } > > There is no need to be exhaustive here, just ask for y/n and accept both cases. > > -Chris > From gclayton at apple.com Mon Nov 14 16:56:59 2011 From: gclayton at apple.com (Greg Clayton) Date: Mon, 14 Nov 2011 22:56:59 -0000 Subject: [Lldb-commits] [lldb] r144581 - /lldb/trunk/source/Core/DataExtractor.cpp Message-ID: <20111114225659.377D82A6C131@llvm.org> Author: gclayton Date: Mon Nov 14 16:56:58 2011 New Revision: 144581 URL: http://llvm.org/viewvc/llvm-project?rev=144581&view=rev Log: Speed improvements for ULEB128 reading from James McIlree. Modified: lldb/trunk/source/Core/DataExtractor.cpp Modified: lldb/trunk/source/Core/DataExtractor.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/DataExtractor.cpp?rev=144581&r1=144580&r2=144581&view=diff ============================================================================== --- lldb/trunk/source/Core/DataExtractor.cpp (original) +++ lldb/trunk/source/Core/DataExtractor.cpp Mon Nov 14 16:56:58 2011 @@ -1147,27 +1147,30 @@ uint64_t DataExtractor::GetULEB128 (uint32_t *offset_ptr) const { - uint64_t result = 0; - if ( m_start < m_end ) + const uint8_t *src = m_start + *offset_ptr; + const uint8_t *end = m_end; + + if (src < end) { - int shift = 0; - const uint8_t *src = m_start + *offset_ptr; - uint8_t byte; - int bytecount = 0; - - while (src < m_end) + uint64_t result = *src++; + if (result >= 0x80) { - bytecount++; - byte = *src++; - result |= (byte & 0x7f) << shift; - if ((byte & 0x80) == 0) - break; - shift += 7; + result &= 0x7f; + int shift = 7; + while (src < end) + { + uint8_t byte = *src++; + result |= (byte & 0x7f) << shift; + if ((byte & 0x80) == 0) + break; + shift += 7; + } } - - *offset_ptr += bytecount; + *offset_ptr = (uint32_t)(src - m_start); + return result; } - return result; + + return 0; } //---------------------------------------------------------------------- From johnny.chen at apple.com Mon Nov 14 17:04:06 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Mon, 14 Nov 2011 23:04:06 -0000 Subject: [Lldb-commits] [lldb] r144584 - /lldb/trunk/test/bench-history Message-ID: <20111114230406.4F8F32A6C131@llvm.org> Author: johnny Date: Mon Nov 14 17:04:06 2011 New Revision: 144584 URL: http://llvm.org/viewvc/llvm-project?rev=144584&view=rev Log: Add bench entries. Modified: lldb/trunk/test/bench-history Modified: lldb/trunk/test/bench-history URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/bench-history?rev=144584&r1=144583&r2=144584&view=diff ============================================================================== --- lldb/trunk/test/bench-history (original) +++ lldb/trunk/test/bench-history Mon Nov 14 17:04:06 2011 @@ -143,4 +143,25 @@ lldb frame variable benchmark: Avg: 1.610409 (Laps: 20, Total Elapsed Time: 32.208184, min=1.575063, max=1.724046) lldb stepping benchmark: Avg: 0.103874 (Laps: 50, Total Elapsed Time: 5.193698, min=0.101364, max=0.186751) lldb expr cmd benchmark: Avg: 0.207476 (Laps: 25, Total Elapsed Time: 5.186895, min=0.203365, max=0.240869) -lldb disassembly benchmark: Avg: 0.090917 (Laps: 10, Total Elapsed Time: 0.909167, min=0.089431, max=0.099787) \ No newline at end of file +lldb disassembly benchmark: Avg: 0.090917 (Laps: 10, Total Elapsed Time: 0.909167, min=0.089431, max=0.099787) + +r144546 +# Observed possible performance regression in lldb startup delay (run to breakpoint)? +# Need more investigation. +[11:27:23] johnny:/Volumes/data/lldb/svn/trunk/test $ ./bench.py -e /Volumes/data/lldb/svn/regression/build/Debug/lldb -x '-F Driver::MainLoop()' 2>&1 | grep -P '^lldb.*benchmark:' +lldb startup delay (create fresh target) benchmark: Avg: 0.112386 (Laps: 30, Total Elapsed Time: 3.371577, min=0.101772, max=0.393109) +lldb startup delay (set first breakpoint) benchmark: Avg: 0.108774 (Laps: 30, Total Elapsed Time: 3.263209, min=0.101605, max=0.292425) +lldb startup delay (run to breakpoint) benchmark: Avg: 0.529530 (Laps: 30, Total Elapsed Time: 15.885899, min=0.468891, max=1.747227) +lldb frame variable benchmark: Avg: 1.631610 (Laps: 20, Total Elapsed Time: 32.632193, min=1.575342, max=1.775941) +lldb stepping benchmark: Avg: 0.146749 (Laps: 50, Total Elapsed Time: 7.337451, min=0.100780, max=2.165057) +lldb expr cmd benchmark: Avg: 0.217782 (Laps: 25, Total Elapsed Time: 5.444553, min=0.203476, max=0.467801) +lldb disassembly benchmark: Avg: 0.091264 (Laps: 10, Total Elapsed Time: 0.912644, min=0.088928, max=0.101681) +[14:58:21] johnny:/Volumes/data/lldb/svn/trunk/test $ ./bench.py -e /Volumes/data/lldb/svn/regression/build/Debug/lldb -x '-F Driver::MainLoop()' 2>&1 | grep -P '^lldb.*benchmark:' +lldb startup delay (create fresh target) benchmark: Avg: 0.105535 (Laps: 30, Total Elapsed Time: 3.166062, min=0.101935, max=0.147107) +lldb startup delay (set first breakpoint) benchmark: Avg: 0.102372 (Laps: 30, Total Elapsed Time: 3.071164, min=0.100945, max=0.102721) +lldb startup delay (run to breakpoint) benchmark: Avg: 0.483826 (Laps: 30, Total Elapsed Time: 14.514786, min=0.471770, max=0.532260) +lldb frame variable benchmark: Avg: 1.576992 (Laps: 20, Total Elapsed Time: 31.539838, min=0.102487, max=2.098732) +lldb stepping benchmark: Avg: 0.102836 (Laps: 50, Total Elapsed Time: 5.141815, min=0.101461, max=0.122378) +lldb expr cmd benchmark: Avg: 0.206334 (Laps: 25, Total Elapsed Time: 5.158355, min=0.203804, max=0.241043) +lldb disassembly benchmark: Avg: 0.033536 (Laps: 10, Total Elapsed Time: 0.335359, min=0.031975, max=0.041612) +[15:01:59] johnny:/Volumes/data/lldb/svn/trunk/test $ \ No newline at end of file From clattner at apple.com Mon Nov 14 17:37:47 2011 From: clattner at apple.com (Chris Lattner) Date: Mon, 14 Nov 2011 15:37:47 -0800 Subject: [Lldb-commits] [lldb] r144562 - in /lldb/trunk: lldb.xcodeproj/project.pbxproj source/Interpreter/CommandInterpreter.cpp In-Reply-To: References: <20111114200202.379602A6C131@llvm.org> Message-ID: On Nov 14, 2011, at 12:47 PM, Jim Ingham wrote: > The curse of a shared Scheme is you fight over incidental settings like this... I'm not sure why you would want to build a Debug version of lldb against the Release version of the LLVM libraries, so I think my setting is more useful. Whoever likes the Release version better will probably overwrite my setting the next time they commit ;-) Ok, please fix this though: >>> @@ -1807,7 +1807,7 @@ >>> { >>> if (out_file.IsValid() && !reader.IsDone() && reader.GetPrompt()) >>> { >>> - out_file.Printf ("Please answer \"y\" or \"n\"\n%s", reader.GetPrompt()); >>> + out_file.Printf ("Please answer \"y\" or \"Y\" or \"n\" or \"N\"\n%s", reader.GetPrompt()); >>> out_file.Flush (); >>> } >> >> There is no need to be exhaustive here, just ask for y/n and accept both cases. >> >> -Chris >> > From gclayton at apple.com Mon Nov 14 21:53:30 2011 From: gclayton at apple.com (Greg Clayton) Date: Tue, 15 Nov 2011 03:53:30 -0000 Subject: [Lldb-commits] [lldb] r144615 - in /lldb/trunk: include/lldb/ include/lldb/Interpreter/ include/lldb/Target/ source/API/ source/Commands/ source/Host/macosx/ source/Interpreter/ source/Plugins/Platform/MacOSX/ source/Plugins/Platform/gdb-server/ source/Plugins/Process/gdb-remote/ source/Target/ Message-ID: <20111115035330.EF8B12A6C131@llvm.org> Author: gclayton Date: Mon Nov 14 21:53:30 2011 New Revision: 144615 URL: http://llvm.org/viewvc/llvm-project?rev=144615&view=rev Log: Added a new class to Process.h: ProcessAttachInfo. This class contains enough info for us to attach by pid, or by name and will also allow us to eventually do a lot more powerful attaches. If you look at the options for the "platform process list" command, there are many options which we should be able to specify. This will allow us to do things like "attach to a process named 'tcsh' that has a parent process ID of 123", or "attach to a process named 'x' which has an effective user ID of 345". I finished up the --shell implementation so that it can be used without the --tty option in "process launch". The "--shell" option now can take an optional argument which is the path to the shell to use (or a partial name like "sh" which we will find using the current PATH environment variable). Modified the Process::Attach to use the new ProcessAttachInfo as the sole argument and centralized a lot of code that was in the "process attach" Execute function so that everyone can take advantage of the powerful new attach functionality. Modified: lldb/trunk/include/lldb/Interpreter/Args.h lldb/trunk/include/lldb/Interpreter/CommandReturnObject.h lldb/trunk/include/lldb/Target/Platform.h lldb/trunk/include/lldb/Target/Process.h lldb/trunk/include/lldb/lldb-forward.h lldb/trunk/source/API/SBProcess.cpp lldb/trunk/source/API/SBTarget.cpp lldb/trunk/source/Commands/CommandObjectPlatform.cpp lldb/trunk/source/Commands/CommandObjectProcess.cpp lldb/trunk/source/Host/macosx/Host.mm lldb/trunk/source/Interpreter/Args.cpp lldb/trunk/source/Interpreter/CommandReturnObject.cpp lldb/trunk/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp lldb/trunk/source/Plugins/Platform/MacOSX/PlatformDarwin.h lldb/trunk/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.cpp lldb/trunk/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.h lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServer.cpp lldb/trunk/source/Target/Platform.cpp lldb/trunk/source/Target/Process.cpp Modified: lldb/trunk/include/lldb/Interpreter/Args.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Interpreter/Args.h?rev=144615&r1=144614&r2=144615&view=diff ============================================================================== --- lldb/trunk/include/lldb/Interpreter/Args.h (original) +++ lldb/trunk/include/lldb/Interpreter/Args.h Mon Nov 14 21:53:30 2011 @@ -401,6 +401,9 @@ static const char * StringToVersion (const char *s, uint32_t &major, uint32_t &minor, uint32_t &update); + static const char * + GetShellSafeArgument (const char *unsafe_arg, std::string &safe_arg); + // This one isn't really relevant to Arguments per se, but we're using the Args as a // general strings container, so... void Modified: lldb/trunk/include/lldb/Interpreter/CommandReturnObject.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Interpreter/CommandReturnObject.h?rev=144615&r1=144614&r2=144615&view=diff ============================================================================== --- lldb/trunk/include/lldb/Interpreter/CommandReturnObject.h (original) +++ lldb/trunk/include/lldb/Interpreter/CommandReturnObject.h Mon Nov 14 21:53:30 2011 @@ -141,6 +141,10 @@ void AppendErrorWithFormat (const char *format, ...) __attribute__ ((format (printf, 2, 3))); + void + SetError (const Error &error, + const char *fallback_error_cstr); + lldb::ReturnStatus GetStatus(); Modified: lldb/trunk/include/lldb/Target/Platform.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/Platform.h?rev=144615&r1=144614&r2=144615&view=diff ============================================================================== --- lldb/trunk/include/lldb/Target/Platform.h (original) +++ lldb/trunk/include/lldb/Target/Platform.h Mon Nov 14 21:53:30 2011 @@ -305,7 +305,7 @@ /// appriopriate error fill into the \a error object. //------------------------------------------------------------------ virtual lldb::ProcessSP - Attach (lldb::pid_t pid, + Attach (ProcessAttachInfo &attach_info, Debugger &debugger, Target *target, // Can be NULL, if NULL create a new target, else use existing one Listener &listener, Modified: lldb/trunk/include/lldb/Target/Process.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/Process.h?rev=144615&r1=144614&r2=144615&view=diff ============================================================================== --- lldb/trunk/include/lldb/Target/Process.h (original) +++ lldb/trunk/include/lldb/Target/Process.h Mon Nov 14 21:53:30 2011 @@ -148,12 +148,6 @@ return m_executable.GetFilename().GetLength(); } - void - SetName (const char *name) - { - m_executable.GetFilename().SetCString (name); - } - FileSpec & GetExecutableFile () { @@ -591,7 +585,7 @@ } void - FinalizeFileActions (Target *target, Process *process); + FinalizeFileActions (Target *target); size_t GetNumFileActions () const @@ -671,21 +665,158 @@ m_plugin_name.clear(); } + const char * + GetShell () const + { + if (m_shell.empty()) + return NULL; + return m_shell.c_str(); + } + + void + SetShell (const char * path) + { + if (path && path[0]) + { + m_shell.assign (path); + m_flags.Set (lldb::eLaunchFlagLaunchInShell); + } + else + { + m_shell.clear(); + m_flags.Clear (lldb::eLaunchFlagLaunchInShell); + } + } + + uint32_t + GetResumeCount () const + { + return m_resume_count; + } + + void + SetResumeCount (uint32_t c) + { + m_resume_count = c; + } + void Clear () { ProcessInfo::Clear(); m_working_dir.clear(); m_plugin_name.clear(); + m_shell.clear(); m_flags.Clear(); m_file_actions.clear(); + m_resume_count = 0; } + bool + ConvertArgumentsForLaunchingInShell (Error &error, bool localhost); + protected: std::string m_working_dir; std::string m_plugin_name; + std::string m_shell; Flags m_flags; // Bitwise OR of bits from lldb::LaunchFlags std::vector m_file_actions; // File actions for any other files + uint32_t m_resume_count; // How many times do we resume after launching +}; + +//---------------------------------------------------------------------- +// ProcessLaunchInfo +// +// Describes any information that is required to launch a process. +//---------------------------------------------------------------------- + +class ProcessAttachInfo : public ProcessInstanceInfo +{ +public: + ProcessAttachInfo() : + ProcessInstanceInfo(), + m_plugin_name (), + m_resume_count (0), + m_wait_for_launch (false) + { + } + + ProcessAttachInfo (const ProcessLaunchInfo &launch_info) : + ProcessInstanceInfo(), + m_plugin_name (), + m_resume_count (0), + m_wait_for_launch (false) + { + ProcessInfo::operator= (launch_info); + SetProcessPluginName (launch_info.GetProcessPluginName()); + SetResumeCount (launch_info.GetResumeCount()); + } + + bool + GetWaitForLaunch () const + { + return m_wait_for_launch; + } + + void + SetWaitForLaunch (bool b) + { + m_wait_for_launch = b; + } + + uint32_t + GetResumeCount () const + { + return m_resume_count; + } + + void + SetResumeCount (uint32_t c) + { + m_resume_count = c; + } + + const char * + GetProcessPluginName () const + { + if (m_plugin_name.empty()) + return NULL; + return m_plugin_name.c_str(); + } + + void + SetProcessPluginName (const char *plugin) + { + if (plugin && plugin[0]) + m_plugin_name.assign (plugin); + else + m_plugin_name.clear(); + } + + void + Clear () + { + ProcessInstanceInfo::Clear(); + m_plugin_name.clear(); + m_resume_count = 0; + m_wait_for_launch = false; + } + + bool + ProcessInfoSpecified () const + { + if (GetExecutableFile()) + return true; + if (GetProcessID() != LLDB_INVALID_PROCESS_ID) + return true; + if (GetParentProcessID() != LLDB_INVALID_PROCESS_ID) + return true; + return false; + } +protected: + std::string m_plugin_name; + uint32_t m_resume_count; // How many times do we resume after launching + bool m_wait_for_launch; }; class ProcessLaunchCommandOptions : public Options @@ -744,12 +875,12 @@ } ProcessInstanceInfoMatch (const char *process_name, - lldb_private::NameMatchType process_name_match_type) : + lldb_private::NameMatchType process_name_match_type) : m_match_info (), m_name_match_type (process_name_match_type), m_match_all_users (false) { - m_match_info.SetName (process_name); + m_match_info.GetExecutableFile().SetFile(process_name, false); } ProcessInstanceInfo & @@ -1316,11 +1447,12 @@ Launch (const ProcessLaunchInfo &launch_info); //------------------------------------------------------------------ - /// Attach to an existing process using a process ID. + /// Attach to an existing process using the process attach info. /// /// This function is not meant to be overridden by Process - /// subclasses. It will first call Process::WillAttach (lldb::pid_t) - /// and if that returns \b true, Process::DoAttach (lldb::pid_t) will + /// subclasses. It will first call WillAttach (lldb::pid_t) + /// or WillAttach (const char *), and if that returns \b + /// true, DoAttach (lldb::pid_t) or DoAttach (const char *) will /// be called to actually do the attach. If DoAttach returns \b /// true, then Process::DidAttach() will be called. /// @@ -1332,28 +1464,8 @@ /// LLDB_INVALID_PROCESS_ID if attaching fails. //------------------------------------------------------------------ virtual Error - Attach (lldb::pid_t pid, uint32_t exec_count); + Attach (ProcessAttachInfo &attach_info); - //------------------------------------------------------------------ - /// Attach to an existing process by process name. - /// - /// This function is not meant to be overridden by Process - /// subclasses. It will first call - /// Process::WillAttach (const char *) and if that returns \b - /// true, Process::DoAttach (const char *) will be called to - /// actually do the attach. If DoAttach returns \b true, then - /// Process::DidAttach() will be called. - /// - /// @param[in] process_name - /// A process name to match against the current process list. - /// - /// @return - /// Returns \a pid if attaching was successful, or - /// LLDB_INVALID_PROCESS_ID if attaching fails. - //------------------------------------------------------------------ - virtual Error - Attach (const char *process_name, bool wait_for_launch); - virtual Error ConnectRemote (const char *remote_url); Modified: lldb/trunk/include/lldb/lldb-forward.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/lldb-forward.h?rev=144615&r1=144614&r2=144615&view=diff ============================================================================== --- lldb/trunk/include/lldb/lldb-forward.h (original) +++ lldb/trunk/include/lldb/lldb-forward.h Mon Nov 14 21:53:30 2011 @@ -112,6 +112,7 @@ class PathMappingList; class Platform; class Process; +class ProcessAttachInfo; class ProcessModID; class ProcessInfo; class ProcessInstanceInfo; @@ -128,7 +129,7 @@ #ifndef LLDB_DISABLE_PYTHON class ScriptInterpreterPython; struct ScriptSummaryFormat; -#endif // #ifndef LLDB_DISABLE_PYTHON +#endif class SearchFilter; class Section; class SectionImpl; @@ -161,7 +162,7 @@ class SyntheticChildrenFrontEnd; #ifndef LLDB_DISABLE_PYTHON class SyntheticScriptProvider; -#endif // #ifndef LLDB_DISABLE_PYTHON +#endif class Target; class TargetList; class Thread; Modified: lldb/trunk/source/API/SBProcess.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBProcess.cpp?rev=144615&r1=144614&r2=144615&view=diff ============================================================================== --- lldb/trunk/source/API/SBProcess.cpp (original) +++ lldb/trunk/source/API/SBProcess.cpp Mon Nov 14 21:53:30 2011 @@ -169,7 +169,9 @@ Mutex::Locker api_locker (m_opaque_sp->GetTarget().GetAPIMutex()); if (m_opaque_sp->GetState() == eStateConnected) { - error.SetError (m_opaque_sp->Attach (pid, 0)); + ProcessAttachInfo attach_info; + attach_info.SetProcessID (pid); + error.SetError (m_opaque_sp->Attach (attach_info)); } else { Modified: lldb/trunk/source/API/SBTarget.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBTarget.cpp?rev=144615&r1=144614&r2=144615&view=diff ============================================================================== --- lldb/trunk/source/API/SBTarget.cpp (original) +++ lldb/trunk/source/API/SBTarget.cpp Mon Nov 14 21:53:30 2011 @@ -337,7 +337,9 @@ if (sb_process.IsValid()) { - error.SetError (sb_process->Attach (pid, 0)); + ProcessAttachInfo attach_info; + attach_info.SetProcessID (pid); + error.SetError (sb_process->Attach (attach_info)); // If we are doing synchronous mode, then wait for the // process to stop! if (m_opaque_sp->GetDebugger().GetAsyncExecution () == false) @@ -409,7 +411,10 @@ if (sb_process.IsValid()) { - error.SetError (sb_process->Attach (name, wait_for)); + ProcessAttachInfo attach_info; + attach_info.GetExecutableFile().SetFile(name, false); + attach_info.SetWaitForLaunch(wait_for); + error.SetError (sb_process->Attach (attach_info)); // If we are doing synchronous mode, then wait for the // process to stop! if (m_opaque_sp->GetDebugger().GetAsyncExecution () == false) Modified: lldb/trunk/source/Commands/CommandObjectPlatform.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectPlatform.cpp?rev=144615&r1=144614&r2=144615&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectPlatform.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectPlatform.cpp Mon Nov 14 21:53:30 2011 @@ -653,27 +653,27 @@ break; case 'n': - match_info.GetProcessInfo().SetName (option_arg); + match_info.GetProcessInfo().GetExecutableFile().SetFile (option_arg, false); match_info.SetNameMatchType (eNameMatchEquals); break; case 'e': - match_info.GetProcessInfo().SetName (option_arg); + match_info.GetProcessInfo().GetExecutableFile().SetFile (option_arg, false); match_info.SetNameMatchType (eNameMatchEndsWith); break; case 's': - match_info.GetProcessInfo().SetName (option_arg); + match_info.GetProcessInfo().GetExecutableFile().SetFile (option_arg, false); match_info.SetNameMatchType (eNameMatchStartsWith); break; case 'c': - match_info.GetProcessInfo().SetName (option_arg); + match_info.GetProcessInfo().GetExecutableFile().SetFile (option_arg, false); match_info.SetNameMatchType (eNameMatchContains); break; case 'r': - match_info.GetProcessInfo().SetName (option_arg); + match_info.GetProcessInfo().GetExecutableFile().SetFile (option_arg, false); match_info.SetNameMatchType (eNameMatchRegularExpression); break; Modified: lldb/trunk/source/Commands/CommandObjectProcess.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectProcess.cpp?rev=144615&r1=144614&r2=144615&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectProcess.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectProcess.cpp Mon Nov 14 21:53:30 2011 @@ -212,12 +212,32 @@ } } - if (launch_args.GetArgumentCount() > 0) + if (launch_args.GetArgumentCount() == 0) + { + const Args &process_args = target->GetRunArguments(); + if (process_args.GetArgumentCount() > 0) + m_options.launch_info.GetArguments().AppendArguments (process_args); + } + else { m_options.launch_info.GetArguments().AppendArguments (launch_args); } - + if (target->GetDisableASLR()) + m_options.launch_info.GetFlags().Set (eLaunchFlagDisableASLR); + + if (target->GetDisableSTDIO()) + m_options.launch_info.GetFlags().Set (eLaunchFlagDisableSTDIO); + + m_options.launch_info.GetFlags().Set (eLaunchFlagDebug); + + Args environment; + target->GetEnvironmentAsArgs (environment); + if (environment.GetArgumentCount() > 0) + m_options.launch_info.GetEnvironmentEntries ().AppendArguments (environment); + + m_options.launch_info.FinalizeFileActions (target); + if (state == eStateConnected) { if (m_options.launch_info.GetFlags().Test (eLaunchFlagLaunchInTTY)) @@ -228,78 +248,18 @@ } else { - const char *plugin_name = m_options.launch_info.GetProcessPluginName(); - - if (m_options.launch_info.GetFlags().Test (eLaunchFlagLaunchInTTY)) - { + if (!m_options.launch_info.GetArchitecture().IsValid()) m_options.launch_info.GetArchitecture() = target->GetArchitecture(); - process = target->GetPlatform()->DebugProcess (m_options.launch_info, - debugger, - target, - debugger.GetListener(), - error).get(); - } - else - { - process = target->CreateProcess (debugger.GetListener(), plugin_name).get(); - - if (launch_args.GetArgumentCount() == 0) - { - const Args &process_args = target->GetRunArguments(); - if (process_args.GetArgumentCount() > 0) - m_options.launch_info.GetArguments().AppendArguments (process_args); - } - - Args environment; - target->GetEnvironmentAsArgs (environment); - m_options.launch_info.GetEnvironmentEntries ().AppendArguments (environment); - - if (target->GetDisableASLR()) - m_options.launch_info.GetFlags().Set (eLaunchFlagDisableASLR); - - if (m_options.launch_info.GetNumFileActions() == 0) - { - // Only use the settings value if the user hasn't specified any options that would override it. - if (target->GetDisableSTDIO()) - m_options.launch_info.GetFlags().Set (eLaunchFlagDisableSTDIO); - - const char *path; - path = target->GetStandardErrorPath(); - if (path) - { - ProcessLaunchInfo::FileAction file_action; - const bool read = true; - const bool write = true; - if (file_action.Open(STDERR_FILENO, path, read, write)) - m_options.launch_info.AppendFileAction (file_action); - } - path = target->GetStandardInputPath(); - if (path) - { - ProcessLaunchInfo::FileAction file_action; - const bool read = true; - const bool write = false; - if (file_action.Open(STDIN_FILENO, path, read, write)) - m_options.launch_info.AppendFileAction (file_action); - } + process = target->GetPlatform()->DebugProcess (m_options.launch_info, + debugger, + target, + debugger.GetListener(), + error).get(); - path = target->GetStandardOutputPath(); - if (path) - { - ProcessLaunchInfo::FileAction file_action; - const bool read = false; - const bool write = true; - if (file_action.Open(STDOUT_FILENO, path, read, write)) - m_options.launch_info.AppendFileAction (file_action); - } - } - error = process->Launch (m_options.launch_info); - } if (process == NULL) { - result.AppendErrorWithFormat ("Failed to find a process plugin for executable.\n"); - result.SetStatus (eReturnStatusFailed); + result.SetError (error, "failed to launch or debug process"); return false; } } @@ -326,7 +286,7 @@ state = process->WaitForProcessToStop (NULL); if (!StateIsStoppedState(state)) { - result.AppendErrorWithFormat ("Process isn't stopped: %s", StateAsCString(state)); + result.AppendErrorWithFormat ("process isn't stopped: %s", StateAsCString(state)); } result.SetDidChangeProcessState (true); result.SetStatus (eReturnStatusSuccessFinishResult); @@ -338,13 +298,13 @@ } else { - result.AppendErrorWithFormat ("Process resume at entry point failed: %s", error.AsCString()); + result.AppendErrorWithFormat ("process resume at entry point failed: %s", error.AsCString()); result.SetStatus (eReturnStatusFailed); } } else { - result.AppendErrorWithFormat ("Initial process state wasn't stopped: %s", StateAsCString(state)); + result.AppendErrorWithFormat ("initial process state wasn't stopped: %s", StateAsCString(state)); result.SetStatus (eReturnStatusFailed); } } @@ -423,23 +383,29 @@ switch (short_option) { case 'p': - pid = Args::StringToUInt32 (option_arg, LLDB_INVALID_PROCESS_ID, 0, &success); - if (!success || pid == LLDB_INVALID_PROCESS_ID) { - error.SetErrorStringWithFormat("invalid process ID '%s'", option_arg); + lldb::pid_t pid = Args::StringToUInt32 (option_arg, LLDB_INVALID_PROCESS_ID, 0, &success); + if (!success || pid == LLDB_INVALID_PROCESS_ID) + { + error.SetErrorStringWithFormat("invalid process ID '%s'", option_arg); + } + else + { + attach_info.SetProcessID (pid); + } } break; case 'P': - plugin_name = option_arg; + attach_info.SetProcessPluginName (option_arg); break; case 'n': - name.assign(option_arg); + attach_info.GetExecutableFile().SetFile(option_arg, false); break; case 'w': - waitfor = true; + attach_info.SetWaitForLaunch(true); break; default: @@ -452,9 +418,7 @@ void OptionParsingStarting () { - pid = LLDB_INVALID_PROCESS_ID; - name.clear(); - waitfor = false; + attach_info.Clear(); } const OptionDefinition* @@ -497,7 +461,7 @@ ProcessInstanceInfoMatch match_info; if (partial_name) { - match_info.GetProcessInfo().SetName(partial_name); + match_info.GetProcessInfo().GetExecutableFile().SetFile(partial_name, false); match_info.SetNameMatchType(eNameMatchStartsWith); } platform_sp->FindProcesses (match_info, process_infos); @@ -522,10 +486,7 @@ // Instance variables to hold the values for command options. - lldb::pid_t pid; - std::string plugin_name; - std::string name; - bool waitfor; + ProcessAttachInfo attach_info; }; CommandObjectProcessAttach (CommandInterpreter &interpreter) : @@ -601,55 +562,37 @@ { if (state != eStateConnected) { - const char *plugin_name = NULL; - - if (!m_options.plugin_name.empty()) - plugin_name = m_options.plugin_name.c_str(); - + const char *plugin_name = m_options.attach_info.GetProcessPluginName(); process = target->CreateProcess (m_interpreter.GetDebugger().GetListener(), plugin_name).get(); } if (process) { Error error; - int attach_pid = m_options.pid; - - const char *wait_name = NULL; - - if (m_options.name.empty()) + // If no process info was specified, then use the target executable + // name as the process to attach to by default + if (!m_options.attach_info.ProcessInfoSpecified ()) { if (old_exec_module_sp) + m_options.attach_info.GetExecutableFile().GetFilename() = old_exec_module_sp->GetFileSpec().GetFilename(); + + if (!m_options.attach_info.ProcessInfoSpecified ()) { - wait_name = old_exec_module_sp->GetFileSpec().GetFilename().AsCString(); + error.SetErrorString ("no process specified, create a target with a file, or specify the --pid or --name command option"); } } - else - { - wait_name = m_options.name.c_str(); - } - - // If we are waiting for a process with this name to show up, do that first. - if (m_options.waitfor) - { - - if (wait_name == NULL) - { - result.AppendError("Invalid arguments: must have a file loaded or supply a process name with the waitfor option.\n"); - result.SetStatus (eReturnStatusFailed); - return false; - } - result.AppendMessageWithFormat("Waiting to attach to a process named \"%s\".\n", wait_name); - error = process->Attach (wait_name, m_options.waitfor); + if (error.Success()) + { + error = process->Attach (m_options.attach_info); + if (error.Success()) { result.SetStatus (eReturnStatusSuccessContinuingNoResult); } else { - result.AppendErrorWithFormat ("Waiting for a process to launch named '%s': %s\n", - wait_name, - error.AsCString()); + result.AppendErrorWithFormat ("attach failed: %s\n", error.AsCString()); result.SetStatus (eReturnStatusFailed); return false; } @@ -658,70 +601,11 @@ // FIXME: in the async case it will now be possible to get to the command // interpreter with a state eStateAttaching. Make sure we handle that correctly. StateType state = process->WaitForProcessToStop (NULL); - + result.SetDidChangeProcessState (true); result.AppendMessageWithFormat ("Process %llu %s\n", process->GetID(), StateAsCString (state)); result.SetStatus (eReturnStatusSuccessFinishNoResult); } - else - { - // If the process was specified by name look it up, so we can warn if there are multiple - // processes with this pid. - - if (attach_pid == LLDB_INVALID_PROCESS_ID && wait_name != NULL) - { - ProcessInstanceInfoList process_infos; - PlatformSP platform_sp (m_interpreter.GetPlatform (true)); - if (platform_sp) - { - ProcessInstanceInfoMatch match_info (wait_name, eNameMatchEquals); - platform_sp->FindProcesses (match_info, process_infos); - } - if (process_infos.GetSize() > 1) - { - result.AppendErrorWithFormat("More than one process named %s\n", wait_name); - result.SetStatus (eReturnStatusFailed); - return false; - } - else if (process_infos.GetSize() == 0) - { - result.AppendErrorWithFormat("Could not find a process named %s\n", wait_name); - result.SetStatus (eReturnStatusFailed); - return false; - } - else - { - attach_pid = process_infos.GetProcessIDAtIndex (0); - } - } - - if (attach_pid != LLDB_INVALID_PROCESS_ID) - { - error = process->Attach (attach_pid, 0); - if (error.Success()) - { - result.SetStatus (eReturnStatusSuccessContinuingNoResult); - } - else - { - result.AppendErrorWithFormat ("Attaching to process %i failed: %s.\n", - attach_pid, - error.AsCString()); - result.SetStatus (eReturnStatusFailed); - } - StateType state = process->WaitForProcessToStop (NULL); - - result.SetDidChangeProcessState (true); - result.AppendMessageWithFormat ("Process %llu %s\n", process->GetID(), StateAsCString (state)); - result.SetStatus (eReturnStatusSuccessFinishNoResult); - } - else - { - result.AppendErrorWithFormat ("No PID specified for attach\n"); - result.SetStatus (eReturnStatusFailed); - - } - } } } Modified: lldb/trunk/source/Host/macosx/Host.mm URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/macosx/Host.mm?rev=144615&r1=144614&r2=144615&view=diff ============================================================================== --- lldb/trunk/source/Host/macosx/Host.mm (original) +++ lldb/trunk/source/Host/macosx/Host.mm Mon Nov 14 21:53:30 2011 @@ -59,6 +59,12 @@ #define _POSIX_SPAWN_DISABLE_ASLR 0x0100 #endif +extern "C" +{ + int __pthread_chdir(const char *path); + int __pthread_fchdir (int fildes); +} + using namespace lldb; using namespace lldb_private; @@ -431,25 +437,6 @@ do script the_shell_script\n\ end tell\n"; -static const char * -GetShellSafeArgument (const char *unsafe_arg, std::string &safe_arg) -{ - safe_arg.assign (unsafe_arg); - size_t prev_pos = 0; - while (prev_pos < safe_arg.size()) - { - // Escape spaces and quotes - size_t pos = safe_arg.find_first_of(" '\"", prev_pos); - if (pos != std::string::npos) - { - safe_arg.insert (pos, 1, '\\'); - prev_pos = pos + 2; - } - else - break; - } - return safe_arg.c_str(); -} static Error LaunchInNewTerminalWithAppleScript (const char *exe_path, ProcessLaunchInfo &launch_info) @@ -499,44 +486,22 @@ if (launch_info.GetFlags().Test (eLaunchFlagDisableASLR)) command.PutCString(" --disable-aslr"); - if (launch_info.GetFlags().Test (eLaunchFlagLaunchInShell)) + command.PutCString(" -- "); + + const char **argv = launch_info.GetArguments().GetConstArgumentVector (); + if (argv) { - const char *shell_executable = "/bin/bash"; //getenv("SHELL"); - std::string safe_arg; - if (launch_info.GetArchitecture().IsValid()) - command.Printf(" -- %s -c 'exec /usr/bin/arch -arch %s", shell_executable, launch_info.GetArchitecture().GetArchitectureName()); - else - command.Printf(" -- %s -c 'exec ", shell_executable); - const char **argv = launch_info.GetArguments().GetConstArgumentVector (); - if (argv) + for (size_t i=0; argv[i] != NULL; ++i) { - for (size_t i=0; argv[i] != NULL; ++i) - { - const char *arg = GetShellSafeArgument (i == 0 ? exe_path : argv[i], safe_arg); - command.Printf(" %s", arg); - } + if (i==0) + command.Printf(" '%s'", exe_path); + else + command.Printf(" '%s'", argv[i]); } - command.PutChar('\''); } else { - command.PutCString(" -- "); - - const char **argv = launch_info.GetArguments().GetConstArgumentVector (); - if (argv) - { - for (size_t i=0; argv[i] != NULL; ++i) - { - if (i==0) - command.Printf(" '%s'", exe_path); - else - command.Printf(" '%s'", argv[i]); - } - } - else - { - command.Printf(" '%s'", exe_path); - } + command.Printf(" '%s'", exe_path); } command.PutCString (" ; echo Process exited with status $?"); @@ -1007,11 +972,11 @@ match_info_ptr->GetNameMatchType(), match_info_ptr->GetProcessInfo().GetName())) { - process_info.SetName (process_name); + process_info.GetExecutableFile().SetFile (process_name, false); return true; } } - process_info.SetName (NULL); + process_info.GetExecutableFile().Clear(); return false; } @@ -1306,6 +1271,11 @@ if (launch_info.GetFlags().Test (eLaunchFlagDisableASLR)) flags |= _POSIX_SPAWN_DISABLE_ASLR; // Darwin specific posix_spawn flag +//#ifdef POSIX_SPAWN_CLOEXEC_DEFAULT +// // Close all files exception those with file actions if this is supported. +// flags |= POSIX_SPAWN_CLOEXEC_DEFAULT; +//#endif + error.SetError( ::posix_spawnattr_setflags (&attr, flags), eErrorTypePOSIX); if (error.Fail() || log) error.PutToLog(log.get(), "::posix_spawnattr_setflags ( &attr, flags=0x%8.8x )", flags); @@ -1347,6 +1317,13 @@ } + const char *working_dir = launch_info.GetWorkingDirectory(); + if (working_dir) + { + // No more thread specific current working directory + __pthread_chdir (working_dir); + } + const size_t num_file_actions = launch_info.GetNumFileActions (); if (num_file_actions > 0) { @@ -1410,6 +1387,12 @@ envp); } + if (working_dir) + { + // No more thread specific current working directory + __pthread_fchdir (-1); + } + if (pid != LLDB_INVALID_PROCESS_ID) { // If all went well, then set the process ID into the launch info Modified: lldb/trunk/source/Interpreter/Args.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Interpreter/Args.cpp?rev=144615&r1=144614&r2=144615&view=diff ============================================================================== --- lldb/trunk/source/Interpreter/Args.cpp (original) +++ lldb/trunk/source/Interpreter/Args.cpp Mon Nov 14 21:53:30 2011 @@ -864,6 +864,26 @@ return 0; } +const char * +Args::GetShellSafeArgument (const char *unsafe_arg, std::string &safe_arg) +{ + safe_arg.assign (unsafe_arg); + size_t prev_pos = 0; + while (prev_pos < safe_arg.size()) + { + // Escape spaces and quotes + size_t pos = safe_arg.find_first_of(" '\"", prev_pos); + if (pos != std::string::npos) + { + safe_arg.insert (pos, 1, '\\'); + prev_pos = pos + 2; + } + else + break; + } + return safe_arg.c_str(); +} + int32_t Args::StringToOptionEnum (const char *s, OptionEnumValueElement *enum_values, int32_t fail_value, Error &error) Modified: lldb/trunk/source/Interpreter/CommandReturnObject.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Interpreter/CommandReturnObject.cpp?rev=144615&r1=144614&r2=144615&view=diff ============================================================================== --- lldb/trunk/source/Interpreter/CommandReturnObject.cpp (original) +++ lldb/trunk/source/Interpreter/CommandReturnObject.cpp Mon Nov 14 21:53:30 2011 @@ -13,6 +13,7 @@ // C++ Includes // Other libraries and framework includes // Project includes +#include "lldb/Core/Error.h" #include "lldb/Core/StreamString.h" using namespace lldb; @@ -134,6 +135,15 @@ GetErrorStream().Printf ("error: %*.*s\n", len, len, in_string); } +void +CommandReturnObject::SetError (const Error &error, const char *fallback_error_cstr) +{ + const char *error_cstr = error.AsCString(); + if (error_cstr == NULL) + error_cstr = fallback_error_cstr; + AppendError (error_cstr); + SetStatus (eReturnStatusFailed); +} // Similar to AppendError, but do not prepend 'Error: ' to message, and // don't append "\n" to the end of it. Modified: lldb/trunk/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp?rev=144615&r1=144614&r2=144615&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp (original) +++ lldb/trunk/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp Mon Nov 14 21:53:30 2011 @@ -395,8 +395,15 @@ PlatformDarwin::LaunchProcess (ProcessLaunchInfo &launch_info) { Error error; + if (IsHost()) { + if (launch_info.GetFlags().Test (eLaunchFlagLaunchInShell)) + { + const bool is_localhost = true; + if (!launch_info.ConvertArgumentsForLaunchingInShell (error, is_localhost)) + return error; + } error = Platform::LaunchProcess (launch_info); } else @@ -410,13 +417,14 @@ } lldb::ProcessSP -PlatformDarwin::Attach (lldb::pid_t pid, +PlatformDarwin::Attach (ProcessAttachInfo &attach_info, Debugger &debugger, Target *target, Listener &listener, Error &error) { lldb::ProcessSP process_sp; + if (IsHost()) { if (target == NULL) @@ -438,18 +446,17 @@ if (target && error.Success()) { debugger.GetTargetList().SetSelectedTarget(target); - // The darwin always currently uses the GDB remote debugger plug-in - // so even when debugging locally we are debugging remotely! - process_sp = target->CreateProcess (listener, "gdb-remote"); + + process_sp = target->CreateProcess (listener, attach_info.GetProcessPluginName()); if (process_sp) - error = process_sp->Attach (pid, 2); + error = process_sp->Attach (attach_info); } } else { if (m_remote_platform_sp) - process_sp = m_remote_platform_sp->Attach (pid, debugger, target, listener, error); + process_sp = m_remote_platform_sp->Attach (attach_info, debugger, target, listener, error); else error.SetErrorString ("the platform is not currently connected"); } Modified: lldb/trunk/source/Plugins/Platform/MacOSX/PlatformDarwin.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Platform/MacOSX/PlatformDarwin.h?rev=144615&r1=144614&r2=144615&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Platform/MacOSX/PlatformDarwin.h (original) +++ lldb/trunk/source/Plugins/Platform/MacOSX/PlatformDarwin.h Mon Nov 14 21:53:30 2011 @@ -79,7 +79,7 @@ LaunchProcess (lldb_private::ProcessLaunchInfo &launch_info); virtual lldb::ProcessSP - Attach (lldb::pid_t pid, + Attach (lldb_private::ProcessAttachInfo &attach_info, lldb_private::Debugger &debugger, lldb_private::Target *target, // Can be NULL, if NULL create a new target, else use existing one lldb_private::Listener &listener, Modified: lldb/trunk/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.cpp?rev=144615&r1=144614&r2=144615&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.cpp (original) +++ lldb/trunk/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.cpp Mon Nov 14 21:53:30 2011 @@ -337,7 +337,7 @@ } lldb::ProcessSP -PlatformRemoteGDBServer::Attach (lldb::pid_t pid, +PlatformRemoteGDBServer::Attach (lldb_private::ProcessAttachInfo &attach_info, Debugger &debugger, Target *target, // Can be NULL, if NULL create a new target, else use existing one Listener &listener, @@ -391,7 +391,7 @@ assert (connect_url_len < sizeof(connect_url)); error = process_sp->ConnectRemote (connect_url); if (error.Success()) - error = process_sp->Attach(pid, 0); + error = process_sp->Attach(attach_info); } } } Modified: lldb/trunk/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.h?rev=144615&r1=144614&r2=144615&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.h (original) +++ lldb/trunk/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.h Mon Nov 14 21:53:30 2011 @@ -94,7 +94,7 @@ LaunchProcess (lldb_private::ProcessLaunchInfo &launch_info); virtual lldb::ProcessSP - Attach (lldb::pid_t pid, + Attach (lldb_private::ProcessAttachInfo &attach_info, lldb_private::Debugger &debugger, lldb_private::Target *target, // Can be NULL, if NULL create a new target, else use existing one lldb_private::Listener &listener, 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=144615&r1=144614&r2=144615&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp (original) +++ lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp Mon Nov 14 21:53:30 2011 @@ -1243,7 +1243,7 @@ extractor.GetStringRef().swap(value); extractor.SetFilePos(0); extractor.GetHexByteString (value); - process_info.SetName (value.c_str()); + process_info.GetExecutableFile().SetFile (value.c_str(), false); } } Modified: lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServer.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServer.cpp?rev=144615&r1=144614&r2=144615&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServer.cpp (original) +++ lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServer.cpp Mon Nov 14 21:53:30 2011 @@ -335,7 +335,7 @@ StringExtractor extractor; extractor.GetStringRef().swap(value); extractor.GetHexByteString (value); - match_info.GetProcessInfo().SetName (value.c_str()); + match_info.GetProcessInfo().GetExecutableFile().SetFile(value.c_str(), false); } else if (key.compare("name_match") == 0) { Modified: lldb/trunk/source/Target/Platform.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/Platform.cpp?rev=144615&r1=144614&r2=144615&view=diff ============================================================================== --- lldb/trunk/source/Target/Platform.cpp (original) +++ lldb/trunk/source/Target/Platform.cpp Mon Nov 14 21:53:30 2011 @@ -577,16 +577,10 @@ error = LaunchProcess (launch_info); if (error.Success()) { - lldb::pid_t pid = launch_info.GetProcessID(); - if (pid != LLDB_INVALID_PROCESS_ID) + if (launch_info.GetProcessID() != LLDB_INVALID_PROCESS_ID) { - process_sp = Attach (pid, debugger, target, listener, error); - -// if (process_sp) -// { -// if (launch_info.GetFlags().IsClear (eLaunchFlagStopAtEntry)) -// process_sp->Resume(); -// } + ProcessAttachInfo attach_info (launch_info); + process_sp = Attach (attach_info, debugger, target, listener, error); } } return process_sp; Modified: lldb/trunk/source/Target/Process.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/Process.cpp?rev=144615&r1=144614&r2=144615&view=diff ============================================================================== --- lldb/trunk/source/Target/Process.cpp (original) +++ lldb/trunk/source/Target/Process.cpp Mon Nov 14 21:53:30 2011 @@ -251,7 +251,7 @@ } void -ProcessLaunchInfo::FinalizeFileActions (Target *target, Process *process) +ProcessLaunchInfo::FinalizeFileActions (Target *target) { // If notthing was specified, then check the process for any default // settings that were set with "settings set" @@ -304,6 +304,87 @@ } } + +bool +ProcessLaunchInfo::ConvertArgumentsForLaunchingInShell (Error &error, bool localhost) +{ + error.Clear(); + + if (GetFlags().Test (eLaunchFlagLaunchInShell)) + { + const char *shell_executable = GetShell(); + if (shell_executable) + { + char shell_resolved_path[PATH_MAX]; + + if (localhost) + { + FileSpec shell_filespec (shell_executable, true); + + if (!shell_filespec.Exists()) + { + // Resolve the path in case we just got "bash", "sh" or "tcsh" + if (!shell_filespec.ResolveExecutableLocation ()) + { + error.SetErrorStringWithFormat("invalid shell path '%s'", shell_executable); + return false; + } + } + shell_filespec.GetPath (shell_resolved_path, sizeof(shell_resolved_path)); + shell_executable = shell_resolved_path; + } + + Args shell_arguments; + std::string safe_arg; + shell_arguments.AppendArgument (shell_executable); + StreamString shell_command; + shell_arguments.AppendArgument ("-c"); + shell_command.PutCString ("exec"); + if (GetArchitecture().IsValid()) + { + shell_command.Printf(" /usr/bin/arch -arch %s", GetArchitecture().GetArchitectureName()); + // Set the resume count to 2: + // 1 - stop in shell + // 2 - stop in /usr/bin/arch + // 3 - then we will stop in our program + SetResumeCount(2); + } + else + { + // Set the resume count to 1: + // 1 - stop in shell + // 2 - then we will stop in our program + SetResumeCount(1); + } + + const char **argv = GetArguments().GetConstArgumentVector (); + if (argv) + { + for (size_t i=0; argv[i] != NULL; ++i) + { + const char *arg = Args::GetShellSafeArgument (argv[i], safe_arg); + shell_command.Printf(" %s", arg); + } + } + shell_arguments.AppendArgument (shell_command.GetString().c_str()); + + m_executable.SetFile(shell_executable, false); + m_arguments = shell_arguments; + return true; + } + else + { + error.SetErrorString ("invalid shell path"); + } + } + else + { + error.SetErrorString ("not launching in shell"); + } + return false; +} + + bool ProcessLaunchInfo::FileAction::Open (int fd, const char *path, bool read, bool write) { @@ -312,11 +393,11 @@ m_action = eFileActionOpen; m_fd = fd; if (read && write) - m_arg = O_RDWR; + m_arg = O_NOCTTY | O_CREAT | O_RDWR; else if (read) - m_arg = O_RDONLY; + m_arg = O_NOCTTY | O_RDONLY; else - m_arg = O_WRONLY; + m_arg = O_NOCTTY | O_CREAT | O_WRONLY; m_path.assign (path); return true; } @@ -404,8 +485,12 @@ else { int oflag = info->m_arg; + mode_t mode = 0; + if (oflag & O_CREAT) + mode = 0640; + error.SetError (::posix_spawn_file_actions_addopen (file_actions, info->m_fd, info->m_path.c_str(), @@ -496,7 +581,10 @@ break; case 'c': - launch_info.GetFlags().Set (eLaunchFlagLaunchInShell); + if (option_arg && option_arg[0]) + launch_info.SetShell (option_arg); + else + launch_info.SetShell ("/bin/bash"); break; case 'v': @@ -520,7 +608,7 @@ { LLDB_OPT_SET_ALL, false, "working-dir", 'w', required_argument, NULL, 0, eArgTypePath, "Set the current working directory to when running the inferior."}, { LLDB_OPT_SET_ALL, false, "arch", 'a', required_argument, NULL, 0, eArgTypeArchitecture, "Set the architecture for the process to launch when ambiguous."}, { LLDB_OPT_SET_ALL, false, "environment", 'v', required_argument, NULL, 0, eArgTypeNone, "Specify an environment variable name/value stirng (--environement NAME=VALUE). Can be specified multiple times for subsequent environment entries."}, -{ LLDB_OPT_SET_ALL, false, "shell", 'c', no_argument, NULL, 0, eArgTypeNone, "Run the process in a shell (not supported on all platforms)."}, +{ LLDB_OPT_SET_ALL, false, "shell", 'c', optional_argument, NULL, 0, eArgTypePath, "Run the process in a shell (not supported on all platforms)."}, { LLDB_OPT_SET_1 , false, "stdin", 'i', required_argument, NULL, 0, eArgTypePath, "Redirect stdin for the process to ."}, { LLDB_OPT_SET_1 , false, "stdout", 'o', required_argument, NULL, 0, eArgTypePath, "Redirect stdout for the process to ."}, @@ -2229,91 +2317,103 @@ } Error -Process::Attach (lldb::pid_t attach_pid, uint32_t exec_count) +Process::Attach (ProcessAttachInfo &attach_info) { - m_abi_sp.reset(); m_process_input_reader.reset(); - m_dyld_ap.reset(); m_os_ap.reset(); - - Error error (WillAttachToProcessWithID(attach_pid)); - if (error.Success()) - { - SetPublicState (eStateAttaching); - - error = DoAttachToProcessWithID (attach_pid); - if (error.Success()) - { - - SetNextEventAction(new Process::AttachCompletionHandler(this, exec_count)); - StartPrivateStateThread(); - } - else - { - if (GetID() != LLDB_INVALID_PROCESS_ID) - { - SetID (LLDB_INVALID_PROCESS_ID); - const char *error_string = error.AsCString(); - if (error_string == NULL) - error_string = "attach failed"; - - SetExitStatus(-1, error_string); - } - } - } - return error; -} - -Error -Process::Attach (const char *process_name, bool wait_for_launch) -{ - m_abi_sp.reset(); - m_process_input_reader.reset(); - // Find the process and its architecture. Make sure it matches the architecture - // of the current Target, and if not adjust it. + lldb::pid_t attach_pid = attach_info.GetProcessID(); Error error; - - if (!wait_for_launch) + if (attach_pid == LLDB_INVALID_PROCESS_ID) { - ProcessInstanceInfoList process_infos; - PlatformSP platform_sp (m_target.GetPlatform ()); - assert (platform_sp.get()); + char process_name[PATH_MAX]; - if (platform_sp) + if (attach_info.GetExecutableFile().GetPath (process_name, sizeof(process_name))) { - ProcessInstanceInfoMatch match_info; - match_info.GetProcessInfo().SetName(process_name); - match_info.SetNameMatchType (eNameMatchEquals); - platform_sp->FindProcesses (match_info, process_infos); - if (process_infos.GetSize() > 1) + const bool wait_for_launch = attach_info.GetWaitForLaunch(); + + if (wait_for_launch) { - error.SetErrorStringWithFormat ("more than one process named %s", process_name); + error = WillAttachToProcessWithName(process_name, wait_for_launch); + if (error.Success()) + { + SetPublicState (eStateAttaching); + error = DoAttachToProcessWithName (process_name, wait_for_launch); + if (error.Fail()) + { + if (GetID() != LLDB_INVALID_PROCESS_ID) + { + SetID (LLDB_INVALID_PROCESS_ID); + if (error.AsCString() == NULL) + error.SetErrorString("attach failed"); + + SetExitStatus(-1, error.AsCString()); + } + } + else + { + SetNextEventAction(new Process::AttachCompletionHandler(this, attach_info.GetResumeCount())); + StartPrivateStateThread(); + } + return error; + } } - else if (process_infos.GetSize() == 0) + else { - error.SetErrorStringWithFormat ("could not find a process named %s", process_name); + ProcessInstanceInfoList process_infos; + PlatformSP platform_sp (m_target.GetPlatform ()); + + if (platform_sp) + { + ProcessInstanceInfoMatch match_info; + match_info.GetProcessInfo() = attach_info; + match_info.SetNameMatchType (eNameMatchEquals); + platform_sp->FindProcesses (match_info, process_infos); + const uint32_t num_matches = process_infos.GetSize(); + if (num_matches == 1) + { + attach_pid = process_infos.GetProcessIDAtIndex(0); + // Fall through and attach using the above process ID + } + else + { + match_info.GetProcessInfo().GetExecutableFile().GetPath (process_name, sizeof(process_name)); + if (num_matches > 1) + error.SetErrorStringWithFormat ("more than one process named %s", process_name); + else + error.SetErrorStringWithFormat ("could not find a process named %s", process_name); + } + } + else + { + error.SetErrorString ("invalid platform, can't find processes by name"); + return error; + } } } else - { - error.SetErrorString ("invalid platform"); + { + error.SetErrorString ("invalid process name"); } } - - if (error.Success()) + + if (attach_pid != LLDB_INVALID_PROCESS_ID) { - m_dyld_ap.reset(); - m_os_ap.reset(); - - error = WillAttachToProcessWithName(process_name, wait_for_launch); + error = WillAttachToProcessWithID(attach_pid); if (error.Success()) { SetPublicState (eStateAttaching); - error = DoAttachToProcessWithName (process_name, wait_for_launch); - if (error.Fail()) + + error = DoAttachToProcessWithID (attach_pid); + if (error.Success()) + { + + SetNextEventAction(new Process::AttachCompletionHandler(this, attach_info.GetResumeCount())); + StartPrivateStateThread(); + } + else { if (GetID() != LLDB_INVALID_PROCESS_ID) { @@ -2325,16 +2425,80 @@ SetExitStatus(-1, error_string); } } - else - { - SetNextEventAction(new Process::AttachCompletionHandler(this, 0)); - StartPrivateStateThread(); - } } } return error; } +//Error +//Process::Attach (const char *process_name, bool wait_for_launch) +//{ +// m_abi_sp.reset(); +// m_process_input_reader.reset(); +// +// // Find the process and its architecture. Make sure it matches the architecture +// // of the current Target, and if not adjust it. +// Error error; +// +// if (!wait_for_launch) +// { +// ProcessInstanceInfoList process_infos; +// PlatformSP platform_sp (m_target.GetPlatform ()); +// assert (platform_sp.get()); +// +// if (platform_sp) +// { +// ProcessInstanceInfoMatch match_info; +// match_info.GetProcessInfo().SetName(process_name); +// match_info.SetNameMatchType (eNameMatchEquals); +// platform_sp->FindProcesses (match_info, process_infos); +// if (process_infos.GetSize() > 1) +// { +// error.SetErrorStringWithFormat ("more than one process named %s", process_name); +// } +// else if (process_infos.GetSize() == 0) +// { +// error.SetErrorStringWithFormat ("could not find a process named %s", process_name); +// } +// } +// else +// { +// error.SetErrorString ("invalid platform"); +// } +// } +// +// if (error.Success()) +// { +// m_dyld_ap.reset(); +// m_os_ap.reset(); +// +// error = WillAttachToProcessWithName(process_name, wait_for_launch); +// if (error.Success()) +// { +// SetPublicState (eStateAttaching); +// error = DoAttachToProcessWithName (process_name, wait_for_launch); +// if (error.Fail()) +// { +// if (GetID() != LLDB_INVALID_PROCESS_ID) +// { +// SetID (LLDB_INVALID_PROCESS_ID); +// const char *error_string = error.AsCString(); +// if (error_string == NULL) +// error_string = "attach failed"; +// +// SetExitStatus(-1, error_string); +// } +// } +// else +// { +// SetNextEventAction(new Process::AttachCompletionHandler(this, 0)); +// StartPrivateStateThread(); +// } +// } +// } +// return error; +//} + void Process::CompleteAttach () { From gclayton at apple.com Mon Nov 14 21:56:34 2011 From: gclayton at apple.com (Greg Clayton) Date: Tue, 15 Nov 2011 03:56:34 -0000 Subject: [Lldb-commits] [lldb] r144616 - in /lldb/trunk: lldb.xcodeproj/project.pbxproj resources/LLDB-Info.plist tools/debugserver/debugserver.xcodeproj/project.pbxproj Message-ID: <20111115035634.9C1332A6C131@llvm.org> Author: gclayton Date: Mon Nov 14 21:56:34 2011 New Revision: 144616 URL: http://llvm.org/viewvc/llvm-project?rev=144616&view=rev Log: Bumped Xcode project version for lldb-88 and debugserver-152. Modified: lldb/trunk/lldb.xcodeproj/project.pbxproj lldb/trunk/resources/LLDB-Info.plist lldb/trunk/tools/debugserver/debugserver.xcodeproj/project.pbxproj Modified: lldb/trunk/lldb.xcodeproj/project.pbxproj URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/lldb.xcodeproj/project.pbxproj?rev=144616&r1=144615&r2=144616&view=diff ============================================================================== --- lldb/trunk/lldb.xcodeproj/project.pbxproj (original) +++ lldb/trunk/lldb.xcodeproj/project.pbxproj Mon Nov 14 21:56:34 2011 @@ -3724,9 +3724,9 @@ buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; COPY_PHASE_STRIP = NO; - CURRENT_PROJECT_VERSION = 86; + CURRENT_PROJECT_VERSION = 88; DYLIB_COMPATIBILITY_VERSION = 1; - DYLIB_CURRENT_VERSION = 86; + DYLIB_CURRENT_VERSION = 88; EXPORTED_SYMBOLS_FILE = "resources/lldb-framework-exports"; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", @@ -3785,10 +3785,10 @@ buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; COPY_PHASE_STRIP = NO; - CURRENT_PROJECT_VERSION = 86; + CURRENT_PROJECT_VERSION = 88; DEAD_CODE_STRIPPING = YES; DYLIB_COMPATIBILITY_VERSION = 1; - DYLIB_CURRENT_VERSION = 86; + DYLIB_CURRENT_VERSION = 88; EXPORTED_SYMBOLS_FILE = "resources/lldb-framework-exports"; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", @@ -3845,8 +3845,8 @@ isa = XCBuildConfiguration; buildSettings = { COPY_PHASE_STRIP = NO; - CURRENT_PROJECT_VERSION = 86; - DYLIB_CURRENT_VERSION = 86; + CURRENT_PROJECT_VERSION = 88; + DYLIB_CURRENT_VERSION = 88; EXECUTABLE_EXTENSION = a; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", @@ -3875,8 +3875,8 @@ isa = XCBuildConfiguration; buildSettings = { COPY_PHASE_STRIP = NO; - CURRENT_PROJECT_VERSION = 86; - DYLIB_CURRENT_VERSION = 86; + CURRENT_PROJECT_VERSION = 88; + DYLIB_CURRENT_VERSION = 88; EXECUTABLE_EXTENSION = a; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", @@ -3905,8 +3905,8 @@ isa = XCBuildConfiguration; buildSettings = { COPY_PHASE_STRIP = NO; - CURRENT_PROJECT_VERSION = 86; - DYLIB_CURRENT_VERSION = 86; + CURRENT_PROJECT_VERSION = 88; + DYLIB_CURRENT_VERSION = 88; EXECUTABLE_EXTENSION = a; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", @@ -3983,7 +3983,7 @@ isa = XCBuildConfiguration; buildSettings = { COPY_PHASE_STRIP = YES; - CURRENT_PROJECT_VERSION = 86; + CURRENT_PROJECT_VERSION = 88; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", "\"$(SYSTEM_LIBRARY_DIR)/PrivateFrameworks\"", @@ -4013,10 +4013,10 @@ buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; COPY_PHASE_STRIP = YES; - CURRENT_PROJECT_VERSION = 86; + CURRENT_PROJECT_VERSION = 88; DEAD_CODE_STRIPPING = YES; DYLIB_COMPATIBILITY_VERSION = 1; - DYLIB_CURRENT_VERSION = 86; + DYLIB_CURRENT_VERSION = 88; EXPORTED_SYMBOLS_FILE = "resources/lldb-framework-exports"; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", @@ -4260,7 +4260,7 @@ isa = XCBuildConfiguration; buildSettings = { COPY_PHASE_STRIP = NO; - CURRENT_PROJECT_VERSION = 86; + CURRENT_PROJECT_VERSION = 88; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", "\"$(SYSTEM_LIBRARY_DIR)/PrivateFrameworks\"", @@ -4291,7 +4291,7 @@ isa = XCBuildConfiguration; buildSettings = { COPY_PHASE_STRIP = YES; - CURRENT_PROJECT_VERSION = 86; + CURRENT_PROJECT_VERSION = 88; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", "\"$(SYSTEM_LIBRARY_DIR)/PrivateFrameworks\"", Modified: lldb/trunk/resources/LLDB-Info.plist URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/resources/LLDB-Info.plist?rev=144616&r1=144615&r2=144616&view=diff ============================================================================== --- lldb/trunk/resources/LLDB-Info.plist (original) +++ lldb/trunk/resources/LLDB-Info.plist Mon Nov 14 21:56:34 2011 @@ -17,7 +17,7 @@ CFBundleSignature ???? CFBundleVersion - 86 + 88 CFBundleName ${EXECUTABLE_NAME} Modified: lldb/trunk/tools/debugserver/debugserver.xcodeproj/project.pbxproj URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/debugserver/debugserver.xcodeproj/project.pbxproj?rev=144616&r1=144615&r2=144616&view=diff ============================================================================== --- lldb/trunk/tools/debugserver/debugserver.xcodeproj/project.pbxproj (original) +++ lldb/trunk/tools/debugserver/debugserver.xcodeproj/project.pbxproj Mon Nov 14 21:56:34 2011 @@ -475,7 +475,7 @@ i386, ); COPY_PHASE_STRIP = NO; - CURRENT_PROJECT_VERSION = 151; + CURRENT_PROJECT_VERSION = 152; GCC_WARN_ABOUT_RETURN_TYPE = YES; GCC_WARN_UNUSED_VARIABLE = YES; SDKROOT = ""; @@ -494,7 +494,7 @@ x86_64, i386, ); - CURRENT_PROJECT_VERSION = 151; + CURRENT_PROJECT_VERSION = 152; DEAD_CODE_STRIPPING = YES; GCC_WARN_ABOUT_RETURN_TYPE = YES; GCC_WARN_UNUSED_VARIABLE = YES; @@ -515,7 +515,7 @@ x86_64, i386, ); - CURRENT_PROJECT_VERSION = 151; + CURRENT_PROJECT_VERSION = 152; DEAD_CODE_STRIPPING = YES; GCC_WARN_ABOUT_RETURN_TYPE = YES; GCC_WARN_UNUSED_VARIABLE = YES; @@ -534,7 +534,7 @@ "ARCHS[sdk=iphoneos*]" = "$(ARCHS_STANDARD_32_BIT)"; "CODE_SIGN_ENTITLEMENTS[sdk=iphoneos*]" = "source/debugserver-entitlements.plist"; COPY_PHASE_STRIP = YES; - CURRENT_PROJECT_VERSION = 151; + CURRENT_PROJECT_VERSION = 152; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; FRAMEWORK_SEARCH_PATHS = $SDKROOT/System/Library/PrivateFrameworks; "FRAMEWORK_SEARCH_PATHS[sdk=iphoneos*][arch=*]" = ( @@ -577,7 +577,7 @@ "CODE_SIGN_ENTITLEMENTS[sdk=iphoneos*]" = "source/debugserver-entitlements.plist"; "CODE_SIGN_IDENTITY[sdk=macosx*]" = lldb_codesign; COPY_PHASE_STRIP = YES; - CURRENT_PROJECT_VERSION = 151; + CURRENT_PROJECT_VERSION = 152; FRAMEWORK_SEARCH_PATHS = $SDKROOT/System/Library/PrivateFrameworks; "FRAMEWORK_SEARCH_PATHS[sdk=iphoneos*][arch=*]" = ( "$(SDKROOT)/System/Library/PrivateFrameworks", @@ -620,7 +620,7 @@ "CODE_SIGN_ENTITLEMENTS[sdk=iphoneos*]" = "source/debugserver-entitlements.plist"; "CODE_SIGN_IDENTITY[sdk=macosx*]" = lldb_codesign; COPY_PHASE_STRIP = YES; - CURRENT_PROJECT_VERSION = 151; + CURRENT_PROJECT_VERSION = 152; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; FRAMEWORK_SEARCH_PATHS = $SDKROOT/System/Library/PrivateFrameworks; "FRAMEWORK_SEARCH_PATHS[sdk=iphoneos*][arch=*]" = ( From gclayton at apple.com Mon Nov 14 21:57:12 2011 From: gclayton at apple.com (Greg Clayton) Date: Tue, 15 Nov 2011 03:57:12 -0000 Subject: [Lldb-commits] [lldb] r144617 - /lldb/tags/lldb-88/ Message-ID: <20111115035712.4A1AF2A6C131@llvm.org> Author: gclayton Date: Mon Nov 14 21:57:12 2011 New Revision: 144617 URL: http://llvm.org/viewvc/llvm-project?rev=144617&view=rev Log: lldb-88 Added: lldb/tags/lldb-88/ - copied from r144616, lldb/trunk/ From scallanan at apple.com Tue Nov 15 13:13:54 2011 From: scallanan at apple.com (Sean Callanan) Date: Tue, 15 Nov 2011 19:13:54 -0000 Subject: [Lldb-commits] [lldb] r144677 - /lldb/trunk/source/Expression/IRForTarget.cpp Message-ID: <20111115191354.71C612A6C131@llvm.org> Author: spyffe Date: Tue Nov 15 13:13:54 2011 New Revision: 144677 URL: http://llvm.org/viewvc/llvm-project?rev=144677&view=rev Log: Fixed a bug where the variable-resolution code would occasionally try to resolve the placeholder variable used for static data allocation. Modified: lldb/trunk/source/Expression/IRForTarget.cpp Modified: lldb/trunk/source/Expression/IRForTarget.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/IRForTarget.cpp?rev=144677&r1=144676&r2=144677&view=diff ============================================================================== --- lldb/trunk/source/Expression/IRForTarget.cpp (original) +++ lldb/trunk/source/Expression/IRForTarget.cpp Tue Nov 15 13:13:54 2011 @@ -1499,6 +1499,9 @@ if (GlobalVariable::isExternalLinkage(global_variable->getLinkage())) return false; + if (global_variable == m_reloc_placeholder) + return true; + uint64_t offset = m_data_allocator->GetStream().GetSize(); llvm::Type *variable_type = global_variable->getType(); From gclayton at apple.com Tue Nov 15 13:53:51 2011 From: gclayton at apple.com (Greg Clayton) Date: Tue, 15 Nov 2011 19:53:51 -0000 Subject: [Lldb-commits] [lldb] r144681 - /lldb/tags/lldb-88/ Message-ID: <20111115195351.E93D82A6C131@llvm.org> Author: gclayton Date: Tue Nov 15 13:53:51 2011 New Revision: 144681 URL: http://llvm.org/viewvc/llvm-project?rev=144681&view=rev Log: Going to retag lldb-88 to include 144680. Removed: lldb/tags/lldb-88/ From gclayton at apple.com Tue Nov 15 13:54:12 2011 From: gclayton at apple.com (Greg Clayton) Date: Tue, 15 Nov 2011 19:54:12 -0000 Subject: [Lldb-commits] [lldb] r144682 - /lldb/tags/lldb-88/ Message-ID: <20111115195412.318302A6C131@llvm.org> Author: gclayton Date: Tue Nov 15 13:54:11 2011 New Revision: 144682 URL: http://llvm.org/viewvc/llvm-project?rev=144682&view=rev Log: lldb-88 take 2 Added: lldb/tags/lldb-88/ - copied from r144681, lldb/trunk/ From johnny.chen at apple.com Tue Nov 15 14:36:58 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Tue, 15 Nov 2011 20:36:58 -0000 Subject: [Lldb-commits] [lldb] r144693 - in /lldb/trunk/test/python_api/value/change_values: TestChangeValueAPI.py TestValueAPI.py Message-ID: <20111115203658.19F192A6C131@llvm.org> Author: johnny Date: Tue Nov 15 14:36:57 2011 New Revision: 144693 URL: http://llvm.org/viewvc/llvm-project?rev=144693&view=rev Log: File renaming. Added: lldb/trunk/test/python_api/value/change_values/TestChangeValueAPI.py - copied unchanged from r144586, lldb/trunk/test/python_api/value/change_values/TestValueAPI.py Removed: lldb/trunk/test/python_api/value/change_values/TestValueAPI.py Removed: lldb/trunk/test/python_api/value/change_values/TestValueAPI.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/python_api/value/change_values/TestValueAPI.py?rev=144692&view=auto ============================================================================== --- lldb/trunk/test/python_api/value/change_values/TestValueAPI.py (original) +++ lldb/trunk/test/python_api/value/change_values/TestValueAPI.py (removed) @@ -1,145 +0,0 @@ -""" -Test some SBValue APIs. -""" - -import os, time -import re -import unittest2 -import lldb, lldbutil -from lldbtest import * - -class ChangeValueAPITestCase(TestBase): - - mydir = os.path.join("python_api", "value", "change_values") - - @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin") - @python_api_test - def test_change_value_with_dsym(self): - """Exercise the SBValue::SetValueFromCString API.""" - d = {'EXE': self.exe_name} - self.buildDsym(dictionary=d) - self.setTearDownCleanup(dictionary=d) - self.change_value_api(self.exe_name) - - @python_api_test - def test_change_value_with_dwarf(self): - """Exercise the SBValue::SetValueFromCString API.""" - d = {'EXE': self.exe_name} - self.buildDwarf(dictionary=d) - self.setTearDownCleanup(dictionary=d) - self.change_value_api(self.exe_name) - - def setUp(self): - # Call super's setUp(). - TestBase.setUp(self) - # We'll use the test method name as the exe_name. - self.exe_name = self.testMethodName - # Find the line number to of function 'c'. - self.line = line_number('main.c', '// Stop here and set values') - self.end_line = line_number ('main.c', '// Set a breakpoint here at the end') - - def change_value_api(self, exe_name): - """Exercise some SBValue APIs.""" - exe = os.path.join(os.getcwd(), exe_name) - - # Create a target by the debugger. - target = self.dbg.CreateTarget(exe) - self.assertTrue(target, VALID_TARGET) - - # Create the breakpoint inside function 'main'. - breakpoint = target.BreakpointCreateByLocation('main.c', self.line) - self.assertTrue(breakpoint, VALID_BREAKPOINT) - - # Create the breakpoint inside function 'main'. - end_breakpoint = target.BreakpointCreateByLocation('main.c', self.end_line) - self.assertTrue(end_breakpoint, VALID_BREAKPOINT) - - # Now launch the process, and do not stop at entry point. - process = target.LaunchSimple(None, None, os.getcwd()) - self.assertTrue(process, PROCESS_IS_VALID) - - # Get Frame #0. - self.assertTrue(process.GetState() == lldb.eStateStopped) - thread = lldbutil.get_stopped_thread(process, lldb.eStopReasonBreakpoint) - self.assertTrue(thread != None, "There should be a thread stopped due to breakpoint condition") - frame0 = thread.GetFrameAtIndex(0) - self.assertTrue (frame0.IsValid(), "Got a valid frame.") - - # Get the val variable and change it: - error = lldb.SBError() - - val_value = frame0.FindVariable ("val") - self.assertTrue (val_value.IsValid(), "Got the SBValue for val") - actual_value = val_value.GetValueAsSigned (error, 0); - self.assertTrue (error.Success(), "Got a value from val") - self.assertTrue (actual_value == 100, "Got the right value from val") - - result = val_value.SetValueFromCString ("12345") - self.assertTrue (result, "Setting val returned True.") - actual_value = val_value.GetValueAsSigned (error, 0); - self.assertTrue (error.Success(), "Got a changed value from val") - self.assertTrue (actual_value == 12345, "Got the right changed value from val") - - # Now check that we can set a structure element: - - mine_value = frame0.FindVariable ("mine") - self.assertTrue (mine_value.IsValid(), "Got the SBValue for mine") - - mine_second_value = mine_value.GetChildMemberWithName ("second_val") - self.assertTrue (mine_second_value.IsValid(), "Got second_val from mine") - actual_value = mine_second_value.GetValueAsUnsigned (error, 0) - self.assertTrue (error.Success(), "Got an unsigned value for second_val") - self.assertTrue (actual_value == 5555) - - result = mine_second_value.SetValueFromCString ("98765") - self.assertTrue (result, "Success setting mine.second_value.") - actual_value = mine_second_value.GetValueAsSigned (error, 0); - self.assertTrue (error.Success(), "Got a changed value from mine.second_val") - self.assertTrue (actual_value == 98765, "Got the right changed value from mine.second_val") - - # Next do the same thing with the pointer version. - ptr_value = frame0.FindVariable ("ptr") - self.assertTrue (ptr_value.IsValid(), "Got the SBValue for ptr") - - ptr_second_value = ptr_value.GetChildMemberWithName ("second_val") - self.assertTrue (ptr_second_value.IsValid(), "Got second_val from ptr") - actual_value = ptr_second_value.GetValueAsUnsigned (error, 0) - self.assertTrue (error.Success(), "Got an unsigned value for ptr->second_val") - self.assertTrue (actual_value == 6666) - - result = ptr_second_value.SetValueFromCString ("98765") - self.assertTrue (result, "Success setting ptr->second_value.") - actual_value = ptr_second_value.GetValueAsSigned (error, 0); - self.assertTrue (error.Success(), "Got a changed value from ptr->second_val") - self.assertTrue (actual_value == 98765, "Got the right changed value from ptr->second_val") - - # Now step, grab the stdout and make sure we changed the real values as well... - thread.StepOver() - expected_value = "Val - 12345 Mine - 55, 98765, 55555555. Ptr - 66, 98765, 66666666" - stdout = process.GetSTDOUT(1000) - self.assertTrue (expected_value in stdout, "STDOUT showed changed values.") - - # Finally, change the stack pointer to 0, and we should not make it to our end breakpoint. - frame0 = thread.GetFrameAtIndex(0) - self.assertTrue (frame0.IsValid(), "Second time: got a valid frame.") - sp_value = frame0.FindValue ("sp", lldb.eValueTypeRegister); - self.assertTrue (sp_value.IsValid(), "Got a stack pointer value") - result = sp_value.SetValueFromCString("1") - self.assertTrue (result, "Setting sp returned true.") - actual_value = sp_value.GetValueAsUnsigned (error, 0) - self.assertTrue (error.Success(), "Got a changed value for sp") - self.assertTrue (actual_value == 1, "Got the right changed value for sp.") - - process.Continue() - - self.assertTrue(process.GetState() == lldb.eStateStopped) - thread = lldbutil.get_stopped_thread(process, lldb.eStopReasonBreakpoint) - self.assertTrue(thread == None, "We should not have managed to hit our second breakpoint with sp == 1") - - process.Kill() - -if __name__ == '__main__': - import atexit - lldb.SBDebugger.Initialize() - atexit.register(lambda: lldb.SBDebugger.Terminate()) - unittest2.main() From johnny.chen at apple.com Tue Nov 15 15:13:13 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Tue, 15 Nov 2011 21:13:13 -0000 Subject: [Lldb-commits] [lldb] r144697 - in /lldb/trunk/test/python_api/value: TestValueAPI.py main.c Message-ID: <20111115211313.996F72A6C131@llvm.org> Author: johnny Date: Tue Nov 15 15:13:13 2011 New Revision: 144697 URL: http://llvm.org/viewvc/llvm-project?rev=144697&view=rev Log: Add test scenario for value.GetChildAtIndex(0) where value is a pointer to a simple type. Modified: lldb/trunk/test/python_api/value/TestValueAPI.py lldb/trunk/test/python_api/value/main.c Modified: lldb/trunk/test/python_api/value/TestValueAPI.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/python_api/value/TestValueAPI.py?rev=144697&r1=144696&r2=144697&view=diff ============================================================================== --- lldb/trunk/test/python_api/value/TestValueAPI.py (original) +++ lldb/trunk/test/python_api/value/TestValueAPI.py Tue Nov 15 15:13:13 2011 @@ -89,6 +89,16 @@ print cvf.format(weekdays) print rdf.format(g_table) + # Get variable 'my_int_ptr'. + value = frame0.FindVariable('my_int_ptr') + self.assertTrue(value, VALID_VARIABLE) + self.DebugSBValue(value) + + # Get what 'my_int_ptr' points to. + pointed = value.GetChildAtIndex(0) + self.assertTrue(pointed, VALID_VARIABLE) + self.DebugSBValue(pointed) + # Get variable 'str_ptr'. value = frame0.FindVariable('str_ptr') self.assertTrue(value, VALID_VARIABLE) Modified: lldb/trunk/test/python_api/value/main.c URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/python_api/value/main.c?rev=144697&r1=144696&r2=144697&view=diff ============================================================================== --- lldb/trunk/test/python_api/value/main.c (original) +++ lldb/trunk/test/python_api/value/main.c Tue Nov 15 15:13:13 2011 @@ -31,6 +31,8 @@ int main (int argc, char const *argv[]) { int i; + int *my_int_ptr = &g_my_int; + printf("my_int_ptr points to location %p\n", my_int_ptr); const char **str_ptr = days_of_week; for (i = 0; i < 7; ++i) printf("%s\n", str_ptr[i]); // Break at this line From scallanan at apple.com Tue Nov 15 15:49:25 2011 From: scallanan at apple.com (Sean Callanan) Date: Tue, 15 Nov 2011 21:49:25 -0000 Subject: [Lldb-commits] [lldb] r144702 - /lldb/trunk/include/lldb/Expression/ClangExpressionDeclMap.h Message-ID: <20111115214925.2C6BB2A6C131@llvm.org> Author: spyffe Date: Tue Nov 15 15:49:24 2011 New Revision: 144702 URL: http://llvm.org/viewvc/llvm-project?rev=144702&view=rev Log: Removed the ClangASTImporter pointer from ClangExpressionDeclMap, which actually uses the one it inherits from ClangASTSource. Modified: lldb/trunk/include/lldb/Expression/ClangExpressionDeclMap.h Modified: lldb/trunk/include/lldb/Expression/ClangExpressionDeclMap.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Expression/ClangExpressionDeclMap.h?rev=144702&r1=144701&r2=144702&view=diff ============================================================================== --- lldb/trunk/include/lldb/Expression/ClangExpressionDeclMap.h (original) +++ lldb/trunk/include/lldb/Expression/ClangExpressionDeclMap.h Tue Nov 15 15:49:24 2011 @@ -27,7 +27,6 @@ #include "lldb/Core/Value.h" #include "lldb/Expression/ClangASTSource.h" #include "lldb/Expression/ClangExpressionVariable.h" -#include "lldb/Symbol/ClangASTImporter.h" #include "lldb/Symbol/TaggedASTType.h" #include "lldb/Symbol/SymbolContext.h" #include "lldb/Target/ExecutionContext.h" @@ -687,7 +686,6 @@ SymbolContext m_sym_ctx; ///< The symbol context to use in finding variables and types. ClangPersistentVariables *m_persistent_vars; ///< The persistent variables for the process. bool m_enable_lookups; ///< Set to true during parsing if we have found the first "$__lldb" name. - std::auto_ptr m_ast_importer; ///< The importer used to import types on the parser's behalf. TargetInfo m_target_info; ///< Basic information about the target. private: ClangExpressionDeclMap &m_decl_map; From scallanan at apple.com Tue Nov 15 15:50:18 2011 From: scallanan at apple.com (Sean Callanan) Date: Tue, 15 Nov 2011 21:50:18 -0000 Subject: [Lldb-commits] [lldb] r144704 - /lldb/trunk/source/Expression/ClangASTSource.cpp Message-ID: <20111115215018.995DA2A6C131@llvm.org> Author: spyffe Date: Tue Nov 15 15:50:18 2011 New Revision: 144704 URL: http://llvm.org/viewvc/llvm-project?rev=144704&view=rev Log: Eliminated a compile warning by removing dyn_cast where isa is good enough. Modified: lldb/trunk/source/Expression/ClangASTSource.cpp Modified: lldb/trunk/source/Expression/ClangASTSource.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/ClangASTSource.cpp?rev=144704&r1=144703&r2=144704&view=diff ============================================================================== --- lldb/trunk/source/Expression/ClangASTSource.cpp (original) +++ lldb/trunk/source/Expression/ClangASTSource.cpp Tue Nov 15 15:50:18 2011 @@ -311,7 +311,7 @@ current_id); } } - else if (const ObjCInterfaceDecl *interface_decl = dyn_cast(context.m_decl_context)) + else if (isa(context.m_decl_context)) { FindObjCPropertyDecls(context); } From scallanan at apple.com Tue Nov 15 16:27:19 2011 From: scallanan at apple.com (Sean Callanan) Date: Tue, 15 Nov 2011 22:27:19 -0000 Subject: [Lldb-commits] [lldb] r144712 - in /lldb/trunk: include/lldb/Symbol/ClangASTImporter.h include/lldb/Target/Target.h include/lldb/lldb-forward.h source/Target/Target.cpp Message-ID: <20111115222720.086D42A6C132@llvm.org> Author: spyffe Date: Tue Nov 15 16:27:19 2011 New Revision: 144712 URL: http://llvm.org/viewvc/llvm-project?rev=144712&view=rev Log: Made Target own a ClangASTSource that will be used to complete types in the scratch AST context. Modified: lldb/trunk/include/lldb/Symbol/ClangASTImporter.h lldb/trunk/include/lldb/Target/Target.h lldb/trunk/include/lldb/lldb-forward.h lldb/trunk/source/Target/Target.cpp Modified: lldb/trunk/include/lldb/Symbol/ClangASTImporter.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Symbol/ClangASTImporter.h?rev=144712&r1=144711&r2=144712&view=diff ============================================================================== --- lldb/trunk/include/lldb/Symbol/ClangASTImporter.h (original) +++ lldb/trunk/include/lldb/Symbol/ClangASTImporter.h Tue Nov 15 16:27:19 2011 @@ -93,7 +93,6 @@ void BuildNamespaceMap (const clang::NamespaceDecl *decl); private: - struct DeclOrigin { DeclOrigin () : Modified: lldb/trunk/include/lldb/Target/Target.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/Target.h?rev=144712&r1=144711&r2=144712&view=diff ============================================================================== --- lldb/trunk/include/lldb/Target/Target.h (original) +++ lldb/trunk/include/lldb/Target/Target.h Tue Nov 15 16:27:19 2011 @@ -1053,6 +1053,7 @@ lldb::SearchFilterSP m_search_filter_sp; PathMappingList m_image_search_paths; std::auto_ptr m_scratch_ast_context_ap; + std::auto_ptr m_scratch_ast_source_ap; ClangPersistentVariables m_persistent_variables; ///< These are the persistent variables associated with this process for the expression parser. SourceManager m_source_manager; Modified: lldb/trunk/include/lldb/lldb-forward.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/lldb-forward.h?rev=144712&r1=144711&r2=144712&view=diff ============================================================================== --- lldb/trunk/include/lldb/lldb-forward.h (original) +++ lldb/trunk/include/lldb/lldb-forward.h Tue Nov 15 16:27:19 2011 @@ -41,6 +41,7 @@ class Broadcaster; class CPPLanguageRuntime; class ClangASTContext; +class ClangASTSource; class ClangASTType; class ClangNamespaceDecl; class ClangExpression; Modified: lldb/trunk/source/Target/Target.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/Target.cpp?rev=144712&r1=144711&r2=144712&view=diff ============================================================================== --- lldb/trunk/source/Target/Target.cpp (original) +++ lldb/trunk/source/Target/Target.cpp Tue Nov 15 16:27:19 2011 @@ -26,6 +26,7 @@ #include "lldb/Core/StreamString.h" #include "lldb/Core/Timer.h" #include "lldb/Core/ValueObject.h" +#include "lldb/Expression/ClangASTSource.h" #include "lldb/Expression/ClangUserExpression.h" #include "lldb/Host/Host.h" #include "lldb/Interpreter/CommandInterpreter.h" @@ -171,6 +172,7 @@ m_search_filter_sp.reset(); m_image_search_paths.Clear(notify); m_scratch_ast_context_ap.reset(); + m_scratch_ast_source_ap.reset(); m_persistent_variables.Clear(); m_stop_hooks.clear(); m_stop_hook_next_id = 0; @@ -794,6 +796,7 @@ { m_images.Clear(); m_scratch_ast_context_ap.reset(); + m_scratch_ast_source_ap.reset(); if (executable_sp.get()) { @@ -1329,7 +1332,13 @@ { // Now see if we know the target triple, and if so, create our scratch AST context: if (m_scratch_ast_context_ap.get() == NULL && m_arch.IsValid()) + { m_scratch_ast_context_ap.reset (new ClangASTContext(m_arch.GetTriple().str().c_str())); + m_scratch_ast_source_ap.reset (new ClangASTSource(GetSP())); + m_scratch_ast_source_ap->InstallASTContext(m_scratch_ast_context_ap->getASTContext()); + llvm::OwningPtr proxy_ast_source(m_scratch_ast_source_ap->CreateProxy()); + m_scratch_ast_context_ap->SetExternalSource(proxy_ast_source); + } return m_scratch_ast_context_ap.get(); } From johnny.chen at apple.com Tue Nov 15 16:42:53 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Tue, 15 Nov 2011 22:42:53 -0000 Subject: [Lldb-commits] [lldb] r144717 - in /lldb/trunk/test/expression_command/two-files: Makefile TestObjCTypeQueryFromOtherCompileUnit.py main.c main.m Message-ID: <20111115224253.6937D2A6C132@llvm.org> Author: johnny Date: Tue Nov 15 16:42:53 2011 New Revision: 144717 URL: http://llvm.org/viewvc/llvm-project?rev=144717&view=rev Log: Fix objc runtime warnings from the inferior program. Added: lldb/trunk/test/expression_command/two-files/main.m - copied, changed from r144698, lldb/trunk/test/expression_command/two-files/main.c Removed: lldb/trunk/test/expression_command/two-files/main.c Modified: lldb/trunk/test/expression_command/two-files/Makefile lldb/trunk/test/expression_command/two-files/TestObjCTypeQueryFromOtherCompileUnit.py Modified: lldb/trunk/test/expression_command/two-files/Makefile URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/expression_command/two-files/Makefile?rev=144717&r1=144716&r2=144717&view=diff ============================================================================== --- lldb/trunk/test/expression_command/two-files/Makefile (original) +++ lldb/trunk/test/expression_command/two-files/Makefile Tue Nov 15 16:42:53 2011 @@ -1,7 +1,6 @@ LEVEL = ../../make -C_SOURCES := main.c -OBJC_SOURCES := foo.m +OBJC_SOURCES := main.m foo.m include $(LEVEL)/Makefile.rules Modified: lldb/trunk/test/expression_command/two-files/TestObjCTypeQueryFromOtherCompileUnit.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/expression_command/two-files/TestObjCTypeQueryFromOtherCompileUnit.py?rev=144717&r1=144716&r2=144717&view=diff ============================================================================== --- lldb/trunk/test/expression_command/two-files/TestObjCTypeQueryFromOtherCompileUnit.py (original) +++ lldb/trunk/test/expression_command/two-files/TestObjCTypeQueryFromOtherCompileUnit.py Tue Nov 15 16:42:53 2011 @@ -15,8 +15,8 @@ def setUp(self): # Call super's setUp(). TestBase.setUp(self) - # Find the line number to break for main.c. - self.line = line_number('main.c', + # Find the line number to break for main.m. + self.line = line_number('main.m', "// Set breakpoint here, then do 'expr (NSArray*)array_token'.") @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin") @@ -34,14 +34,14 @@ """The expression parser's type search should be wider than the current compilation unit.""" self.runCmd("file a.out", CURRENT_EXECUTABLE_SET) - self.expect("breakpoint set -f main.c -l %d" % self.line, + self.expect("breakpoint set -f main.m -l %d" % self.line, BREAKPOINT_CREATED, - startstr = "Breakpoint created: 1: file ='main.c', line = %d" % + startstr = "Breakpoint created: 1: file ='main.m', line = %d" % self.line) self.runCmd("run", RUN_SUCCEEDED) - # Now do a NSArry type query from the 'main.c' compile uint. + # Now do a NSArry type query from the 'main.m' compile uint. self.expect("expression (NSArray*)array_token", substrs = ['(NSArray *) $0 = 0x']) # (NSArray *) $0 = 0x00007fff70118398 Removed: lldb/trunk/test/expression_command/two-files/main.c URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/expression_command/two-files/main.c?rev=144716&view=auto ============================================================================== --- lldb/trunk/test/expression_command/two-files/main.c (original) +++ lldb/trunk/test/expression_command/two-files/main.c (removed) @@ -1,19 +0,0 @@ -#include - -extern int AddElement (char *value); -extern char *GetElement (int idx); -extern void *GetArray(); - -int -main () -{ - - int idx = AddElement ("some string"); - void *array_token = GetArray(); - - char *string = GetElement (0); // Set breakpoint here, then do 'expr (NSArray*)array_token'. - if (string) - printf ("This: %s.\n", string); - - return 0; -} Copied: lldb/trunk/test/expression_command/two-files/main.m (from r144698, lldb/trunk/test/expression_command/two-files/main.c) URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/expression_command/two-files/main.m?p2=lldb/trunk/test/expression_command/two-files/main.m&p1=lldb/trunk/test/expression_command/two-files/main.c&r1=144698&r2=144717&rev=144717&view=diff ============================================================================== --- lldb/trunk/test/expression_command/two-files/main.c (original) +++ lldb/trunk/test/expression_command/two-files/main.m Tue Nov 15 16:42:53 2011 @@ -1,3 +1,4 @@ +#import #include extern int AddElement (char *value); @@ -7,6 +8,7 @@ int main () { + NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; int idx = AddElement ("some string"); void *array_token = GetArray(); @@ -15,5 +17,6 @@ if (string) printf ("This: %s.\n", string); + [pool release]; return 0; } From johnny.chen at apple.com Tue Nov 15 17:30:40 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Tue, 15 Nov 2011 23:30:40 -0000 Subject: [Lldb-commits] [lldb] r144728 - /lldb/trunk/test/python_api/value/TestValueAPI.py Message-ID: <20111115233040.3A06E2A6C132@llvm.org> Author: johnny Date: Tue Nov 15 17:30:39 2011 New Revision: 144728 URL: http://llvm.org/viewvc/llvm-project?rev=144728&view=rev Log: While we are at it, verify that 'my_int_ptr' points to 'g_my_int', using the SBTarget.ResolveLoadAddress() to get its SBAddress, and SBAddress.GetSymbol() to get the corresponding symbol. Modified: lldb/trunk/test/python_api/value/TestValueAPI.py Modified: lldb/trunk/test/python_api/value/TestValueAPI.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/python_api/value/TestValueAPI.py?rev=144728&r1=144727&r2=144728&view=diff ============================================================================== --- lldb/trunk/test/python_api/value/TestValueAPI.py (original) +++ lldb/trunk/test/python_api/value/TestValueAPI.py Tue Nov 15 17:30:39 2011 @@ -99,6 +99,12 @@ self.assertTrue(pointed, VALID_VARIABLE) self.DebugSBValue(pointed) + # While we are at it, verify that 'my_int_ptr' points to 'g_my_int'. + symbol = target.ResolveLoadAddress(int(pointed.GetLocation(), 0)).GetSymbol() + self.assertTrue(symbol) + self.expect(symbol.GetName(), exe=False, + startstr = 'g_my_int') + # Get variable 'str_ptr'. value = frame0.FindVariable('str_ptr') self.assertTrue(value, VALID_VARIABLE) From scallanan at apple.com Tue Nov 15 18:20:50 2011 From: scallanan at apple.com (Sean Callanan) Date: Wed, 16 Nov 2011 00:20:50 -0000 Subject: [Lldb-commits] [lldb] r144741 - in /lldb/trunk/source/Expression: IRDynamicChecks.cpp IRForTarget.cpp Message-ID: <20111116002050.CF7742A6C132@llvm.org> Author: spyffe Date: Tue Nov 15 18:20:50 2011 New Revision: 144741 URL: http://llvm.org/viewvc/llvm-project?rev=144741&view=rev Log: Two fixes for Objetive-C methods that return struct types. First, I added handling for the memset intrinsic in the IR, which is used to zero out the returned struct. Second, I fixed the object-checking instrumentation to objc_msgSend_stret, and generally tightened up how the object-checking functions get inserted. Modified: lldb/trunk/source/Expression/IRDynamicChecks.cpp lldb/trunk/source/Expression/IRForTarget.cpp Modified: lldb/trunk/source/Expression/IRDynamicChecks.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/IRDynamicChecks.cpp?rev=144741&r1=144740&r2=144741&view=diff ============================================================================== --- lldb/trunk/source/Expression/IRDynamicChecks.cpp (original) +++ lldb/trunk/source/Expression/IRDynamicChecks.cpp Tue Nov 15 18:20:50 2011 @@ -423,6 +423,17 @@ ~ObjcObjectChecker () { } + + enum msgSend_type + { + eMsgSend = 0, + eMsgSendSuper, + eMsgSendSuper_stret, + eMsgSend_fpret, + eMsgSend_stret + }; + + std::map msgSend_types; private: bool InstrumentInstruction(llvm::Instruction *inst) @@ -437,8 +448,23 @@ // id objc_msgSend(id theReceiver, SEL theSelector, ...) - llvm::Value *target_object = call_inst->getArgOperand(0);; - llvm::Value *selector = call_inst->getArgOperand(1); + llvm::Value *target_object; + llvm::Value *selector; + + switch (msgSend_types[inst]) + { + case eMsgSend: + case eMsgSend_fpret: + target_object = call_inst->getArgOperand(0); + selector = call_inst->getArgOperand(1); + break; + case eMsgSend_stret: + target_object = call_inst->getArgOperand(1); + selector = call_inst->getArgOperand(2); + case eMsgSendSuper: + case eMsgSendSuper_stret: + return true; + } // Insert an instruction to cast the receiver id to int8_t* @@ -505,8 +531,51 @@ if (log) log->Printf("Found call to %s: %s\n", real_name->getAsString().c_str(), PrintValue(call_inst).c_str()); - if (real_name->getAsString().find("objc_msgSend") != std::string::npos) + std::string name_str = real_name->getAsString(); + const char* name_cstr = name_str.c_str(); + + if (name_str.find("objc_msgSend") == std::string::npos) + return true; + + if (!strcmp(name_cstr, "objc_msgSend")) + { RegisterInstruction(i); + msgSend_types[&i] = eMsgSend; + return true; + } + + if (!strcmp(name_cstr, "objc_msgSend_stret")) + { + RegisterInstruction(i); + msgSend_types[&i] = eMsgSend_stret; + return true; + } + + if (!strcmp(name_cstr, "objc_msgSend_fpret")) + { + RegisterInstruction(i); + msgSend_types[&i] = eMsgSend_fpret; + return true; + } + + if (!strcmp(name_cstr, "objc_msgSendSuper")) + { + RegisterInstruction(i); + msgSend_types[&i] = eMsgSendSuper; + return true; + } + + if (!strcmp(name_cstr, "objc_msgSendSuper_stret")) + { + RegisterInstruction(i); + msgSend_types[&i] = eMsgSendSuper_stret; + return true; + } + + if (log) + log->Printf("Function name '%s' contains 'objc_msgSend' but is not handled", name_str.c_str()); + + return true; } return true; Modified: lldb/trunk/source/Expression/IRForTarget.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/IRForTarget.cpp?rev=144741&r1=144740&r2=144741&view=diff ============================================================================== --- lldb/trunk/source/Expression/IRForTarget.cpp (original) +++ lldb/trunk/source/Expression/IRForTarget.cpp Tue Nov 15 18:20:50 2011 @@ -205,6 +205,12 @@ name = g_memcpy_str; } break; + case Intrinsic::memset: + { + static lldb_private::ConstString g_memset_str ("memset"); + name = g_memset_str; + } + break; } if (log && name) From echristo at apple.com Tue Nov 15 18:31:09 2011 From: echristo at apple.com (Eric Christopher) Date: Tue, 15 Nov 2011 16:31:09 -0800 Subject: [Lldb-commits] [lldb] r144741 - in /lldb/trunk/source/Expression: IRDynamicChecks.cpp IRForTarget.cpp In-Reply-To: <20111116002050.CF7742A6C132@llvm.org> References: <20111116002050.CF7742A6C132@llvm.org> Message-ID: <10A809D5-C6F2-4CDF-9CD2-E535BB7B4C14@apple.com> On Nov 15, 2011, at 4:20 PM, Sean Callanan wrote: > + if (!strcmp(name_cstr, "objc_msgSend")) > + { > RegisterInstruction(i); > + msgSend_types[&i] = eMsgSend; > + return true; > + } > + ... > + if (!strcmp(name_cstr, "objc_msgSendSuper_stret")) > + { > + RegisterInstruction(i); > + msgSend_types[&i] = eMsgSendSuper_stret; > + return true; > + } For this kind of code you could use the llvm::StringSwitch and it'd look like: msgSend_types[&i] = llvm::StringSwitch(name_cstr) .case("objc_msgSend", eMsgSend) ? .Default(eMsgUnknown) if (msgSend_types[&I] != eMsgUnknown) RegisterInstruction(i) else log(?) return true; and probably save you some duplicated code :) -eric -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.cs.uiuc.edu/pipermail/lldb-commits/attachments/20111115/c36e3432/attachment.html From scallanan at apple.com Tue Nov 15 18:40:13 2011 From: scallanan at apple.com (Sean Callanan) Date: Wed, 16 Nov 2011 00:40:13 -0000 Subject: [Lldb-commits] [lldb] r144744 - /lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp Message-ID: <20111116004013.9C01E2A6C132@llvm.org> Author: spyffe Date: Tue Nov 15 18:40:13 2011 New Revision: 144744 URL: http://llvm.org/viewvc/llvm-project?rev=144744&view=rev Log: Fixed a crash when we merrily went on to try to log information about a nonexistent function declaration. Modified: lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp Modified: lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp?rev=144744&r1=144743&r2=144744&view=diff ============================================================================== --- lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp (original) +++ lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp Tue Nov 15 18:40:13 2011 @@ -2988,6 +2988,8 @@ fun_type->GetName().GetCString(), fun_type->GetID()); } + + return; } } else if (symbol) From scallanan at apple.com Tue Nov 15 19:54:58 2011 From: scallanan at apple.com (Sean Callanan) Date: Wed, 16 Nov 2011 01:54:58 -0000 Subject: [Lldb-commits] [lldb] r144760 - in /lldb/trunk: include/lldb/Target/Target.h source/Target/Target.cpp Message-ID: <20111116015458.357822A6C133@llvm.org> Author: spyffe Date: Tue Nov 15 19:54:57 2011 New Revision: 144760 URL: http://llvm.org/viewvc/llvm-project?rev=144760&view=rev Log: Fixed a problem where the target didn't use a NULL-terminated C string to store the contents of the expression prefix file. This meant that expressions, when printing the contents of the prefix into the expression's text, would invariably put in bad data after the end of the expression. Now, instead, we store the prefix contents in a std::string, which handles null-termination correctly. Modified: lldb/trunk/include/lldb/Target/Target.h lldb/trunk/source/Target/Target.cpp Modified: lldb/trunk/include/lldb/Target/Target.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/Target.h?rev=144760&r1=144759&r2=144760&view=diff ============================================================================== --- lldb/trunk/include/lldb/Target/Target.h (original) +++ lldb/trunk/include/lldb/Target/Target.h Tue Nov 15 19:54:57 2011 @@ -221,7 +221,7 @@ CreateInstanceName (); OptionValueFileSpec m_expr_prefix_file; - lldb::DataBufferSP m_expr_prefix_contents_sp; + std::string m_expr_prefix_contents; int m_prefer_dynamic_value; OptionValueBoolean m_skip_prologue; PathMappingList m_source_map; Modified: lldb/trunk/source/Target/Target.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/Target.cpp?rev=144760&r1=144759&r2=144760&view=diff ============================================================================== --- lldb/trunk/source/Target/Target.cpp (original) +++ lldb/trunk/source/Target/Target.cpp Tue Nov 15 19:54:57 2011 @@ -1430,8 +1430,8 @@ const char * Target::GetExpressionPrefixContentsAsCString () { - if (m_expr_prefix_contents_sp) - return (const char *)m_expr_prefix_contents_sp->GetBytes(); + if (!m_expr_prefix_contents.empty()) + return m_expr_prefix_contents.c_str(); return NULL; } @@ -2160,7 +2160,7 @@ ) : InstanceSettings (owner, name ? name : InstanceSettings::InvalidName().AsCString(), live_instance), m_expr_prefix_file (), - m_expr_prefix_contents_sp (), + m_expr_prefix_contents (), m_prefer_dynamic_value (2), m_skip_prologue (true, true), m_source_map (NULL, NULL), @@ -2198,7 +2198,7 @@ TargetInstanceSettings::TargetInstanceSettings (const TargetInstanceSettings &rhs) : InstanceSettings (*Target::GetSettingsController(), CreateInstanceName().AsCString()), m_expr_prefix_file (rhs.m_expr_prefix_file), - m_expr_prefix_contents_sp (rhs.m_expr_prefix_contents_sp), + m_expr_prefix_contents (rhs.m_expr_prefix_contents), m_prefer_dynamic_value (rhs.m_prefer_dynamic_value), m_skip_prologue (rhs.m_skip_prologue), m_source_map (rhs.m_source_map), @@ -2231,7 +2231,7 @@ if (this != &rhs) { m_expr_prefix_file = rhs.m_expr_prefix_file; - m_expr_prefix_contents_sp = rhs.m_expr_prefix_contents_sp; + m_expr_prefix_contents = rhs.m_expr_prefix_contents; m_prefer_dynamic_value = rhs.m_prefer_dynamic_value; m_skip_prologue = rhs.m_skip_prologue; m_source_map = rhs.m_source_map; @@ -2280,17 +2280,19 @@ return; } - m_expr_prefix_contents_sp = m_expr_prefix_file.GetCurrentValue().ReadFileContents(); - - if (!m_expr_prefix_contents_sp && m_expr_prefix_contents_sp->GetByteSize() == 0) + DataBufferSP file_contents = m_expr_prefix_file.GetCurrentValue().ReadFileContents(); + + if (!file_contents && file_contents->GetByteSize() == 0) { err.SetErrorStringWithFormat ("couldn't read data from '%s'", value); - m_expr_prefix_contents_sp.reset(); + m_expr_prefix_contents.clear(); } + + m_expr_prefix_contents.assign((const char*)file_contents->GetBytes(), file_contents->GetByteSize()); } break; case eVarSetOperationClear: - m_expr_prefix_contents_sp.reset(); + m_expr_prefix_contents.clear(); } } } From gclayton at apple.com Tue Nov 15 23:37:57 2011 From: gclayton at apple.com (Greg Clayton) Date: Wed, 16 Nov 2011 05:37:57 -0000 Subject: [Lldb-commits] [lldb] r144780 - in /lldb/trunk: include/lldb/Core/Debugger.h include/lldb/Host/Host.h include/lldb/Target/Process.h source/Core/Debugger.cpp source/Host/common/Host.cpp source/Host/macosx/Host.mm source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp source/Plugins/Process/gdb-remote/ProcessGDBRemote.h source/Target/Process.cpp Message-ID: <20111116053757.4E3E82A6C133@llvm.org> Author: gclayton Date: Tue Nov 15 23:37:56 2011 New Revision: 144780 URL: http://llvm.org/viewvc/llvm-project?rev=144780&view=rev Log: Made the darwin host layer properly reap any child processes that it spawns. After recent changes we weren't reaping child processes resulting in many zombie processes. This was fixed by adding more settings to the ProcessLaunchOptions class that allow clients to specify a callback function and baton to be notified when their process dies. If one is not supplied a default callback will be used that "does the right thing". Cleaned up a race condition in the ProcessGDBRemote class that would attempt to monitor when debugserver died. Added an extra boolean to the process monitor callbacks that indicate if a process exited or not. If your process exited with a zero exit status and no signal, both items could be zero. Modified the process monitor functions to not require a callback function in order to reap the child process. Modified: lldb/trunk/include/lldb/Core/Debugger.h lldb/trunk/include/lldb/Host/Host.h lldb/trunk/include/lldb/Target/Process.h lldb/trunk/source/Core/Debugger.cpp lldb/trunk/source/Host/common/Host.cpp lldb/trunk/source/Host/macosx/Host.mm lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h lldb/trunk/source/Target/Process.cpp Modified: lldb/trunk/include/lldb/Core/Debugger.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/Debugger.h?rev=144780&r1=144779&r2=144780&view=diff ============================================================================== --- lldb/trunk/include/lldb/Core/Debugger.h (original) +++ lldb/trunk/include/lldb/Core/Debugger.h Tue Nov 15 23:37:56 2011 @@ -260,6 +260,9 @@ static lldb::TargetSP FindTargetWithProcessID (lldb::pid_t pid); + + static lldb::TargetSP + FindTargetWithProcess (Process *process); static void Initialize (); Modified: lldb/trunk/include/lldb/Host/Host.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Host/Host.h?rev=144780&r1=144779&r2=144780&view=diff ============================================================================== --- lldb/trunk/include/lldb/Host/Host.h (original) +++ lldb/trunk/include/lldb/Host/Host.h Tue Nov 15 23:37:56 2011 @@ -29,6 +29,7 @@ public: typedef bool (*MonitorChildProcessCallback) (void *callback_baton, lldb::pid_t pid, + bool exited, int signal, // Zero for no signal int status); // Exit value of process if signal is zero Modified: lldb/trunk/include/lldb/Target/Process.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/Process.h?rev=144780&r1=144779&r2=144780&view=diff ============================================================================== --- lldb/trunk/include/lldb/Target/Process.h (original) +++ lldb/trunk/include/lldb/Target/Process.h Tue Nov 15 23:37:56 2011 @@ -35,6 +35,7 @@ #include "lldb/Expression/ClangPersistentVariables.h" #include "lldb/Expression/IRDynamicChecks.h" #include "lldb/Host/FileSpec.h" +#include "lldb/Host/Host.h" #include "lldb/Interpreter/Args.h" #include "lldb/Interpreter/Options.h" #include "lldb/Target/ExecutionContextScope.h" @@ -399,7 +400,7 @@ uint32_t m_egid; lldb::pid_t m_parent_pid; }; - + //---------------------------------------------------------------------- // ProcessLaunchInfo @@ -500,7 +501,15 @@ const char *working_directory, uint32_t launch_flags) : ProcessInfo(), - m_flags (launch_flags) + m_working_dir (), + m_plugin_name (), + m_shell (), + m_flags (launch_flags), + m_file_actions (), + m_resume_count (0), + m_monitor_callback (NULL), + m_monitor_callback_baton (NULL), + m_monitor_signals (false) { if (stderr_path) { @@ -715,6 +724,31 @@ bool ConvertArgumentsForLaunchingInShell (Error &error, bool localhost); + void + SetMonitorProcessCallback (Host::MonitorChildProcessCallback callback, + void *baton, + bool monitor_signals) + { + m_monitor_callback = callback; + m_monitor_callback_baton = baton; + m_monitor_signals = monitor_signals; + } + + bool + MonitorProcess () const + { + if (m_monitor_callback && ProcessIDIsValid()) + { + Host::StartMonitoringChildProcess (m_monitor_callback, + m_monitor_callback_baton, + GetProcessID(), + m_monitor_signals); + return true; + } + return false; + } + + protected: std::string m_working_dir; std::string m_plugin_name; @@ -722,6 +756,9 @@ Flags m_flags; // Bitwise OR of bits from lldb::LaunchFlags std::vector m_file_actions; // File actions for any other files uint32_t m_resume_count; // How many times do we resume after launching + Host::MonitorChildProcessCallback m_monitor_callback; + void *m_monitor_callback_baton; + bool m_monitor_signals; }; //---------------------------------------------------------------------- @@ -1360,6 +1397,7 @@ static bool SetProcessExitStatus (void *callback_baton, // The callback baton which should be set to NULL lldb::pid_t pid, // The process ID we want to monitor + bool exited, int signo, // Zero for no signal int status); // Exit value of process if signal is zero Modified: lldb/trunk/source/Core/Debugger.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/Debugger.cpp?rev=144780&r1=144779&r2=144780&view=diff ============================================================================== --- lldb/trunk/source/Core/Debugger.cpp (original) +++ lldb/trunk/source/Core/Debugger.cpp Tue Nov 15 23:37:56 2011 @@ -216,6 +216,22 @@ return target_sp; } +TargetSP +Debugger::FindTargetWithProcess (Process *process) +{ + TargetSP target_sp; + Mutex::Locker locker (GetDebuggerListMutex ()); + DebuggerList &debugger_list = GetDebuggerList(); + DebuggerList::iterator pos, end = debugger_list.end(); + for (pos = debugger_list.begin(); pos != end; ++pos) + { + target_sp = (*pos)->GetTargetList().FindTargetWithProcess (process); + if (target_sp) + break; + } + return target_sp; +} + Debugger::Debugger () : UserID (g_unique_id++), Modified: lldb/trunk/source/Host/common/Host.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/common/Host.cpp?rev=144780&r1=144779&r2=144780&view=diff ============================================================================== --- lldb/trunk/source/Host/common/Host.cpp (original) +++ lldb/trunk/source/Host/common/Host.cpp Tue Nov 15 23:37:56 2011 @@ -56,6 +56,8 @@ using namespace lldb; using namespace lldb_private; + +#if 1 // !defined (__APPLE__) struct MonitorInfo { lldb::pid_t pid; // The process ID to monitor @@ -77,25 +79,20 @@ ) { lldb::thread_t thread = LLDB_INVALID_HOST_THREAD; - if (callback) - { - std::auto_ptr info_ap(new MonitorInfo); - - info_ap->pid = pid; - info_ap->callback = callback; - info_ap->callback_baton = callback_baton; - info_ap->monitor_signals = monitor_signals; + MonitorInfo * info_ptr = new MonitorInfo(); - char thread_name[256]; - ::snprintf (thread_name, sizeof(thread_name), "", pid); - thread = ThreadCreate (thread_name, - MonitorChildProcessThreadFunction, - info_ap.get(), - NULL); - - if (IS_VALID_LLDB_HOST_THREAD(thread)) - info_ap.release(); - } + info_ptr->pid = pid; + info_ptr->callback = callback; + info_ptr->callback_baton = callback_baton; + info_ptr->monitor_signals = monitor_signals; + + char thread_name[256]; + ::snprintf (thread_name, sizeof(thread_name), "", pid); + thread = ThreadCreate (thread_name, + MonitorChildProcessThreadFunction, + info_ptr, + NULL); + return thread; } @@ -146,16 +143,15 @@ int status = -1; const int options = 0; - struct rusage *rusage = NULL; while (1) { log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_PROCESS); if (log) - log->Printf("%s ::wait4 (pid = %i, &status, options = %i, rusage = %p)...", function, pid, options, rusage); + log->Printf("%s ::wait_pid (pid = %i, &status, options = %i)...", function, pid, options); // Wait for all child processes ::pthread_testcancel (); - const lldb::pid_t wait_pid = ::wait4 (pid, &status, options, rusage); + const lldb::pid_t wait_pid = ::waitpid (pid, &status, options); ::pthread_testcancel (); if (wait_pid == -1) @@ -200,11 +196,10 @@ log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_PROCESS); if (log) - log->Printf ("%s ::wait4 (pid = %i, &status, options = %i, rusage = %p) => pid = %i, status = 0x%8.8x (%s), signal = %i, exit_state = %i", + log->Printf ("%s ::waitpid (pid = %i, &status, options = %i) => pid = %i, status = 0x%8.8x (%s), signal = %i, exit_state = %i", function, wait_pid, options, - rusage, pid, status, status_cstr, @@ -213,7 +208,9 @@ if (exited || (signal != 0 && monitor_signals)) { - bool callback_return = callback (callback_baton, pid, signal, exit_status); + bool callback_return = false; + if (callback) + callback_return = callback (callback_baton, pid, exited, signal, exit_status); // If our process exited, then this thread should exit if (exited) @@ -234,6 +231,8 @@ return NULL; } +#endif // #if !defined (__APPLE__) + size_t Host::GetPageSize() { Modified: lldb/trunk/source/Host/macosx/Host.mm URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/macosx/Host.mm?rev=144780&r1=144779&r2=144780&view=diff ============================================================================== --- lldb/trunk/source/Host/macosx/Host.mm (original) +++ lldb/trunk/source/Host/macosx/Host.mm Tue Nov 15 23:37:56 2011 @@ -1191,7 +1191,6 @@ return false; } - Error Host::LaunchProcess (ProcessLaunchInfo &launch_info) { @@ -1396,7 +1395,17 @@ if (pid != LLDB_INVALID_PROCESS_ID) { // If all went well, then set the process ID into the launch info - launch_info.SetProcessID(pid); + launch_info.SetProcessID(pid); + + // Make sure we reap any processes we spawn or we will have zombies. + if (!launch_info.MonitorProcess()) + { + const bool monitor_signals = false; + StartMonitoringChildProcess (Process::SetProcessExitStatus, + NULL, + pid, + monitor_signals); + } } else { @@ -1407,4 +1416,104 @@ return error; } +#if 0 +lldb::thread_t +Host::StartMonitoringChildProcess (Host::MonitorChildProcessCallback callback, + void *callback_baton, + lldb::pid_t pid, + bool monitor_signals) +{ + lldb::thread_t thread = LLDB_INVALID_HOST_THREAD; + unsigned long mask = DISPATCH_PROC_EXIT; + if (monitor_signals) + mask |= DISPATCH_PROC_SIGNAL; + + + dispatch_source_t source = ::dispatch_source_create (DISPATCH_SOURCE_TYPE_PROC, + pid, + mask, + ::dispatch_get_global_queue (DISPATCH_QUEUE_PRIORITY_DEFAULT,0)); + + printf ("Host::StartMonitoringChildProcess (callback=%p, baton=%p, pid=%i, monitor_signals=%i) source = %p\n", + callback, + callback_baton, + (int)pid, + monitor_signals, + source); + + if (source) + { + ::dispatch_source_set_cancel_handler (source, ^{ + printf ("::dispatch_source_set_cancel_handler (source=%p, ^{...\n", source); + ::dispatch_release (source); + }); + ::dispatch_source_set_event_handler (source, ^{ + + printf ("::dispatch_source_set_event_handler (source=%p, ^{...\n", source); + + int status= 0; + int wait_pid = 0; + bool cancel = false; + bool exited = false; + do + { + wait_pid = ::waitpid (pid, &status, 0); + } while (wait_pid < 0 && errno == EINTR); + + if (wait_pid >= 0) + { + int signal = 0; + int exit_status = 0; + const char *status_cstr = NULL; + if (WIFSTOPPED(status)) + { + signal = WSTOPSIG(status); + status_cstr = "STOPPED"; + } + else if (WIFEXITED(status)) + { + exit_status = WEXITSTATUS(status); + status_cstr = "EXITED"; + exited = true; + } + else if (WIFSIGNALED(status)) + { + signal = WTERMSIG(status); + status_cstr = "SIGNALED"; + exited = true; + exit_status = -1; + } + else + { + status_cstr = "???"; + } + + LogSP log (GetLogIfAllCategoriesSet (LIBLLDB_LOG_PROCESS)); + if (log) + log->Printf ("::waitpid (pid = %i, &status, 0) => pid = %i, status = 0x%8.8x (%s), signal = %i, exit_status = %i", + pid, + wait_pid, + status, + status_cstr, + signal, + exit_status); + + if (callback) + cancel = callback (callback_baton, pid, exited, signal, exit_status); + + if (exited) + { + printf ("::dispatch_source_set_event_handler (source=%p, ^{... dispatch_source_cancel(source);\n", source); + ::dispatch_source_cancel(source); + } + } + }); + + ::dispatch_resume (source); + } + return thread; +} + + +#endif 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=144780&r1=144779&r2=144780&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp (original) +++ lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp Tue Nov 15 23:37:56 2011 @@ -122,7 +122,6 @@ m_flags (0), m_gdb_comm(false), m_debugserver_pid (LLDB_INVALID_PROCESS_ID), - m_debugserver_thread (LLDB_INVALID_HOST_THREAD), m_last_stop_packet (), m_register_info (), m_async_broadcaster ("lldb.process.gdb-remote.async-broadcaster"), @@ -145,13 +144,6 @@ //---------------------------------------------------------------------- ProcessGDBRemote::~ProcessGDBRemote() { - if (IS_VALID_LLDB_HOST_THREAD(m_debugserver_thread)) - { - Host::ThreadCancel (m_debugserver_thread, NULL); - thread_result_t thread_result; - Host::ThreadJoin (m_debugserver_thread, &thread_result, NULL); - m_debugserver_thread = LLDB_INVALID_HOST_THREAD; - } // m_mach_process.UnregisterNotificationCallbacks (this); Clear(); // We need to call finalize on the process before destroying ourselves @@ -669,11 +661,6 @@ error.SetErrorString("not connected to remote gdb server"); return error; } - if (m_debugserver_pid != LLDB_INVALID_PROCESS_ID) - m_debugserver_thread = Host::StartMonitoringChildProcess (MonitorDebugserverProcess, - this, - m_debugserver_pid, - false); m_gdb_comm.ResetDiscoverableSettings(); m_gdb_comm.QueryNoAckModeSupported (); m_gdb_comm.GetThreadSuffixSupported (); @@ -2122,6 +2109,8 @@ log->Printf("%s arguments:\n%s", debugserver_args.GetArgumentAtIndex(0), strm.GetData()); } + launch_info.SetMonitorProcessCallback (MonitorDebugserverProcess, this, false); + error = Host::LaunchProcess(launch_info); if (error.Success ()) @@ -2148,61 +2137,85 @@ ( void *callback_baton, lldb::pid_t debugserver_pid, + bool exited, // True if the process did exit int signo, // Zero for no signal int exit_status // Exit value of process if signal is zero ) { - // We pass in the ProcessGDBRemote inferior process it and name it - // "gdb_remote_pid". The process ID is passed in the "callback_baton" - // pointer value itself, thus we need the double cast... + // The baton is a "ProcessGDBRemote *". Now this class might be gone + // and might not exist anymore, so we need to carefully try to get the + // target for this process first since we have a race condition when + // we are done running between getting the notice that the inferior + // process has died and the debugserver that was debugging this process. + // In our test suite, we are also continually running process after + // process, so we must be very careful to make sure: + // 1 - process object hasn't been deleted already + // 2 - that a new process object hasn't been recreated in its place // "debugserver_pid" argument passed in is the process ID for // debugserver that we are tracking... + LogSP log (ProcessGDBRemoteLog::GetLogIfAllCategoriesSet(GDBR_LOG_PROCESS)); ProcessGDBRemote *process = (ProcessGDBRemote *)callback_baton; - LogSP log (ProcessGDBRemoteLog::GetLogIfAllCategoriesSet(GDBR_LOG_PROCESS)); + // Get a shared pointer to the target that has a matching process pointer. + // This target could be gone, or the target could already have a new process + // object inside of it + TargetSP target_sp (Debugger::FindTargetWithProcess(process)); + if (log) log->Printf ("ProcessGDBRemote::MonitorDebugserverProcess (baton=%p, pid=%i, signo=%i (0x%x), exit_status=%i)", callback_baton, debugserver_pid, signo, signo, exit_status); - if (process) + if (target_sp) { - // Sleep for a half a second to make sure our inferior process has - // time to set its exit status before we set it incorrectly when - // both the debugserver and the inferior process shut down. - usleep (500000); - // If our process hasn't yet exited, debugserver might have died. - // If the process did exit, the we are reaping it. - const StateType state = process->GetState(); - - if (process->m_debugserver_pid != LLDB_INVALID_PROCESS_ID && - state != eStateInvalid && - state != eStateUnloaded && - state != eStateExited && - state != eStateDetached) - { - char error_str[1024]; - if (signo) - { - const char *signal_cstr = process->GetUnixSignals().GetSignalAsCString (signo); - if (signal_cstr) - ::snprintf (error_str, sizeof (error_str), DEBUGSERVER_BASENAME " died with signal %s", signal_cstr); + // We found a process in a target that matches, but another thread + // might be in the process of launching a new process that will + // soon replace it, so get a shared pointer to the process so we + // can keep it alive. + ProcessSP process_sp (target_sp->GetProcessSP()); + // Now we have a shared pointer to the process that can't go away on us + // so we now make sure it was the same as the one passed in, and also make + // sure that our previous "process *" didn't get deleted and have a new + // "process *" created in its place with the same pointer. To verify this + // we make sure the process has our debugserver process ID. If we pass all + // of these tests, then we are sure that this process is the one we were + // looking for. + if (process_sp && process == process_sp.get() && process->m_debugserver_pid == debugserver_pid) + { + // Sleep for a half a second to make sure our inferior process has + // time to set its exit status before we set it incorrectly when + // both the debugserver and the inferior process shut down. + usleep (500000); + // If our process hasn't yet exited, debugserver might have died. + // If the process did exit, the we are reaping it. + const StateType state = process->GetState(); + + if (process->m_debugserver_pid != LLDB_INVALID_PROCESS_ID && + state != eStateInvalid && + state != eStateUnloaded && + state != eStateExited && + state != eStateDetached) + { + char error_str[1024]; + if (signo) + { + const char *signal_cstr = process->GetUnixSignals().GetSignalAsCString (signo); + if (signal_cstr) + ::snprintf (error_str, sizeof (error_str), DEBUGSERVER_BASENAME " died with signal %s", signal_cstr); + else + ::snprintf (error_str, sizeof (error_str), DEBUGSERVER_BASENAME " died with signal %i", signo); + } else - ::snprintf (error_str, sizeof (error_str), DEBUGSERVER_BASENAME " died with signal %i", signo); - } - else - { - ::snprintf (error_str, sizeof (error_str), DEBUGSERVER_BASENAME " died with an exit status of 0x%8.8x", exit_status); - } + { + ::snprintf (error_str, sizeof (error_str), DEBUGSERVER_BASENAME " died with an exit status of 0x%8.8x", exit_status); + } - process->SetExitStatus (-1, error_str); + process->SetExitStatus (-1, error_str); + } + // Debugserver has exited we need to let our ProcessGDBRemote + // know that it no longer has a debugserver instance + process->m_debugserver_pid = LLDB_INVALID_PROCESS_ID; } - // Debugserver has exited we need to let our ProcessGDBRemote - // know that it no longer has a debugserver instance - process->m_debugserver_pid = LLDB_INVALID_PROCESS_ID; - // We are returning true to this function below, so we can - // forget about the monitor handle. - process->m_debugserver_thread = LLDB_INVALID_HOST_THREAD; } return true; } Modified: lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h?rev=144780&r1=144779&r2=144780&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h (original) +++ lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h Tue Nov 15 23:37:56 2011 @@ -279,7 +279,6 @@ lldb_private::Flags m_flags; // Process specific flags (see eFlags enums) GDBRemoteCommunicationClient m_gdb_comm; lldb::pid_t m_debugserver_pid; - lldb::thread_t m_debugserver_thread; StringExtractorGDBRemote m_last_stop_packet; GDBRemoteDynamicRegisterInfo m_register_info; lldb_private::Broadcaster m_async_broadcaster; @@ -308,8 +307,9 @@ static bool MonitorDebugserverProcess (void *callback_baton, lldb::pid_t pid, - int signo, // Zero for no signal - int exit_status); // Exit value of process if signal is zero + bool exited, + int signo, + int exit_status); lldb::StateType SetThreadStopInfo (StringExtractor& stop_packet); Modified: lldb/trunk/source/Target/Process.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/Process.cpp?rev=144780&r1=144779&r2=144780&view=diff ============================================================================== --- lldb/trunk/source/Target/Process.cpp (original) +++ lldb/trunk/source/Target/Process.cpp Tue Nov 15 23:37:56 2011 @@ -1136,15 +1136,23 @@ // found in the global target list (we want to be completely sure that the // lldb_private::Process doesn't go away before we can deliver the signal. bool -Process::SetProcessExitStatus -( - void *callback_baton, - lldb::pid_t pid, - int signo, // Zero for no signal - int exit_status // Exit value of process if signal is zero +Process::SetProcessExitStatus (void *callback_baton, + lldb::pid_t pid, + bool exited, + int signo, // Zero for no signal + int exit_status // Exit value of process if signal is zero ) { - if (signo == 0 || exit_status) + LogSP log(lldb_private::GetLogIfAnyCategoriesSet (LIBLLDB_LOG_PROCESS)); + if (log) + log->Printf ("Process::SetProcessExitStatus (baton=%p, pid=%i, exited=%i, signal=%i, exit_status=%i)\n", + callback_baton, + pid, + exited, + signo, + exit_status); + + if (exited) { TargetSP target_sp(Debugger::FindTargetWithProcessID (pid)); if (target_sp) From scallanan at apple.com Wed Nov 16 12:20:48 2011 From: scallanan at apple.com (Sean Callanan) Date: Wed, 16 Nov 2011 18:20:48 -0000 Subject: [Lldb-commits] [lldb] r144802 - in /lldb/trunk: include/lldb/Expression/ClangASTSource.h include/lldb/Symbol/ClangASTImporter.h include/lldb/Target/Target.h include/lldb/lldb-forward.h source/Expression/ClangASTSource.cpp source/Symbol/ClangASTImporter.cpp source/Target/Target.cpp Message-ID: <20111116182048.2D7FC1BE001@llvm.org> Author: spyffe Date: Wed Nov 16 12:20:47 2011 New Revision: 144802 URL: http://llvm.org/viewvc/llvm-project?rev=144802&view=rev Log: I made the ClangASTImporter owned by the target rather than individually on behalf of each ASTContext. This allows the ASTImporter to know about all containers of types, which will let it be smarter about forwarding information about type origins. That means that the following sequence of steps will be possible (after a few more changes): - Import a type from a Module's ASTContext into an expression parser ASTContext, tracking its origin information -- this works now. - Because the result of the expression uses that type, import it from the expression parser ASTContext into the Target's scratch AST context, forwarding the origin information -- this needs to be added. - For a later expression that uses the result, import the type from the Target's scratch AST context, still forwarding origin information -- this also needs to be added. - Use the intact origin information to complete the type as needed -- this works now if the origin information is present. To this end, I made the following changes: - ASTImporter top-level copy functions now require both a source and a destination AST context parameter. - The ASTImporter now knows how to purge records related to an ASTContext that is going away. - The Target now owns and creates the ASTImporter whenever the main executable changes or (in the absence of a main executable) on demand. Modified: lldb/trunk/include/lldb/Expression/ClangASTSource.h lldb/trunk/include/lldb/Symbol/ClangASTImporter.h lldb/trunk/include/lldb/Target/Target.h lldb/trunk/include/lldb/lldb-forward.h lldb/trunk/source/Expression/ClangASTSource.cpp lldb/trunk/source/Symbol/ClangASTImporter.cpp lldb/trunk/source/Target/Target.cpp Modified: lldb/trunk/include/lldb/Expression/ClangASTSource.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Expression/ClangASTSource.h?rev=144802&r1=144801&r2=144802&view=diff ============================================================================== --- lldb/trunk/include/lldb/Expression/ClangASTSource.h (original) +++ lldb/trunk/include/lldb/Expression/ClangASTSource.h Wed Nov 16 12:20:47 2011 @@ -50,6 +50,7 @@ m_ast_context (NULL), m_active_lookups () { + m_ast_importer = m_target->GetClangASTImporter(); } //------------------------------------------------------------------ @@ -71,13 +72,6 @@ void InstallASTContext (clang::ASTContext *ast_context) { - if (!m_ast_importer.get() || - m_ast_importer->TargetASTContext() != ast_context) - { - m_ast_importer.reset(new ClangASTImporter(ast_context)); - m_ast_importer->InstallMapCompleter(*this); - } - m_ast_context = ast_context; } @@ -329,8 +323,8 @@ bool m_lookups_enabled; const lldb::TargetSP m_target; ///< The target to use in finding variables and types. - clang::ASTContext *m_ast_context; ///< The parser's AST context, for copying types into - std::auto_ptr m_ast_importer; + clang::ASTContext *m_ast_context; ///< The AST context requests are coming in for. + ClangASTImporter *m_ast_importer; ///< The target's AST importer. std::set m_active_lookups; }; Modified: lldb/trunk/include/lldb/Symbol/ClangASTImporter.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Symbol/ClangASTImporter.h?rev=144802&r1=144801&r2=144802&view=diff ============================================================================== --- lldb/trunk/include/lldb/Symbol/ClangASTImporter.h (original) +++ lldb/trunk/include/lldb/Symbol/ClangASTImporter.h Wed Nov 16 12:20:47 2011 @@ -28,24 +28,19 @@ class ClangASTImporter { public: - ClangASTImporter (clang::ASTContext *target_ctx) : - m_file_manager(clang::FileSystemOptions()), - m_target_ctx(target_ctx) + ClangASTImporter () : + m_file_manager(clang::FileSystemOptions()) { } - clang::ASTContext * - TargetASTContext () - { - return m_target_ctx; - } - clang::QualType - CopyType (clang::ASTContext *src_ctx, + CopyType (clang::ASTContext *dst_ctx, + clang::ASTContext *src_ctx, clang::QualType type); clang::Decl * - CopyDecl (clang::ASTContext *src_ctx, + CopyDecl (clang::ASTContext *dst_ctx, + clang::ASTContext *src_ctx, clang::Decl *decl); void @@ -92,6 +87,8 @@ NamespaceMapSP GetNamespaceMap (const clang::NamespaceDecl *decl); void BuildNamespaceMap (const clang::NamespaceDecl *decl); + + void PurgeMaps (clang::ASTContext *dest_ast_ctx); private: struct DeclOrigin { @@ -130,13 +127,13 @@ { public: Minion (ClangASTImporter &master, - clang::ASTContext *source_ctx, - bool minimal) : - clang::ASTImporter(*master.m_target_ctx, + clang::ASTContext *target_ctx, + clang::ASTContext *source_ctx) : + clang::ASTImporter(*target_ctx, master.m_file_manager, *source_ctx, master.m_file_manager, - minimal), + true /*minimal*/), m_master(master), m_source_ctx(source_ctx) { @@ -149,24 +146,40 @@ }; typedef lldb::SharedPtr::Type MinionSP; - typedef std::map MinionMap; - MinionSP - GetMinion (clang::ASTContext *source_ctx, bool minimal) + struct MinionSpec { - MinionMap *minions; + clang::ASTContext *dst; + clang::ASTContext *src; - minimal = true; // This override is temporary, while I sort out the attendant issues. + MinionSpec (clang::ASTContext *_dst, + clang::ASTContext *_src) : + dst(_dst), + src(_src) + { + } - if (minimal) - minions = &m_minimal_minions; - else - minions = &m_minions; + bool operator<(const MinionSpec &rhs) const + { + if (dst < rhs.dst) + return true; + if (dst == rhs.dst && src < rhs.src) + return true; + return false; + } + }; + + typedef std::map MinionMap; + + MinionSP + GetMinion (clang::ASTContext *target_ctx, clang::ASTContext *source_ctx) + { + MinionSpec spec(target_ctx, source_ctx); - if (minions->find(source_ctx) == minions->end()) - (*minions)[source_ctx] = MinionSP(new Minion(*this, source_ctx, minimal)); + if (m_minions.find(spec) == m_minions.end()) + m_minions[spec] = MinionSP(new Minion(*this, target_ctx, source_ctx)); - return (*minions)[source_ctx]; + return m_minions[spec]; } DeclOrigin @@ -185,9 +198,7 @@ NamespaceMetaMap m_namespace_maps; NamespaceMapCompleter *m_map_completer; clang::FileManager m_file_manager; - clang::ASTContext *m_target_ctx; MinionMap m_minions; - MinionMap m_minimal_minions; OriginMap m_origins; }; Modified: lldb/trunk/include/lldb/Target/Target.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/Target.h?rev=144802&r1=144801&r2=144802&view=diff ============================================================================== --- lldb/trunk/include/lldb/Target/Target.h (original) +++ lldb/trunk/include/lldb/Target/Target.h Wed Nov 16 12:20:47 2011 @@ -801,6 +801,9 @@ ClangASTContext * GetScratchClangASTContext(); + ClangASTImporter * + GetClangASTImporter(); + const char * GetExpressionPrefixContentsAsCString (); @@ -1054,6 +1057,7 @@ PathMappingList m_image_search_paths; std::auto_ptr m_scratch_ast_context_ap; std::auto_ptr m_scratch_ast_source_ap; + std::auto_ptr m_ast_importer_ap; ClangPersistentVariables m_persistent_variables; ///< These are the persistent variables associated with this process for the expression parser. SourceManager m_source_manager; Modified: lldb/trunk/include/lldb/lldb-forward.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/lldb-forward.h?rev=144802&r1=144801&r2=144802&view=diff ============================================================================== --- lldb/trunk/include/lldb/lldb-forward.h (original) +++ lldb/trunk/include/lldb/lldb-forward.h Wed Nov 16 12:20:47 2011 @@ -41,6 +41,7 @@ class Broadcaster; class CPPLanguageRuntime; class ClangASTContext; +class ClangASTImporter; class ClangASTSource; class ClangASTType; class ClangNamespaceDecl; Modified: lldb/trunk/source/Expression/ClangASTSource.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/ClangASTSource.cpp?rev=144802&r1=144801&r2=144802&view=diff ============================================================================== --- lldb/trunk/source/Expression/ClangASTSource.cpp (original) +++ lldb/trunk/source/Expression/ClangASTSource.cpp Wed Nov 16 12:20:47 2011 @@ -24,6 +24,7 @@ ClangASTSource::~ClangASTSource() { + m_ast_importer->PurgeMaps(m_ast_context); } void @@ -249,7 +250,7 @@ log->Printf(" FELD[%d] Adding lexical decl %s", current_id, ast_dumper.GetCString()); } - Decl *copied_decl = m_ast_importer->CopyDecl(original_ctx, decl); + Decl *copied_decl = m_ast_importer->CopyDecl(m_ast_context, original_ctx, decl); decls.push_back(copied_decl); } @@ -551,7 +552,7 @@ if (found_interface_decl->getName() == interface_decl->getName()) { - Decl *copied_decl = m_ast_importer->CopyDecl(&method_decl->getASTContext(), method_decl); + Decl *copied_decl = m_ast_importer->CopyDecl(m_ast_context, &method_decl->getASTContext(), method_decl); if (!copied_decl) continue; @@ -610,7 +611,7 @@ if (!property_decl) return; - Decl *copied_decl = m_ast_importer->CopyDecl(orig_ast_ctx, property_decl); + Decl *copied_decl = m_ast_importer->CopyDecl(m_ast_context, orig_ast_ctx, property_decl); if (!copied_decl) return; @@ -734,7 +735,7 @@ const ClangNamespaceDecl &namespace_decl = namespace_decls->begin()->second; - Decl *copied_decl = m_ast_importer->CopyDecl(namespace_decl.GetASTContext(), namespace_decl.GetNamespaceDecl()); + Decl *copied_decl = m_ast_importer->CopyDecl(m_ast_context, namespace_decl.GetASTContext(), namespace_decl.GetNamespaceDecl()); NamespaceDecl *copied_namespace_decl = dyn_cast(copied_decl); @@ -750,7 +751,7 @@ { SetImportInProgress(true); - QualType ret_qual_type = m_ast_importer->CopyType (source_context, QualType::getFromOpaquePtr(clang_type)); + QualType ret_qual_type = m_ast_importer->CopyType (m_ast_context, source_context, QualType::getFromOpaquePtr(clang_type)); void *ret = ret_qual_type.getAsOpaquePtr(); Modified: lldb/trunk/source/Symbol/ClangASTImporter.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/ClangASTImporter.cpp?rev=144802&r1=144801&r2=144802&view=diff ============================================================================== --- lldb/trunk/source/Symbol/ClangASTImporter.cpp (original) +++ lldb/trunk/source/Symbol/ClangASTImporter.cpp Wed Nov 16 12:20:47 2011 @@ -19,10 +19,11 @@ using namespace clang; clang::QualType -ClangASTImporter::CopyType (clang::ASTContext *src_ast, +ClangASTImporter::CopyType (clang::ASTContext *dst_ast, + clang::ASTContext *src_ast, clang::QualType type) { - MinionSP minion_sp (GetMinion(src_ast, false)); + MinionSP minion_sp (GetMinion(dst_ast, src_ast)); if (minion_sp) return minion_sp->Import(type); @@ -31,15 +32,13 @@ } clang::Decl * -ClangASTImporter::CopyDecl (clang::ASTContext *src_ast, +ClangASTImporter::CopyDecl (clang::ASTContext *dst_ast, + clang::ASTContext *src_ast, clang::Decl *decl) { MinionSP minion_sp; - if (isa(decl)) - minion_sp = GetMinion(src_ast, true); - else - minion_sp = GetMinion(src_ast, false); + minion_sp = GetMinion(dst_ast, src_ast); if (minion_sp) { @@ -77,7 +76,7 @@ if (!ClangASTContext::GetCompleteDecl(decl_origin.ctx, decl_origin.decl)) return; - MinionSP minion_sp (GetMinion(decl_origin.ctx, false)); + MinionSP minion_sp (GetMinion(&decl->getASTContext(), decl_origin.ctx)); if (minion_sp) minion_sp->ImportDefinition(decl_origin.decl); @@ -98,7 +97,7 @@ if (!ClangASTContext::GetCompleteDecl(decl_origin.ctx, decl_origin.decl)) return; - MinionSP minion_sp (GetMinion(decl_origin.ctx, false)); + MinionSP minion_sp (GetMinion(&interface_decl->getASTContext(), decl_origin.ctx)); if (minion_sp) minion_sp->ImportDefinition(decl_origin.decl); @@ -148,6 +147,18 @@ RegisterNamespaceMap (decl, new_map); } +void +ClangASTImporter::PurgeMaps (clang::ASTContext *dst_ast) +{ + for (MinionMap::iterator i = m_minions.begin(); i != m_minions.end(); ) + { + if ((*i).first.dst == dst_ast) + m_minions.erase(i++); + else + ++i; + } +} + ClangASTImporter::NamespaceMapCompleter::~NamespaceMapCompleter () { return; Modified: lldb/trunk/source/Target/Target.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/Target.cpp?rev=144802&r1=144801&r2=144802&view=diff ============================================================================== --- lldb/trunk/source/Target/Target.cpp (original) +++ lldb/trunk/source/Target/Target.cpp Wed Nov 16 12:20:47 2011 @@ -61,6 +61,8 @@ m_search_filter_sp (), m_image_search_paths (ImageSearchPathsChanged, this), m_scratch_ast_context_ap (NULL), + m_scratch_ast_source_ap (NULL), + m_ast_importer_ap (NULL), m_persistent_variables (), m_source_manager(*this), m_stop_hooks (), @@ -173,6 +175,7 @@ m_image_search_paths.Clear(notify); m_scratch_ast_context_ap.reset(); m_scratch_ast_source_ap.reset(); + m_ast_importer_ap.reset(); m_persistent_variables.Clear(); m_stop_hooks.clear(); m_stop_hook_next_id = 0; @@ -797,6 +800,7 @@ m_images.Clear(); m_scratch_ast_context_ap.reset(); m_scratch_ast_source_ap.reset(); + m_ast_importer_ap.reset(); if (executable_sp.get()) { @@ -837,6 +841,7 @@ } } + m_ast_importer_ap.reset(new ClangASTImporter()); } UpdateInstanceName(); @@ -865,6 +870,8 @@ ModuleSP executable_sp = GetExecutableModule (); m_images.Clear(); m_scratch_ast_context_ap.reset(); + m_scratch_ast_source_ap.reset(); + m_ast_importer_ap.reset(); // Need to do something about unsetting breakpoints. if (executable_sp) @@ -1342,6 +1349,20 @@ return m_scratch_ast_context_ap.get(); } +ClangASTImporter * +Target::GetClangASTImporter() +{ + ClangASTImporter *ast_importer = m_ast_importer_ap.get(); + + if (!ast_importer) + { + ast_importer = new ClangASTImporter(); + m_ast_importer_ap.reset(ast_importer); + } + + return ast_importer; +} + void Target::SettingsInitialize () { From johnny.chen at apple.com Wed Nov 16 12:48:48 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Wed, 16 Nov 2011 18:48:48 -0000 Subject: [Lldb-commits] [lldb] r144807 - /lldb/trunk/test/dosep.ty Message-ID: <20111116184848.D40361BE001@llvm.org> Author: johnny Date: Wed Nov 16 12:48:48 2011 New Revision: 144807 URL: http://llvm.org/viewvc/llvm-project?rev=144807&view=rev Log: Remove invalid docstring (due to cut-and-paste error). Modified: lldb/trunk/test/dosep.ty Modified: lldb/trunk/test/dosep.ty URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/dosep.ty?rev=144807&r1=144806&r2=144807&view=diff ============================================================================== --- lldb/trunk/test/dosep.ty (original) +++ lldb/trunk/test/dosep.ty Wed Nov 16 12:48:48 2011 @@ -29,7 +29,6 @@ os.system(command) def main(): - """Read the root dir and the path spec, invoke lldb-disasm.py on the file.""" test_root = sys.path[0] parser = OptionParser(usage="""\ From scallanan at apple.com Wed Nov 16 13:07:39 2011 From: scallanan at apple.com (Sean Callanan) Date: Wed, 16 Nov 2011 19:07:39 -0000 Subject: [Lldb-commits] [lldb] r144813 - in /lldb/trunk: include/lldb/Symbol/ClangASTImporter.h source/Symbol/ClangASTImporter.cpp Message-ID: <20111116190739.70F171BE001@llvm.org> Author: spyffe Date: Wed Nov 16 13:07:39 2011 New Revision: 144813 URL: http://llvm.org/viewvc/llvm-project?rev=144813&view=rev Log: Added a CopyType method to the ASTImporter that handles opaque QualTypes. Modified: lldb/trunk/include/lldb/Symbol/ClangASTImporter.h lldb/trunk/source/Symbol/ClangASTImporter.cpp Modified: lldb/trunk/include/lldb/Symbol/ClangASTImporter.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Symbol/ClangASTImporter.h?rev=144813&r1=144812&r2=144813&view=diff ============================================================================== --- lldb/trunk/include/lldb/Symbol/ClangASTImporter.h (original) +++ lldb/trunk/include/lldb/Symbol/ClangASTImporter.h Wed Nov 16 13:07:39 2011 @@ -38,6 +38,11 @@ clang::ASTContext *src_ctx, clang::QualType type); + lldb::clang_type_t + CopyType (clang::ASTContext *dst_ctx, + clang::ASTContext *src_ctx, + lldb::clang_type_t type); + clang::Decl * CopyDecl (clang::ASTContext *dst_ctx, clang::ASTContext *src_ctx, Modified: lldb/trunk/source/Symbol/ClangASTImporter.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/ClangASTImporter.cpp?rev=144813&r1=144812&r2=144813&view=diff ============================================================================== --- lldb/trunk/source/Symbol/ClangASTImporter.cpp (original) +++ lldb/trunk/source/Symbol/ClangASTImporter.cpp Wed Nov 16 13:07:39 2011 @@ -31,6 +31,14 @@ return QualType(); } +lldb::clang_type_t +ClangASTImporter::CopyType (clang::ASTContext *dst_ast, + clang::ASTContext *src_ast, + lldb::clang_type_t type) +{ + return CopyType (dst_ast, src_ast, QualType::getFromOpaquePtr(type)).getAsOpaquePtr(); +} + clang::Decl * ClangASTImporter::CopyDecl (clang::ASTContext *dst_ast, clang::ASTContext *src_ast, From scallanan at apple.com Wed Nov 16 15:40:57 2011 From: scallanan at apple.com (Sean Callanan) Date: Wed, 16 Nov 2011 21:40:57 -0000 Subject: [Lldb-commits] [lldb] r144835 - in /lldb/trunk: include/lldb/Symbol/ClangASTImporter.h source/Symbol/ClangASTImporter.cpp Message-ID: <20111116214057.C80341BE001@llvm.org> Author: spyffe Date: Wed Nov 16 15:40:57 2011 New Revision: 144835 URL: http://llvm.org/viewvc/llvm-project?rev=144835&view=rev Log: Changed the ClangASTImporter to store metadata for each AST context it knows about in a single object. This makes it faster to look up the appropriate ASTImpoter for a given ASTContext pair and also makes it much easier to delete all metadata for a given AST context. In the future, this fix will allow the ClangASTImporter to propagate completion information between the metadata for different AST contexts as its minions move AST objects around. Modified: lldb/trunk/include/lldb/Symbol/ClangASTImporter.h lldb/trunk/source/Symbol/ClangASTImporter.cpp Modified: lldb/trunk/include/lldb/Symbol/ClangASTImporter.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Symbol/ClangASTImporter.h?rev=144835&r1=144834&r2=144835&view=diff ============================================================================== --- lldb/trunk/include/lldb/Symbol/ClangASTImporter.h (original) +++ lldb/trunk/include/lldb/Symbol/ClangASTImporter.h Wed Nov 16 15:40:57 2011 @@ -84,9 +84,22 @@ NamespaceMapSP &parent_map) const = 0; }; - void InstallMapCompleter (NamespaceMapCompleter &completer) + void InstallMapCompleter (clang::ASTContext *dst_ctx, NamespaceMapCompleter &completer) { - m_map_completer = &completer; + ASTContextMetadataSP context_md; + ContextMetadataMap::iterator context_md_iter = m_metadata_map.find(dst_ctx); + + if (context_md_iter == m_metadata_map.end()) + { + context_md = ASTContextMetadataSP(new ASTContextMetadata(dst_ctx)); + m_metadata_map[dst_ctx] = context_md; + } + else + { + context_md = context_md_iter->second; + } + + context_md->m_map_completer = &completer; } NamespaceMapSP GetNamespaceMap (const clang::NamespaceDecl *decl); @@ -150,61 +163,78 @@ clang::ASTContext *m_source_ctx; }; - typedef lldb::SharedPtr::Type MinionSP; + typedef lldb::SharedPtr::Type MinionSP; + + typedef std::map MinionMap; - struct MinionSpec + typedef std::map NamespaceMetaMap; + + struct ASTContextMetadata { - clang::ASTContext *dst; - clang::ASTContext *src; - - MinionSpec (clang::ASTContext *_dst, - clang::ASTContext *_src) : - dst(_dst), - src(_src) + ASTContextMetadata(clang::ASTContext *dst_ctx) : + m_dst_ctx (dst_ctx), + m_minions (), + m_origins (), + m_namespace_maps (), + m_map_completer (NULL) { } - bool operator<(const MinionSpec &rhs) const - { - if (dst < rhs.dst) - return true; - if (dst == rhs.dst && src < rhs.src) - return true; - return false; - } + clang::ASTContext *m_dst_ctx; + MinionMap m_minions; + OriginMap m_origins; + + NamespaceMetaMap m_namespace_maps; + NamespaceMapCompleter *m_map_completer; }; - typedef std::map MinionMap; + typedef lldb::SharedPtr::Type ASTContextMetadataSP; - MinionSP - GetMinion (clang::ASTContext *target_ctx, clang::ASTContext *source_ctx) + typedef std::map ContextMetadataMap; + + ContextMetadataMap m_metadata_map; + + ASTContextMetadataSP + GetContextMetadata (clang::ASTContext *dst_ctx) { - MinionSpec spec(target_ctx, source_ctx); + ContextMetadataMap::iterator context_md_iter = m_metadata_map.find(dst_ctx); - if (m_minions.find(spec) == m_minions.end()) - m_minions[spec] = MinionSP(new Minion(*this, target_ctx, source_ctx)); - - return m_minions[spec]; + if (context_md_iter == m_metadata_map.end()) + { + ASTContextMetadataSP context_md = ASTContextMetadataSP(new ASTContextMetadata(dst_ctx)); + m_metadata_map[dst_ctx] = context_md; + return context_md; + } + else + { + return context_md_iter->second; + } } - DeclOrigin - GetDeclOrigin (const clang::Decl *decl) + MinionSP + GetMinion (clang::ASTContext *dst_ctx, clang::ASTContext *src_ctx) { - OriginMap::iterator iter = m_origins.find(decl); + ASTContextMetadataSP context_md = GetContextMetadata(dst_ctx); - if (iter != m_origins.end()) - return iter->second; + MinionMap &minions = context_md->m_minions; + MinionMap::iterator minion_iter = minions.find(src_ctx); + + if (minion_iter == minions.end()) + { + MinionSP minion = MinionSP(new Minion(*this, dst_ctx, src_ctx)); + minions[src_ctx] = minion; + return minion; + } else - return DeclOrigin(); + { + return minion_iter->second; + } } - typedef std::map NamespaceMetaMap; - - NamespaceMetaMap m_namespace_maps; - NamespaceMapCompleter *m_map_completer; + DeclOrigin + GetDeclOrigin (const clang::Decl *decl); + clang::FileManager m_file_manager; - MinionMap m_minions; - OriginMap m_origins; }; } Modified: lldb/trunk/source/Symbol/ClangASTImporter.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/ClangASTImporter.cpp?rev=144835&r1=144834&r2=144835&view=diff ============================================================================== --- lldb/trunk/source/Symbol/ClangASTImporter.cpp (original) +++ lldb/trunk/source/Symbol/ClangASTImporter.cpp Wed Nov 16 15:40:57 2011 @@ -113,19 +113,40 @@ return; } +ClangASTImporter::DeclOrigin +ClangASTImporter::GetDeclOrigin(const clang::Decl *decl) +{ + ASTContextMetadataSP context_md = GetContextMetadata(&decl->getASTContext()); + + OriginMap &origins = context_md->m_origins; + + OriginMap::iterator iter = origins.find(decl); + + if (iter != origins.end()) + return iter->second; + else + return DeclOrigin(); +} + void ClangASTImporter::RegisterNamespaceMap(const clang::NamespaceDecl *decl, NamespaceMapSP &namespace_map) { - m_namespace_maps[decl] = namespace_map; + ASTContextMetadataSP context_md = GetContextMetadata(&decl->getASTContext()); + + context_md->m_namespace_maps[decl] = namespace_map; } ClangASTImporter::NamespaceMapSP ClangASTImporter::GetNamespaceMap(const clang::NamespaceDecl *decl) { - NamespaceMetaMap::iterator iter = m_namespace_maps.find(decl); + ASTContextMetadataSP context_md = GetContextMetadata(&decl->getASTContext()); + + NamespaceMetaMap &namespace_maps = context_md->m_namespace_maps; - if (iter != m_namespace_maps.end()) + NamespaceMetaMap::iterator iter = namespace_maps.find(decl); + + if (iter != namespace_maps.end()) return iter->second; else return NamespaceMapSP(); @@ -134,6 +155,8 @@ void ClangASTImporter::BuildNamespaceMap(const clang::NamespaceDecl *decl) { + ASTContextMetadataSP context_md = GetContextMetadata(&decl->getASTContext()); + const DeclContext *parent_context = decl->getDeclContext(); const NamespaceDecl *parent_namespace = dyn_cast(parent_context); NamespaceMapSP parent_map; @@ -145,11 +168,11 @@ new_map.reset(new NamespaceMap); - if (m_map_completer) + if (context_md->m_map_completer) { std::string namespace_string = decl->getDeclName().getAsString(); - m_map_completer->CompleteNamespaceMap (new_map, ConstString(namespace_string.c_str()), parent_map); + context_md->m_map_completer->CompleteNamespaceMap (new_map, ConstString(namespace_string.c_str()), parent_map); } RegisterNamespaceMap (decl, new_map); @@ -158,13 +181,7 @@ void ClangASTImporter::PurgeMaps (clang::ASTContext *dst_ast) { - for (MinionMap::iterator i = m_minions.begin(); i != m_minions.end(); ) - { - if ((*i).first.dst == dst_ast) - m_minions.erase(i++); - else - ++i; - } + m_metadata_map.erase(dst_ast); } ClangASTImporter::NamespaceMapCompleter::~NamespaceMapCompleter () @@ -177,7 +194,9 @@ { lldb::LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS)); - m_master.m_origins[to] = DeclOrigin (m_source_ctx, from); + ASTContextMetadataSP context_md = m_master.GetContextMetadata(&to->getASTContext()); + + context_md->m_origins[to] = DeclOrigin (m_source_ctx, from); if (TagDecl *from_tag_decl = dyn_cast(from)) { From scallanan at apple.com Wed Nov 16 16:23:29 2011 From: scallanan at apple.com (Sean Callanan) Date: Wed, 16 Nov 2011 22:23:29 -0000 Subject: [Lldb-commits] [lldb] r144838 - in /lldb/trunk: include/lldb/Symbol/ClangASTImporter.h source/Symbol/ClangASTImporter.cpp Message-ID: <20111116222329.3552B1BE001@llvm.org> Author: spyffe Date: Wed Nov 16 16:23:28 2011 New Revision: 144838 URL: http://llvm.org/viewvc/llvm-project?rev=144838&view=rev Log: Added support to the ASTImporter for passing completion information between different AST contexts. It works like this: - If a Decl is imported from a context that has completion metadata, then that Decl is associated with the same completion information (possibly none) as the Decl it was imported from. - If a Decl is imported from a context that does not have completion metadata, then it is marked as completable by consulting the Decl and context it was imported from. Modified: lldb/trunk/include/lldb/Symbol/ClangASTImporter.h lldb/trunk/source/Symbol/ClangASTImporter.cpp Modified: lldb/trunk/include/lldb/Symbol/ClangASTImporter.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Symbol/ClangASTImporter.h?rev=144838&r1=144837&r2=144838&view=diff ============================================================================== --- lldb/trunk/include/lldb/Symbol/ClangASTImporter.h (original) +++ lldb/trunk/include/lldb/Symbol/ClangASTImporter.h Wed Nov 16 16:23:28 2011 @@ -211,6 +211,17 @@ } } + ASTContextMetadataSP + MaybeGetContextMetadata (clang::ASTContext *dst_ctx) + { + ContextMetadataMap::iterator context_md_iter = m_metadata_map.find(dst_ctx); + + if (context_md_iter != m_metadata_map.end()) + return context_md_iter->second; + else + return ASTContextMetadataSP(); + } + MinionSP GetMinion (clang::ASTContext *dst_ctx, clang::ASTContext *src_ctx) { Modified: lldb/trunk/source/Symbol/ClangASTImporter.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/ClangASTImporter.cpp?rev=144838&r1=144837&r2=144838&view=diff ============================================================================== --- lldb/trunk/source/Symbol/ClangASTImporter.cpp (original) +++ lldb/trunk/source/Symbol/ClangASTImporter.cpp Wed Nov 16 16:23:28 2011 @@ -194,10 +194,35 @@ { lldb::LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS)); - ASTContextMetadataSP context_md = m_master.GetContextMetadata(&to->getASTContext()); + ASTContextMetadataSP to_context_md = m_master.GetContextMetadata(&to->getASTContext()); + ASTContextMetadataSP from_context_md = m_master.MaybeGetContextMetadata(m_source_ctx); - context_md->m_origins[to] = DeclOrigin (m_source_ctx, from); - + if (from_context_md) + { + OriginMap &origins = from_context_md->m_origins; + + OriginMap::iterator origin_iter = origins.find(from); + + if (origin_iter != origins.end()) + to_context_md->m_origins[to] = origin_iter->second; + + if (clang::NamespaceDecl *to_namespace = dyn_cast(to)) + { + clang::NamespaceDecl *from_namespace = dyn_cast(from); + + NamespaceMetaMap &namespace_maps = from_context_md->m_namespace_maps; + + NamespaceMetaMap::iterator namespace_map_iter = namespace_maps.find(from_namespace); + + if (namespace_map_iter != namespace_maps.end()) + to_context_md->m_namespace_maps[to_namespace] = namespace_map_iter->second; + } + } + else + { + to_context_md->m_origins[to] = DeclOrigin (m_source_ctx, from); + } + if (TagDecl *from_tag_decl = dyn_cast(from)) { TagDecl *to_tag_decl = dyn_cast(to); From johnny.chen at apple.com Wed Nov 16 16:41:54 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Wed, 16 Nov 2011 22:41:54 -0000 Subject: [Lldb-commits] [lldb] r144846 - /lldb/trunk/test/lldbtest.py Message-ID: <20111116224154.2D0A31BE001@llvm.org> Author: johnny Date: Wed Nov 16 16:41:53 2011 New Revision: 144846 URL: http://llvm.org/viewvc/llvm-project?rev=144846&view=rev Log: Also dump the pid of the process launching through the lldbtest.system(*popenargs, **kwargs) API. This helps track down possible zombie processes. Modified: lldb/trunk/test/lldbtest.py Modified: lldb/trunk/test/lldbtest.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/lldbtest.py?rev=144846&r1=144845&r2=144846&view=diff ============================================================================== --- lldb/trunk/test/lldbtest.py (original) +++ lldb/trunk/test/lldbtest.py Wed Nov 16 16:41:53 2011 @@ -296,6 +296,7 @@ if 'stdout' in kwargs: raise ValueError('stdout argument not allowed, it will be overridden.') process = Popen(stdout=PIPE, stderr=PIPE, *popenargs, **kwargs) + pid = process.pid output, error = process.communicate() retcode = process.poll() @@ -306,6 +307,7 @@ args = list(popenargs) print >> sbuf print >> sbuf, "os command:", args + print >> sbuf, "with pid:", pid print >> sbuf, "stdout:", output print >> sbuf, "stderr:", error print >> sbuf, "retcode:", retcode From johnny.chen at apple.com Wed Nov 16 16:44:28 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Wed, 16 Nov 2011 22:44:28 -0000 Subject: [Lldb-commits] [lldb] r144848 - /lldb/trunk/test/lldbtest.py Message-ID: <20111116224428.4D6BD1BE001@llvm.org> Author: johnny Date: Wed Nov 16 16:44:28 2011 New Revision: 144848 URL: http://llvm.org/viewvc/llvm-project?rev=144848&view=rev Log: Docstring clarification. Modified: lldb/trunk/test/lldbtest.py Modified: lldb/trunk/test/lldbtest.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/lldbtest.py?rev=144848&r1=144847&r2=144848&view=diff ============================================================================== --- lldb/trunk/test/lldbtest.py (original) +++ lldb/trunk/test/lldbtest.py Wed Nov 16 16:44:28 2011 @@ -270,7 +270,7 @@ # From 2.7's subprocess.check_output() convenience function. # Return a tuple (stdoutdata, stderrdata). def system(*popenargs, **kwargs): - r"""Run command with arguments and return its output as a byte string. + r"""Run an os command with arguments and return its output as a byte string. If the exit code was non-zero it raises a CalledProcessError. The CalledProcessError object will have the return code in the returncode From clattner at apple.com Wed Nov 16 19:15:38 2011 From: clattner at apple.com (Chris Lattner) Date: Wed, 16 Nov 2011 17:15:38 -0800 Subject: [Lldb-commits] [lldb] r144562 - in /lldb/trunk: lldb.xcodeproj/project.pbxproj source/Interpreter/CommandInterpreter.cpp In-Reply-To: References: <20111114200202.379602A6C131@llvm.org> Message-ID: Jim? -Chris On Nov 14, 2011, at 3:37 PM, Chris Lattner wrote: > On Nov 14, 2011, at 12:47 PM, Jim Ingham wrote: >> The curse of a shared Scheme is you fight over incidental settings like this... I'm not sure why you would want to build a Debug version of lldb against the Release version of the LLVM libraries, so I think my setting is more useful. Whoever likes the Release version better will probably overwrite my setting the next time they commit ;-) > > Ok, please fix this though: > >>>> @@ -1807,7 +1807,7 @@ >>>> { >>>> if (out_file.IsValid() && !reader.IsDone() && reader.GetPrompt()) >>>> { >>>> - out_file.Printf ("Please answer \"y\" or \"n\"\n%s", reader.GetPrompt()); >>>> + out_file.Printf ("Please answer \"y\" or \"Y\" or \"n\" or \"N\"\n%s", reader.GetPrompt()); >>>> out_file.Flush (); >>>> } >>> >>> There is no need to be exhaustive here, just ask for y/n and accept both cases. >>> >>> -Chris >>> >> > > _______________________________________________ > lldb-commits mailing list > lldb-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/lldb-commits From jingham at apple.com Wed Nov 16 19:22:00 2011 From: jingham at apple.com (Jim Ingham) Date: Thu, 17 Nov 2011 01:22:00 -0000 Subject: [Lldb-commits] [lldb] r144874 - /lldb/trunk/source/Interpreter/CommandInterpreter.cpp Message-ID: <20111117012200.E27F61BE001@llvm.org> Author: jingham Date: Wed Nov 16 19:22:00 2011 New Revision: 144874 URL: http://llvm.org/viewvc/llvm-project?rev=144874&view=rev Log: (empty) Modified: lldb/trunk/source/Interpreter/CommandInterpreter.cpp Modified: lldb/trunk/source/Interpreter/CommandInterpreter.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Interpreter/CommandInterpreter.cpp?rev=144874&r1=144873&r2=144874&view=diff ============================================================================== --- lldb/trunk/source/Interpreter/CommandInterpreter.cpp (original) +++ lldb/trunk/source/Interpreter/CommandInterpreter.cpp Wed Nov 16 19:22:00 2011 @@ -1807,7 +1807,7 @@ { if (out_file.IsValid() && !reader.IsDone() && reader.GetPrompt()) { - out_file.Printf ("Please answer \"y\" or \"Y\" or \"n\" or \"N\"\n%s", reader.GetPrompt()); + out_file.Printf ("Please answer \"y\" or \"n\".\n%s", reader.GetPrompt()); out_file.Flush (); } } From jingham at apple.com Wed Nov 16 19:25:01 2011 From: jingham at apple.com (Jim Ingham) Date: Wed, 16 Nov 2011 17:25:01 -0800 Subject: [Lldb-commits] [lldb] r144562 - in /lldb/trunk: lldb.xcodeproj/project.pbxproj source/Interpreter/CommandInterpreter.cpp In-Reply-To: References: <20111114200202.379602A6C131@llvm.org> Message-ID: <5CAE4418-17D1-4305-A330-128AE0403437@apple.com> Sorry, I got busy with other things. Jim On Nov 16, 2011, at 5:15 PM, Chris Lattner wrote: > Jim? > > -Chris > > On Nov 14, 2011, at 3:37 PM, Chris Lattner wrote: > >> On Nov 14, 2011, at 12:47 PM, Jim Ingham wrote: >>> The curse of a shared Scheme is you fight over incidental settings like this... I'm not sure why you would want to build a Debug version of lldb against the Release version of the LLVM libraries, so I think my setting is more useful. Whoever likes the Release version better will probably overwrite my setting the next time they commit ;-) >> >> Ok, please fix this though: >> >>>>> @@ -1807,7 +1807,7 @@ >>>>> { >>>>> if (out_file.IsValid() && !reader.IsDone() && reader.GetPrompt()) >>>>> { >>>>> - out_file.Printf ("Please answer \"y\" or \"n\"\n%s", reader.GetPrompt()); >>>>> + out_file.Printf ("Please answer \"y\" or \"Y\" or \"n\" or \"N\"\n%s", reader.GetPrompt()); >>>>> out_file.Flush (); >>>>> } >>>> >>>> There is no need to be exhaustive here, just ask for y/n and accept both cases. >>>> >>>> -Chris >>>> >>> >> >> _______________________________________________ >> lldb-commits mailing list >> lldb-commits at cs.uiuc.edu >> http://lists.cs.uiuc.edu/mailman/listinfo/lldb-commits > From gclayton at apple.com Wed Nov 16 19:23:07 2011 From: gclayton at apple.com (Greg Clayton) Date: Thu, 17 Nov 2011 01:23:07 -0000 Subject: [Lldb-commits] [lldb] r144875 - in /lldb/trunk: include/lldb/Core/State.h source/API/SBDebugger.cpp source/Commands/CommandObjectProcess.cpp source/Commands/CommandObjectTarget.cpp source/Core/State.cpp source/Host/macosx/Host.mm source/Target/Process.cpp Message-ID: <20111117012308.063A21BE001@llvm.org> Author: gclayton Date: Wed Nov 16 19:23:07 2011 New Revision: 144875 URL: http://llvm.org/viewvc/llvm-project?rev=144875&view=rev Log: Fixed an issue with the pthread_setspecific() where we weren't NULL-ing out the thread specific data and were destroying the thread specfic data more than once. Also added the ability to ask a lldb::StateType if it is stopped with an additional paramter of "must_exist" which means that the state must be a stopped state for a process that still exists. This means that eStateExited and eStateUnloaded will no longer return true if "must_exist" is set to true. Modified: lldb/trunk/include/lldb/Core/State.h lldb/trunk/source/API/SBDebugger.cpp lldb/trunk/source/Commands/CommandObjectProcess.cpp lldb/trunk/source/Commands/CommandObjectTarget.cpp lldb/trunk/source/Core/State.cpp lldb/trunk/source/Host/macosx/Host.mm 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=144875&r1=144874&r2=144875&view=diff ============================================================================== --- lldb/trunk/include/lldb/Core/State.h (original) +++ lldb/trunk/include/lldb/Core/State.h Wed Nov 16 19:23:07 2011 @@ -32,12 +32,44 @@ const char * StateAsCString (lldb::StateType state); +//------------------------------------------------------------------ +/// Check if a state represents a state where the process or thread +/// is running. +/// +/// @param[in] state +/// The StateType enumeration value +/// +/// @return +/// \b true if the state represents a process or thread state +/// where the process or thread is running, \b false otherwise. +//------------------------------------------------------------------ bool StateIsRunningState (lldb::StateType state); +//------------------------------------------------------------------ +/// Check if a state represents a state where the process or thread +/// is stopped. Stopped can mean stopped when the process is still +/// around, or stopped when the process has exited or doesn't exist +/// yet. The \a must_exist argument tells us which of these cases is +/// desired. +/// +/// @param[in] state +/// The StateType enumeration value +/// +/// @param[in] must_exist +/// A boolean that indicates the thread must also be alive +/// so states like unloaded or exited won't return true. +/// +/// @return +/// \b true if the state represents a process or thread state +/// where the process or thread is stopped. If \a must_exist is +/// \b true, then the process can't be exited or unloaded, +/// otherwise exited and unloaded or other states where the +/// process no longer exists are considered to be stopped. +//------------------------------------------------------------------ bool -StateIsStoppedState (lldb::StateType state); - +StateIsStoppedState (lldb::StateType state, bool must_exist); + const char * GetPermissionsAsCString (uint32_t permissions); Modified: lldb/trunk/source/API/SBDebugger.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBDebugger.cpp?rev=144875&r1=144874&r2=144875&view=diff ============================================================================== --- lldb/trunk/source/API/SBDebugger.cpp (original) +++ lldb/trunk/source/API/SBDebugger.cpp Wed Nov 16 19:23:07 2011 @@ -452,7 +452,7 @@ { LogSP log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); - const bool result = lldb_private::StateIsStoppedState (state); + const bool result = lldb_private::StateIsStoppedState (state, false); if (log) log->Printf ("SBDebugger::StateIsStoppedState (state=%s) => %i", StateAsCString (state), result); Modified: lldb/trunk/source/Commands/CommandObjectProcess.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectProcess.cpp?rev=144875&r1=144874&r2=144875&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectProcess.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectProcess.cpp Wed Nov 16 19:23:07 2011 @@ -284,7 +284,8 @@ if (synchronous_execution) { state = process->WaitForProcessToStop (NULL); - if (!StateIsStoppedState(state)) + const bool must_be_alive = true; + if (!StateIsStoppedState(state, must_be_alive)) { result.AppendErrorWithFormat ("process isn't stopped: %s", StateAsCString(state)); } Modified: lldb/trunk/source/Commands/CommandObjectTarget.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectTarget.cpp?rev=144875&r1=144874&r2=144875&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectTarget.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectTarget.cpp Wed Nov 16 19:23:07 2011 @@ -82,7 +82,7 @@ lldb::pid_t pid = process_sp->GetID(); StateType state = process_sp->GetState(); if (show_stopped_process_status) - show_process_status = StateIsStoppedState(state); + show_process_status = StateIsStoppedState(state, true); const char *state_cstr = StateAsCString (state); if (pid != LLDB_INVALID_PROCESS_ID) strm.Printf ("%spid=%i", properties++ > 0 ? ", " : " ( ", pid); Modified: lldb/trunk/source/Core/State.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/State.cpp?rev=144875&r1=144874&r2=144875&view=diff ============================================================================== --- lldb/trunk/source/Core/State.cpp (original) +++ lldb/trunk/source/Core/State.cpp Wed Nov 16 19:23:07 2011 @@ -90,7 +90,7 @@ } bool -lldb_private::StateIsStoppedState (StateType state) +lldb_private::StateIsStoppedState (StateType state, bool must_exist) { switch (state) { @@ -105,9 +105,11 @@ break; case eStateUnloaded: + case eStateExited: + return !must_exist; + case eStateStopped: case eStateCrashed: - case eStateExited: case eStateSuspended: return true; } Modified: lldb/trunk/source/Host/macosx/Host.mm URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/macosx/Host.mm?rev=144875&r1=144874&r2=144875&view=diff ============================================================================== --- lldb/trunk/source/Host/macosx/Host.mm (original) +++ lldb/trunk/source/Host/macosx/Host.mm Wed Nov 16 19:23:07 2011 @@ -68,6 +68,9 @@ using namespace lldb; using namespace lldb_private; +static pthread_once_t g_thread_create_once = PTHREAD_ONCE_INIT; +static pthread_key_t g_thread_create_key = 0; + class MacOSXDarwinThread { public: @@ -98,12 +101,17 @@ ~MacOSXDarwinThread() { if (m_pool) + { [m_pool release]; + m_pool = nil; + } } static void PThreadDestructor (void *v) { - delete (MacOSXDarwinThread*)v; + if (v) + delete static_cast(v); + ::pthread_setspecific (g_thread_create_key, NULL); } protected: @@ -112,9 +120,6 @@ DISALLOW_COPY_AND_ASSIGN (MacOSXDarwinThread); }; -static pthread_once_t g_thread_create_once = PTHREAD_ONCE_INIT; -static pthread_key_t g_thread_create_key = 0; - static void InitThreadCreated() { Modified: lldb/trunk/source/Target/Process.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/Process.cpp?rev=144875&r1=144874&r2=144875&view=diff ============================================================================== --- lldb/trunk/source/Target/Process.cpp (original) +++ lldb/trunk/source/Target/Process.cpp Wed Nov 16 19:23:07 2011 @@ -1179,16 +1179,20 @@ const uint32_t stop_id = GetStopID(); if (m_thread_list.GetSize(false) == 0 || stop_id != m_thread_list.GetStopID()) { - Mutex::Locker locker (m_thread_list.GetMutex ()); - ThreadList new_thread_list(this); - // Always update the thread list with the protocol specific - // thread list - UpdateThreadList (m_thread_list, new_thread_list); - OperatingSystem *os = GetOperatingSystem (); - if (os) - os->UpdateThreadList (m_thread_list, new_thread_list); - m_thread_list.Update (new_thread_list); - m_thread_list.SetStopID (stop_id); + const StateType state = GetPrivateState(); + if (StateIsStoppedState (state, true)) + { + Mutex::Locker locker (m_thread_list.GetMutex ()); + ThreadList new_thread_list(this); + // Always update the thread list with the protocol specific + // thread list + UpdateThreadList (m_thread_list, new_thread_list); + OperatingSystem *os = GetOperatingSystem (); + if (os) + os->UpdateThreadList (m_thread_list, new_thread_list); + m_thread_list.Update (new_thread_list); + m_thread_list.SetStopID (stop_id); + } } } @@ -1236,7 +1240,7 @@ if (state_changed) { m_private_state.SetValueNoLock (new_state); - if (StateIsStoppedState(new_state)) + if (StateIsStoppedState(new_state, false)) { m_mod_id.BumpStopID(); m_memory_cache.Clear(); @@ -2167,7 +2171,7 @@ event_sp.reset(); state = WaitForStateChangedEventsPrivate (timeout, event_sp); - if (StateIsStoppedState(state)) + if (StateIsStoppedState(state, false)) break; // If state is invalid, then we timed out @@ -2683,7 +2687,7 @@ } else { - if (StateIsStoppedState (state)) + if (StateIsStoppedState (state, false)) { // We caused the process to interrupt itself, so mark this // as such in the stop event so clients can tell an interrupted @@ -4247,7 +4251,7 @@ Process::GetStatus (Stream &strm) { const StateType state = GetState(); - if (StateIsStoppedState(state)) + if (StateIsStoppedState(state, false)) { if (state == eStateExited) { From gclayton at apple.com Wed Nov 16 22:46:03 2011 From: gclayton at apple.com (Greg Clayton) Date: Thu, 17 Nov 2011 04:46:03 -0000 Subject: [Lldb-commits] [lldb] r144882 - in /lldb/trunk: include/lldb/Target/Process.h source/Core/Debugger.cpp source/Plugins/Process/MacOSX-Kernel/ProcessKDP.cpp source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp source/Target/Platform.cpp source/Target/Process.cpp Message-ID: <20111117044603.39C301BE001@llvm.org> Author: gclayton Date: Wed Nov 16 22:46:02 2011 New Revision: 144882 URL: http://llvm.org/viewvc/llvm-project?rev=144882&view=rev Log: Fixed the issue that was causing our monitor process threads to crash, it turned out to be unitialized data in the ProcessLaunchInfo default constructor. Turning on MallocScribble in the environment helped track this down. When we launch and attach using the host layer, we now inform the process that it shouldn't detach when by calling an accessor. Modified: lldb/trunk/include/lldb/Target/Process.h lldb/trunk/source/Core/Debugger.cpp lldb/trunk/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.cpp lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp lldb/trunk/source/Target/Platform.cpp 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=144882&r1=144881&r2=144882&view=diff ============================================================================== --- lldb/trunk/include/lldb/Target/Process.h (original) +++ lldb/trunk/include/lldb/Target/Process.h Wed Nov 16 22:46:02 2011 @@ -491,7 +491,15 @@ ProcessLaunchInfo () : ProcessInfo(), - m_flags () + m_working_dir (), + m_plugin_name (), + m_shell (), + m_flags (0), + m_file_actions (), + m_resume_count (0), + m_monitor_callback (NULL), + m_monitor_callback_baton (NULL), + m_monitor_signals (false) { } @@ -1508,11 +1516,17 @@ ConnectRemote (const char *remote_url); bool - AttachedToProcess() const + GetShouldDetach () const { - return m_attached_to_process; + return m_should_detach; } - + + void + SetShouldDetach (bool b) + { + m_should_detach = b; + } + //------------------------------------------------------------------ /// Get the image information address for the current process. /// @@ -2944,7 +2958,7 @@ std::string m_stderr_data; MemoryCache m_memory_cache; AllocatedMemoryCache m_allocated_memory_cache; - bool m_attached_to_process; /// Did we launch the process or attach to it? + bool m_should_detach; /// Should we detach if the process object goes away with an explicit call to Kill or Detach? typedef std::map LanguageRuntimeCollection; LanguageRuntimeCollection m_language_runtimes; Modified: lldb/trunk/source/Core/Debugger.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/Debugger.cpp?rev=144882&r1=144881&r2=144882&view=diff ============================================================================== --- lldb/trunk/source/Core/Debugger.cpp (original) +++ lldb/trunk/source/Core/Debugger.cpp Wed Nov 16 22:46:02 2011 @@ -272,7 +272,7 @@ ProcessSP process_sp (m_target_list.GetTargetAtIndex (i)->GetProcessSP()); if (process_sp) { - if (process_sp->AttachedToProcess()) + if (process_sp->GetShouldDetach()) process_sp->Detach(); else process_sp->Destroy(); Modified: lldb/trunk/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.cpp?rev=144882&r1=144881&r2=144882&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.cpp (original) +++ lldb/trunk/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.cpp Wed Nov 16 22:46:02 2011 @@ -97,6 +97,11 @@ ProcessKDP::~ProcessKDP() { Clear(); + // We need to call finalize on the process before destroying ourselves + // to make sure all of the broadcaster cleanup goes as planned. If we + // destruct this class, then Process::~Process() might have problems + // trying to fully destroy the broadcaster. + Finalize(); } //---------------------------------------------------------------------- @@ -620,7 +625,6 @@ void ProcessKDP::Clear() { - Mutex::Locker locker (m_thread_list.GetMutex ()); m_thread_list.Clear(); } 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=144882&r1=144881&r2=144882&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp (original) +++ lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp Wed Nov 16 22:46:02 2011 @@ -1171,6 +1171,9 @@ { // thread in big endian hex tid = Args::StringToUInt32 (value.c_str(), 0, 16); + // m_thread_list does have its own mutex, but we need to + // hold onto the mutex between the call to m_thread_list.FindThreadByID(...) + // and the m_thread_list.AddThread(...) so it doesn't change on us Mutex::Locker locker (m_thread_list.GetMutex ()); thread_sp = m_thread_list.FindThreadByID(tid, false); if (!thread_sp) Modified: lldb/trunk/source/Target/Platform.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/Platform.cpp?rev=144882&r1=144881&r2=144882&view=diff ============================================================================== --- lldb/trunk/source/Target/Platform.cpp (original) +++ lldb/trunk/source/Target/Platform.cpp Wed Nov 16 22:46:02 2011 @@ -581,6 +581,14 @@ { ProcessAttachInfo attach_info (launch_info); process_sp = Attach (attach_info, debugger, target, listener, error); + if (process_sp) + { + // Since we attached to the process, it will think it needs to detach + // if the process object just goes away without an explicit call to + // Process::Kill() or Process::Detach(), so let it know to kill the + // process if this happens. + process_sp->SetShouldDetach (false); + } } } return process_sp; Modified: lldb/trunk/source/Target/Process.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/Process.cpp?rev=144882&r1=144881&r2=144882&view=diff ============================================================================== --- lldb/trunk/source/Target/Process.cpp (original) +++ lldb/trunk/source/Target/Process.cpp Wed Nov 16 22:46:02 2011 @@ -774,7 +774,7 @@ m_stderr_data (), m_memory_cache (*this), m_allocated_memory_cache (*this), - m_attached_to_process (false), + m_should_detach (false), m_next_event_action_ap(), m_can_jit(eCanJITYes) { @@ -818,6 +818,29 @@ void Process::Finalize() { + switch (GetPrivateState()) + { + case eStateConnected: + case eStateAttaching: + case eStateLaunching: + case eStateStopped: + case eStateRunning: + case eStateStepping: + case eStateCrashed: + case eStateSuspended: + if (GetShouldDetach()) + Detach(); + else + Destroy(); + break; + + case eStateInvalid: + case eStateUnloaded: + case eStateDetached: + case eStateExited: + break; + } + // Clear our broadcaster before we proceed with destroying Broadcaster::Clear(); @@ -1183,6 +1206,9 @@ if (StateIsStoppedState (state, true)) { Mutex::Locker locker (m_thread_list.GetMutex ()); + // m_thread_list does have its own mutex, but we need to + // hold onto the mutex between the call to UpdateThreadList(...) + // and the os->UpdateThreadList(...) so it doesn't change on us ThreadList new_thread_list(this); // Always update the thread list with the protocol specific // thread list @@ -2209,6 +2235,7 @@ if (error.Success()) { SetPublicState (eStateLaunching); + m_should_detach = false; // Now launch using these arguments. error = DoLaunch (exe_module, launch_info); @@ -2351,6 +2378,8 @@ error = WillAttachToProcessWithName(process_name, wait_for_launch); if (error.Success()) { + m_should_detach = true; + SetPublicState (eStateAttaching); error = DoAttachToProcessWithName (process_name, wait_for_launch); if (error.Fail()) @@ -2416,6 +2445,7 @@ error = WillAttachToProcessWithID(attach_pid); if (error.Success()) { + m_should_detach = true; SetPublicState (eStateAttaching); error = DoAttachToProcessWithID (attach_pid); @@ -2516,7 +2546,6 @@ { // Let the process subclass figure out at much as it can about the process // before we go looking for a dynamic loader plug-in. - m_attached_to_process = true; DidAttach(); // We just attached. If we have a platform, ask it for the process architecture, and if it isn't From gclayton at apple.com Thu Nov 17 11:22:31 2011 From: gclayton at apple.com (Greg Clayton) Date: Thu, 17 Nov 2011 17:22:31 -0000 Subject: [Lldb-commits] [lldb] r144911 - in /lldb/trunk: lldb.xcodeproj/project.pbxproj resources/LLDB-Info.plist tools/debugserver/debugserver.xcodeproj/project.pbxproj Message-ID: <20111117172231.B96CE2A6C133@llvm.org> Author: gclayton Date: Thu Nov 17 11:22:31 2011 New Revision: 144911 URL: http://llvm.org/viewvc/llvm-project?rev=144911&view=rev Log: Bumped Xcode project versions for lldb-89 and debugserver-153. Modified: lldb/trunk/lldb.xcodeproj/project.pbxproj lldb/trunk/resources/LLDB-Info.plist lldb/trunk/tools/debugserver/debugserver.xcodeproj/project.pbxproj Modified: lldb/trunk/lldb.xcodeproj/project.pbxproj URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/lldb.xcodeproj/project.pbxproj?rev=144911&r1=144910&r2=144911&view=diff ============================================================================== --- lldb/trunk/lldb.xcodeproj/project.pbxproj (original) +++ lldb/trunk/lldb.xcodeproj/project.pbxproj Thu Nov 17 11:22:31 2011 @@ -3724,9 +3724,9 @@ buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; COPY_PHASE_STRIP = NO; - CURRENT_PROJECT_VERSION = 88; + CURRENT_PROJECT_VERSION = 89; DYLIB_COMPATIBILITY_VERSION = 1; - DYLIB_CURRENT_VERSION = 88; + DYLIB_CURRENT_VERSION = 89; EXPORTED_SYMBOLS_FILE = "resources/lldb-framework-exports"; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", @@ -3785,10 +3785,10 @@ buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; COPY_PHASE_STRIP = NO; - CURRENT_PROJECT_VERSION = 88; + CURRENT_PROJECT_VERSION = 89; DEAD_CODE_STRIPPING = YES; DYLIB_COMPATIBILITY_VERSION = 1; - DYLIB_CURRENT_VERSION = 88; + DYLIB_CURRENT_VERSION = 89; EXPORTED_SYMBOLS_FILE = "resources/lldb-framework-exports"; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", @@ -3845,8 +3845,8 @@ isa = XCBuildConfiguration; buildSettings = { COPY_PHASE_STRIP = NO; - CURRENT_PROJECT_VERSION = 88; - DYLIB_CURRENT_VERSION = 88; + CURRENT_PROJECT_VERSION = 89; + DYLIB_CURRENT_VERSION = 89; EXECUTABLE_EXTENSION = a; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", @@ -3875,8 +3875,8 @@ isa = XCBuildConfiguration; buildSettings = { COPY_PHASE_STRIP = NO; - CURRENT_PROJECT_VERSION = 88; - DYLIB_CURRENT_VERSION = 88; + CURRENT_PROJECT_VERSION = 89; + DYLIB_CURRENT_VERSION = 89; EXECUTABLE_EXTENSION = a; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", @@ -3905,8 +3905,8 @@ isa = XCBuildConfiguration; buildSettings = { COPY_PHASE_STRIP = NO; - CURRENT_PROJECT_VERSION = 88; - DYLIB_CURRENT_VERSION = 88; + CURRENT_PROJECT_VERSION = 89; + DYLIB_CURRENT_VERSION = 89; EXECUTABLE_EXTENSION = a; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", @@ -3983,7 +3983,7 @@ isa = XCBuildConfiguration; buildSettings = { COPY_PHASE_STRIP = YES; - CURRENT_PROJECT_VERSION = 88; + CURRENT_PROJECT_VERSION = 89; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", "\"$(SYSTEM_LIBRARY_DIR)/PrivateFrameworks\"", @@ -4013,10 +4013,10 @@ buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; COPY_PHASE_STRIP = YES; - CURRENT_PROJECT_VERSION = 88; + CURRENT_PROJECT_VERSION = 89; DEAD_CODE_STRIPPING = YES; DYLIB_COMPATIBILITY_VERSION = 1; - DYLIB_CURRENT_VERSION = 88; + DYLIB_CURRENT_VERSION = 89; EXPORTED_SYMBOLS_FILE = "resources/lldb-framework-exports"; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", @@ -4260,7 +4260,7 @@ isa = XCBuildConfiguration; buildSettings = { COPY_PHASE_STRIP = NO; - CURRENT_PROJECT_VERSION = 88; + CURRENT_PROJECT_VERSION = 89; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", "\"$(SYSTEM_LIBRARY_DIR)/PrivateFrameworks\"", @@ -4291,7 +4291,7 @@ isa = XCBuildConfiguration; buildSettings = { COPY_PHASE_STRIP = YES; - CURRENT_PROJECT_VERSION = 88; + CURRENT_PROJECT_VERSION = 89; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", "\"$(SYSTEM_LIBRARY_DIR)/PrivateFrameworks\"", Modified: lldb/trunk/resources/LLDB-Info.plist URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/resources/LLDB-Info.plist?rev=144911&r1=144910&r2=144911&view=diff ============================================================================== --- lldb/trunk/resources/LLDB-Info.plist (original) +++ lldb/trunk/resources/LLDB-Info.plist Thu Nov 17 11:22:31 2011 @@ -17,7 +17,7 @@ CFBundleSignature ???? CFBundleVersion - 88 + 89 CFBundleName ${EXECUTABLE_NAME} Modified: lldb/trunk/tools/debugserver/debugserver.xcodeproj/project.pbxproj URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/debugserver/debugserver.xcodeproj/project.pbxproj?rev=144911&r1=144910&r2=144911&view=diff ============================================================================== --- lldb/trunk/tools/debugserver/debugserver.xcodeproj/project.pbxproj (original) +++ lldb/trunk/tools/debugserver/debugserver.xcodeproj/project.pbxproj Thu Nov 17 11:22:31 2011 @@ -475,7 +475,7 @@ i386, ); COPY_PHASE_STRIP = NO; - CURRENT_PROJECT_VERSION = 152; + CURRENT_PROJECT_VERSION = 153; GCC_WARN_ABOUT_RETURN_TYPE = YES; GCC_WARN_UNUSED_VARIABLE = YES; SDKROOT = ""; @@ -494,7 +494,7 @@ x86_64, i386, ); - CURRENT_PROJECT_VERSION = 152; + CURRENT_PROJECT_VERSION = 153; DEAD_CODE_STRIPPING = YES; GCC_WARN_ABOUT_RETURN_TYPE = YES; GCC_WARN_UNUSED_VARIABLE = YES; @@ -515,7 +515,7 @@ x86_64, i386, ); - CURRENT_PROJECT_VERSION = 152; + CURRENT_PROJECT_VERSION = 153; DEAD_CODE_STRIPPING = YES; GCC_WARN_ABOUT_RETURN_TYPE = YES; GCC_WARN_UNUSED_VARIABLE = YES; @@ -534,7 +534,7 @@ "ARCHS[sdk=iphoneos*]" = "$(ARCHS_STANDARD_32_BIT)"; "CODE_SIGN_ENTITLEMENTS[sdk=iphoneos*]" = "source/debugserver-entitlements.plist"; COPY_PHASE_STRIP = YES; - CURRENT_PROJECT_VERSION = 152; + CURRENT_PROJECT_VERSION = 153; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; FRAMEWORK_SEARCH_PATHS = $SDKROOT/System/Library/PrivateFrameworks; "FRAMEWORK_SEARCH_PATHS[sdk=iphoneos*][arch=*]" = ( @@ -577,7 +577,7 @@ "CODE_SIGN_ENTITLEMENTS[sdk=iphoneos*]" = "source/debugserver-entitlements.plist"; "CODE_SIGN_IDENTITY[sdk=macosx*]" = lldb_codesign; COPY_PHASE_STRIP = YES; - CURRENT_PROJECT_VERSION = 152; + CURRENT_PROJECT_VERSION = 153; FRAMEWORK_SEARCH_PATHS = $SDKROOT/System/Library/PrivateFrameworks; "FRAMEWORK_SEARCH_PATHS[sdk=iphoneos*][arch=*]" = ( "$(SDKROOT)/System/Library/PrivateFrameworks", @@ -620,7 +620,7 @@ "CODE_SIGN_ENTITLEMENTS[sdk=iphoneos*]" = "source/debugserver-entitlements.plist"; "CODE_SIGN_IDENTITY[sdk=macosx*]" = lldb_codesign; COPY_PHASE_STRIP = YES; - CURRENT_PROJECT_VERSION = 152; + CURRENT_PROJECT_VERSION = 153; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; FRAMEWORK_SEARCH_PATHS = $SDKROOT/System/Library/PrivateFrameworks; "FRAMEWORK_SEARCH_PATHS[sdk=iphoneos*][arch=*]" = ( From gclayton at apple.com Thu Nov 17 11:22:55 2011 From: gclayton at apple.com (Greg Clayton) Date: Thu, 17 Nov 2011 17:22:55 -0000 Subject: [Lldb-commits] [lldb] r144912 - /lldb/tags/lldb-89/ Message-ID: <20111117172255.CD9B22A6C133@llvm.org> Author: gclayton Date: Thu Nov 17 11:22:55 2011 New Revision: 144912 URL: http://llvm.org/viewvc/llvm-project?rev=144912&view=rev Log: lldb-89 Added: lldb/tags/lldb-89/ - copied from r144911, lldb/trunk/ From johnny.chen at apple.com Thu Nov 17 12:47:38 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Thu, 17 Nov 2011 18:47:38 -0000 Subject: [Lldb-commits] [lldb] r144915 - /lldb/trunk/test/lang/objc/objc-class-method/TestObjCClassMethod.py Message-ID: <20111117184738.D13062A6C133@llvm.org> Author: johnny Date: Thu Nov 17 12:47:38 2011 New Revision: 144915 URL: http://llvm.org/viewvc/llvm-project?rev=144915&view=rev Log: Rename test class appropriately. Modified: lldb/trunk/test/lang/objc/objc-class-method/TestObjCClassMethod.py Modified: lldb/trunk/test/lang/objc/objc-class-method/TestObjCClassMethod.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/lang/objc/objc-class-method/TestObjCClassMethod.py?rev=144915&r1=144914&r2=144915&view=diff ============================================================================== --- lldb/trunk/test/lang/objc/objc-class-method/TestObjCClassMethod.py (original) +++ lldb/trunk/test/lang/objc/objc-class-method/TestObjCClassMethod.py Thu Nov 17 12:47:38 2011 @@ -6,7 +6,7 @@ import lldbutil from lldbtest import * -class TestObjCStaticMethod(TestBase): +class TestObjCClassMethod(TestBase): mydir = os.path.join("lang", "objc", "objc-class-method") From gclayton at apple.com Thu Nov 17 13:41:57 2011 From: gclayton at apple.com (Greg Clayton) Date: Thu, 17 Nov 2011 19:41:57 -0000 Subject: [Lldb-commits] [lldb] r144918 - in /lldb/trunk/source/Host: common/Host.cpp macosx/Host.mm Message-ID: <20111117194157.E33112A6C133@llvm.org> Author: gclayton Date: Thu Nov 17 13:41:57 2011 New Revision: 144918 URL: http://llvm.org/viewvc/llvm-project?rev=144918&view=rev Log: Now that I fixed the uninitialized callback problem, I can enable GCD pid monitoring on darwin in the host layer. Modified: lldb/trunk/source/Host/common/Host.cpp lldb/trunk/source/Host/macosx/Host.mm Modified: lldb/trunk/source/Host/common/Host.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/common/Host.cpp?rev=144918&r1=144917&r2=144918&view=diff ============================================================================== --- lldb/trunk/source/Host/common/Host.cpp (original) +++ lldb/trunk/source/Host/common/Host.cpp Thu Nov 17 13:41:57 2011 @@ -57,7 +57,7 @@ using namespace lldb_private; -#if 1 // !defined (__APPLE__) +#if !defined (__APPLE__) struct MonitorInfo { lldb::pid_t pid; // The process ID to monitor Modified: lldb/trunk/source/Host/macosx/Host.mm URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/macosx/Host.mm?rev=144918&r1=144917&r2=144918&view=diff ============================================================================== --- lldb/trunk/source/Host/macosx/Host.mm (original) +++ lldb/trunk/source/Host/macosx/Host.mm Thu Nov 17 13:41:57 2011 @@ -1421,8 +1421,6 @@ return error; } -#if 0 - lldb::thread_t Host::StartMonitoringChildProcess (Host::MonitorChildProcessCallback callback, void *callback_baton, @@ -1434,29 +1432,29 @@ if (monitor_signals) mask |= DISPATCH_PROC_SIGNAL; + LogSP log(lldb_private::GetLogIfAnyCategoriesSet (LIBLLDB_LOG_HOST | LIBLLDB_LOG_PROCESS)); + dispatch_source_t source = ::dispatch_source_create (DISPATCH_SOURCE_TYPE_PROC, pid, mask, ::dispatch_get_global_queue (DISPATCH_QUEUE_PRIORITY_DEFAULT,0)); - printf ("Host::StartMonitoringChildProcess (callback=%p, baton=%p, pid=%i, monitor_signals=%i) source = %p\n", - callback, - callback_baton, - (int)pid, - monitor_signals, - source); + if (log) + log->Printf ("Host::StartMonitoringChildProcess (callback=%p, baton=%p, pid=%i, monitor_signals=%i) source = %p\n", + callback, + callback_baton, + (int)pid, + monitor_signals, + source); if (source) { ::dispatch_source_set_cancel_handler (source, ^{ - printf ("::dispatch_source_set_cancel_handler (source=%p, ^{...\n", source); ::dispatch_release (source); }); ::dispatch_source_set_event_handler (source, ^{ - printf ("::dispatch_source_set_event_handler (source=%p, ^{...\n", source); - int status= 0; int wait_pid = 0; bool cancel = false; @@ -1494,7 +1492,6 @@ status_cstr = "???"; } - LogSP log (GetLogIfAllCategoriesSet (LIBLLDB_LOG_PROCESS)); if (log) log->Printf ("::waitpid (pid = %i, &status, 0) => pid = %i, status = 0x%8.8x (%s), signal = %i, exit_status = %i", pid, @@ -1509,7 +1506,6 @@ if (exited) { - printf ("::dispatch_source_set_event_handler (source=%p, ^{... dispatch_source_cancel(source);\n", source); ::dispatch_source_cancel(source); } } @@ -1519,6 +1515,3 @@ } return thread; } - - -#endif From johnny.chen at apple.com Thu Nov 17 13:57:27 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Thu, 17 Nov 2011 19:57:27 -0000 Subject: [Lldb-commits] [lldb] r144919 - in /lldb/trunk/test: dotest.py lldbtest.py Message-ID: <20111117195727.A246F2A6C133@llvm.org> Author: johnny Date: Thu Nov 17 13:57:27 2011 New Revision: 144919 URL: http://llvm.org/viewvc/llvm-project?rev=144919&view=rev Log: Add an option '-S' to skip the build and cleanup while running the test. Use this option with care as you would need to build the inferior(s) by hand and build the executable(s) with the correct name(s). This option can be used with '-# n' to stress test certain test cases for n number of times. An example: [11:55:11] johnny:/Volumes/data/lldb/svn/trunk/test/python_api/value $ ls Makefile TestValueAPI.pyc linked_list TestValueAPI.py change_values main.c [11:55:14] johnny:/Volumes/data/lldb/svn/trunk/test/python_api/value $ make EXE=test_with_dsym clang -gdwarf-2 -O0 -arch x86_64 -c -o main.o main.c clang -gdwarf-2 -O0 -arch x86_64 main.o -o "test_with_dsym" /usr/bin/dsymutil -o "test_with_dsym.dSYM" "test_with_dsym" [11:55:20] johnny:/Volumes/data/lldb/svn/trunk/test/python_api/value $ cd ../.. [11:55:24] johnny:/Volumes/data/lldb/svn/trunk/test $ ./dotest.py -v -# 10 -S -f ValueAPITestCase.test_with_dsym LLDB build dir: /Volumes/data/lldb/svn/trunk/build/Debug LLDB-89 Path: /Volumes/data/lldb/svn/trunk URL: https://johnny at llvm.org/svn/llvm-project/lldb/trunk Repository Root: https://johnny at llvm.org/svn/llvm-project Repository UUID: 91177308-0d34-0410-b5e6-96231b3b80d8 Revision: 144914 Node Kind: directory Schedule: normal Last Changed Author: gclayton Last Changed Rev: 144911 Last Changed Date: 2011-11-17 09:22:31 -0800 (Thu, 17 Nov 2011) Session logs for test failures/errors/unexpected successes will go into directory '2011-11-17-11_55_29' Command invoked: python ./dotest.py -v -# 10 -S -f ValueAPITestCase.test_with_dsym ---------------------------------------------------------------------- Collected 1 test 1: test_with_dsym (TestValueAPI.ValueAPITestCase) Exercise some SBValue APIs. ... ok ---------------------------------------------------------------------- Ran 1 test in 1.163s OK 1: test_with_dsym (TestValueAPI.ValueAPITestCase) Exercise some SBValue APIs. ... ok ---------------------------------------------------------------------- Ran 1 test in 0.200s OK 1: test_with_dsym (TestValueAPI.ValueAPITestCase) Exercise some SBValue APIs. ... ok ---------------------------------------------------------------------- Ran 1 test in 0.198s OK 1: test_with_dsym (TestValueAPI.ValueAPITestCase) Exercise some SBValue APIs. ... ok ---------------------------------------------------------------------- Ran 1 test in 0.199s OK 1: test_with_dsym (TestValueAPI.ValueAPITestCase) Exercise some SBValue APIs. ... ok ---------------------------------------------------------------------- Ran 1 test in 0.239s OK 1: test_with_dsym (TestValueAPI.ValueAPITestCase) Exercise some SBValue APIs. ... ok ---------------------------------------------------------------------- Ran 1 test in 1.215s OK 1: test_with_dsym (TestValueAPI.ValueAPITestCase) Exercise some SBValue APIs. ... ok ---------------------------------------------------------------------- Ran 1 test in 0.105s OK 1: test_with_dsym (TestValueAPI.ValueAPITestCase) Exercise some SBValue APIs. ... ok ---------------------------------------------------------------------- Ran 1 test in 0.098s OK 1: test_with_dsym (TestValueAPI.ValueAPITestCase) Exercise some SBValue APIs. ... ok ---------------------------------------------------------------------- Ran 1 test in 0.195s OK 1: test_with_dsym (TestValueAPI.ValueAPITestCase) Exercise some SBValue APIs. ... ok ---------------------------------------------------------------------- Ran 1 test in 1.197s OK [11:55:34] johnny:/Volumes/data/lldb/svn/trunk/test $ Modified: lldb/trunk/test/dotest.py lldb/trunk/test/lldbtest.py Modified: lldb/trunk/test/dotest.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/dotest.py?rev=144919&r1=144918&r2=144919&view=diff ============================================================================== --- lldb/trunk/test/dotest.py (original) +++ lldb/trunk/test/dotest.py Thu Nov 17 13:57:27 2011 @@ -128,8 +128,11 @@ # Ignore the build search path relative to this script to locate the lldb.py module. ignore = False +# By default, we do not skip build and cleanup. Use '-S' option to override. +skip_build_and_cleanup = False + # By default, we skip long running test case. Use '-l' option to override. -skipLongRunningTest = True +skip_long_running_test = True # By default, we print the build dir, lldb version, and svn info. Use '-n' option to # turn it off. @@ -210,6 +213,11 @@ -r : specify a dir to relocate the tests and their intermediate files to; the directory must not exist before running this test driver; no cleanup of intermediate test files is performed in this case +-S : skip the build and cleanup while running the test + use this option with care as you would need to build the inferior(s) by hand + and build the executable(s) with the correct name(s) + this can be used with '-# n' to stress test certain test cases for n number of + times -s : specify the name of the dir created to store the session files of tests with errored or failed status; if not specified, the test driver uses the timestamp as the session dir name @@ -337,7 +345,8 @@ global fs4all global ignore global runHooks - global skipLongRunningTest + global skip_build_and_cleanup + global skip_long_running_test global noHeaders global regexp global rdir @@ -448,7 +457,7 @@ runHooks.append(sys.argv[index]) index += 1 elif sys.argv[index].startswith('-l'): - skipLongRunningTest = False + skip_long_running_test = False index += 1 elif sys.argv[index].startswith('-n'): noHeaders = True @@ -470,6 +479,9 @@ print "Relocated directory:", rdir, "must not exist!" usage() index += 1 + elif sys.argv[index].startswith('-S'): + skip_build_and_cleanup = True + index += 1 elif sys.argv[index].startswith('-s'): # Increment by 1 to fetch the session dir name. index += 1 @@ -895,7 +907,7 @@ # # If '-l' is specified, do not skip the long running tests. -if not skipLongRunningTest: +if not skip_long_running_test: os.environ["LLDB_SKIP_LONG_RUNNING_TEST"] = "NO" # @@ -927,6 +939,9 @@ lldb.just_do_python_api_test = just_do_python_api_test lldb.just_do_benchmarks_test = just_do_benchmarks_test +# Do we need to skip build and cleanup? +lldb.skip_build_and_cleanup = skip_build_and_cleanup + # Put bmExecutable, bmBreakpointSpec, and bmIterationCount into the lldb namespace, too. lldb.bmExecutable = bmExecutable lldb.bmBreakpointSpec = bmBreakpointSpec Modified: lldb/trunk/test/lldbtest.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/lldbtest.py?rev=144919&r1=144918&r2=144919&view=diff ============================================================================== --- lldb/trunk/test/lldbtest.py (original) +++ lldb/trunk/test/lldbtest.py Thu Nov 17 13:57:27 2011 @@ -438,7 +438,7 @@ Do class-wide cleanup. """ - if doCleanup: + if doCleanup and not lldb.skip_build_and_cleanup: # First, let's do the platform-specific cleanup. module = builder_module() if not module.cleanup(): @@ -673,17 +673,13 @@ # Perform registered teardown cleanup. if doCleanup and self.doTearDownCleanup: - module = builder_module() - if not module.cleanup(self, dictionary=self.dict): - raise Exception("Don't know how to do cleanup with dictionary: " + self.dict) + self.cleanup(dictionary=self.dict) # In rare cases where there are multiple teardown cleanups added. if doCleanup and self.doTearDownCleanups: - module = builder_module() if self.dicts: for dict in reversed(self.dicts): - if not module.cleanup(self, dictionary=dict): - raise Exception("Don't know how to do cleanup with dictionary: " + dict) + self.cleanup(dictionary=dict) # Decide whether to dump the session info. self.dumpSessionInfo() @@ -832,27 +828,35 @@ def buildDefault(self, architecture=None, compiler=None, dictionary=None): """Platform specific way to build the default binaries.""" + if lldb.skip_build_and_cleanup: + return module = builder_module() if not module.buildDefault(self, architecture, compiler, dictionary): raise Exception("Don't know how to build default binary") def buildDsym(self, architecture=None, compiler=None, dictionary=None): """Platform specific way to build binaries with dsym info.""" + if lldb.skip_build_and_cleanup: + return module = builder_module() if not module.buildDsym(self, architecture, compiler, dictionary): raise Exception("Don't know how to build binary with dsym") def buildDwarf(self, architecture=None, compiler=None, dictionary=None): """Platform specific way to build binaries with dwarf maps.""" + if lldb.skip_build_and_cleanup: + return module = builder_module() if not module.buildDwarf(self, architecture, compiler, dictionary): raise Exception("Don't know how to build binary with dwarf") def cleanup(self, dictionary=None): """Platform specific way to do cleanup after build.""" + if lldb.skip_build_and_cleanup: + return module = builder_module() if not module.cleanup(self, dictionary): - raise Exception("Don't know how to do cleanup") + raise Exception("Don't know how to do cleanup with dictionary: "+dictionary) class TestBase(Base): From gclayton at apple.com Thu Nov 17 16:14:32 2011 From: gclayton at apple.com (Greg Clayton) Date: Thu, 17 Nov 2011 22:14:32 -0000 Subject: [Lldb-commits] [lldb] r144922 - in /lldb/trunk: include/lldb/Target/Process.h source/Commands/CommandObjectProcess.cpp source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp source/Target/Platform.cpp source/Target/Process.cpp Message-ID: <20111117221432.260122A6C133@llvm.org> Author: gclayton Date: Thu Nov 17 16:14:31 2011 New Revision: 144922 URL: http://llvm.org/viewvc/llvm-project?rev=144922&view=rev Log: Use a pseudoterminal for local processes if no STDIO redirection or other file actions have been specified. Modified: lldb/trunk/include/lldb/Target/Process.h lldb/trunk/source/Commands/CommandObjectProcess.cpp lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp lldb/trunk/source/Target/Platform.cpp 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=144922&r1=144921&r2=144922&view=diff ============================================================================== --- lldb/trunk/include/lldb/Target/Process.h (original) +++ lldb/trunk/include/lldb/Target/Process.h Thu Nov 17 16:14:31 2011 @@ -42,6 +42,7 @@ #include "lldb/Target/Memory.h" #include "lldb/Target/ThreadList.h" #include "lldb/Target/UnixSignals.h" +#include "lldb/Utility/PseudoTerminal.h" namespace lldb_private { @@ -496,6 +497,7 @@ m_shell (), m_flags (0), m_file_actions (), + m_pty (), m_resume_count (0), m_monitor_callback (NULL), m_monitor_callback_baton (NULL), @@ -514,6 +516,7 @@ m_shell (), m_flags (launch_flags), m_file_actions (), + m_pty (), m_resume_count (0), m_monitor_callback (NULL), m_monitor_callback_baton (NULL), @@ -602,7 +605,8 @@ } void - FinalizeFileActions (Target *target); + FinalizeFileActions (Target *target, + bool default_to_use_pty); size_t GetNumFileActions () const @@ -756,6 +760,11 @@ return false; } + lldb_utility::PseudoTerminal & + GetPTY () + { + return m_pty; + } protected: std::string m_working_dir; @@ -763,6 +772,7 @@ std::string m_shell; Flags m_flags; // Bitwise OR of bits from lldb::LaunchFlags std::vector m_file_actions; // File actions for any other files + lldb_utility::PseudoTerminal m_pty; uint32_t m_resume_count; // How many times do we resume after launching Host::MonitorChildProcessCallback m_monitor_callback; void *m_monitor_callback_baton; @@ -2845,6 +2855,9 @@ lldb::ProcessSP GetSP (); + void + SetSTDIOFileDescriptor (int file_descriptor); + protected: //------------------------------------------------------------------ // NextEventAction provides a way to register an action on the next @@ -3041,9 +3054,6 @@ void ResetProcessInputReader (); - void - SetUpProcessInputReader (int file_descriptor); - static size_t ProcessInputReaderCallback (void *baton, InputReader &reader, Modified: lldb/trunk/source/Commands/CommandObjectProcess.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectProcess.cpp?rev=144922&r1=144921&r2=144922&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectProcess.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectProcess.cpp Thu Nov 17 16:14:31 2011 @@ -236,7 +236,10 @@ if (environment.GetArgumentCount() > 0) m_options.launch_info.GetEnvironmentEntries ().AppendArguments (environment); - m_options.launch_info.FinalizeFileActions (target); + // Finalize the file actions, and if none were given, default to opening + // up a pseudo terminal + const bool default_to_use_pty = true; + m_options.launch_info.FinalizeFileActions (target, default_to_use_pty); if (state == eStateConnected) { 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=144922&r1=144921&r2=144922&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp (original) +++ lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp Thu Nov 17 16:14:31 2011 @@ -593,7 +593,7 @@ if (!disable_stdio) { if (pty.GetMasterFileDescriptor() != lldb_utility::PseudoTerminal::invalid_fd) - SetUpProcessInputReader (pty.ReleaseMasterFileDescriptor()); + SetSTDIOFileDescriptor (pty.ReleaseMasterFileDescriptor()); } } } Modified: lldb/trunk/source/Target/Platform.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/Platform.cpp?rev=144922&r1=144921&r2=144922&view=diff ============================================================================== --- lldb/trunk/source/Target/Platform.cpp (original) +++ lldb/trunk/source/Target/Platform.cpp Thu Nov 17 16:14:31 2011 @@ -588,6 +588,16 @@ // Process::Kill() or Process::Detach(), so let it know to kill the // process if this happens. process_sp->SetShouldDetach (false); + + // If we didn't have any file actions, the pseudo terminal might + // have been used where the slave side was given as the file to + // open for stdin/out/err after we have already opened the master + // so we can read/write stdin/out/err. + int pty_fd = launch_info.GetPTY().ReleaseMasterFileDescriptor(); + if (pty_fd != lldb_utility::PseudoTerminal::invalid_fd) + { + process_sp->SetSTDIOFileDescriptor(pty_fd); + } } } } Modified: lldb/trunk/source/Target/Process.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/Process.cpp?rev=144922&r1=144921&r2=144922&view=diff ============================================================================== --- lldb/trunk/source/Target/Process.cpp (original) +++ lldb/trunk/source/Target/Process.cpp Thu Nov 17 16:14:31 2011 @@ -251,7 +251,7 @@ } void -ProcessLaunchInfo::FinalizeFileActions (Target *target) +ProcessLaunchInfo::FinalizeFileActions (Target *target, bool default_to_use_pty) { // If notthing was specified, then check the process for any default // settings that were set with "settings set" @@ -270,36 +270,32 @@ // (lldb) settings set target.input-path // (lldb) settings set target.output-path // (lldb) settings set target.error-path + const char *in_path = NULL; + const char *out_path = NULL; + const char *err_path = NULL; if (target) { - path = target->GetStandardErrorPath(); - if (path) - { - const bool read = true; - const bool write = true; - AppendOpenFileAction(STDERR_FILENO, path, read, write); - } - path = target->GetStandardInputPath(); - if (path) - { - const bool read = true; - const bool write = false; - AppendOpenFileAction(STDIN_FILENO, path, read, write); - } - - path = target->GetStandardOutputPath(); - if (path) + in_path = target->GetStandardErrorPath(); + out_path = target->GetStandardInputPath(); + err_path = target->GetStandardOutputPath(); + } + + if (default_to_use_pty && (!in_path && !out_path && !err_path)) + { + if (m_pty.OpenFirstAvailableMaster (O_RDWR|O_NOCTTY, NULL, 0)) { - const bool read = false; - const bool write = true; - AppendOpenFileAction(STDOUT_FILENO, path, read, write); + in_path = out_path = err_path = m_pty.GetSlaveName (NULL, 0); } } - // If we still don't have any actions... - if (m_file_actions.empty()) - { - } + if (in_path) + AppendOpenFileAction(STDERR_FILENO, in_path, true, true); + + if (out_path) + AppendOpenFileAction(STDIN_FILENO, out_path, true, false); + + if (err_path) + AppendOpenFileAction(STDOUT_FILENO, err_path, false, true); } } } @@ -3549,7 +3545,7 @@ } void -Process::SetUpProcessInputReader (int file_descriptor) +Process::SetSTDIOFileDescriptor (int file_descriptor) { // First set up the Read Thread for reading/handling process I/O From johnny.chen at apple.com Thu Nov 17 18:19:29 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Fri, 18 Nov 2011 00:19:29 -0000 Subject: [Lldb-commits] [lldb] r144940 - /lldb/trunk/test/dotest.py Message-ID: <20111118001929.F39812A6C133@llvm.org> Author: johnny Date: Thu Nov 17 18:19:29 2011 New Revision: 144940 URL: http://llvm.org/viewvc/llvm-project?rev=144940&view=rev Log: Add a simple progress bar when neither '-v' nor '-t' is specified. 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=144940&r1=144939&r2=144940&view=diff ============================================================================== --- lldb/trunk/test/dotest.py (original) +++ lldb/trunk/test/dotest.py Thu Nov 17 18:19:29 2011 @@ -161,6 +161,9 @@ # Default verbosity is 0. verbose = 0 +# Set to True only if verbose is 0 and LLDB trace mode is off. +progress_bar = False + # By default, search from the script directory. testdirs = [ sys.path[0] ] @@ -344,6 +347,7 @@ global filters global fs4all global ignore + global progress_bar global runHooks global skip_build_and_cleanup global skip_long_running_test @@ -530,6 +534,10 @@ if dont_do_python_api_test and just_do_python_api_test: usage() + # The simple progress bar is turned on only if verbose == 0 and LLDB_COMMAND_TRACE is not 'YES' + if ("LLDB_COMMAND_TRACE" not in os.environ or os.environ["LLDB_COMMAND_TRACE"]!="YES") and verbose==0: + progress_bar = True + # Gather all the dirs passed on the command line. if len(sys.argv) > index: testdirs = map(os.path.abspath, sys.argv[index:]) @@ -1076,11 +1084,10 @@ #print "sys.stdout name is", sys.stdout.name # First, write out the number of collected test cases. - if not noHeaders: - sys.stderr.write(separator + "\n") - sys.stderr.write("Collected %d test%s\n\n" - % (suite.countTestCases(), - suite.countTestCases() != 1 and "s" or "")) + sys.stderr.write(separator + "\n") + sys.stderr.write("Collected %d test%s\n\n" + % (suite.countTestCases(), + suite.countTestCases() != 1 and "s" or "")) class LLDBTestResult(unittest2.TextTestResult): """ @@ -1122,6 +1129,16 @@ self.stream.write(self.fmt % self.counter) super(LLDBTestResult, self).startTest(test) + def stopTest(self, test): + """Called when the given test has been run""" + if progress_bar: + sys.__stdout__.write('.') + sys.__stdout__.flush() + if self.counter == suite.countTestCases(): + sys.__stdout__.write('\n') + + super(LLDBTestResult, self).stopTest(test) + def addError(self, test, err): global sdir_has_content sdir_has_content = True From johnny.chen at apple.com Thu Nov 17 18:30:58 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Fri, 18 Nov 2011 00:30:58 -0000 Subject: [Lldb-commits] [lldb] r144945 - /lldb/trunk/test/functionalities/conditional_break/TestConditionalBreak.py Message-ID: <20111118003058.5C1EF2A6C133@llvm.org> Author: johnny Date: Thu Nov 17 18:30:58 2011 New Revision: 144945 URL: http://llvm.org/viewvc/llvm-project?rev=144945&view=rev Log: Do not print debug messages if self.TraceON() is False. Modified: lldb/trunk/test/functionalities/conditional_break/TestConditionalBreak.py Modified: lldb/trunk/test/functionalities/conditional_break/TestConditionalBreak.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/functionalities/conditional_break/TestConditionalBreak.py?rev=144945&r1=144944&r2=144945&view=diff ============================================================================== --- lldb/trunk/test/functionalities/conditional_break/TestConditionalBreak.py (original) +++ lldb/trunk/test/functionalities/conditional_break/TestConditionalBreak.py Thu Nov 17 18:30:58 2011 @@ -71,7 +71,8 @@ # The 10 in range(10) is just an arbitrary number, which means we would # like to try for at most 10 times. for j in range(10): - print "j is: ", j + if self.TraceOn(): + print "j is: ", j thread = process.GetThreadAtIndex(0) if thread.GetNumFrames() >= 2: @@ -103,13 +104,18 @@ # executable, sets the breakpoint on c(), and adds the callback for the # breakpoint such that lldb only stops when the caller of c() is a(). # the "my" package that defines the date() function. - print "About to source .lldb" + if self.TraceOn(): + print "About to source .lldb" + if not self.TraceOn(): + self.HideStdout() self.runCmd("command source .lldb") - print "About to run." + if self.TraceOn(): + print "About to run." self.runCmd("run", RUN_SUCCEEDED) - print "Done running" + if self.TraceOn(): + print "Done running" # The stop reason of the thread should be breakpoint. self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT, From johnny.chen at apple.com Thu Nov 17 18:38:51 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Thu, 17 Nov 2011 16:38:51 -0800 Subject: [Lldb-commits] [lldb] r144940 - /lldb/trunk/test/dotest.py In-Reply-To: <20111118001929.F39812A6C133@llvm.org> References: <20111118001929.F39812A6C133@llvm.org> Message-ID: <743A0661-DE22-4B7A-AA16-FD8F82D72610@apple.com> BTW, I tried to use the ProgressBar.py from llvm, to no avail. The Python unittest framework is messing with sys.stdout plus other things that I don't quite understand, so I take the simple and dumb approach of outputting '.' when each test case is done. On Nov 17, 2011, at 4:19 PM, Johnny Chen wrote: > Author: johnny > Date: Thu Nov 17 18:19:29 2011 > New Revision: 144940 > > URL: http://llvm.org/viewvc/llvm-project?rev=144940&view=rev > Log: > Add a simple progress bar when neither '-v' nor '-t' is specified. > > 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=144940&r1=144939&r2=144940&view=diff > ============================================================================== > --- lldb/trunk/test/dotest.py (original) > +++ lldb/trunk/test/dotest.py Thu Nov 17 18:19:29 2011 > @@ -161,6 +161,9 @@ > # Default verbosity is 0. > verbose = 0 > > +# Set to True only if verbose is 0 and LLDB trace mode is off. > +progress_bar = False > + > # By default, search from the script directory. > testdirs = [ sys.path[0] ] > > @@ -344,6 +347,7 @@ > global filters > global fs4all > global ignore > + global progress_bar > global runHooks > global skip_build_and_cleanup > global skip_long_running_test > @@ -530,6 +534,10 @@ > if dont_do_python_api_test and just_do_python_api_test: > usage() > > + # The simple progress bar is turned on only if verbose == 0 and LLDB_COMMAND_TRACE is not 'YES' > + if ("LLDB_COMMAND_TRACE" not in os.environ or os.environ["LLDB_COMMAND_TRACE"]!="YES") and verbose==0: > + progress_bar = True > + > # Gather all the dirs passed on the command line. > if len(sys.argv) > index: > testdirs = map(os.path.abspath, sys.argv[index:]) > @@ -1076,11 +1084,10 @@ > #print "sys.stdout name is", sys.stdout.name > > # First, write out the number of collected test cases. > - if not noHeaders: > - sys.stderr.write(separator + "\n") > - sys.stderr.write("Collected %d test%s\n\n" > - % (suite.countTestCases(), > - suite.countTestCases() != 1 and "s" or "")) > + sys.stderr.write(separator + "\n") > + sys.stderr.write("Collected %d test%s\n\n" > + % (suite.countTestCases(), > + suite.countTestCases() != 1 and "s" or "")) > > class LLDBTestResult(unittest2.TextTestResult): > """ > @@ -1122,6 +1129,16 @@ > self.stream.write(self.fmt % self.counter) > super(LLDBTestResult, self).startTest(test) > > + def stopTest(self, test): > + """Called when the given test has been run""" > + if progress_bar: > + sys.__stdout__.write('.') > + sys.__stdout__.flush() > + if self.counter == suite.countTestCases(): > + sys.__stdout__.write('\n') > + > + super(LLDBTestResult, self).stopTest(test) > + > def addError(self, test, err): > global sdir_has_content > sdir_has_content = True > > > _______________________________________________ > lldb-commits mailing list > lldb-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/lldb-commits From johnny.chen at apple.com Thu Nov 17 18:58:29 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Fri, 18 Nov 2011 00:58:29 -0000 Subject: [Lldb-commits] [lldb] r144958 - /lldb/trunk/test/functionalities/process_launch/TestProcessLaunch.py Message-ID: <20111118005829.B6C732A6C133@llvm.org> Author: johnny Date: Thu Nov 17 18:58:29 2011 New Revision: 144958 URL: http://llvm.org/viewvc/llvm-project?rev=144958&view=rev Log: Redirect the stderr output into a file so as to not pollute the terminal. Modified: lldb/trunk/test/functionalities/process_launch/TestProcessLaunch.py Modified: lldb/trunk/test/functionalities/process_launch/TestProcessLaunch.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/functionalities/process_launch/TestProcessLaunch.py?rev=144958&r1=144957&r2=144958&view=diff ============================================================================== --- lldb/trunk/test/functionalities/process_launch/TestProcessLaunch.py (original) +++ lldb/trunk/test/functionalities/process_launch/TestProcessLaunch.py Thu Nov 17 18:58:29 2011 @@ -122,18 +122,22 @@ mywd = 'my_working_dir' out_file_name = "my_working_dir_test.out" + err_file_name = "my_working_dir_test.err" my_working_dir_path = os.path.join(os.getcwd(), mywd) out_file_path = os.path.join(my_working_dir_path, out_file_name) + err_file_path = os.path.join(my_working_dir_path, err_file_name) # Make sure the output files do not exist before launching the process try: os.remove (out_file_path) + os.remove (err_file_path) except OSError: pass - launch_command = "process launch -w %s -o %s" % (my_working_dir_path, - out_file_path) + launch_command = "process launch -w %s -o %s -e %sl" % (my_working_dir_path, + out_file_path, + err_file_path) self.expect(launch_command, patterns = [ "Process .* launched: .*a.out" ]) @@ -157,9 +161,10 @@ err_msg = err_msg + "The current working directory was not set correctly.\n" out_f.close(); - # Try to delete the 'stdout' file + # Try to delete the 'stdout' and 'stderr' files try: os.remove(out_file_path) + os.remove(err_file_path) pass except OSError: pass From scallanan at apple.com Thu Nov 17 21:28:10 2011 From: scallanan at apple.com (Sean Callanan) Date: Fri, 18 Nov 2011 03:28:10 -0000 Subject: [Lldb-commits] [lldb] r144969 - in /lldb/trunk: include/lldb/Symbol/ClangASTImporter.h llvm.zip scripts/build-llvm.pl scripts/clang.is-being-completed-from-lexical-storage.diff scripts/clang.visit-translation-unit-decl.diff source/Expression/ClangASTSource.cpp source/Expression/ClangExpressionDeclMap.cpp source/Expression/IRForTarget.cpp source/Symbol/ClangASTImporter.cpp Message-ID: <20111118032810.689102A6C133@llvm.org> Author: spyffe Date: Thu Nov 17 21:28:09 2011 New Revision: 144969 URL: http://llvm.org/viewvc/llvm-project?rev=144969&view=rev Log: This commit completes the rearchitecting of ClangASTSource to allow variables in the persistent variable store to know how to complete themselves from debug information. That fixes a variety of bugs during dematerialization of expression results and also makes persistent variable and result variables ($foo, $4, ...) more useful. I have also added logging improvements that make it much easier to figure out how types are moving from place to place, and made some checking a little more aggressive. The commit includes patches to Clang which are currently being integrated into Clang proper; once these fixes are in Clang top-of-tree, these patches will be removed. The patches don't fix API; rather, they fix some internal bugs in Clang's ASTImporter that were exposed when LLDB was moving types from place to place multiple times. Added: lldb/trunk/scripts/clang.is-being-completed-from-lexical-storage.diff lldb/trunk/scripts/clang.visit-translation-unit-decl.diff Modified: lldb/trunk/include/lldb/Symbol/ClangASTImporter.h lldb/trunk/llvm.zip lldb/trunk/scripts/build-llvm.pl lldb/trunk/source/Expression/ClangASTSource.cpp lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp lldb/trunk/source/Expression/IRForTarget.cpp lldb/trunk/source/Symbol/ClangASTImporter.cpp Modified: lldb/trunk/include/lldb/Symbol/ClangASTImporter.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Symbol/ClangASTImporter.h?rev=144969&r1=144968&r2=144969&view=diff ============================================================================== --- lldb/trunk/include/lldb/Symbol/ClangASTImporter.h (original) +++ lldb/trunk/include/lldb/Symbol/ClangASTImporter.h Thu Nov 17 21:28:09 2011 @@ -129,6 +129,12 @@ decl = rhs.decl; } + void operator= (const DeclOrigin &rhs) + { + ctx = rhs.ctx; + decl = rhs.decl; + } + bool Valid () { Modified: lldb/trunk/llvm.zip URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/llvm.zip?rev=144969&r1=144968&r2=144969&view=diff ============================================================================== Binary files - no diff available. Modified: lldb/trunk/scripts/build-llvm.pl URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/scripts/build-llvm.pl?rev=144969&r1=144968&r2=144969&view=diff ============================================================================== --- lldb/trunk/scripts/build-llvm.pl (original) +++ lldb/trunk/scripts/build-llvm.pl Thu Nov 17 21:28:09 2011 @@ -156,7 +156,7 @@ do_command ("cd '$SRCROOT' && svn co --quiet --revision $llvm_revision http://llvm.org/svn/llvm-project/llvm/trunk llvm", "checking out llvm from repository", 1); print "Checking out clang sources from revision $clang_revision...\n"; do_command ("cd '$llvm_srcroot/tools' && svn co --quiet --revision $clang_revision http://llvm.org/svn/llvm-project/cfe/trunk clang", "checking out clang from repository", 1); - print "Applying any local patches to LLVM..."; + print "Applying any local patches to LLVM/Clang..."; my @llvm_patches = bsd_glob("$ENV{SRCROOT}/scripts/llvm.*.diff"); @@ -164,6 +164,13 @@ { do_command ("cd '$llvm_srcroot' && patch -p0 < $patch"); } + + my @clang_patches = bsd_glob("$ENV{SRCROOT}/scripts/clang.*.diff"); + + foreach my $patch (@clang_patches) + { + do_command ("cd '$llvm_srcroot/tools/clang' && patch -p0 < $patch"); + } print "Removing the llvm/test and llvm/tools/clang/test directories...\n"; do_command ("cd '$llvm_srcroot' && rm -rf test && rm -rf tools/clang/test ", "removing test directories", 1); Added: lldb/trunk/scripts/clang.is-being-completed-from-lexical-storage.diff URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/scripts/clang.is-being-completed-from-lexical-storage.diff?rev=144969&view=auto ============================================================================== --- lldb/trunk/scripts/clang.is-being-completed-from-lexical-storage.diff (added) +++ lldb/trunk/scripts/clang.is-being-completed-from-lexical-storage.diff Thu Nov 17 21:28:09 2011 @@ -0,0 +1,78 @@ +Index: include/clang/AST/DeclBase.h +=================================================================== +--- include/clang/AST/DeclBase.h (revision 144573) ++++ include/clang/AST/DeclBase.h (working copy) +@@ -807,6 +807,12 @@ + /// storage that contains additional declarations that are visible + /// in this context. + mutable unsigned ExternalVisibleStorage : 1; ++ ++ /// \brief True if this declaration context is currently having ++ /// declarations added from its external lexical storage. This flag ++ /// is intended to prevent One Definition Rule checking as the ++ /// declarations are imported. ++ mutable unsigned IsBeingCompletedFromLexicalStorage : 1; + + /// \brief Pointer to the data structure used to lookup declarations + /// within this context (or a DependentStoredDeclsMap if this is a +@@ -834,8 +840,8 @@ + + DeclContext(Decl::Kind K) + : DeclKind(K), ExternalLexicalStorage(false), +- ExternalVisibleStorage(false), LookupPtr(0), FirstDecl(0), +- LastDecl(0) { } ++ ExternalVisibleStorage(false), IsBeingCompletedFromLexicalStorage(false), ++ LookupPtr(0), FirstDecl(0), LastDecl(0) { } + + public: + ~DeclContext(); +@@ -1339,6 +1345,14 @@ + ExternalVisibleStorage = ES; + } + ++ bool isBeingCompletedFromLexicalStorage() const { ++ return IsBeingCompletedFromLexicalStorage; ++ } ++ ++ void setIsBeingCompletedFromLexicalStorage(bool IBC) const { ++ IsBeingCompletedFromLexicalStorage = IBC; ++ } ++ + /// \brief Determine whether the given declaration is stored in the list of + /// declarations lexically within this context. + bool isDeclInLexicalTraversal(const Decl *D) const { +Index: lib/AST/Decl.cpp +=================================================================== +--- lib/AST/Decl.cpp (revision 144573) ++++ lib/AST/Decl.cpp (working copy) +@@ -2405,8 +2405,14 @@ + ExternalASTSource::Deserializing TheFields(Source); + + SmallVector Decls; +- LoadedFieldsFromExternalStorage = true; +- switch (Source->FindExternalLexicalDeclsBy(this, Decls)) { ++ LoadedFieldsFromExternalStorage = true; ++ ++ setIsBeingCompletedFromLexicalStorage(true); ++ ExternalLoadResult LoadResult = ++ Source->FindExternalLexicalDeclsBy(this, Decls); ++ setIsBeingCompletedFromLexicalStorage(false); ++ ++ switch (LoadResult) { + case ELR_Success: + break; + +Index: lib/AST/ASTImporter.cpp +=================================================================== +--- lib/AST/ASTImporter.cpp (revision 144573) ++++ lib/AST/ASTImporter.cpp (working copy) +@@ -2290,7 +2290,8 @@ + + if (RecordDecl *FoundRecord = dyn_cast(Found)) { + if (RecordDecl *FoundDef = FoundRecord->getDefinition()) { +- if (!D->isCompleteDefinition() || IsStructuralMatch(D, FoundDef)) { ++ if (FoundDef->isBeingCompletedFromLexicalStorage() || ++ !D->isCompleteDefinition() || IsStructuralMatch(D, FoundDef)) { + // The record types structurally match, or the "from" translation + // unit only had a forward declaration anyway; call it the same + // function. Added: lldb/trunk/scripts/clang.visit-translation-unit-decl.diff URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/scripts/clang.visit-translation-unit-decl.diff?rev=144969&view=auto ============================================================================== --- lldb/trunk/scripts/clang.visit-translation-unit-decl.diff (added) +++ lldb/trunk/scripts/clang.visit-translation-unit-decl.diff Thu Nov 17 21:28:09 2011 @@ -0,0 +1,28 @@ +Index: lib/AST/ASTImporter.cpp +=================================================================== +--- lib/AST/ASTImporter.cpp (revision 144573) ++++ lib/AST/ASTImporter.cpp (working copy) +@@ -100,6 +100,7 @@ + bool IsStructuralMatch(EnumDecl *FromEnum, EnumDecl *ToRecord); + bool IsStructuralMatch(ClassTemplateDecl *From, ClassTemplateDecl *To); + Decl *VisitDecl(Decl *D); ++ Decl *VisitTranslationUnitDecl(TranslationUnitDecl *D); + Decl *VisitNamespaceDecl(NamespaceDecl *D); + Decl *VisitTypedefNameDecl(TypedefNameDecl *D, bool IsAlias); + Decl *VisitTypedefDecl(TypedefDecl *D); +@@ -2030,6 +2031,15 @@ + return 0; + } + ++Decl *ASTNodeImporter::VisitTranslationUnitDecl(TranslationUnitDecl *D) { ++ TranslationUnitDecl *ToD = ++ Importer.getToContext().getTranslationUnitDecl(); ++ ++ Importer.Imported(D, ToD); ++ ++ return ToD; ++} ++ + Decl *ASTNodeImporter::VisitNamespaceDecl(NamespaceDecl *D) { + // Import the major distinguishing characteristics of this namespace. + DeclContext *DC, *LexicalDC; Modified: lldb/trunk/source/Expression/ClangASTSource.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/ClangASTSource.cpp?rev=144969&r1=144968&r2=144969&view=diff ============================================================================== --- lldb/trunk/source/Expression/ClangASTSource.cpp (original) +++ lldb/trunk/source/Expression/ClangASTSource.cpp Thu Nov 17 21:28:09 2011 @@ -135,7 +135,7 @@ if (log) { - log->Printf(" [CompleteTagDecl] Completing a TagDecl named %s", tag_decl->getName().str().c_str()); + log->Printf(" [CompleteTagDecl] on (ASTContext*)%p Completing a TagDecl named %s", m_ast_context, tag_decl->getName().str().c_str()); log->Printf(" [CTD] Before:"); ASTDumper dumper((Decl*)tag_decl); dumper.ToLog(log, " [CTD] "); @@ -158,7 +158,7 @@ if (log) { - log->Printf(" [CompleteObjCInterfaceDecl] Completing an ObjCInterfaceDecl named %s", interface_decl->getName().str().c_str()); + log->Printf(" [CompleteObjCInterfaceDecl] on (ASTContext*)%p Completing an ObjCInterfaceDecl named %s", m_ast_context, interface_decl->getName().str().c_str()); log->Printf(" [COID] Before:"); ASTDumper dumper((Decl*)interface_decl); dumper.ToLog(log, " [COID] "); @@ -192,19 +192,24 @@ if (log) { if (const NamedDecl *context_named_decl = dyn_cast(context_decl)) - log->Printf("FindExternalLexicalDecls[%u] in '%s' (a %s) with %s predicate", + log->Printf("FindExternalLexicalDecls[%u] on (ASTContext*)%p in '%s' (%sDecl*)%p with %s predicate", current_id, + m_ast_context, context_named_decl->getNameAsString().c_str(), - context_decl->getDeclKindName(), + context_decl->getDeclKindName(), + context_decl, (predicate ? "non-null" : "null")); else if(context_decl) - log->Printf("FindExternalLexicalDecls[%u] in a %s with %s predicate", + log->Printf("FindExternalLexicalDecls[%u] on (ASTContext*)%p in (%sDecl*)%p with %s predicate", current_id, + m_ast_context, context_decl->getDeclKindName(), + context_decl, (predicate ? "non-null" : "null")); else - log->Printf("FindExternalLexicalDecls[%u] in a NULL context with %s predicate", + log->Printf("FindExternalLexicalDecls[%u] on (ASTContext*)%p in a NULL context with %s predicate", current_id, + m_ast_context, (predicate ? "non-null" : "null")); } @@ -274,11 +279,11 @@ if (log) { if (!context.m_decl_context) - log->Printf("ClangASTSource::FindExternalVisibleDecls[%u] for '%s' in a NULL DeclContext", current_id, name.GetCString()); + log->Printf("ClangASTSource::FindExternalVisibleDecls[%u] on (ASTContext*)%p for '%s' in a NULL DeclContext", current_id, m_ast_context, name.GetCString()); else if (const NamedDecl *context_named_decl = dyn_cast(context.m_decl_context)) - log->Printf("ClangASTSource::FindExternalVisibleDecls[%u] for '%s' in '%s'", current_id, name.GetCString(), context_named_decl->getNameAsString().c_str()); + log->Printf("ClangASTSource::FindExternalVisibleDecls[%u] on (ASTContext*)%p for '%s' in '%s'", current_id, m_ast_context, name.GetCString(), context_named_decl->getNameAsString().c_str()); else - log->Printf("ClangASTSource::FindExternalVisibleDecls[%u] for '%s' in a '%s'", current_id, name.GetCString(), context.m_decl_context->getDeclKindName()); + log->Printf("ClangASTSource::FindExternalVisibleDecls[%u] on (ASTContext*)%p for '%s' in a '%s'", current_id, m_ast_context, name.GetCString(), context.m_decl_context->getDeclKindName()); } context.m_namespace_map.reset(new ClangASTImporter::NamespaceMap); @@ -511,8 +516,9 @@ ConstString selector_name(ss.GetData()); if (log) - log->Printf("ClangASTSource::FindObjCMethodDecls[%d] for selector [%s %s]", - current_id, + log->Printf("ClangASTSource::FindObjCMethodDecls[%d] on (ASTContext*)%p for selector [%s %s]", + current_id, + m_ast_context, interface_decl->getNameAsString().c_str(), selector_name.AsCString()); @@ -603,8 +609,9 @@ ObjCPropertyDecl *property_decl = orig_iface_decl->FindPropertyDeclaration(&orig_ast_ctx->Idents.get(property_name)); if (log) - log->Printf("ClangASTSource::FindObjCPropertyDecls[%d] for property '%s.%s'", + log->Printf("ClangASTSource::FindObjCPropertyDecls[%d] on (ASTContext*)%p for property '%s.%s'", current_id, + m_ast_context, iface_decl->getNameAsString().c_str(), property_name_str.c_str()); @@ -643,13 +650,15 @@ if (log) { if (parent_map && parent_map->size()) - log->Printf("CompleteNamespaceMap[%u] Searching for namespace %s in namespace %s", + log->Printf("CompleteNamespaceMap[%u] on (ASTContext*)%p Searching for namespace %s in namespace %s", current_id, + m_ast_context, name.GetCString(), parent_map->begin()->second.GetNamespaceDecl()->getDeclName().getAsString().c_str()); else - log->Printf("CompleteNamespaceMap[%u] Searching for namespace %s", + log->Printf("CompleteNamespaceMap[%u] on (ASTContext*)%p Searching for namespace %s", current_id, + m_ast_context, name.GetCString()); } Modified: lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp?rev=144969&r1=144968&r2=144969&view=diff ============================================================================== --- lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp (original) +++ lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp Thu Nov 17 21:28:09 2011 @@ -196,9 +196,9 @@ ASTContext *context(target->GetScratchClangASTContext()->getASTContext()); - TypeFromUser user_type(ClangASTContext::CopyType(context, - type.GetASTContext(), - type.GetOpaqueQualType()), + TypeFromUser user_type(m_ast_importer->CopyType(context, + type.GetASTContext(), + type.GetOpaqueQualType()), context); if (!m_parser_vars->m_persistent_vars->CreatePersistentVariable (exe_ctx->GetBestExecutionContextScope (), @@ -285,9 +285,9 @@ if (!var_sp) return ClangExpressionVariableSP(); - TypeFromUser user_type(ClangASTContext::CopyType(context, - type.GetASTContext(), - type.GetOpaqueQualType()), + TypeFromUser user_type(m_ast_importer->CopyType(context, + type.GetASTContext(), + type.GetOpaqueQualType()), context); TypeFromUser var_type = var_sp->GetTypeFromUser(); @@ -424,10 +424,17 @@ ASTContext *context(target->GetScratchClangASTContext()->getASTContext()); - TypeFromUser user_type(ClangASTContext::CopyType(context, - parser_type.GetASTContext(), - parser_type.GetOpaqueQualType()), + TypeFromUser user_type(m_ast_importer->CopyType(context, + parser_type.GetASTContext(), + parser_type.GetOpaqueQualType()), context); + + if (!user_type.GetOpaqueQualType()) + { + if (log) + log->Printf("Persistent variable's type wasn't copied successfully"); + return false; + } if (!m_parser_vars->m_target_info.IsValid()) return false; @@ -499,7 +506,7 @@ return false; if (log) - log->Printf("Adding value for decl %p [%s - %s] to the structure", + log->Printf("Adding value for (NamedDecl*)%p [%s - %s] to the structure", decl, name.GetCString(), var_sp->GetName().GetCString()); @@ -936,8 +943,15 @@ return err.Success(); } case Value::eValueTypeHostAddress: - memcpy (data, (const void *)value.GetScalar().ULongLong(), length); + { + void *host_addr = (void*)value.GetScalar().ULongLong(); + + if (!host_addr) + return false; + + memcpy (data, host_addr, length); return true; + } case Value::eValueTypeScalar: return false; } @@ -1370,12 +1384,16 @@ log->PutCString("Allocating memory for materialized argument struct"); lldb::addr_t mem = process->AllocateMemory(m_struct_vars->m_struct_alignment + m_struct_vars->m_struct_size, - lldb::ePermissionsReadable | lldb::ePermissionsWritable, - err); + lldb::ePermissionsReadable | lldb::ePermissionsWritable, + err); if (mem == LLDB_INVALID_ADDRESS) + { + err.SetErrorStringWithFormat("Couldn't allocate 0x%llx bytes for materialized argument struct", + (unsigned long long)(m_struct_vars->m_struct_alignment + m_struct_vars->m_struct_size)); return false; - + } + m_material_vars->m_allocated_area = mem; } @@ -1400,8 +1418,11 @@ RegisterContext *reg_ctx = exe_ctx.GetRegisterContext(); if (!reg_ctx) + { + err.SetErrorString("Couldn't get register context"); return false; - + } + if (!DoMaterializeOneRegister (dematerialize, exe_ctx, *reg_ctx, @@ -1413,7 +1434,10 @@ else { if (!member_sp->m_jit_vars.get()) + { + err.SetErrorString("Variable being materialized doesn't have necessary state"); return false; + } if (!DoMaterializeOneVariable (dematerialize, exe_ctx, @@ -1485,7 +1509,10 @@ uint8_t *pvar_data = var_sp->GetValueBytes(); if (pvar_data == NULL) + { + err.SetErrorString("Persistent variable being materialized contains no data"); return false; + } Error error; Process *process = exe_ctx.GetProcessPtr(); @@ -1689,7 +1716,10 @@ StackFrame *frame = exe_ctx.GetFramePtr(); if (!frame || !process || !target || !m_parser_vars.get() || !expr_var->m_parser_vars.get()) + { + err.SetErrorString("Necessary state for variable materialization isn't present"); return false; + } // Vital information about the value @@ -2200,7 +2230,7 @@ ClangASTImporter::NamespaceMapSP namespace_map = m_ast_importer->GetNamespaceMap(namespace_context); if (log && log->GetVerbose()) - log->Printf(" CEDM::FEVD[%u] Inspecting namespace map %p (%d entries)", + log->Printf(" CEDM::FEVD[%u] Inspecting (NamespaceMap*)%p (%d entries)", current_id, namespace_map.get(), (int)namespace_map->size()); @@ -2873,7 +2903,7 @@ QualType var_type = var_decl->getType(); TypeFromParser parser_type(var_type.getAsOpaquePtr(), &var_decl->getASTContext()); - lldb::clang_type_t copied_type = ClangASTContext::CopyType(scratch_ast_context, &var_decl->getASTContext(), var_type.getAsOpaquePtr()); + lldb::clang_type_t copied_type = m_ast_importer->CopyType(scratch_ast_context, &var_decl->getASTContext(), var_type.getAsOpaquePtr()); TypeFromUser user_type(copied_type, scratch_ast_context); Modified: lldb/trunk/source/Expression/IRForTarget.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/IRForTarget.cpp?rev=144969&r1=144968&r2=144969&view=diff ============================================================================== --- lldb/trunk/source/Expression/IRForTarget.cpp (original) +++ lldb/trunk/source/Expression/IRForTarget.cpp Thu Nov 17 21:28:09 2011 @@ -647,12 +647,25 @@ clang::QualType element_qual_type = pointer_pointertype->getPointeeType(); m_result_type = lldb_private::TypeFromParser(element_qual_type.getAsOpaquePtr(), - &result_decl->getASTContext()); + &result_decl->getASTContext()); } else { m_result_type = lldb_private::TypeFromParser(result_var->getType().getAsOpaquePtr(), - &result_decl->getASTContext()); + &result_decl->getASTContext()); + } + + if (m_result_type.GetClangTypeBitWidth() == 0) + { + lldb_private::StreamString type_desc_stream; + m_result_type.DumpTypeDescription(&type_desc_stream); + + if (log) + log->Printf("Result type has size 0"); + + if (m_error_stream) + m_error_stream->Printf("Internal error [IRForTarget]: Result type '%s' has invalid size\n", + type_desc_stream.GetData()); } if (log) @@ -660,13 +673,15 @@ lldb_private::StreamString type_desc_stream; m_result_type.DumpTypeDescription(&type_desc_stream); - log->Printf("Result decl type: \"%s\"", type_desc_stream.GetString().c_str()); + log->Printf("Result decl type: \"%s\"", type_desc_stream.GetData()); } m_result_name = m_decl_map->GetPersistentResultName(); if (log) - log->Printf("Creating a new result global: \"%s\"", m_result_name.GetCString()); + log->Printf("Creating a new result global: \"%s\" with size 0x%x", + m_result_name.GetCString(), + m_result_type.GetClangTypeBitWidth() / 8); // Construct a new result global and set up its metadata @@ -755,11 +770,12 @@ } if (!m_const_result) - m_decl_map->AddPersistentVariable(result_decl, - m_result_name, - m_result_type, - true, - m_result_is_pointer); + if (!m_decl_map->AddPersistentVariable(result_decl, + m_result_name, + m_result_type, + true, + m_result_is_pointer)) + return false; result_global->eraseFromParent(); Modified: lldb/trunk/source/Symbol/ClangASTImporter.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/ClangASTImporter.cpp?rev=144969&r1=144968&r2=144969&view=diff ============================================================================== --- lldb/trunk/source/Symbol/ClangASTImporter.cpp (original) +++ lldb/trunk/source/Symbol/ClangASTImporter.cpp Thu Nov 17 21:28:09 2011 @@ -193,7 +193,26 @@ *ClangASTImporter::Minion::Imported (clang::Decl *from, clang::Decl *to) { lldb::LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS)); - + + if (log) + { + if (NamedDecl *from_named_decl = dyn_cast(from)) + { + log->Printf(" [ClangASTImporter] Imported (%sDecl*)%p, named %s (from (Decl*)%p)", + from->getDeclKindName(), + to, + from_named_decl->getName().str().c_str(), + from); + } + else + { + log->Printf(" [ClangASTImporter] Imported (%sDecl*)%p (from (Decl*)%p)", + from->getDeclKindName(), + to, + from); + } + } + ASTContextMetadataSP to_context_md = m_master.GetContextMetadata(&to->getASTContext()); ASTContextMetadataSP from_context_md = m_master.MaybeGetContextMetadata(m_source_ctx); @@ -204,7 +223,22 @@ OriginMap::iterator origin_iter = origins.find(from); if (origin_iter != origins.end()) + { to_context_md->m_origins[to] = origin_iter->second; + + if (log) + log->Printf(" [ClangASTImporter] Propagated origin (Decl*)%p/(ASTContext*)%p from (ASTContext*)%p to (ASTContext*)%p", + origin_iter->second.decl, + origin_iter->second.ctx, + &from->getASTContext(), + &to->getASTContext()); + } + else + { + if (log) + log->Printf(" [ClangASTImporter] Decl has no origin information in (ASTContext*)%p", + &from->getASTContext()); + } if (clang::NamespaceDecl *to_namespace = dyn_cast(to)) { @@ -221,6 +255,12 @@ else { to_context_md->m_origins[to] = DeclOrigin (m_source_ctx, from); + + if (log) + log->Printf(" [ClangASTImporter] Sourced origin (Decl*)%p/(ASTContext*)%p into (ASTContext*)%p", + from, + m_source_ctx, + &to->getASTContext()); } if (TagDecl *from_tag_decl = dyn_cast(from)) @@ -230,14 +270,13 @@ to_tag_decl->setHasExternalLexicalStorage(); if (log) - log->Printf(" [ClangASTImporter] Imported %p, a %s named %s%s%s [%s->%s]", - to, - ((clang::Decl*)from_tag_decl)->getDeclKindName(), - from_tag_decl->getName().str().c_str(), + log->Printf(" [ClangASTImporter] To is a TagDecl - attributes %s%s [%s->%s]", (to_tag_decl->hasExternalLexicalStorage() ? " Lexical" : ""), (to_tag_decl->hasExternalVisibleStorage() ? " Visible" : ""), (from_tag_decl->isCompleteDefinition() ? "complete" : "incomplete"), (to_tag_decl->isCompleteDefinition() ? "complete" : "incomplete")); + + to_tag_decl = NULL; } if (isa(from)) @@ -249,7 +288,7 @@ to_namespace_decl->setHasExternalVisibleStorage(); } - if (ObjCInterfaceDecl *from_interface_decl = dyn_cast(from)) + if (isa(from)) { ObjCInterfaceDecl *to_interface_decl = dyn_cast(to); @@ -262,10 +301,7 @@ to_interface_decl->setExternallyCompleted(); if (log) - log->Printf(" [ClangASTImporter] Imported %p, a %s named %s%s%s%s", - to, - ((clang::Decl*)from_interface_decl)->getDeclKindName(), - from_interface_decl->getName().str().c_str(), + log->Printf(" [ClangASTImporter] To is an ObjCInterfaceDecl - attributes %s%s%s", (to_interface_decl->hasExternalLexicalStorage() ? " Lexical" : ""), (to_interface_decl->hasExternalVisibleStorage() ? " Visible" : ""), (to_interface_decl->isForwardDecl() ? " Forward" : "")); From gclayton at apple.com Thu Nov 17 22:43:59 2011 From: gclayton at apple.com (Greg Clayton) Date: Fri, 18 Nov 2011 04:43:59 -0000 Subject: [Lldb-commits] [lldb] r144975 - in /lldb/trunk/source: Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.h Target/Process.cpp Message-ID: <20111118044359.A6B482A6C133@llvm.org> Author: gclayton Date: Thu Nov 17 22:43:59 2011 New Revision: 144975 URL: http://llvm.org/viewvc/llvm-project?rev=144975&view=rev Log: Looking at our memory usage with Instruments when debugging a large application we say that the vectors of DWARFDebugInfoEntry objects were the highest on the the list. With these changes we cut our memory usage by 40%!!! I did this by reducing the size of the DWARFDebugInfoEntry from a previous: uint32_t offset uint32_t parent_idx uint32_t sibling_idx Abbrev * abbrev_ptr which was 20 bytes, but rounded up to 24 bytes due to alignment. Now we have: uint32_t offset uint32_t parent_idx uint32_t sibling_idx uint32_t abbr_idx:15, // 32767 possible abbreviation codes has_children:1, // 0 = no children, 1 = has children tag:16; // DW_TAG_XXX value This gets us down to 16 bytes per DIE. I tested some VERY large DWARF files (900MB) and found there were only ~700 unique abbreviations, so 32767 should be enough for any sane compiler. If it isn't there are built in assertions that will fire off and tell us. Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.h lldb/trunk/source/Target/Process.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=144975&r1=144974&r2=144975&view=diff ============================================================================== --- lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp (original) +++ lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp Thu Nov 17 22:43:59 2011 @@ -210,14 +210,7 @@ AddDIE (die); } - const DWARFAbbreviationDeclaration* abbrDecl = die.GetAbbreviationDeclarationPtr(); - if (abbrDecl) - { - // Normal DIE - if (abbrDecl->HasChildren()) - ++depth; - } - else + if (die.IsNULL()) { // NULL DIE. if (depth > 0) @@ -225,6 +218,12 @@ if (depth == 0) break; // We are done with this compile unit! } + else + { + // Normal DIE + if (die.HasChildren()) + ++depth; + } } @@ -469,23 +468,21 @@ // safely access the next die in the array. DWARFDebugInfoEntry* next_die = curr_die + 1; - const DWARFAbbreviationDeclaration* curr_die_abbrev = curr_die->GetAbbreviationDeclarationPtr(); - - if (curr_die_abbrev) - { - // Normal DIE - if (curr_die_abbrev->HasChildren()) - next_die->SetParent(curr_die); - else - curr_die->SetSibling(next_die); - } - else + if (curr_die->IsNULL()) { // NULL DIE that terminates a sibling chain DWARFDebugInfoEntry* parent = curr_die->GetParent(); if (parent) parent->SetSibling(next_die); } + else + { + // Normal DIE + if (curr_die->HasChildren()) + next_die->SetParent(curr_die); + else + curr_die->SetSibling(next_die); + } } // Since we skipped the last element, we need to fix it up! Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp?rev=144975&r1=144974&r2=144975&view=diff ============================================================================== --- lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp (original) +++ lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp Thu Nov 17 22:43:59 2011 @@ -113,23 +113,27 @@ { m_offset = *offset_ptr; - dw_uleb128_t abbrCode = debug_info_data.GetULEB128 (offset_ptr); + uint64_t abbr_idx = debug_info_data.GetULEB128 (offset_ptr); + assert (abbr_idx < (1 << DIE_ABBR_IDX_BITSIZE)); + m_abbr_idx = abbr_idx; assert (fixed_form_sizes); // For best performance this should be specified! - if (abbrCode) + if (m_abbr_idx) { uint32_t offset = *offset_ptr; - m_abbrevDecl = cu->GetAbbreviations()->GetAbbreviationDeclaration(abbrCode); + const DWARFAbbreviationDeclaration *abbrevDecl = cu->GetAbbreviations()->GetAbbreviationDeclaration(m_abbr_idx); + m_tag = abbrevDecl->Tag(); + m_has_children = abbrevDecl->HasChildren(); // Skip all data in the .debug_info for the attributes - const uint32_t numAttributes = m_abbrevDecl->NumAttributes(); + const uint32_t numAttributes = abbrevDecl->NumAttributes(); register uint32_t i; register dw_form_t form; for (i=0; iGetFormByIndexUnchecked(i); + form = abbrevDecl->GetFormByIndexUnchecked(i); const uint8_t fixed_skip_size = fixed_form_sizes [form]; if (fixed_skip_size) @@ -213,7 +217,8 @@ } else { - m_abbrevDecl = NULL; + m_tag = 0; + m_has_children = false; return true; // NULL debug tag entry } @@ -246,28 +251,30 @@ { m_offset = offset; - dw_uleb128_t abbrCode = debug_info_data.GetULEB128(&offset); - - if (abbrCode) + const uint64_t abbr_idx = debug_info_data.GetULEB128(&offset); + assert (abbr_idx < (1 << DIE_ABBR_IDX_BITSIZE)); + m_abbr_idx = abbr_idx; + if (abbr_idx) { - m_abbrevDecl = cu->GetAbbreviations()->GetAbbreviationDeclaration(abbrCode); + const DWARFAbbreviationDeclaration *abbrevDecl = cu->GetAbbreviations()->GetAbbreviationDeclaration(abbr_idx); - if (m_abbrevDecl) + if (abbrevDecl) { - dw_tag_t tag = m_abbrevDecl->Tag(); + m_tag = abbrevDecl->Tag(); + m_has_children = abbrevDecl->HasChildren(); - bool isCompileUnitTag = tag == DW_TAG_compile_unit; + bool isCompileUnitTag = m_tag == DW_TAG_compile_unit; if (cu && isCompileUnitTag) ((DWARFCompileUnit*)cu)->SetBaseAddress(0); // Skip all data in the .debug_info for the attributes - const uint32_t numAttributes = m_abbrevDecl->NumAttributes(); + const uint32_t numAttributes = abbrevDecl->NumAttributes(); uint32_t i; dw_attr_t attr; dw_form_t form; for (i=0; iGetAttrAndFormByIndexUnchecked(i, attr, form); + abbrevDecl->GetAttrAndFormByIndexUnchecked(i, attr, form); if (isCompileUnitTag && ((attr == DW_AT_entry_pc) || (attr == DW_AT_low_pc))) { @@ -359,7 +366,8 @@ } else { - m_abbrevDecl = NULL; + m_tag = 0; + m_has_children = false; *offset_ptr = offset; return true; // NULL debug tag entry } @@ -369,209 +377,6 @@ } //---------------------------------------------------------------------- -// AppendDependentDIES() -//---------------------------------------------------------------------- -bool -DWARFDebugInfoEntry::AppendDependentDIES -( - SymbolFileDWARF* dwarf2Data, - const DWARFCompileUnit* cu, - const bool add_children, - DWARFDIECollection& dependent_dies -) const -{ - // Add this object's DIE offset - // The line below is the only place that should add a die to the - // dependent_dies collection as we have to be careful of recursion! - if ( !dependent_dies.Insert(this) ) - return false; // This DIE already exists in the collection, nothing to do! - - //DEBUG_PRINTF(" dependent_dies.Insert(0x%8.8x)\n", GetOffset());/// - - if (m_abbrevDecl) - { - // Keep adding parent DIE offsets as long as the offsets do not - // already exist in the collection - const DWARFDebugInfoEntry* die = GetParent(); - while ( die && die->AppendDependentDIES(dwarf2Data, cu, false, dependent_dies) ) - die = die->GetParent(); - - bool add_non_subprogram_children = false; - bool add_children_override = false; - - if (!add_children) - { - switch (m_abbrevDecl->Tag()) - { - case DW_TAG_array_type: break; - case DW_TAG_class_type: add_non_subprogram_children = true; break; - case DW_TAG_entry_point: break; - case DW_TAG_enumeration_type: break; - case DW_TAG_formal_parameter: break; - case DW_TAG_imported_declaration: break; - case DW_TAG_label: break; - case DW_TAG_lexical_block: add_children_override = true; break; - case DW_TAG_member: break; - case DW_TAG_pointer_type: break; - case DW_TAG_reference_type: break; - case DW_TAG_compile_unit: break; - case DW_TAG_string_type: break; - case DW_TAG_structure_type: add_non_subprogram_children = true; break; - case DW_TAG_subroutine_type: add_children_override = true; break; - case DW_TAG_typedef: break; - case DW_TAG_union_type: add_non_subprogram_children = true; break; - case DW_TAG_unspecified_parameters: break; - case DW_TAG_variant: break; - case DW_TAG_common_block: break; - case DW_TAG_common_inclusion: break; - case DW_TAG_inheritance: break; - case DW_TAG_inlined_subroutine: break; - case DW_TAG_module: break; - case DW_TAG_ptr_to_member_type: break; - case DW_TAG_set_type: break; - case DW_TAG_subrange_type: break; - case DW_TAG_with_stmt: break; - case DW_TAG_access_declaration: break; - case DW_TAG_base_type: break; - case DW_TAG_catch_block: break; - case DW_TAG_const_type: break; - case DW_TAG_constant: break; - case DW_TAG_enumerator: break; - case DW_TAG_file_type: break; - case DW_TAG_friend: break; - case DW_TAG_namelist: break; - case DW_TAG_namelist_item: break; - case DW_TAG_packed_type: break; - case DW_TAG_subprogram: add_children_override = true; break; - case DW_TAG_template_type_parameter: break; - case DW_TAG_template_value_parameter: break; - case DW_TAG_thrown_type: break; - case DW_TAG_try_block: break; - case DW_TAG_variant_part: break; - case DW_TAG_variable: break; - case DW_TAG_volatile_type: break; - case DW_TAG_dwarf_procedure: break; - case DW_TAG_restrict_type: break; - case DW_TAG_interface_type: break; - case DW_TAG_namespace: break; - case DW_TAG_imported_module: break; - case DW_TAG_unspecified_type: break; - case DW_TAG_partial_unit: break; - case DW_TAG_imported_unit: break; - case DW_TAG_shared_type: break; - } - } - const DataExtractor& debug_info_data = dwarf2Data->get_debug_info_data(); - - // Dump all data in the .debug_info for the attributes - const uint32_t numAttributes = m_abbrevDecl->NumAttributes(); - uint32_t i; - dw_offset_t offset = GetOffset(); - debug_info_data.Skip_LEB128(&offset); // Skip abbreviation code - - dw_attr_t attr; - dw_form_t form; - for (i=0; iGetAttrAndFormByIndexUnchecked(i, attr, form); - DWARFFormValue form_value(form); - - switch (attr) - { - // All cases that use refer to another DIE should use this case - // without - // having to check the FORM of the attribute to tell if it refers to another - // DIE - case DW_AT_abstract_origin: - case DW_AT_import: - case DW_AT_discr: - case DW_AT_containing_type: - case DW_AT_base_types: - case DW_AT_friend: - case DW_AT_specification: - case DW_AT_type: - case DW_AT_common_reference: - case DW_AT_default_value: - { - form_value.ExtractValue(debug_info_data, &offset, cu); - DWARFCompileUnitSP cu_sp_ptr; - const DWARFDebugInfoEntry* ref_die = const_cast(dwarf2Data)->DebugInfo()->GetDIEPtr(form_value.Reference(cu), &cu_sp_ptr); - if (ref_die) - ref_die->AppendDependentDIES(dwarf2Data, cu_sp_ptr.get(), true, dependent_dies); - } - break; - - default: - if (attr != DW_AT_sibling) - { - switch (form_value.Form()) - { - case DW_FORM_ref_addr: - case DW_FORM_ref1: - case DW_FORM_ref2: - case DW_FORM_ref4: - case DW_FORM_ref8: - case DW_FORM_ref_udata: -// Log::WarningVerbose("DWARFDebugInfoEntry::AppendDependentDIES() -- check on this item %s: attr = %s form = %s", -// DW_TAG_value_to_name(m_abbrevDecl->Tag()), -// DW_AT_value_to_name(attr), -// DW_FORM_value_to_name(form)); - break; - } - } - form_value.SkipValue(debug_info_data, &offset, cu); - break; - } - } - - if (m_abbrevDecl->HasChildren()) - { - const DWARFDebugInfoEntry* child; - for (child = GetFirstChild(); child != NULL; child = child->GetSibling()) - { - bool add = add_children || add_children_override; - - if (!add) - { - if (add_non_subprogram_children) - { - // add_non_subprogram_children is used for classes and structs - // that may contain children that are the member variables that - // may have functions as children and whom may add the class or - // struct by adding their parent. We don't want to add any - // functions though since they may have been optimized out. But - // we do need to watch for declarations and keep them. - if (child->Tag() == DW_TAG_subprogram) - { - // Check if this subprogram TAG had a DW_AT_declaration attribute set to 1. - // If so we need to include this DIE so that we always have a complete view - // of a class definition so debuggers can track down any weak symbols that - // may not have had weak definition entries. - if (child->GetAttributeValueAsUnsigned(dwarf2Data, cu, DW_AT_declaration, 0) == 1) - add = true; - } - else - { - // Add all other items inside a class/struct - add = true; - } - } - else - { - // We don't need to add this child, only add it if it's a NULL tag - add = child->IsNULL(); - } - } - - if (add) - child->AppendDependentDIES(dwarf2Data, cu, true, dependent_dies); - } - } - } - return true; -} - -//---------------------------------------------------------------------- // DumpAncestry // // Dumps all of a debug information entries parents up until oldest and @@ -894,7 +699,10 @@ dw_addr_t hi_pc = DW_INVALID_ADDRESS; std::vector die_offsets; bool set_frame_base_loclist_addr = false; - if (m_abbrevDecl) + + const DWARFAbbreviationDeclaration* abbrevDecl = GetAbbreviationDeclarationPtr(cu); + + if (abbrevDecl) { const DataExtractor& debug_info_data = dwarf2Data->get_debug_info_data(); uint32_t offset = m_offset; @@ -905,13 +713,13 @@ // Skip the abbreviation code debug_info_data.Skip_LEB128(&offset); - const uint32_t numAttributes = m_abbrevDecl->NumAttributes(); + const uint32_t numAttributes = abbrevDecl->NumAttributes(); uint32_t i; dw_attr_t attr; dw_form_t form; for (i=0; iGetAttrAndFormByIndexUnchecked(i, attr, form); + abbrevDecl->GetAttrAndFormByIndexUnchecked(i, attr, form); DWARFFormValue form_value(form); if (form_value.ExtractValue(debug_info_data, &offset, cu)) { @@ -1088,19 +896,21 @@ s.Indent(); if (abbrCode) { - if (m_abbrevDecl) + const DWARFAbbreviationDeclaration* abbrevDecl = GetAbbreviationDeclarationPtr(cu); + + if (abbrevDecl) { - s.PutCString(DW_TAG_value_to_name(m_abbrevDecl->Tag())); - s.Printf( " [%u] %c\n", abbrCode, m_abbrevDecl->HasChildren() ? '*':' '); + s.PutCString(DW_TAG_value_to_name(abbrevDecl->Tag())); + s.Printf( " [%u] %c\n", abbrCode, abbrevDecl->HasChildren() ? '*':' '); // Dump all data in the .debug_info for the attributes - const uint32_t numAttributes = m_abbrevDecl->NumAttributes(); + const uint32_t numAttributes = abbrevDecl->NumAttributes(); uint32_t i; dw_attr_t attr; dw_form_t form; for (i=0; iGetAttrAndFormByIndexUnchecked(i, attr, form); + abbrevDecl->GetAttrAndFormByIndexUnchecked(i, attr, form); DumpAttribute(dwarf2Data, cu, debug_info_data, &offset, s, attr, form); } @@ -1326,7 +1136,9 @@ uint32_t curr_depth ) const { - if (m_abbrevDecl) + const DWARFAbbreviationDeclaration* abbrevDecl = GetAbbreviationDeclarationPtr(cu); + + if (abbrevDecl) { if (fixed_form_sizes == NULL) fixed_form_sizes = DWARFFormValue::GetFixedFormSizesForAddressSize(cu->GetAddressByteSize()); @@ -1336,14 +1148,14 @@ // Skip the abbreviation code so we are at the data for the attributes debug_info_data.Skip_LEB128(&offset); - const uint32_t num_attributes = m_abbrevDecl->NumAttributes(); + const uint32_t num_attributes = abbrevDecl->NumAttributes(); uint32_t i; dw_attr_t attr; dw_form_t form; DWARFFormValue form_value; for (i=0; iGetAttrAndFormByIndexUnchecked (i, attr, form); + abbrevDecl->GetAttrAndFormByIndexUnchecked (i, attr, form); // If we are tracking down DW_AT_specification or DW_AT_abstract_origin // attributes, the depth will be non-zero. We need to omit certain @@ -1423,9 +1235,11 @@ dw_offset_t* end_attr_offset_ptr ) const { - if (m_abbrevDecl) + const DWARFAbbreviationDeclaration* abbrevDecl = GetAbbreviationDeclarationPtr(cu); + + if (abbrevDecl) { - uint32_t attr_idx = m_abbrevDecl->FindAttributeIndex(attr); + uint32_t attr_idx = abbrevDecl->FindAttributeIndex(attr); if (attr_idx != DW_INVALID_INDEX) { @@ -1438,10 +1252,10 @@ uint32_t idx=0; while (idxGetFormByIndex(idx++), debug_info_data, &offset, cu); + DWARFFormValue::SkipValue(abbrevDecl->GetFormByIndex(idx++), debug_info_data, &offset, cu); const dw_offset_t attr_offset = offset; - form_value.SetForm(m_abbrevDecl->GetFormByIndex(idx)); + form_value.SetForm(abbrevDecl->GetFormByIndex(idx)); if (form_value.ExtractValue(debug_info_data, &offset, cu)) { if (end_attr_offset_ptr) @@ -1749,7 +1563,7 @@ else { bool result = true; - const DWARFAbbreviationDeclaration* abbrevDecl = die.GetAbbreviationDeclarationPtr(); + const DWARFAbbreviationDeclaration* abbrevDecl = die.GetAbbreviationDeclarationPtr(cu); switch (abbrevDecl->Tag()) { @@ -1831,10 +1645,9 @@ DWARFDebugAranges* debug_aranges ) const { - if (m_abbrevDecl) + if (m_tag) { - dw_tag_t tag = m_abbrevDecl->Tag(); - if (tag == DW_TAG_subprogram) + if (m_tag == DW_TAG_subprogram) { dw_addr_t hi_pc = DW_INVALID_ADDRESS; dw_addr_t lo_pc = GetAttributeValueAsUnsigned(dwarf2Data, cu, DW_AT_low_pc, DW_INVALID_ADDRESS); @@ -1873,10 +1686,9 @@ DWARFDebugAranges* debug_aranges ) const { - if (m_abbrevDecl) + if (m_tag) { - dw_tag_t tag = m_abbrevDecl->Tag(); - if (tag == DW_TAG_subprogram) + if (m_tag == DW_TAG_subprogram) { dw_addr_t hi_pc = DW_INVALID_ADDRESS; dw_addr_t lo_pc = GetAttributeValueAsUnsigned(dwarf2Data, cu, DW_AT_low_pc, DW_INVALID_ADDRESS); @@ -1913,13 +1725,12 @@ ) { bool found_address = false; - if (m_abbrevDecl) + if (m_tag) { bool check_children = false; bool match_addr_range = false; - dw_tag_t tag = m_abbrevDecl->Tag(); // printf("0x%8.8x: %30s: address = 0x%8.8x - ", m_offset, DW_TAG_value_to_name(tag), address); - switch (tag) + switch (m_tag) { case DW_TAG_array_type : break; case DW_TAG_class_type : check_children = true; break; @@ -1993,7 +1804,7 @@ { found_address = true; // puts("***MATCH***"); - switch (tag) + switch (m_tag) { case DW_TAG_compile_unit: // File check_children = ((function_die != NULL) || (block_die != NULL)); @@ -2024,7 +1835,7 @@ { // compile units may not have a valid high/low pc when there // are address gaps in subroutines so we must always search // if there is no valid high and low PC - check_children = (tag == DW_TAG_compile_unit) && ((function_die != NULL) || (block_die != NULL)); + check_children = (m_tag == DW_TAG_compile_unit) && ((function_die != NULL) || (block_die != NULL)); } } else @@ -2043,7 +1854,7 @@ { found_address = true; // puts("***MATCH***"); - switch (tag) + switch (m_tag) { case DW_TAG_compile_unit: // File check_children = ((function_die != NULL) || (block_die != NULL)); @@ -2093,6 +1904,14 @@ return found_address; } +const DWARFAbbreviationDeclaration* +DWARFDebugInfoEntry::GetAbbreviationDeclarationPtr (const DWARFCompileUnit *cu) const +{ + if (m_abbr_idx) + return cu->GetAbbreviations()->GetAbbreviationDeclaration (m_abbr_idx); + return NULL; +} + bool DWARFDebugInfoEntry::OffsetLessThan (const DWARFDebugInfoEntry& a, const DWARFDebugInfoEntry& b) Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.h?rev=144975&r1=144974&r2=144975&view=diff ============================================================================== --- lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.h (original) +++ lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.h Thu Nov 17 22:43:59 2011 @@ -11,9 +11,9 @@ #define SymbolFileDWARF_DWARFDebugInfoEntry_h_ #include "SymbolFileDWARF.h" - #include "llvm/ADT/SmallVector.h" +#include "DWARFDebugAbbrev.h" #include "DWARFAbbreviationDeclaration.h" #include "DWARFDebugRanges.h" #include @@ -41,6 +41,8 @@ typedef UInt32ToDIEMMap::iterator UInt32ToDIEMMapIter; typedef UInt32ToDIEMMap::const_iterator UInt32ToDIEMMapConstIter; +#define DIE_ABBR_IDX_BITSIZE 15 + class DWARFDebugInfoEntry { public: @@ -105,7 +107,8 @@ m_offset (DW_INVALID_OFFSET), m_parent_idx (0), m_sibling_idx (0), - m_abbrevDecl (NULL) + m_abbr_idx (0), + m_has_children (false) { } @@ -229,12 +232,6 @@ const DWARFDebugInfoEntry& a, const DWARFDebugInfoEntry& b); - bool AppendDependentDIES( - SymbolFileDWARF* dwarf2Data, - const DWARFCompileUnit* cu, - const bool add_children, - DWARFDIECollection& die_offsets) const; - void Dump( SymbolFileDWARF* dwarf2Data, const DWARFCompileUnit* cu, @@ -276,13 +273,44 @@ int& call_column, lldb_private::DWARFExpression *frame_base = NULL) const; + const DWARFAbbreviationDeclaration* + GetAbbreviationDeclarationPtr (const DWARFCompileUnit *cu) const; + + dw_tag_t + Tag () const + { + return m_tag; + } + + bool + IsNULL() const + { + return m_abbr_idx == 0; + } + + dw_offset_t + GetOffset () const + { + return m_offset; + } + + void + SetOffset (dw_offset_t offset) + { + m_offset = offset; + } - dw_tag_t Tag() const { return m_abbrevDecl ? m_abbrevDecl->Tag() : 0; } - bool IsNULL() const { return m_abbrevDecl == NULL; } - dw_offset_t GetOffset() const { return m_offset; } - void SetOffset(dw_offset_t offset) { m_offset = offset; } - uint32_t NumAttributes() const { return m_abbrevDecl ? m_abbrevDecl->NumAttributes() : 0; } - bool HasChildren() const { return m_abbrevDecl != NULL && m_abbrevDecl->HasChildren(); } + bool + HasChildren () const + { + return m_has_children; + } + + void + SetHasChildren (bool b) + { + m_has_children = b; + } // We know we are kept in a vector of contiguous entries, so we know // our parent will be some index behind "this". @@ -323,13 +351,15 @@ else m_sibling_idx = 0; } - const DWARFAbbreviationDeclaration* GetAbbreviationDeclarationPtr() const { return m_abbrevDecl; } protected: - dw_offset_t m_offset; // Offset within the .debug_info of the start of this entry - uint32_t m_parent_idx; // How many to subtract from "this" to get the parent. If zero this die has no parent - uint32_t m_sibling_idx; // How many to add to "this" to get the sibling. - const DWARFAbbreviationDeclaration* m_abbrevDecl; + dw_offset_t m_offset; // Offset within the .debug_info of the start of this entry + uint32_t m_parent_idx; // How many to subtract from "this" to get the parent. If zero this die has no parent + uint32_t m_sibling_idx; // How many to add to "this" to get the sibling. + uint32_t m_abbr_idx:DIE_ABBR_IDX_BITSIZE, + m_has_children:1, + m_tag:16; + }; #endif // SymbolFileDWARF_DWARFDebugInfoEntry_h_ Modified: lldb/trunk/source/Target/Process.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/Process.cpp?rev=144975&r1=144974&r2=144975&view=diff ============================================================================== --- lldb/trunk/source/Target/Process.cpp (original) +++ lldb/trunk/source/Target/Process.cpp Thu Nov 17 22:43:59 2011 @@ -257,7 +257,6 @@ // settings that were set with "settings set" if (m_file_actions.empty()) { - const char *path; if (m_flags.Test(eLaunchFlagDisableSTDIO)) { AppendSuppressFileAction (STDERR_FILENO, true , true ); From gclayton at apple.com Fri Nov 18 01:03:08 2011 From: gclayton at apple.com (Greg Clayton) Date: Fri, 18 Nov 2011 07:03:08 -0000 Subject: [Lldb-commits] [lldb] r144976 - in /lldb/trunk: include/lldb/Target/ source/Plugins/Process/gdb-remote/ tools/debugserver/source/ tools/debugserver/source/MacOSX/ Message-ID: <20111118070309.0BC9F2A6C133@llvm.org> Author: gclayton Date: Fri Nov 18 01:03:08 2011 New Revision: 144976 URL: http://llvm.org/viewvc/llvm-project?rev=144976&view=rev Log: Added optional calls to lldb_private::Process for getting memory region info from a process and hooked it up to the new packet that was recently added to our GDB remote executable named debugserver. Now Process has the following new calls: virtual Error Process::GetMemoryRegionInfo (lldb::addr_t load_addr, MemoryRegionInfo &range_info); virtual uint32_t GetLoadAddressPermissions (lldb::addr_t load_addr); Only the first one needs to be implemented by subclasses that can add this support. Cleaned up the way the new packet was implemented in debugserver to be more useful as an API inside debugserver. Also found an error where finding a region for an address actually will pick up the next region that follows the address in the query so we also need ot make sure that the address we requested the region for falls into the region that gets returned. Modified: lldb/trunk/include/lldb/Target/Process.h 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 lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h lldb/trunk/tools/debugserver/source/DNB.cpp lldb/trunk/tools/debugserver/source/DNB.h lldb/trunk/tools/debugserver/source/DNBDefs.h lldb/trunk/tools/debugserver/source/MacOSX/MachProcess.cpp lldb/trunk/tools/debugserver/source/MacOSX/MachProcess.h lldb/trunk/tools/debugserver/source/MacOSX/MachTask.cpp lldb/trunk/tools/debugserver/source/MacOSX/MachTask.h lldb/trunk/tools/debugserver/source/MacOSX/MachVMMemory.cpp lldb/trunk/tools/debugserver/source/MacOSX/MachVMMemory.h lldb/trunk/tools/debugserver/source/MacOSX/MachVMRegion.cpp lldb/trunk/tools/debugserver/source/MacOSX/MachVMRegion.h lldb/trunk/tools/debugserver/source/RNBRemote.cpp Modified: lldb/trunk/include/lldb/Target/Process.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/Process.h?rev=144976&r1=144975&r2=144976&view=diff ============================================================================== --- lldb/trunk/include/lldb/Target/Process.h (original) +++ lldb/trunk/include/lldb/Target/Process.h Fri Nov 18 01:03:08 2011 @@ -27,6 +27,7 @@ #include "lldb/Core/Communication.h" #include "lldb/Core/Error.h" #include "lldb/Core/Event.h" +#include "lldb/Core/RangeMap.h" #include "lldb/Core/StringList.h" #include "lldb/Core/ThreadSafeValue.h" #include "lldb/Core/PluginInterface.h" @@ -1171,6 +1172,77 @@ else return false; } + +class MemoryRegionInfo +{ +public: + typedef Range RangeType; + + MemoryRegionInfo () : + m_range (), + m_permissions (0) + { + } + + ~MemoryRegionInfo () + { + } + + RangeType & + GetRange() + { + return m_range; + } + + void + Clear() + { + m_range.Clear(); + m_permissions = 0; + } + + const RangeType & + GetRange() const + { + return m_range; + } + + // Pass in a uint32_t permissions with one or more lldb::Permissions + // enumeration values logical OR'ed together. + bool + TestPermissions (uint32_t permissions) const + { + return m_permissions.AllSet(permissions); + } + + const Flags & + GetPermissions () const + { + return m_permissions; + } + + void + SetPermissions (uint32_t permissions) + { + m_permissions.Reset(permissions); + } + + void + AddPermissions (uint32_t permissions) + { + m_permissions.Set (permissions); + } + + void + RemovePermissions (uint32_t permissions) + { + m_permissions.Clear (permissions); + } + +protected: + RangeType m_range; + Flags m_permissions; // Uses lldb::Permissions enumeration values logical OR'ed together +}; //---------------------------------------------------------------------- /// @class Process Process.h "lldb/Target/Process.h" @@ -2478,6 +2550,25 @@ lldb::addr_t AllocateMemory (size_t size, uint32_t permissions, Error &error); + virtual Error + GetMemoryRegionInfo (lldb::addr_t load_addr, + MemoryRegionInfo &range_info) + { + Error error; + error.SetErrorString ("Process::GetMemoryRegionInfo() not supported"); + return error; + } + + virtual uint32_t + GetLoadAddressPermissions (lldb::addr_t load_addr) + { + MemoryRegionInfo range_info; + Error error (GetMemoryRegionInfo (load_addr, range_info)); + if (error.Success()) + return range_info.GetPermissions().Get(); + return 0; + } + //------------------------------------------------------------------ /// Determines whether executing JIT-compiled code in this process /// is possible. 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=144976&r1=144975&r2=144976&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp (original) +++ lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp Fri Nov 18 01:03:08 2011 @@ -46,6 +46,7 @@ m_supports_vCont_S (eLazyBoolCalculate), m_qHostInfo_is_valid (eLazyBoolCalculate), m_supports_alloc_dealloc_memory (eLazyBoolCalculate), + m_supports_memory_region_info (eLazyBoolCalculate), m_supports_qProcessInfoPID (true), m_supports_qfProcessInfo (true), m_supports_qUserName (true), @@ -123,6 +124,7 @@ m_supports_vCont_S = eLazyBoolCalculate; m_qHostInfo_is_valid = eLazyBoolCalculate; m_supports_alloc_dealloc_memory = eLazyBoolCalculate; + m_supports_memory_region_info = eLazyBoolCalculate; m_supports_qProcessInfoPID = true; m_supports_qfProcessInfo = true; @@ -1086,6 +1088,77 @@ return false; } +Error +GDBRemoteCommunicationClient::GetMemoryRegionInfo (lldb::addr_t addr, + lldb_private::MemoryRegionInfo ®ion_info) +{ + Error error; + region_info.Clear(); + + if (m_supports_memory_region_info != eLazyBoolNo) + { + m_supports_memory_region_info = eLazyBoolYes; + char packet[64]; + const int packet_len = ::snprintf(packet, sizeof(packet), "qMemoryRegionInfo:%llx", (uint64_t)addr); + assert (packet_len < sizeof(packet)); + StringExtractorGDBRemote response; + if (SendPacketAndWaitForResponse (packet, packet_len, response, false)) + { + std::string name; + std::string value; + addr_t addr_value; + bool success = true; + while (success && response.GetNameColonValue(name, value)) + { + if (name.compare ("start") == 0) + { + addr_value = Args::StringToUInt64(value.c_str(), LLDB_INVALID_ADDRESS, 16, &success); + if (success) + region_info.GetRange().SetRangeBase(addr_value); + } + else if (name.compare ("size") == 0) + { + addr_value = Args::StringToUInt64(value.c_str(), 0, 16, &success); + if (success) + region_info.GetRange().SetByteSize (addr_value); + } + else if (name.compare ("permissions") == 0) + { + if (value.find('r') != std::string::npos) + region_info.AddPermissions (ePermissionsReadable); + if (value.find('w') != std::string::npos) + region_info.AddPermissions (ePermissionsWritable); + if (value.find('x') != std::string::npos) + region_info.AddPermissions (ePermissionsExecutable); + } + else if (name.compare ("error") == 0) + { + StringExtractorGDBRemote name_extractor; + // Swap "value" over into "name_extractor" + name_extractor.GetStringRef().swap(value); + // Now convert the HEX bytes into a string value + name_extractor.GetHexByteString (value); + error.SetErrorString(value.c_str()); + } + } + } + else + { + m_supports_memory_region_info = eLazyBoolNo; + } + } + + if (m_supports_memory_region_info == eLazyBoolNo) + { + error.SetErrorString("qMemoryRegionInfo is not supported"); + } + if (error.Fail()) + region_info.Clear(); + return error; + +} + + int GDBRemoteCommunicationClient::SetSTDIN (char const *path) { 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=144976&r1=144975&r2=144976&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.h (original) +++ lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.h Fri Nov 18 01:03:08 2011 @@ -17,6 +17,7 @@ // Other libraries and framework includes // Project includes #include "lldb/Core/ArchSpec.h" +#include "lldb/Target/Process.h" #include "GDBRemoteCommunication.h" @@ -196,6 +197,10 @@ bool DeallocateMemory (lldb::addr_t addr); + lldb_private::Error + GetMemoryRegionInfo (lldb::addr_t addr, + lldb_private::MemoryRegionInfo &range_info); + const lldb_private::ArchSpec & GetHostArchitecture (); @@ -332,6 +337,7 @@ lldb_private::LazyBool m_supports_vCont_S; lldb_private::LazyBool m_qHostInfo_is_valid; lldb_private::LazyBool m_supports_alloc_dealloc_memory; + lldb_private::LazyBool m_supports_memory_region_info; bool m_supports_qProcessInfoPID:1, 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=144976&r1=144975&r2=144976&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp (original) +++ lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp Fri Nov 18 01:03:08 2011 @@ -1704,6 +1704,15 @@ } Error +ProcessGDBRemote::GetMemoryRegionInfo (addr_t load_addr, + MemoryRegionInfo ®ion_info) +{ + + Error error (m_gdb_comm.GetMemoryRegionInfo (load_addr, region_info)); + return error; +} + +Error ProcessGDBRemote::DoDeallocateMemory (lldb::addr_t addr) { Error error; Modified: lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h?rev=144976&r1=144975&r2=144976&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h (original) +++ lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h Fri Nov 18 01:03:08 2011 @@ -167,6 +167,10 @@ DoAllocateMemory (size_t size, uint32_t permissions, lldb_private::Error &error); virtual lldb_private::Error + GetMemoryRegionInfo (lldb::addr_t load_addr, + lldb_private::MemoryRegionInfo ®ion_info); + + virtual lldb_private::Error DoDeallocateMemory (lldb::addr_t ptr); //------------------------------------------------------------------ Modified: lldb/trunk/tools/debugserver/source/DNB.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/debugserver/source/DNB.cpp?rev=144976&r1=144975&r2=144976&view=diff ============================================================================== --- lldb/trunk/tools/debugserver/source/DNB.cpp (original) +++ lldb/trunk/tools/debugserver/source/DNB.cpp Fri Nov 18 01:03:08 2011 @@ -1139,13 +1139,12 @@ // //---------------------------------------------------------------------- int -DNBMemoryRegionInfo (nub_process_t pid, nub_addr_t addr, char *outbuf, nub_size_t outbufsize) +DNBMemoryRegionInfo (nub_process_t pid, nub_addr_t addr, DNBRegionInfo *region_info) { MachProcessSP procSP; if (GetProcessSP (pid, procSP)) - { - return procSP->MemoryRegionInfo(addr, outbuf, outbufsize); - } + return procSP->Task().GetMemoryRegionInfo (addr, region_info); + return -1; } Modified: lldb/trunk/tools/debugserver/source/DNB.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/debugserver/source/DNB.h?rev=144976&r1=144975&r2=144976&view=diff ============================================================================== --- lldb/trunk/tools/debugserver/source/DNB.h (original) +++ lldb/trunk/tools/debugserver/source/DNB.h Fri Nov 18 01:03:08 2011 @@ -66,7 +66,7 @@ nub_size_t DNBProcessMemoryWrite (nub_process_t pid, nub_addr_t addr, nub_size_t size, const void *buf) DNB_EXPORT; nub_addr_t DNBProcessMemoryAllocate (nub_process_t pid, nub_size_t size, uint32_t permissions) DNB_EXPORT; nub_bool_t DNBProcessMemoryDeallocate (nub_process_t pid, nub_addr_t addr) DNB_EXPORT; -int DNBMemoryRegionInfo (nub_process_t pid, nub_addr_t addr, char *outbuf, nub_size_t outbufsize); +int DNBMemoryRegionInfo (nub_process_t pid, nub_addr_t addr, DNBRegionInfo *region_info) DNB_EXPORT; //---------------------------------------------------------------------- // Process status Modified: lldb/trunk/tools/debugserver/source/DNBDefs.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/debugserver/source/DNBDefs.h?rev=144976&r1=144975&r2=144976&view=diff ============================================================================== --- lldb/trunk/tools/debugserver/source/DNBDefs.h (original) +++ lldb/trunk/tools/debugserver/source/DNBDefs.h Fri Nov 18 01:03:08 2011 @@ -333,6 +333,13 @@ DNBSegment *segments; // Array of contiguous memory segments in executable }; +struct DNBRegionInfo +{ + nub_addr_t addr; + nub_addr_t size; + uint32_t permissions; +}; + typedef nub_bool_t (*DNBCallbackBreakpointHit)(nub_process_t pid, nub_thread_t tid, nub_break_t breakID, void *baton); typedef nub_addr_t (*DNBCallbackNameToAddress)(nub_process_t pid, const char *name, const char *shlib_regex, void *baton); typedef nub_size_t (*DNBCallbackCopyExecutableImageInfos)(nub_process_t pid, struct DNBExecutableImageInfo **image_infos, nub_bool_t only_changed, void *baton); Modified: lldb/trunk/tools/debugserver/source/MacOSX/MachProcess.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/debugserver/source/MacOSX/MachProcess.cpp?rev=144976&r1=144975&r2=144976&view=diff ============================================================================== --- lldb/trunk/tools/debugserver/source/MacOSX/MachProcess.cpp (original) +++ lldb/trunk/tools/debugserver/source/MacOSX/MachProcess.cpp Fri Nov 18 01:03:08 2011 @@ -603,12 +603,6 @@ return bytes_written; } -int -MachProcess::MemoryRegionInfo(nub_addr_t address, char *outbuf, nub_size_t outbufsize) -{ - return m_task.MemoryRegionInfo (address, outbuf, outbufsize); -} - void MachProcess::ReplyToAllExceptions () { Modified: lldb/trunk/tools/debugserver/source/MacOSX/MachProcess.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/debugserver/source/MacOSX/MachProcess.h?rev=144976&r1=144975&r2=144976&view=diff ============================================================================== --- lldb/trunk/tools/debugserver/source/MacOSX/MachProcess.h (original) +++ lldb/trunk/tools/debugserver/source/MacOSX/MachProcess.h Fri Nov 18 01:03:08 2011 @@ -99,7 +99,6 @@ bool Detach (); nub_size_t ReadMemory (nub_addr_t addr, nub_size_t size, void *buf); nub_size_t WriteMemory (nub_addr_t addr, nub_size_t size, const void *buf); - int MemoryRegionInfo(nub_addr_t address, char *outbuf, nub_size_t outbufsize); //---------------------------------------------------------------------- // Path and arg accessors Modified: lldb/trunk/tools/debugserver/source/MacOSX/MachTask.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/debugserver/source/MacOSX/MachTask.cpp?rev=144976&r1=144975&r2=144976&view=diff ============================================================================== --- lldb/trunk/tools/debugserver/source/MacOSX/MachTask.cpp (original) +++ lldb/trunk/tools/debugserver/source/MacOSX/MachTask.cpp Fri Nov 18 01:03:08 2011 @@ -208,14 +208,19 @@ // MachTask::MemoryRegionInfo //---------------------------------------------------------------------- int -MachTask::MemoryRegionInfo (nub_addr_t addr, char *outbuf, nub_size_t outbufsize) +MachTask::GetMemoryRegionInfo (nub_addr_t addr, DNBRegionInfo *region_info) { task_t task = TaskPort(); if (task == TASK_NULL) return -1; - int ret = m_vm_memory.MemoryRegionInfo(task, addr, outbuf, outbufsize); - DNBLogThreadedIf(LOG_MEMORY, "MachTask::MemoryRegionInfo ( addr = 0x%8.8llx ) => %d", (uint64_t)addr, ret); + int ret = m_vm_memory.GetMemoryRegionInfo(task, addr, region_info); + DNBLogThreadedIf(LOG_MEMORY, "MachTask::MemoryRegionInfo ( addr = 0x%8.8llx ) => %i (start = 0x%8.8llx, size = 0x%8.8llx, permissions = %u)", + (uint64_t)addr, + ret, + (uint64_t)region_info->addr, + (uint64_t)region_info->size, + region_info->permissions); return ret; } Modified: lldb/trunk/tools/debugserver/source/MacOSX/MachTask.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/debugserver/source/MacOSX/MachTask.h?rev=144976&r1=144975&r2=144976&view=diff ============================================================================== --- lldb/trunk/tools/debugserver/source/MacOSX/MachTask.h (original) +++ lldb/trunk/tools/debugserver/source/MacOSX/MachTask.h Fri Nov 18 01:03:08 2011 @@ -64,7 +64,7 @@ nub_size_t ReadMemory (nub_addr_t addr, nub_size_t size, void *buf); nub_size_t WriteMemory (nub_addr_t addr, nub_size_t size, const void *buf); - int MemoryRegionInfo (nub_addr_t addr, char *outbuf, nub_size_t outbufsize); + int GetMemoryRegionInfo (nub_addr_t addr, DNBRegionInfo *region_info); nub_addr_t AllocateMemory (nub_size_t size, uint32_t permissions); nub_bool_t DeallocateMemory (nub_addr_t addr); Modified: lldb/trunk/tools/debugserver/source/MacOSX/MachVMMemory.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/debugserver/source/MacOSX/MachVMMemory.cpp?rev=144976&r1=144975&r2=144976&view=diff ============================================================================== --- lldb/trunk/tools/debugserver/source/MacOSX/MachVMMemory.cpp (original) +++ lldb/trunk/tools/debugserver/source/MacOSX/MachVMMemory.cpp Fri Nov 18 01:03:08 2011 @@ -53,15 +53,21 @@ } int -MachVMMemory::MemoryRegionInfo(task_t task, nub_addr_t address, char *outbuf, nub_size_t outbufsize) +MachVMMemory::GetMemoryRegionInfo(task_t task, nub_addr_t address, DNBRegionInfo *region_info) { MachVMRegion vmRegion(task); - outbuf[0] = '\0'; - if (vmRegion.GetRegionForAddress(address) && vmRegion.GetRegionDescription(outbuf, outbufsize)) + if (vmRegion.GetRegionForAddress(address)) + { + region_info->addr = vmRegion.StartAddress(); + region_info->size = vmRegion.GetByteSize(); + region_info->permissions = vmRegion.GetDNBPermissions(); return 1; - else - return 0; + } + region_info->addr = 0; + region_info->size = 0; + region_info->permissions = 0; + return 0; } nub_size_t Modified: lldb/trunk/tools/debugserver/source/MacOSX/MachVMMemory.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/debugserver/source/MacOSX/MachVMMemory.h?rev=144976&r1=144975&r2=144976&view=diff ============================================================================== --- lldb/trunk/tools/debugserver/source/MacOSX/MachVMMemory.h (original) +++ lldb/trunk/tools/debugserver/source/MacOSX/MachVMMemory.h Fri Nov 18 01:03:08 2011 @@ -27,7 +27,7 @@ nub_size_t Read(task_t task, nub_addr_t address, void *data, nub_size_t data_count); nub_size_t Write(task_t task, nub_addr_t address, const void *data, nub_size_t data_count); nub_size_t PageSize(); - int MemoryRegionInfo(task_t task, nub_addr_t address, char *outbuf, nub_size_t outbufsize); + int GetMemoryRegionInfo(task_t task, nub_addr_t address, DNBRegionInfo *region_info); protected: nub_size_t MaxBytesLeftInPage(nub_addr_t addr, nub_size_t count); Modified: lldb/trunk/tools/debugserver/source/MacOSX/MachVMRegion.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/debugserver/source/MacOSX/MachVMRegion.cpp?rev=144976&r1=144975&r2=144976&view=diff ============================================================================== --- lldb/trunk/tools/debugserver/source/MacOSX/MachVMRegion.cpp (original) +++ lldb/trunk/tools/debugserver/source/MacOSX/MachVMRegion.cpp Fri Nov 18 01:03:08 2011 @@ -134,7 +134,21 @@ mach_msg_type_number_t info_size = kRegionInfoSize; assert(sizeof(info_size) == 4); m_err = ::mach_vm_region_recurse (m_task, &m_start, &m_size, &m_depth, (vm_region_recurse_info_t)&m_data, &info_size); - if (DNBLogCheckLogBit(LOG_MEMORY_PROTECTIONS) || m_err.Fail()) + const bool log_protections = DNBLogCheckLogBit(LOG_MEMORY_PROTECTIONS); + if (m_err.Success()) + { + if ((addr < m_start) || (addr >= (m_start + m_size))) + { + m_err.SetErrorString("no region for address"); + m_err.SetError(-1, DNBError::Generic); + if (log_protections) + m_err.LogThreaded("::mach_vm_region_recurse ( task = 0x%4.4x, address => 0x%8.8llx, size => %llu, nesting_depth => %d, info => %p, infoCnt => %d) addr = 0x%8.8llx not in range [0x%8.8llx - 0x%8.8llx)", + m_task, (uint64_t)m_start, (uint64_t)m_size, m_depth, &m_data, info_size, (uint64_t)addr, (uint64_t)m_start, (uint64_t)m_start + m_size); + return false; + } + } + + if (log_protections || m_err.Fail()) m_err.LogThreaded("::mach_vm_region_recurse ( task = 0x%4.4x, address => 0x%8.8llx, size => %llu, nesting_depth => %d, info => %p, infoCnt => %d) addr = 0x%8.8llx ", m_task, (uint64_t)m_start, (uint64_t)m_size, m_depth, &m_data, info_size, (uint64_t)addr); if (m_err.Fail()) { @@ -142,7 +156,7 @@ } else { - if (DNBLogCheckLogBit(LOG_MEMORY_PROTECTIONS)) + if (log_protections) { DNBLogThreaded("info = { prot = %u, " "max_prot = %u, " @@ -178,26 +192,18 @@ return true; } -bool -MachVMRegion::GetRegionDescription (char *outbuf, nub_size_t outbufsize) +uint32_t +MachVMRegion::GetDNBPermissions () const { - if (m_addr == INVALID_NUB_ADDRESS || m_start == INVALID_NUB_ADDRESS || m_size == 0) - return false; - snprintf (outbuf, outbufsize, "start:%llx,size:%llx", m_start, m_size); - outbuf[outbufsize - 1] = '\0'; - - char tmpbuf[128]; - strcpy (tmpbuf, ",permissions:"); - if ((m_data.protection & VM_PROT_READ) == VM_PROT_READ) - strcat (tmpbuf, "r"); - if ((m_data.protection & VM_PROT_WRITE) == VM_PROT_WRITE) - strcat (tmpbuf, "w"); - if ((m_data.protection & VM_PROT_EXECUTE) == VM_PROT_EXECUTE) - strcat (tmpbuf, "x"); - strlcat (outbuf, tmpbuf, outbufsize); - - // It would be nice if we could figure out whether the memory region is stack memory or jitted code memory as well - - outbuf[outbufsize - 1] = '\0'; - return true; + if (m_addr == INVALID_NUB_ADDRESS || m_start == INVALID_NUB_ADDRESS || m_size == 0) + return 0; + uint32_t dnb_permissions = 0; + + if ((m_data.protection & VM_PROT_READ) == VM_PROT_READ) + dnb_permissions |= eMemoryPermissionsReadable; + if ((m_data.protection & VM_PROT_WRITE) == VM_PROT_WRITE) + dnb_permissions |= eMemoryPermissionsWritable; + if ((m_data.protection & VM_PROT_EXECUTE) == VM_PROT_EXECUTE) + dnb_permissions |= eMemoryPermissionsExecutable; + return dnb_permissions; } Modified: lldb/trunk/tools/debugserver/source/MacOSX/MachVMRegion.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/debugserver/source/MacOSX/MachVMRegion.h?rev=144976&r1=144975&r2=144976&view=diff ============================================================================== --- lldb/trunk/tools/debugserver/source/MacOSX/MachVMRegion.h (original) +++ lldb/trunk/tools/debugserver/source/MacOSX/MachVMRegion.h Fri Nov 18 01:03:08 2011 @@ -27,6 +27,7 @@ void Clear(); mach_vm_address_t StartAddress() const { return m_start; } mach_vm_address_t EndAddress() const { return m_start + m_size; } + mach_vm_size_t GetByteSize () const { return m_size; } mach_vm_address_t BytesRemaining(mach_vm_address_t addr) const { if (ContainsAddress(addr)) @@ -43,7 +44,8 @@ bool RestoreProtections(); bool GetRegionForAddress(nub_addr_t addr); - bool GetRegionDescription (char *outbuf, nub_size_t outbufsize); + uint32_t + GetDNBPermissions () const; protected: #if defined (VM_REGION_SUBMAP_SHORT_INFO_COUNT_64) Modified: lldb/trunk/tools/debugserver/source/RNBRemote.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/debugserver/source/RNBRemote.cpp?rev=144976&r1=144975&r2=144976&view=diff ============================================================================== --- lldb/trunk/tools/debugserver/source/RNBRemote.cpp (original) +++ lldb/trunk/tools/debugserver/source/RNBRemote.cpp Fri Nov 18 01:03:08 2011 @@ -3282,16 +3282,51 @@ return HandlePacket_ILLFORMED (__FILE__, __LINE__, p, "Invalid address in qMemoryRegionInfo packet"); } - char retbuf[1024]; + DNBRegionInfo region_info = { 0, 0, 0 }; + int ret = DNBMemoryRegionInfo (m_ctx.ProcessID(), address, ®ion_info); + std::ostringstream ostrm; - int ret = DNBMemoryRegionInfo (m_ctx.ProcessID(), address, retbuf, sizeof (retbuf)); - retbuf[sizeof (retbuf) - 1] = '\0'; - if (ret == 1) - return SendPacket (retbuf); - if (ret == 0) - return SendPacket ("error:address in unmapped region"); - if (ret == -1) - return SendPacket ("error:region lookup cannot be performed"); + if (ret == 1 && region_info.size > 0) + { + // start:3a50000,size:100000,permissions:rwx + ostrm << "start:" << std::hex << region_info.addr << ';' + << "size:" << std::hex << region_info.size << ';'; + + if (region_info.permissions) + { + ostrm << "permissions:"; + + if (region_info.permissions & eMemoryPermissionsReadable) + ostrm << 'r'; + if (region_info.permissions & eMemoryPermissionsWritable) + ostrm << 'w'; + if (region_info.permissions & eMemoryPermissionsExecutable) + ostrm << 'x'; + ostrm << ';'; + } + return SendPacket (ostrm.str()); + } + else + { + ostrm << std::hex << "error:"; + const char *error_message = NULL; + if (ret == -1) + { + error_message = "region lookup cannot be performed"; + } + else + { + error_message = "address in unmapped region"; + } + // hex encode the error message so we can send any characters we want in + // the future since this is text + const int error_message_len = strlen (error_message); + const uint8_t *u_error_message = (const uint8_t *)error_message; + for (int i = 0; i < error_message_len; i++) + ostrm << RAWHEX8(u_error_message[i]); + ostrm << ';'; + return SendPacket (ostrm.str()); + } return SendPacket ("E68"); } From jingham at apple.com Fri Nov 18 18:19:25 2011 From: jingham at apple.com (Jim Ingham) Date: Sat, 19 Nov 2011 00:19:25 -0000 Subject: [Lldb-commits] [lldb] r144981 - in /lldb/trunk: include/lldb/Core/ModuleList.h include/lldb/Target/DynamicLoader.h source/Core/ModuleList.cpp source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.cpp source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.h Message-ID: <20111119001925.93A942A6C133@llvm.org> Author: jingham Date: Fri Nov 18 18:19:25 2011 New Revision: 144981 URL: http://llvm.org/viewvc/llvm-project?rev=144981&view=rev Log: Handle stepping through a trampoline where the jump target is calculated a runtime - and so doesn't match the name of the PLT entry. This solution assumes a naming convention agreed upon by us and the system folks, and isn't general. The general solution requires actually finding & calling the resolver function if it hasn't been called yet. That's more tricky. Modified: lldb/trunk/include/lldb/Core/ModuleList.h lldb/trunk/include/lldb/Target/DynamicLoader.h lldb/trunk/source/Core/ModuleList.cpp lldb/trunk/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.cpp lldb/trunk/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.h Modified: lldb/trunk/include/lldb/Core/ModuleList.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/ModuleList.h?rev=144981&r1=144980&r2=144981&view=diff ============================================================================== --- lldb/trunk/include/lldb/Core/ModuleList.h (original) +++ lldb/trunk/include/lldb/Core/ModuleList.h Fri Nov 18 18:19:25 2011 @@ -296,8 +296,15 @@ size_t FindSymbolsWithNameAndType (const ConstString &name, lldb::SymbolType symbol_type, - SymbolContextList &sc_list); + SymbolContextList &sc_list, + bool append = false); + size_t + FindSymbolsMatchingRegExAndType (const RegularExpression ®ex, + lldb::SymbolType symbol_type, + SymbolContextList &sc_list, + bool append = false); + //------------------------------------------------------------------ /// Find types by name. /// Modified: lldb/trunk/include/lldb/Target/DynamicLoader.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/DynamicLoader.h?rev=144981&r1=144980&r2=144981&view=diff ============================================================================== --- lldb/trunk/include/lldb/Target/DynamicLoader.h (original) +++ lldb/trunk/include/lldb/Target/DynamicLoader.h Fri Nov 18 18:19:25 2011 @@ -143,6 +143,31 @@ //------------------------------------------------------------------ + /// Some dynamic loaders provide features where there are a group of symbols "equivalent to" + /// a given symbol one of which will be chosen when the symbol is bound. If you want to + /// set a breakpoint on one of these symbols, you really need to set it on all the + /// equivalent symbols. + /// + /// + /// @param[in] original_symbol + /// The symbol for which we are finding equivalences. + /// + /// @param[in] module_list + /// The set of modules in which to search. + /// + /// @param[out] equivalent_symbols + /// The equivalent symbol list - any equivalent symbols found are appended to this list. + /// + /// @return + /// Number of equivalent symbols found. + //------------------------------------------------------------------ + virtual size_t + FindEquivalentSymbols (Symbol *original_symbol, ModuleList &module_list, SymbolContextList &equivalent_symbols) + { + return 0; + } + + //------------------------------------------------------------------ /// Ask if it is ok to try and load or unload an shared library /// (image). /// Modified: lldb/trunk/source/Core/ModuleList.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/ModuleList.cpp?rev=144981&r1=144980&r2=144981&view=diff ============================================================================== --- lldb/trunk/source/Core/ModuleList.cpp (original) +++ lldb/trunk/source/Core/ModuleList.cpp Fri Nov 18 18:19:25 2011 @@ -248,14 +248,35 @@ size_t ModuleList::FindSymbolsWithNameAndType (const ConstString &name, SymbolType symbol_type, - SymbolContextList &sc_list) + SymbolContextList &sc_list, + bool append) { Mutex::Locker locker(m_modules_mutex); - sc_list.Clear(); + if (!append) + sc_list.Clear(); + size_t initial_size = sc_list.GetSize(); + collection::iterator pos, end = m_modules.end(); for (pos = m_modules.begin(); pos != end; ++pos) (*pos)->FindSymbolsWithNameAndType (name, symbol_type, sc_list); - return sc_list.GetSize(); + return sc_list.GetSize() - initial_size; +} + + size_t +ModuleList::FindSymbolsMatchingRegExAndType (const RegularExpression ®ex, + lldb::SymbolType symbol_type, + SymbolContextList &sc_list, + bool append) +{ + Mutex::Locker locker(m_modules_mutex); + if (!append) + sc_list.Clear(); + size_t initial_size = sc_list.GetSize(); + + collection::iterator pos, end = m_modules.end(); + for (pos = m_modules.begin(); pos != end; ++pos) + (*pos)->FindSymbolsMatchingRegExAndType (regex, symbol_type, sc_list); + return sc_list.GetSize() - initial_size; } class ModuleMatches Modified: lldb/trunk/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.cpp?rev=144981&r1=144980&r2=144981&view=diff ============================================================================== --- lldb/trunk/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.cpp (original) +++ lldb/trunk/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.cpp Fri Nov 18 18:19:25 2011 @@ -1423,6 +1423,14 @@ } } +// This bit in the n_desc field of the mach file means that this is a +// stub that runs arbitrary code to determine the trampoline target. +// We've established a naming convention with the CoreOS folks for the +// equivalent symbols they will use for this (which the objc guys didn't follow...) +// For now we'll just look for all symbols matching that naming convention... + +#define MACH_O_N_SYMBOL_RESOLVER 0x100 + ThreadPlanSP DynamicLoaderMacOSXDYLD::GetStepThroughTrampolinePlan (Thread &thread, bool stop_others) { @@ -1442,46 +1450,75 @@ { SymbolContextList target_symbols; ModuleList &images = thread.GetProcess().GetTarget().GetImages(); + images.FindSymbolsWithNameAndType(trampoline_name, eSymbolTypeCode, target_symbols); - // FIXME - Make the Run to Address take multiple addresses, and - // run to any of them. - uint32_t num_symbols = target_symbols.GetSize(); - if (num_symbols == 1) + + size_t num_original_symbols = target_symbols.GetSize(); + bool orig_is_resolver = (current_symbol->GetFlags() & MACH_O_N_SYMBOL_RESOLVER) == MACH_O_N_SYMBOL_RESOLVER; + + if (num_original_symbols > 0) { - SymbolContext context; - AddressRange addr_range; - if (target_symbols.GetContextAtIndex(0, context)) + // We found symbols that look like they are the targets to our symbol. Now look through the + // modules containing our symbols to see if there are any for our symbol. + + ModuleList modules_to_search; + + for (size_t i = 0; i < num_original_symbols; i++) { - context.GetAddressRange (eSymbolContextEverything, 0, false, addr_range); - thread_plan_sp.reset (new ThreadPlanRunToAddress (thread, addr_range.GetBaseAddress(), stop_others)); + SymbolContext sc; + target_symbols.GetContextAtIndex(i, sc); + + Module* module_to_add = sc.symbol->CalculateSymbolContextModule(); + if (module_to_add) + modules_to_search.AppendIfNeeded(static_cast(module_to_add)); } - else + + // If the original stub symbol is a resolver, then we don't want to break on the symbol with the + // original name, but instead on all the symbols it could resolve to since otherwise we would stop + // in the middle of the resolution... + // Note that the stub is not of the resolver type it will point to the equivalent symbol, + // not the original name, so in that case we don't need to do anything. + + if (orig_is_resolver) { - if (log) - log->Printf ("Couldn't resolve the symbol context."); + target_symbols.Clear(); + + FindEquivalentSymbols (current_symbol, modules_to_search, target_symbols); } - } - else if (num_symbols > 1) - { - std::vector addresses; - addresses.resize (num_symbols); - for (uint32_t i = 0; i < num_symbols; i++) + + // FIXME - Make the Run to Address take multiple addresses, and + // run to any of them. + uint32_t num_symbols = target_symbols.GetSize(); + if (num_symbols > 0) { - SymbolContext context; - AddressRange addr_range; - if (target_symbols.GetContextAtIndex(i, context)) + std::vector addresses; + addresses.resize (num_symbols); + for (uint32_t i = 0; i < num_symbols; i++) { - context.GetAddressRange (eSymbolContextEverything, 0, false, addr_range); - lldb::addr_t load_addr = addr_range.GetBaseAddress().GetLoadAddress(&thread.GetProcess().GetTarget()); - addresses[i] = load_addr; + SymbolContext context; + AddressRange addr_range; + if (target_symbols.GetContextAtIndex(i, context)) + { + context.GetAddressRange (eSymbolContextEverything, 0, false, addr_range); + lldb::addr_t load_addr = addr_range.GetBaseAddress().GetLoadAddress(&thread.GetProcess().GetTarget()); + addresses[i] = load_addr; + } + } + if (addresses.size() > 0) + thread_plan_sp.reset (new ThreadPlanRunToAddress (thread, addresses, stop_others)); + else + { + if (log) + log->Printf ("Couldn't resolve the symbol contexts."); } } - if (addresses.size() > 0) - thread_plan_sp.reset (new ThreadPlanRunToAddress (thread, addresses, stop_others)); else { if (log) - log->Printf ("Couldn't resolve the symbol contexts."); + { + log->Printf ("Found a resolver stub for: \"%s\" but could not find any symbols it resolves to.", + trampoline_name.AsCString()); + } } } else @@ -1503,6 +1540,29 @@ return thread_plan_sp; } +size_t +DynamicLoaderMacOSXDYLD::FindEquivalentSymbols (lldb_private::Symbol *original_symbol, + lldb_private::ModuleList &images, + lldb_private::SymbolContextList &equivalent_symbols) +{ + const ConstString &trampoline_name = original_symbol->GetMangled().GetName(Mangled::ePreferMangled); + if (!trampoline_name) + return 0; + + size_t initial_size = equivalent_symbols.GetSize(); + + static const char *resolver_name_regex = "(_gc|_non_gc|\\$[A-Z0-9]+)$"; + std::string equivalent_regex_buf("^"); + equivalent_regex_buf.append (trampoline_name.GetCString()); + equivalent_regex_buf.append (resolver_name_regex); + + RegularExpression equivalent_name_regex (equivalent_regex_buf.c_str()); + const bool append = true; + images.FindSymbolsMatchingRegExAndType (equivalent_name_regex, eSymbolTypeCode, equivalent_symbols, append); + + return equivalent_symbols.GetSize() - initial_size; +} + Error DynamicLoaderMacOSXDYLD::CanLoadImage () { Modified: lldb/trunk/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.h?rev=144981&r1=144980&r2=144981&view=diff ============================================================================== --- lldb/trunk/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.h (original) +++ lldb/trunk/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.h Fri Nov 18 18:19:25 2011 @@ -66,6 +66,11 @@ GetStepThroughTrampolinePlan (lldb_private::Thread &thread, bool stop_others); + virtual size_t + FindEquivalentSymbols (lldb_private::Symbol *original_symbol, + lldb_private::ModuleList &module_list, + lldb_private::SymbolContextList &equivalent_symbols); + virtual lldb_private::Error CanLoadImage (); From scallanan at apple.com Fri Nov 18 19:35:08 2011 From: scallanan at apple.com (Sean Callanan) Date: Sat, 19 Nov 2011 01:35:08 -0000 Subject: [Lldb-commits] [lldb] r144982 - /lldb/trunk/source/Symbol/ClangASTContext.cpp Message-ID: <20111119013508.C2C4F2A6C133@llvm.org> Author: spyffe Date: Fri Nov 18 19:35:08 2011 New Revision: 144982 URL: http://llvm.org/viewvc/llvm-project?rev=144982&view=rev Log: Ensure that the empty RecordDecl generated for templates is properly complete (though still empty). 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=144982&r1=144981&r2=144982&view=diff ============================================================================== --- lldb/trunk/source/Symbol/ClangASTContext.cpp (original) +++ lldb/trunk/source/Symbol/ClangASTContext.cpp Fri Nov 18 19:35:08 2011 @@ -1196,8 +1196,12 @@ SourceLocation(), SourceLocation(), &identifier_info); - - + + // With templated classes, we say that a class is templated with + // specializations, but that the bare class has no functions. + template_cxx_decl->startDefinition(); + template_cxx_decl->completeDefinition(); + class_template_decl = ClassTemplateDecl::Create (*ast, decl_ctx, // What decl context do we use here? TU? The actual decl context? SourceLocation(), From gclayton at apple.com Fri Nov 18 20:11:31 2011 From: gclayton at apple.com (Greg Clayton) Date: Sat, 19 Nov 2011 02:11:31 -0000 Subject: [Lldb-commits] [lldb] r144983 - in /lldb/trunk/source/Plugins: Process/gdb-remote/ProcessGDBRemote.cpp SymbolFile/DWARF/DWARFCompileUnit.cpp SymbolFile/DWARF/DWARFCompileUnit.h SymbolFile/DWARF/DWARFDebugInfoEntry.cpp SymbolFile/DWARF/DWARFDebugInfoEntry.h Message-ID: <20111119021131.578E82A6C133@llvm.org> Author: gclayton Date: Fri Nov 18 20:11:30 2011 New Revision: 144983 URL: http://llvm.org/viewvc/llvm-project?rev=144983&view=rev Log: Further performance improvements in the DWARF parser: 1 - the DIE collections no longer have the NULL tags which saves up to 25% of the memory on typical C++ code 2 - faster parsing by not having to run the SetDIERelations() function anymore it is done when parsing the DWARF very efficiently. Modified: lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.h lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.h Modified: lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp?rev=144983&r1=144982&r2=144983&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp (original) +++ lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp Fri Nov 18 20:11:30 2011 @@ -773,7 +773,7 @@ { char packet[64]; const int packet_len = ::snprintf (packet, sizeof(packet), "vAttach;%x", attach_pid); - + SetID (attach_pid); m_async_broadcaster.BroadcastEvent (eBroadcastBitAsyncContinue, new EventDataBytes (packet, packet_len)); } } 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=144983&r1=144982&r2=144983&view=diff ============================================================================== --- lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp (original) +++ lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp Fri Nov 18 20:11:30 2011 @@ -28,6 +28,7 @@ using namespace lldb_private; using namespace std; + extern int g_verbose; DWARFCompileUnit::DWARFCompileUnit(SymbolFileDWARF* dwarf2Data) : @@ -176,7 +177,10 @@ // We are in our compile unit, parse starting at the offset // we were told to parse const DataExtractor& debug_info_data = m_dwarf2Data->get_debug_info_data(); - + std::vector die_index_stack; + die_index_stack.reserve(32); + die_index_stack.push_back(0); + bool prev_die_had_children = false; const uint8_t *fixed_form_sizes = DWARFFormValue::GetFixedFormSizesForAddressSize (GetAddressByteSize()); while (offset < next_cu_offset && die.FastExtract (debug_info_data, this, fixed_form_sizes, &offset)) @@ -188,43 +192,70 @@ // DW_TAG_value_to_name (die.Tag()), // die.HasChildren() ? " *" : ""); + const bool null_die = die.IsNULL(); if (depth == 0) { uint64_t base_addr = die.GetAttributeValueAsUnsigned(m_dwarf2Data, this, DW_AT_low_pc, LLDB_INVALID_ADDRESS); if (base_addr == LLDB_INVALID_ADDRESS) base_addr = die.GetAttributeValueAsUnsigned(m_dwarf2Data, this, DW_AT_entry_pc, 0); SetBaseAddress (base_addr); - } - - if (cu_die_only) - { - AddDIE (die); - return 1; - } - else if (depth == 0 && initial_die_array_size == 1) - { - // Don't append the CU die as we already did that + if (initial_die_array_size == 0) + AddDIE (die); + if (cu_die_only) + return 1; } else { - AddDIE (die); + if (null_die) + { + if (prev_die_had_children) + { + // This will only happen if a DIE says is has children + // but all it contains is a NULL tag. Since we are removing + // the NULL DIEs from the list (saves up to 25% in C++ code), + // we need a way to let the DIE know that it actually doesn't + // have children. + if (!m_die_array.empty()) + m_die_array.back().SetEmptyChildren(true); + } + } + else + { + die.SetParentIndex(m_die_array.size() - die_index_stack[depth-1]); + + if (die_index_stack.back()) + m_die_array[die_index_stack.back()].SetSiblingIndex(m_die_array.size()-die_index_stack.back()); + + // Only push the DIE if it isn't a NULL DIE + m_die_array.push_back(die); + } } - if (die.IsNULL()) + if (null_die) { // NULL DIE. + if (!die_index_stack.empty()) + die_index_stack.pop_back(); + if (depth > 0) --depth; if (depth == 0) break; // We are done with this compile unit! + + prev_die_had_children = false; } else { + die_index_stack.back() = m_die_array.size() - 1; // Normal DIE - if (die.HasChildren()) + const bool die_has_children = die.HasChildren(); + if (die_has_children) + { + die_index_stack.push_back(0); ++depth; + } + prev_die_had_children = die_has_children; } - } // Give a little bit of info if we encounter corrupt DWARF (our offset @@ -240,8 +271,15 @@ } fprintf (stderr, "warning: DWARF compile unit extends beyond its bounds cu 0x%8.8x at 0x%8.8x in '%s'\n", GetOffset(), offset, path); } + + LogSP log (LogChannelDWARF::GetLogIfAll (DWARF_LOG_DEBUG_INFO)); + if (log) + { + StreamString strm; + DWARFDebugInfoEntry::DumpDIECollection (strm, m_die_array); + log->PutCString (strm.GetString().c_str()); + } - SetDIERelations(); return m_die_array.size(); } @@ -406,114 +444,6 @@ } //---------------------------------------------------------------------- -// SetDIERelations() -// -// We read in all of the DIE entries into our flat list of DIE entries -// and now we need to go back through all of them and set the parent, -// sibling and child pointers for quick DIE navigation. -//---------------------------------------------------------------------- -void -DWARFCompileUnit::SetDIERelations() -{ -#if 0 - // Compute average bytes per DIE - // - // We can figure out what the average number of bytes per DIE is - // to help us pre-allocate the correct number of m_die_array - // entries so we don't end up doing a lot of memory copies as we - // are creating our DIE array when parsing - // - // Enable this code by changing "#if 0" above to "#if 1" and running - // the dsymutil or dwarfdump with a bunch of dwarf files and see what - // the running average ends up being in the stdout log. - static size_t g_total_cu_debug_info_size = 0; - static size_t g_total_num_dies = 0; - static size_t g_min_bytes_per_die = UINT32_MAX; - static size_t g_max_bytes_per_die = 0; - const size_t num_dies = m_die_array.size(); - const size_t cu_debug_info_size = GetDebugInfoSize(); - const size_t bytes_per_die = cu_debug_info_size / num_dies; - if (g_min_bytes_per_die > bytes_per_die) - g_min_bytes_per_die = bytes_per_die; - if (g_max_bytes_per_die < bytes_per_die) - g_max_bytes_per_die = bytes_per_die; - if (g_total_cu_debug_info_size == 0) - { - cout << " min max avg" << endl - << "n dies cu size bpd bpd bpd bpd" << endl - << "------ -------- --- === === ===" << endl; - } - g_total_cu_debug_info_size += cu_debug_info_size; - g_total_num_dies += num_dies; - const size_t avg_bytes_per_die = g_total_cu_debug_info_size / g_total_num_dies; - cout - << DECIMAL_WIDTH(6) << num_dies << ' ' - << DECIMAL_WIDTH(8) << cu_debug_info_size << ' ' - << DECIMAL_WIDTH(3) << bytes_per_die << ' ' - << DECIMAL_WIDTH(3) << g_min_bytes_per_die << ' ' - << DECIMAL_WIDTH(3) << g_max_bytes_per_die << ' ' - << DECIMAL_WIDTH(3) << avg_bytes_per_die - << endl; -#endif - if (m_die_array.empty()) - return; - DWARFDebugInfoEntry* die_array_begin = &m_die_array.front(); - DWARFDebugInfoEntry* die_array_end = &m_die_array.back(); - DWARFDebugInfoEntry* curr_die; - // We purposely are skipping the last element in the array in the loop below - // so that we can always have a valid next item - for (curr_die = die_array_begin; curr_die < die_array_end; ++curr_die) - { - // Since our loop doesn't include the last element, we can always - // safely access the next die in the array. - DWARFDebugInfoEntry* next_die = curr_die + 1; - - if (curr_die->IsNULL()) - { - // NULL DIE that terminates a sibling chain - DWARFDebugInfoEntry* parent = curr_die->GetParent(); - if (parent) - parent->SetSibling(next_die); - } - else - { - // Normal DIE - if (curr_die->HasChildren()) - next_die->SetParent(curr_die); - else - curr_die->SetSibling(next_die); - } - } - - // Since we skipped the last element, we need to fix it up! - if (die_array_begin < die_array_end) - curr_die->SetParent(die_array_begin); - -#if 0 - // The code below will dump the DIE relations in case any modification - // is done to the above code. This dump can be used in a diff to make - // sure that no functionality is lost. - { - DWARFDebugInfoEntry::const_iterator pos; - DWARFDebugInfoEntry::const_iterator end = m_die_array.end(); - puts("offset parent sibling child"); - puts("-------- -------- -------- --------"); - for (pos = m_die_array.begin(); pos != end; ++pos) - { - const DWARFDebugInfoEntry& die_ref = *pos; - const DWARFDebugInfoEntry* p = die_ref.GetParent(); - const DWARFDebugInfoEntry* s = die_ref.GetSibling(); - const DWARFDebugInfoEntry* c = die_ref.GetFirstChild(); - printf("%.8x: %.8x %.8x %.8x\n", die_ref.GetOffset(), - p ? p->GetOffset() : 0, - s ? s->GetOffset() : 0, - c ? c->GetOffset() : 0); - } - } -#endif - -} -//---------------------------------------------------------------------- // Compare function DWARFDebugAranges::Range structures //---------------------------------------------------------------------- static bool CompareDIEOffset (const DWARFDebugInfoEntry& die1, const DWARFDebugInfoEntry& die2) Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.h?rev=144983&r1=144982&r2=144983&view=diff ============================================================================== --- lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.h (original) +++ lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.h Fri Nov 18 20:11:30 2011 @@ -55,9 +55,6 @@ m_base_addr = base_addr; } - void - SetDIERelations(); - const DWARFDebugInfoEntry* GetCompileUnitDIEOnly() { Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp?rev=144983&r1=144982&r2=144983&view=diff ============================================================================== --- lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp (original) +++ lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp Fri Nov 18 20:11:30 2011 @@ -112,11 +112,13 @@ ) { m_offset = *offset_ptr; - + m_parent_idx = 0; + m_sibling_idx = 0; + m_empty_children = false; uint64_t abbr_idx = debug_info_data.GetULEB128 (offset_ptr); assert (abbr_idx < (1 << DIE_ABBR_IDX_BITSIZE)); m_abbr_idx = abbr_idx; - + assert (fixed_form_sizes); // For best performance this should be specified! if (m_abbr_idx) @@ -1919,3 +1921,28 @@ return a.GetOffset() < b.GetOffset(); } +void +DWARFDebugInfoEntry::DumpDIECollection (Stream &strm, DWARFDebugInfoEntry::collection &die_collection) +{ + DWARFDebugInfoEntry::const_iterator pos; + DWARFDebugInfoEntry::const_iterator end = die_collection.end(); + puts("offset parent sibling child"); + puts("-------- -------- -------- --------"); + for (pos = die_collection.begin(); pos != end; ++pos) + { + const DWARFDebugInfoEntry& die_ref = *pos; + const DWARFDebugInfoEntry* p = die_ref.GetParent(); + const DWARFDebugInfoEntry* s = die_ref.GetSibling(); + const DWARFDebugInfoEntry* c = die_ref.GetFirstChild(); + strm.Printf("%.8x: %.8x %.8x %.8x 0x%4.4x %s%s\n", + die_ref.GetOffset(), + p ? p->GetOffset() : 0, + s ? s->GetOffset() : 0, + c ? c->GetOffset() : 0, + die_ref.Tag(), + DW_TAG_value_to_name(die_ref.Tag()), + die_ref.HasChildren() ? " *" : ""); + } +} + + Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.h?rev=144983&r1=144982&r2=144983&view=diff ============================================================================== --- lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.h (original) +++ lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.h Fri Nov 18 20:11:30 2011 @@ -41,6 +41,7 @@ typedef UInt32ToDIEMMap::iterator UInt32ToDIEMMapIter; typedef UInt32ToDIEMMap::const_iterator UInt32ToDIEMMapConstIter; +#define DIE_SIBLING_IDX_BITSIZE 31 #define DIE_ABBR_IDX_BITSIZE 15 class DWARFDebugInfoEntry @@ -107,11 +108,24 @@ m_offset (DW_INVALID_OFFSET), m_parent_idx (0), m_sibling_idx (0), + m_empty_children(false), m_abbr_idx (0), - m_has_children (false) + m_has_children (false), + m_tag (0) { } + void Clear () + { + m_offset = DW_INVALID_OFFSET; + m_parent_idx = 0; + m_sibling_idx = 0; + m_empty_children = false; + m_abbr_idx = 0; + m_has_children = false; + m_tag = 0; + } + bool Contains (const DWARFDebugInfoEntry *die) const; void BuildAddressRangeTable( @@ -323,8 +337,8 @@ // We know we are kept in a vector of contiguous entries, so we know // we don't need to store our child pointer, if we have a child it will // be the next entry in the list... - DWARFDebugInfoEntry* GetFirstChild() { return HasChildren() ? this + 1 : NULL; } - const DWARFDebugInfoEntry* GetFirstChild() const { return HasChildren() ? this + 1 : NULL; } + DWARFDebugInfoEntry* GetFirstChild() { return (HasChildren() && !m_empty_children) ? this + 1 : NULL; } + const DWARFDebugInfoEntry* GetFirstChild() const { return (HasChildren() && !m_empty_children) ? this + 1 : NULL; } void SetParent (DWARFDebugInfoEntry* parent) @@ -352,13 +366,42 @@ m_sibling_idx = 0; } + void + SetSiblingIndex (uint32_t idx) + { + m_sibling_idx = idx; + } + + void + SetParentIndex (uint32_t idx) + { + m_parent_idx = idx; + } + + bool + GetEmptyChildren () const + { + return m_empty_children; + } + + void + SetEmptyChildren (bool b) + { + m_empty_children = b; + } + + static void + DumpDIECollection (lldb_private::Stream &strm, + DWARFDebugInfoEntry::collection &die_collection); + protected: - dw_offset_t m_offset; // Offset within the .debug_info of the start of this entry - uint32_t m_parent_idx; // How many to subtract from "this" to get the parent. If zero this die has no parent - uint32_t m_sibling_idx; // How many to add to "this" to get the sibling. + dw_offset_t m_offset; // Offset within the .debug_info of the start of this entry + uint32_t m_parent_idx; // How many to subtract from "this" to get the parent. If zero this die has no parent + uint32_t m_sibling_idx:31, // How many to add to "this" to get the sibling. + m_empty_children:1; // If a DIE says it had children, yet it just contained a NULL tag, this will be set. uint32_t m_abbr_idx:DIE_ABBR_IDX_BITSIZE, - m_has_children:1, - m_tag:16; + m_has_children:1, // Set to 1 if this DIE has children + m_tag:16; // A copy of the DW_TAG value so we don't have to go through the compile unit abbrev table }; From peter at pcc.me.uk Sun Nov 20 18:10:14 2011 From: peter at pcc.me.uk (Peter Collingbourne) Date: Mon, 21 Nov 2011 00:10:14 -0000 Subject: [Lldb-commits] [lldb] r145020 - in /lldb/trunk/source/Plugins/Platform/Linux: PlatformLinux.cpp PlatformLinux.h Message-ID: <20111121001014.ECCE42A6C134@llvm.org> Author: pcc Date: Sun Nov 20 18:10:14 2011 New Revision: 145020 URL: http://llvm.org/viewvc/llvm-project?rev=145020&view=rev Log: Update PlatformLinux::Attach signature. Modified: lldb/trunk/source/Plugins/Platform/Linux/PlatformLinux.cpp lldb/trunk/source/Plugins/Platform/Linux/PlatformLinux.h Modified: lldb/trunk/source/Plugins/Platform/Linux/PlatformLinux.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Platform/Linux/PlatformLinux.cpp?rev=145020&r1=145019&r2=145020&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Platform/Linux/PlatformLinux.cpp (original) +++ lldb/trunk/source/Plugins/Platform/Linux/PlatformLinux.cpp Sun Nov 20 18:10:14 2011 @@ -249,7 +249,7 @@ } lldb::ProcessSP -PlatformLinux::Attach(lldb::pid_t pid, +PlatformLinux::Attach(ProcessAttachInfo &attach_info, Debugger &debugger, Target *target, Listener &listener, Modified: lldb/trunk/source/Plugins/Platform/Linux/PlatformLinux.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Platform/Linux/PlatformLinux.h?rev=145020&r1=145019&r2=145020&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Platform/Linux/PlatformLinux.h (original) +++ lldb/trunk/source/Plugins/Platform/Linux/PlatformLinux.h Sun Nov 20 18:10:14 2011 @@ -95,8 +95,8 @@ BreakpointSite *bp_site); virtual lldb::ProcessSP - Attach(lldb::pid_t pid, Debugger &debugger, Target *target, - Listener &listener, Error &error); + Attach(ProcessAttachInfo &attach_info, Debugger &debugger, + Target *target, Listener &listener, Error &error); protected: From peter at pcc.me.uk Sun Nov 20 18:10:19 2011 From: peter at pcc.me.uk (Peter Collingbourne) Date: Mon, 21 Nov 2011 00:10:19 -0000 Subject: [Lldb-commits] [lldb] r145021 - in /lldb/trunk/source/Plugins/Process/Linux: ProcessMonitor.cpp ProcessMonitor.h Message-ID: <20111121001019.E1BC42A6C134@llvm.org> Author: pcc Date: Sun Nov 20 18:10:19 2011 New Revision: 145021 URL: http://llvm.org/viewvc/llvm-project?rev=145021&view=rev Log: Update ProcessMonitor::MonitorCallback signature. Modified: lldb/trunk/source/Plugins/Process/Linux/ProcessMonitor.cpp lldb/trunk/source/Plugins/Process/Linux/ProcessMonitor.h Modified: lldb/trunk/source/Plugins/Process/Linux/ProcessMonitor.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Linux/ProcessMonitor.cpp?rev=145021&r1=145020&r2=145021&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Process/Linux/ProcessMonitor.cpp (original) +++ lldb/trunk/source/Plugins/Process/Linux/ProcessMonitor.cpp Sun Nov 20 18:10:19 2011 @@ -1186,6 +1186,7 @@ bool ProcessMonitor::MonitorCallback(void *callback_baton, lldb::pid_t pid, + bool exited, int signal, int status) { Modified: lldb/trunk/source/Plugins/Process/Linux/ProcessMonitor.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Linux/ProcessMonitor.h?rev=145021&r1=145020&r2=145021&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Process/Linux/ProcessMonitor.h (original) +++ lldb/trunk/source/Plugins/Process/Linux/ProcessMonitor.h Sun Nov 20 18:10:19 2011 @@ -253,7 +253,7 @@ static bool MonitorCallback(void *callback_baton, - lldb::pid_t pid, int signal, int status); + lldb::pid_t pid, bool exited, int signal, int status); static ProcessMessage MonitorSIGTRAP(ProcessMonitor *monitor,