[ dwarfdump ] Add symbolic dump of known DWARF attribute values.

David Blaikie dblaikie at gmail.com
Wed Sep 3 13:56:18 PDT 2014


Perhaps we could avoid the goto & offload some of the repetition from the
macro like this:

const char *Name = nullptr;

switch (attr) {
#define ENUM_TO_STRING_ATTRIBUTE(NAME)
  if (Optional<uint64_t> Val = formValue.getAsUnsignedConstant())
    Name = NAME##String(*Val);
  break;

  case ...
    ...
  // no default here
}

if (Name)
  OS << Name;
else
  formValue.dump(OS, u);

Or even refactor the switch into a function, then you can just have this in
the macro:

  if (Optional<uint64_t> Val = ...)
    return *Val;

and a "return nullptr" at the end.


On Wed, Sep 3, 2014 at 1:38 PM, Frédéric Riss <friss at apple.com> wrote:

> Here is a new version rebased on the reviewed FormValue accessor patch.
>
> OK?
>
>
> On 03 Sep 2014, at 21:12, Adrian Prantl <aprantl at apple.com> wrote:
>
>
> On Sep 3, 2014, at 12:03 PM, Frédéric Riss <friss at apple.com> wrote:
>
>
> On 03 Sep 2014, at 20:57, Adrian Prantl <aprantl at apple.com> wrote:
>
>
> On Sep 3, 2014, at 11:52 AM, Frédéric Riss <friss at apple.com> wrote:
>
> This patch introduces symbolic dump of all the DWARF standard values
> (defined in Dwarf.h). It requires the previous DWARFFormValue accessor
> patch. The fixed accessibility test shows that it’s much easier to check
> that the test is actually correct, rather than having to cross-check with
> the enumerator value.
>
> OK?
> <dwarfdump-SymbolicAttributes.diff>
>
>
> If you look at lib/Support/Dwarf.cpp, there is already a similar switch
> table for converting all the attribute names. We should probably only have
> one such implementation.
>
>
> Really, which one? I see tables converting from various enum to const char
> * value, but my switch associates DW_AT_* attributes with the corresponding
> attribute enumeration. This patch uses all the switch functions in
> Dwarf.cpp, but AFAICS it doesn’t duplicate anything. But maybe I’m looking
> at the wrong place?
>
>
> My apologies, you are correct! That email went out too fast.
>
> -- adrian
>
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20140903/668d5857/attachment.html>


More information about the llvm-commits mailing list