[PATCH] D57365: [llvm-readobj] Add a flag to dump just the section-to-segment mapping.

George Rimar via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Jan 30 02:27:29 PST 2019


grimar added inline comments.


================
Comment at: llvm/test/tools/llvm-readobj/gnu-phdrs.test:26
+RUN: llvm-readelf -section-mapping %p/Inputs/phdrs-elf.exe-x86_64 \
+RUN:   | not grep "Program Headers:"
+
----------------
jhenderson wrote:
> Using grep in lit has been deprecated, I believe. Use FileCheck `CHECK-NOT` patterns.
> 
> You can do the checking that the program headers are not present at the same time as the section mapping test, by using careful placement of the NOT patterns. NOT patterns fail if the output appears between the two positive checks either side of the NOT (or the start/end of file if there are none before/after it). Example that would fail if "Program Headers:" appears before or after the section mapping:
> ```
> CHECK-NOT: Program Headers:
> CHECK: Mapping
> CHECK-NOT: Program Headers:
> ```
> You can even use `check-prefixes` to share check patterns in a mix-and-match kind of way to avoid duplicating common things. All the names get added to one big bucket. When FileCheck scans the file for patterns it uses any with a matching prefix, in sequence, regardless of which prefix (i.e. the order of prefixes in the option is irrelevant).
> 
> For example, for the following case, using `FileCheck --check-prefixes=NO-PHDRS,CHECK` would be the equivalent of the above test case, whilst `FileCheck --check-prefixes=PHDRS,CHECK`  or `FileCheck --check-prefixes=CHECK,PHDRS` would match the program headers followed by the mapping. I think you could even use `FileCheck --check-prefixes=NO-PHDRS,CHECK,PHDRS` to show that the Program Headers appear followed by the mapping, but that no more program headers appear after the mapping (I'm not quite sure whether the first NO-PHDRS-NOT would have any effect in this case though).
> ```
> NO-PHDRS-NOT: Program Headers:
> PHDRS: Program Headers:
> CHECK: Mapping
> NO-PHDRS-NOT: Program Headers:
> ```
> 
> Using grep in lit has been deprecated, I believe. Use FileCheck CHECK-NOT patterns.

Oh, I wanted to write the same comment at first but found that `grep` is also used in LLVM. I did not realize it is deprecated, supposed we just use both ways.


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

https://reviews.llvm.org/D57365





More information about the llvm-commits mailing list