invoking gdb

The most usual way to start gdb is with one argument, specifying an executable program:

  1. gdb program

You can also start with both an executable program and a core file specified:

  1. gdb program core

You can, instead, specify a process ID as a second argument, if you want to debug a running process:

  1. gdb program 1234

would attach gdb to process 1234 (unless you also have a file named 1234; gdb does check for a core file first).

You can optionally have gdb pass any arguments after the executable file to the inferior using --args. This option stops option processing.

  1. gdb --args gcc -O2 -c foo.c

This will cause gdb to debug gcc, and to set gcc's command-line arguments (see Arguments) to ‘-O2 -c foo.c’.

Index Files Speed Up gdb

When gdb finds a symbol file, it scans the symbols in the file in order to construct an internal symbol table. This lets most gdb operations work quickly—at the cost of a delay early on. For large programs, this delay can be quite lengthy, so gdb provides a way to build an index, which speeds up startup.

The index is stored as a section in the symbol file. gdb can write the index to a file, then you can put it into the symbol file using objcopy.

To create an index file, use the save gdb-index command:

save gdb-index directory
Create an index file for each symbol file currently known by gdb. Each file is named after its corresponding symbol file, with ‘.gdb-index’ appended, and is written into the given directory.

Once you have created an index file you can merge it into your symbol file, here named symfile, using objcopy:

  1. $ objcopy --add-section .gdb_index=symfile.gdb-index \
  2. --set-section-flags .gdb_index=readonly symfile symfile

参考:

  1、https://sourceware.org/gdb/download/onlinedocs/gdb/Invoking-GDB.html#Invoking-GDB

  2、https://sourceware.org/gdb/download/onlinedocs/gdb/Index-Files.html#Index-Files

invoking gdb的更多相关文章

  1. gdb调试libtool封装的可执行文件

    http://www.gnu.org/software/libtool/manual/html_node/Debugging-executables.html 3.4 Debugging execut ...

  2. linux内核调试指南

    linux内核调试指南 一些前言 作者前言 知识从哪里来 为什么撰写本文档 为什么需要汇编级调试 ***第一部分:基础知识*** 总纲:内核世界的陷阱 源码阅读的陷阱 代码调试的陷阱 原理理解的陷阱 ...

  3. Linux Kernel - Debug Guide (Linux内核调试指南 )

    http://blog.csdn.net/blizmax6/article/details/6747601 linux内核调试指南 一些前言 作者前言 知识从哪里来 为什么撰写本文档 为什么需要汇编级 ...

  4. linux应用调试技术之GDB和GDBServer

    1.调试原理 GDB调试是应用程序在开发板上运行,然后在PC机上对开发板上得应用程序进行调试,PC机运行GDB,开发板上运行GDBServer.在应用程序调试的时候,pc机上的gdb向开发板上的GDB ...

  5. 新手如何在gdb中存活

    网络上已经有很多gdb调试的文章了,为什么我还要写这篇文章呢,因为本文是写给gdb新手的,目的就是通过一个简单的例子来让新手很快上手.一旦上手入门了,其他的问题就可以自己去搜索搞定了.右边是gdb的L ...

  6. GDB 多线程调试:只停止断点的线程,其他线程任然执行; 或只运行某些线程 其他线程中断

    多线程调试之痛 调试器(如VS2008和老版GDB)往往只支持all-stop模式,调试多线程程序时,如果某个线程断在一个断点上,你的调试器会让整个程序freeze,直到你continue这个线程,程 ...

  7. GDB调试命令

    1.查看源码: list [函数名][行数] 2.暂停程序 (1)设置断点: a.break + [源代码行号][源代码函数名][内存地址] b.break ... if condition   .. ...

  8. 关于gdb和shp的FID问题

    gdb的FID从1开始,并且FID唯一,从数字化时开始,每个图形对应唯一的FID,删除图形亦删除对应的FID.FID可能出现中断的情况. shp的FID从0开始,并且永远连续.删除图形,则编号在其下面 ...

  9. GDB调试命令小结

    1.启动调试 前置条件:编译生成执行码时带上 -g,如果使用Makefile,通过给CFLAGS指定-g选项,否则调试时没有符号信息.gdb program //最常用的用gdb启动程序,开始调试的方 ...

随机推荐

  1. Android实现自定义字体

    介绍 最近在看开源项目的时候,发现里面涉及到了自定义字体,虽然自己目前还用不到,但是动手demo笔记记录一下还是有必要的,没准哪天需要到这个功能. 原理 1.其实实现起来非常简单,主要是用到了Type ...

  2. jquery radio 取值 取消选中 赋值

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/ ...

  3. UVa 12265 (单调栈) Selling Land

    紫书上分析了很多很多,超详细,= ̄ω ̄= 每扫描一行可以计算一个height数组,表示从这块空地向上延伸多少块空地,而且这个数组可以逐行递推. 首先对于每一行来说维护一个单调栈,栈里放的是矩形的左上角 ...

  4. STL set容器的一点总结

    整理了一下set常用语句,参看这篇http://www.cnblogs.com/BeyondAnyTime/archive/2012/08/13/2636375.html -------------- ...

  5. 通过javascript把图片转化为字符画

    1.获取上传图片对象数据 Javascript无法直接获取本地上传的图片的数据,html5可以解决这一问题 .html5里面的FileReader interface可以把图片对象的数据读到内存,然后 ...

  6. mysql,多表的内外连接+子查询

    表: student house course 关系:student_course 多对多 student house 多对一 需求:查询房间1 的学生 都学习了什么课程 select s.s_nam ...

  7. 数据结构——Java实现二叉树

    相关概念 存储结构: 顺序存储结构:二叉树的顺序存储结构适用于完全二叉树,对完全二叉树进行顺序编号,通过二叉树的性质五(第1个结点为根结点,第i个结点的左孩子为第2i个结点,右孩子为第2i+1个结点) ...

  8. 【转】itunes connect 如何修改主要语言

    原文网址:http://blog.csdn.net/yuedong56/article/details/50662181 刚开始提交app,没有做国际化(本地化),提交的app只有简体中文一种语言,第 ...

  9. 中小型数据库 RMAN CATALOG 备份恢复方案(二)

    中小型数据库呈现的是数据库并发少,数据库容量小,版本功能受限以及N多单实例等特点.尽管如此,数据库的损失程度也会存在零丢失的情形.企业不愿意花太多的钱又要保证数据库的可靠稳定,可是苦煞了我这些搞DB的 ...

  10. Android 实现切换主题皮肤功能(类似于众多app中的 夜间模式,主题包等)

    首先来个最简单的一键切换主题功能,就做个白天和晚上的主题好了. 先看我们的styles文件: <resources> <!-- Base application theme. --& ...