rtfaults.txt
1 Finding line number information for faults in realtime components 2 3 1. Get a version of LinuxCNC which prints the faulting instruction address 4 (that includes this version of LinuxCNC) 5 6 2. Include debugging info in your modules. For built-in modules, 7 below the definition of EXTRA_CFLAGS in Makefile, add 8 EXTRA_CFLAGS += -g 9 For standalone modules, add the same line just above the line 10 ifeq ($(BUILDSYS),kbuild) 11 and (re)build the component 12 13 3. Run hal until the fault occurs. DO NOT EXIT THE HAL SESSION YET. You 14 must find the start of the module (step 5) first. 15 16 4. Note the ip (instruction pointer) address in dmesg. e.g.: 17 RTAPI: Task 1[c2800000]: Fault with vec=14, signo=11 ip=c93dc01a. 18 ^^^^^^^^ 19 5. Find the module which contains the offending IP. 20 $cat /proc/modules 21 motmod 142230 0 - Live 0xc93df000 22 fault 1626 1 motmod, Live 0xc93dc000 23 hal_lib 30517 2 motmod,fault, Live 0xc93d5000 24 25 Now you can exit hal/emc2. 26 27 6. Subtract the start of the module from the faulting ip (in this case, 0x1a) 28 Among other ways to do this, you can use the shell: 29 $ printf "0x%x\n" $((0xc93dc01a-0xc93dc000)) 30 0x1a 31 32 7. Use addr2line to find out the source code line: 33 $ addr2line -e emc2-dev/src/fault.ko 0x1a 34 /usr/src/linux-headers-2.6.32-122-rtai/hal/components/fault.comp:9 35 Ignore how the directory name is wrong and see whether this has helped you 36 localize the problem: 37 fault.comp:9 *(int*)0 = 0; 38 Yup! Looks like it has. 39 40 Note that even if you do not prefix the address argument to addr2line 41 with 0x, it is taken to be a hex number, and you'll get the wrong 42 line-number information. Take care to always use hex addresses with 43 addr2line.