[PATCH] D82351: [ObjectYAML][DWARF] Remove unused context. NFC.

Xing GUO via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Jun 23 01:32:49 PDT 2020


Higuoxing added a comment.

In D82351#2108345 <https://reviews.llvm.org/D82351#2108345>, @jhenderson wrote:

> Are you sure it's unused? I took a quick look and the function `void MappingTraits<DWARFYAML::PubEntry>::mapping` uses it to determine the style (GNU/non-GNU).


Yeah, the GNU-style is determined by `DWARFYAML::PubSection` rather than `DWARFYAML::Data`. The `DWARF` context is never used.

  void MappingTraits<DWARFYAML::PubEntry>::mapping(IO &IO,
                                                   DWARFYAML::PubEntry &Entry) {
    IO.mapRequired("DieOffset", Entry.DieOffset);
    if (reinterpret_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();   // unused                            |
    IO.setContext(&Section);                                                  |
    ^-------------------------------------------------------------------------+
    IO.mapRequired("Length", Section.Length);
    IO.mapRequired("Version", Section.Version);
    IO.mapRequired("UnitOffset", Section.UnitOffset);
    IO.mapRequired("UnitSize", Section.UnitSize);
    IO.mapRequired("Entries", Section.Entries);
  
    IO.setContext(OldContext);
  }

Besides, the implementation of mapping YAML to `PubSection` is buggy. If we map `debug_gnu_pubnames/debug_gnu_pubtypes` to `PubSection`, the `GNUStyle` is always `false` and `Descriptor` can never be mapped into `Entry.Descriptor`.
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'`.

But if we map `PubSection` to `debug_gnu_pubnames/debug_gnu_pubtypes`, that is fine since the `GNUStyle` has been set by obj2yaml.

I'm wondering if we need to add support for emitting the .debug_gnu_pubnames and .debug_gnu_pubtypes since no test case relies on them.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D82351/new/

https://reviews.llvm.org/D82351





More information about the llvm-commits mailing list