Linux Debugging Reference Card
Total Page:16
File Type:pdf, Size:1020Kb
Version 2.2 ;Connect to boot core only Load Linux Awareness for v3.x/v4.x CORE.ASSIGN <physical boot core> TASK.CONFIG \ ~~/demo/<arch>/kernel/linux/linux-3.x/linux3.t32 ;Connect debugger and try to stop at reset vector MENU.ReProgram \ SYStem.Up ~~/demo/<arch>/kernel/linux/linux-3.x/linux.men Define Groups ;Let bootloader (e.g. U-Boot) initialize the system GROUP.Create "kernel" \ Go <kernel virtual address range> /RED WAIT 5.s Break Linux Debugging Reference Card Linux Resource Displays ;Load FIT image (Flattened-Image-Tree) to physical address Processes ;Linux menu Display Processes This reference card gives you an overview of frequently-used Data.LOAD.Binary image.FIT <phys.addr> TRACE32® commands for debugging targets running Linux TASK.Process ;Load kernel symbols (stop mode). Detailed task info Data.LOAD.Elf vmlinux /NoCODE ;Linux menu Display Processes Display Tasks Configure Linux for Debugging ;Continue bootloader – set temporary breakpoint to ‘start_kernel’ TASK.DTask "<name>" Compile kernel with debug info CONFIG_DEBUG_INFO=y Go start_kernel /Onchip "ps" #CONFIG_DEBUG_INFO_REDUCED not set ;Patch bootargs for debugging (in terminal window) ;Linux menu Display ps-like For module debugging set CONFIG_KALLSYMS=y setenv bootargs … nowatchdog \ TASK.PS Trace and task specific CONFIG_PID_IN_CONTEXTIDR=y breakpoints (ARM only) rcupdate.rcu_cpu_stall_suppress=1 File system internals ;Linux menu Display File System Disable KASLR (x86/x64 only) #CONFIG_RANDOMIZE_BASE not set ;Start FIT image with bootloader (in terminal window) TASK.FS.* Compile applications with option -g bootm <phys.addr> Kernel log buffer ;Wait until breakpoint (at start_kernel) is hit Attach to a Running Linux Target ;Linux menu Display Kernel Log WAIT !STATE.RUN() ;Initialize debugger TASK.DMESG Continue with Configure Linux Awareness. Actual sequence Device tree blob SYStem.CPU <cpu> heavily depends on target system and loading mechanisms. SYStem.Option <option> ;Linux menu Device Tree ;Enable space IDs TASK.DTB SYStem.Option MMUSPACES ON Configure Linux Awareness ;Connect debugger without reset assertion Debug Processes Mandatory for Userspace and Module debugging. Display processes SYStem.Mode Attach Examples available: . Break ~~/demo/<arch>/kernel/linux/boards ;Linux menu Display Processes ;Load kernel symbols MMU Declaration TASK.Process Data.LOAD.Elf vmlinux /NoCODE MMU.FORMAT LINUX swapper_pg_dir \ Configure symbol loader Continue with Configure Linux Awareness. Actual sequence heavily <virtual address range of swapper_pg_dir>\ ;Linux menu Symbol Autoloader <physical start address> depends on target system. TASK.sYmbol.Option AutoLoad Process TRANSlation.TableWalk ON TRANSlation.ON Start debugging at main() Download and Run Linux with TRACE32 ;Linux menu Process Debugging Debug new Process Define Common Range ;Initialize debugger DO ~~/demo/<arch>/kernel/linux/linux-3.x/ \ TRANSlation.COMMON \ app_debug <process> SYStem.CPU <cpu> <kernel+module virtual address range> SYStem.Option <option> Watch process starts ;Enable space IDs ;Linux menu Process Debugging Watch Processes SYStem.Option MMUSPACES ON TASK.Watch www.lauterbach.com Load symbols for running processes SMP Support Trace-based Task Profiling ;Linux menu Display Processes Right click on "magic" Setup Attach Debugging Display task switches Load Process Symbols The debugger automatically selects all cores Trace.List List.TASK /DEFault TASK.sYmbol.LOAD "<name>" Statistics when executing SYStem.CPU <cpu>. ;Perf menu Task runtime Show numerical Show thread context Start Debugging ;Linux menu Display Processes Right click on "magic" Trace.STATistic.TASK Use CORE.ASSIGN to select the physical boot Display Stack Frame core and switch to SMP after smp_init_done Charts Frame /TASK "<name>" is called. ;Perf menu Task runtime Show graphical Thread specific breakpoints Go smp_init_done Trace.Chart.TASK WAIT !STATE.RUN() TrOnchip.ContextID ON ;Set to ON (ARM only) ;Select breakpoint advanced TASK SYStem.Mode Down Trace-based Function Profiling Break.Set <addr> /TASK "<name>" CORE.ASSIGN 1. 2. … SYStem.Mode Attach Statistics ;Perf menu Task function runtime Show numerical View Debugger shows context of one core. Debug Libraries Trace.STATistic.Func State line shows current core number. Display libraries ;Filter specific task in the recorded trace e.g. offchip-trace ;Linux menu Display Processes right-click on "magic" Data/Register windows change color. Display maps Change core Right-click on core number in state line. Trace.STATistic.Func /TASK "<name>" TASK.MAPS "<name>" Use CORE.select <x> command. Charts Use option in window context. ;Perf menu Task function runtime Show graphical Configure symbol loader /CORE <x> ;Linux menu Symbol Autoloader Breakpoints Are set on all cores, current view switches Trace.Chart.Func automatically to core that hits the breakpoint. ;Filter specific task in the recorded trace e.g. offchip-trace TASK.sYmbol.Option AutoLoad Library Trace.Chart.Func /TASK "<name>" Load symbols ;Display maps Right-click on library "magic" Configure Trace-based Task Detection Load Library Symbols Using data trace (e.g. PowerPC) Documentation / Help / Support TASK.sYmbol.LOADLib <proc> <lib> Break.Set TASK.CONFIG(magic) /Write /TraceData User manuals pdf/rtos_linux_stop.pdf Using Context ID (ARM only) pdf/rtos_linux_run.pdf Debug Kernel Modules ETM.ContextID 32 Training manual pdf/training_rtos_linux.pdf Display modules ;Linux menu Display Modules pdf/training_rtos_linux_x86.pdf TASK.MODule Filter Trace Recording Example scripts demo/<arch>/kernel/linux Generic syntax Configure symbol loader Support local sales offices, Break.Set <space ID>:<virtual address range> ;Linux menu Symbol Autoloader [email protected] /TraceEnable TASK.sYmbol.Option AutoLoad Module Example: Filter Kernel function __switch_to Start debugging at module init routine Var.Break.Set __switch_to /TraceEnable ;Linux menu Module Debugging Debug Module on init Example: Filter Kernel, Modules, Userspace running in Task context DO ~~/demo/<arch>/kernel/linux/linux-3.x/ \ mod_debug <module> ;Linux menu Display Processes right-click on "magic" trace this task Load module symbols Break.Set <space ID>:0x0--0xffffffffffffffff ;Linux menu Display Modules Right click on "magic" /TraceEnable ;Use to adapt range e.g. to Load Module Symbols TASK.MAPS "<name>" ;task+libraries TASK.sYmbol.LOADMod "<name>" www.lauterbach.com Lauterbach GmbH • Altlaufstraße 40 • 85635 Höhenkirchen • [email protected] .