[llvm] [llvm-readobj] Dump callgraph section info for ELF (PR #157499)
Paul Kirth via llvm-commits
llvm-commits at lists.llvm.org
Mon Sep 22 14:06:10 PDT 2025
================
@@ -0,0 +1,191 @@
+## Tests --call-graph-info prints information from call graph section.
+
+# REQUIRES: x86-registered-target
+
+# RUN: llvm-mc %s -filetype=obj -triple=x86_64-pc-linux -o %t
+# RUN: llvm-readelf --call-graph-info %t 2>&1 | FileCheck %s -DFILE=%t --match-full-lines
+# RUN: llvm-readelf --elf-output-style=LLVM --call-graph-info %t 2>&1 | FileCheck %s --match-full-lines -DFILE=%t --check-prefix=LLVM
+# RUN: llvm-readelf --elf-output-style=JSON --pretty-print --call-graph-info %t 2>&1 | FileCheck %s --match-full-lines -DFILE=%t --check-prefix=JSON
+
+# CHECK: {{.*}}llvm-readelf{{.*}}: warning: '[[FILE]]': .callgraph section has unknown type id for 1 indirect targets.
+# CHECK-NEXT: Per-function call graph information::
+# CHECK-EMPTY:
+# CHECK-NEXT: Function:: foo
+# CHECK-NEXT: Function PC:: 0x0
+# CHECK-NEXT: FormatVersionNumber:: 0
+# CHECK-NEXT: Function Kind:: NOT_INDIRECT
+# CHECK-NEXT: Indirect callee count:: 0
+# CHECK-NEXT: Direct callee count:: 1
+# CHECK-NEXT: {
+# CHECK-NEXT: CalleePC:: 0x5
+# CHECK-NEXT: }
+# CHECK-EMPTY:
+# CHECK-NEXT: Function:: bar
+# CHECK-NEXT: Function PC:: 0x6
+# CHECK-NEXT: FormatVersionNumber:: 0
+# CHECK-NEXT: Function Kind:: UNKNOWN_TID
+# CHECK-NEXT: Indirect callee count:: 1
+# CHECK-NEXT: {
+# CHECK-NEXT: callsite: 0x9
+# CHECK-NEXT: calleeTypeId: 0x10
+# CHECK-NEXT: }
+# CHECK-NEXT: Direct callee count:: 0
+# CHECK-EMPTY:
+# CHECK-NEXT: Function:: baz
+# CHECK-NEXT: Function PC:: 0xa
+# CHECK-NEXT: FormatVersionNumber:: 0
+# CHECK-NEXT: Function Kind:: KNOWN_TID
+# CHECK-NEXT: Function Type ID:: 0x20
+# CHECK-NEXT: Indirect callee count:: 0
+# CHECK-NEXT: Direct callee count:: 0
----------------
ilovepi wrote:
shouldn't this section fail when you do json(and I guess llvm too) output? CHECK lines are always checked no matter the prefix.
https://github.com/llvm/llvm-project/pull/157499
More information about the llvm-commits
mailing list