gdb查段错误

root@7-arm:/home/chien# make
make:"DeltaRobot"时最新的
root@7-arm:/home/chien# ./DeltaRobot
段错误

root@7-arm:/home/chien# dmesg -c
[1381688.961266] DeltaRobot[22665]: segfault at 4 ip 0804f9d1 sp b74cb360 error in 4 DeltaRobot[8048000+19000]

root@7-arm:/home/chien#  ulimit -c
0
root@7-arm:/home/chien#  ulimit -c unlimited
root@7-arm:/home/chien# ./DeltaRobot
段错误(吐核)

root@7-arm:/home/chien#  scp core 192.168.168.116:/tmp
root@192.168.168.116's password:
core   100%   93M   11.6MB/s  00:08
root@7-arm:/home/chien#  scp DeltaRobot 192.168.168.116:/tmp
root@192.168.168.116's password:
DeltaRobot   100%   194KB 194.0KB/s 00:00


root@7-arm:/home/chien#  ssh 192.168.168.116
root@192.168.168.116's password:
root@UCN:#~  cd /tmp/
root@UCN:/tmp#  ls  
core           ....             .............
DeltaRobot     .....            ...........
.....          .....            .........


root@UCN:/tmp#  gdb -c core
..............
..............
Core was generated by "./DeltaRobot".
Program terminated with Signal SIGSEGV,Segmentation fault.
#0 Ox0804f9d1 in ??()
..................
.................. 
root@UCN:/tmp#  gdb DeltaRobot core
..............
..............
Core was generated by "./DeltaRobot".
Program terminated with Signal SIGSEGV,Segmentation fault.
#0 Ox0804f9d1 in CEncoder::TickLoop(p=OxO) at Encoder.cpp:69
69 Encoder.cpp:no such file or directory
.........
..................
查:Encoder.cpp

58 void CEncoder::TickLoop(void * p)
59  {
60    CEncoder * tmp;
61    tmp = (CEncoder *)p;
62    while(1)
63    {
64        #ifdef _WIN32;
65          Sleep(1);
66        #else
67           usleep(1000);
68         #endif
69            tmp->m_cnt++;
70    }
71}
72
73 bool CEncoder::startTickLoop()
  {
#ifdef  _WIN32
    DWORD id;
    HANDLE reth = CreateThread(NULL,0,(unsigned long(_stdcall *)(void *))TickLoop,this,0,&id);
    if(reth == INVALID_HANDLE_VALUE)
    {
    return false
    }
#else
  unsigned long id;
    int reth = pthread_create(&id,NULL,(void* (*)(void*))TickLoop,NULL);
    if(reth == -1)
    {
        return false;
    }
 #endif
}


 结果:   
将  int reth = pthread_create(&id,NULL,(void* (*)(void*))TickLoop,NULL);
改为int reth = pthread_create(&id,NULL,(void* (*)(void*))TickLoop,(void*)this);
执行通过

注意:Makefile文件加 -g
cc=g++ -g
exe=DeltaRobot
................

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值