[llvm] [llvm-gsymutil] Add option to load callsites from DWARF (PR #119913)
Greg Clayton via llvm-commits
llvm-commits at lists.llvm.org
Mon Dec 16 13:31:34 PST 2024
================
@@ -553,6 +558,58 @@ void DwarfTransformer::handleDie(OutputAggregator &Out, CUInfo &CUI,
handleDie(Out, CUI, ChildDie);
}
+void DwarfTransformer::parseCallSiteInfoFromDwarf(CUInfo &CUI, DWARFDie Die,
+ FunctionInfo &FI) {
+ // Parse all DW_TAG_call_site DIEs that are children of this subprogram DIE.
+ // DWARF specification:
+ // - DW_TAG_call_site can have DW_AT_call_return_pc for return address offset.
+ // - DW_AT_call_origin might point to a DIE of the function being called.
+ // For simplicity, we will just extract return_offset and possibly target name
+ // if available.
+
+ CallSiteInfoCollection CSIC;
+
+ for (DWARFDie Child : Die.children()) {
+ if (Child.getTag() != dwarf::DW_TAG_call_site)
+ continue;
+
+ CallSiteInfo CSI;
+ // DW_AT_call_return_pc: the return PC (address). We'll convert it to
+ // offset relative to FI's start.
+ auto ReturnPC = dwarf::toAddress(Child.find(dwarf::DW_AT_call_return_pc));
+ if (!ReturnPC || *ReturnPC < FI.startAddress() ||
+ *ReturnPC >= FI.endAddress())
----------------
clayborg wrote:
Change to use `FI.Range.contains(*ReturnPC)`
https://github.com/llvm/llvm-project/pull/119913
More information about the llvm-commits
mailing list