好得很程序员自学网

<tfoot draggable='sEl'></tfoot>

使用GDB在ARM上进行开发调试

int add( int a, int b) { return a+b; } int main( int argc ,char* argv[]) { int num1= 1 ,num2= 2 , time ; const int plusCount= 3 ; for ( time = 0 ; time !=plusCount;++ time ) printf ( " %dplus %d = %d .\r\n" ,num1,num2,num1+num2); printf ( " %dplus %d = %d byfunc.\r\n" ,num1,num2,add(num1,num2)); return 0 ; }

在命令行里输入:arm-hisiv100nptl-linux-gcc test.c -g -o test 即可生成应用程序test。注意,编译时一定要加入-g参数,表示应用程序调试。

三、GDB+GDB server nfs调试方法
进行调试前首先需要保证目标开发板与宿主机支持nfs。在宿主机上安装samba教程可自行百度获取,或者参考文章附录。本例中宿主机IP为218.192.171.55,目标板IP为218.192.171.72,开发环境(win7 x64)IP为218.192.171.78,宿主机的共享目录为/mnt/nfs。
1.将gdbserver和test拷贝到/mnt/nfs,更改应用程序权限:chmod 777 gdbserver test。
2.通过telnet或者minicom远程到目标板,挂载nfs:
mount -t nfs -o nolock -o tcp 218.192.171.55:/mnt/nfs /nfsroot

3.进入/nfsroot目录,输入指令:
./gdbserver 218.192.171.55:5000 test
其中,218.192.171.55为宿主机IP,5000表示目标开发板的调试端口(一般任意大于1024的端口号均可)。

4.在宿主机命令行输入:arm-linux-gdb test,接着输入:
target remote 218.192.171.72:5000
连接成功后,出现如下提示:

5.在宿主机命令行输入’c’,程序执行。效果如下:

目标板端输出提示如下:

注,本例仅进行简单测试,其它调试命令可参考附录。
四、串口调试
未完待续。

$(function () { $(‘pre.prettyprint code‘).each(function () { var lines = $(this).text().split(‘\n‘).length; var $numbering = $(‘ ‘).addClass(‘pre-numbering‘).hide(); $(this).addClass(‘has-numbering‘).parent().append($numbering); for (i = 1; i ‘).text(i)); }; $numbering.fadeIn(1700); }); });

使用GDB在ARM上进行开发调试

标签:gdb   开发   arm   c   

查看更多关于使用GDB在ARM上进行开发调试的详细内容...

  阅读:25次