# Debug and *trace options in the kernel config



## tommyhp2 (Apr 3, 2019)

Hi,

I'm trying to get VirtIO driver to work on PCIe bus.  In the midst of my troubleshooting, I decided to turn on kernel debug and the various trace options like the default GENERIC:


```
root@fbsd12:~ # diff Custom12 Custom12_dbg
24,25c24,25
< #makeoptions  DEBUG=-g                # Build kernel with gdb(1) debug symbols
< #makeoptions  WITH_CTF=1              # Run ctfconvert(1) for DTrace support
---
> makeoptions   DEBUG=-g                # Build kernel with gdb(1) debug symbols
> makeoptions   WITH_CTF=1              # Run ctfconvert(1) for DTrace support
67c67
< #options      KTRACE                  # ktrace(1) support
---
> options       KTRACE                  # ktrace(1) support
80,81c80,81
< #options      KDTRACE_FRAME           # Ensure frames are compiled in
< #options      KDTRACE_HOOKS           # Kernel DTrace hooks
---
> options       KDTRACE_FRAME           # Ensure frames are compiled in
> options       KDTRACE_HOOKS           # Kernel DTrace hooks
89,90c89,90
< #options      KDB                     # Enable kernel debugger support.
< #options      KDB_TRACE               # Print a stack trace for a panic.
---
> options       KDB                     # Enable kernel debugger support.
> options       KDB_TRACE               # Print a stack trace for a panic.
93,96c93,96
< #options      EKCD                    # Support for encrypted kernel dumps
< #options      GZIO                    # gzip-compressed kernel and user dumps
< #options      ZSTDIO                  # zstd-compressed kernel and user dumps
< #options      NETDUMP                 # netdump(4) client support
---
> options       EKCD                    # Support for encrypted kernel dumps
> options       GZIO                    # gzip-compressed kernel and user dumps
> options       ZSTDIO                  # zstd-compressed kernel and user dumps
> options       NETDUMP                 # netdump(4) client support
362c362
< #device               netmap                  # netmap(4) support
---
> device                netmap                  # netmap(4) support
```

It seems that the above options broke the PCIe driver some how...  When the debug, traces, and netmap removed from the kernel,  PCIe root port are detected properly as seen in pciconf:


```
pcib1@pci0:0:2:0:       class=0x060400 card=0x00001b36 chip=0x000c1b36 rev=0x00 hdr=0x01
    vendor     = 'Red Hat, Inc.'
    device     = 'QEMU PCIe Root port'
    class      = bridge
    subclass   = PCI-PCI
    cap 10[54] = PCI-Express 2 root port max data 128(128) ARI disabled
                 link x1(x1) speed 2.5(2.5) ASPM disabled(L0s)
                 slot 0 power limit 0 mW HotPlug(present) surprise Attn Button PC(on) EI(disengaged)
    cap 11[48] = MSI-X supports 1 message
                 Table in map 0x10[0x0], PBA in map 0x10[0x800]
    cap 0d[40] = PCI Bridge card=0x00001b36
    ecap 0001[100] = AER 2 0 fatal 0 non-fatal 0 corrected
```

With debug and traces enabled, the above PCIe controller becomes like the original kernel from the install ISO:


```
none0@pci0:0:2:0:       class=0x060400 card=0x00001b36 chip=0x000c1b36 rev=0x00 hdr=0x01
    vendor     = 'Red Hat, Inc.'
    device     = 'QEMU PCIe Root port'
    class      = bridge
    subclass   = PCI-PCI
    bar   [10] = type Memory, range 32, base 0xfd212000, size 4096, enabled
    bus range  = 1-1
    window[1c] = type I/O Port, range 16, addr 0xe000-0xdfff, disabled
    window[20] = type Memory, range 32, addr 0xfd000000-0xfd1fffff, enabled
    window[24] = type Prefetchable Memory, range 64, addr 0xfea00000-0xfebfffff, enabled
    cap 10[54] = PCI-Express 2 root port max data 128(128) ARI disabled
                 link x1(x1) speed 2.5(2.5) ASPM disabled(L0s)
                 slot 0 power limit 0 mW HotPlug(present) surprise Attn Button PC(on) EI(disengaged)
    cap 11[48] = MSI-X supports 1 message
                 Table in map 0x10[0x0], PBA in map 0x10[0x800]
    cap 0d[40] = PCI Bridge card=0x00001b36
    ecap 0001[100] = AER 2 0 fatal 0 non-fatal 0 corrected
```

Is this behavior by design?

Thanks,
Tommy


Attachments:

Custom12 - kernel config:  debug, trace, COMPAT*, and unneeded drivers removed
Custom12_dbg - kernel debug config - same as above with with debug, traces, and netmap enabled
messages_12.0_r341666_ori - verbose logging of the original kernel from the install ISO
messages_12.0_r345840 - verbose logging of the updated kernel *without* debug, trace, and netmap
messages_12.0_r345840_dbg - verbose logging of the updated kernel *with* debug, trace, and netmap


----------

