Telem GW kernel debug

From Phobos Wiki
Revision as of 12:25, 3 March 2015 by MarkTomm (talk | contribs)
Jump to navigation Jump to search

Kernel Conf

Additions

  • Kernel Hacking
    • KGDB: kernel debugger
      • KGDB: use kgdb over the serial console
      • KGDB_KDB: include kdb frontend for kgdb
    • Kernel memory leak detector
    • (40000) Maximum kmemleak early log entries
    • Tracers
      • Kernel Function Tracer
      • Trace max Stack
      • Trace SLAB allocations
      • Kernel function profiler
    • Linux Kernel Dump Test Tool Module
    • Fault-injection framework
      • Fault-injection capability for kmalloc
      • Fault-injection capability for allow_pages()
      • Fault-injection capability for disk IO
      • Fault-injection capability for faking disk interrupts
      • Debugfs entries for fault-injection capabilities
        • stacktrace filter for fault-injection capabilities
    • Enable stack utilization instrumentation

Other

Add kernel boot argument

console=ttymxc0


Add

nodev   /sys/kernel/debug      debugfs  defaults          0      0

at the end of buildroot/system/skeleton/etc/fstab

Various Details

Kernel Hacking Configuration Options Details

KGDB: kernel debugger

KGDB: kernel debugger

menuconfig KGDB
        bool "KGDB: kernel debugger"
        depends on HAVE_ARCH_KGDB
        depends on DEBUG_KERNEL && EXPERIMENTAL
        help
          If you say Y here, it will be possible to remotely debug the
          kernel using gdb.  It is recommended but not required, that
          you also turn on the kernel config option
          CONFIG_FRAME_POINTER to aid in producing more reliable stack
          backtraces in the external debugger.  Documentation of
          kernel debugger is available at http://kgdb.sourceforge.net
          as well as in DocBook form in Documentation/DocBook/.

KGDB: use kgdb over the serial console

config KGDB_SERIAL_CONSOLE
        tristate "KGDB: use kgdb over the serial console"
        select CONSOLE_POLL
        select MAGIC_SYSRQ
        default y
        help
          Share a serial console with kgdb. Sysrq-g must be used
          to break in initially.

KGDB_KDB: include kdb frontend for kgdb

config KGDB_KDB
        bool "KGDB_KDB: include kdb frontend for kgdb"
        default n
        help
          KDB frontend for kernel

Kernel memory leak detector

Kernel memory leak detector

config DEBUG_KMEMLEAK
        bool "Kernel memory leak detector"
        depends on DEBUG_KERNEL && EXPERIMENTAL && !MEMORY_HOTPLUG && \
                (X86 || ARM || PPC || S390 || SPARC64 || SUPERH || MICROBLAZE)

        select DEBUG_FS if SYSFS
        select STACKTRACE if STACKTRACE_SUPPORT
        select KALLSYMS
        select CRC32
        help
          Say Y here if you want to enable the memory leak
          detector. The memory allocation/freeing is traced in a way
          similar to the Boehm's conservative garbage collector, the
          difference being that the orphan objects are not freed but
          only shown in /sys/kernel/debug/kmemleak. Enabling this
          feature will introduce an overhead to memory
          allocations. See Documentation/kmemleak.txt for more
          details.

          Enabling DEBUG_SLAB or SLUB_DEBUG may increase the chances
          of finding leaks due to the slab objects poisoning.

          In order to access the kmemleak file, debugfs needs to be
          mounted (usually at /sys/kernel/debug).

40000) Maximum kmemleak early log entries

Tracers

Kernel Function Tracer

config FUNCTION_TRACER
        bool "Kernel Function Tracer"
        depends on HAVE_FUNCTION_TRACER
        select FRAME_POINTER
        select KALLSYMS
        select GENERIC_TRACER
        select CONTEXT_SWITCH_TRACER
        help
          Enable the kernel to trace every kernel function. This is done
          by using a compiler feature to insert a small, 5-byte No-Operation
          instruction at the beginning of every kernel function, which NOP
          sequence is then dynamically patched into a tracer call when
          tracing is enabled by the administrator. If it's runtime disabled
          (the bootup default), then the overhead of the instructions is very
          small and not measurable even in micro-benchmarks.

Trace max Stack

config STACK_TRACER
        bool "Trace max stack"
        depends on HAVE_FUNCTION_TRACER
        select FUNCTION_TRACER
        select STACKTRACE
        select KALLSYMS
        help
          This special tracer records the maximum stack footprint of the
          kernel and displays it in /sys/kernel/debug/tracing/stack_trace.

          This tracer works by hooking into every function call that the
          kernel executes, and keeping a maximum stack depth value and
          stack-trace saved.  If this is configured with DYNAMIC_FTRACE
          then it will not have any overhead while the stack tracer
          is disabled.

          To enable the stack tracer on bootup, pass in 'stacktrace'
          on the kernel command line.

          The stack tracer can also be enabled or disabled via the
          sysctl kernel.stack_tracer_enabled

Trace SLAB allocations

config KMEMTRACE
        bool "Trace SLAB allocations"
        select GENERIC_TRACER
        help
          kmemtrace provides tracing for slab allocator functions, such as
          kmalloc, kfree, kmem_cache_alloc, kmem_cache_free, etc. Collected
          data is then fed to the userspace application in order to analyse
          allocation hotspots, internal fragmentation and so on, making it
          possible to see how well an allocator performs, as well as debug
          and profile kernel code.

          This requires an userspace application to use. See
          Documentation/trace/kmemtrace.txt for more information.

          Saying Y will make the kernel somewhat larger and slower. However,
          if you disable kmemtrace at run-time or boot-time, the performance
          impact is minimal (depending on the arch the kernel is built for).

Kernel function profiler

config FUNCTION_PROFILER
        bool "Kernel function profiler"
        depends on FUNCTION_TRACER
        default n
        help
          This option enables the kernel function profiler. A file is created
          in debugfs called function_profile_enabled which defaults to zero.
          When a 1 is echoed into this file profiling begins, and when a
          zero is entered, profiling stops. A "functions" file is created in
          the trace_stats directory; this file shows the list of functions that
          have been hit and their counters.

Linux Kernel Dump Test Tool Module

Linux Kernel Dump Test Tool Module

config LKDTM
        tristate "Linux Kernel Dump Test Tool Module"
        depends on DEBUG_FS
        depends on BLOCK
        default n
        help
        This module enables testing of the different dumping mechanisms by
        inducing system failures at predefined crash points.
        If you don't need it: say N
        Choose M here to compile this code as a module. The module will be
        called lkdtm.

        Documentation on how to use the module can be found in
        Documentation/fault-injection/provoke-crashes.txt

Fault-injection framework

Fault-injection framework

config FAULT_INJECTION
        bool "Fault-injection framework"
        depends on DEBUG_KERNEL
        help
          Provide fault-injection framework.
          For more details, see Documentation/fault-injection/.

Fault-injection capability for kmalloc

config FAILSLAB
        bool "Fault-injection capability for kmalloc"
        depends on FAULT_INJECTION
        depends on SLAB || SLUB
        help
          Provide fault-injection capability for kmalloc.

Fault-injection capability for allow_pages()

config FAIL_PAGE_ALLOC
        bool "Fault-injection capabilitiy for alloc_pages()"
        depends on FAULT_INJECTION
        help
          Provide fault-injection capability for alloc_pages().

Fault-injection capability for disk IO

config FAIL_MAKE_REQUEST
        bool "Fault-injection capability for disk IO"
        depends on FAULT_INJECTION && BLOCK
        help
          Provide fault-injection capability for disk IO.

Fault-injection capability for faking disk interrupts

config FAIL_IO_TIMEOUT
        bool "Faul-injection capability for faking disk interrupts"
        depends on FAULT_INJECTION && BLOCK
        help
          Provide fault-injection capability on end IO handling. This
          will make the block layer "forget" an interrupt as configured,
          thus exercising the error handling.

          Only works with drivers that use the generic timeout handling,
          for others it wont do anything.

Debugfs entries for fault-injection capabilities

config FAULT_INJECTION_DEBUG_FS
        bool "Debugfs entries for fault-injection capabilities"
        depends on FAULT_INJECTION && SYSFS && DEBUG_FS
        help
          Enable configuration of fault-injection capabilities via debugfs.

stacktrace filter for fault-injection capabilities

config FAULT_INJECTION_STACKTRACE_FILTER
        bool "stacktrace filter for fault-injection capabilities"
        depends on FAULT_INJECTION_DEBUG_FS && STACKTRACE_SUPPORT
        depends on !X86_64
        select STACKTRACE
        select FRAME_POINTER if !PPC && !S390
        help
          Provide stacktrace filter for fault-injection capabilities

Enable stack utilization instrumentation

Enable stack utilization instrumentation

config DEBUG_STACK_USAGE
        bool "Enable stack utilization instrumentation"
        depends on DEBUG_KERNEL
        help
          Enables the display of the minimum amount of free stack which each
          task has ever had available in the sysrq-T output.


MarkTomm 3. märts 2015, kell 14:25 (EET)