[PATCH] D82435: [DWARFYAML][debug_gnu_*] Add the missing context `IsGNUStyle`. NFC.
Xing GUO via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Jun 23 23:25:40 PDT 2020
Higuoxing created this revision.
Higuoxing added reviewers: jhenderson, grimar, MaskRay.
Herald added subscribers: llvm-commits, hiraditya, aprantl.
Herald added a project: LLVM.
This patch helps add the missing context `IsGNUStyle`. Before this patch, yaml2obj cannot parse the YAML description of 'debug_gnu_pubnames' and 'debug_gnu_pubtypes' correctly due to the missing context.
In other words, if we have
DWARF:
debug_gnu_pubtypes:
Length:
TotalLength: 0x1234
Version: 2
UnitOffset: 0x1234
UnitSize: 0x4321
Entries:
- DieOffset: 0x12345678
Name: abc
Descriptor: 0x00 ## Descripor can never be mapped into Entry.Descriptor
yaml2obj will complain that "error: unknown key 'Descriptor'".
This patch helps resolve this problem.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D82435
Files:
llvm/lib/ObjectYAML/DWARFYAML.cpp
Index: llvm/lib/ObjectYAML/DWARFYAML.cpp
===================================================================
--- llvm/lib/ObjectYAML/DWARFYAML.cpp
+++ llvm/lib/ObjectYAML/DWARFYAML.cpp
@@ -54,10 +54,19 @@
IO.mapOptional("debug_aranges", DWARF.ARanges);
if (!DWARF.DebugRanges.empty() || !IO.outputting())
IO.mapOptional("debug_ranges", DWARF.DebugRanges);
- IO.mapOptional("debug_pubnames", DWARF.PubNames);
- IO.mapOptional("debug_pubtypes", DWARF.PubTypes);
- IO.mapOptional("debug_gnu_pubnames", DWARF.GNUPubNames);
- IO.mapOptional("debug_gnu_pubtypes", DWARF.GNUPubTypes);
+ if (DWARF.PubNames || DWARF.PubTypes || DWARF.GNUPubNames ||
+ DWARF.GNUPubTypes || !IO.outputting()) {
+ auto *OldContext = IO.getContext();
+ bool IsGNUStyle = false;
+ IO.setContext(&IsGNUStyle);
+ IO.mapOptional("debug_pubnames", DWARF.PubNames);
+ IO.mapOptional("debug_pubtypes", DWARF.PubTypes);
+
+ IsGNUStyle = true;
+ IO.mapOptional("debug_gnu_pubnames", DWARF.GNUPubNames);
+ IO.mapOptional("debug_gnu_pubtypes", DWARF.GNUPubTypes);
+ IO.setContext(OldContext);
+ }
IO.mapOptional("debug_info", DWARF.CompileUnits);
IO.mapOptional("debug_line", DWARF.DebugLines);
IO.mapOptional("debug_addr", DWARF.DebugAddr);
@@ -112,14 +121,15 @@
void MappingTraits<DWARFYAML::PubEntry>::mapping(IO &IO,
DWARFYAML::PubEntry &Entry) {
IO.mapRequired("DieOffset", Entry.DieOffset);
- if (reinterpret_cast<DWARFYAML::PubSection *>(IO.getContext())->IsGNUStyle)
+ if (static_cast<DWARFYAML::PubSection *>(IO.getContext())->IsGNUStyle)
IO.mapRequired("Descriptor", Entry.Descriptor);
IO.mapRequired("Name", Entry.Name);
}
void MappingTraits<DWARFYAML::PubSection>::mapping(
IO &IO, DWARFYAML::PubSection &Section) {
- auto OldContext = IO.getContext();
+ bool *IsGNUStyle = static_cast<bool *>(IO.getContext());
+ Section.IsGNUStyle = *IsGNUStyle;
IO.setContext(&Section);
IO.mapRequired("Length", Section.Length);
@@ -127,8 +137,7 @@
IO.mapRequired("UnitOffset", Section.UnitOffset);
IO.mapRequired("UnitSize", Section.UnitSize);
IO.mapRequired("Entries", Section.Entries);
-
- IO.setContext(OldContext);
+ IO.setContext(IsGNUStyle);
}
void MappingTraits<DWARFYAML::Unit>::mapping(IO &IO, DWARFYAML::Unit &Unit) {
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D82435.272919.patch
Type: text/x-patch
Size: 2346 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200624/924c9efe/attachment-0001.bin>
More information about the llvm-commits
mailing list