错误log:
[ 55.132887] Unable to handle kernel paging request at virtual address 0000676d
[ 55.140503] pgd = c0004000
[ 55.143278] [0000676d] *pgd=00000000
[ 55.147001] Internal error: Oops: 5 [#1] PREEMPT SMP
[ 55.152084] Modules linked in: ssd1306 rtk_btusb
[ 55.156985] CPU: 1 Tainted: G W (3.0.35-gcbc3f7a4c9f-dirty #43)
[ 55.164158] PC is at i2c_smbus_xfer+0x8/0x564
[ 55.168580] LR is at i2c_smbus_read_byte_data+0x58/0xac
[ 55.173922] pc : [<c0413964>] lr : [<c04141d0>] psr: 200f0013
[ 55.173927] sp : d4057eac ip : d4057ee6 fp : 00000089
[ 55.185587] r10: c0046840 r9 : 00007069 r8 : c0a04b5c
[ 55.190874] r7 : d4725000 r6 : c09b4440 r5 : 00000008 r4 : c0878290
[ 55.197517] r3 : 00000001 r2 : 00005f66 r1 : 00007069 r0 : 00006765
[ 55.204111] Flags: nzCv IRQs on FIQs on Mode SVC_32 ISA ARM Segment kernel
[ 55.211536] Control: 10c53c7d Table: 2082404a DAC: 00000015
上面红字“PC is at i2c_smbus_xfer+0x8/0x564”说明,PC指针指向出问题函数的地址,出问题的函数是i2c_smbus_xfer,那他的地址是多少呢?
找到System.map所在位置,执行如下命令
root@root:~/android-work/kernel_imx$ grep i2c_smbus_xfer ./System.map
c041395c T i2c_smbus_xfer
c08b18d0 r __ksymtab_i2c_smbus_xfer
c08bc21c r __kcrctab_i2c_smbus_xfer
c08d220d r __kstrtab_i2c_smbus_xfer
这句日志最后[ 55.164158] PC is at i2c_smbus_xfer+0x8/0x564, 0x564是i2c_smbus_xfer函数的大小,0x8是i2c_smbus_xfer函数的地址偏移。
结合错误日志c041395c就是i2c_smbus_xfer的地址,i2c_smbus_xfer+0x8即0xc041395c+0x8=0xc0413964,这就对上了这句话:[ 55.173922] pc : [<c0413964>] lr : [<c04141d0>] psr: 200f0013
下面用GDB工具具体定位:
root@root:~/android-work/kernel_imx$ gdb ./vmlinux
GNU gdb (Ubuntu 7.7.1-0ubuntu5~14.04.3) 7.7.1
Copyright (C) 2014 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law. Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from ./vmlinux...done.
(gdb) b *0xc0413964
Breakpoint 1 at 0xc0413964: file drivers/i2c/i2c-core.c, line 2098.
(gdb)