Chinaunix首页 | 论坛 | 博客
  • 博客访问: 731538
  • 博文数量: 130
  • 博客积分: 10
  • 博客等级: 民兵
  • 技术积分: 2198
  • 用 户 组: 普通用户
  • 注册时间: 2011-11-29 12:48
个人简介

每一个“丑得人神共愤”的泡妞高 手都有一颗坚忍的心,这证明了人类 在绝境中毫不妥协的求生精神,反正丑都丑了,索性放开手脚大干一场,这就叫“无产阶级失去的是锁链,得到的是全世界”

文章分类

全部博文(130)

文章存档

2013年(130)

我的朋友

分类: LINUX

2013-09-23 16:42:59

Cross debugging with GDB

注意,gdbserver在板子上运行,本地运行的是交叉编译的gdb
To set up a cross debug session using GDB, it is necessary to run debugging tools on both the target Linux system and the host system.

    1.On the target Linux system the GDB debug server, gdbserver needs to be told which port to use and which application to debug. Run gdbserver with the command:
  1. gdbserver localhost:
    where ; is the port number to use (chose a port that does not conflict with any other ports in use) and is the application to be debugged. For example, to debug /root/hello using port 3278:
  1. target% gdbserver localhost:3278 /root/hello
  2. Process application created: pid = 184
  3. Listening on port 3278
    Note: To support symbolic debugging the application must have been compiled with the -g flag. This causes DWARF debugging information to be included in the executable. See the GDB documentation for details.

    2.On the host, run the appropriate debugger, for example sh4-linux-gdb, giving the name of the executable to be debugged as an argument. This is so that GDB can access its debug information.

    3.When the host debugger is running, connect to gdbserver using the target remote command:
  1. (gdb) target remote :
    In this command specifies the target name or IP address, and is the port number gdbserver is using.

    Using the example above, and supposing the target is 192.168.1.2:
  1. host% sh4-linux-gdb /opt/STM/STLinux2.3/devkit/sh4/target/root/hello
  2. GNU gdb STMicroelectronics/Linux Base 6.5-32 [build Jul 22 2008]
  3. Copyright (C) 2006 Free Software Foundation, Inc.
  4. This GDB was configured as "--host=i686-pc-linux-gnu --target=sh4-linux"...
  5. (gdb) target remote 192.168.1.2:3278
  6. Remote debugging using 192.168.1.2:3278
  7. 0x29558080 in ??()
  8. (gdb)
    4.Initially the program is stopped at its entry point in the C runtime, so the first step is to run to main:
  1. (gdb) break main
  2. Breakpoint 1 at 0x400656: file main.c, line 20.
  3. (gdb) continue
  4. Continuing.
  5. Breakpoint 1, main() at main.c:20 20 printf("Welcome to the application\n");
  6. (gdb)
    Note: To avoid having to enter these commands manually whenever GDB is invoked, they can be automated by creating a GDB startup script file. When GDB starts, it looks for a file named .shgdbinit in the home directory of the user, and in the current directory, and (if found) executes it. The user can specify an alternative startup script to be run, by starting GDB with the command line option --command=
阅读(1849) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~