Re: [Lldb-commits] Performing ManualDWARFIndex::Index() async during ManualDWARFIndex::Preload()

2021-02-07 Thread Lasse Folger via lldb-commits
Hi Pavel,

Thanks for the detailed response and sorry for the late reply. I was very
busy this week and I do this work as part of a side project (so I might
need some time to react).
I hope I will find some time next week to work on it.

We tried 'target.preload-symbols'. Unfortunately, it only led to the lag
spike occurring later but not disappearing completely.
I will do some tests and let you know of the results.

2) You mentioned:
*I might even go for a once_flag/call_once to also get the "runs once"
behavior for free.*
Is this a common pattern/utility in llvm? (This is my first llvm
contribution, so let me know if I should use any pattern/utility)
Or do you mean to create a flag *ManualDWARFIndex *and use it to check at
the beginning of Preload() to avoid creating the async task?

As for the locking. I have seen that the lock is already taken in
*SymbolFileDWARF::PreloadSymbols().
*My concern is that the code after PreloadSymbols() is now (potentially)
executed in parallel to the code in Index().

3) I will also take a look with some tests to check if I can provoke
contention issues.

kind regards,
Lasse


On Sun, Jan 31, 2021 at 2:21 PM Pavel Labath  wrote:

> On 29/01/2021 16:25, Lasse Folger via lldb-commits wrote:
>  > Hi lldb devs,
>  >
>  > We experienced some issues when debugging large binaries.
>  > The startup time of lldb for large binaries is long (tens of seconds).
>  > One of the reasons is that the /ManualDWARFIndex::Index()/ function is
>  > executed synchronously and thus blocks during startup.
>
> Before I go further, let me ask this: You are aware of the
> 'target.preload-symbols' setting which can disable (delay) the indexing
> at starting, right? I am asking because it may result in a similar
> behavior than what you get with your patch. At the very least, it would
> be interesting to see a comparison of the two scenarios, to get a feel
> for the benefits it offers.
>
> On 29/01/2021 18:23, Lasse Folger via lldb-commits wrote:
> > Thanks Raphael for the pointers, I will take a look.
> >
> > I just noticed I forgot to attach the actual patch I prepared ;)
> > Here it is.
> >
> > On Fri, Jan 29, 2021, 5:02 PM Raphael “Teemperor” Isemann
> > mailto:teempe...@gmail.com>> wrote:
> >
> > I can't help with any of the requested feedback, but the last time I
> > looked at a benchmark involving ManualDWARFIndex, the
> > ManualDWARFIndex::IndexUnit spent about 40% of its runtime just
> > constructing ConstString. Half of that 40% (so, 20% total time) was
> > just spend contesting/locking the locks for ConstString's global
> > string pools. Refactoring the code to not having to reaquire a
> > contested global lock for every DIE might help with improving
> > startup time.
>
> I also feel obligated to point out that this code has been optimized and
> re-optimized by a number of people already. So all of the quick wins are
> likely gone already.
>
> I am not saying that its not possible to improve the performance of this
> (in fact, I'm certain it can) -- however, such an effort will probably
> require making fundamental changes to the algorithm, rather than just
> using fancier data structures.
>
> I don't want to sound too discouraging, but I think you ought to know
> what you're getting yourself into.
>
> Good luck! (I mean it)
>
> >> I would like to have feedback on three parts:
> >>
> >>  1. In /ManualDWARFIndex::Preload() /I capture /this/ of the
> >> /ManualDWARFIndex/. As far as I could tell this is not a
> >> problem since the index is not relocated or deleted. However,
> >> I'm not that familiar with the architecture. Are there cases
> >> when the object is relocated or deleted before lldb stops?
> While it's very unlikely, I don't think we can guarantee that the Module
> object holding the index is not deleted by the time the async thread
> runs. Such a thing might happen due to events totally beyond our
> control, such as the user calling SBTarget::RemoveModule.
>
> This should be fixable by simply stashing the Module shared pointer.
>
>
> >>  2. I use the /Module /mutex for synchronization because I didn't
> >> want to introduce a mutex in /ManualDWARFIndex /or
> >> /DWARFIndex/. Do you think this locking granularity is fine or
> >> should I create a dedicated mutex for it?
> I think it should work, but a separate synchronization primitive might
> be cleaner. I might even go for a once_flag/call_once to also get the
> "runs once" behavior for free.
>
> >> Furthermore, I
> >> looked through the implementation
> >> of ManualDWARFIndex::/Index()/ and couldn't find any locking
> >> function in there. However, I might have missed something (or
> >> some of the underlying implementations change in the future)
> >> and there is a danger for a deadlock.
> The lack of locking is not surprising because these functions already
> expect that the cal

[Lldb-commits] [PATCH] D96176: Implement jAttachWait

2021-02-07 Thread Augusto Noronha via Phabricator via lldb-commits
augusto2112 added a comment.

In D96176#2546777 , @labath wrote:

> One alternative could be to just tack on some extra data to the existing 
> vAttach family packets  (`vAttachWait;foo;interval:47;duration=74`).

This was how I did it originally on https://reviews.llvm.org/D93895. @clayborg 
pointed out that this might not be compatible with existing lldb-server 
implementations, and suggested a new packet.

>> Lastly, this current implementation has a bug I couldn't figure out, where 
>> if we're sending l an error response, lldb loses connection to lldb-server 
>> (this happens even if the first thing I do in the handle_jAttachWait 
>> function is return an error)
>
> I'm not sure that's a bug (i.e., lldb may be intentionally dropping the 
> connection). What would you expect lldb to do when it gets an error response?

To expand on the error, if I change `handle_vAttachWait` to immediately return 
an error with string "foo", lldb will print out: `error: attach failed: foo`, 
while if I do the same on `handle_jAttachWait` if will print out: `error: 
attach failed: lost connection`, so we lose the error message.

>> and, also, CTRL+C from lldb doesn't interrupt lldb-server. If anyone know 
>> why this might be happening, I'd be glad to hear it.
>
> Seems to work for me (in that I get back to the lldb prompt and the server 
> connection is terminated), if I press ^C **twice**.

What I mean is that my new packet has these problems, and `vAttachWait` 
doesn't. I'm confused because I believe I implemented all the parts the same as 
the other `vAttach` functions.

Also, I misunderstood the bug I was having. It looks like two `^C` will 
interrupt my function as well, the problem is that it lags for around 5 seconds 
before doing so (and I was inputing a third `^C` before the interrupt, which 
killed lldb, and left lldb-server running), whereas the `vAttachWait` variant 
interrupts immediately.




Comment at: lldb/include/lldb/Target/Process.h:223-224
   bool m_wait_for_launch;
+  llvm::Optional m_wait_for_launch_interval;
+  llvm::Optional m_wait_for_launch_duration;
   bool m_ignore_existing;

labath wrote:
> clayborg wrote:
> > Should we attach _usec and sec to these names to make it clear what the 
> > units are?
> I'd make that std::chrono::(micro)seconds
I agree that using chrono would make it evident what the units are.



Comment at: lldb/include/lldb/Utility/StringExtractorGDBRemote.h:136
 eServerPacketType_vAttachOrWait,
+eServerPacketType_jAttachWait,
 eServerPacketType_vAttachName,

labath wrote:
> clayborg wrote:
> > So we currently have 4 flavors from the old way: vAttach, vAttachWait 
> > vAttachOrWait, vAttachName. Do we want to possibly make a "jAttach" that 
> > works for all cases? The new "jAttach" could be powerful enough to do it 
> > all in one packet if needed. I just worry about attaching the "Wait" to the 
> > "jAttachWait" command name in case we want to use it for all of the above 
> > cases at a later point. 
> > 
> > A "jAttach" could implement all of:
> > - attach to existing pid
> > - attach to by name
> >   - unique existing process
> >   - wait
> > - allow existing (true/false)
> > - poll interval (time in usec)
> > - wait duration (time in sec)
> > 
> > Not that we need to add support for all of these flavor with this patch, 
> > I'm just trying to forward think about the future in case other attach 
> > flags are added to any flavor of attach. 
> Sounds like a good idea.
Sure! I was considering that as well. I wasn't sure what granularity lldb's 
packets should have, which is why I decided to start only with the attachWait 
first and see what you thought. I can include this in this patch, I don't think 
it's a lot of extra work.



Comment at: 
lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp:261-273
+bool GDBRemoteCommunicationClient::GetJAttachWaitSupported() {
+  if (m_j_attach_wait_reply == eLazyBoolCalculate) {
+m_j_attach_wait_reply = eLazyBoolNo;
+
+StringExtractorGDBRemote response;
+if (SendPacketAndWaitForResponse("qJAttachWaitSupported", response,
+ false) == PacketResult::Success) {

labath wrote:
> I'm not sure this is really useful. We could infer that the packet is not 
> supported by the "unsupported" response to the packet itself...
Do you mean the `qJAttachWaitSupported` packet? I'm mimicking  the existing 
`qVAttachOrWaitSupported` packet, I think it's good to use the same pattern, 
no? 


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D96176/new/

https://reviews.llvm.org/D96176

___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D96176: Implement jAttachWait

2021-02-07 Thread Pavel Labath via Phabricator via lldb-commits
labath added a comment.

In D96176#2547324 , @augusto2112 wrote:

> In D96176#2546777 , @labath wrote:
>
>> One alternative could be to just tack on some extra data to the existing 
>> vAttach family packets  (`vAttachWait;foo;interval:47;duration=74`).
>
> This was how I did it originally on https://reviews.llvm.org/D93895. 
> @clayborg pointed out that this might not be compatible with existing 
> lldb-server implementations, and suggested a new packet.

If we only append the extra fields when the user explicitly requests them, then 
I don't think this would be a compatibility issue. The way I see it, one of two 
things can happen in this case:
a) the server ignores the extra fields and completes the attach with the 
default values
b) the server balks at the packet, and returns an error
I think both of them are reasonable results and they can be fixed/worked around 
in the same way -- just drop the special requests...

>>> Lastly, this current implementation has a bug I couldn't figure out, where 
>>> if we're sending l an error response, lldb loses connection to lldb-server 
>>> (this happens even if the first thing I do in the handle_jAttachWait 
>>> function is return an error)
>>
>> I'm not sure that's a bug (i.e., lldb may be intentionally dropping the 
>> connection). What would you expect lldb to do when it gets an error response?
>
> To expand on the error, if I change `handle_vAttachWait` to immediately 
> return an error with string "foo", lldb will print out: `error: attach 
> failed: foo`, while if I do the same on `handle_jAttachWait` if will print 
> out: `error: attach failed: lost connection`, so we lose the error message.
>
>>> and, also, CTRL+C from lldb doesn't interrupt lldb-server. If anyone know 
>>> why this might be happening, I'd be glad to hear it.
>>
>> Seems to work for me (in that I get back to the lldb prompt and the server 
>> connection is terminated), if I press ^C **twice**.
>
> What I mean is that my new packet has these problems, and `vAttachWait` 
> doesn't. I'm confused because I believe I implemented all the parts the same 
> as the other `vAttach` functions.

Hm.. I don't know.. I guess you'll have to step through the code to find where 
it diverges...


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D96176/new/

https://reviews.llvm.org/D96176

___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D49968: DWZ 02/06: Refactor DWARFUnit::ExtractDIEsScoped

2021-02-07 Thread Jan Kratochvil via Phabricator via lldb-commits
jankratochvil abandoned this revision.
jankratochvil added a comment.

This change is no longer needed.


Repository:
  rLLDB LLDB

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D49968/new/

https://reviews.llvm.org/D49968

___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D96201: [nfc] [lldb] Add Dwo assert

2021-02-07 Thread Jan Kratochvil via Phabricator via lldb-commits
jankratochvil abandoned this revision.
jankratochvil added a comment.

OK, dropped.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D96201/new/

https://reviews.llvm.org/D96201

___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D73206: Pass `CompileUnit *` along `DWARFDIE` for DWZ

2021-02-07 Thread Jan Kratochvil via Phabricator via lldb-commits
jankratochvil abandoned this revision.
jankratochvil added a comment.
Herald added subscribers: sstefan1, JDevlieghere.

Replaced by D96236 .


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D73206/new/

https://reviews.llvm.org/D73206

___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D40473: DWZ 01/06: Adjust existing code for the DWZ support

2021-02-07 Thread Jan Kratochvil via Phabricator via lldb-commits
jankratochvil abandoned this revision.
jankratochvil added a comment.
Herald added a reviewer: shafik.

Replaced by D96236 .


Repository:
  rLLDB LLDB

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D40473/new/

https://reviews.llvm.org/D40473

___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D96237: DWZ 02/08: More support for .gnu_debugaltlink

2021-02-07 Thread Jan Kratochvil via Phabricator via lldb-commits
jankratochvil created this revision.
jankratochvil added reviewers: labath, clayborg.
jankratochvil added a project: LLDB.
Herald added a subscriber: JDevlieghere.
jankratochvil requested review of this revision.

It was already added by D40468  but a few bits 
were still missing.

All DWZ patches are also applied at: `git clone -b dwz 
git://git.jankratochvil.net/lldb`
There is a copy: `git clone -b dwz 
https://github.com/jankratochvil/llvm-project`


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D96237

Files:
  lldb/source/Plugins/SymbolFile/DWARF/DWARFContext.cpp
  lldb/source/Plugins/SymbolFile/DWARF/DWARFContext.h


Index: lldb/source/Plugins/SymbolFile/DWARF/DWARFContext.h
===
--- lldb/source/Plugins/SymbolFile/DWARF/DWARFContext.h
+++ lldb/source/Plugins/SymbolFile/DWARF/DWARFContext.h
@@ -44,6 +44,7 @@
   SectionData m_data_debug_str_offsets;
   SectionData m_data_debug_tu_index;
   SectionData m_data_debug_types;
+  SectionData m_data_gnu_debug_alt_link;
 
   const DWARFDataExtractor &
   LoadOrGetSection(llvm::Optional main_section_type,
@@ -73,6 +74,7 @@
   const DWARFDataExtractor &getOrLoadStrData();
   const DWARFDataExtractor &getOrLoadStrOffsetsData();
   const DWARFDataExtractor &getOrLoadDebugTypesData();
+  const DWARFDataExtractor &getOrLoadGNUDebugAltLink();
 
   bool isDwo() { return m_dwo_section_list != nullptr; }
 
Index: lldb/source/Plugins/SymbolFile/DWARF/DWARFContext.cpp
===
--- lldb/source/Plugins/SymbolFile/DWARF/DWARFContext.cpp
+++ lldb/source/Plugins/SymbolFile/DWARF/DWARFContext.cpp
@@ -123,6 +123,11 @@
   eSectionTypeDWARFDebugTypesDwo, m_data_debug_types);
 }
 
+const DWARFDataExtractor &DWARFContext::getOrLoadGNUDebugAltLink() {
+  return LoadOrGetSection(eSectionTypeDWARFGNUDebugAltLink, llvm::None,
+  m_data_gnu_debug_alt_link);
+}
+
 llvm::DWARFContext &DWARFContext::GetAsLLVM() {
   if (!m_llvm_context) {
 llvm::StringMap> section_map;


Index: lldb/source/Plugins/SymbolFile/DWARF/DWARFContext.h
===
--- lldb/source/Plugins/SymbolFile/DWARF/DWARFContext.h
+++ lldb/source/Plugins/SymbolFile/DWARF/DWARFContext.h
@@ -44,6 +44,7 @@
   SectionData m_data_debug_str_offsets;
   SectionData m_data_debug_tu_index;
   SectionData m_data_debug_types;
+  SectionData m_data_gnu_debug_alt_link;
 
   const DWARFDataExtractor &
   LoadOrGetSection(llvm::Optional main_section_type,
@@ -73,6 +74,7 @@
   const DWARFDataExtractor &getOrLoadStrData();
   const DWARFDataExtractor &getOrLoadStrOffsetsData();
   const DWARFDataExtractor &getOrLoadDebugTypesData();
+  const DWARFDataExtractor &getOrLoadGNUDebugAltLink();
 
   bool isDwo() { return m_dwo_section_list != nullptr; }
 
Index: lldb/source/Plugins/SymbolFile/DWARF/DWARFContext.cpp
===
--- lldb/source/Plugins/SymbolFile/DWARF/DWARFContext.cpp
+++ lldb/source/Plugins/SymbolFile/DWARF/DWARFContext.cpp
@@ -123,6 +123,11 @@
   eSectionTypeDWARFDebugTypesDwo, m_data_debug_types);
 }
 
+const DWARFDataExtractor &DWARFContext::getOrLoadGNUDebugAltLink() {
+  return LoadOrGetSection(eSectionTypeDWARFGNUDebugAltLink, llvm::None,
+  m_data_gnu_debug_alt_link);
+}
+
 llvm::DWARFContext &DWARFContext::GetAsLLVM() {
   if (!m_llvm_context) {
 llvm::StringMap> section_map;
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D96237: DWZ 02/08: More support for .gnu_debugaltlink

2021-02-07 Thread Jan Kratochvil via Phabricator via lldb-commits
jankratochvil updated this revision to Diff 322026.

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D96237/new/

https://reviews.llvm.org/D96237

Files:
  lldb/source/Plugins/SymbolFile/DWARF/DWARFContext.cpp
  lldb/source/Plugins/SymbolFile/DWARF/DWARFContext.h


Index: lldb/source/Plugins/SymbolFile/DWARF/DWARFContext.h
===
--- lldb/source/Plugins/SymbolFile/DWARF/DWARFContext.h
+++ lldb/source/Plugins/SymbolFile/DWARF/DWARFContext.h
@@ -44,6 +44,7 @@
   SectionData m_data_debug_str_offsets;
   SectionData m_data_debug_tu_index;
   SectionData m_data_debug_types;
+  SectionData m_data_gnu_debug_alt_link;
 
   const DWARFDataExtractor &
   LoadOrGetSection(llvm::Optional main_section_type,
@@ -73,6 +74,7 @@
   const DWARFDataExtractor &getOrLoadStrData();
   const DWARFDataExtractor &getOrLoadStrOffsetsData();
   const DWARFDataExtractor &getOrLoadDebugTypesData();
+  const DWARFDataExtractor &getOrLoadGNUDebugAltLink();
 
   bool isDwo() { return m_dwo_section_list != nullptr; }
 
Index: lldb/source/Plugins/SymbolFile/DWARF/DWARFContext.cpp
===
--- lldb/source/Plugins/SymbolFile/DWARF/DWARFContext.cpp
+++ lldb/source/Plugins/SymbolFile/DWARF/DWARFContext.cpp
@@ -123,6 +123,11 @@
   eSectionTypeDWARFDebugTypesDwo, m_data_debug_types);
 }
 
+const DWARFDataExtractor &DWARFContext::getOrLoadGNUDebugAltLink() {
+  return LoadOrGetSection(eSectionTypeDWARFGNUDebugAltLink, llvm::None,
+  m_data_gnu_debug_alt_link);
+}
+
 llvm::DWARFContext &DWARFContext::GetAsLLVM() {
   if (!m_llvm_context) {
 llvm::StringMap> section_map;


Index: lldb/source/Plugins/SymbolFile/DWARF/DWARFContext.h
===
--- lldb/source/Plugins/SymbolFile/DWARF/DWARFContext.h
+++ lldb/source/Plugins/SymbolFile/DWARF/DWARFContext.h
@@ -44,6 +44,7 @@
   SectionData m_data_debug_str_offsets;
   SectionData m_data_debug_tu_index;
   SectionData m_data_debug_types;
+  SectionData m_data_gnu_debug_alt_link;
 
   const DWARFDataExtractor &
   LoadOrGetSection(llvm::Optional main_section_type,
@@ -73,6 +74,7 @@
   const DWARFDataExtractor &getOrLoadStrData();
   const DWARFDataExtractor &getOrLoadStrOffsetsData();
   const DWARFDataExtractor &getOrLoadDebugTypesData();
+  const DWARFDataExtractor &getOrLoadGNUDebugAltLink();
 
   bool isDwo() { return m_dwo_section_list != nullptr; }
 
Index: lldb/source/Plugins/SymbolFile/DWARF/DWARFContext.cpp
===
--- lldb/source/Plugins/SymbolFile/DWARF/DWARFContext.cpp
+++ lldb/source/Plugins/SymbolFile/DWARF/DWARFContext.cpp
@@ -123,6 +123,11 @@
   eSectionTypeDWARFDebugTypesDwo, m_data_debug_types);
 }
 
+const DWARFDataExtractor &DWARFContext::getOrLoadGNUDebugAltLink() {
+  return LoadOrGetSection(eSectionTypeDWARFGNUDebugAltLink, llvm::None,
+  m_data_gnu_debug_alt_link);
+}
+
 llvm::DWARFContext &DWARFContext::GetAsLLVM() {
   if (!m_llvm_context) {
 llvm::StringMap> section_map;
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D96238: [lldb] [nfc] DWZ 03/08: rename TypeUnitSupportFiles -> SharedUnitSupportFiles

2021-02-07 Thread Jan Kratochvil via Phabricator via lldb-commits
jankratochvil created this revision.
jankratochvil added reviewers: labath, clayborg.
jankratochvil added a project: LLDB.
Herald added a subscriber: JDevlieghere.
jankratochvil requested review of this revision.

With DWZ it is no longer being used just for `DW_TAG_type_unit` but now it is 
used also for `DW_TAG_partial_unit`. Therefore the former name would be 
inappropriate.

All DWZ patches are also applied at: `git clone -b dwz 
git://git.jankratochvil.net/lldb`
There is a copy: `git clone -b dwz 
https://github.com/jankratochvil/llvm-project`


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D96238

Files:
  lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
  lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h


Index: lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
===
--- lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
+++ lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
@@ -491,7 +491,7 @@
 
   void FindDwpSymbolFile();
 
-  const lldb_private::FileSpecList &GetTypeUnitSupportFiles(DWARFTypeUnit &tu);
+  const lldb_private::FileSpecList &GetSharedUnitSupportFiles(DWARFUnit &tu);
 
   lldb::ModuleWP m_debug_map_module_wp;
   SymbolFileDWARFDebugMap *m_debug_map_symfile;
@@ -526,7 +526,7 @@
   DIEToClangType m_forward_decl_die_to_clang_type;
   ClangTypeToDIE m_forward_decl_clang_type_to_die;
   llvm::DenseMap
-  m_type_unit_support_files;
+  m_shared_unit_support_files;
   std::vector m_lldb_cu_to_dwarf_unit;
 };
 
Index: lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
===
--- lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
+++ lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
@@ -919,15 +919,14 @@
 return FileSpec();
   }
 
-  auto &tu = llvm::cast(unit);
-  return GetTypeUnitSupportFiles(tu).GetFileSpecAtIndex(file_idx);
+  return GetSharedUnitSupportFiles(unit).GetFileSpecAtIndex(file_idx);
 }
 
 const FileSpecList &
-SymbolFileDWARF::GetTypeUnitSupportFiles(DWARFTypeUnit &tu) {
+SymbolFileDWARF::GetSharedUnitSupportFiles(DWARFUnit &unit) {
   static FileSpecList empty_list;
 
-  dw_offset_t offset = tu.GetLineTableOffset();
+  dw_offset_t offset = unit.GetLineTableOffset();
   if (offset == DW_INVALID_OFFSET ||
   offset == llvm::DenseMapInfo::getEmptyKey() ||
   offset == llvm::DenseMapInfo::getTombstoneKey())
@@ -935,7 +934,7 @@
 
   // Many type units can share a line table, so parse the support file list
   // once, and cache it based on the offset field.
-  auto iter_bool = m_type_unit_support_files.try_emplace(offset);
+  auto iter_bool = m_shared_unit_support_files.try_emplace(offset);
   FileSpecList &list = iter_bool.first->second;
   if (iter_bool.second) {
 uint64_t line_table_offset = offset;
@@ -944,16 +943,17 @@
 llvm::DWARFDebugLine::Prologue prologue;
 auto report = [](llvm::Error error) {
   Log *log = LogChannelDWARF::GetLogIfAll(DWARF_LOG_DEBUG_INFO);
-  LLDB_LOG_ERROR(log, std::move(error),
- "SymbolFileDWARF::GetTypeUnitSupportFiles failed to parse 
"
- "the line table prologue");
+  LLDB_LOG_ERROR(
+  log, std::move(error),
+  "SymbolFileDWARF::GetSharedUnitSupportFiles failed to parse "
+  "the line table prologue");
 };
 llvm::Error error = prologue.parse(data, &line_table_offset, report, ctx);
 if (error) {
   report(std::move(error));
 } else {
   list = ParseSupportFilesFromPrologue(GetObjectFile()->GetModule(),
-   prologue, tu.GetPathStyle());
+   prologue, unit.GetPathStyle());
 }
   }
   return list;


Index: lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
===
--- lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
+++ lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
@@ -491,7 +491,7 @@
 
   void FindDwpSymbolFile();
 
-  const lldb_private::FileSpecList &GetTypeUnitSupportFiles(DWARFTypeUnit &tu);
+  const lldb_private::FileSpecList &GetSharedUnitSupportFiles(DWARFUnit &tu);
 
   lldb::ModuleWP m_debug_map_module_wp;
   SymbolFileDWARFDebugMap *m_debug_map_symfile;
@@ -526,7 +526,7 @@
   DIEToClangType m_forward_decl_die_to_clang_type;
   ClangTypeToDIE m_forward_decl_clang_type_to_die;
   llvm::DenseMap
-  m_type_unit_support_files;
+  m_shared_unit_support_files;
   std::vector m_lldb_cu_to_dwarf_unit;
 };
 
Index: lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
===
--- lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
+++ lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
@@ -919,15 +919,14 @@
 return FileSpec();
   }
 
-  auto &tu = llvm::cast(unit);
-  return GetTypeUnitSuppor

[Lldb-commits] [PATCH] D96239: [lldb] DWZ 04/08: DIERef support

2021-02-07 Thread Jan Kratochvil via Phabricator via lldb-commits
jankratochvil created this revision.
jankratochvil added reviewers: labath, clayborg.
jankratochvil added a project: LLDB.
Herald added subscribers: JDevlieghere, arphaman.
jankratochvil requested review of this revision.

DIERef needs to contain more context information as DWZ needs to track main 
unit and it also needs to locate some DIEs in a separate shared common file in 
`/usr/lib/debug/.dwz/` .

All DWZ patches are also applied at: `git clone -b dwz 
git://git.jankratochvil.net/lldb`
There is a copy: `git clone -b dwz 
https://github.com/jankratochvil/llvm-project`


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D96239

Files:
  lldb/source/Plugins/SymbolFile/DWARF/DIERef.cpp
  lldb/source/Plugins/SymbolFile/DWARF/DIERef.h
  lldb/source/Plugins/SymbolFile/DWARF/DWARFBaseDIE.cpp
  lldb/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.cpp
  lldb/source/Plugins/SymbolFile/DWARF/HashedNameToDIE.h
  lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp

Index: lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
===
--- lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
+++ lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
@@ -1300,10 +1300,15 @@
 
   // WARNING: Use ref.dwo_num() as GetDwoNum() may not be valid in 'this'.
   static_assert(sizeof(ref.die_offset()) * 8 == 32, "");
-  lldbassert(!ref.dwo_num().hasValue() || *ref.dwo_num() <= 0x3fff);
+  lldbassert(!ref.dwo_num().hasValue() || *ref.dwo_num() <= 0x1fff);
+  lldbassert(!ref.main_cu().hasValue() || *ref.main_cu() <= 0x1fff);
+  lldbassert(0 <= ref.kind_get());
+  lldbassert(ref.kind_get() <= 3);
   user_id_t retval =
-  user_id_t(ref.dwo_num().getValueOr(0)) << 32 | ref.die_offset() |
-  lldb::user_id_t(ref.dwo_num().hasValue()) << 62 |
+  user_id_t(ref.dwo_num() ? *ref.dwo_num()
+  : (ref.main_cu() ? *ref.main_cu() : 0))
+  << 32 |
+  ref.die_offset() | user_id_t(ref.kind_get()) << 61 |
   lldb::user_id_t(ref.section() == DIERef::Section::DebugTypes) << 63;
 
 #ifndef NDEBUG
@@ -1330,8 +1335,9 @@
   if (SymbolFileDWARFDebugMap *debug_map = GetDebugMapSymfile()) {
 SymbolFileDWARF *dwarf = debug_map->GetSymbolFileByOSOIndex(
 debug_map->GetOSOIndexFromUserID(uid));
-return DecodedUID{
-*dwarf, {llvm::None, DIERef::Section::DebugInfo, dw_offset_t(uid)}};
+return DecodedUID{*dwarf,
+  {llvm::None, llvm::None, DIERef::MainDwz,
+   DIERef::Section::DebugInfo, dw_offset_t(uid)}};
   }
   dw_offset_t die_offset = uid;
   if (die_offset == DW_INVALID_OFFSET)
@@ -1340,12 +1346,14 @@
   DIERef::Section section =
   uid >> 63 ? DIERef::Section::DebugTypes : DIERef::Section::DebugInfo;
 
+  DIERef::Kind kind = DIERef::Kind(uid >> 61 & 3);
+
   llvm::Optional dwo_num;
-  bool dwo_valid = uid >> 62 & 1;
-  if (dwo_valid)
-dwo_num = uid >> 32 & 0x3fff;
+  if (kind == DIERef::Kind::DwoKind)
+dwo_num = uid >> 32 & 0x1fff;
 
-  return DecodedUID{*this, {dwo_num, section, die_offset}};
+  return DecodedUID{
+  *this, {dwo_num, llvm::None, DIERef::MainDwz, section, die_offset}};
 }
 
 DWARFDIE
@@ -1619,7 +1627,7 @@
 DWARFDIE
 SymbolFileDWARF::GetDIE(const DIERef &die_ref, DWARFUnit **main_unit_return) {
   if (die_ref.dwo_num()) {
-SymbolFileDWARF *dwarf = *die_ref.dwo_num() == 0x3fff
+SymbolFileDWARF *dwarf = *die_ref.dwo_num() == 0x1fff
  ? m_dwp_symfile.get()
  : this->DebugInfo()
.GetUnitAtIndex(*die_ref.dwo_num())
@@ -1712,6 +1720,7 @@
   if (dwo_obj_file == nullptr)
 return nullptr;
 
+  lldbassert(dwarf_cu->GetID() < 0x1fff);
   return std::make_shared(*this, dwo_obj_file,
   dwarf_cu->GetID());
 }
@@ -3958,7 +3967,7 @@
   if (!dwp_obj_file)
 return;
   m_dwp_symfile =
-  std::make_shared(*this, dwp_obj_file, 0x3fff);
+  std::make_shared(*this, dwp_obj_file, 0x1fff);
 }
   });
   return m_dwp_symfile;
Index: lldb/source/Plugins/SymbolFile/DWARF/HashedNameToDIE.h
===
--- lldb/source/Plugins/SymbolFile/DWARF/HashedNameToDIE.h
+++ lldb/source/Plugins/SymbolFile/DWARF/HashedNameToDIE.h
@@ -65,7 +65,8 @@
 DIEInfo(dw_offset_t o, dw_tag_t t, uint32_t f, uint32_t h);
 
 explicit operator DIERef() const {
-  return DIERef(llvm::None, DIERef::Section::DebugInfo, die_offset);
+  return DIERef(llvm::None, llvm::None, DIERef::MainDwz,
+DIERef::Section::DebugInfo, die_offset);
 }
   };
 
Index: lldb/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.cpp
===
--- lldb/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.cpp
+++ lld

[Lldb-commits] [PATCH] D96240: [lldb] DWZ 05/08: Main functionality

2021-02-07 Thread Jan Kratochvil via Phabricator via lldb-commits
jankratochvil created this revision.
jankratochvil added reviewers: labath, clayborg.
jankratochvil added a project: LLDB.
Herald added subscribers: JDevlieghere, arphaman, mgorny.
jankratochvil requested review of this revision.

All DWZ patches are also applied at: `git clone -b dwz 
git://git.jankratochvil.net/lldb`
There is a copy: `git clone -b dwz 
https://github.com/jankratochvil/llvm-project`


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D96240

Files:
  lldb/include/lldb/Utility/ConstString.h
  lldb/include/lldb/Utility/FileSpec.h
  lldb/source/Plugins/SymbolFile/DWARF/CMakeLists.txt
  lldb/source/Plugins/SymbolFile/DWARF/DWARFBaseDIE.cpp
  lldb/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp
  lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.cpp
  lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp
  lldb/source/Plugins/SymbolFile/DWARF/DWARFFormValue.cpp
  lldb/source/Plugins/SymbolFile/DWARF/DWARFTypeUnit.h
  lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
  lldb/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.cpp
  lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp
  lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
  lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
  lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwz.cpp
  lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwz.h

Index: lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwz.h
===
--- /dev/null
+++ lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwz.h
@@ -0,0 +1,36 @@
+//===-- SymbolFileDWARFDwz.h *- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#ifndef SymbolFileDWARFDwz_SymbolFileDWARFDwz_h_
+#define SymbolFileDWARFDwz_SymbolFileDWARFDwz_h_
+
+#include "SymbolFileDWARF.h"
+
+typedef std::unique_ptr SymbolFileDWARFDwzUP;
+
+class SymbolFileDWARFDwz : public SymbolFileDWARF {
+public:
+  SymbolFileDWARFDwz(lldb::ObjectFileSP objfile, lldb::ModuleSP m_module);
+
+  bool GetIsDwz() const override { return true; }
+
+  static void InitializeForDWARF(SymbolFileDWARF &dwarf);
+
+  void ClearForDWARF(SymbolFileDWARF &dwarf);
+
+private:
+  void SetForDWARF(SymbolFileDWARF &dwarf);
+
+  size_t m_use_count = 0;
+  lldb::ModuleSP m_module;
+
+  SymbolFileDWARFDwz(const SymbolFileDWARFDwz &) = delete;
+  const SymbolFileDWARFDwz &operator=(const SymbolFileDWARFDwz &) = delete;
+};
+
+#endif // SymbolFileDWARFDwz_SymbolFileDWARFDwz_h_
Index: lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwz.cpp
===
--- /dev/null
+++ lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwz.cpp
@@ -0,0 +1,175 @@
+//===-- SymbolFileDWARFDwz.cpp --*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "SymbolFileDWARFDwz.h"
+#include "DWARFDebugInfo.h"
+#include "lldb/Core/Module.h"
+#include "lldb/Core/ModuleSpec.h"
+#include "lldb/Host/FileSystem.h"
+#include "lldb/Symbol/ObjectFile.h"
+#include "lldb/Utility/FileSpec.h"
+#include "llvm/ADT/PointerUnion.h"
+
+using namespace lldb;
+using namespace lldb_private;
+
+SymbolFileDWARFDwz::SymbolFileDWARFDwz(ObjectFileSP objfile, ModuleSP module)
+: SymbolFileDWARF(std::move(objfile), /*dwo_section_list*/ nullptr),
+  m_module(std::move(module)) {
+  InitializeObject();
+  // Call private DWARFDebugInfo::ParseCompileUnitHeadersIfNeeded() as
+  // otherwise DWARFCompileUnit::GetAbbreviations() would have no data.
+  DebugInfo().GetNumUnits();
+}
+
+// C++20: Use heterogeneous lookup for unordered container instead.
+class DwzAsKey {
+public:
+  DwzAsKey(SymbolFileDWARFDwz &dwz) : ptr(&dwz) {}
+  DwzAsKey(FileSpec &fspec) : ptr(&fspec) {}
+  DwzAsKey() {}
+  SymbolFileDWARFDwz &GetDwz() const {
+return *ptr.get();
+  }
+  FileSpec &GetFileSpec() const {
+if (ptr.is())
+  return *ptr.get();
+return GetDwz().GetObjectFile()->GetFileSpec();
+  }
+  bool operator==(const DwzAsKey &rhs) const {
+return GetFileSpec() == rhs.GetFileSpec();
+  }
+  bool operator!=(const DwzAsKey &rhs) const { return !(*this == rhs); }
+  class Hasher {
+  public:
+size_t operator()(const DwzAsKey &key) const {
+  return FileSpec::Hasher()(key.GetFileSpec());
+}
+  };
+
+private:
+  llvm::PointerUnion ptr;
+};
+
+static std::unordered_map
+dwz_map;
+static llvm::sys::RWMutex dwz_map_mutex;
+
+void Symbol

[Lldb-commits] [PATCH] D40474: DWZ 03/06: Main functionality

2021-02-07 Thread Jan Kratochvil via Phabricator via lldb-commits
jankratochvil abandoned this revision.
jankratochvil added a comment.

Replaced by D96240 .


Repository:
  rLLDB LLDB

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D40474/new/

https://reviews.llvm.org/D40474

___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D49969: DWZ 04/06: ManualDWARFIndex::GetGlobalVariables for DIEs in PUs

2021-02-07 Thread Jan Kratochvil via Phabricator via lldb-commits
jankratochvil abandoned this revision.
jankratochvil added a comment.

Replaced by D96240 .


Repository:
  rLLDB LLDB

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D49969/new/

https://reviews.llvm.org/D49969

___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D96241: [lldb] DWZ 06/08: New testsuite category 'dwz'

2021-02-07 Thread Jan Kratochvil via Phabricator via lldb-commits
jankratochvil created this revision.
jankratochvil added reviewers: labath, clayborg.
jankratochvil added a project: LLDB.
Herald added a subscriber: JDevlieghere.
jankratochvil requested review of this revision.

All DWZ patches are also applied at: `git clone -b dwz 
git://git.jankratochvil.net/lldb`
There is a copy: `git clone -b dwz 
https://github.com/jankratochvil/llvm-project`


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D96241

Files:
  lldb/packages/Python/lldbsuite/test/builders/builder.py
  lldb/packages/Python/lldbsuite/test/dotest.py
  lldb/packages/Python/lldbsuite/test/lldbinline.py
  lldb/packages/Python/lldbsuite/test/lldbtest.py
  lldb/packages/Python/lldbsuite/test/make/Makefile.rules
  lldb/packages/Python/lldbsuite/test/test_categories.py
  lldb/test/API/lang/cpp/template-function/TestTemplateFunctions.py

Index: lldb/test/API/lang/cpp/template-function/TestTemplateFunctions.py
===
--- lldb/test/API/lang/cpp/template-function/TestTemplateFunctions.py
+++ lldb/test/API/lang/cpp/template-function/TestTemplateFunctions.py
@@ -53,6 +53,6 @@
 self.do_test_template_function(True)
 
 @skipIfWindows
-@expectedFailureAll(debug_info=["dwarf", "gmodules", "dwo"])
+@expectedFailureAll(debug_info=["dwarf", "gmodules", "dwo", "dwz"])
 def test_template_function_without_cast(self):
 self.do_test_template_function(False)
Index: lldb/packages/Python/lldbsuite/test/test_categories.py
===
--- lldb/packages/Python/lldbsuite/test/test_categories.py
+++ lldb/packages/Python/lldbsuite/test/test_categories.py
@@ -15,7 +15,7 @@
 
 
 debug_info_categories = [
-'dwarf', 'dwo', 'dsym', 'gmodules'
+'dwarf', 'dwo', 'dsym', 'gmodules', 'dwz'
 ]
 
 all_categories = {
@@ -27,6 +27,7 @@
 'dsym': 'Tests that can be run with DSYM debug information',
 'dwarf': 'Tests that can be run with DWARF debug information',
 'dwo': 'Tests that can be run with DWO debug information',
+'dwz': 'Tests using DWZ and its DWARF partial units',
 'dyntype': 'Tests related to dynamic type support',
 'expression': 'Tests related to the expression parser',
 'flakey': 'Flakey test cases, i.e. tests that do not reliably pass at each execution',
@@ -67,6 +68,8 @@
 if platform not in ["freebsd", "darwin", "macosx", "ios", "watchos", "tvos", "bridgeos"]:
 return False
 return gmodules.is_compiler_clang_with_gmodules(compiler_path)
+elif category == "dwz":
+return platform in ["linux"]
 return True
 
 
Index: lldb/packages/Python/lldbsuite/test/make/Makefile.rules
===
--- lldb/packages/Python/lldbsuite/test/make/Makefile.rules
+++ lldb/packages/Python/lldbsuite/test/make/Makefile.rules
@@ -26,6 +26,7 @@
 # SPLIT_DEBUG_SYMBOLS := YES
 # CROSS_COMPILE :=
 # USE_PRIVATE_MODULE_CACHE := YES
+# DWZ := YES
 
 # Uncomment line below for debugging shell commands
 # SHELL = /bin/sh -x
@@ -198,8 +199,12 @@
 		override ARCHFLAG := -
 	endif
 
-	ifeq "$(SPLIT_DEBUG_SYMBOLS)" "YES"
-		DSYM = $(EXE).debug
+	ifeq "$(DWZ)" "YES"
+		# DWZ always does SPLIT_DEBUG_SYMBOLS (as otherwise the dwz command fails)
+	else
+		ifeq "$(SPLIT_DEBUG_SYMBOLS)" "YES"
+			DSYM = $(EXE).debug
+		endif
 	endif
 endif
 
@@ -355,6 +360,26 @@
 	LDFLAGS += -pie
 endif
 
+#--
+# Make the DWZ symbol file from the executable if $(DWZ) = "YES"
+# The dwz retry without -m is there because:
+#   dwz -m still succeeds even for no debug info present (missing -g):
+# dwz: $(1).debug: .debug_info section not present
+#   But dwz -m fails if there is some debug info but none if it is big enough
+#   to be shared from the the common file $(1).debug.dwz:
+# dwz: $(1).debug.dwz: .debug_info section not present
+#--
+ifeq "$(DWZ)" "YES"
+	dwz_strip = \
+		eu-strip --remove-comment -f "$(1).debug" "$(1)" \
+		&& cp "$(1).debug" "$(1).debug.dup" \
+		&& (dwz -m "$(1).debug.dwz" -M $$(basename "$(1).debug.dwz") "$(1).debug" "$(1).debug.dup" \
+		|| dwz "$(1).debug") \
+		&& /usr/lib/rpm/sepdebugcrcfix . "$$(realpath --relative-to=$$PWD "$(1)")"
+else
+	dwz_strip =
+endif
+
 #--
 # Windows specific options
 #--
@@ -490,6 +515,7 @@
 ifeq "$(DYLIB_ONLY)" ""
 $(EXE) : $(OBJECTS) $(DYLIB_FILENAME)
 	$(LD) $(OBJECTS) -L. -l$(DYLIB_NAME) $(LDFLAGS) -o "$(EXE)"
+	$(call dwz_strip,$(EXE))
 ifneq "$(CODESIGN)" ""
 	$(CODESIGN) -s - "$(EXE)"
 endif
@@ -499,6 +525,7 @@
 else
 $(EXE) : $(OBJECTS)
 	$(LD) $(OBJECTS) $(LDFLAGS) -o "$(EXE)"
+	$(call dwz_strip,$(EXE))
 ifneq "$(CODESIGN)" ""
 	$(CODESIGN) -s - "$(EXE)"
 endif

[Lldb-commits] [PATCH] D40475: DWZ 05/06: DWZ test mode

2021-02-07 Thread Jan Kratochvil via Phabricator via lldb-commits
jankratochvil abandoned this revision.
jankratochvil added a comment.

Replaced by D96241 .


Repository:
  rLLDB LLDB

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D40475/new/

https://reviews.llvm.org/D40475

___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D96242: [lldb] DWZ 07/08: New testcases

2021-02-07 Thread Jan Kratochvil via Phabricator via lldb-commits
jankratochvil created this revision.
jankratochvil added reviewers: labath, clayborg.
jankratochvil added a project: LLDB.
Herald added subscribers: JDevlieghere, mgorny.
jankratochvil requested review of this revision.

All DWZ patches are also applied at: `git clone -b dwz 
git://git.jankratochvil.net/lldb`
There is a copy: `git clone -b dwz 
https://github.com/jankratochvil/llvm-project`


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D96242

Files:
  lldb/test/Shell/SymbolFile/DWARF/dump-debug-types.cpp
  lldb/unittests/SymbolFile/CMakeLists.txt
  lldb/unittests/SymbolFile/DWZ/CMakeLists.txt
  lldb/unittests/SymbolFile/DWZ/Inputs/dwztest.c
  lldb/unittests/SymbolFile/DWZ/Inputs/dwztest.debug
  lldb/unittests/SymbolFile/DWZ/Inputs/dwztest.debug.dwz
  lldb/unittests/SymbolFile/DWZ/Inputs/dwztest.out
  lldb/unittests/SymbolFile/DWZ/SymbolFileDWZTests.cpp

Index: lldb/unittests/SymbolFile/DWZ/SymbolFileDWZTests.cpp
===
--- /dev/null
+++ lldb/unittests/SymbolFile/DWZ/SymbolFileDWZTests.cpp
@@ -0,0 +1,88 @@
+//===-- 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/ObjectFile/ELF/ObjectFileELF.h"
+#include "Plugins/SymbolFile/DWARF/SymbolFileDWARF.h"
+#include "Plugins/SymbolVendor/ELF/SymbolVendorELF.h"
+#include "Plugins/TypeSystem/Clang/TypeSystemClang.h"
+#include "lldb/Core/Module.h"
+#include "lldb/Host/HostInfo.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
+
+FileSystem::Initialize();
+HostInfo::Initialize();
+SymbolFileDWARF::Initialize();
+TypeSystemClang::Initialize();
+ObjectFileELF::Initialize();
+SymbolVendorELF::Initialize();
+
+m_dwztest_out = GetInputFilePath("dwztest.out");
+  }
+
+  void TearDown() override {
+SymbolVendorELF::Terminate();
+ObjectFileELF::Terminate();
+TypeSystemClang::Terminate();
+SymbolFileDWARF::Terminate();
+HostInfo::Terminate();
+FileSystem::Terminate();
+
+#if defined(_MSC_VER)
+::CoUninitialize();
+#endif
+  }
+
+protected:
+  std::string m_dwztest_out;
+};
+
+TEST_F(SymbolFileDWZTests, TestSimpleClassTypes) {
+  FileSpec fspec(m_dwztest_out);
+  ArchSpec aspec("x86_64-pc-linux");
+  lldb::ModuleSP module = std::make_shared(fspec, aspec);
+
+  SymbolFile *symfile = module->GetSymbolFile();
+  EXPECT_NE(nullptr, symfile);
+  EXPECT_EQ(symfile->GetPluginName(), SymbolFileDWARF::GetPluginNameStatic());
+  SymbolContext sc;
+  llvm::DenseSet searched_files;
+  TypeMap results;
+  symfile->FindTypes(ConstString("StructMovedToDWZCommonFile"),
+ CompilerDeclContext(), 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(TypeSystemClang::IsClassType(compiler_type.GetOpaqueQualType()));
+}
Index: lldb/unittests/SymbolFile/DWZ/Inputs/dwztest.c
===
--- /dev/null
+++ lldb/unittests/SymbolFile/DWZ/Inputs/dwztest.c
@@ -0,0 +1,11 @@
+// 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: lldb/unittests/SymbolFile/DWZ/CMakeLists.txt
===
--- /dev/null
+++ lldb/unittests/SymbolFile/DWZ/CMakeLists.txt
@@ -0,0 +1,21 @@
+add_lldb_unittest(SymbolFileDWZTests
+  SymbolFileDWZTests.cpp
+
+  LINK_LIBS
+lldbCore
+lldbHost
+lldbSymbol
+lldbPluginSymbolFileDWARF
+

[Lldb-commits] [PATCH] D96243: [lldb] DWZ 08/08: Fix symlinked /usr/lib/debug/.build-id/**.debug files

2021-02-07 Thread Jan Kratochvil via Phabricator via lldb-commits
jankratochvil created this revision.
jankratochvil added reviewers: labath, clayborg.
jankratochvil added a project: LLDB.
Herald added a subscriber: JDevlieghere.
jankratochvil requested review of this revision.

LLDB could not find DWZ common files due to their relative symbolic link.

All DWZ patches are also applied at: `git clone -b dwz 
git://git.jankratochvil.net/lldb`
There is a copy: `git clone -b dwz 
https://github.com/jankratochvil/llvm-project`


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D96243

Files:
  lldb/packages/Python/lldbsuite/test/decorators.py
  lldb/packages/Python/lldbsuite/test/linux/buildidsymlink/Makefile
  
lldb/packages/Python/lldbsuite/test/linux/buildidsymlink/TestTargetSymbolsBuildidSymlink.py
  lldb/packages/Python/lldbsuite/test/linux/buildidsymlink/main.c
  lldb/source/Symbol/LocateSymbolFile.cpp

Index: lldb/source/Symbol/LocateSymbolFile.cpp
===
--- lldb/source/Symbol/LocateSymbolFile.cpp
+++ lldb/source/Symbol/LocateSymbolFile.cpp
@@ -350,6 +350,10 @@
   if (llvm::sys::fs::equivalent(file_spec.GetPath(),
 module_file_spec.GetPath()))
 continue;
+  if (FileSystem::Instance()
+  .ResolveSymbolicLink(file_spec, file_spec)
+  .Fail())
+continue;
 
   if (FileSystem::Instance().Exists(file_spec)) {
 lldb_private::ModuleSpecList specs;
Index: lldb/packages/Python/lldbsuite/test/linux/buildidsymlink/main.c
===
--- /dev/null
+++ lldb/packages/Python/lldbsuite/test/linux/buildidsymlink/main.c
@@ -0,0 +1,4 @@
+struct s {
+  int i1, i2, i3, i4, i5, i6, i7, i8, i9;
+} v;
+int main() { return 0; }
Index: lldb/packages/Python/lldbsuite/test/linux/buildidsymlink/TestTargetSymbolsBuildidSymlink.py
===
--- /dev/null
+++ lldb/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()
+exe = self.getBuildArtifact("stripped.out")
+
+lldbutil.run_to_name_breakpoint(self, "main", exe_name = exe)
Index: lldb/packages/Python/lldbsuite/test/linux/buildidsymlink/Makefile
===
--- /dev/null
+++ lldb/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
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D43512: DWZ 06/06: Fix for symlinked .build-id/**.debug files

2021-02-07 Thread Jan Kratochvil via Phabricator via lldb-commits
jankratochvil abandoned this revision.
jankratochvil added a comment.
Herald added subscribers: JDevlieghere, pengfei.

Replaced by D96243 .


Repository:
  rLLDB LLDB

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D43512/new/

https://reviews.llvm.org/D43512

___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits