小碼哥

          誰(shuí)謂河廣,一葦杭之

             :: 首頁(yè) :: 新隨筆 :: 聯(lián)系 :: 聚合  :: 管理 ::
            7 隨筆 :: 17 文章 :: 74 評(píng)論 :: 0 Trackbacks

          常用鏈接

          留言簿(21)

          隨筆分類(lèi)

          隨筆檔案

          文章分類(lèi)

          文章檔案

          相冊(cè)

          訂閱Canvas

          搜索

          最新評(píng)論

          閱讀排行榜

          評(píng)論排行榜

          最近做一些Kernel方面的工作,從一頭霧水開(kāi)始,多做些記錄吧。

          addr2line也可以根據(jù)指令地址定位C代碼對(duì)應(yīng)的行,但是對(duì)于Kernel module卻不是很方便,使用gdb就要容易得多。

          NOTE:在使用gdb定位C代碼之前需要開(kāi)啟-g選項(xiàng)編譯內(nèi)核或者module

          例如有這樣的Call Trace
          Call Trace:
          [<8033265c>] dump_stack+0x8/0x30
          [<8003abbc>] warn_slowpath_common+0x70/0x98
          [<80041f10>] local_bh_enable_ip+0x98/0xec
          [<c13f1c6c>] ieee80211_alloc_node+0x29c/0x47c [umac]
          [<c13f1f70>] ieee80211_reset_bss+0x58/0x154 [umac]
          [<c13f7c84>] ieee80211_vap_attach+0x20/0x68 [umac]
          [<c14096cc>] ath_vap_create+0x430/0x6b0 [umac]
          [<c13f7290>] wlan_vap_create+0x58/0x210 [umac]
          [<c14686e8>] osif_ioctl_create_vap+0x268/0x790 [umac]
          [<c14597b0>] ath_ioctl+0x134/0x94c [umac]
          [<8022db50>] dev_ioctl+0x28c/0x88

          現(xiàn)在想定位指令:
          [<80041f10>] local_bh_enable_ip+0x98/0xec

          可以這樣做:
          $ mips-linux-gdb vmlinux

          GNU gdb 6.8
          Copyright (coffee) 2008 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 "--host=i386-pc-linux-gnu --target=mips-linux-uclibc"...

          輸入命令
          (gdb) list *(local_bh_enable_ip+0x98)

          gdb返回結(jié)果
          0x80041f10 is in local_bh_enable_ip (kernel/softirq.c:216).
          211
          212 EXPORT_SYMBOL(_local_bh_enable);
          213
          214 static inline void _local_bh_enable_ip(unsigned long ip)
          215 {
          216  WARN_ON_ONCE(in_irq() || irqs_disabled());
          217 #ifdef CONFIG_TRACE_IRQFLAGS
          218  local_irq_disable();
          219 #endif
          220  /*
          (gdb)
          posted on 2012-11-06 15:18 小碼哥 閱讀(5162) 評(píng)論(0)  編輯  收藏 所屬分類(lèi): 備忘
          主站蜘蛛池模板: 汤阴县| 清河县| 和政县| 新巴尔虎右旗| 清徐县| 四会市| 娄底市| 周宁县| 五家渠市| 祁门县| 卢氏县| 江城| 陇南市| 德化县| 磐石市| 潞西市| 融水| 翁牛特旗| 海口市| 襄城县| 确山县| 旅游| 大埔县| 平和县| 子长县| 防城港市| 肥城市| 英吉沙县| 安阳县| 武定县| 临潭县| 淅川县| 新安县| 武邑县| 彩票| 寻乌县| 夏津县| 镇坪县| 新乡市| 黎平县| 壤塘县|