[Lldb-commits] [PATCH] D43546: Fix TestMultithreaded when specifying an alternative debugserver.
friss created this revision. This test launches a helper that uses the debugserver. The environment variable sepcifying the debug server wasn't passed to this helper, thus it was using the default one. I'd love to hear if anyone has a nicer idea how to get access to the alternative server passed on the command line. https://reviews.llvm.org/D43546 Files: packages/Python/lldbsuite/test/api/multithreaded/TestMultithreaded.py Index: packages/Python/lldbsuite/test/api/multithreaded/TestMultithreaded.py === --- packages/Python/lldbsuite/test/api/multithreaded/TestMultithreaded.py +++ packages/Python/lldbsuite/test/api/multithreaded/TestMultithreaded.py @@ -101,6 +101,8 @@ exe = [test_exe, self.getBuildArtifact(self.inferior)] env = {self.dylibPath: self.getLLDBLibraryEnvVal()} +if os.environ['LLDB_DEBUGSERVER_PATH']: +env['LLDB_DEBUGSERVER_PATH'] = os.environ['LLDB_DEBUGSERVER_PATH'] if self.TraceOn(): print("Running test %s" % " ".join(exe)) check_call(exe, env=env) Index: packages/Python/lldbsuite/test/api/multithreaded/TestMultithreaded.py === --- packages/Python/lldbsuite/test/api/multithreaded/TestMultithreaded.py +++ packages/Python/lldbsuite/test/api/multithreaded/TestMultithreaded.py @@ -101,6 +101,8 @@ exe = [test_exe, self.getBuildArtifact(self.inferior)] env = {self.dylibPath: self.getLLDBLibraryEnvVal()} +if os.environ['LLDB_DEBUGSERVER_PATH']: +env['LLDB_DEBUGSERVER_PATH'] = os.environ['LLDB_DEBUGSERVER_PATH'] if self.TraceOn(): print("Running test %s" % " ".join(exe)) check_call(exe, env=env) ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] r325666 - Fix TestAppleTypesIsProduced after r324226
Author: friss Date: Tue Feb 20 22:20:03 2018 New Revision: 325666 URL: http://llvm.org/viewvc/llvm-project?rev=325666&view=rev Log: Fix TestAppleTypesIsProduced after r324226 This test was accessing self.debug_info, which doesn't exist anymore. For some reason the macOS bots are skipping this test because they think the compiler is not clang. We'll look into this separately. Modified: lldb/trunk/packages/Python/lldbsuite/test/macosx/debug-info/apple_types/TestAppleTypesIsProduced.py Modified: lldb/trunk/packages/Python/lldbsuite/test/macosx/debug-info/apple_types/TestAppleTypesIsProduced.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/macosx/debug-info/apple_types/TestAppleTypesIsProduced.py?rev=325666&r1=325665&r2=325666&view=diff == --- lldb/trunk/packages/Python/lldbsuite/test/macosx/debug-info/apple_types/TestAppleTypesIsProduced.py (original) +++ lldb/trunk/packages/Python/lldbsuite/test/macosx/debug-info/apple_types/TestAppleTypesIsProduced.py Tue Feb 20 22:20:03 2018 @@ -27,7 +27,7 @@ class AppleTypesTestCase(TestBase): self.skipTest("clang compiler only test") self.build() -if self.debug_info == "dsym": +if self.getDebugInfo() == "dsym": exe = self.getBuildArtifact( "a.out.dSYM/Contents/Resources/DWARF/a.out") else: ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D43419: Fix TestBreakpointInGlobalConstructor for Windows
labath added a comment. I was actually thinking of making this unconditional. It makes the behaviour easier to understand and this test really does not care about whether the libraries were resolved statically or not. I'm with Jim that we should make targeted tests for that functionality. https://reviews.llvm.org/D43419 ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D43532: Fix TestSBData.py on Windows (which uses Python 3)
amccarth created this revision. amccarth added a reviewer: zturner. Herald added a subscriber: sanjoy. This test uses the SB API to set and read back bytes of data, and it works fine when Python 2 is the scripting language. On Windows, however, Python 3 is the default. Note this line from the test: addr_data = '\x11\x22\x33\x44\x55\x66\x77\x88' The intent here is to create an array of eight bytes as a string literal. This works in Python 2, but Python 3 treats those as a series Unicode code points, and the CPython implementation happens to encode those code points as UTF-8. The first seven characters encode directly as single bytes of the same value. But the UTF-8 encoding of 0x88 is two bytes long: 0xC2 0x88. So the input array doesn't have the intended data at the end, so the test cases that use all eight bytes fail. Adding the `b` prefix tells Python 3 that we want a byte array rather than a string. With this change, the test now passes on Windows. I believe this also works for Python 2 (Python 2.7 accepts the b-prefix and seems to do the right thing), but I'm not very familiar with the details of Python 2. https://reviews.llvm.org/D43532 Files: lldb/packages/Python/lldbsuite/test/python_api/sbdata/TestSBData.py Index: lldb/packages/Python/lldbsuite/test/python_api/sbdata/TestSBData.py === --- lldb/packages/Python/lldbsuite/test/python_api/sbdata/TestSBData.py +++ lldb/packages/Python/lldbsuite/test/python_api/sbdata/TestSBData.py @@ -25,7 +25,7 @@ def test_byte_order_and_address_byte_size(self): """Test the SBData::SetData() to ensure the byte order and address byte size are obeyed""" -addr_data = '\x11\x22\x33\x44\x55\x66\x77\x88' +addr_data = b'\x11\x22\x33\x44\x55\x66\x77\x88' error = lldb.SBError() data = lldb.SBData() data.SetData(error, addr_data, lldb.eByteOrderBig, 4) Index: lldb/packages/Python/lldbsuite/test/python_api/sbdata/TestSBData.py === --- lldb/packages/Python/lldbsuite/test/python_api/sbdata/TestSBData.py +++ lldb/packages/Python/lldbsuite/test/python_api/sbdata/TestSBData.py @@ -25,7 +25,7 @@ def test_byte_order_and_address_byte_size(self): """Test the SBData::SetData() to ensure the byte order and address byte size are obeyed""" -addr_data = '\x11\x22\x33\x44\x55\x66\x77\x88' +addr_data = b'\x11\x22\x33\x44\x55\x66\x77\x88' error = lldb.SBError() data = lldb.SBData() data.SetData(error, addr_data, lldb.eByteOrderBig, 4) ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D43419: Fix TestBreakpointInGlobalConstructor for Windows
amccarth added a comment. In https://reviews.llvm.org/D43419#1013559, @jingham wrote: > At some point we should introduce "platformCapacities" so that you could do: > > if not test.getPlatformCapacities("preload-dylibs"): > > > so we are testing specific features not the whole platform. Yes, I agree completely. > It looks like your added comment has no line endings? Can you reformat the > comment so it's easier to read? Then it will be good. Done. I'm never sure how Python handles docstrings. The existing code looked like it was trying to avoid line breaks that weren't separating paragraphs. https://reviews.llvm.org/D43419 ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D43419: Fix TestBreakpointInGlobalConstructor for Windows
amccarth updated this revision to Diff 135124. amccarth added a comment. Wrapped the modified docstring. https://reviews.llvm.org/D43419 Files: lldb/packages/Python/lldbsuite/test/functionalities/breakpoint/global_constructor/TestBreakpointInGlobalConstructor.py lldb/packages/Python/lldbsuite/test/lldbutil.py Index: lldb/packages/Python/lldbsuite/test/lldbutil.py === --- lldb/packages/Python/lldbsuite/test/lldbutil.py +++ lldb/packages/Python/lldbsuite/test/lldbutil.py @@ -343,7 +343,9 @@ If extra_options is not None, then we append it to the breakpoint set command. -If num_expected_locations is -1 we check that we got AT LEAST one location, otherwise we check that num_expected_locations equals the number of locations. +If num_expected_locations is -1, we check that we got AT LEAST one location. If num_expected_locations is -2, we check +that we got AT LEAST one location on platforms other than Windows. Otherwise, we check that num_expected_locations +equals the number of locations. If loc_exact is true, we check that there is one location, and that location must be at the input file and line number.""" @@ -563,6 +565,12 @@ if num_locations == -1: test.assertTrue(out_num_locations > 0, "Expecting one or more locations, got none.") +elif num_locations == -2: +# On Windows, breakpoints may remain pending until a DLL is loaded, +# so we allow zero. Other platforms expect at least one. +if test.getPlatform() != "windows": + test.assertTrue(out_num_locations > 0, + "Expecting one or more locations, got none.") else: test.assertTrue( num_locations == out_num_locations, Index: lldb/packages/Python/lldbsuite/test/functionalities/breakpoint/global_constructor/TestBreakpointInGlobalConstructor.py === --- lldb/packages/Python/lldbsuite/test/functionalities/breakpoint/global_constructor/TestBreakpointInGlobalConstructor.py +++ lldb/packages/Python/lldbsuite/test/functionalities/breakpoint/global_constructor/TestBreakpointInGlobalConstructor.py @@ -29,8 +29,9 @@ bp_main = lldbutil.run_break_set_by_file_and_line( self, 'main.cpp', self.line_main) + bp_foo = lldbutil.run_break_set_by_file_and_line( -self, 'foo.cpp', self.line_foo) +self, 'foo.cpp', self.line_foo, num_expected_locations=-2) process = target.LaunchSimple( None, env, self.get_process_working_directory()) Index: lldb/packages/Python/lldbsuite/test/lldbutil.py === --- lldb/packages/Python/lldbsuite/test/lldbutil.py +++ lldb/packages/Python/lldbsuite/test/lldbutil.py @@ -343,7 +343,9 @@ If extra_options is not None, then we append it to the breakpoint set command. -If num_expected_locations is -1 we check that we got AT LEAST one location, otherwise we check that num_expected_locations equals the number of locations. +If num_expected_locations is -1, we check that we got AT LEAST one location. If num_expected_locations is -2, we check +that we got AT LEAST one location on platforms other than Windows. Otherwise, we check that num_expected_locations +equals the number of locations. If loc_exact is true, we check that there is one location, and that location must be at the input file and line number.""" @@ -563,6 +565,12 @@ if num_locations == -1: test.assertTrue(out_num_locations > 0, "Expecting one or more locations, got none.") +elif num_locations == -2: +# On Windows, breakpoints may remain pending until a DLL is loaded, +# so we allow zero. Other platforms expect at least one. +if test.getPlatform() != "windows": + test.assertTrue(out_num_locations > 0, + "Expecting one or more locations, got none.") else: test.assertTrue( num_locations == out_num_locations, Index: lldb/packages/Python/lldbsuite/test/functionalities/breakpoint/global_constructor/TestBreakpointInGlobalConstructor.py === --- lldb/packages/Python/lldbsuite/test/functionalities/breakpoint/global_constructor/TestBreakpointInGlobalConstructor.py +++ lldb/packages/Python/lldbsuite/test/functionalities/breakpoint/global_constructor/TestBreakpointInGlobalConstructor.py @@ -29,8 +29,9 @@ bp_main = lldbutil.run_break_set_by_file_and_line( self, 'main.cpp', self.line_main) + bp_foo = lldbutil.run_break_set_by_file_and_line( -self, 'foo.cpp', self.line_foo) +self, 'foo.cpp', self.line_foo, num_expected_locations=-2) process = target.LaunchSimple( None, e
[Lldb-commits] [PATCH] D43419: Fix TestBreakpointInGlobalConstructor for Windows
jingham requested changes to this revision. jingham added a comment. This revision now requires changes to proceed. At some point we should introduce "platformCapacities" so that you could do: if not test.getPlatformCapacities("preload-dylibs"): so we are testing specific features not the whole platform. But that seems a bigger change than this fix warrants. It looks like your added comment has no line endings? Can you reformat the comment so it's easier to read? Then it will be good. https://reviews.llvm.org/D43419 ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D43419: Fix TestBreakpointInGlobalConstructor for Windows
amccarth updated this revision to Diff 135120. amccarth added a comment. Added new special value to accommodate the fact that Windows may postpone resolving the breakpoints for DLLs that aren't yet loaded. https://reviews.llvm.org/D43419 Files: lldb/packages/Python/lldbsuite/test/functionalities/breakpoint/global_constructor/TestBreakpointInGlobalConstructor.py lldb/packages/Python/lldbsuite/test/lldbutil.py Index: lldb/packages/Python/lldbsuite/test/lldbutil.py === --- lldb/packages/Python/lldbsuite/test/lldbutil.py +++ lldb/packages/Python/lldbsuite/test/lldbutil.py @@ -343,7 +343,7 @@ If extra_options is not None, then we append it to the breakpoint set command. -If num_expected_locations is -1 we check that we got AT LEAST one location, otherwise we check that num_expected_locations equals the number of locations. +If num_expected_locations is -1, we check that we got AT LEAST one location. If num_expected_locations is -2, we check that we got AT LEAST one location on platforms other than Windows. Otherwise, we check that num_expected_locations equals the number of locations. If loc_exact is true, we check that there is one location, and that location must be at the input file and line number.""" @@ -563,6 +563,12 @@ if num_locations == -1: test.assertTrue(out_num_locations > 0, "Expecting one or more locations, got none.") +elif num_locations == -2: +# On Windows, breakpoints may remain pending until a DLL is loaded, +# so we allow zero. Other platforms expect at least one. +if test.getPlatform() != "windows": + test.assertTrue(out_num_locations > 0, + "Expecting one or more locations, got none.") else: test.assertTrue( num_locations == out_num_locations, Index: lldb/packages/Python/lldbsuite/test/functionalities/breakpoint/global_constructor/TestBreakpointInGlobalConstructor.py === --- lldb/packages/Python/lldbsuite/test/functionalities/breakpoint/global_constructor/TestBreakpointInGlobalConstructor.py +++ lldb/packages/Python/lldbsuite/test/functionalities/breakpoint/global_constructor/TestBreakpointInGlobalConstructor.py @@ -29,8 +29,9 @@ bp_main = lldbutil.run_break_set_by_file_and_line( self, 'main.cpp', self.line_main) + bp_foo = lldbutil.run_break_set_by_file_and_line( -self, 'foo.cpp', self.line_foo) +self, 'foo.cpp', self.line_foo, num_expected_locations=-2) process = target.LaunchSimple( None, env, self.get_process_working_directory()) Index: lldb/packages/Python/lldbsuite/test/lldbutil.py === --- lldb/packages/Python/lldbsuite/test/lldbutil.py +++ lldb/packages/Python/lldbsuite/test/lldbutil.py @@ -343,7 +343,7 @@ If extra_options is not None, then we append it to the breakpoint set command. -If num_expected_locations is -1 we check that we got AT LEAST one location, otherwise we check that num_expected_locations equals the number of locations. +If num_expected_locations is -1, we check that we got AT LEAST one location. If num_expected_locations is -2, we check that we got AT LEAST one location on platforms other than Windows. Otherwise, we check that num_expected_locations equals the number of locations. If loc_exact is true, we check that there is one location, and that location must be at the input file and line number.""" @@ -563,6 +563,12 @@ if num_locations == -1: test.assertTrue(out_num_locations > 0, "Expecting one or more locations, got none.") +elif num_locations == -2: +# On Windows, breakpoints may remain pending until a DLL is loaded, +# so we allow zero. Other platforms expect at least one. +if test.getPlatform() != "windows": + test.assertTrue(out_num_locations > 0, + "Expecting one or more locations, got none.") else: test.assertTrue( num_locations == out_num_locations, Index: lldb/packages/Python/lldbsuite/test/functionalities/breakpoint/global_constructor/TestBreakpointInGlobalConstructor.py === --- lldb/packages/Python/lldbsuite/test/functionalities/breakpoint/global_constructor/TestBreakpointInGlobalConstructor.py +++ lldb/packages/Python/lldbsuite/test/functionalities/breakpoint/global_constructor/TestBreakpointInGlobalConstructor.py @@ -29,8 +29,9 @@ bp_main = lldbutil.run_break_set_by_file_and_line( self, 'main.cpp', self.line_main) + bp_foo = lldbutil.run_break_set_by_file_and_line( -self, 'foo.cpp', self.line_foo) +self, 'foo.cpp', self.line_foo, num_ex
[Lldb-commits] [PATCH] D43506: Fix a couple of more tests to not create files in the source tree
davide added a comment. LGTM. This is really good work, thanks https://reviews.llvm.org/D43506 ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
Re: [Lldb-commits] [PATCH] D43419: Fix TestBreakpointInGlobalConstructor for Windows
We don’t parse libraries beyond getting sections until we look for symbols, this doesn’t seem to slow startup noticeably, and since I find it super useful especially for a program like lldb, where the driver has very little code in it and most of the functionality is in libraries, I’m happy with the tradeoff. But I don’t think we should require all platforms to do this, nor is it expected to be exact (for instance, the darwin dynamic loader plugin doesn’t track setting environment variables in the run-args, re-calculating the loaded libraries based on new DYLD_LIBRARY_PATH variables… So the tests should be flexible and not require this. I think having a special value for num_locations is fine. We probably should add some tests that explicitly test this for platforms that do support the feature, I think we are only testing it by accident now. Jim > On Feb 20, 2018, at 9:37 AM, Adrian McCarthy via Phabricator > wrote: > > amccarth added a comment. > > I have reservations about making the debugger try to pre-locate the modules > and their PDBs before those modules are actually loaded. For a few reasons. > > (1) On Windows, module resolution is complex. Search paths, the safe search > path, manifests, the side-by-side cache, dynamic library link redirection > (.exe.local), Windows API sets, etc. It got to the point that Microsoft > dropped support for the venerable DependencyWalker tool (though there is an > open source community trying to keep it alive). That's a lot of logic to > bake into the debugger (and to create tests for), and the cost of getting it > wrong is that we think your breakpoint will resolve when actually it won't. > > (2) A typical program depends directly and indirectly on many DLLs. Even > with lazy-evaluation, trying to apply all the rules in 1 (which must be done > serially) to locate all of the dependents seems like a lot of unnecessary > work on startup. > > (3) It's different than how all the debuggers on Windows work, which might be > mildly surprising to users. > > If there's a strong will to head down this path, I think that'll be a > separate effort than my getting this test working again in the short term. > So I think I'll do something less invasive along the lines of Pavel's > suggestion to get this test working. Stay tuned. > > > https://reviews.llvm.org/D43419 > > > ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D42145: [lldb] Use vFlash commands when writing to target's flash memory regions
owenpshaw updated this revision to Diff 135087. owenpshaw added a comment. Herald added a subscriber: arichardson. Update patch to include new @skipIfXmlSupportMissing decorator on test https://reviews.llvm.org/D42145 Files: include/lldb/Host/XML.h include/lldb/Target/MemoryRegionInfo.h include/lldb/Target/Process.h packages/Python/lldbsuite/test/functionalities/gdb_remote_client/TestGDBRemoteLoad.py source/Host/common/XML.cpp source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp source/Plugins/ObjectFile/ELF/ObjectFileELF.h source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.h source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp source/Plugins/Process/gdb-remote/ProcessGDBRemote.h source/Symbol/ObjectFile.cpp source/Target/Process.cpp Index: source/Target/Process.cpp === --- source/Target/Process.cpp +++ source/Target/Process.cpp @@ -2533,6 +2533,17 @@ return 0; } +Status Process::WriteObjectFile(std::vector entries) { + Status error; + for (const auto &Entry : entries) { +WriteMemory(Entry.Dest, Entry.Contents.data(), Entry.Contents.size(), +error); +if (!error.Success()) + break; + } + return error; +} + #define USE_ALLOCATE_MEMORY_CACHE 1 addr_t Process::AllocateMemory(size_t size, uint32_t permissions, Status &error) { Index: source/Symbol/ObjectFile.cpp === --- source/Symbol/ObjectFile.cpp +++ source/Symbol/ObjectFile.cpp @@ -659,22 +659,31 @@ SectionList *section_list = GetSectionList(); if (!section_list) return Status("No section in object file"); + + std::vector writeEntries; + + // Create a list of write entries from loadable sections size_t section_count = section_list->GetNumSections(0); for (size_t i = 0; i < section_count; ++i) { +Process::WriteEntry entry; SectionSP section_sp = section_list->GetSectionAtIndex(i); -addr_t addr = target.GetSectionLoadList().GetSectionLoadAddress(section_sp); -if (addr != LLDB_INVALID_ADDRESS) { - DataExtractor section_data; - // We can skip sections like bss - if (section_sp->GetFileSize() == 0) -continue; - section_sp->GetSectionData(section_data); - lldb::offset_t written = process->WriteMemory( - addr, section_data.GetDataStart(), section_data.GetByteSize(), error); - if (written != section_data.GetByteSize()) -return error; -} +entry.Dest = target.GetSectionLoadList().GetSectionLoadAddress(section_sp); +if (entry.Dest == LLDB_INVALID_ADDRESS) + continue; +// We can skip sections like bss +if (section_sp->GetFileSize() == 0) + continue; +DataExtractor section_data; +section_sp->GetSectionData(section_data); +entry.Contents = llvm::ArrayRef(section_data.GetDataStart(), + section_data.GetByteSize()); +writeEntries.push_back(entry); } + + error = process->WriteObjectFile(std::move(writeEntries)); + if (!error.Success()) +return error; + if (set_pc) { ThreadList &thread_list = process->GetThreadList(); ThreadSP curr_thread(thread_list.GetSelectedThread()); Index: source/Plugins/Process/gdb-remote/ProcessGDBRemote.h === --- source/Plugins/Process/gdb-remote/ProcessGDBRemote.h +++ source/Plugins/Process/gdb-remote/ProcessGDBRemote.h @@ -144,6 +144,8 @@ size_t DoReadMemory(lldb::addr_t addr, void *buf, size_t size, Status &error) override; + Status WriteObjectFile(std::vector entries) override; + size_t DoWriteMemory(lldb::addr_t addr, const void *buf, size_t size, Status &error) override; @@ -302,6 +304,11 @@ int64_t m_breakpoint_pc_offset; lldb::tid_t m_initial_tid; // The initial thread ID, given by stub on attach + bool m_allow_flash_writes; + using FlashRangeVector = lldb_private::RangeVector; + using FlashRange = FlashRangeVector::Entry; + FlashRangeVector m_erased_flash_ranges; + //-- // Accessors //-- @@ -408,6 +415,12 @@ Status UpdateAutomaticSignalFiltering() override; + Status FlashErase(lldb::addr_t addr, size_t size); + + Status FlashDone(); + + bool HasErased(FlashRange range); + private: //-- // For ProcessGDBRemote only Index: source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp === --- source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp +++ source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp @@ -59,6 +59,7 @@ #incl
[Lldb-commits] [PATCH] D43419: Fix TestBreakpointInGlobalConstructor for Windows
amccarth added a comment. I have reservations about making the debugger try to pre-locate the modules and their PDBs before those modules are actually loaded. For a few reasons. (1) On Windows, module resolution is complex. Search paths, the safe search path, manifests, the side-by-side cache, dynamic library link redirection (.exe.local), Windows API sets, etc. It got to the point that Microsoft dropped support for the venerable DependencyWalker tool (though there is an open source community trying to keep it alive). That's a lot of logic to bake into the debugger (and to create tests for), and the cost of getting it wrong is that we think your breakpoint will resolve when actually it won't. (2) A typical program depends directly and indirectly on many DLLs. Even with lazy-evaluation, trying to apply all the rules in 1 (which must be done serially) to locate all of the dependents seems like a lot of unnecessary work on startup. (3) It's different than how all the debuggers on Windows work, which might be mildly surprising to users. If there's a strong will to head down this path, I think that'll be a separate effort than my getting this test working again in the short term. So I think I'll do something less invasive along the lines of Pavel's suggestion to get this test working. Stay tuned. https://reviews.llvm.org/D43419 ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D43506: Fix a couple of more tests to not create files in the source tree
aprantl accepted this revision. aprantl added a comment. This revision is now accepted and ready to land. Thanks! By the way, just in case you are motivated :-), one outstanding task is also to replace all uses of the `clean` target in the makefiles with simply removing the test build directory. https://reviews.llvm.org/D43506 ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D43512: DWZ 11/11: Fix for symlinked .build-id/**.debug files
jankratochvil created this revision. jankratochvil added reviewers: labath, clayborg. jankratochvil added a dependency: D40475: DWZ 10/11: DWZ test mode. So far `/usr/lib/debug/.build-id/**.debug` files could be opened any way. But with DWZ they can contain relative filename reference to `/usr/lib/debug/.dwz/*` files which then depends on whether the build-id .debug file is a symlink or not. Resolve the symlinks first before storing the filename for later references. All DWZ patches are also applied in: git clone -b dwz git://git.jankratochvil.net/lldb https://reviews.llvm.org/D43512 Files: packages/Python/lldbsuite/test/decorators.py packages/Python/lldbsuite/test/linux/buildidsymlink/Makefile packages/Python/lldbsuite/test/linux/buildidsymlink/TestTargetSymbolsBuildidSymlink.py packages/Python/lldbsuite/test/linux/buildidsymlink/main.c source/Host/common/Symbols.cpp Index: source/Host/common/Symbols.cpp === --- source/Host/common/Symbols.cpp +++ source/Host/common/Symbols.cpp @@ -280,6 +280,11 @@ const std::string &filename = files[idx_file]; FileSpec file_spec(filename, true); +if (llvm::sys::fs::equivalent(file_spec.GetPath(), + module_file_spec.GetPath())) + continue; +if (FileSystem::ResolveSymbolicLink(file_spec, file_spec).Fail()) + continue; if (llvm::sys::fs::equivalent(file_spec.GetPath(), module_file_spec.GetPath())) continue; Index: packages/Python/lldbsuite/test/linux/buildidsymlink/main.c === --- /dev/null +++ packages/Python/lldbsuite/test/linux/buildidsymlink/main.c @@ -0,0 +1,6 @@ +struct s { + int i1, i2, i3, i4, i5, i6, i7, i8, i9; +} v; +int main() { + return 0; +} Index: packages/Python/lldbsuite/test/linux/buildidsymlink/TestTargetSymbolsBuildidSymlink.py === --- /dev/null +++ packages/Python/lldbsuite/test/linux/buildidsymlink/TestTargetSymbolsBuildidSymlink.py @@ -0,0 +1,24 @@ +""" Testing separate debug info loading for base binary with a symlink. """ +import os +import time +import lldb +import sys +from lldbsuite.test.decorators import * +from lldbsuite.test.lldbtest import * +from lldbsuite.test import lldbutil + + +class TestTargetSymbolsBuildidSymlink(TestBase): + +mydir = TestBase.compute_mydir(__file__) + +@no_debug_info_test # Prevent the genaration of the dwarf version of this test +@skipUnlessPlatform(['linux']) +@skipIf(hostoslist=["windows"]) +@skipIfRemote # llvm.org/pr36237 +@skipUnlessDWZInstalled +def test_target_symbols_buildid_symlink(self): +self.build(clean=True) +exe = self.getBuildArtifact("stripped.out") + +lldbutil.run_to_name_breakpoint(self, "main", exe_name = exe) Index: packages/Python/lldbsuite/test/linux/buildidsymlink/Makefile === --- /dev/null +++ packages/Python/lldbsuite/test/linux/buildidsymlink/Makefile @@ -0,0 +1,24 @@ +LEVEL = ../../make +C_SOURCES := main.c +LD_EXTRAS += -Wl,--build-id=sha1 + +all: .build-id + +.PHONY: .build-id +stripped.out stripped.debug stripped.debug.dwz: a.out + eu-strip --remove-comment -f stripped.debug -F stripped.debugx -o stripped.out $< + cp -p stripped.debug stripped.debug.dup + dwz -m stripped.debug.dwz stripped.debug stripped.debug.dup + +.build-id: stripped.debug + $(OBJCOPY) -j .note.gnu.build-id -O binary $< tmp + rm -rf .build-id + fn=`od -An -tx1 ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D40475: DWZ 10/11: DWZ test mode
jankratochvil updated this revision to Diff 135063. jankratochvil retitled this revision from "DWZ 12/12: DWZ test mode" to "DWZ 10/11: DWZ test mode". jankratochvil added a comment. Herald added subscribers: JDevlieghere, mgorny. It now includes also unittests/SymbolFile/DWZ/ which should PASS even on systems without DWZ tool(s). https://reviews.llvm.org/D40475 Files: packages/Python/lldbsuite/test/lldbinline.py packages/Python/lldbsuite/test/lldbtest.py packages/Python/lldbsuite/test/make/Makefile.rules packages/Python/lldbsuite/test/plugins/builder_base.py packages/Python/lldbsuite/test/test_categories.py unittests/SymbolFile/CMakeLists.txt unittests/SymbolFile/DWZ/CMakeLists.txt unittests/SymbolFile/DWZ/Inputs/dwztest.c unittests/SymbolFile/DWZ/Inputs/dwztest.debug unittests/SymbolFile/DWZ/Inputs/dwztest.debug.dwz unittests/SymbolFile/DWZ/Inputs/dwztest.out unittests/SymbolFile/DWZ/SymbolFileDWZTests.cpp Index: unittests/SymbolFile/DWZ/SymbolFileDWZTests.cpp === --- /dev/null +++ unittests/SymbolFile/DWZ/SymbolFileDWZTests.cpp @@ -0,0 +1,89 @@ +//===-- SymbolFileDWZTests.cpp --*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===--===// + +#include "gtest/gtest.h" + +#include "TestingSupport/TestUtilities.h" + +#include "Plugins/SymbolFile/DWARF/SymbolFileDWARF.h" +#include "Plugins/ObjectFile/ELF/ObjectFileELF.h" +#include "Plugins/SymbolVendor/ELF/SymbolVendorELF.h" +#include "lldb/Core/Module.h" +#include "lldb/Host/HostInfo.h" +#include "lldb/Symbol/ClangASTContext.h" +#include "lldb/Symbol/SymbolVendor.h" +#include "lldb/Utility/ArchSpec.h" +#include "lldb/Utility/FileSpec.h" + +#if defined(_MSC_VER) +#include "lldb/Host/windows/windows.h" +#include +#endif + +#include + +using namespace lldb_private; + +class SymbolFileDWZTests : public testing::Test { +public: + void SetUp() override { +// Initialize and TearDown the plugin every time, so we get a brand new +// AST every time so that modifications to the AST from each test don't +// leak into the next test. +#if defined(_MSC_VER) +::CoInitializeEx(nullptr, COINIT_MULTITHREADED); +#endif + +HostInfo::Initialize(); +SymbolFileDWARF::Initialize(); +ClangASTContext::Initialize(); +ObjectFileELF::Initialize(); +SymbolVendorELF::Initialize(); + +m_dwztest_out = GetInputFilePath("dwztest.out"); + } + + void TearDown() override { +SymbolVendorELF::Terminate(); +ObjectFileELF::Terminate(); +ClangASTContext::Terminate(); +SymbolFileDWARF::Terminate(); +HostInfo::Terminate(); + +#if defined(_MSC_VER) +::CoUninitialize(); +#endif + } + +protected: + std::string m_dwztest_out; +}; + +TEST_F(SymbolFileDWZTests, TestSimpleClassTypes) { + FileSpec fspec(m_dwztest_out.c_str(), false); + ArchSpec aspec("x86_64-pc-linux"); + lldb::ModuleSP module = std::make_shared(fspec, aspec); + + SymbolVendor *plugin = module->GetSymbolVendor(); + EXPECT_NE(nullptr, plugin); + SymbolFile *symfile = plugin->GetSymbolFile(); + EXPECT_NE(nullptr, symfile); + EXPECT_EQ(symfile->GetPluginName(), SymbolFileDWARF::GetPluginNameStatic()); + SymbolContext sc; + llvm::DenseSet searched_files; + TypeMap results; + EXPECT_EQ(1u, + symfile->FindTypes(sc, ConstString("StructMovedToDWZCommonFile"), nullptr, + false, 0, searched_files, results)); + EXPECT_EQ(1u, results.GetSize()); + lldb::TypeSP udt_type = results.GetTypeAtIndex(0); + EXPECT_EQ(ConstString("StructMovedToDWZCommonFile"), udt_type->GetName()); + CompilerType compiler_type = udt_type->GetForwardCompilerType(); + EXPECT_TRUE(ClangASTContext::IsClassType(compiler_type.GetOpaqueQualType())); +} Index: unittests/SymbolFile/DWZ/Inputs/dwztest.c === --- /dev/null +++ unittests/SymbolFile/DWZ/Inputs/dwztest.c @@ -0,0 +1,9 @@ +// gcc -Wall -g -o dwztest.out dwztest.c; eu-strip --remove-comment -f dwztest.debug dwztest.out; cp -p dwztest.debug dwztest.debug.dup; dwz -m dwztest.debug.dwz dwztest.debug dwztest.debug.dup;rm dwztest.debug.dup; /usr/lib/rpm/sepdebugcrcfix . dwztest.out + +struct StructMovedToDWZCommonFile { + int i1, i2, i3, i4, i5, i6, i7, i8, i9; +} VarWithStructMovedToDWZCommonFile; +static const int sizeof_StructMovedToDWZCommonFile = sizeof(struct StructMovedToDWZCommonFile); +int main() { + return sizeof_StructMovedToDWZCommonFile; +} Index: unittests/SymbolFile/DWZ/CMakeLists.txt === --- /dev/null +++ unittests/SymbolFile/DWZ/CMakeLists.txt @@ -0,0 +1,21 @@ +add_lldb_unittest(SymbolFileDWZTests + SymbolFileDWZTests.cpp + + LINK_LIBS +lldbCore +lldbH
[Lldb-commits] [PATCH] D40474: DWZ 09/11: Main functionality
jankratochvil updated this revision to Diff 135060. jankratochvil marked an inline comment as done. jankratochvil retitled this revision from "DWZ 11/12: Main functionality" to "DWZ 09/11: Main functionality". https://reviews.llvm.org/D40474 Files: include/lldb/Utility/ConstString.h include/lldb/Utility/FileSpec.h source/Plugins/SymbolFile/DWARF/CMakeLists.txt source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.h source/Plugins/SymbolFile/DWARF/DWARFCompileUnitDWZ.h source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.cpp source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.h source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp source/Plugins/SymbolFile/DWARF/DWARFFileOffset.cpp source/Plugins/SymbolFile/DWARF/DWARFFileOffset.h source/Plugins/SymbolFile/DWARF/DWARFFormValue.cpp source/Plugins/SymbolFile/DWARF/DWARFFormValue.h source/Plugins/SymbolFile/DWARF/DWARFPartialUnit.cpp source/Plugins/SymbolFile/DWARF/DWARFPartialUnit.h source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp source/Plugins/SymbolFile/DWARF/DWARFUnit.h source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h Index: source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h === --- source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h +++ source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h @@ -18,10 +18,12 @@ #include #include #include +#include // Other libraries and framework includes #include "llvm/ADT/DenseMap.h" #include "llvm/Support/Threading.h" +#include "llvm/Support/RWMutex.h" #include "lldb/Utility/Flags.h" @@ -312,6 +314,13 @@ // the method returns a pointer to the base compile unit. virtual DWARFUnit *GetBaseCompileUnit(); + SymbolFileDWARF *GetDWZSymbolFile() const { +if (!m_dwz_common_file) + return nullptr; +return m_dwz_common_file->SymbolFile(); + } + bool GetIsDWZ() const { return m_is_dwz; } + protected: typedef llvm::DenseMap DIEToTypePtr; @@ -473,6 +482,44 @@ SymbolFileDWARFDwp *GetDwpSymbolFile(); + void InitializeDWZ(); + + class DWZCommonFile { + public: +// C++14: Use heterogenous lookup. +DWZCommonFile(const lldb_private::FileSpec &filespec_ref); +DWZCommonFile(std::unique_ptr &&symbol_file, +lldb::ObjectFileSP &&obj_file, lldb::ModuleSP &&module); +SymbolFileDWARF *SymbolFile() const { return m_symbol_file.get(); } + +bool operator==(const DWZCommonFile &rhs) const { + return m_filespec_ref == rhs.m_filespec_ref; +} +bool operator!=(const DWZCommonFile &rhs) const { return !(*this == rhs); } +class Hasher { +public: + size_t operator()(const DWZCommonFile &key) const { +return lldb_private::FileSpec::Hasher()(key.m_filespec_ref); + } +}; + +size_t m_use_count = 0; + + private: +std::unique_ptr m_symbol_file; +lldb::ObjectFileSP m_obj_file; +lldb::ModuleSP m_module; +const lldb_private::FileSpec &m_filespec_ref; + +DISALLOW_COPY_AND_ASSIGN(DWZCommonFile); + }; + DWZCommonFile *m_dwz_common_file = nullptr; + void DWZCommonFileClear(); + static std::unordered_set + m_filespec_to_dwzcommonfile; + static llvm::sys::RWMutex m_filespec_to_dwzcommonfile_mutex; + bool m_is_dwz = false; + lldb::ModuleWP m_debug_map_module_wp; SymbolFileDWARFDebugMap *m_debug_map_symfile; Index: source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp === --- source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp +++ source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp @@ -410,7 +410,9 @@ m_supports_DW_AT_APPLE_objc_complete_type(eLazyBoolCalculate), m_ranges(), m_unique_ast_type_map() {} -SymbolFileDWARF::~SymbolFileDWARF() {} +SymbolFileDWARF::~SymbolFileDWARF() { + DWZCommonFileClear(); +} static const ConstString &GetDWARFMachOSegmentName() { static ConstString g_dwarf_section_name("__DWARF"); @@ -426,6 +428,7 @@ } TypeSystem *SymbolFileDWARF::GetTypeSystemForLanguage(LanguageType language) { + lldbassert(!GetIsDWZ()); SymbolFileDWARFDebugMap *debug_map_symfile = GetDebugMapSymfile(); TypeSystem *type_system; if (debug_map_symfile) { @@ -488,6 +491,8 @@ else m_apple_objc_ap.reset(); } + + InitializeDWZ(); } bool SymbolFileDWARF::SupportedVersion(uint16_t version) { @@ -2055,6 +2060,8 @@ if (dwarf_cu) { // dwarf_cu->ExtractDIEsIfNeeded(false) will return zero if the // DIEs for a compile unit have already been parsed. +// While DW_TAG_partial_unit will not be indexed directly each such +// unit will be used by some other unit of this SymbolFileDWARF. if (dwarf_cu->ExtractDIEsIfNeeded(false) > 1) clear_cu_dies[cu_idx] = true; } @@ -4392,3 +4399,134 @@ }); return m_dwp_symfile.get(); } + +std::unordered_set +
[Lldb-commits] [PATCH] D40473: DWZ 08/11: Adjust existing code for the DWZ support.
jankratochvil updated this revision to Diff 135059. jankratochvil retitled this revision from "DWZ 10/12: Adjust existing code for the DWZ support." to "DWZ 08/11: Adjust existing code for the DWZ support.". https://reviews.llvm.org/D40473 Files: source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp source/Plugins/SymbolFile/DWARF/DWARFDIE.cpp source/Plugins/SymbolFile/DWARF/DWARFDIE.h source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.cpp source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp source/Plugins/SymbolFile/DWARF/DWARFUnit.h source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp Index: source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp === --- source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp +++ source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp @@ -734,6 +734,8 @@ DWARFUnit *dwarf_cu = info->GetCompileUnit((dw_offset_t)comp_unit->GetID()); +if (dwarf_cu) + dwarf_cu = dwarf_cu->GetMainCU(); if (dwarf_cu && dwarf_cu->GetUserData() == NULL) dwarf_cu->SetUserData(comp_unit); return dwarf_cu; @@ -763,6 +765,7 @@ uint32_t cu_idx) { CompUnitSP cu_sp; if (dwarf_cu) { +dwarf_cu = dwarf_cu->GetMainCU(); CompileUnit *comp_unit = (CompileUnit *)dwarf_cu->GetUserData(); if (comp_unit) { // We already parsed this compile unit, had out a shared pointer to it @@ -1370,6 +1373,9 @@ Type *SymbolFileDWARF::ResolveTypeUID(const DWARFDIE &die, bool assert_not_being_parsed) { + // this can be neither die.GetDWARF() nor die.GetMainDWARF(). + if (die.GetMainDWARF() != this) +return die.GetMainDWARF()->ResolveTypeUID(die, assert_not_being_parsed); if (die) { Log *log(LogChannelDWARF::GetLogIfAll(DWARF_LOG_DEBUG_INFO)); if (log) @@ -1482,6 +1488,10 @@ Type *SymbolFileDWARF::ResolveType(const DWARFDIE &die, bool assert_not_being_parsed, bool resolve_function_context) { + // this can be neither die.GetDWARF() nor die.GetMainDWARF(). + if (die.GetMainDWARF() != this) +return die.GetMainDWARF()->ResolveType( +die, assert_not_being_parsed, resolve_function_context); if (die) { Type *type = GetTypeForDIE(die, resolve_function_context).get(); @@ -1502,6 +1512,7 @@ CompileUnit * SymbolFileDWARF::GetCompUnitForDWARFCompUnit(DWARFUnit *dwarf_cu, uint32_t cu_idx) { + dwarf_cu = dwarf_cu->GetMainCU(); // Check if the symbol vendor already knows about this compile unit? if (dwarf_cu->GetUserData() == NULL) { // The symbol vendor doesn't know about this compile unit, we Index: source/Plugins/SymbolFile/DWARF/DWARFUnit.h === --- source/Plugins/SymbolFile/DWARF/DWARFUnit.h +++ source/Plugins/SymbolFile/DWARF/DWARFUnit.h @@ -151,6 +151,11 @@ } dw_offset_t GetNextCompileUnitFileOffset() const; + // DW_TAG_compile_unit with DW_TAG_imported_unit for this DW_TAG_partial_unit. + DWARFUnit *GetMainCU() const { +return const_cast(this); + } + protected: virtual DWARFCompileUnit &Data() = 0; virtual const DWARFCompileUnit &Data() const = 0; Index: source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp === --- source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp +++ source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp @@ -162,7 +162,8 @@ // Don't specify the compile unit offset as we don't know it because the // DIE belongs to // a different compile unit in the same symbol file. - return Data().m_dwarf2Data->DebugInfo()->GetDIEForDIEOffset(die_offset); + return GetMainCU()->Data().m_dwarf2Data->DebugInfo() + ->GetDIEForDIEOffset(die_offset); } } Data().m_dwarf2Data->GetObjectFile()->GetModule()->ReportError( Index: source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp === --- source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp +++ source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp @@ -570,7 +570,8 @@ if (ranges.IsEmpty() || name == NULL || mangled == NULL) { for (const DIERef &die_ref : die_refs) { if (die_ref.die_offset != DW_INVALID_OFFSET) { -DWARFDIE die = dwarf2Data->GetDIE(die_ref); +DWARFDIE die = cu->GetMainCU()->GetSymbolFileDWARF() +->GetDIE(die_ref); if (die) die.GetDIE()->GetDIENamesAndRanges( die.GetDWARF(), die.GetCU(), name, mangled, ranges, decl_file, Index: source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.cpp === --- source/Plu
[Lldb-commits] [PATCH] D40473: DWZ 10/12: Adjust existing code for the DWZ support.
jankratochvil added a subscriber: alexshap. jankratochvil added inline comments. Comment at: source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.cpp:199-202 + if (die_ref.cu_offset == DW_INVALID_OFFSET + // FIXME: Workaround default cu_offset = 0 in DIERef ctor. + // Why does GetCompileUnit exist at all? + || (die_ref.cu_offset == 0 /* && m_dwarf2Data->GetDWZSymbolFile() */ )) clayborg wrote: > Just fix the DIERef constructor to not use 0 for the cu_offset? This has been fixed in the meantime by @alexshap's D42563. Comment at: source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp:388-390 + // DIERef(DWARFFormValue)->DWARFFormValue::Reference() may need + // FileOffsetToUniqOffset. + dwarf2Data->PreloadSymbols(); clayborg wrote: > This seems like the wrong place to do this call. We are asking all DWARF to > index itself from DWARFDebugInfoEntry::GetDIENamesAndRanges()? Doesn't seem > like the right place. Fortunately it is somehow no longer needed now, dropped it. https://reviews.llvm.org/D40473 ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D40472: DWZ 07/11: Protect DWARFDebugInfo::m_compile_units by a new mutex
jankratochvil updated this revision to Diff 135058. https://reviews.llvm.org/D40472 Files: source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.cpp source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.h Index: source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.h === --- source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.h +++ source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.h @@ -18,6 +18,7 @@ #include "SymbolFileDWARF.h" #include "lldb/Core/STLUtils.h" #include "lldb/lldb-private.h" +#include "llvm/Support/RWMutex.h" typedef std::multimap CStringToDIEMap; @@ -74,6 +75,9 @@ std::unique_ptr m_cu_aranges_ap; // A quick address to compile unit table + std::atomic_size_t m_compile_units_size_atomic { 0 }; + mutable llvm::sys::RWMutex m_compile_units_mutex; + private: // All parsing needs to be done partially any managed by this class as // accessors are called. Index: source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.cpp === --- source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.cpp +++ source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.cpp @@ -40,6 +40,8 @@ // SetDwarfData //-- void DWARFDebugInfo::SetDwarfData(SymbolFileDWARF *dwarf2Data) { + llvm::sys::ScopedWriter lock(m_compile_units_mutex); + m_compile_units_size_atomic = 0; m_dwarf2Data = dwarf2Data; m_compile_units.clear(); } @@ -96,32 +98,39 @@ } void DWARFDebugInfo::ParseCompileUnitHeadersIfNeeded() { - if (m_compile_units.empty()) { -if (m_dwarf2Data != NULL) { - lldb::offset_t file_offset = 0; - DWARFUnitSP cu_sp; - while ((cu_sp = DWARFCompileUnit::Extract(m_dwarf2Data, &file_offset))) { -m_compile_units.push_back(cu_sp); - -file_offset = cu_sp->GetNextCompileUnitFileOffset(); - } -} + if (m_compile_units_size_atomic) +return; + if (m_dwarf2Data == NULL) +return; + llvm::sys::ScopedWriter lock(m_compile_units_mutex); + if (!m_compile_units.empty()) +return; + lldb::offset_t file_offset = 0; + DWARFUnitSP cu_sp; + while ((cu_sp = DWARFCompileUnit::Extract(m_dwarf2Data, &file_offset))) { +m_compile_units.push_back(cu_sp); + +file_offset = cu_sp->GetNextCompileUnitFileOffset(); } + m_compile_units_size_atomic = m_compile_units.size(); } size_t DWARFDebugInfo::GetNumCompileUnits() { ParseCompileUnitHeadersIfNeeded(); - return m_compile_units.size(); + return m_compile_units_size_atomic; } DWARFUnit *DWARFDebugInfo::GetCompileUnitAtIndex(uint32_t idx) { DWARFUnit *cu = NULL; - if (idx < GetNumCompileUnits()) + if (idx < GetNumCompileUnits()) { +llvm::sys::ScopedReader lock(m_compile_units_mutex); cu = m_compile_units[idx].get(); + } return cu; } bool DWARFDebugInfo::ContainsCompileUnit(const DWARFUnit *cu) const { + llvm::sys::ScopedReader lock(m_compile_units_mutex); // Not a verify efficient function, but it is handy for use in assertions // to make sure that a compile unit comes from a debug information file. CompileUnitColl::const_iterator end_pos = m_compile_units.end(); @@ -145,6 +154,7 @@ uint32_t cu_idx = DW_INVALID_INDEX; if (cu_offset != DW_INVALID_OFFSET) { ParseCompileUnitHeadersIfNeeded(); +llvm::sys::ScopedReader lock(m_compile_units_mutex); // Watch out for single compile unit executable as they are pretty common const size_t num_cus = m_compile_units.size(); @@ -185,6 +195,7 @@ DWARFUnit * DWARFDebugInfo::GetCompileUnitContainingDIEOffset(dw_offset_t die_offset) { ParseCompileUnitHeadersIfNeeded(); + llvm::sys::ScopedReader lock(m_compile_units_mutex); DWARFUnitSP cu_sp; @@ -494,6 +505,7 @@ CompileUnitColl::const_iterator pos; uint32_t curr_depth = 0; ParseCompileUnitHeadersIfNeeded(); + llvm::sys::ScopedReader lock(m_compile_units_mutex); for (pos = m_compile_units.begin(); pos != m_compile_units.end(); ++pos) { DWARFUnit *cu = pos->get(); DumpCallback(m_dwarf2Data, cu, NULL, 0, curr_depth, &dumpInfo); ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D40472: DWZ 07/11: Protect DWARFDebugInfo::m_compile_units by a new mutex
jankratochvil updated this revision to Diff 135055. jankratochvil retitled this revision from "DWZ 09/12: Protect DWARFDebugInfo::m_compile_units by a new mutex" to "DWZ 07/11: Protect DWARFDebugInfo::m_compile_units by a new mutex". jankratochvil edited the summary of this revision. https://reviews.llvm.org/D40472 Files: source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.cpp source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.h Index: source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.h === --- source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.h +++ source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.h @@ -18,6 +18,7 @@ #include "SymbolFileDWARF.h" #include "lldb/Core/STLUtils.h" #include "lldb/lldb-private.h" +#include "llvm/Support/RWMutex.h" typedef std::multimap CStringToDIEMap; @@ -74,6 +75,9 @@ std::unique_ptr m_cu_aranges_ap; // A quick address to compile unit table + std::atomic_size_t m_compile_units_size { 0 }; + mutable llvm::sys::RWMutex m_compile_units_mutex; + private: // All parsing needs to be done partially any managed by this class as // accessors are called. Index: source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.cpp === --- source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.cpp +++ source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.cpp @@ -40,6 +40,8 @@ // SetDwarfData //-- void DWARFDebugInfo::SetDwarfData(SymbolFileDWARF *dwarf2Data) { + llvm::sys::ScopedWriter lock(m_compile_units_mutex); + m_compile_units_size = 0; m_dwarf2Data = dwarf2Data; m_compile_units.clear(); } @@ -96,32 +98,39 @@ } void DWARFDebugInfo::ParseCompileUnitHeadersIfNeeded() { - if (m_compile_units.empty()) { -if (m_dwarf2Data != NULL) { - lldb::offset_t file_offset = 0; - DWARFUnitSP cu_sp; - while ((cu_sp = DWARFCompileUnit::Extract(m_dwarf2Data, &file_offset))) { -m_compile_units.push_back(cu_sp); - -file_offset = cu_sp->GetNextCompileUnitFileOffset(); - } -} + if (m_compile_units_size) +return; + if (m_dwarf2Data == NULL) +return; + llvm::sys::ScopedWriter lock(m_compile_units_mutex); + if (!m_compile_units.empty()) +return; + lldb::offset_t file_offset = 0; + DWARFUnitSP cu_sp; + while ((cu_sp = DWARFCompileUnit::Extract(m_dwarf2Data, &file_offset))) { +m_compile_units.push_back(cu_sp); + +file_offset = cu_sp->GetNextCompileUnitFileOffset(); } + m_compile_units_size = m_compile_units.size(); } size_t DWARFDebugInfo::GetNumCompileUnits() { ParseCompileUnitHeadersIfNeeded(); - return m_compile_units.size(); + return m_compile_units_size; } DWARFUnit *DWARFDebugInfo::GetCompileUnitAtIndex(uint32_t idx) { DWARFUnit *cu = NULL; - if (idx < GetNumCompileUnits()) + if (idx < GetNumCompileUnits()) { +llvm::sys::ScopedReader lock(m_compile_units_mutex); cu = m_compile_units[idx].get(); + } return cu; } bool DWARFDebugInfo::ContainsCompileUnit(const DWARFUnit *cu) const { + llvm::sys::ScopedReader lock(m_compile_units_mutex); // Not a verify efficient function, but it is handy for use in assertions // to make sure that a compile unit comes from a debug information file. CompileUnitColl::const_iterator end_pos = m_compile_units.end(); @@ -145,6 +154,7 @@ uint32_t cu_idx = DW_INVALID_INDEX; if (cu_offset != DW_INVALID_OFFSET) { ParseCompileUnitHeadersIfNeeded(); +llvm::sys::ScopedReader lock(m_compile_units_mutex); // Watch out for single compile unit executable as they are pretty common const size_t num_cus = m_compile_units.size(); @@ -185,6 +195,7 @@ DWARFUnit * DWARFDebugInfo::GetCompileUnitContainingDIEOffset(dw_offset_t die_offset) { ParseCompileUnitHeadersIfNeeded(); + llvm::sys::ScopedReader lock(m_compile_units_mutex); DWARFUnitSP cu_sp; @@ -494,6 +505,7 @@ CompileUnitColl::const_iterator pos; uint32_t curr_depth = 0; ParseCompileUnitHeadersIfNeeded(); + llvm::sys::ScopedReader lock(m_compile_units_mutex); for (pos = m_compile_units.begin(); pos != m_compile_units.end(); ++pos) { DWARFUnit *cu = pos->get(); DumpCallback(m_dwarf2Data, cu, NULL, 0, curr_depth, &dumpInfo); ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D40470: DWZ 06/11: Protect DWARFCompileUnit::m_die_array by a new mutex
jankratochvil updated this revision to Diff 135053. jankratochvil retitled this revision from "DWZ 07/12: Protect DWARFCompileUnit::m_die_array by a new mutex" to "DWZ 06/11: Protect DWARFCompileUnit::m_die_array by a new mutex". jankratochvil edited the summary of this revision. https://reviews.llvm.org/D40470 Files: source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.h Index: source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.h === --- source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.h +++ source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.h @@ -93,6 +93,8 @@ void *m_user_data = nullptr; DWARFDebugInfoEntry::collection m_die_array; // The compile unit debug information entry item + // Prevent m_extractdies_mutex lock overhead for most cases. + std::atomic_size_t m_die_array_size_atomic { 0 }; std::unique_ptr m_func_aranges_ap; // A table similar to // the .debug_aranges // table, but this one @@ -116,6 +118,8 @@ // in the main object file dw_offset_t m_base_obj_offset = DW_INVALID_OFFSET; + std::mutex m_extractdies_mutex; + void ParseProducerInfo(); private: Index: source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp === --- source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp +++ source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp @@ -83,6 +83,8 @@ void DWARFCompileUnit::ClearDIEs(bool keep_compile_unit_die) { if (m_die_array.size() > 1) { +std::lock_guard guard(m_extractdies_mutex); + // std::vectors never get any smaller when resized to a smaller size, // or when clear() or erase() are called, the size will report that it // is smaller, but the memory allocated remains intact (call capacity() @@ -94,8 +96,11 @@ // Save at least the compile unit DIE DWARFDebugInfoEntry::collection tmp_array; m_die_array.swap(tmp_array); -if (keep_compile_unit_die) +m_die_array_size_atomic = 0; +if (keep_compile_unit_die) { m_die_array.push_back(tmp_array.front()); + ++m_die_array_size_atomic; +} } if (m_dwo_symbol_file) @@ -109,9 +114,19 @@ // done. //-- size_t DWARFCompileUnit::ExtractDIEsIfNeeded(bool cu_die_only) { - const size_t initial_die_array_size = m_die_array.size(); - if ((cu_die_only && initial_die_array_size > 0) || initial_die_array_size > 1) -return 0; // Already parsed + size_t initial_die_array_size; + auto already_parsed = [cu_die_only, &initial_die_array_size, this]() -> bool { +initial_die_array_size = m_die_array_size_atomic; +return (cu_die_only && initial_die_array_size > 0) +|| initial_die_array_size > 1; + }; + if (already_parsed()) +return 0; + std::lock_guard guard(m_extractdies_mutex); + if (already_parsed()) +return 0; + std::shared_ptr m_die_array_finished_set(nullptr, + [&](void*){ m_die_array_size_atomic = m_die_array.size(); }); static Timer::Category func_cat(LLVM_PRETTY_FUNCTION); Timer scoped_timer( Index: source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.h === --- source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.h +++ source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.h @@ -93,6 +93,8 @@ void *m_user_data = nullptr; DWARFDebugInfoEntry::collection m_die_array; // The compile unit debug information entry item + // Prevent m_extractdies_mutex lock overhead for most cases. + std::atomic_size_t m_die_array_size_atomic { 0 }; std::unique_ptr m_func_aranges_ap; // A table similar to // the .debug_aranges // table, but this one @@ -116,6 +118,8 @@ // in the main object file dw_offset_t m_base_obj_offset = DW_INVALID_OFFSET; + std::mutex m_extractdies_mutex; + void ParseProducerInfo(); private: Index: source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp === --- source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp +++ source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp @@ -83,6 +83,8 @@ void DWARFCompileUnit::ClearDIEs(bool keep_compile_unit_die) { if (m_die_array.size() > 1) { +std::lock_guard guard(m_extractdies_mutex); + // std::vectors never get any smaller when resized to a smaller size, // or when clear() or erase() are called, the size will report that it // is smaller, but the memory allocated remains intact (call capacity() @@ -94,8 +96,11 @@ // Save at least the compile unit DIE DWARFDebugInfoEntry::collection tmp_array; m_die_array.swap(tmp_array); -
[Lldb-commits] [PATCH] D40470: DWZ 07/12: Protect DWARFCompileUnit::m_die_array by a new mutex
jankratochvil added inline comments. Comment at: source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp:123 size_t DWARFCompileUnit::ExtractDIEsIfNeeded(bool cu_die_only) { - const size_t initial_die_array_size = m_data->m_die_array.size(); - if ((cu_die_only && initial_die_array_size > 0) || initial_die_array_size > 1) -return 0; // Already parsed + size_t initial_die_array_size; + auto already_parsed = [cu_die_only, &initial_die_array_size]() -> bool { clayborg wrote: > clayborg wrote: > > I really can't tell what any of the above changed code is doing besides > > adding the mutex. Seems like you are trying to emulate a condition variable > > to halt other threads trying to get access to the DIEs. But > > m_die_array_finished isn't initialized in the constructor or inlined in the > > header file and initial_die_array_size isn't initialized so I can't really > > tell what this is supposed to actually do. > This isn't initialized and it is captured and used in already_parsed below? I am sorry but the missing initialization was just due to a wrong patch splitting. Next patch in the series did initialize it. Anyway it has been reworked now (after dropping whole ExtractDIEsIfNeededKind for its AllDiesButCuDieOnlyForPartialUnits). Comment at: source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp:123-137 + size_t initial_die_array_size; + auto already_parsed = [cu_die_only, &initial_die_array_size]() -> bool { +return (cu_die_only && initial_die_array_size > 0) +|| initial_die_array_size > 1; + }; + if (already_parsed() && m_data->m_die_array_finished) +return 0; jankratochvil wrote: > clayborg wrote: > > clayborg wrote: > > > I really can't tell what any of the above changed code is doing besides > > > adding the mutex. Seems like you are trying to emulate a condition > > > variable to halt other threads trying to get access to the DIEs. But > > > m_die_array_finished isn't initialized in the constructor or inlined in > > > the header file and initial_die_array_size isn't initialized so I can't > > > really tell what this is supposed to actually do. > > This isn't initialized and it is captured and used in already_parsed below? > I am sorry but the missing initialization was just due to a wrong patch > splitting. Next patch in the series did initialize it. Anyway it has been > reworked now (after dropping whole ExtractDIEsIfNeededKind for its > AllDiesButCuDieOnlyForPartialUnits). > Condition variable is not required here I think. m_die_array_finished is initialized before any time it gets read. https://reviews.llvm.org/D40470 ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D40469: DWZ 04/11: Match also DW_TAG_partial_unit when DW_TAG_compile_unit is matched
jankratochvil updated this revision to Diff 135051. jankratochvil retitled this revision from "DWZ 06/12: Mask DW_TAG_partial_unit as DW_TAG_compile_unit for Tag()" to "DWZ 04/11: Match also DW_TAG_partial_unit when DW_TAG_compile_unit is matched". https://reviews.llvm.org/D40469 Files: source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp source/Plugins/SymbolFile/DWARF/DWARFASTParserGo.cpp source/Plugins/SymbolFile/DWARF/DWARFASTParserJava.cpp source/Plugins/SymbolFile/DWARF/DWARFASTParserOCaml.cpp source/Plugins/SymbolFile/DWARF/DWARFDIE.cpp source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp source/Plugins/SymbolFile/DWARF/UniqueDWARFASTType.cpp Index: source/Plugins/SymbolFile/DWARF/UniqueDWARFASTType.cpp === --- source/Plugins/SymbolFile/DWARF/UniqueDWARFASTType.cpp +++ source/Plugins/SymbolFile/DWARF/UniqueDWARFASTType.cpp @@ -57,6 +57,7 @@ } break; case DW_TAG_compile_unit: + case DW_TAG_partial_unit: done = true; break; } Index: source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp === --- source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp +++ source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp @@ -381,6 +381,7 @@ switch (tag) { case DW_TAG_compile_unit: +case DW_TAG_partial_unit: case DW_TAG_subprogram: case DW_TAG_inlined_subroutine: case DW_TAG_lexical_block: @@ -3110,6 +3111,7 @@ if (orig_die != die) { switch (die.Tag()) { case DW_TAG_compile_unit: +case DW_TAG_partial_unit: case DW_TAG_namespace: case DW_TAG_structure_type: case DW_TAG_union_type: @@ -3309,7 +3311,7 @@ // [0] DW_TAG_class_type for "B" // [1] DW_TAG_class_type for "A" // [2] DW_TAG_namespace for "lldb" - // [3] DW_TAG_compile_unit for the source file. + // [3] DW_TAG_compile_unit or DW_TAG_partial_unit for the source file. // // We grab both contexts and make sure that everything matches // all the way back to the compiler unit. @@ -3338,9 +3340,11 @@ #if defined LLDB_CONFIGURATION_DEBUG // Make sure the top item in the decl context die array is always - // DW_TAG_compile_unit. If it isn't then something went wrong in - // the DWARFDIE::GetDeclContextDIEs() function... - assert(decl_ctx_1.GetDIEAtIndex(count1 - 1).Tag() == DW_TAG_compile_unit); + // DW_TAG_compile_unit or DW_TAG_partial_unit. If it isn't then something + // went wrong in the DWARFDIE::GetDeclContextDIEs() function... + dw_tag_t cu_tag = decl_ctx_1.GetDIEAtIndex(count1 - 1).Tag(); + UNUSED_IF_ASSERT_DISABLED(cu_tag); + assert(cu_tag == DW_TAG_compile_unit || cu_tag == DW_TAG_partial_unit); #endif // Always skip the compile unit when comparing by only iterating up to @@ -3944,7 +3948,8 @@ const DWARFDIE parent_context_die = GetDeclContextDIEContainingDIE(die); const dw_tag_t parent_tag = die.GetParent().Tag(); bool is_static_member = - parent_tag == DW_TAG_compile_unit && + (parent_tag == DW_TAG_compile_unit || + parent_tag == DW_TAG_partial_unit) && (parent_context_die.Tag() == DW_TAG_class_type || parent_context_die.Tag() == DW_TAG_structure_type); @@ -3966,7 +3971,8 @@ // "(int) A::B::j = 4". If the compiler does not emit a linkage name, we // should be able // to generate a fully qualified name from the declaration context. -if (parent_tag == DW_TAG_compile_unit && +if ((parent_tag == DW_TAG_compile_unit || + parent_tag == DW_TAG_partial_unit) && Language::LanguageIsCPlusPlus(die.GetLanguage())) { DWARFDeclContext decl_ctx; @@ -4224,6 +4230,7 @@ dw_tag_t parent_tag = sc_parent_die.Tag(); switch (parent_tag) { case DW_TAG_compile_unit: + case DW_TAG_partial_unit: if (sc.comp_unit != NULL) { variable_list_sp = sc.comp_unit->GetVariableList(false); if (variable_list_sp.get() == NULL) { Index: source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp === --- source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp +++ source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp @@ -472,6 +472,7 @@ break; case DW_TAG_compile_unit: + case DW_TAG_partial_unit: is_global_or_static_variable = true; parent_die = NULL; // Terminate the while loop. break; Index: source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp === --- source/Plugins/SymbolFile/DWARF/DWARFDebugInf
[Lldb-commits] [PATCH] D40468: DWZ 04/11: Support reading section ".gnu_debugaltlink"
jankratochvil updated this revision to Diff 135050. jankratochvil retitled this revision from "DWZ 05/12: Support reading section ".gnu_debugaltlink"" to "DWZ 04/11: Support reading section ".gnu_debugaltlink"". https://reviews.llvm.org/D40468 Files: include/lldb/lldb-enumerations.h source/Core/Section.cpp source/Expression/IRExecutionUnit.cpp source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h source/Plugins/SymbolVendor/ELF/SymbolVendorELF.cpp source/Symbol/ObjectFile.cpp Index: source/Symbol/ObjectFile.cpp === --- source/Symbol/ObjectFile.cpp +++ source/Symbol/ObjectFile.cpp @@ -364,6 +364,7 @@ case eSectionTypeDWARFAppleTypes: case eSectionTypeDWARFAppleNamespaces: case eSectionTypeDWARFAppleObjC: + case eSectionTypeDWARFGNUDebugAltLink: return eAddressClassDebug; case eSectionTypeEHFrame: case eSectionTypeARMexidx: Index: source/Plugins/SymbolVendor/ELF/SymbolVendorELF.cpp === --- source/Plugins/SymbolVendor/ELF/SymbolVendorELF.cpp +++ source/Plugins/SymbolVendor/ELF/SymbolVendorELF.cpp @@ -134,7 +134,7 @@ eSectionTypeDWARFDebugMacInfo, eSectionTypeDWARFDebugPubNames, eSectionTypeDWARFDebugPubTypes, eSectionTypeDWARFDebugRanges, eSectionTypeDWARFDebugStr, eSectionTypeDWARFDebugStrOffsets, - eSectionTypeELFSymbolTable, + eSectionTypeELFSymbolTable, eSectionTypeDWARFGNUDebugAltLink, }; for (size_t idx = 0; idx < sizeof(g_sections) / sizeof(g_sections[0]); ++idx) { Index: source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h === --- source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h +++ source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h @@ -250,6 +250,7 @@ const lldb_private::DWARFDataExtractor &get_apple_types_data(); const lldb_private::DWARFDataExtractor &get_apple_namespaces_data(); const lldb_private::DWARFDataExtractor &get_apple_objc_data(); + const lldb_private::DWARFDataExtractor &get_gnu_debugaltlink(); DWARFDebugAbbrev *DebugAbbrev(); @@ -495,6 +496,7 @@ DWARFDataSegment m_data_apple_types; DWARFDataSegment m_data_apple_namespaces; DWARFDataSegment m_data_apple_objc; + DWARFDataSegment m_data_gnu_debugaltlink; // The unique pointer items below are generated on demand if and when someone // accesses Index: source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp === --- source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp +++ source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp @@ -681,6 +681,11 @@ return GetCachedSectionData(eSectionTypeDWARFAppleObjC, m_data_apple_objc); } +const DWARFDataExtractor &SymbolFileDWARF::get_gnu_debugaltlink() { + return GetCachedSectionData(eSectionTypeDWARFGNUDebugAltLink, + m_data_gnu_debugaltlink); +} + DWARFDebugAbbrev *SymbolFileDWARF::DebugAbbrev() { if (m_abbr.get() == NULL) { const DWARFDataExtractor &debug_abbrev_data = get_debug_abbrev_data(); Index: source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp === --- source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp +++ source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp @@ -1212,6 +1212,7 @@ case eSectionTypeDWARFAppleTypes: case eSectionTypeDWARFAppleNamespaces: case eSectionTypeDWARFAppleObjC: + case eSectionTypeDWARFGNUDebugAltLink: return eAddressClassDebug; case eSectionTypeEHFrame: Index: source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp === --- source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp +++ source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp @@ -1823,6 +1823,7 @@ static ConstString g_sect_name_arm_exidx(".ARM.exidx"); static ConstString g_sect_name_arm_extab(".ARM.extab"); static ConstString g_sect_name_go_symtab(".gosymtab"); + static ConstString g_sect_name_dwarf_gnu_debugaltlink(".gnu_debugaltlink"); SectionType sect_type = eSectionTypeOther; @@ -1913,6 +1914,8 @@ sect_type = eSectionTypeARMextab; else if (name == g_sect_name_go_symtab) sect_type = eSectionTypeGoSymtab; + else if (name == g_sect_name_dwarf_gnu_debugaltlink) +sect_type = eSectionTypeDWARFGNUDebugAltLink; const uint32_t permissions = ((header.sh_flags & SHF_ALLOC) ? ePermissionsReadable : 0u) | Index: source/Expression/IRExecutionUnit.cpp
[Lldb-commits] [PATCH] D40469: DWZ 06/12: Mask DW_TAG_partial_unit as DW_TAG_compile_unit for Tag()
jankratochvil added a comment. In https://reviews.llvm.org/D40469#936245, @clayborg wrote: > Seems like it would be cleaner to leave DWARFDebugInfoEntry and DWARFDie > alone and just make clients deal with accepting DW_TAG_partial_unit when and > where they need to. I don't like the idea of not telling the truth. done https://reviews.llvm.org/D40469 ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D40467: DWZ 03/11: Separate Offset also into FileOffset
jankratochvil updated this revision to Diff 135049. jankratochvil retitled this revision from "DWZ 04/12: Separate Offset also into FileOffset" to "DWZ 03/11: Separate Offset also into FileOffset". https://reviews.llvm.org/D40467 Files: include/lldb/Expression/DWARFExpression.h source/Expression/DWARFExpression.cpp source/Plugins/SymbolFile/DWARF/DWARFAttribute.cpp source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.h source/Plugins/SymbolFile/DWARF/DWARFDIE.cpp source/Plugins/SymbolFile/DWARF/DWARFDebugAranges.cpp source/Plugins/SymbolFile/DWARF/DWARFDebugAranges.h source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.cpp source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.h source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.h source/Plugins/SymbolFile/DWARF/DWARFFormValue.cpp source/Plugins/SymbolFile/DWARF/DWARFFormValue.h source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp source/Plugins/SymbolFile/DWARF/DWARFUnit.h source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp Index: source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp === --- source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp +++ source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp @@ -3810,7 +3810,8 @@ DWARFFormValue::GetFixedFormSizesForAddressSize( attributes.CompileUnitAtIndex(i)->GetAddressByteSize(), attributes.CompileUnitAtIndex(i)->IsDWARF64()); -uint32_t data_offset = attributes.DIEOffsetAtIndex(i); +uint32_t data_file_offset = die.GetCU() +->ThisCUUniqToFileOffset(attributes.DIEOffsetAtIndex(i)); uint32_t data_length = fixed_form_sizes.GetSize(form_value.Form()); if (data_length == 0) { @@ -3823,21 +3824,22 @@ const_value = form_value; } } else - location.CopyOpcodeData(module, debug_info_data, data_offset, - data_length); + location.CopyOpcodeData(module, debug_info_data, + data_file_offset, data_length); } else { // Retrieve the value as a string expression. if (form_value.Form() == DW_FORM_strp) { DWARFFormValue::FixedFormSizes fixed_form_sizes = DWARFFormValue::GetFixedFormSizesForAddressSize( attributes.CompileUnitAtIndex(i) ->GetAddressByteSize(), attributes.CompileUnitAtIndex(i)->IsDWARF64()); - uint32_t data_offset = attributes.DIEOffsetAtIndex(i); + uint32_t data_file_offset = die.GetCU() + ->ThisCUUniqToFileOffset(attributes.DIEOffsetAtIndex(i)); uint32_t data_length = fixed_form_sizes.GetSize(form_value.Form()); - location.CopyOpcodeData(module, debug_info_data, data_offset, - data_length); + location.CopyOpcodeData(module, debug_info_data, + data_file_offset, data_length); } else { const char *str = form_value.AsCString(); uint32_t string_offset = Index: source/Plugins/SymbolFile/DWARF/DWARFUnit.h === --- source/Plugins/SymbolFile/DWARF/DWARFUnit.h +++ source/Plugins/SymbolFile/DWARF/DWARFUnit.h @@ -13,6 +13,7 @@ #include "DWARFDIE.h" #include "DWARFDebugInfoEntry.h" #include "lldb/lldb-enumerations.h" +#include "lldb/Utility/LLDBAssert.h" class DWARFUnit; class DWARFCompileUnit; @@ -133,6 +134,23 @@ dw_offset_t GetBaseObjOffset() const; + dw_offset_t GetFileOffset() const; + + dw_offset_t ThisCUFileOffsetToUniq_nocheck(dw_offset_t file) const { +return file + (GetOffset() - GetFileOffset()); + } + dw_offset_t ThisCUFileOffsetToUniq(dw_offset_t file) const { +dw_offset_t uniq = ThisCUFileOffsetToUniq_nocheck(file); +lldbassert(ContainsDIEOffset(uniq)); +return uniq; + } + dw_offset_t FileOffsetToUniqOffset(dw_offset_t file) const; + dw_offset_t ThisCUUniqToFileOffset(dw_offset_t uniq) const; + bool ContainsFileOffset(dw_offset_t file) const { +return ContainsDIEOffset(ThisCUFileOffsetToUniq_nocheck(file)); + } + dw_offset_t GetNextCompileUnitFileOffset() const; + protected: virtual DWARFCompileUnit &Data() = 0; virtual const DWARFCompileUnit &Data() const = 0; Index: source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp === --- source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp +++ source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp @@ -12
[Lldb-commits] [PATCH] D42892: DWZ 02/11: Move the codebase to use: DWARFCompileUnit -> DWARFUnit
jankratochvil updated this revision to Diff 135048. jankratochvil retitled this revision from "DWZ 03/12: Move the codebase to use: DWARFCompileUnit -> DWARFUnit" to "DWZ 02/11: Move the codebase to use: DWARFCompileUnit -> DWARFUnit". jankratochvil edited the summary of this revision. https://reviews.llvm.org/D42892 Files: include/lldb/Expression/DWARFExpression.h source/Expression/DWARFExpression.cpp source/Plugins/SymbolFile/DWARF/DIERef.cpp source/Plugins/SymbolFile/DWARF/DWARFASTParserJava.cpp source/Plugins/SymbolFile/DWARF/DWARFAttribute.cpp source/Plugins/SymbolFile/DWARF/DWARFAttribute.h source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.h source/Plugins/SymbolFile/DWARF/DWARFDIE.cpp source/Plugins/SymbolFile/DWARF/DWARFDIE.h source/Plugins/SymbolFile/DWARF/DWARFDebugAranges.cpp source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.cpp source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.h source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.h source/Plugins/SymbolFile/DWARF/DWARFFormValue.cpp source/Plugins/SymbolFile/DWARF/DWARFFormValue.h source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp source/Plugins/SymbolFile/DWARF/DWARFUnit.h source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.cpp source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.h source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwoDwp.cpp source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwoDwp.h source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwp.cpp source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwp.h Index: source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwp.h === --- source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwp.h +++ source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwp.h @@ -29,7 +29,7 @@ Create(lldb::ModuleSP module_sp, const lldb_private::FileSpec &file_spec); std::unique_ptr - GetSymbolFileForDwoId(DWARFCompileUnit *dwarf_cu, uint64_t dwo_id); + GetSymbolFileForDwoId(DWARFUnit *dwarf_cu, uint64_t dwo_id); bool LoadSectionData(uint64_t dwo_id, lldb::SectionType sect_type, lldb_private::DWARFDataExtractor &data); Index: source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwp.cpp === --- source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwp.cpp +++ source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwp.cpp @@ -85,7 +85,7 @@ {} std::unique_ptr -SymbolFileDWARFDwp::GetSymbolFileForDwoId(DWARFCompileUnit *dwarf_cu, +SymbolFileDWARFDwp::GetSymbolFileForDwoId(DWARFUnit *dwarf_cu, uint64_t dwo_id) { return std::unique_ptr( new SymbolFileDWARFDwoDwp(this, m_obj_file, dwarf_cu, dwo_id)); Index: source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwoDwp.h === --- source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwoDwp.h +++ source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwoDwp.h @@ -20,7 +20,7 @@ class SymbolFileDWARFDwoDwp : public SymbolFileDWARFDwo { public: SymbolFileDWARFDwoDwp(SymbolFileDWARFDwp *dwp_symfile, -lldb::ObjectFileSP objfile, DWARFCompileUnit *dwarf_cu, +lldb::ObjectFileSP objfile, DWARFUnit *dwarf_cu, uint64_t dwo_id); protected: Index: source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwoDwp.cpp === --- source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwoDwp.cpp +++ source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwoDwp.cpp @@ -14,15 +14,15 @@ #include "lldb/Symbol/ObjectFile.h" #include "lldb/Utility/LLDBAssert.h" -#include "DWARFCompileUnit.h" +#include "DWARFUnit.h" #include "DWARFDebugInfo.h" using namespace lldb; using namespace lldb_private; SymbolFileDWARFDwoDwp::SymbolFileDWARFDwoDwp(SymbolFileDWARFDwp *dwp_symfile, ObjectFileSP objfile, - DWARFCompileUnit *dwarf_cu, + DWARFUnit *dwarf_cu, uint64_t dwo_id) : SymbolFileDWARFDwo(objfile, dwarf_cu), m_dwp_symfile(dwp_symfile), m_dwo_id(dwo_id) {} Index: source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.h === --- source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.h +++ source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.h @@ -18,16 +18,16 @@ class SymbolFileDWARFDwo : public SymbolFileDWARF { public: - SymbolFileDWARFDwo(lldb::ObjectFileSP objfile, DWARFCompileUnit *dwarf_cu); + SymbolFileDWARFDwo(lldb::ObjectFileSP objfile, DWARFUnit *dwarf_cu); ~Symbo
[Lldb-commits] [PATCH] D40466: DWZ 02/12: DWARFUnit split out of DWARFCompileUnit
jankratochvil updated this revision to Diff 135047. https://reviews.llvm.org/D40466 Files: source/Plugins/SymbolFile/DWARF/CMakeLists.txt source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.h source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp source/Plugins/SymbolFile/DWARF/DWARFUnit.h Index: source/Plugins/SymbolFile/DWARF/DWARFUnit.h === --- /dev/null +++ source/Plugins/SymbolFile/DWARF/DWARFUnit.h @@ -0,0 +1,159 @@ +//===-- DWARFUnit.h -*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===--===// + +#ifndef SymbolFileDWARF_DWARFUnit_h_ +#define SymbolFileDWARF_DWARFUnit_h_ + +#include "DWARFDIE.h" +#include "DWARFDebugInfoEntry.h" +#include "lldb/lldb-enumerations.h" + +class DWARFUnit; +class DWARFCompileUnit; +class NameToDIE; +class SymbolFileDWARF; +class SymbolFileDWARFDwo; + +typedef std::shared_ptr DWARFUnitSP; + +enum DWARFProducer { + eProducerInvalid = 0, + eProducerClang, + eProducerGCC, + eProducerLLVMGCC, + eProcucerOther +}; + +class DWARFUnit { +public: + virtual ~DWARFUnit(); + + size_t ExtractDIEsIfNeeded(bool cu_die_only); + DWARFDIE LookupAddress(const dw_addr_t address); + size_t AppendDIEsWithTag(const dw_tag_t tag, + DWARFDIECollection &matching_dies, + uint32_t depth = UINT32_MAX) const; + bool Verify(lldb_private::Stream *s) const; + void Dump(lldb_private::Stream *s) const; + // Offset of the initial length field. + dw_offset_t GetOffset() const { return m_offset; } + lldb::user_id_t GetID() const; + // Size in bytes of the initial length + compile unit header. + uint32_t Size() const; + bool ContainsDIEOffset(dw_offset_t die_offset) const { +return die_offset >= GetFirstDIEOffset() && + die_offset < GetNextCompileUnitOffset(); + } + dw_offset_t GetFirstDIEOffset() const { return m_offset + Size(); } + dw_offset_t GetNextCompileUnitOffset() const; + // Size of the CU data (without initial length and without header). + size_t GetDebugInfoSize() const; + // Size of the CU data incl. header but without initial length. + uint32_t GetLength() const; + uint16_t GetVersion() const; + const DWARFAbbreviationDeclarationSet *GetAbbreviations() const; + dw_offset_t GetAbbrevOffset() const; + uint8_t GetAddressByteSize() const; + dw_addr_t GetBaseAddress() const; + dw_addr_t GetAddrBase() const; + dw_addr_t GetRangesBase() const; + void SetAddrBase(dw_addr_t addr_base, dw_addr_t ranges_base, dw_offset_t base_obj_offset); + void ClearDIEs(bool keep_compile_unit_die); + void BuildAddressRangeTable(SymbolFileDWARF *dwarf2Data, + DWARFDebugAranges *debug_aranges); + + lldb::ByteOrder GetByteOrder() const; + + lldb_private::TypeSystem *GetTypeSystem(); + + DWARFFormValue::FixedFormSizes GetFixedFormSizes(); + + void SetBaseAddress(dw_addr_t base_addr); + + DWARFDIE + GetCompileUnitDIEOnly(); + + DWARFDIE + DIE(); + + bool HasDIEsParsed() const; + + DWARFDIE GetDIE(dw_offset_t die_offset); + + static uint8_t GetAddressByteSize(const DWARFUnit *cu); + + static bool IsDWARF64(const DWARFUnit *cu); + + static uint8_t GetDefaultAddressSize(); + + static void SetDefaultAddressSize(uint8_t addr_size); + + void *GetUserData() const; + + void SetUserData(void *d); + + bool Supports_DW_AT_APPLE_objc_complete_type(); + + bool DW_AT_decl_file_attributes_are_invalid(); + + bool Supports_unnamed_objc_bitfields(); + + void Index(NameToDIE &func_basenames, NameToDIE &func_fullnames, + NameToDIE &func_methods, NameToDIE &func_selectors, + NameToDIE &objc_class_selectors, NameToDIE &globals, + NameToDIE &types, NameToDIE &namespaces); + + SymbolFileDWARF *GetSymbolFileDWARF() const; + + DWARFProducer GetProducer(); + + uint32_t GetProducerVersionMajor(); + + uint32_t GetProducerVersionMinor(); + + uint32_t GetProducerVersionUpdate(); + + static lldb::LanguageType LanguageTypeFromDWARF(uint64_t val); + + lldb::LanguageType GetLanguageType(); + + bool IsDWARF64() const; + + bool GetIsOptimized(); + + SymbolFileDWARFDwo *GetDwoSymbolFile() const; + + dw_offset_t GetBaseObjOffset() const; + +protected: + virtual DWARFCompileUnit &Data() = 0; + virtual const DWARFCompileUnit &Data() const = 0; + + DWARFUnit(); + + static void + IndexPrivate(DWARFUnit *dwarf_cu, const lldb::LanguageType cu_language, + const DWARFFormValue::FixedFormSizes &fixed_form_sizes, + const dw_offset_t cu_offset, NameToDIE &func_basenames, + NameToDIE &func_fullnames, NameToDIE &func_methods, + NameToDIE &func_se
[Lldb-commits] [PATCH] D43506: Fix a couple of more tests to not create files in the source tree
labath created this revision. labath added reviewers: davide, aprantl. These were not being flaky, but they're still making the tree dirty. These tests were using lldbutil.append_to_process_working_directory to derive the file path so I fix them by modifying the function to return the build directory for local tests. Technically, now the path returned by this function does not point to the process working directory for local tests, but I think it makes sense to keep the function name, as I think we should move towards launching the process in the build directory (and I intend to change this for the handful of inferiors that actually care about their PWD, for example because they need to create files there). https://reviews.llvm.org/D43506 Files: packages/Python/lldbsuite/test/functionalities/process_attach/attach_denied/TestAttachDenied.py packages/Python/lldbsuite/test/functionalities/process_group/TestChangeProcessGroup.py packages/Python/lldbsuite/test/lldbtest.py packages/Python/lldbsuite/test/lldbutil.py packages/Python/lldbsuite/test/python_api/target/TestTargetAPI.py packages/Python/lldbsuite/test/tools/lldb-server/TestGdbRemoteModuleInfo.py packages/Python/lldbsuite/test/tools/lldb-server/gdbremote_testcase.py Index: packages/Python/lldbsuite/test/tools/lldb-server/gdbremote_testcase.py === --- packages/Python/lldbsuite/test/tools/lldb-server/gdbremote_testcase.py +++ packages/Python/lldbsuite/test/tools/lldb-server/gdbremote_testcase.py @@ -549,7 +549,7 @@ inferior_exe_path = self.getBuildArtifact("a.out") if lldb.remote_platform: -remote_path = lldbutil.append_to_process_working_directory( +remote_path = lldbutil.append_to_process_working_directory(self, os.path.basename(inferior_exe_path)) remote_file_spec = lldb.SBFileSpec(remote_path, False) err = lldb.remote_platform.Install(lldb.SBFileSpec( @@ -1610,7 +1610,7 @@ exe_path = self.getBuildArtifact("a.out") if not lldb.remote_platform: return [exe_path] -remote_path = lldbutil.append_to_process_working_directory( +remote_path = lldbutil.append_to_process_working_directory(self, os.path.basename(exe_path)) remote_file_spec = lldb.SBFileSpec(remote_path, False) err = lldb.remote_platform.Install(lldb.SBFileSpec(exe_path, True), Index: packages/Python/lldbsuite/test/tools/lldb-server/TestGdbRemoteModuleInfo.py === --- packages/Python/lldbsuite/test/tools/lldb-server/TestGdbRemoteModuleInfo.py +++ packages/Python/lldbsuite/test/tools/lldb-server/TestGdbRemoteModuleInfo.py @@ -20,7 +20,7 @@ self.test_sequence.add_log_lines([ 'read packet: $jModulesInfo:[{"file":"%s","triple":"%s"}]]#00' % ( -lldbutil.append_to_process_working_directory("a.out"), +lldbutil.append_to_process_working_directory(self, "a.out"), info["triple"].decode('hex')), {"direction": "send", "regex": r'^\$\[{(.*)}\]\]#[0-9A-Fa-f]{2}', Index: packages/Python/lldbsuite/test/python_api/target/TestTargetAPI.py === --- packages/Python/lldbsuite/test/python_api/target/TestTargetAPI.py +++ packages/Python/lldbsuite/test/python_api/target/TestTargetAPI.py @@ -60,12 +60,6 @@ self.build() self.get_description() -@add_test_categories(['pyapi']) -def test_launch_new_process_and_redirect_stdout(self): -"""Exercise SBTarget.Launch() API.""" -self.build() -self.launch_new_process_and_redirect_stdout() - @add_test_categories(['pyapi']) def test_resolve_symbol_context_with_address(self): """Exercise SBTarget.ResolveSymbolContextForAddress() API.""" @@ -268,8 +262,11 @@ substrs=['a.out', 'Target', 'Module', 'Breakpoint']) @not_remote_testsuite_ready -def launch_new_process_and_redirect_stdout(self): +@add_test_categories(['pyapi']) +@no_debug_info_test +def test_launch_new_process_and_redirect_stdout(self): """Exercise SBTaget.Launch() API with redirected stdout.""" +self.build() exe = self.getBuildArtifact("a.out") # Create a target by the debugger. @@ -285,9 +282,12 @@ # Now launch the process, do not stop at entry point, and redirect stdout to "stdout.txt" file. # The inferior should run to completion after "process.Continue()" # call. -local_path = "stdout.txt" +local_path = self.getBuildArtifact("stdout.txt") +if os.path.exists(local_path): +os.remove(local_path) + if lldb.remote_platform: -stdout_path = lldbutil.append_to_process_working_directory( +
[Lldb-commits] [PATCH] D43464: Avoid dirtying the source tree in breakpoint command tests
This revision was automatically updated to reflect the committed changes. Closed by commit rL325570: Avoid dirtying the source tree in breakpoint command tests (authored by labath, committed by ). Herald added a subscriber: llvm-commits. Repository: rL LLVM https://reviews.llvm.org/D43464 Files: lldb/trunk/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_command/TestBreakpointCommand.py lldb/trunk/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_command/TestBreakpointCommandsFromPython.py lldb/trunk/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_command/bktptcmd.py lldb/trunk/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_command/side_effect.py Index: lldb/trunk/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_command/side_effect.py === --- lldb/trunk/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_command/side_effect.py +++ lldb/trunk/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_command/side_effect.py @@ -0,0 +1,5 @@ +""" +A dummy module for testing the execution of various breakpoint commands. A +command will modify a global variable in this module and test will check its +value. +""" Index: lldb/trunk/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_command/TestBreakpointCommand.py === --- lldb/trunk/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_command/TestBreakpointCommand.py +++ lldb/trunk/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_command/TestBreakpointCommand.py @@ -11,18 +11,14 @@ from lldbsuite.test.decorators import * from lldbsuite.test.lldbtest import * from lldbsuite.test import lldbutil +import side_effect class BreakpointCommandTestCase(TestBase): +NO_DEBUG_INFO_TESTCASE = True mydir = TestBase.compute_mydir(__file__) -@classmethod -def classCleanup(cls): -"""Cleanup the test byproduct of breakpoint_command_sequence(self).""" -cls.RemoveTempFile("output.txt") -cls.RemoveTempFile("output2.txt") - @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr24528") def test_breakpoint_command_sequence(self): """Test a sequence of breakpoint command add, list, and delete.""" @@ -71,7 +67,7 @@ self.runCmd( "breakpoint command add -s command -o 'frame variable --show-types --scope' 1 4") self.runCmd( -"breakpoint command add -s python -o 'here = open(\"output.txt\", \"w\"); here.write(\"lldb\\n\"); here.close()' 2") +"breakpoint command add -s python -o 'import side_effect; side_effect.one_liner = \"one liner was here\"' 2") self.runCmd( "breakpoint command add --python-function bktptcmd.function 3") @@ -104,9 +100,8 @@ "frame variable --show-types --scope"]) self.expect("breakpoint command list 2", "Breakpoint 2 command ok", substrs=["Breakpoint commands (Python):", - "here = open", - "here.write", - "here.close()"]) + "import side_effect", + "side_effect.one_liner"]) self.expect("breakpoint command list 3", "Breakpoint 3 command ok", substrs=["Breakpoint commands (Python):", "bktptcmd.function(frame, bp_loc, internal_dict)"]) @@ -151,40 +146,14 @@ extra_options="-f a.c", num_expected_locations=1) -# Run the program. Remove 'output.txt' if it exists. -self.RemoveTempFile("output.txt") -self.RemoveTempFile("output2.txt") +# Reset our canary variables and run the program. +side_effect.one_liner = None +side_effect.bktptcmd = None self.runCmd("run", RUN_SUCCEEDED) -# Check that the file 'output.txt' exists and contains the string -# "lldb". - -# The 'output.txt' file should now exist. -self.assertTrue( -os.path.isfile("output.txt"), -"'output.txt' exists due to breakpoint command for breakpoint 2.") -self.assertTrue( -os.path.isfile("output2.txt"), -"'output2.txt' exists due to breakpoint command for breakpoint 3.") - -# Read the output file produced by running the program. -with open('output.txt', 'r') as f: -output = f.read() - -self.expect( -output, -"File 'output.txt' and the content matches", -exe=False, -startstr="lldb") - -with open('output2.txt', 'r') as f: -output = f.read() - -self.expect( -output, -"File 'output2.txt'
[Lldb-commits] [lldb] r325570 - Avoid dirtying the source tree in breakpoint command tests
Author: labath Date: Tue Feb 20 02:24:37 2018 New Revision: 325570 URL: http://llvm.org/viewvc/llvm-project?rev=325570&view=rev Log: Avoid dirtying the source tree in breakpoint command tests Summary: The paralelization patch exposed a bunch of cases where we were still touching the source tree (as these tests were now stepping on each others toes and being flaky). This patch removes such issues from breakpoint command tests. Since the only reason they were creating files was to indirectly test whether the breakpoint commands got executed (and plumbing the full build tree path to all places that needed it would be messy) I decided to modify the tests to check for a different side effect instead: modification of a global variable. This also makes the code simpler as checking the value of the global variable is easier, and there is nothing to clean up. As the tests aren't really doing anything debug-info related, I took the opportunity to also mark them as NO_DEBUG_INFO_TESTCASEs. Reviewers: jingham, aprantl Subscribers: lldb-commits Differential Revision: https://reviews.llvm.org/D43464 Added: lldb/trunk/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_command/side_effect.py Modified: lldb/trunk/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_command/TestBreakpointCommand.py lldb/trunk/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_command/TestBreakpointCommandsFromPython.py lldb/trunk/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_command/bktptcmd.py Modified: lldb/trunk/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_command/TestBreakpointCommand.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_command/TestBreakpointCommand.py?rev=325570&r1=325569&r2=325570&view=diff == --- lldb/trunk/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_command/TestBreakpointCommand.py (original) +++ lldb/trunk/packages/Python/lldbsuite/test/functionalities/breakpoint/breakpoint_command/TestBreakpointCommand.py Tue Feb 20 02:24:37 2018 @@ -11,18 +11,14 @@ import lldb from lldbsuite.test.decorators import * from lldbsuite.test.lldbtest import * from lldbsuite.test import lldbutil +import side_effect class BreakpointCommandTestCase(TestBase): +NO_DEBUG_INFO_TESTCASE = True mydir = TestBase.compute_mydir(__file__) -@classmethod -def classCleanup(cls): -"""Cleanup the test byproduct of breakpoint_command_sequence(self).""" -cls.RemoveTempFile("output.txt") -cls.RemoveTempFile("output2.txt") - @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr24528") def test_breakpoint_command_sequence(self): """Test a sequence of breakpoint command add, list, and delete.""" @@ -71,7 +67,7 @@ class BreakpointCommandTestCase(TestBase self.runCmd( "breakpoint command add -s command -o 'frame variable --show-types --scope' 1 4") self.runCmd( -"breakpoint command add -s python -o 'here = open(\"output.txt\", \"w\"); here.write(\"lldb\\n\"); here.close()' 2") +"breakpoint command add -s python -o 'import side_effect; side_effect.one_liner = \"one liner was here\"' 2") self.runCmd( "breakpoint command add --python-function bktptcmd.function 3") @@ -104,9 +100,8 @@ class BreakpointCommandTestCase(TestBase "frame variable --show-types --scope"]) self.expect("breakpoint command list 2", "Breakpoint 2 command ok", substrs=["Breakpoint commands (Python):", - "here = open", - "here.write", - "here.close()"]) + "import side_effect", + "side_effect.one_liner"]) self.expect("breakpoint command list 3", "Breakpoint 3 command ok", substrs=["Breakpoint commands (Python):", "bktptcmd.function(frame, bp_loc, internal_dict)"]) @@ -151,40 +146,14 @@ class BreakpointCommandTestCase(TestBase extra_options="-f a.c", num_expected_locations=1) -# Run the program. Remove 'output.txt' if it exists. -self.RemoveTempFile("output.txt") -self.RemoveTempFile("output2.txt") +# Reset our canary variables and run the program. +side_effect.one_liner = None +side_effect.bktptcmd = None self.runCmd("run", RUN_SUCCEEDED) -# Check that the file 'output.txt' exists and contains the string -# "lldb". - -# The 'output.txt' file should now exist. -self.assertTrue( -os.path.isfile("output.txt"), -"'output.txt' exists due to br
[Lldb-commits] [PATCH] D43471: Handle typeof() expressions
This revision was automatically updated to reflect the committed changes. Closed by commit rL325568: Handle typeof() expressions (authored by JDevlieghere, committed by ). Herald added a subscriber: llvm-commits. Changed prior to commit: https://reviews.llvm.org/D43471?vs=134965&id=135025#toc Repository: rL LLVM https://reviews.llvm.org/D43471 Files: lldb/trunk/lit/Expr/TestTypeOfDeclTypeExpr.test lldb/trunk/source/Symbol/ClangASTContext.cpp Index: lldb/trunk/source/Symbol/ClangASTContext.cpp === --- lldb/trunk/source/Symbol/ClangASTContext.cpp +++ lldb/trunk/source/Symbol/ClangASTContext.cpp @@ -3964,7 +3964,10 @@ case clang::Type::DependentTemplateSpecialization: return eTypeIsTemplate; case clang::Type::Decltype: -return 0; +return CompilerType( + getASTContext(), + llvm::cast(qual_type)->getUnderlyingType()) +.GetTypeInfo(pointee_or_element_clang_type); case clang::Type::Enum: if (pointee_or_element_clang_type) @@ -4046,9 +4049,16 @@ ->getUnderlyingType()) .GetTypeInfo(pointee_or_element_clang_type); case clang::Type::TypeOfExpr: -return 0; +return CompilerType(getASTContext(), +llvm::cast(qual_type) +->getUnderlyingExpr() +->getType()) +.GetTypeInfo(pointee_or_element_clang_type); case clang::Type::TypeOf: -return 0; +return CompilerType( + getASTContext(), + llvm::cast(qual_type)->getUnderlyingType()) +.GetTypeInfo(pointee_or_element_clang_type); case clang::Type::UnresolvedUsing: return 0; @@ -4255,11 +4265,21 @@ break; case clang::Type::TypeOfExpr: -break; +return CompilerType(getASTContext(), +llvm::cast(qual_type) +->getUnderlyingExpr() +->getType()) +.GetTypeClass(); case clang::Type::TypeOf: -break; +return CompilerType( + getASTContext(), + llvm::cast(qual_type)->getUnderlyingType()) +.GetTypeClass(); case clang::Type::Decltype: -break; +return CompilerType( + getASTContext(), + llvm::cast(qual_type)->getUnderlyingType()) +.GetTypeClass(); case clang::Type::TemplateSpecialization: break; case clang::Type::DeducedTemplateSpecialization: @@ -5060,7 +5080,22 @@ return CompilerType(getASTContext(), llvm::cast(qual_type)->desugar()) .GetEncoding(count); - + case clang::Type::TypeOfExpr: +return CompilerType(getASTContext(), +llvm::cast(qual_type) +->getUnderlyingExpr() +->getType()) +.GetEncoding(count); + case clang::Type::TypeOf: +return CompilerType( + getASTContext(), + llvm::cast(qual_type)->getUnderlyingType()) +.GetEncoding(count); + case clang::Type::Decltype: +return CompilerType( + getASTContext(), + llvm::cast(qual_type)->getUnderlyingType()) +.GetEncoding(count); case clang::Type::DependentSizedArray: case clang::Type::DependentSizedExtVector: case clang::Type::UnresolvedUsing: @@ -5074,9 +5109,6 @@ case clang::Type::PackExpansion: case clang::Type::ObjCObject: - case clang::Type::TypeOfExpr: - case clang::Type::TypeOf: - case clang::Type::Decltype: case clang::Type::TemplateSpecialization: case clang::Type::DeducedTemplateSpecialization: case clang::Type::Atomic: @@ -5214,6 +5246,22 @@ getASTContext(), llvm::cast(qual_type)->getNamedType()) .GetFormat(); + case clang::Type::TypeOfExpr: +return CompilerType(getASTContext(), +llvm::cast(qual_type) +->getUnderlyingExpr() +->getType()) +.GetFormat(); + case clang::Type::TypeOf: +return CompilerType( + getASTContext(), + llvm::cast(qual_type)->getUnderlyingType()) +.GetFormat(); + case clang::Type::Decltype: +return CompilerType( + getASTContext(), + llvm::cast(qual_type)->getUnderlyingType()) +.GetFormat(); case clang::Type::DependentSizedArray: case clang::Type::DependentSizedExtVector: case clang::Type::UnresolvedUsing: @@ -5227,9 +5275,6 @@ case clang::Type::PackExpansion: case clang::Type::ObjCObject: - case clang::Type::TypeOfExpr: - case clang::Type::TypeOf: - case clang::Type::Decltype: case clang::Type::TemplateSpecialization: case clang::Type::DeducedTemplateSpecialization: case clang::Type::Atomic: @@ -6264,11 +6309,15 @@ return GetNumPointeeChildren( llvm::cast(qual_type)->getNamedType());
[Lldb-commits] [lldb] r325568 - Handle typeof() expressions
Author: jdevlieghere Date: Tue Feb 20 02:15:08 2018 New Revision: 325568 URL: http://llvm.org/viewvc/llvm-project?rev=325568&view=rev Log: Handle typeof() expressions Before this patch, LLDB was not able to evaluate expressions that resulted in a value with a typeof- or decltype-type. This patch fixes that. Before: (lldb) p int i; __typeof__(i) j = 1; j (typeof (i)) $0 = After: (lldb) p int i; __typeof__(i) j = 1; j (typeof (i)) $0 = 1 Differential revision: https://reviews.llvm.org/D43471 rdar://37461520 Added: lldb/trunk/lit/Expr/TestTypeOfDeclTypeExpr.test Modified: lldb/trunk/source/Symbol/ClangASTContext.cpp Added: lldb/trunk/lit/Expr/TestTypeOfDeclTypeExpr.test URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/lit/Expr/TestTypeOfDeclTypeExpr.test?rev=325568&view=auto == --- lldb/trunk/lit/Expr/TestTypeOfDeclTypeExpr.test (added) +++ lldb/trunk/lit/Expr/TestTypeOfDeclTypeExpr.test Tue Feb 20 02:15:08 2018 @@ -0,0 +1,13 @@ +# RUN: %lldb -b -s %s | FileCheck %s + +expression int i; __typeof__(i) j = 1; j +# CHECK: (lldb) expression int i; __typeof__(i) j = 1; j +# CHECK-NEXT: (typeof (i)) {{.*}} = 1 + +expression int i; typeof(i) j = 1; j +# CHECK: (lldb) expression int i; typeof(i) j = 1; j +# CHECK-NEXT: (typeof (i)) {{.*}} = 1 + +expression int i; decltype(i) j = 1; j +# CHECK: (lldb) expression int i; decltype(i) j = 1; j +# CHECK-NEXT: (decltype(i)) {{.*}} = 1 Modified: lldb/trunk/source/Symbol/ClangASTContext.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/ClangASTContext.cpp?rev=325568&r1=325567&r2=325568&view=diff == --- lldb/trunk/source/Symbol/ClangASTContext.cpp (original) +++ lldb/trunk/source/Symbol/ClangASTContext.cpp Tue Feb 20 02:15:08 2018 @@ -3964,7 +3964,10 @@ ClangASTContext::GetTypeInfo(lldb::opaqu case clang::Type::DependentTemplateSpecialization: return eTypeIsTemplate; case clang::Type::Decltype: -return 0; +return CompilerType( + getASTContext(), + llvm::cast(qual_type)->getUnderlyingType()) +.GetTypeInfo(pointee_or_element_clang_type); case clang::Type::Enum: if (pointee_or_element_clang_type) @@ -4046,9 +4049,16 @@ ClangASTContext::GetTypeInfo(lldb::opaqu ->getUnderlyingType()) .GetTypeInfo(pointee_or_element_clang_type); case clang::Type::TypeOfExpr: -return 0; +return CompilerType(getASTContext(), +llvm::cast(qual_type) +->getUnderlyingExpr() +->getType()) +.GetTypeInfo(pointee_or_element_clang_type); case clang::Type::TypeOf: -return 0; +return CompilerType( + getASTContext(), + llvm::cast(qual_type)->getUnderlyingType()) +.GetTypeInfo(pointee_or_element_clang_type); case clang::Type::UnresolvedUsing: return 0; @@ -4255,11 +4265,21 @@ ClangASTContext::GetTypeClass(lldb::opaq break; case clang::Type::TypeOfExpr: -break; +return CompilerType(getASTContext(), +llvm::cast(qual_type) +->getUnderlyingExpr() +->getType()) +.GetTypeClass(); case clang::Type::TypeOf: -break; +return CompilerType( + getASTContext(), + llvm::cast(qual_type)->getUnderlyingType()) +.GetTypeClass(); case clang::Type::Decltype: -break; +return CompilerType( + getASTContext(), + llvm::cast(qual_type)->getUnderlyingType()) +.GetTypeClass(); case clang::Type::TemplateSpecialization: break; case clang::Type::DeducedTemplateSpecialization: @@ -5060,7 +5080,22 @@ lldb::Encoding ClangASTContext::GetEncod return CompilerType(getASTContext(), llvm::cast(qual_type)->desugar()) .GetEncoding(count); - + case clang::Type::TypeOfExpr: +return CompilerType(getASTContext(), +llvm::cast(qual_type) +->getUnderlyingExpr() +->getType()) +.GetEncoding(count); + case clang::Type::TypeOf: +return CompilerType( + getASTContext(), + llvm::cast(qual_type)->getUnderlyingType()) +.GetEncoding(count); + case clang::Type::Decltype: +return CompilerType( + getASTContext(), + llvm::cast(qual_type)->getUnderlyingType()) +.GetEncoding(count); case clang::Type::DependentSizedArray: case clang::Type::DependentSizedExtVector: case clang::Type::UnresolvedUsing: @@ -5074,9 +5109,6 @@ lldb::Encoding ClangASTContext::GetEncod case clang::Type::PackExpansion: case clang::Type::ObjCObject: - case clang::Type::TypeOfExpr: - case clang::Type::TypeOf: -