How can I use GDB to break points on all functions of a file?

Source: Internet
Author: User
How can I use GDB to break points on all functions of a file?
 


1389vstux8d0dbxpprtpwzpqo8yeora3knwiqk2mnoigys5ocmi how to use GDB to break a breakpoint on all functions of a file? Sometimes, you want to clear the code execution sequence of a module and break points on each function of the module. if you look for every function from the source code and break a breakpoint in GDB, the efficiency is very low. After research, find the following method. 1) The first step is to compile the source code as. O.
Here we use Doug Lea's malloc. C source code as an example.
Download the malloc. C source code:
Http://gee.cs.oswego.edu/pub/misc/malloc.c
Http://gee.cs.oswego.edu/pub/misc/malloc.h
2) view all exported function symbols through nm, and connect the symbols with \ |
NM malloc. o | C ++ filt | grep-w-I t | awk '{print $3}' | tr '\ n',' | SED's /, the result is as follows: add_segment \ | bulk_free \ | calloc \ | change_mparam \ | percent \ | free \ | percent \ | ialloc \ | independent_calloc \ | percent \ | init_bins \ | percent \ | init_top \ | internal_bulk_free \ | internal_mallinfo \ | Alibaba \ | internal_memalign \ | mallinfo \ | malloc \ | malloc_footprint \ | Alibaba \ | malloc_stats \ | malloc_trim \ | Alibaba \ | mallopt \ | memalign \ | mmap_alloc \ | mmap_resize \ | posix_memalign \ | prepend_alloc \ | pvalloc \ | realloc \ | prop \ | percent \ | sys_alloc \ | sys_trim \ | percent \ | tmalloc_small \ | try_realloc_chunk \ | valloc \ | 3) Go to GDB to debug your program and execute the following command:
The symbol string connected by \ | in the Rb
RB add_segment \ | bulk_free \ | calloc \ | change_mparam \ | percent \ | free \ | percent \ | ialloc \ | independent_calloc \ | percent \ | init_bins \ | init_mparams \ | init_top \ | internal_bulk_free \ | internal_mallinfo \ | Alibaba \ | internal_memalign \ | mallinfo \ | malloc \ | Alibaba \ | malloc_stats \ | malloc_trim \ | Alibaba \ | mallopt \ | memalign \ | mmap_alloc \ | mmap_resize \ | posix_memalign \ | prepend_alloc \ | pvalloc \ | realloc \ | identifier \ | sys_alloc \ | sys_trim \ | identifier \ | tmalloc_small \ | try_realloc_chunk \ | valloc
Note: RB uses regular expressions to batch break points on all matching symbols.
I am very satisfied with the following results:
1389vstux8d0dbxpprtpwzpqo8yeora3knwiqk2mnoigys5ocmi label: GDB
Breakpoint
Batch 1389vstux8d0dbxpprtpwzpqo8yeora3knwiqk2mnoigys5ocmi how to use GDB to break a breakpoint on all functions of a file? Sometimes, you want to clear the code execution sequence of a module and break points on each function of the module. if you look for every function from the source code and break a breakpoint in GDB, the efficiency is very low. After research, find the following method. 1) The first step is to compile the source code as. O.
Here we use Doug Lea's malloc. C source code as an example.
Download the malloc. C source code:
Http://gee.cs.oswego.edu/pub/misc/malloc.c
Http://gee.cs.oswego.edu/pub/misc/malloc.h
2) view all exported function symbols through nm, and connect the symbols with \ |
NM malloc. o | C ++ filt | grep-w-I t | awk '{print $3}' | tr '\ n',' | SED's /, the result is as follows: add_segment \ | bulk_free \ | calloc \ | change_mparam \ | percent \ | free \ | percent \ | ialloc \ | independent_calloc \ | percent \ | init_bins \ | percent \ | init_top \ | internal_bulk_free \ | internal_mallinfo \ | Alibaba \ | internal_memalign \ | mallinfo \ | malloc \ | malloc_footprint \ | Alibaba \ | malloc_stats \ | malloc_trim \ | Alibaba \ | mallopt \ | memalign \ | mmap_alloc \ | mmap_resize \ | posix_memalign \ | prepend_alloc \ | pvalloc \ | realloc \ | prop \ | percent \ | sys_alloc \ | sys_trim \ | percent \ | tmalloc_small \ | try_realloc_chunk \ | valloc \ | 3) Go to GDB to debug your program and execute the following command:
The symbol string connected by \ | in the Rb
RB add_segment \ | bulk_free \ | calloc \ | change_mparam \ | percent \ | free \ | percent \ | ialloc \ | independent_calloc \ | percent \ | init_bins \ | init_mparams \ | init_top \ | internal_bulk_free \ | internal_mallinfo \ | Alibaba \ | internal_memalign \ | mallinfo \ | malloc \ | Alibaba \ | malloc_stats \ | malloc_trim \ | Alibaba \ | mallopt \ | memalign \ | mmap_alloc \ | mmap_resize \ | posix_memalign \ | prepend_alloc \ | pvalloc \ | realloc \ | identifier \ | sys_alloc \ | sys_trim \ | identifier \ | tmalloc_small \ | try_realloc_chunk \ | valloc
Note: RB uses regular expressions to batch break points on all matching symbols.
I am very satisfied with the following results:
1389vstux8d0dbxpprtpwzpqo8yeora3knwiqk2mnoigys5ocmi

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.