Two auxiliary programming tools perf and GDB under Linux

Source: Internet
Author: User

A few days ago in the laboratory to do a few small experiments, benefited, write code is second, the most important thing is to gradually understand the real computer science work way.

A lot of work can be done efficiently with tools under Linux, such as running a group of experiments with two parameter changes, so you don't have to run it manually multiple times, and you can do it with just one Shell Script. More efficient with awk.

Two of these tools are really good, one is GDB, one is perf. The former is used for program debugging, the latter for program performance detection.

GDB is a great debugger under Linux, and many common debugging tools, such as breakpoint, call stack, are well implemented.

For GDB, it is recommended to read this tutorial, which is very good, especially in the later integrated Pcontainer method for STL.

SF, and the often-appearing core dump, can be accurately positioned with GDB for the previous segment errors that occurred. However, when compiling with g++, add the-ggdb parameter and try not to turn on optimization, otherwise it is difficult for the compiler to record each symbol.

Perf is a program performance detection tool built into the Linux kernel. The specific source code should be found in the kernel.

Before using a graph system to run the experiment, found that multi-threading performance is poor, but can not find bottlenecks, using perf can easily see, is omp_barrier_wait_end, through the search can know that this function is OpenMP synchronous method, then can infer the problem in OpenMP task assignments, unbalanced task assignments result in uneven calculation times.

Perf has built-in tools to see Man perf, the two most important of which are the report and record.

Like the time command, you can generate a report with the Perf record in front of the program, which shows how long each function takes in the program's run, and the general report suffix is. Perf.data.

After the report is generated, the perf report is used to analyze the record-generated reports and to show the specific time-of-use ranking of the functions.

Two auxiliary programming tools perf and GDB under Linux

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.