tools: bpftool: Document and add bash completion for -L, -B options
[linux-2.6-microblaze.git] / tools / bpf / bpftool / Documentation / bpftool-prog.rst
index 4b8412f..2ea5df3 100644 (file)
@@ -13,7 +13,8 @@ SYNOPSIS
        **bpftool** [*OPTIONS*] **prog** *COMMAND*
 
        *OPTIONS* := { { **-j** | **--json** } [{ **-p** | **--pretty** }] | { **-d** | **--debug** } |
-               { **-f** | **--bpffs** } | { **-m** | **--mapcompat** } | { **-n** | **--nomount** } }
+               { **-f** | **--bpffs** } | { **-m** | **--mapcompat** } | { **-n** | **--nomount** } |
+               { **-L** | **--use-loader** } }
 
        *COMMANDS* :=
        { **show** | **list** | **dump xlated** | **dump jited** | **pin** | **load**
@@ -224,6 +225,20 @@ OPTIONS
                  Do not automatically attempt to mount any virtual file system
                  (such as tracefs or BPF virtual file system) when necessary.
 
+       -L, --use-loader
+                 Load program as a "loader" program. This is useful to debug
+                 the generation of such programs. When this option is in
+                 use, bpftool attempts to load the programs from the object
+                 file into the kernel, but does not pin them (therefore, the
+                 *PATH* must not be provided).
+
+                 When combined with the **-d**\ \|\ **--debug** option,
+                 additional debug messages are generated, and the execution
+                 of the loader program will use the **bpf_trace_printk**\ ()
+                 helper to log each step of loading BTF, creating the maps,
+                 and loading the programs (see **bpftool prog tracelog** as
+                 a way to dump those messages).
+
 EXAMPLES
 ========
 **# bpftool prog show**
@@ -327,3 +342,16 @@ EXAMPLES
       40176203 cycles                                                 (83.05%)
       42518139 instructions    #   1.06 insns per cycle               (83.39%)
            123 llc_misses      #   2.89 LLC misses per million insns  (83.15%)
+
+|
+| Output below is for the trace logs.
+| Run in separate terminals:
+| **# bpftool prog tracelog**
+| **# bpftool prog load -L -d file.o**
+
+::
+
+    bpftool-620059  [004] d... 2634685.517903: bpf_trace_printk: btf_load size 665 r=5
+    bpftool-620059  [004] d... 2634685.517912: bpf_trace_printk: map_create sample_map idx 0 type 2 value_size 4 value_btf_id 0 r=6
+    bpftool-620059  [004] d... 2634685.517997: bpf_trace_printk: prog_load sample insn_cnt 13 r=7
+    bpftool-620059  [004] d... 2634685.517999: bpf_trace_printk: close(5) = 0