前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >Shell的Debug命令

Shell的Debug命令

作者头像
Taishan3721
发布2021-01-08 15:39:50
6480
发布2021-01-08 15:39:50
举报
文章被收录于专栏:这里只有VxWorks这里只有VxWorks

使用Host的Target Server与Target的WDB Agent连接后,既可以使用Workbench的Debugger进行图形化的在线调试,也可以使用Host Shell的gdb进行命令行的调试

如果没有Target Connection呢?其实VxWorks还提供了一个专门用在Shell里的dbgLib - debugging facilities(INCLUDE_DEBUG)

代码语言:javascript
复制
-> dbgHelp
b                               Display breakpoints and eventpoints
b         addr[,task[,count [,quiet]]]
                                Set breakpoint
bi        [bpId]                Display breakpoint(s) detailed information
e         addr[,eventNo[,task[,func[,arg]]]]] Set eventpoint
dprintf   addr,task,count,fmtStr[,args]
                                Set dynamic printf eventpoint
bd        addr[,task]           Delete breakpoint
bdall     [task]                Delete all breakpoints and eventpoints
c         [task[,addr[,addr1]]] Continue from breakpoint
cret      [task]                Continue to subroutine return
s         [task[,addr[,addr1]]] Single step
so        [task]                Single step/step over subroutine
l         [adr[,nInst]]         List disassembled memory
tt        [task]                Do stack trace on task
hdprintf  addr,access,task,count,fmtStr[,args]
                                Set hardware dynamic printf eventpoint
                                (bh() help entry lists access modes)
bh addr[,access[,task[,count[,quiet]]]] Set hardware breakpoint
         access :      0 - instruction        1 - write 1 byte
                       3 - read/write 1 byte  5 - write 2 bytes
                       7 - read/write 2 bytes d - write 4 bytes
                       f - read/write 4 bytes 9 - write 8 bytes
                       b - read/write 8 bytes

写个小栗子

代码语言:javascript
复制
#include <stdio.h>

void eee()
{
    printf("!%s\n", __FUNCTION__);
    }
void ddd()
{
    printf("!%s\n", __FUNCTION__);
    eee();
    }
void ccc()
{
    printf("!%s\n", __FUNCTION__);
    ddd();
    }
void bbb()
{
    printf("!%s\n", __FUNCTION__);
    ccc();
    }
void aaa()
{
    printf("!%s\n", __FUNCTION__);
    bbb();
    }

用它来试试这个dbgLib的操作

先加个断点,例如在bbb()的位置

从aaa()启动程序,新任务会在bbb()处停住

使用tt()看一下调用栈,使用l()看一下即将执行的汇编代码(尽管我也看不懂)

使用dprintf()加个动态事件点,例如在ddd()的位置

使用c()让程序执行到下一个断点或结束

很不错的小机制!

打完收工

我是泰山 专注VX 0x10年

一起学习 共同进步

本文参与 腾讯云自媒体分享计划,分享自微信公众号。
原始发表:2021-01-01,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 这里只有VxWorks 微信公众号,前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档