QQ登录

只需一步,快速开始

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1637|回复: 3

debug uClinux with gdb

[复制链接]
发表于 2008-8-28 11:34:25 | 显示全部楼层 |阅读模式
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     /*
        358      * Interrupts are still disabled. Do necessary setups, then
        359      * enable them
        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();
        (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--http://www.linuxfans.org/bbs/thread-181087-1-1.html
发表于 2008-10-3 21:46:19 | 显示全部楼层
这个时候可以打印出向相关到寄存器到内容吗?
比如说 PC cpsr 到内容,谢谢!
回复

使用道具 举报

发表于 2008-10-5 12:30:46 | 显示全部楼层
(gdb) info register
回复

使用道具 举报

发表于 2008-10-8 23:35:11 | 显示全部楼层

回复 #3 ksh 的帖子

多谢!多谢!
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

GMT+8, 2024-5-2 10:37 , Processed in 0.077416 second(s), 15 queries .

© 2021 Powered by Discuz! X3.5.

快速回复 返回顶部 返回列表