zoukankan      html  css  js  c++  java
  • invoking gdb

    invoking gdb

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

         gdb program
    

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

         gdb program core
    

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

         gdb program 1234
    

    would attach gdb to process 1234 (unless you also have a file named 1234gdb 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.

         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 filegdb 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:

         $ objcopy --add-section .gdb_index=symfile.gdb-index 
             --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

  • 相关阅读:
    RabbitMQ-RPC版主机管理程序
    FTP
    主机管理程序
    高级FTP
    选课系统
    电子银行购物商城
    计算器
    员工信息查询系统
    工资管理系统
    三级菜单
  • 原文地址:https://www.cnblogs.com/tekkaman/p/3472060.html
Copyright © 2011-2022 走看看