Chinaunix首页 | 论坛 | 博客
  • 博客访问: 9163800
  • 博文数量: 1727
  • 博客积分: 12961
  • 博客等级: 上将
  • 技术积分: 19860
  • 用 户 组: 普通用户
  • 注册时间: 2009-01-09 11:25
个人简介

偷得浮生半桶水(半日闲), 好记性不如抄下来(烂笔头). 信息爆炸的时代, 学习是一项持续的工作.

文章分类

全部博文(1727)

文章存档

2024年(3)

2023年(26)

2022年(112)

2021年(217)

2020年(157)

2019年(192)

2018年(81)

2017年(78)

2016年(70)

2015年(52)

2014年(40)

2013年(51)

2012年(85)

2011年(45)

2010年(231)

2009年(287)

分类: LINUX

2009-09-15 08:49:39

使用图形界面调试arm程序: insight + gdb 收藏
【转帖请注明出处:blog.csdn.net/lanmanck】
1、首先下载insight,我这里是6.8版本,里面已经包含gdb和gdbserver了 :)
2、编译pc端得程序,类似visual studio,可以按照这篇文章来做:
但是有一点上述文章没有提到,那就是编译器链接库路径也要加进去的问题。
#cd insight
#./configure --target=arm-linux --prefix=/opt/work/insight --with-solib-absolute-prefix=/opt/armgcc/4.3.2/libc/lib
3、编译arm端得gdbserver:
cd insight/gdb/gdbserver
./configure --host=arm-linux --target=arm-linux
make
现在gdbserver已经生成,拷贝到arm文件系统的bin目录下即可。
============================调试方法===========================
1、打开arm-linux-insight,可以看到友好的界面,他会自动加载arm-linux-gdb
2、在界面打开一个arm可执行文件。这时会弹出对话框,让你选择gdb连接方式:有串口、tcp(网口)等。
3、在串口端运行gdbserver 192.168.1.2:1000 myarmexec,然后在insight选择好连接方式,点确定即可。
insight里的端口号1000好像改不了,咋回事?
注意:如果编译insight的时候,arm-linux-gcc的库路径没有加上去的话,会报一堆错误和警告,例如:
xxx is not at the expected address。
Error while mapping shared library sections。
解决方法如下2种之一:
1)、按照第一个步骤,把编译路径加上去:
--with-solib-absolute-prefix=/opt/armgcc/4.3.2/libc/lib
2)、在insight加载文件之前,设置好路径:
在insight的菜单打开gdb的console,用命令: set solib-absolute-path=/opt/armgcc/4.3.2/libc/lib
现在,我们也可以像visual studio 那样调试linux程序了,嘿嘿.

本文来自CSDN博客,转载请标明出处:http://blog.csdn.net/lanmanck/archive/2009/09/12/4545023.aspx




==========================================================================
下载gdb-6.8.tar.bz2

一.编译安装gdb
<1>luther@gliethttp:~/gdb-6.8$ ./configure --target=arm-linux --enable-sim --prefix=/usr/local
<2>luther@gliethttp:~/gdb-6.8$ make
<3>luther@gliethttp:~/gdb-6.8$ sudo make install
二.编译安装gdbserver
<1>luther@gliethttp:~/gdb-6.8/gdb/gdbserver$ ./configure --target=arm-linux --host=arm-linux
<2>luther@gliethttp:~/gdb-6.8/gdb/gdbserver$ make
   或者make CC=/usr/local/arm-linux/bin/arm-linux-gcc指定编译器目录
<3>这样在gdb-6.8/gdb/gdbserver目录下就生成了一个gdbserver可执行文件,拷贝到
   目标开发板上.
三.测试arm-linux-gdb + gdbserver
在minicom或者putty输入:[192.168.100.1为pc机ip地址,2345为监听端口]
<1>gdbserver 192.168.100.1:2345 hello
在pc机上输入:[192.168.100.2为开发板ip地址]
<2>luther@gliethttp:~/ arm-linux-gdb hello 然后输入
target remote 192.168.100.2:2345
这样在开发板minicom或putty上可以看到如下提示信息:
/ # ./gdbserver 192.168.100.1:2345 hello
Process wpa_cli created; pid = 730
Listening on port 2345
Remote debugging from host 192.168.100.1
=====================================================================
具体实例如下:
=====================================================================
pc端log或者使用arm-linux-gdbtui简易图形gdb终端
luther@gliethttp:~/arm$ arm-linux-gdb hello
GNU gdb 6.8
Copyright (C) 2008 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <
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=i686-pc-linux-gnu --target=arm-linux"...
(gdb) target remote 192.168.100.2:2345
Remote debugging using 192.168.100.2:2345
[New Thread 1514]
warning: Unable to find dynamic linker breakpoint function.
GDB will be unable to debug shared library initializers
and track explicitly loaded dynamic code.
0x400007e0 in ?? ()
(gdb) b main
Breakpoint 1 at 0x835c: file hello.c, line 6.
(gdb) l
1    #include
2    
3    int main(int argc, char *argv[])
4    {
5        int i;
6        for(i = 0;i < 10;i++)
7        {
8            printf("%d\n", i);
9        }
10        return 0;
(gdb) c  不要输入r,输入c,因为target端的hello在载入时处于了run状态.
Continuing.
warning: .dynamic section for "/lib/libc.so.6" is not at the expected address (wrong library or version mismatch?)
Error while mapping shared library sections:
/lib/ld-linux.so.3: No such file or directory.

Breakpoint 1, main (argc=1, argv=0xbeb4ad84) at hello.c:6
6        for(i = 0;i < 10;i++)
(gdb) n
8            printf("%d\n", i);
(gdb) n
6        for(i = 0;i < 10;i++)
(gdb) n
8            printf("%d\n", i);

(gdb)
=====================================================================
target板端log
/ # ./gdbserver 192.168.100.1:2345 hello
[ 3688.476398] init: untracked pid 1513 exited
Process hello created; pid = 1514
Listening on port 2345
Remote debugging from host 192.168.100.1
0

=====================================================================
也可以使用ddd -debugger arm-linux-gdb hello图形化调试,
insight需要从源码编译才行:
<1>下载源码insight-6.8.tar.bz2

<2>luther@gliethttp:~/insight-6.8$ ./configure --target=arm-linux --enable-sim --prefix=/usr/local
<3>luther@gliethttp:~/insight-6.8$ make
<4>luther@gliethttp:~/insight-6.8$ sudo make install
编译于insight配对的gdbserver
<1>luther@gliethttp:~/insight-6.8/gdb/gdbserver$ ./configure --target=arm-linux --host=arm-linux
<2>luther@gliethttp:~/insight-6.8/gdb/gdbserver$ make
启动arm-linux-insight,因为arm-linux-insight依赖gdb,所以会自动编译出arm-linux-gdb.
=====================================================================
具体实例如下:
luther@gliethttp:~/arm$ arm-linux-insight
ide_initialize_paths failed: Can't find the GUI Tcl library in the following directories:
    /home/usr/share/redhat/gui /home/share/redhat/gui /share/redhat/gui /usr/local/libgui/library /home/usr/share/redhat/ide /home/share/redhat/ide /share/redhat/ide /usr/local/libide/library
后来发现/usr/local/arm-linux/bin目录下
lrwxrwxrwx 1 root root  32 2008-02-03 11:00 arm-linux-insight -> arm-iwmmxt-linux-gnueabi-insight
-rwxr-xr-x 1 root root 16M 2008-02-03 11:00 arm-iwmmxt-linux-gnueabi-insight
把它干掉就ok了



========================================

编译insight的过程中正常,但是执行是出现错误,信息未 tk.tcl 未正确安装, 需要打个补丁

2008-08-05  Joe English	 

* generic/tk.h, generic/tkEvent.c: Fix for [Bug 2010422] "no event
type or button # or keysym while executing "bind Listbox
[...]".

Index: tk/generic/tk.h
===================================================================
RCS file: /cvs/src/src/tk/generic/tk.h,v
retrieving revision 1.5
diff -u -p -r1.5 tk.h
--- tk/generic/tk.h 21 Jan 2003 20:24:42 -0000 1.5
+++ tk/generic/tk.h 26 Feb 2009 17:13:32 -0000
@@ -650,17 +650,15 @@ typedef struct Tk_GeomMgr {
*
*---------------------------------------------------------------------------
*/
-#define VirtualEvent (LASTEvent)
-#define ActivateNotify (LASTEvent + 1)
-#define DeactivateNotify (LASTEvent + 2)
-#define MouseWheelEvent (LASTEvent + 3)
-#define TK_LASTEVENT (LASTEvent + 4)
+#define VirtualEvent (MappingNotify + 1)
+#define ActivateNotify (MappingNotify + 2)
+#define DeactivateNotify (MappingNotify + 3)
+#define MouseWheelEvent (MappingNotify + 4)
+#define TK_LASTEVENT (MappingNotify + 5)

#define MouseWheelMask (1L << 28)
-
#define ActivateMask (1L << 29)
#define VirtualEventMask (1L << 30)
-#define TK_LASTEVENT (LASTEvent + 4)


/*
Index: tk/generic/tkEvent.c
===================================================================
RCS file: /cvs/src/src/tk/generic/tkEvent.c,v
retrieving revision 1.5
diff -u -p -r1.5 tkEvent.c
--- tk/generic/tkEvent.c 21 Jan 2003 20:24:43 -0000 1.5
+++ tk/generic/tkEvent.c 26 Feb 2009 17:13:32 -0000
@@ -77,7 +77,7 @@ typedef struct TkWindowEvent {
* Array of event masks corresponding to each X event:
*/

-static unsigned long eventMasks[TK_LASTEVENT] = {
+static unsigned long realEventMasks[MappingNotify+1] = {
0,
0,
KeyPressMask, /* KeyPress */
@@ -115,7 +115,10 @@ static unsigned long eventMasks[TK_LASTE
0, /* SelectionNotify */
ColormapChangeMask, /* ColormapNotify */
0, /* ClientMessage */
- 0, /* Mapping Notify */
+ 0 /* Mapping Notify */
+};
+
+static unsigned long virtualEventMasks[TK_LASTEVENT-VirtualEvent] = {
VirtualEventMask, /* VirtualEvents */
ActivateMask, /* ActivateNotify */
ActivateMask, /* DeactivateNotify */
@@ -734,7 +737,21 @@ Tk_HandleEvent(eventPtr)
*/

handlerWindow = eventPtr->xany.window;
- mask = eventMasks[eventPtr->xany.type];
+
+ /*
+ * Get the event mask from the correct table. Note that there are two
+ * tables here because that means we no longer need this code to rely on
+ * the exact value of VirtualEvent, which has caused us problems in the
+ * past when X11 changed the value of LASTEvent. [Bug ???]
+ */
+
+ if (eventPtr->xany.type <= MappingNotify) {
+ mask = realEventMasks[eventPtr->xany.type];
+ } else if (eventPtr->xany.type >= VirtualEvent
+ && eventPtr->xany.type+ mask = virtualEventMasks[eventPtr->xany.type - VirtualEvent];
+ }
+
if (mask == StructureNotifyMask) {
if (eventPtr->xmap.event != eventPtr->xmap.window) {
mask = SubstructureNotifyMask;
Index: tk/unix/tkUnixEvent.c
===================================================================
RCS file: /cvs/src/src/tk/unix/tkUnixEvent.c,v
retrieving revision 1.5
diff -u -p -r1.5 tkUnixEvent.c
--- tk/unix/tkUnixEvent.c 21 Jan 2003 20:24:52 -0000 1.5
+++ tk/unix/tkUnixEvent.c 26 Feb 2009 17:13:32 -0000
@@ -288,6 +288,14 @@ TransferXEventsToTcl(display)

while (numFound > 0) {
XNextEvent(display, &event);
+#ifdef GenericEvent
+ if (event.type == GenericEvent) {
+ xGenericEvent *xgePtr = (xGenericEvent *) &event;
+
+ Tcl_Panic("Wild GenericEvent; panic! (extension=%d,evtype=%d)",
+ xgePtr->extension, xgePtr->evtype);
+ }
+#endif
Tk_QueueWindowEvent(&event, TCL_QUEUE_TAIL);
numFound--;
}


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