[PATCH] D124052: [DWARF] Add API to get data from MCDwarfLineStr
Alexander Yermolovich via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Apr 19 16:25:23 PDT 2022
ayermolo created this revision.
Herald added subscribers: hoy, modimo, wenlei, hiraditya.
Herald added a project: All.
ayermolo requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
This API will be used in D121876 <https://reviews.llvm.org/D121876>, to get finalized string data for
.debug_line_str.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D124052
Files:
llvm/include/llvm/MC/MCDwarf.h
llvm/include/llvm/MC/StringTableBuilder.h
llvm/lib/MC/MCDwarf.cpp
Index: llvm/lib/MC/MCDwarf.cpp
===================================================================
--- llvm/lib/MC/MCDwarf.cpp
+++ llvm/lib/MC/MCDwarf.cpp
@@ -334,12 +334,18 @@
// Switch to the .debug_line_str section.
MCOS->SwitchSection(
MCOS->getContext().getObjectFileInfo()->getDwarfLineStrSection());
+ SmallString<0> Data = getFinalizedData();
+ MCOS->emitBinaryData(Data.str());
+}
+
+SmallString<0> MCDwarfLineStr::getFinalizedData() {
// Emit the strings without perturbing the offsets we used.
- LineStrings.finalizeInOrder();
+ if (!LineStrings.isFinalized())
+ LineStrings.finalizeInOrder();
SmallString<0> Data;
Data.resize(LineStrings.getSize());
LineStrings.write((uint8_t *)Data.data());
- MCOS->emitBinaryData(Data.str());
+ return Data;
}
void MCDwarfLineStr::emitRef(MCStreamer *MCOS, StringRef Path) {
Index: llvm/include/llvm/MC/StringTableBuilder.h
===================================================================
--- llvm/include/llvm/MC/StringTableBuilder.h
+++ llvm/include/llvm/MC/StringTableBuilder.h
@@ -85,7 +85,6 @@
void write(raw_ostream &OS) const;
void write(uint8_t *Buf) const;
-private:
bool isFinalized() const { return Finalized; }
};
Index: llvm/include/llvm/MC/MCDwarf.h
===================================================================
--- llvm/include/llvm/MC/MCDwarf.h
+++ llvm/include/llvm/MC/MCDwarf.h
@@ -62,6 +62,9 @@
/// Emit the .debug_line_str section if appropriate.
void emitSection(MCStreamer *MCOS);
+
+ /// Returns finalized section.
+ SmallString<0> getFinalizedData();
};
/// Instances of this class represent the name of the dwarf .file directive and
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D124052.423760.patch
Type: text/x-patch
Size: 1681 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220419/c7ce4f81/attachment.bin>
More information about the llvm-commits
mailing list