zoukankan      html  css  js  c++  java
  • NOI Linux下Emacs && gdb调试方法

    1. 首先要配置emacs文件:

     1 (global-linum-mode t)
     2 (show-paren-mode t)
     3 (global-set-key (kbd "C-s") 'save-buffer)
     4 (global-set-key (kbd "RET") 'newline-and-indent)
     5 (global-set-key [f9] 'compile)
     6 (global-set-key [C-f7] 'gud-gdb)
     7 (global-set-key (kbd "C-z") 'undo)
     8 (global-set-key (kbd "C-c") 'kill-ring-save)
     9 (global-set-key (kbd "C-v") 'yank)
    10 (global-set-key (kbd "C-a") 'mark-whole-buffer)
    11 (global-set-key (kbd "C-y") 'kill-whole-line)
    12 (custom-set-variables
    13   ;; custom-set-variables was added by Custom.
    14   ;; If you edit it by hand, you could mess it up, so be careful.
    15   ;; Your init file should contain only one such instance.
    16   ;; If there is more than one, they won't work right.
    17  '(inhibit-startup-screen t)
    18  '(show-paren-mode t))
    19 (custom-set-faces
    20   ;; custom-set-faces was added by Custom.
    21   ;; If you edit it by hand, you could mess it up, so be careful.
    22   ;; Your init file should contain only one such instance.
    23   ;; If there is more than one, they won't work right.
    24  '(default ((t (:inherit nil :stipple nil :background "white" :foreground "black" :inverse-video nil :box nil :strike-through nil :overline nil :underline nil :slant normal :weight normal :height 113 :width normal :foundry "bitstream" :family "Courier 10 Pitch")))))

    就是C-c, C-v, C-a, C-s, C-z, C-F7 和 F9的快捷键设置

    2. 程序编译

    先F9,输入 g++ -o xxx xxx.cpp -g -Wall (-Wl,-stack=1000000) 编译

    C-F7调出gdb

    3. gdb调试命令

    先打:

    1 b main
    2 r

    进入调试,各种调试命令:

    单步执行:

    n 表示next执行下一行,会跳过函数

    s 同理,但不会跳过,而且会进入系统函数= =

    fin 表示跳出当前函数,且返回函数值 ex:"Value returned is $1 = (const int &) @0x8058cfc: 1"

    b x if xxx 调到x行,并且满足xxx

    查看变量:

    p x 查看当前变量x的值(同时可以查看数组,显示就和P的一样。。)

    disp x 永久查看变量x的值

    und 一次性去除所有查看信息

    断点:

    b x 在line x设置一个断点

    c 跳到下一个断点

    d 去掉所有断点

    其他:

    k 杀死进程

    q 退出gdb

    两次C-c 死循环时退出程序

    set print pretty on/off 调试的时候看变量的格式修改

    (p.s.  这里的C代表Ctrl键)

    By Xs酱~ 转载请说明 博客地址:http://www.cnblogs.com/rausen
  • 相关阅读:
    五分钟带你了解啥是JWT
    软件系统方案设计
    基于工程实践的需求分析和概念原型
    Linux添加环境变量与GCC编译器添加INCLUDE与LIB环境变量
    ssh链接到minikube虚拟机
    error converting YAML to JSON: yaml: line 3: mapping values are not allowed in this context
    CentOS 7 virt-manager “authentication failed”错误及解决方法
    centos安装docker
    kali安装php-gd
    mariadb忘记root密码
  • 原文地址:https://www.cnblogs.com/rausen/p/4204424.html
Copyright © 2011-2022 走看看