LINUX.ORG.RU

omit-frame-pointer


0

1

пошлите куданить прочитать про это в gcc
он на новых версиях gcc включен по умолчанию в -O2 оптимизацию на 32 битах
и программка одна начинает падать от этого

что именно может не так оптимизироваться в программе с этим флагом - и как избежать этого ?

★★

Frame pointer is a reference pointer allowing a debugger to know where local variable or an argument is at with a single constant offset. Although ESP's value changes over the course of execution, EBP remains the same allowing you to reach the same variable at the same offset (such as first parameter will always be at EBP-4 while ESP offsets can change significantly since you'll be pushing/popping things)

Why don't compilers throw away frame pointer? Because it makes compiler's job easier, it doesn't have to track the change in ESP when generating local variable/argument access code.

With frame pointer, debugger can figure out where local variables and arguments are using the symbol table since they are guaranteed to be at a constant offset to EBP. Otherwise there isn't an easy way to figure where a local variable is at any point in code.

As Greg mentioned, it also helps stack unwinding for a debugger since EBP provides a reverse linked list of stack frames therefore allowing the debugger to figure out size of stack frame (local variables + arguments) of the function.

Most compilers provide an option to omit frame pointers although it makes debugging really hard. That option should never be used globally, even in release code. You don't know when you'll need to debug a user's crash.

говоря по-русски, оснаовная надобность frame-pointer'a - упрощение отладки, т.е. в релизных билдах особой в нем надобности нет и можно соответствующий флаг ставить

marvin_yorke ★★★
()
Ответ на: комментарий от marvin_yorke

эта опция включена по умолчанию в -O2 на новых gcc
если я принудительно ее отклоючаю через -fno-omit-frame-pointer то прога радостно работает
а если нет - то радостно падает

ae1234 ★★
() автор топика
Ответ на: комментарий от unsigned

ассемблерных вставок точно нет

ae1234 ★★
() автор топика
Ответ на: комментарий от ae1234

> а если нет - то радостно падает

Ищи баг. Можно начать валгриндом.

const86 ★★★★★
()
Вы не можете добавлять комментарии в эту тему. Тема перемещена в архив.