[PATCH] D91678: Symbolizer test for Basic block sections

Sriraman Tallam via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Nov 17 20:15:17 PST 2020


tmsriram created this revision.
tmsriram added reviewers: saugustine, dblaikie.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
tmsriram requested review of this revision.

This adds a new test checking llvm-symbolizer with a binary built with basic block sections.

Build a binary with -fbasic-block-sections and reorder the basic blocks to be non-contiguous.  Then check if llvm-symbolizer correctly reports the symbolized addresses.  I have included the source to build the binary with full command lines.


https://reviews.llvm.org/D91678

Files:
  llvm/test/DebugInfo/Inputs/llvm-symbolizer-bbsections-test.c
  llvm/test/DebugInfo/Inputs/llvm-symbolizer-bbsections-test.elf-x86-64
  llvm/test/DebugInfo/symbolize-bbsections.test


Index: llvm/test/DebugInfo/symbolize-bbsections.test
===================================================================
--- /dev/null
+++ llvm/test/DebugInfo/symbolize-bbsections.test
@@ -0,0 +1,10 @@
+RUN: llvm-symbolizer --obj=%p/Inputs/llvm-symbolizer-bbsections-test.elf-x86-64 0x201740 0x201750 0x201760 0x2017bf| FileCheck %s
+
+CHECK:      main
+CHECK-NEXT: llvm-symbolizer-bbsections-test.c:18
+CHECK:      g
+CHECK-NEXT: llvm-symbolizer-bbsections-test.c:5
+CHECK:      main
+CHECK-NEXT: llvm-symbolizer-bbsections-test.c:13
+CHECK:      main
+CHECK-NEXT: llvm-symbolizer-bbsections-test.c:17
Index: llvm/test/DebugInfo/Inputs/llvm-symbolizer-bbsections-test.c
===================================================================
--- /dev/null
+++ llvm/test/DebugInfo/Inputs/llvm-symbolizer-bbsections-test.c
@@ -0,0 +1,37 @@
+// This is used to generate llvm-symbolizer-bbsections-test.elf-x86-64.
+// $ cat > syms.txt
+// main.4
+// g
+// main
+// f
+// main.1
+// h
+// main.3
+// _start
+// main.2
+// $
+// $ clang -fbasic-block-sections=all llvm-symbolizer-bbsections-test.c \
+//   -fuse-ld=lld -Wl,--symbol-ordering-file,syms.txt
+
+int f(int a) {
+  return a + 1;
+}
+
+int g(int a) {
+  return a + 2;
+}
+
+int h(int a) {
+  return a + 3;
+}
+
+// Use simple control flow to generate lots of basic block sections.
+int main(int argc, char *argv[]) {
+  if (argc > 10)
+    return f(argc);
+  else if (argc > 8)
+    return g(argc);
+  else if (argc > 4)
+    return h(argc);
+  return 0;
+}


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D91678.305962.patch
Type: text/x-patch
Size: 1510 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20201118/29a427da/attachment.bin>


More information about the llvm-commits mailing list