[PATCH] D105258: [llvm-readobj][MachO] Support option --unwind for __eh_frame

Greg Clayton via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Jul 1 13:56:35 PDT 2021


clayborg added a comment.

If we need to cross check between the two outputs (__eh_frame and __unwind_info), do we want some sort of intermediate output so we can see the unwind info organized by address instead of random order?



================
Comment at: llvm/tools/llvm-readobj/MachODumper.cpp:726-734
+      W.startLine() << format("[0x%" PRIx64 "] CIE length=%" PRIu64 "\n",
+                              Address + CIE->getOffset(), CIE->getLength());
+      W.indent();
+
+      W.printNumber("version", CIE->getVersion());
+      W.printString("augmentation", CIE->getAugmentationString());
+      W.printNumber("code_alignment_factor", CIE->getCodeAlignmentFactor());
----------------
I am assuming we must print this all in this code so we can use the "W" dumper (as opposed to telling the CIE to dump itself to a raw_ostream)?


================
Comment at: llvm/tools/llvm-readobj/MachODumper.cpp:743-746
+      W.startLine() << format("initial_location: 0x%" PRIx64 "\n",
+                              FDE->getInitialLocation());
+      W.startLine() << format(
+          "address_range: 0x%" PRIx64 " (end : 0x%" PRIx64 ")\n",
----------------
I really don't like how the FDE calls is start address "initial location" and the address range size "address range". Granted this is how it is documented in the DWARF spec, but I am not a huge fan of these names. If you need it the output to be true to the specficiation, then this is ok. But in general, I would much rather see a printed address range in the output something like:

```
range: [0x1000-0x2000)
```
instead of
```
initial_location: 0x1000
address_range: 0x1000 (end: 0x2000)
```

Also make sure that the start address range has been relocated. In the actual data it is PC relative, just make sure the address range makes sense and matches what llvm-dwarfdump outputs in its output:
```
00000018 0000001c 0000001c FDE cie=00000000 pc=00004d50...00004d6a
```


================
Comment at: llvm/tools/llvm-readobj/MachODumper.cpp:748
+          FDE->getAddressRange(),
+          FDE->getInitialLocation() + FDE->getAddressRange());
+    }
----------------
FYI: you can easily dump the unwind info for each FDE to show the unwind info in the row. The output looks like:
```
00000018 0000001c 0000001c FDE cie=00000000 pc=00004d50...00004d6a
  Format:       DWARF32
  DW_CFA_nop:
  DW_CFA_nop:
  DW_CFA_nop:
  DW_CFA_nop:
  DW_CFA_nop:
  DW_CFA_nop:
  DW_CFA_nop:

  0x4d50: CFA=RSP+8: RIP=[CFA-8]
```

The last line dumps all of the rows that the FDE defines. Might be handy to include this information. 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105258



More information about the llvm-commits mailing list