aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSid Nayyar <sidnayyar@google.com>2024-05-13 15:14:23 +0100
committerGiuliano Procida <gprocida@google.com>2024-05-14 16:59:39 +0100
commit41ede4ddacdda34195a45bc1394ae954b3d493a1 (patch)
tree09dccc0fbea80b875666013749c318dca5659eac
parent5adbe8ef91fc7932683d3f88ece819bc695e56af (diff)
downloadstg-41ede4ddacdda34195a45bc1394ae954b3d493a1.tar.gz
rust: add DWARF processor for `VariantMember` nodes
PiperOrigin-RevId: 633199025 Change-Id: I2089b60947382dcd06539b43f7126a6dc44ff381
-rw-r--r--dwarf_processor.cc31
1 files changed, 31 insertions, 0 deletions
diff --git a/dwarf_processor.cc b/dwarf_processor.cc
index 9e84971..632ea2f 100644
--- a/dwarf_processor.cc
+++ b/dwarf_processor.cc
@@ -577,6 +577,37 @@ class Processor {
}
}
+ void ProcessVariantMember(Entry& entry) {
+ // TODO: Process signed discriminant values.
+ auto dw_discriminant_value =
+ entry.MaybeGetUnsignedConstant(DW_AT_discr_value);
+ auto discriminant_value =
+ dw_discriminant_value
+ ? std::optional(static_cast<int64_t>(*dw_discriminant_value))
+ : std::nullopt;
+
+ auto children = entry.GetChildren();
+ if (children.size() != 1) {
+ Die() << "Unexpected number of children for variant member: "
+ << EntryToString(entry);
+ }
+
+ auto child = children[0];
+ if (child.GetTag() != DW_TAG_member) {
+ Die() << "Unexpected tag for variant member child: "
+ << Hex(child.GetTag()) << ", " << EntryToString(child);
+ }
+ if (GetDataBitOffset(child, 0, is_little_endian_binary_) != 0) {
+ Die() << "Unexpected data member location for variant member: "
+ << EntryToString(child);
+ }
+
+ const std::string name = GetNameOrEmpty(child);
+ auto referred_type_id = GetReferredTypeId(GetReferredType(child));
+ AddProcessedNode<VariantMember>(entry, name, discriminant_value,
+ referred_type_id);
+ }
+
void ProcessMember(Entry& entry) {
const auto name = GetNameOrEmpty(entry);
auto referred_type = GetReferredType(entry);