zoukankan      html  css  js  c++  java
  • vlc学习计划(4)在EMACS中使用GDB调试

    一 .EMACS 中调试
      1、using the clipboard
                    M-x  menu-bar-enable-clipboard
            (make cut,copy,pasty menu items,use the clipboard)
      2、using “wheel”mice
                  M-x   mouse-wheel-mode
             (激活中间的滚动键)
      3、退出出任何命令状态
             C-g
      
      4、进入编译模式
           M-x  compile 或者从菜单-》TOOLS-》COMPILE 
      5、用COMPILE 模式
           C-x  `       (搜索出错的源代码行)
           <RET>    (光标定位在compile buffer 的出错提示行上,按〈RET〉键,会跳到出错的源代码行)
          C-u C-x ` 在compile buffer 列出同样的错误。
       6、用GREP 搜索
           一、M-x grep    进入搜索
                  参数为 a grep-style regexp(using in single-quotes to quote the shell's special characters)follows bye file names;
           二、 C-x  `       (搜索出错的源代码行 --grep  搜索出来的同种错误)
             <RET>    (光标定位在grep  buffer 的出错提示行上,按〈RET〉键,会跳到出错的源代码行)
    二、GUD 调试
       1、进入
            M-x gdb
       2、命令
            C-x <SPC>     在指针所在源代码行上设置断点
        说明 C-c 在GUD BUFFER,而C-x C-a 在gud buffer and source buffer 都行
        3、  C-c    C-l
                C-x C-a   C-l   到达最后一行
        4、C-c   C-s
              C-x C-a  C-s      gud-step
        5、C-c   C-n
              C-x C-a  C-n      gud-next
         6、C-c C-r
                C-x C-a  C-r  gud-cont  执行到下一个断点
          7、C-c  C-d
                C-x C-a  C-d   gud-remove 删除当前断点
    三、GDB 命令
        1、调试命令
              step         next          continue          untile
         2、设置断点
               break file.c:foo
               break  file.c:11
               break +12
               break -12        如果执行到某一行,+表示往前,-表示向后
              断点信息
                 info breakpoint
                 enable <breakpoint number>
                 disable  <breakpoint number>
                断点条件
                  break <args> if <cond>
                  condition <break number> <cond>
                  delete  breakpoints <break number> 
                 clear
        3、显示源代码
               list 使用同断点
        4、查看变量
              print /fmt  <expr>
         5、查看内存
              x /<fmt>  <addr>
         6、切换目录
                 cd
         7、添加源文件路径
               dir <path>
         8、显示
               如果有    char msg[25];
                               int *arr=(int *)mollac(len*sizeof(int));
       
                则    display msg
                        display [email=*arr@len]*arr@len[/email]
                 或者  p msg
                           p  [email=*arr@len]*arr@len[/email]
             9、跳转执行
                 jump linespec
                 jump  <addr>
    四、Makefile 文件
    //mt.h
    #ifdef _cplusplus
    extern "c" {
    #endif
    int add(int a,int b);
    int substract(int num,int n,int *ret);
    #ifdef _cplusplus
    }
    #endif
    -----------------------------------------------
    //math.c
    #include"mt.h"
    int add(int a,int b)
     {  return (a+b);}
    int subtract(int num,int n,int *ret)
    {*ret=num-n;
    return *ret;
    }
    -----------------------------------------------
    //msg.h
    #ifdef _cplusplus
    extern "c" {
    #endif
    void prnmsg(char *msg);
    #ifdef _cplusplus
    }
    #endif
    -----------------------------------------------
    //msg.c
    #include<stdio.h>
    #include"msg.h"
    void prnmsg(char * msg)
    {  printf("%s\n",msg);}
    -----------------------------------------------
    //comm.h
    #include"mt.h"
    #include"msg.h"
    -----------------------------------------------
    //vlc.c
    #include<stdlib.h>
    #include<stdio.h>
    #include"comm.h"
    int main(int argc,char *argv[])
    {
       int i,j,sum;
       int *p_iret;
      
      char  msg[256];
        printf("hellow,this is a test program\n");
        
        i=15;
        j=10;
        sum=add(i,j);
       
       sprintf(msg,"number=%d",sum);
        prnmsg(msg);
     
       subtract(i,j,p_iret);
       sprintf(msg,"substract=%d",*p_iret);
       prnmsg(msg); 
        
       sprintf(msg,"this has modify=%d",*p_iret);
       prnmsg(msg); 
       return 0;
    }
    -----------------------------------------------
    //Makefile
    vlc:vlc.o math.o msg.o
        gcc -g -o $@ vlc.o  math.o msg.o
    math.o:math.c mt.h
        gcc -g -c -o $@ math.c
    msg.o:msg.c msg.h
        gcc -g -c msg.c
    vlc.o:vlc.c comm.h
        gcc -g -c  vlc.c
    clean:
        rm -rvf msg.o math.o vlc.o vlc
     

    本文来自CSDN博客,转载请标明出处:http://blog.csdn.net/jsphuang/archive/2005/01/19/259290.aspx
  • 相关阅读:
    mysql 获取blob类型的值
    idea导入 spring framework源码
    SpringBoot集成Swagger2,3分钟轻松入手!
    mysql索引类型:FULLTEXT、NORMAL、SPATIAL、UNIQUE的区别
    Spring Boot 如何解决项目启动时初始化资源
    微服务架构设计基础之领域驱动设计
    Spring Boot 集成 Memcached
    zookeeper简单实现注册与发现以及其他基本操作
    什么是RPC,RPC好处,常用的RPC框架
    Thrift IDL基本语法
  • 原文地址:https://www.cnblogs.com/qq78292959/p/2077031.html
Copyright © 2011-2022 走看看