Important Notice: Our web hosting provider recently started charging us for additional visits, which was unexpected. In response, we're seeking donations. Depending on the situation, we may explore different monetization options for our Community and Expert Contributors. It's crucial to provide more returns for their expertise and offer more Expert Validated Answers or AI Validated Answers. Learn more about our hosting issue here.

How do I debug with gdb?

debug gdb
0
10 Posted

How do I debug with gdb?

0
10

First gotcha is that GDB can’t resolve symbols in PIEs; it doesn’t realise that the addresses are relative in PIEs not absolute. This shows up when you try to get a backtrace for example, and see a stream of lines with ‘??’ where the symbol should be. To get around this, do the final link stage with -nopie – all the preceding object compilations can still be with -fPIE as normal (i.e. the default with the hardened compiler) so that your executable is as close as possible to the real thing, but the final link must create a regular executable. Try adding -nopie to LDFLAGS if you’re building with emerge. Another way of accomplishing this, it to emerge =sys-devel/gdb-6.3-r5, which contains a special patch that makes it able to debug executeables linked with -pie. The second gotcha is that PaX may prevent GDB from setting breakpoints, depending on how the kernel is configured. This includes the breakpoint at main which you need to get started. To stop PaX doing this, the executable being de

Related Questions

What is your question?

*Sadly, we had to bring back ads too. Hopefully more targeted.

Experts123