Debug printf source code with GDB on Ubuntu

Source: Internet
Author: User
By default, the library function does not contain debugging information in Ubuntu, so gdb cannot be used to enter the printf () function. Solution: 1. install libc: sudoapt-getinstalllibc6-dbg2 with debugging information. download libc source code. select a directory to place the source code and enter, such as/home/kent/dev-OS/libc6-sourceb. perform sudoapt-getsourcelibc6,

By default, the library function does not contain debugging information in Ubuntu, so gdb cannot be used to enter the printf () function.

Solution:

1. install the libc: sudo apt-get install libc6-dbg with debugging information

2. Download the libc source code

A. Select a directory to place the source code and enter, such as/home/kent/dev-OS/libc6-source

B. Execute sudo apt-get source libc6 and download the source code to the current directory. The last source directory is probably:/home/kent/dev-OS/libc6-source/eglibc-2.15

3. Specify the libc source code directory when running gdb: gdb 'Find/home/kent/dev-OS/libc6-source/eglibc-2.15-type d-printf'-d % P' my_program

4. Enter the printf () function. The first line of code I see here is

Va_list arg;

For more information about Ubuntu, see Ubuntu special page http://www.linuxidc.com/topicnews.aspx? Tid = 2

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.