본문으로 건너뛰기
0%
약 2분 (338 단어) ko

Preparing for GDB Debugging

Categories TechSavvy EmbeddedLinux
Tags #Blogging #Linux #AGL #EmbeddedLinux #OpenEmbedded #Yocto #CrossDevelopment #GCC #GDB #Toolchain

Once your toolchain is ready, you can consider all the tools prepared.

Now let’s make the actual target you need to debug ready for debugging.

Adjusting Compiler Options

Desktop View Ref: Linux Foundation 2020 Conference

First, when compiling C or C++ source code, add the -g option or -gN option as shown in the diagram above to include various information like source code debugging information in the ELF file.

Using -ggdbN will create an ELF using the gdb format instead of the standard DWARF format.

Generally, just adding -g will give the ELF a level equivalent to -g2.

Desktop View Ref: Linux Foundation 2020 Conference

Next, you need to adjust the Optimization Options.

When optimization is enabled, the compiler analyzes the code logic and might generate different execution code that produces the same results, so you should remove optimization options during debugging.

Use the -O0 option or give -Og for GDB-compatible optimization options.

Reference

  1. http://www.epnc.co.kr/news/articleView.html?idxno=48128

Share this article

Found this helpful? Share it with your network

Join the Discussion

Share your thoughts and connect with other readers

댓글

GitHub 계정으로 로그인하여 댓글을 남겨보세요. 건설적인 의견과 질문을 환영합니다!

댓글을 불러오는 중...