Chinaunix首页 | 论坛 | 博客
  • 博客访问: 456618
  • 博文数量: 73
  • 博客积分: 3593
  • 博客等级: 中校
  • 技术积分: 912
  • 用 户 组: 普通用户
  • 注册时间: 2009-10-14 11:32
文章分类

全部博文(73)

文章存档

2013年(2)

2012年(20)

2011年(25)

2010年(12)

2009年(14)

分类: 嵌入式

2009-11-26 17:28:50

 
一年前在没有开发板的情况下,skyeye帮助我了解了linux。当时写了一些笔记,现在转到这里来。当时尝试全部用E文下,不管写得多烂啦。
----------------------
 
最近有空把skyeye那本书拿来翻翻,一时兴起想玩玩linux。于是就去下vmware安装装FC4。
在FC4下安装skyeye的最新版本,下载安装uClinux_gnutools,下载uClinux源码并用编译,编译完用挂上gdb远程调试一下,可以调试内核了啊,哈。
怕以后自己忘了将整个过程写下来发到skyeye社区上。
 
原文:debug uClinux with gdb
 

first we need:
  --install uClinux_gnutools(I use arm-elf-tools-20011219.tar.gz)
  --build uclinux(I use uClinux-dist-20030522.tar.gz)
  --creat new link for linux:
    # ln -s uClinux-dist/linux-2.4.x/linux linux
  --build skyeye(I use skyeye-1.2.5_REL.tar.gz)
  if you don't how to do these see https://www.ibm.com/developerworks/cn/linux/l-skyeye/part2/

next:   
  --run uClinux in skyeye with debug option:
  [root@localhost uClinux-dist]# arm-elf-skyeye -d -e linux
  Your elf file is little endian.
  arch: arm
  cpu info: armv3, arm7tdmi, 41007700, fff8ff00, 0
  mach info: name at91, mach_init addr 0x805cb28
  ethmod num=1, mac addr=0:4:3:2:1:f, hostip=10.0.0.1
  uart_mod:0, desc_in:, desc_out:, converter:
  SKYEYE: use arm7100 mmu ops
  Loaded ROM   images/romfs.img
  exec file "linux"'s format is elf32-little.
  load section .init: addr = 0x01000000  size = 0x0000a000.
  load section .text: addr = 0x0100a000  size = 0x000c5c10.
  load section .data: addr = 0x010d0000  size = 0x00008320.
  not load section .bss: addr = 0x010d8320  size = 0x00022198 .
  not load section .debug_abbrev: addr = 0x00000000  size = 0x00039846 .
  not load section .debug_info: addr = 0x00000000  size = 0x016b6881 .
  not load section .debug_line: addr = 0x00000000  size = 0x002a8b67 .
  not load section .debug_pubnames: addr = 0x00000000  size = 0x0000b40d .
  not load section .debug_aranges: addr = 0x00000000  size = 0x000022e0 .
  call ARMul_InitSymTable,kernel filename is linux.
  start addr is set to 0x01000000 by exec file.
  debugmode= 1, filename = skyeye.conf, server TCP port is 12345  //stop here wait gdb host conecte
  Remote debugging using host:12345                 //this show gdb has conected
     
  --open other consle in your computer, go your uClinux dir
    [root@localhost uClinux-dist]# arm-elf-gdb linux
  GNU gdb 5.0
  Copyright 2000 Free Software Foundation, Inc.
  GDB is free software, covered by the GNU General Public License, and you are
  welcome to change it and/or distribute copies of it under certain conditions.
  Type "show copying" to see the conditions.
  There is absolutely no warranty for GDB.  Type "show warranty" for details.
  This GDB was configured as "--host=i686-pc-linux-gnu --target=arm-elf"...
  (gdb) target remote 127.0.0.1:12345                //conecte target
  Remote debugging using 127.0.0.1:12345
  0x1000000 in stext () at af_packet.c:1891             
  1891            sock_unregister(PF_PACKET);
  (gdb) break start_kernel                     //set breakpoint at start_kernel()
  Breakpoint 1 at 0x100055c: file init/main.c, line 362.
  (gdb) continue                          
  Continuing.
  
  Breakpoint 1, start_kernel () at init/main.c:362         //now program stop at start_kernel
  362             printk(linux_banner);
  (gdb) list
  357    
  361             lock_kernel();
  362             printk(linux_banner);
  363             setup_arch(&command_line);
  364             printk("Kernel command line: %s\n", saved_command_line);
  365             parse_options(command_line);
  366             trap_init();
  (gdb) break main.c:364                      
  Breakpoint 2 at 0x1000578: file init/main.c, line 364.
  (gdb) next   //Note: next command has something wrong, if no breakpoint it will full run.
  
  Breakpoint 2, start_kernel () at init/main.c:364
  364             printk("Kernel command line: %s\n", saved_command_line);
  (gdb) break main.c:366
  Breakpoint 3 at 0x100058c: file init/main.c, line 366.
  (gdb) next
  365             parse_options(command_line);
  (gdb) list
  360      */
  361             lock_kernel();
  362             printk(linux_banner);
  363             setup_arch(&command_line);
  364             printk("Kernel command line: %s\n", saved_command_line);
  365             parse_options(command_line);
  366             trap_init();
  367             init_IRQ();
  368             sched_init();
  369             softirq_init();
  (gdb) step   //'next' has someting wrong but 'step' is ok.
  parse_options (line=0x10d8ec4 "@") at init/main.c:234
  234     {
  (gdb) list
  229      *
  230      * This routine also checks for options meant for the kernel.
  231      * These options are not given to init - they are for internal kernel use only.
  232      */
  233     static void __init parse_options(char *line)
  234     {
  235             char *next,*quote;
  236             int args, envs;
  237
  238             if (!*line)
  (gdb) s
  238             if (!*line)
  (gdb) p args
  $1 = 0
  (gdb) p *next
  $2 = 0 '\000'
    ......
   
enjoy it!
just beginning...

thanks yymusic & ksh
see--

 

//------------------------------------------------------

有关于skyeye介绍:

https://www.ibm.com/developerworks/cn/linux/l-skyeye/part1/

阅读(1476) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~