[Lldb-commits] [lldb] Improve performance of .debug_names lookups when DW_IDX_parent attributes are used (PR #91808)
ayermolo wrote: What is "nameless index entry"? I don't quite understand from the spec. https://github.com/llvm/llvm-project/pull/91808 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] Improve performance of .debug_names lookups when DW_IDX_parent attributes are used (PR #91808)
ayermolo wrote: Using example above, with a fix by @dwblaikie I see: ``` Hash: 0xE0CDC6A2 String: 0x0018 "InnerState" Entry @ 0x10b { Abbrev: 0x3 Tag: DW_TAG_class_type DW_IDX_type_unit: 0x01 DW_IDX_die_offset: 0x0030 } ``` Since clang no longer emits entry for: ``` 0x0057: DW_TAG_structure_type DW_AT_declaration (true) DW_AT_signature (0xe742f49eeadc2244) ``` Is this the right behavior? Current BOLT behavior is to skip that DIE and reference it's parent: ``` Hash: 0xE0CDC6A2 String: 0x0018 "InnerState" Entry @ 0x109 { Abbrev: 0x3 Tag: DW_TAG_class_type DW_IDX_type_unit: 0x01 DW_IDX_die_offset: 0x0030 DW_IDX_parent: Entry @ 0x147 } Entry @ 0x147 { Abbrev: 0x7 Tag: DW_TAG_namespace DW_IDX_type_unit: 0x01 DW_IDX_die_offset: 0x0025 DW_IDX_parent: Entry @ 0x126 } ``` ``` 0x0055: DW_TAG_namespace DW_AT_name ("B") 0x0057: DW_TAG_structure_type DW_AT_declaration (true) DW_AT_signature (0xe742f49eeadc2244) 0x0060: DW_TAG_class_type DW_AT_calling_convention (DW_CC_pass_by_value) DW_AT_name ("InnerState") DW_AT_byte_size (0x01) DW_AT_decl_file ("/main.cpp") DW_AT_decl_line (1) ``` https://github.com/llvm/llvm-project/pull/91808 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] Improve performance of .debug_names lookups when DW_IDX_parent attributes are used (PR #91808)
ayermolo wrote: > > Using example above, with a fix by @dwblaikie > > I see: > > ``` > > Hash: 0xE0CDC6A2 > > String: 0x0018 "InnerState" > > Entry @ 0x10b { > > Abbrev: 0x3 > > Tag: DW_TAG_class_type > > DW_IDX_type_unit: 0x01 > > DW_IDX_die_offset: 0x0030 > > } > > ``` > > > > > > > > > > > > > > > > > > > > > > > > Since clang no longer emits entry for: > > ``` > > 0x0057: DW_TAG_structure_type > > DW_AT_declaration (true) > > DW_AT_signature (0xe742f49eeadc2244) > > ``` > > > > > > > > > > > > > > > > > > > > > > > > Is this the right behavior? > > I would say "yes", because the spec is pretty explicit about excluding > DW_AT_declaration entries. > > I can see a case being made that DW_AT_signature should be treated the same > way as DW_AT_specification and DW_AT_abstract_origin (i.e., transparently), > but that's definitely not what the spec says right now. > > > Current BOLT behavior is to skip that DIE and reference it's parent: > > ``` > > Hash: 0xE0CDC6A2 > > String: 0x0018 "InnerState" > > Entry @ 0x109 { > > Abbrev: 0x3 > > Tag: DW_TAG_class_type > > DW_IDX_type_unit: 0x01 > > DW_IDX_die_offset: 0x0030 > > DW_IDX_parent: Entry @ 0x147 > > } > > Entry @ 0x147 { > > Abbrev: 0x7 > > Tag: DW_TAG_namespace > > DW_IDX_type_unit: 0x01 > > DW_IDX_die_offset: 0x0025 > > DW_IDX_parent: Entry @ 0x126 > > } > > ``` > > > > > > > > > > > > > > > > > > > > > > > > ``` > > 0x0055: DW_TAG_namespace > > DW_AT_name ("B") > > > > 0x0057: DW_TAG_structure_type > > DW_AT_declaration (true) > > DW_AT_signature (0xe742f49eeadc2244) > > > > 0x0060: DW_TAG_class_type > > DW_AT_calling_convention (DW_CC_pass_by_value) > > DW_AT_name ("InnerState") > > DW_AT_byte_size (0x01) > > DW_AT_decl_file ("/main.cpp") > > DW_AT_decl_line (1) > > ``` > > > > > > > > > > > > > > > > > > > > > > > > It doesn't emit entry for this because there is no name attribute > > ``` > > 0x0057: DW_TAG_structure_type > > DW_AT_declaration (true) > > DW_AT_signature (0xe742f49eeadc2244) > > ``` > > This gets a bit fuzzy, I think. The spec appears to allow this behavior (_In > such a case, a parent attribute may point to a nameless index entry (...), or > it may point to the **nearest ancestor that does have an index entry**._), > but I don't think this is particularly useful. I think it would be better to > have the parent point to the definition in the type unit (streching the > meaning of "parent" in the spec), or use one of those nameless entries to > point to the physical (declaration) parent) > > (IANAL YMMV) For "parent point to the definition in the type unit". That definition will be in a different type unit, correct? Is that allowed? For one entry DW_IDX_type_unit will have one index, and it's parent will have another index. There is also DWP scenario. Where we don't know which TU will be picked. So chain might be pointing to "discarded" TU from a different CU. So in this particular case what would the nameless entry look like? https://github.com/llvm/llvm-project/pull/91808 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] Improve performance of .debug_names lookups when DW_IDX_parent attributes are used (PR #91808)
ayermolo wrote: > > Since clang no longer emits entry for: > > But what does the `debug_info` section look like? In particular, what is the > _parent_ of the class DIE? If the parent of `InnerState` is not some kind of > entry for `State` (either a declaration or a definition), IMO Clang is > generating incorrect information for the type. What caused Clang to stop > emitting these entries? > > > This gets a bit fuzzy, I think. The spec appears to allow this behavior > > (_In such a case, a parent attribute may point to a nameless index entry > > (...), or it may point to the **nearest ancestor that does have an index > > entry**._), but I don't think this is particularly useful. I think it would > > be better to have the parent point to the definition in the type unit > > (streching the meaning of "parent" in the spec), or use one of those > > nameless entries to point to the physical (declaration) parent) > > (IANAL YMMV) > > We can discuss this, but I think the point is going to be moot given what I > mentioned above. The debug_names section is reflecting the state of > `debug_info`. If the `debug_info` is saying that `State` is not a parent of > `InnerState`, the `debug_names` section is correct in the literal sense, but > will produce incorrect results for the query: "find A::B::State::InnerState". > > In the case where the declaration is there, debug_names will have correct > info for `InnerState`: it will just say the parent is not indexed and things > work out just fine. > > > have the parent point to the definition in the type unit (streching the > > meaning of "parent" in the spec), > > Why do you say this is stretching the meaning of parent? This looks fine to > me, but it seems impossible to emit such debug_names section if the compiler > is no longer emitting the declaration with the type signature. (we'd need to > check if the emitter code has some way of finding the definition, but also > how could it possibly know there is a type between any two Parent-Child > nodes? It really feels like we can't just elide the definition). For clang I used example here with TOT clang. Which included this change: https://github.com/llvm/llvm-project/commit/bd5c6367bd79c01665ff8ab9848afbf5b1249ce6 ``` namespace A { namespace B { struct State { class InnerState{}; }; } } A::B::State::InnerState get_state() { return A::B::State::InnerState(); } int main() { return 0; } ``` clang++ main.cpp -fuse-ld=lld -g2 -O0 -fdebug-types-section -gpubnames -o main.exe https://github.com/llvm/llvm-project/pull/91808 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] Improve performance of .debug_names lookups when DW_IDX_parent attributes are used (PR #91808)
ayermolo wrote: OK, thanks for detailed explanation. Will re-read few more time to fully process it. :) I'll change BOLT behavior to reflect the new clang behavior. If there is a forward delcaration (skeleton die), the parent chain won't skip it, but instead won't emit parent for it's children. https://github.com/llvm/llvm-project/pull/91808 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] Improve performance of .debug_names lookups when DW_IDX_parent attributes are used (PR #91808)
ayermolo wrote: I have a follow up question. For case talked about here earlier: "namespace A { namespace B { struct State { class InnerState{}; }; } } A::B::State::InnerState get_state() { return A::B::State::InnerState(); }" After David fix clang generates: ``` Name 3 { Hash: 0xE0CDC6A2 String: 0x0018 "InnerState" Entry @ 0x10b { Abbrev: 0x3 Tag: DW_TAG_class_type DW_IDX_type_unit: 0x01 DW_IDX_die_offset: 0x0030 } } ``` Would it affect LLDB negatively if BOLT generates: ``` Name 3 { Hash: 0xE0CDC6A2 String: 0x0018 "InnerState" Entry @ 0x109 { Abbrev: 0x3 Tag: DW_TAG_class_type DW_IDX_type_unit: 0x01 DW_IDX_die_offset: 0x0030 DW_IDX_parent: } } ``` So with DW_IDX_parent: https://github.com/llvm/llvm-project/pull/91808 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] Improve performance of .debug_names lookups when DW_IDX_parent attributes are used (PR #91808)
ayermolo wrote: > > I have a follow up question. > > It sounds like you've answered it yourself. :) > > With this kind of debug info, lldb would think this refers to a global entity > and return it for queries like `::InnerState`. Without that entry, lldb will > (correctly) look up the context in the DIE tree, and compare it that way. Yes, although it wasn't clear to me how lldb would handle it. Thanks for elaborating. :) https://github.com/llvm/llvm-project/pull/91808 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] Improve performance of .debug_names lookups when DW_IDX_parent attributes are used (PR #91808)
ayermolo wrote: I have another question. For the same example. I see: ``` Name 4 { Hash: 0x2F94396D String: 0x0049 "_Z9get_statev" Entry @ 0x112 { Abbrev: 0x2 Tag: DW_TAG_subprogram DW_IDX_die_offset: 0x0023 DW_IDX_parent: } ... Name 8 { Hash: 0x2B607 String: 0x0041 "B" Entry @ 0x13b { Abbrev: 0x7 Tag: DW_TAG_namespace DW_IDX_type_unit: 0x00 DW_IDX_die_offset: 0x0025 DW_IDX_parent: Entry @ 0x112 } ``` This seems like a bug no? Looks like it's confusing ``` 0x0023: DW_TAG_namespace DW_AT_name ("A") ``` In TU 0 With Subprogram at the same (relative offset) in the CU ``` 0x006a: Compile Unit: length = 0x005c, format = DWARF32, version = 0x0005, unit_type = DW_UT_compile, abbr_offset = 0x, addr_size = 0x08 (next unit at 0x00ca) ... 0x008d: DW_TAG_subprogram ``` I think it should be pointing to: ``` String: 0x0023 "A" Entry @ 0x11e { Abbrev: 0x4 Tag: DW_TAG_namespace DW_IDX_type_unit: 0x00 DW_IDX_die_offset: 0x0023 DW_IDX_parent: } ``` https://github.com/llvm/llvm-project/pull/91808 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] Improve performance of .debug_names lookups when DW_IDX_parent attributes are used (PR #91808)
ayermolo wrote: Still would be nice to have a small repro to make sure clang, and BOLT, now does the right thing. https://github.com/llvm/llvm-project/pull/91808 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] Improve performance of .debug_names lookups when DW_IDX_parent attributes are used (PR #91808)
ayermolo wrote: > One easy question would be: do you/your users use -fdebug-types-section? If > so, that'd probably explain what you were seeing & you could add some test > coverage for that wherever you like (in lldb, presumably, maybe in bolt too). > But if you/they don't, then it's unclear where this bad index came from - and > it'd be good to know more about the DWARF so we could figure out where else > there might be problems like this... Yes -fdebug-types-section is the default for us. https://github.com/llvm/llvm-project/pull/91808 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] Improve performance of .debug_names lookups when DW_IDX_parent attributes are used (PR #91808)
ayermolo wrote: > > @felipepiovezan I have another question. For the same example. I see: > > You are right. The fact that they have the same relative offset tells me that > some part of the code is failing to account for TUs. I just checked the > printing code in the hope that it was a mistake while dumping, but it doesn't > seem to be... yeah not print tools, at assembly it points to wrong thing. :( Do you think you would be able to fix? :D https://github.com/llvm/llvm-project/pull/91808 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [llvm] Add support for using foreign type units in .debug_names. (PR #87740)
@@ -657,6 +657,42 @@ std::optional DWARFDebugNames::Entry::getLocalTUOffset() const { return NameIdx->getLocalTUOffset(*Index); } +std::optional +DWARFDebugNames::Entry::getForeignTUTypeSignature() const { + std::optional Index = getLocalTUIndex(); + const uint32_t NumLocalTUs = NameIdx->getLocalTUCount(); + if (!Index || *Index < NumLocalTUs) +return std::nullopt; // Invalid TU index or TU index is for a local TU + // The foreign TU index is the TU index minus the number of local TUs. + const uint64_t ForeignTUIndex = *Index - NumLocalTUs; + if (ForeignTUIndex >= NameIdx->getForeignTUCount()) +return std::nullopt; // Invalid foreign TU index. + return NameIdx->getForeignTUSignature(ForeignTUIndex); +} + +std::optional +DWARFDebugNames::Entry::getForeignTUSkeletonCUOffset() const { + // Must have a DW_IDX_type_unit and it must be a foreign type unit. + if (!getForeignTUTypeSignature()) ayermolo wrote: I think according to spec if there is only one TU DW_IDX_type_unit is not needed. Just like if there is only one CU. https://github.com/llvm/llvm-project/pull/87740 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [llvm] Add support for using foreign type units in .debug_names. (PR #87740)
@@ -657,6 +657,42 @@ std::optional DWARFDebugNames::Entry::getLocalTUOffset() const { return NameIdx->getLocalTUOffset(*Index); } +std::optional +DWARFDebugNames::Entry::getForeignTUTypeSignature() const { + std::optional Index = getLocalTUIndex(); + const uint32_t NumLocalTUs = NameIdx->getLocalTUCount(); + if (!Index || *Index < NumLocalTUs) +return std::nullopt; // Invalid TU index or TU index is for a local TU + // The foreign TU index is the TU index minus the number of local TUs. + const uint64_t ForeignTUIndex = *Index - NumLocalTUs; + if (ForeignTUIndex >= NameIdx->getForeignTUCount()) +return std::nullopt; // Invalid foreign TU index. + return NameIdx->getForeignTUSignature(ForeignTUIndex); +} + +std::optional +DWARFDebugNames::Entry::getForeignTUSkeletonCUOffset() const { + // Must have a DW_IDX_type_unit and it must be a foreign type unit. + if (!getForeignTUTypeSignature()) ayermolo wrote: Sorry wasn't clear. I wasn't saying it will have only TU. I was saying it can have one TU (with a CU), at which point the DW_IDX_type_unit is not necessary. https://github.com/llvm/llvm-project/pull/87740 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [llvm] Add support for using foreign type units in .debug_names. (PR #87740)
@@ -657,6 +657,42 @@ std::optional DWARFDebugNames::Entry::getLocalTUOffset() const { return NameIdx->getLocalTUOffset(*Index); } +std::optional +DWARFDebugNames::Entry::getForeignTUTypeSignature() const { + std::optional Index = getLocalTUIndex(); + const uint32_t NumLocalTUs = NameIdx->getLocalTUCount(); + if (!Index || *Index < NumLocalTUs) +return std::nullopt; // Invalid TU index or TU index is for a local TU + // The foreign TU index is the TU index minus the number of local TUs. + const uint64_t ForeignTUIndex = *Index - NumLocalTUs; + if (ForeignTUIndex >= NameIdx->getForeignTUCount()) +return std::nullopt; // Invalid foreign TU index. + return NameIdx->getForeignTUSignature(ForeignTUIndex); +} + +std::optional +DWARFDebugNames::Entry::getForeignTUSkeletonCUOffset() const { + // Must have a DW_IDX_type_unit and it must be a foreign type unit. + if (!getForeignTUTypeSignature()) ayermolo wrote: I guess I miss understood "Must have a DW_IDX_type_unit". I thought you meant that an entry for foreign type unit must have DW_IDX_type_unit attribute. https://github.com/llvm/llvm-project/pull/87740 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [llvm] Add support for using foreign type units in .debug_names. (PR #87740)
ayermolo wrote: > Most of the patch is very clean, but I'm bothered by the > `getForeignTUSkeletonCUOffset` function, how it opens up with a mostly > redundant (the callers checks this already) call to > `getForeignTUTypeSignature`, and then proceeds with a reimplementation of > `getCUOffset` (sans the type unit check). I think we could design a better > set of APIs for this, but I'm not sure what those is, because I'm unclear of > the meaning of various combinations of DW_IDX unit entries. > > What the new function (I think) essentially does is "give me the CU > associated with this entry even if the entry does not describe a DIE in this > CU" (because `DW_IDX_die_offset` is relative to a type unit)". I think this > API would make sense, even without needing to talk about type units. However, > is it actually implementable? For single-CU indexes, that's fine, because we > can kind of assume all entries are related to that CU. But what about > multi-CU indexes? The only way to determine the CU there is to have an > explicit attribute. Are we saying that each entry in a multi-CU index must > have a DW_IDX_compile_unit (in addition to a DW_IDX_type_unit)? > > If the answer is yes, then this function can be implemented, but then I think > the current implementation of `getCUOffset` (which I interpret as "give me > the CU offset **IF** this entry is relative to that CU") doesn't make sense > -- because it treats entries with an explicit `DW_IDX_compile_unit` different > from an implicit/missing `DW_IDX_compile_unit`. And in this world, we assume > that `DW_IDX_type_unit` takes precedence over `DW_IDX_compile_unit` -- if > both are present then `DW_IDX_die_offset` is relative to the former. And I'm > not sure if we would actually want to take up space by putting both values > into the index. Looking at existing producers would be interesting, but I'm > not sure if there are any (lld does not merge type unit indexes right now, > possibly for this very reason). Maybe one could produce something with LTO? > > OTOH, if the answer is no, then the function isn't implementable in the > generic case. That doesn't mean you can't implement this feature -- which is > useful for guarding against ODR violations (exacerbated by llvm's > nonconforming type signature computation algorithm...). However, I think it > could be implemented in a much simpler way. For example, lldb could just > check if it's looking at a single-CU index, and get the CU offset that way. > No extra llvm APIs would be needed. BOLT does as I mentioned in: https://github.com/llvm/llvm-project/pull/87740#issuecomment-2060023287 https://github.com/llvm/llvm-project/pull/87740 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [llvm] [lldb] Add support for parsing type unit entries in .debug_names. (PR #72952)
ayermolo wrote: What happens when Linker tombstones the tu local entry to -1, or will that be in a separate patch after LLD changes land? https://github.com/llvm/llvm-project/pull/72952 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] Allow lldb to load .dwp files with large .debug_info or .debug_types. (PR #73736)
https://github.com/ayermolo approved this pull request. Thanks for fixing places I missed. https://github.com/llvm/llvm-project/pull/73736 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] Fix DWARF locations when we have large .dwp files. (PR #87164)
https://github.com/ayermolo approved this pull request. thx https://github.com/llvm/llvm-project/pull/87164 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [llvm] Add support for using foreign type units in .debug_names. (PR #87740)
@@ -273,6 +301,44 @@ void DebugNamesDWARFIndex::GetFullyQualifiedType( if (!isType(entry.tag())) continue; + +DWARFTypeUnit *foreign_tu = GetForeignTypeUnit(entry); +if (foreign_tu) { + // If this entry represents a foreign type unit, we need to verify that + // the type unit that ended up in the final .dwp file is the right type + // unit. Type units have signatures which are the same across multiple + // .dwo files, but only one of those type units will end up in the .dwp + // file. The contents of type units for the same type can be different + // in different .dwo file, which means the DIE offsets might not be the + // same between two different type units. So we need to determine if this + // accelerator table matches the type unit in the .dwp file. If it doesn't + // match, then we need to ignore this accelerator table entry as the type + // unit that is in the .dwp file will have its own index. + const llvm::DWARFDebugNames::NameIndex *name_index = entry.getNameIndex(); + if (name_index == nullptr) +continue; + // In order to determine if the type unit that ended up in a .dwp file + // is valid, we need to grab the type unit and check the attribute on the + // type unit matches the .dwo file. For this to happen we rely on each + // .dwo file having its own .debug_names table with a single compile unit + // and multiple type units. This is the only way we can tell if a type + // unit came from a specific .dwo file. ayermolo wrote: > I think our conclusion from previous discussions was to put > `DW_IDX_compile_unit`, in addition to the `DW_IDX_type_unit` on the entries > in the .debug_names table - and add the CU column to the .debug_tu_index in > the dwp file, to match these things up? We went with adding comp_dir/name to type unit unit die: https://discourse.llvm.org/t/debuginfo-dwarfv5-lld-debug-names-with-fdebug-type-sections/73445/29?u=ayermolo A bit of a shortcut so we don't have to deal with non-standar dwp. https://github.com/llvm/llvm-project/pull/87740 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [llvm] Add support for using foreign type units in .debug_names. (PR #87740)
@@ -273,6 +301,44 @@ void DebugNamesDWARFIndex::GetFullyQualifiedType( if (!isType(entry.tag())) continue; + +DWARFTypeUnit *foreign_tu = GetForeignTypeUnit(entry); +if (foreign_tu) { + // If this entry represents a foreign type unit, we need to verify that + // the type unit that ended up in the final .dwp file is the right type + // unit. Type units have signatures which are the same across multiple + // .dwo files, but only one of those type units will end up in the .dwp + // file. The contents of type units for the same type can be different + // in different .dwo file, which means the DIE offsets might not be the + // same between two different type units. So we need to determine if this + // accelerator table matches the type unit in the .dwp file. If it doesn't + // match, then we need to ignore this accelerator table entry as the type + // unit that is in the .dwp file will have its own index. + const llvm::DWARFDebugNames::NameIndex *name_index = entry.getNameIndex(); + if (name_index == nullptr) +continue; + // In order to determine if the type unit that ended up in a .dwp file + // is valid, we need to grab the type unit and check the attribute on the + // type unit matches the .dwo file. For this to happen we rely on each + // .dwo file having its own .debug_names table with a single compile unit + // and multiple type units. This is the only way we can tell if a type + // unit came from a specific .dwo file. ayermolo wrote: > Sounds like this wouldn't work for a merged `.debug_names` table? Could you > leave a FIXME/do you plan to fix this? Oh, it also wouldn't work for any kind > of LTO which could have multiple CUs in a single object file/dwo file. > > (FYI @cmtice ) Does "multiple cus" in .o/dwo actually happen? >From spec perspective I don't understand how this will work. Skeleton CU >points to .o/dwo which then has multiple cus? What does it mean? https://github.com/llvm/llvm-project/pull/87740 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [llvm] Add support for using foreign type units in .debug_names. (PR #87740)
ayermolo wrote: @clayborg Figured I reply here to your comment: https://github.com/llvm/llvm-project/pull/88092#issuecomment-2059961175 This was regarding merging .debug_names in linker (although types are not implemented yet there), but FYI BOLT output is similar. All the CUs are in one module. Entry for type unit will have two indexes. One for CU to which it belongs and another for type unit. Which can either be local or foreign. example: ``` Compilation Unit offsets [ CU[0]: 0x CU[1]: 0x0029 ] Foreign Type Unit signatures [ ForeignTU[0]: 0x49dc260088be7e56 ForeignTU[1]: 0x104ec427d2ebea6f ForeignTU[2]: 0xca1e65a66d92b970 ForeignTU[3]: 0x104ec427d2ebea6f ] ... Bucket 1 [ Name 1 { Hash: 0x7C96E4DB String: 0x0027 "Foo2" Entry @ 0x117 { Abbrev: 0x1 Tag: DW_TAG_structure_type DW_IDX_type_unit: 0x00 DW_IDX_compile_unit: 0x00 DW_IDX_die_offset: 0x0021 DW_IDX_parent: } } ``` https://github.com/llvm/llvm-project/pull/87740 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [clang] [lldb] Revert "NFC: Make clang resource headers an interface library (#88317)" (PR #89266)
ayermolo wrote: Thanks. It's failing internally in our automatic multi stage build. Trying to dig into it as part of my oncall. :) https://github.com/llvm/llvm-project/pull/89266 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [clang] [lldb] Revert "NFC: Make clang resource headers an interface library (#88317)" (PR #89266)
ayermolo wrote: Fixed our internal foobar yesterday. Can close this. https://github.com/llvm/llvm-project/pull/89266 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lld] [mlir] [flang] [clang-tools-extra] [libunwind] [clang] [openmp] [libcxx] [compiler-rt] [llvm] [libc] [pstl] [ELF] Don't resolve relocations referencing SHN_ABS to tombstone
ayermolo wrote: Hmm, interesting. Thanks for the fix. https://github.com/llvm/llvm-project/pull/79238 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] Add more ways to find the .dwp file. (PR #81067)
ayermolo wrote: Will this now work with .dwp files not having UUID? https://github.com/llvm/llvm-project/pull/81067 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] Add more ways to find the .dwp file. (PR #81067)
ayermolo wrote: > > Will this now work with .dwp files not having UUID? > > No. If binairies have UUIDs (GNU build IDs), they need to match right now. > That is larger fix that involves adding a "enum UUIDFlavor" to the UUIDs so > we can ensure we aren't comparing two different things. > > What Alexander is talking about is if we have a GNU build ID in ``, the > `.debug` file will have the same UUID, but llvm-dwp currently doesn't > copy the GNU build ID over into the `.dwp` file. This causes LLDB to not > allow the .dwp file to be loaded. The problem is if the .dwp file doesn't > have a UUID, it will make one up by calculating a CRC of the file itself, and > then we will compare a GNU build ID from `` to the CRC calculated by the > `.dwp` file and they won't match. > > @dwblaikie do you know how accurate the DWO ID is? Can we avoid relying on > matching up the UUID on the .dwp file and solely rely on allowing it to be > loaded and rely on the DWO IDs matching between the skeleton unit and the > .dwo unit? If so, there is an easy fix I can make to this patch to solve that > problem. Not sure I follow. For .dwo files path is described in Skeleton CU: DW_AT_comp_dir/DW_AT_dwo_name. The DWP file can have multiple CUs with different DWO IDs. https://github.com/llvm/llvm-project/pull/81067 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Add more ways to find the .dwp file. (PR #81067)
ayermolo wrote: Just my 2 cents as a "random dude who works on DWARF". The interoperability of various gnu extensions and DWARF spec is not well defined. Which leads to situations like this. If binary is A then DWP is A.dwp no direct link between binary and dwp file. If binary has gnulink than it has a section that points to an elf file with rest of the debuginfo. Most people name it as binary.debuglink. If binary has split dwarf and gnulink not well defined I think. It would be great if tools took an option away from the user that "create" debug information or at least restricted so that all of this was standardized, but currently they are not. Even if we change them there are still legacy builds that is a free for all. I think we are already at a "people are confused" point, and DWARF consumer (LLDB) being more permissive doesn't really contribute to it. Because people who use LLDB by and large are not the people who are responsible for build systems that produce debug information. Users of LLDB just want things to work, and have no clue what split-dwarf is or gnulink. They download a coredump launch lldb and then wonder why it is not working. https://github.com/llvm/llvm-project/pull/81067 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] 130167e - [LLDB] Handle DIE with DW_AT_low_pc and empty ranges
Author: Alexander Yermolovich Date: 2022-06-22T10:54:25-07:00 New Revision: 130167ed1effa36aa56c83c4293e732e5163d993 URL: https://github.com/llvm/llvm-project/commit/130167ed1effa36aa56c83c4293e732e5163d993 DIFF: https://github.com/llvm/llvm-project/commit/130167ed1effa36aa56c83c4293e732e5163d993.diff LOG: [LLDB] Handle DIE with DW_AT_low_pc and empty ranges The case comes out of how BOLT handles transformation of DW_AT_low_pc/DW_AT_high_pc into DW_AT_low_pc/DW_AT_high_pc with latter being 0. Reviewed By: clayborg Differential Revision: https://reviews.llvm.org/D127889 Added: lldb/test/Shell/Commands/Inputs/dwarf4-low-pc-ranges-inlining.s lldb/test/Shell/Commands/Inputs/dwarf5-low-pc-ranges-inlining.s lldb/test/Shell/Commands/dwarf4-low-pc-ranges-inlining.test lldb/test/Shell/Commands/dwarf5-low-pc-ranges-inlining.test Modified: lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp Removed: diff --git a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp index c0bf13e0281d3..7be67f83add3d 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp +++ b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp @@ -1279,6 +1279,8 @@ size_t SymbolFileDWARF::ParseBlocksRecursive( const size_t num_ranges = ranges.GetSize(); for (size_t i = 0; i < num_ranges; ++i) { const DWARFRangeList::Entry &range = ranges.GetEntryRef(i); + if (range.GetByteSize() == 0) +continue; const addr_t range_base = range.GetRangeBase(); if (range_base >= subprogram_low_pc) block->AddRange(Block::Range(range_base - subprogram_low_pc, diff --git a/lldb/test/Shell/Commands/Inputs/dwarf4-low-pc-ranges-inlining.s b/lldb/test/Shell/Commands/Inputs/dwarf4-low-pc-ranges-inlining.s new file mode 100644 index 0..458e26250b429 --- /dev/null +++ b/lldb/test/Shell/Commands/Inputs/dwarf4-low-pc-ranges-inlining.s @@ -0,0 +1,369 @@ + +# Manually modified to have DW_AT_ranges point to end list. +# int helper(int i) { +# return ++i; +# } +# +# int main(int argc, char *argv[]) { +# return helper(argc); +# } + +# Manually modified DW_TAG_inlined_subroutine to have DW_AT_low_pc with value 0, +# and DW_AT_ranges to point to end ranges list. + + .text + .file "main.cpp" + .section.text._Z6helperi,"ax",@progbits + .globl _Z6helperi # -- Begin function _Z6helperi + .p2align4, 0x90 + .type _Z6helperi,@function +_Z6helperi: # @_Z6helperi +.Lfunc_begin0: + .file 1 "/home/test" "main.cpp" + .loc1 1 0 # main.cpp:1:0 + .cfi_startproc +# %bb.0:# %entry + #DEBUG_VALUE: helper:i <- $edi +# kill: def $edi killed $edi def $rdi + .loc1 2 10 prologue_end # main.cpp:2:10 + leal1(%rdi), %eax +.Ltmp0: + #DEBUG_VALUE: helper:i <- $eax + .loc1 2 3 is_stmt 0 # main.cpp:2:3 + retq +.Ltmp1: +.Lfunc_end0: + .size _Z6helperi, .Lfunc_end0-_Z6helperi + .cfi_endproc +# -- End function + .section.text.main,"ax",@progbits + .globl main# -- Begin function main + .p2align4, 0x90 + .type main,@function +main: # @main +.Lfunc_begin1: + .loc1 5 0 is_stmt 1 # main.cpp:5:0 + .cfi_startproc +# %bb.0:# %entry + #DEBUG_VALUE: main:argc <- $edi + #DEBUG_VALUE: main:argv <- $rsi + #DEBUG_VALUE: helper:i <- $edi +# kill: def $edi killed $edi def $rdi + .loc1 2 10 prologue_end # main.cpp:2:10 + leal1(%rdi), %eax +.Ltmp2: + #DEBUG_VALUE: helper:i <- $eax + .loc1 6 3 # main.cpp:6:3 + retq +.Ltmp3: +.Lfunc_end1: + .size main, .Lfunc_end1-main + .cfi_endproc +# -- End function + .section.debug_loc,"",@progbits +.Ldebug_loc0: + .quad -1 + .quad .Lfunc_begin0 # base address + .quad .Lfunc_begin0-.Lfunc_begin0 + .quad .Ltmp0-.Lfunc_begin0 + .short 1 # Loc expr size + .byte 85 # super-register DW_OP_reg5 + .quad .Ltmp0-.Lfunc_begin0 + .quad .Lfunc_end0-.Lfunc_begin0 + .short 1 # Loc expr size + .byte 80 # super-register DW_OP_reg0 + .quad 0 + .quad 0 +.Ldebug_lo
[Lldb-commits] [lldb] e262b8f - [LLDB] Change formatting to use llvm::formatv
Author: Alexander Yermolovich Date: 2023-01-09T11:29:43-08:00 New Revision: e262b8f48af9fdca8380f2f079e50291956aad71 URL: https://github.com/llvm/llvm-project/commit/e262b8f48af9fdca8380f2f079e50291956aad71 DIFF: https://github.com/llvm/llvm-project/commit/e262b8f48af9fdca8380f2f079e50291956aad71.diff LOG: [LLDB] Change formatting to use llvm::formatv In preparation for eanbling 64bit support in LLDB switching to use llvm::formatv instead of format MACROs. Reviewed By: labath, JDevlieghere Differential Revision: https://reviews.llvm.org/D139955 Added: Modified: lldb/include/lldb/Core/Module.h lldb/include/lldb/Utility/Status.h lldb/source/Core/Module.cpp lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp lldb/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp lldb/source/Plugins/SymbolFile/DWARF/DWARFFormValue.cpp lldb/source/Plugins/SymbolFile/DWARF/DWARFIndex.cpp lldb/source/Plugins/SymbolFile/DWARF/DWARFTypeUnit.cpp lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.cpp lldb/source/Plugins/SymbolFile/PDB/PDBASTParser.cpp lldb/source/Symbol/CompileUnit.cpp lldb/source/Symbol/DWARFCallFrameInfo.cpp lldb/source/Target/SectionLoadList.cpp lldb/test/Shell/SymbolFile/DWARF/DW_AT_range-DW_FORM_sec_offset.s lldb/test/Shell/SymbolFile/DWARF/x86/debug_ranges-missing-section.s Removed: diff --git a/lldb/include/lldb/Core/Module.h b/lldb/include/lldb/Core/Module.h index 56c3de1249c9..31f7894178d7 100644 --- a/lldb/include/lldb/Core/Module.h +++ b/lldb/include/lldb/Core/Module.h @@ -825,22 +825,35 @@ class Module : public std::enable_shared_from_this, // architecture, path and object name (if any)). This centralizes code so // that everyone doesn't need to format their error and log messages on their // own and keeps the output a bit more consistent. - void LogMessage(Log *log, const char *format, ...) - __attribute__((format(printf, 3, 4))); + template + void LogMessage(Log *log, const char *format, Args &&...args) { +LogMessage(log, llvm::formatv(format, std::forward(args)...)); + } - void LogMessageVerboseBacktrace(Log *log, const char *format, ...) - __attribute__((format(printf, 3, 4))); + template + void LogMessageVerboseBacktrace(Log *log, const char *format, + Args &&...args) { +LogMessageVerboseBacktrace( +log, llvm::formatv(format, std::forward(args)...)); + } - void ReportWarning(const char *format, ...) - __attribute__((format(printf, 2, 3))); + template + void ReportWarning(const char *format, Args &&...args) { +ReportWarning(llvm::formatv(format, std::forward(args)...)); + } - void ReportError(const char *format, ...) - __attribute__((format(printf, 2, 3))); + template + void ReportError(const char *format, Args &&...args) { +ReportError(llvm::formatv(format, std::forward(args)...)); + } // Only report an error once when the module is first detected to be modified // so we don't spam the console with many messages. - void ReportErrorIfModifyDetected(const char *format, ...) - __attribute__((format(printf, 2, 3))); + template + void ReportErrorIfModifyDetected(const char *format, Args &&...args) { +ReportErrorIfModifyDetected( +llvm::formatv(format, std::forward(args)...)); + } void ReportWarningOptimization(std::optional debugger_id); @@ -1155,6 +1168,13 @@ class Module : public std::enable_shared_from_this, Module(const Module &) = delete; const Module &operator=(const Module &) = delete; + + void LogMessage(Log *log, const llvm::formatv_object_base &payload); + void LogMessageVerboseBacktrace(Log *log, + const llvm::formatv_object_base &payload); + void ReportWarning(const llvm::formatv_object_base &payload); + void ReportError(const llvm::formatv_object_base &payload); + void ReportErrorIfModifyDetected(const llvm::formatv_object_base &payload); }; } // namespace lldb_private diff --git a/lldb/include/lldb/Utility/Status.h b/lldb/include/lldb/Utility/Status.h index bee2b57b6ea9..ac410552438e 100644 --- a/lldb/include/lldb/Utility/Status.h +++ b/lldb/include/lldb/Utility/Status.h @@ -64,6 +64,11 @@ class Status { explicit Status(const char *format, ...) __attribute__((format(printf, 2, 3))); + template + static Status createWithFormat(const char *format, Args &&...args) { +
[Lldb-commits] [lldb] 7fc7934 - [llvm][dwwarf] Change CU/TU index to 64-bit
Author: Alexander Yermolovich Date: 2023-01-11T15:07:11-08:00 New Revision: 7fc79340234f3acd354c52bd8bf2cf44f38fc4be URL: https://github.com/llvm/llvm-project/commit/7fc79340234f3acd354c52bd8bf2cf44f38fc4be DIFF: https://github.com/llvm/llvm-project/commit/7fc79340234f3acd354c52bd8bf2cf44f38fc4be.diff LOG: [llvm][dwwarf] Change CU/TU index to 64-bit Changed contribution data structure to 64 bit. I added the 32bit and 64bit accessors to make it explicit where we use 32bit and where we use 64bit. Also to make sure sure we catch all the cases where this data structure is used. Reviewed By: dblaikie Differential Revision: https://reviews.llvm.org/D139379 Added: Modified: bolt/lib/Core/DebugData.cpp bolt/lib/Rewrite/DWARFRewriter.cpp lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.cpp llvm/include/llvm/DebugInfo/DWARF/DWARFUnit.h llvm/include/llvm/DebugInfo/DWARF/DWARFUnitIndex.h llvm/lib/DWP/DWP.cpp llvm/lib/DebugInfo/DWARF/DWARFUnit.cpp llvm/lib/DebugInfo/DWARF/DWARFUnitIndex.cpp llvm/lib/DebugInfo/DWARF/DWARFVerifier.cpp llvm/test/DebugInfo/X86/debug-cu-index-unknown-section.s llvm/test/DebugInfo/X86/dwp-v2-cu-index.s llvm/test/DebugInfo/X86/dwp-v2-tu-index.s llvm/test/DebugInfo/X86/dwp-v5-cu-index.s llvm/test/DebugInfo/X86/dwp-v5-tu-index.s llvm/test/DebugInfo/dwarfdump-dwp.test llvm/test/tools/llvm-dwp/X86/debug_macro_v5.s llvm/test/tools/llvm-dwp/X86/info-v5.s llvm/test/tools/llvm-dwp/X86/loclists.s llvm/test/tools/llvm-dwp/X86/merge.test llvm/test/tools/llvm-dwp/X86/rnglists.s llvm/test/tools/llvm-dwp/X86/simple.test llvm/test/tools/llvm-dwp/X86/tu_units_v5.s llvm/test/tools/llvm-dwp/X86/unknown-section-id.s Removed: diff --git a/bolt/lib/Core/DebugData.cpp b/bolt/lib/Core/DebugData.cpp index fa5505ad78aa6..2cbd119e69fe2 100644 --- a/bolt/lib/Core/DebugData.cpp +++ b/bolt/lib/Core/DebugData.cpp @@ -1241,8 +1241,8 @@ void DebugAbbrevWriter::addUnitAbbreviations(DWARFUnit &Unit) { const DWARFUnitIndex::Entry::SectionContribution *DWOContrubution = DWOEntry->getContribution(DWARFSectionKind::DW_SECT_ABBREV); - AbbrevContents = AbbrevSectionContents.substr(DWOContrubution->Offset, -DWOContrubution->Length); + AbbrevContents = AbbrevSectionContents.substr( + DWOContrubution->getOffset(), DWOContrubution->getLength()); } else if (!Unit.isDWOUnit()) { const uint64_t StartOffset = Unit.getAbbreviationsOffset(); diff --git a/bolt/lib/Rewrite/DWARFRewriter.cpp b/bolt/lib/Rewrite/DWARFRewriter.cpp index a76d128ea4e60..5b8a28465fd7c 100644 --- a/bolt/lib/Rewrite/DWARFRewriter.cpp +++ b/bolt/lib/Rewrite/DWARFRewriter.cpp @@ -1212,11 +1212,11 @@ updateDebugData(DWARFContext &DWCtx, std::string &Storage, const DWARFUnitIndex::Entry::SectionContribution; auto getSliceData = [&](const DWARFUnitIndex::Entry *DWOEntry, StringRef OutData, DWARFSectionKind Sec, - uint32_t &DWPOffset) -> StringRef { + uint64_t &DWPOffset) -> StringRef { if (DWOEntry) { DWOSectionContribution *DWOContrubution = DWOEntry->getContribution(Sec); - DWPOffset = DWOContrubution->Offset; - OutData = OutData.substr(DWPOffset, DWOContrubution->Length); + DWPOffset = DWOContrubution->getOffset(); + OutData = OutData.substr(DWPOffset, DWOContrubution->getLength()); } return OutData; }; @@ -1227,7 +1227,7 @@ updateDebugData(DWARFContext &DWCtx, std::string &Storage, Streamer.switchSection(SectionIter->second.first); StringRef OutData = SectionContents; - uint32_t DWPOffset = 0; + uint64_t DWPOffset = 0; switch (SectionIter->second.second) { default: { @@ -1310,14 +1310,15 @@ static std::string extractDWOTUFromDWP( // Sorting so it's easy to compare output. // They should be sharing the same Abbrev. llvm::sort(TUContributions, [](const TUEntry &V1, const TUEntry &V2) -> bool { -return V1.second->Offset < V2.second->Offset; +return V1.second->getOffset() < V2.second->getOffset(); }); for (auto &PairEntry : TUContributions) { const DWARFUnitIndex::Entry::SectionContribution *C = PairEntry.second; const uint64_t TUSignature = PairEntry.first; -DWOTUSection.append(Contents.slice(C->Offset, C->Offset + C->Length).str()); -TUContributionsToCU.push_back({TUSignature, C->Length}); +DWOTUSection.append( +Contents.slice(C->getOffset(), C->getOffset() + C->getLength()).str()); +TUContributionsToCU.push_back({TUSignature, C->getLength32()}); } return DWOTUSection; } @@ -1357,11 +1358,12 @@ static void extractTypesFromDWPDWARF5( llvm::sort(TUContributions, [](const DWARFUn
[Lldb-commits] [lldb] 4e7da80 - [fix] Change formatting to use llvm::formatv Summary:
Author: Alexander Yermolovich Date: 2023-01-12T11:18:29-08:00 New Revision: 4e7da8000e2771907609c3fe149dd4b96cfe0b08 URL: https://github.com/llvm/llvm-project/commit/4e7da8000e2771907609c3fe149dd4b96cfe0b08 DIFF: https://github.com/llvm/llvm-project/commit/4e7da8000e2771907609c3fe149dd4b96cfe0b08.diff LOG: [fix] Change formatting to use llvm::formatv Summary: Missed one formating that was reversed. Reviewed By: hoy, zhuhan0 Differential Revision: https://reviews.llvm.org/D141624 Added: Modified: lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp Removed: diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp index 9f042e9893bac..b50c974f9b89f 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp +++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp @@ -677,7 +677,7 @@ DWARFASTParserClang::ParseTypeModifier(const SymbolContext &sc, if (log) dwarf->GetObjectFile()->GetModule()->LogMessage( log, -"SymbolFileDWARF::ParseType (die = {0:16x}) {1} '{2}' " +"SymbolFileDWARF::ParseType (die = {0:x16}) {1} '{2}' " "is Objective-C 'id' built-in type.", die.GetOffset(), die.GetTagAsCString(), die.GetName()); clang_type = m_ast.GetBasicType(eBasicTypeObjCID); ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] f36fe00 - [LLDB] Enable 64 bit debug/type offset
Author: Alexander Yermolovich Date: 2023-02-13T13:08:01-08:00 New Revision: f36fe009c0fc1d655bfc6168730bedfa1b36e622 URL: https://github.com/llvm/llvm-project/commit/f36fe009c0fc1d655bfc6168730bedfa1b36e622 DIFF: https://github.com/llvm/llvm-project/commit/f36fe009c0fc1d655bfc6168730bedfa1b36e622.diff LOG: [LLDB] Enable 64 bit debug/type offset This came out of from https://discourse.llvm.org/t/dwarf-dwp-4gb-limit/63902 With big binaries we can have .dwp files where .debug_info.dwo section can grow beyond 4GB. We would like to support this in LLVM and in LLDB. The plan is to enable manual parsing of cu/tu index in DWARF library (https://reviews.llvm.org/D137882), and then switch internal index data structure to 64 bit. For the second part is to enable 64bit offset support in LLDB with this patch. Depends on D139955 Reviewed By: labath Differential Revision: https://reviews.llvm.org/D138618 Added: Modified: lldb/include/lldb/Core/dwarf.h lldb/include/lldb/Symbol/DWARFCallFrameInfo.h lldb/source/Plugins/SymbolFile/DWARF/AppleDWARFIndex.cpp lldb/source/Plugins/SymbolFile/DWARF/DIERef.cpp lldb/source/Plugins/SymbolFile/DWARF/DIERef.h lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp lldb/source/Plugins/SymbolFile/DWARF/DWARFBaseDIE.cpp lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.cpp lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.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/NameToDIE.cpp lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.cpp lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.h lldb/test/Shell/SymbolFile/DWARF/DW_AT_range-DW_FORM_sec_offset.s lldb/test/Shell/SymbolFile/DWARF/x86/debug_rnglists-dwo.s lldb/unittests/Expression/DWARFExpressionTest.cpp lldb/unittests/SymbolFile/DWARF/DWARFIndexCachingTest.cpp Removed: diff --git a/lldb/include/lldb/Core/dwarf.h b/lldb/include/lldb/Core/dwarf.h index 60fbdec40beed..af0762ea7b704 100644 --- a/lldb/include/lldb/Core/dwarf.h +++ b/lldb/include/lldb/Core/dwarf.h @@ -30,11 +30,12 @@ typedef uint64_t dw_addr_t; // Dwarf address define that must be big enough for // any addresses in the compile units that get // parsed -typedef uint32_t dw_offset_t; // Dwarf Debug Information Entry offset for any +typedef uint64_t dw_offset_t; // Dwarf Debug Information Entry offset for any // offset into the file /* Constants */ -#define DW_INVALID_OFFSET (~(dw_offset_t)0) +#define DW_DIE_OFFSET_MAX_BITSIZE 40 +#define DW_INVALID_OFFSET (((uint64_t)1u << DW_DIE_OFFSET_MAX_BITSIZE) - 1) #define DW_INVALID_INDEX 0xul // #define DW_ADDR_none 0x0 diff --git a/lldb/include/lldb/Symbol/DWARFCallFrameInfo.h b/lldb/include/lldb/Symbol/DWARFCallFrameInfo.h index ea5c325e11a35..6cc24a02de257 100644 --- a/lldb/include/lldb/Symbol/DWARFCallFrameInfo.h +++ b/lldb/include/lldb/Symbol/DWARFCallFrameInfo.h @@ -128,7 +128,7 @@ class DWARFCallFrameInfo { void GetFDEIndex(); - bool FDEToUnwindPlan(uint32_t offset, Address startaddr, + bool FDEToUnwindPlan(dw_offset_t offset, Address startaddr, UnwindPlan &unwind_plan); const CIE *GetCIE(dw_offset_t cie_offset); @@ -159,7 +159,7 @@ class DWARFCallFrameInfo { Type m_type; CIESP - ParseCIE(const uint32_t cie_offset); + ParseCIE(const dw_offset_t cie_offset); lldb::RegisterKind GetRegisterKind() const { return m_type == EH ? lldb::eRegisterKindEHFrame : lldb::eRegisterKindDWARF; diff --git a/lldb/source/Plugins/SymbolFile/DWARF/AppleDWARFIndex.cpp b/lldb/source/Plugins/SymbolFile/DWARF/AppleDWARFIndex.cpp index f6a49ba6141a7..ccbe1b6961a51 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/AppleDWARFIndex.cpp +++ b/lldb/source/Plugins/SymbolFile/DWARF/AppleDWARFIndex.cpp @@ -80,7 +80,7 @@ void AppleDWARFIndex::GetGlobalVariables( if (!m_apple_names_up) return; - lldbassert(!cu.GetSymbolFileDWARF().GetDwoNum()); + lldbassert(!cu.GetSymbolFileDWARF().GetFileIndex()); const DWARFUnit &non_skeleton_cu = cu.GetNonSkeletonUnit(); DWARFMappedHash::DIEInfoArray hash_data; m_apple_names_up->AppendAllDIEsInRange(non_skeleton_cu.GetOffset(), diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DIERef.cpp b/lldb/source/Plugins/SymbolFile/DWARF/DIERef.cpp index 53e154fd651
[Lldb-commits] [lldb] 620b3d9 - Revert "[LLDB] Enable 64 bit debug/type offset"
Author: Alexander Yermolovich Date: 2023-02-13T14:08:40-08:00 New Revision: 620b3d9ba3343d7bc5bab2340174a20952fcd00f URL: https://github.com/llvm/llvm-project/commit/620b3d9ba3343d7bc5bab2340174a20952fcd00f DIFF: https://github.com/llvm/llvm-project/commit/620b3d9ba3343d7bc5bab2340174a20952fcd00f.diff LOG: Revert "[LLDB] Enable 64 bit debug/type offset" This reverts commit f36fe009c0fc1d655bfc6168730bedfa1b36e622. Added: Modified: lldb/include/lldb/Core/dwarf.h lldb/include/lldb/Symbol/DWARFCallFrameInfo.h lldb/source/Plugins/SymbolFile/DWARF/AppleDWARFIndex.cpp lldb/source/Plugins/SymbolFile/DWARF/DIERef.cpp lldb/source/Plugins/SymbolFile/DWARF/DIERef.h lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp lldb/source/Plugins/SymbolFile/DWARF/DWARFBaseDIE.cpp lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.cpp lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.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/NameToDIE.cpp lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.cpp lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.h lldb/test/Shell/SymbolFile/DWARF/DW_AT_range-DW_FORM_sec_offset.s lldb/test/Shell/SymbolFile/DWARF/x86/debug_rnglists-dwo.s lldb/unittests/Expression/DWARFExpressionTest.cpp lldb/unittests/SymbolFile/DWARF/DWARFIndexCachingTest.cpp Removed: diff --git a/lldb/include/lldb/Core/dwarf.h b/lldb/include/lldb/Core/dwarf.h index af0762ea7b704..60fbdec40beed 100644 --- a/lldb/include/lldb/Core/dwarf.h +++ b/lldb/include/lldb/Core/dwarf.h @@ -30,12 +30,11 @@ typedef uint64_t dw_addr_t; // Dwarf address define that must be big enough for // any addresses in the compile units that get // parsed -typedef uint64_t dw_offset_t; // Dwarf Debug Information Entry offset for any +typedef uint32_t dw_offset_t; // Dwarf Debug Information Entry offset for any // offset into the file /* Constants */ -#define DW_DIE_OFFSET_MAX_BITSIZE 40 -#define DW_INVALID_OFFSET (((uint64_t)1u << DW_DIE_OFFSET_MAX_BITSIZE) - 1) +#define DW_INVALID_OFFSET (~(dw_offset_t)0) #define DW_INVALID_INDEX 0xul // #define DW_ADDR_none 0x0 diff --git a/lldb/include/lldb/Symbol/DWARFCallFrameInfo.h b/lldb/include/lldb/Symbol/DWARFCallFrameInfo.h index 6cc24a02de257..ea5c325e11a35 100644 --- a/lldb/include/lldb/Symbol/DWARFCallFrameInfo.h +++ b/lldb/include/lldb/Symbol/DWARFCallFrameInfo.h @@ -128,7 +128,7 @@ class DWARFCallFrameInfo { void GetFDEIndex(); - bool FDEToUnwindPlan(dw_offset_t offset, Address startaddr, + bool FDEToUnwindPlan(uint32_t offset, Address startaddr, UnwindPlan &unwind_plan); const CIE *GetCIE(dw_offset_t cie_offset); @@ -159,7 +159,7 @@ class DWARFCallFrameInfo { Type m_type; CIESP - ParseCIE(const dw_offset_t cie_offset); + ParseCIE(const uint32_t cie_offset); lldb::RegisterKind GetRegisterKind() const { return m_type == EH ? lldb::eRegisterKindEHFrame : lldb::eRegisterKindDWARF; diff --git a/lldb/source/Plugins/SymbolFile/DWARF/AppleDWARFIndex.cpp b/lldb/source/Plugins/SymbolFile/DWARF/AppleDWARFIndex.cpp index ccbe1b6961a51..f6a49ba6141a7 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/AppleDWARFIndex.cpp +++ b/lldb/source/Plugins/SymbolFile/DWARF/AppleDWARFIndex.cpp @@ -80,7 +80,7 @@ void AppleDWARFIndex::GetGlobalVariables( if (!m_apple_names_up) return; - lldbassert(!cu.GetSymbolFileDWARF().GetFileIndex()); + lldbassert(!cu.GetSymbolFileDWARF().GetDwoNum()); const DWARFUnit &non_skeleton_cu = cu.GetNonSkeletonUnit(); DWARFMappedHash::DIEInfoArray hash_data; m_apple_names_up->AppendAllDIEsInRange(non_skeleton_cu.GetOffset(), diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DIERef.cpp b/lldb/source/Plugins/SymbolFile/DWARF/DIERef.cpp index 88a5e6027557b..53e154fd651d8 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/DIERef.cpp +++ b/lldb/source/Plugins/SymbolFile/DWARF/DIERef.cpp @@ -17,22 +17,40 @@ using namespace lldb_private; void llvm::format_provider::format(const DIERef &ref, raw_ostream &OS, StringRef Style) { - if (ref.file_index()) -OS << format_hex_no_prefix(*ref.file_index(), 8) << "/"; + if (ref.dwo_num()) +OS << format_hex_no_prefix(*ref.dwo_num(), 8) << "/";
[Lldb-commits] [lldb] 2062e90 - [LLDB] Enable 64 bit debug/type offset
Author: Alexander Yermolovich Date: 2023-02-16T14:46:13-08:00 New Revision: 2062e90aa531e8445e5dc0e16222c0f246af1bf4 URL: https://github.com/llvm/llvm-project/commit/2062e90aa531e8445e5dc0e16222c0f246af1bf4 DIFF: https://github.com/llvm/llvm-project/commit/2062e90aa531e8445e5dc0e16222c0f246af1bf4.diff LOG: [LLDB] Enable 64 bit debug/type offset This came out of from https://discourse.llvm.org/t/dwarf-dwp-4gb-limit/63902 With big binaries we can have .dwp files where .debug_info.dwo section can grow beyond 4GB. We would like to support this in LLVM and in LLDB. The plan is to enable manual parsing of cu/tu index in DWARF library (https://reviews.llvm.org/D137882), and then switch internal index data structure to 64 bit. For the second part is to enable 64bit offset support in LLDB with this patch. Depends on D139955 Reviewed By: labath Differential Revision: https://reviews.llvm.org/D138618 Added: Modified: lldb/include/lldb/Core/dwarf.h lldb/include/lldb/Symbol/DWARFCallFrameInfo.h lldb/source/Plugins/SymbolFile/DWARF/AppleDWARFIndex.cpp lldb/source/Plugins/SymbolFile/DWARF/DIERef.cpp lldb/source/Plugins/SymbolFile/DWARF/DIERef.h lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp lldb/source/Plugins/SymbolFile/DWARF/DWARFBaseDIE.cpp lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.cpp lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.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/NameToDIE.cpp lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.cpp lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.h lldb/test/Shell/SymbolFile/DWARF/DW_AT_range-DW_FORM_sec_offset.s lldb/unittests/Expression/DWARFExpressionTest.cpp lldb/unittests/SymbolFile/DWARF/DWARFIndexCachingTest.cpp Removed: diff --git a/lldb/include/lldb/Core/dwarf.h b/lldb/include/lldb/Core/dwarf.h index 60fbdec40beed..af0762ea7b704 100644 --- a/lldb/include/lldb/Core/dwarf.h +++ b/lldb/include/lldb/Core/dwarf.h @@ -30,11 +30,12 @@ typedef uint64_t dw_addr_t; // Dwarf address define that must be big enough for // any addresses in the compile units that get // parsed -typedef uint32_t dw_offset_t; // Dwarf Debug Information Entry offset for any +typedef uint64_t dw_offset_t; // Dwarf Debug Information Entry offset for any // offset into the file /* Constants */ -#define DW_INVALID_OFFSET (~(dw_offset_t)0) +#define DW_DIE_OFFSET_MAX_BITSIZE 40 +#define DW_INVALID_OFFSET (((uint64_t)1u << DW_DIE_OFFSET_MAX_BITSIZE) - 1) #define DW_INVALID_INDEX 0xul // #define DW_ADDR_none 0x0 diff --git a/lldb/include/lldb/Symbol/DWARFCallFrameInfo.h b/lldb/include/lldb/Symbol/DWARFCallFrameInfo.h index ea5c325e11a35..6cc24a02de257 100644 --- a/lldb/include/lldb/Symbol/DWARFCallFrameInfo.h +++ b/lldb/include/lldb/Symbol/DWARFCallFrameInfo.h @@ -128,7 +128,7 @@ class DWARFCallFrameInfo { void GetFDEIndex(); - bool FDEToUnwindPlan(uint32_t offset, Address startaddr, + bool FDEToUnwindPlan(dw_offset_t offset, Address startaddr, UnwindPlan &unwind_plan); const CIE *GetCIE(dw_offset_t cie_offset); @@ -159,7 +159,7 @@ class DWARFCallFrameInfo { Type m_type; CIESP - ParseCIE(const uint32_t cie_offset); + ParseCIE(const dw_offset_t cie_offset); lldb::RegisterKind GetRegisterKind() const { return m_type == EH ? lldb::eRegisterKindEHFrame : lldb::eRegisterKindDWARF; diff --git a/lldb/source/Plugins/SymbolFile/DWARF/AppleDWARFIndex.cpp b/lldb/source/Plugins/SymbolFile/DWARF/AppleDWARFIndex.cpp index f6a49ba6141a7..ccbe1b6961a51 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/AppleDWARFIndex.cpp +++ b/lldb/source/Plugins/SymbolFile/DWARF/AppleDWARFIndex.cpp @@ -80,7 +80,7 @@ void AppleDWARFIndex::GetGlobalVariables( if (!m_apple_names_up) return; - lldbassert(!cu.GetSymbolFileDWARF().GetDwoNum()); + lldbassert(!cu.GetSymbolFileDWARF().GetFileIndex()); const DWARFUnit &non_skeleton_cu = cu.GetNonSkeletonUnit(); DWARFMappedHash::DIEInfoArray hash_data; m_apple_names_up->AppendAllDIEsInRange(non_skeleton_cu.GetOffset(), diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DIERef.cpp b/lldb/source/Plugins/SymbolFile/DWARF/DIERef.cpp index 53e154fd651d8..88a5e6027557b 100644 --- a/lldb/source/Plugins/SymbolFile/
[Lldb-commits] [lldb] 8116fc5 - Revert "[LLDB] Enable 64 bit debug/type offset"
Author: Alexander Yermolovich Date: 2023-02-16T17:20:27-08:00 New Revision: 8116fc592c5eef88584033ec4f3539f405dee0e0 URL: https://github.com/llvm/llvm-project/commit/8116fc592c5eef88584033ec4f3539f405dee0e0 DIFF: https://github.com/llvm/llvm-project/commit/8116fc592c5eef88584033ec4f3539f405dee0e0.diff LOG: Revert "[LLDB] Enable 64 bit debug/type offset" This reverts commit 2062e90aa531e8445e5dc0e16222c0f246af1bf4. Added: Modified: lldb/include/lldb/Core/dwarf.h lldb/include/lldb/Symbol/DWARFCallFrameInfo.h lldb/source/Plugins/SymbolFile/DWARF/AppleDWARFIndex.cpp lldb/source/Plugins/SymbolFile/DWARF/DIERef.cpp lldb/source/Plugins/SymbolFile/DWARF/DIERef.h lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp lldb/source/Plugins/SymbolFile/DWARF/DWARFBaseDIE.cpp lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.cpp lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.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/NameToDIE.cpp lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.cpp lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.h lldb/test/Shell/SymbolFile/DWARF/DW_AT_range-DW_FORM_sec_offset.s lldb/unittests/Expression/DWARFExpressionTest.cpp lldb/unittests/SymbolFile/DWARF/DWARFIndexCachingTest.cpp Removed: diff --git a/lldb/include/lldb/Core/dwarf.h b/lldb/include/lldb/Core/dwarf.h index af0762ea7b704..60fbdec40beed 100644 --- a/lldb/include/lldb/Core/dwarf.h +++ b/lldb/include/lldb/Core/dwarf.h @@ -30,12 +30,11 @@ typedef uint64_t dw_addr_t; // Dwarf address define that must be big enough for // any addresses in the compile units that get // parsed -typedef uint64_t dw_offset_t; // Dwarf Debug Information Entry offset for any +typedef uint32_t dw_offset_t; // Dwarf Debug Information Entry offset for any // offset into the file /* Constants */ -#define DW_DIE_OFFSET_MAX_BITSIZE 40 -#define DW_INVALID_OFFSET (((uint64_t)1u << DW_DIE_OFFSET_MAX_BITSIZE) - 1) +#define DW_INVALID_OFFSET (~(dw_offset_t)0) #define DW_INVALID_INDEX 0xul // #define DW_ADDR_none 0x0 diff --git a/lldb/include/lldb/Symbol/DWARFCallFrameInfo.h b/lldb/include/lldb/Symbol/DWARFCallFrameInfo.h index 6cc24a02de257..ea5c325e11a35 100644 --- a/lldb/include/lldb/Symbol/DWARFCallFrameInfo.h +++ b/lldb/include/lldb/Symbol/DWARFCallFrameInfo.h @@ -128,7 +128,7 @@ class DWARFCallFrameInfo { void GetFDEIndex(); - bool FDEToUnwindPlan(dw_offset_t offset, Address startaddr, + bool FDEToUnwindPlan(uint32_t offset, Address startaddr, UnwindPlan &unwind_plan); const CIE *GetCIE(dw_offset_t cie_offset); @@ -159,7 +159,7 @@ class DWARFCallFrameInfo { Type m_type; CIESP - ParseCIE(const dw_offset_t cie_offset); + ParseCIE(const uint32_t cie_offset); lldb::RegisterKind GetRegisterKind() const { return m_type == EH ? lldb::eRegisterKindEHFrame : lldb::eRegisterKindDWARF; diff --git a/lldb/source/Plugins/SymbolFile/DWARF/AppleDWARFIndex.cpp b/lldb/source/Plugins/SymbolFile/DWARF/AppleDWARFIndex.cpp index ccbe1b6961a51..f6a49ba6141a7 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/AppleDWARFIndex.cpp +++ b/lldb/source/Plugins/SymbolFile/DWARF/AppleDWARFIndex.cpp @@ -80,7 +80,7 @@ void AppleDWARFIndex::GetGlobalVariables( if (!m_apple_names_up) return; - lldbassert(!cu.GetSymbolFileDWARF().GetFileIndex()); + lldbassert(!cu.GetSymbolFileDWARF().GetDwoNum()); const DWARFUnit &non_skeleton_cu = cu.GetNonSkeletonUnit(); DWARFMappedHash::DIEInfoArray hash_data; m_apple_names_up->AppendAllDIEsInRange(non_skeleton_cu.GetOffset(), diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DIERef.cpp b/lldb/source/Plugins/SymbolFile/DWARF/DIERef.cpp index 88a5e6027557b..53e154fd651d8 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/DIERef.cpp +++ b/lldb/source/Plugins/SymbolFile/DWARF/DIERef.cpp @@ -17,22 +17,40 @@ using namespace lldb_private; void llvm::format_provider::format(const DIERef &ref, raw_ostream &OS, StringRef Style) { - if (ref.file_index()) -OS << format_hex_no_prefix(*ref.file_index(), 8) << "/"; + if (ref.dwo_num()) +OS << format_hex_no_prefix(*ref.dwo_num(), 8) << "/"; OS << (ref.section() == DIERef::DebugInfo ? "INFO" : "TYPE")
[Lldb-commits] [lldb] 34a8e6e - [LLDB] Enable 64 bit debug/type offset
Author: Alexander Yermolovich Date: 2023-02-22T11:34:00-08:00 New Revision: 34a8e6eee666fe1e67b8b689abe5e4e95bf6b166 URL: https://github.com/llvm/llvm-project/commit/34a8e6eee666fe1e67b8b689abe5e4e95bf6b166 DIFF: https://github.com/llvm/llvm-project/commit/34a8e6eee666fe1e67b8b689abe5e4e95bf6b166.diff LOG: [LLDB] Enable 64 bit debug/type offset This came out of from https://discourse.llvm.org/t/dwarf-dwp-4gb-limit/63902 With big binaries we can have .dwp files where .debug_info.dwo section can grow beyond 4GB. We would like to support this in LLVM and in LLDB. The plan is to enable manual parsing of cu/tu index in DWARF library (https://reviews.llvm.org/D137882), and then switch internal index data structure to 64 bit. For the second part is to enable 64bit offset support in LLDB with this patch. Reviewed By: labath Differential Revision: https://reviews.llvm.org/D138618 Added: Modified: lldb/include/lldb/Core/dwarf.h lldb/include/lldb/Symbol/DWARFCallFrameInfo.h lldb/source/Plugins/SymbolFile/DWARF/AppleDWARFIndex.cpp lldb/source/Plugins/SymbolFile/DWARF/DIERef.cpp lldb/source/Plugins/SymbolFile/DWARF/DIERef.h lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp lldb/source/Plugins/SymbolFile/DWARF/DWARFBaseDIE.cpp lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.cpp lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.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/NameToDIE.cpp lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.cpp lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.h lldb/test/Shell/SymbolFile/DWARF/DW_AT_range-DW_FORM_sec_offset.s lldb/unittests/Expression/DWARFExpressionTest.cpp lldb/unittests/SymbolFile/DWARF/DWARFIndexCachingTest.cpp Removed: diff --git a/lldb/include/lldb/Core/dwarf.h b/lldb/include/lldb/Core/dwarf.h index 60fbdec40beed..af0762ea7b704 100644 --- a/lldb/include/lldb/Core/dwarf.h +++ b/lldb/include/lldb/Core/dwarf.h @@ -30,11 +30,12 @@ typedef uint64_t dw_addr_t; // Dwarf address define that must be big enough for // any addresses in the compile units that get // parsed -typedef uint32_t dw_offset_t; // Dwarf Debug Information Entry offset for any +typedef uint64_t dw_offset_t; // Dwarf Debug Information Entry offset for any // offset into the file /* Constants */ -#define DW_INVALID_OFFSET (~(dw_offset_t)0) +#define DW_DIE_OFFSET_MAX_BITSIZE 40 +#define DW_INVALID_OFFSET (((uint64_t)1u << DW_DIE_OFFSET_MAX_BITSIZE) - 1) #define DW_INVALID_INDEX 0xul // #define DW_ADDR_none 0x0 diff --git a/lldb/include/lldb/Symbol/DWARFCallFrameInfo.h b/lldb/include/lldb/Symbol/DWARFCallFrameInfo.h index ea5c325e11a35..6cc24a02de257 100644 --- a/lldb/include/lldb/Symbol/DWARFCallFrameInfo.h +++ b/lldb/include/lldb/Symbol/DWARFCallFrameInfo.h @@ -128,7 +128,7 @@ class DWARFCallFrameInfo { void GetFDEIndex(); - bool FDEToUnwindPlan(uint32_t offset, Address startaddr, + bool FDEToUnwindPlan(dw_offset_t offset, Address startaddr, UnwindPlan &unwind_plan); const CIE *GetCIE(dw_offset_t cie_offset); @@ -159,7 +159,7 @@ class DWARFCallFrameInfo { Type m_type; CIESP - ParseCIE(const uint32_t cie_offset); + ParseCIE(const dw_offset_t cie_offset); lldb::RegisterKind GetRegisterKind() const { return m_type == EH ? lldb::eRegisterKindEHFrame : lldb::eRegisterKindDWARF; diff --git a/lldb/source/Plugins/SymbolFile/DWARF/AppleDWARFIndex.cpp b/lldb/source/Plugins/SymbolFile/DWARF/AppleDWARFIndex.cpp index f6a49ba6141a7..33555d4f8f4ba 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/AppleDWARFIndex.cpp +++ b/lldb/source/Plugins/SymbolFile/DWARF/AppleDWARFIndex.cpp @@ -80,7 +80,6 @@ void AppleDWARFIndex::GetGlobalVariables( if (!m_apple_names_up) return; - lldbassert(!cu.GetSymbolFileDWARF().GetDwoNum()); const DWARFUnit &non_skeleton_cu = cu.GetNonSkeletonUnit(); DWARFMappedHash::DIEInfoArray hash_data; m_apple_names_up->AppendAllDIEsInRange(non_skeleton_cu.GetOffset(), diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DIERef.cpp b/lldb/source/Plugins/SymbolFile/DWARF/DIERef.cpp index 53e154fd651d8..88a5e6027557b 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/DIERef.cpp +++ b/lldb/source/Plugins/SymbolFile/DWARF/DIERef.cpp @@ -1
[Lldb-commits] [lldb] d557384 - [LLDB] Fix for D139955 Summary:
Author: Alexander Yermolovich Date: 2023-03-23T14:03:42-07:00 New Revision: d557384b43d32700ed09b08564a4f7823061d999 URL: https://github.com/llvm/llvm-project/commit/d557384b43d32700ed09b08564a4f7823061d999 DIFF: https://github.com/llvm/llvm-project/commit/d557384b43d32700ed09b08564a4f7823061d999.diff LOG: [LLDB] Fix for D139955 Summary: Fixing a small typo. Reviewed By: clayborg Differential Revision: https://reviews.llvm.org/D146659 Added: lldb/test/Shell/SymbolFile/DWARF/range-lower-then-low-pc.s Modified: lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp Removed: diff --git a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp index 99a0152eaf6e6..c6873a5b7a09a 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp +++ b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp @@ -1319,7 +1319,7 @@ size_t SymbolFileDWARF::ParseBlocksRecursive( range.GetByteSize())); else { GetObjectFile()->GetModule()->ReportError( -"{0x:+8}: adding range [{1:x16}-{2:x16}) which has a base " +"{0:x8}: adding range [{1:x16}-{2:x16}) which has a base " "that is less than the function's low PC {3:x16}. Please file " "a bug and attach the file at the " "start of this error message", diff --git a/lldb/test/Shell/SymbolFile/DWARF/range-lower-then-low-pc.s b/lldb/test/Shell/SymbolFile/DWARF/range-lower-then-low-pc.s new file mode 100644 index 0..e3cc84db12652 --- /dev/null +++ b/lldb/test/Shell/SymbolFile/DWARF/range-lower-then-low-pc.s @@ -0,0 +1,317 @@ +# REQUIRES: x86 + +# RUN: llvm-mc -triple=x86_64-pc-linux -filetype=obj %s > %t +# RUN: lldb-test symbols %t &> %t.txt +# RUN: cat %t.txt | FileCheck %s + +# Tests that error is printed correctly when DW_AT_low_pc value is +# greater then a range entry. + +# CHECK: 0x006e: adding range [0x-0x001f) +# CHECK-SAME: which has a base that is less than the function's low PC 0x0021. +# CHECK-SAME: Please file a bug and attach the file at the start of this error message + + + +# Test was manually modified to change DW_TAG_lexical_block +# to use DW_AT_ranges, and value lower then DW_AT_low_pc value +# in DW_TAG_subprogram +# static int foo(bool b) { +# if (b) { +#int food = 1; +# return food; +# } +# return 0; +# } +# int main() { +# return foo(true); +# } + .text + .file "main.cpp" + .section.text.main,"ax",@progbits + .globl main# -- Begin function main + .p2align4, 0x90 + .type main,@function +main: # @main +.Lfunc_begin0: + .file 1 "base-lower-then-range-entry" "main.cpp" + .loc1 8 0 # main.cpp:8:0 + .cfi_startproc +# %bb.0:# %entry + pushq %rbp + .cfi_def_cfa_offset 16 + .cfi_offset %rbp, -16 + movq%rsp, %rbp + .cfi_def_cfa_register %rbp + subq$16, %rsp + movl$0, -4(%rbp) +.Ltmp0: + .loc1 9 10 prologue_end # main.cpp:9:10 + movl$1, %edi + callq _ZL3foob + .loc1 9 3 epilogue_begin is_stmt 0 # main.cpp:9:3 + addq$16, %rsp + popq%rbp + .cfi_def_cfa %rsp, 8 + retq +.Ltmp1: +.Lfunc_end0: + .size main, .Lfunc_end0-main + .cfi_endproc +# -- End function + .section.text._ZL3foob,"ax",@progbits + .p2align4, 0x90 # -- Begin function _ZL3foob + .type _ZL3foob,@function +_ZL3foob: # @_ZL3foob +.Lfunc_begin1: + .loc1 1 0 is_stmt 1 # main.cpp:1:0 + .cfi_startproc +# %bb.0:# %entry + pushq %rbp + .cfi_def_cfa_offset 16 + .cfi_offset %rbp, -16 + movq%rsp, %rbp + .cfi_def_cfa_register %rbp + movb%dil, %al + andb$1, %al + movb%al, -5(%rbp) +.Ltmp2: + .loc1 2 7 prologue_end # main.cpp:2:7 + testb $1, -5(%rbp) + je .LBB1_2 +# %bb.1:# %if.then +.Ltmp3: + .loc1 3 8 # main.cpp:3:8 + movl$1, -12(%rbp) + .loc1 4 12 # main.cpp:4:12 + movl-12(%rbp), %eax + .loc1 4 5 is_stmt 0 # main.cpp:4:5 + movl%eax, -4(%rbp) + jmp .LBB1_3 +.Ltmp4: +.LBB1_2:# %if.end + .loc1 6 3 is_stmt 1 # main.cpp:6:3 + movl$0, -4(%rbp) +.LB
[Lldb-commits] [lldb] [LLVM][DWARF] Add support for monolithic types in .debug_names (PR #70512)
https://github.com/ayermolo updated https://github.com/llvm/llvm-project/pull/70512 >From 1c6a604df93b833c3bb9c7d34f4f27415592dbe5 Mon Sep 17 00:00:00 2001 From: Alexander Yermolovich Date: Thu, 5 Oct 2023 12:39:02 -0700 Subject: [PATCH] [LLVM][DWARF] Add support for monolithic types in .debug_names Enable Type Units with DWARF5 accelerator tables for monolithic DWARF. Implementation relies on linker to tombstone offset in LocalTU list to -1 when it deduplciates type units using COMDAT. --- llvm/include/llvm/CodeGen/AccelTable.h| 64 +-- llvm/lib/CodeGen/AsmPrinter/AccelTable.cpp| 173 -- .../lib/CodeGen/AsmPrinter/DwarfCompileUnit.h | 2 +- llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp| 37 +++- llvm/lib/CodeGen/AsmPrinter/DwarfDebug.h | 12 +- llvm/lib/CodeGen/AsmPrinter/DwarfFile.cpp | 4 + llvm/lib/CodeGen/AsmPrinter/DwarfFile.h | 20 ++ llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp | 6 + llvm/lib/CodeGen/AsmPrinter/DwarfUnit.h | 15 ++ llvm/lib/DWARFLinker/DWARFStreamer.cpp| 18 +- .../DWARFLinkerParallel/DWARFEmitterImpl.cpp | 13 +- .../test/DebugInfo/X86/accel-tables-dwarf5.ll | 1 - .../test/DebugInfo/X86/debug-names-dwarf64.ll | 8 +- .../X86/debug-names-types-monolithic.ll | 163 + .../DebugInfo/X86/debug-names-types-split.ll | 57 ++ .../ARM/dwarf5-dwarf4-combination-macho.test | 14 +- 16 files changed, 503 insertions(+), 104 deletions(-) create mode 100644 llvm/test/DebugInfo/X86/debug-names-types-monolithic.ll create mode 100644 llvm/test/DebugInfo/X86/debug-names-types-split.ll diff --git a/llvm/include/llvm/CodeGen/AccelTable.h b/llvm/include/llvm/CodeGen/AccelTable.h index d4e21b2ac8e7ebc..d948b7d82b85979 100644 --- a/llvm/include/llvm/CodeGen/AccelTable.h +++ b/llvm/include/llvm/CodeGen/AccelTable.h @@ -16,7 +16,6 @@ #include "llvm/ADT/ArrayRef.h" #include "llvm/ADT/MapVector.h" #include "llvm/ADT/STLFunctionalExtras.h" -#include "llvm/ADT/StringMap.h" #include "llvm/ADT/StringRef.h" #include "llvm/BinaryFormat/Dwarf.h" #include "llvm/CodeGen/DIE.h" @@ -104,10 +103,13 @@ namespace llvm { class AsmPrinter; -class DwarfCompileUnit; +class DwarfUnit; class DwarfDebug; +class DwarfTypeUnit; class MCSymbol; class raw_ostream; +struct TypeUnitMetaInfo; +using TUVectorTy = SmallVector; /// Interface which the different types of accelerator table data have to /// conform. It serves as a base class for different values of the template @@ -197,6 +199,9 @@ template class AccelTable : public AccelTableBase { template void addName(DwarfStringPoolEntryRef Name, Types &&... Args); + void clear() { Entries.clear(); } + void addEntries(AccelTable &Table); + const StringEntries getEntries() const { return Entries; } }; template @@ -250,11 +255,21 @@ class AppleAccelTableData : public AccelTableData { /// emitDWARF5AccelTable function. class DWARF5AccelTableData : public AccelTableData { public: + struct AttributeEncoding { +dwarf::Index Index; +dwarf::Form Form; + }; static uint32_t hash(StringRef Name) { return caseFoldingDjbHash(Name); } - DWARF5AccelTableData(const DIE &Die, const DwarfCompileUnit &CU); - DWARF5AccelTableData(uint64_t DieOffset, unsigned DieTag, unsigned CUIndex) - : OffsetVal(DieOffset), DieTag(DieTag), UnitID(CUIndex) {} + DWARF5AccelTableData(const DIE &Die, const DwarfUnit &CU, + const bool IsTU = false); + DWARF5AccelTableData(const uint64_t DieOffset, const unsigned DieTag, + const unsigned Index, const bool IsTU = false) + : OffsetVal(DieOffset) { +Data.DieTag = DieTag; +Data.UnitID = Index; +Data.IsTU = IsTU; + } #ifndef NDEBUG void print(raw_ostream &OS) const override; @@ -265,18 +280,25 @@ class DWARF5AccelTableData : public AccelTableData { "Accessing DIE Offset before normalizing."); return std::get(OffsetVal); } - unsigned getDieTag() const { return DieTag; } - unsigned getUnitID() const { return UnitID; } + unsigned getDieTag() const { return Data.DieTag; } + unsigned getUnitID() const { return Data.UnitID; } + bool isTU() const { return Data.IsTU; } void normalizeDIEToOffset() { assert(std::holds_alternative(OffsetVal) && "Accessing offset after normalizing."); OffsetVal = std::get(OffsetVal)->getOffset(); } + bool isNormalized() const { +return std::holds_alternative(OffsetVal); + } protected: std::variant OffsetVal; - unsigned DieTag; - unsigned UnitID; + struct MetaData { +uint32_t DieTag : 16; +uint32_t UnitID : 15; +uint32_t IsTU : 1; + } Data; uint64_t order() const override { return getDieOffset(); } }; @@ -288,7 +310,19 @@ class DWARF5AccelTable : public AccelTable { void convertDieToOffset() { for (auto &Entry : Entries) { for (AccelTableData *Value : Entry.second.Values) { -static_cast(Value)->normalize
[Lldb-commits] [lldb] [LLVM][DWARF] Add support for monolithic types in .debug_names (PR #70512)
https://github.com/ayermolo closed https://github.com/llvm/llvm-project/pull/70512 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [clang] [lldb] [llvm] [BOLT][DWARF] Fix handling of DWARF5 DWP (PR #72729)
https://github.com/ayermolo created https://github.com/llvm/llvm-project/pull/72729 Fixed handling of DWP as input. Before BOLT crashed. Now it will write out correct CU, and all the TUs. Potential future improvement is to scan all the TUs used in this CU, and only include those. >From 80adaca72cf869f8735d7a3684a8d64bc438e5b6 Mon Sep 17 00:00:00 2001 From: Amir Ayupov Date: Tue, 1 Jun 2021 11:37:41 -0700 Subject: [PATCH 1/3] Rebase: [Facebook] Add clang driver options to test debug info and BOLT Summary: This is an essential piece of infrastructure for us to be continuously testing debug info with BOLT. We can't only make changes to a test repo because we need to change debuginfo tests to call BOLT, hence, this diff needs to sit in our opensource repo. But when upstreaming to LLVM, this should be kept BOLT-only outside of LLVM. When upstreaming, we need to git diff and check all folders that are being modified by our commits and discard this one (and leave as an internal diff). To test BOLT in debuginfo tests, configure it with -DLLVM_TEST_BOLT=ON. Then run check-lldb and check-debuginfo. Manual rebase conflict history: https://phabricator.intern.facebook.com/D29205224 https://phabricator.intern.facebook.com/D29564078 https://phabricator.intern.facebook.com/D33289118 https://phabricator.intern.facebook.com/D34957174 https://phabricator.intern.facebook.com/D35317341 Test Plan: tested locally Configured with: -DLLVM_ENABLE_PROJECTS="clang;lld;lldb;compiler-rt;bolt;debuginfo-tests" -DLLVM_TEST_BOLT=ON Ran test suite with: ninja check-debuginfo ninja check-lldb Reviewers: maks, #llvm-bolt Reviewed By: maks Subscribers: ayermolo, phabricatorlinter Differential Revision: https://phabricator.intern.facebook.com/D46256657 Tasks: T92898286 --- clang/include/clang/Driver/Options.td | 4 clang/lib/Driver/ToolChains/Gnu.cpp| 29 ++ cross-project-tests/lit.cfg.py | 14 - cross-project-tests/lit.site.cfg.py.in | 4 lldb/test/API/lit.cfg.py | 5 + lldb/test/API/lit.site.cfg.py.in | 8 +++ lldb/test/Shell/helper/toolchain.py| 5 + lldb/test/Shell/lit.site.cfg.py.in | 9 llvm/CMakeLists.txt| 4 9 files changed, 81 insertions(+), 1 deletion(-) diff --git a/clang/include/clang/Driver/Options.td b/clang/include/clang/Driver/Options.td index 811550416110b3d..31ad86bc098ec63 100644 --- a/clang/include/clang/Driver/Options.td +++ b/clang/include/clang/Driver/Options.td @@ -5178,6 +5178,10 @@ def pg : Flag<["-"], "pg">, HelpText<"Enable mcount instrumentation">, MarshallingInfoFlag>; def pipe : Flag<["-", "--"], "pipe">, HelpText<"Use pipes between commands, when possible">; +// Facebook T92898286 +def post_link_optimize : Flag<["--"], "post-link-optimize">, + HelpText<"Apply post-link optimizations using BOLT">; +// End Facebook T92898286 def prebind__all__twolevel__modules : Flag<["-"], "prebind_all_twolevel_modules">; def prebind : Flag<["-"], "prebind">; def preload : Flag<["-"], "preload">; diff --git a/clang/lib/Driver/ToolChains/Gnu.cpp b/clang/lib/Driver/ToolChains/Gnu.cpp index ba95ce9c5a28153..bf55d90f6dc704b 100644 --- a/clang/lib/Driver/ToolChains/Gnu.cpp +++ b/clang/lib/Driver/ToolChains/Gnu.cpp @@ -666,12 +666,41 @@ void tools::gnutools::Linker::ConstructJob(Compilation &C, const JobAction &JA, } } + // Facebook T92898286 + if (Args.hasArg(options::OPT_post_link_optimize)) +CmdArgs.push_back("-q"); + // End Facebook T92898286 + Args.AddAllArgs(CmdArgs, options::OPT_T); const char *Exec = Args.MakeArgString(ToolChain.GetLinkerPath()); C.addCommand(std::make_unique(JA, *this, ResponseFileSupport::AtFileCurCP(), Exec, CmdArgs, Inputs, Output)); + // Facebook T92898286 + if (!Args.hasArg(options::OPT_post_link_optimize) || !Output.isFilename()) +return; + + const char *MvExec = Args.MakeArgString(ToolChain.GetProgramPath("mv")); + ArgStringList MoveCmdArgs; + MoveCmdArgs.push_back(Output.getFilename()); + const char *PreBoltBin = + Args.MakeArgString(Twine(Output.getFilename()) + ".pre-bolt"); + MoveCmdArgs.push_back(PreBoltBin); + C.addCommand(std::make_unique(JA, *this, ResponseFileSupport::None(), + MvExec, MoveCmdArgs, std::nullopt)); + + ArgStringList BoltCmdArgs; + const char *BoltExec = + Args.MakeArgString(ToolChain.GetProgramPath("llvm-bolt")); + BoltCmdArgs.push_back(PreBoltBin); + BoltCmdArgs.push_back("-reorder-blocks=reverse"); + BoltCmdArgs.push_back("-update-debug-sections"); + BoltCmdArgs.push_back("-o"); + BoltCmdArgs.push_back(Output.getFilename()); + C.addCommand(std::make_unique(JA, *this, ResponseFileSupport::None(), + BoltExec, BoltCmdArgs, std::nullopt)); + // End Facebook T92898286 } void tools::gnutoo