<optimized out> in debugger

2,150 views
Skip to first unread message

Ehsan

unread,
Sep 16, 2014, 6:55:54 AM9/16/14
to dea...@googlegroups.com
Hi,

When I trace the code in debugger, I get <optimized out> for some variables.
For example I set const double test_value = 1; but when I watch test_value it only shows <optimized out>.
I use last version of eclipse and debug with gdb debugger

How can I solve this problem?

Best regards.
Ehsan

Timo Heister

unread,
Sep 16, 2014, 7:06:18 AM9/16/14
to dea...@googlegroups.com
Ehsan,

is the code compiled in debug mode?
(https://stackoverflow.com/questions/5497855/what-does-value-optimized-out-mean-in-gdb)
> --
> The deal.II project is located at http://www.dealii.org/
> For mailing list/forum options, see
> https://groups.google.com/d/forum/dealii?hl=en
> ---
> You received this message because you are subscribed to the Google Groups
> "deal.II User Group" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to dealii+un...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.



--
Timo Heister
http://www.math.clemson.edu/~heister/

Ehsan

unread,
Sep 16, 2014, 8:11:14 AM9/16/14
to dea...@googlegroups.com
Dear Timo,

How can I compile in debug mode?

I tried make -debug but the problem is not solved.

Regards.
Ehsan

Armin Ghajar Jazi

unread,
Sep 16, 2014, 8:42:55 AM9/16/14
to dea...@googlegroups.com
Ehsan,

you have to specify the type of build when calling the cmake(precompiler) which according to documentation is:
$ cmake -DCMAKE_BUILD_TYPE="Debug" .

$ cmake -DCMAKE_BUILD_TYPE="Release" .

Also take a look at the following:
it gives you a nice overview of cmake-build and compiling.

cheers,
armin

--

Ehsan

unread,
Sep 16, 2014, 9:20:58 AM9/16/14
to dea...@googlegroups.com
Dear Armin,

I did as you recommended, but the problem is not solved yet !!

Best regards.
Ehsan



Ehsan

unread,
Sep 17, 2014, 5:15:29 AM9/17/14
to dea...@googlegroups.com
Hi,
I compiled the code in debug mode, but still get <optimized out> in debugger for some variables.
Is this a usual problem or I am doing something wrong?
Regards.
Ehsan


Wolfgang Bangerth

unread,
Sep 17, 2014, 6:47:26 AM9/17/14
to dea...@googlegroups.com

> I compiled the code in debug mode, but still get <optimized out>in debugger
> for some variables.
> Is this a usual problem or I am doing something wrong?

It's not common but it may happen on rare occasions. I'm still surprised
though. What do you get when you say
ldd my_executable | grep deal_II
where my_executable is the executable program in the directory you're working
in? It should show libdeal_II.g.so if you are linking against the debug mode
libraries (not the .g. in the middle).

The typical case where a variable may be optimized out even in debug mode is
code like this:

class X {
static const unsigned int dim = 2;
};

Here, 'dim' is essentially just an alias for the number 2. It may not have a
memory location. Otherwise, compilers have become pretty good at producing
reasonable debug information.

Best
W.

--
------------------------------------------------------------------------
Wolfgang Bangerth email: bang...@math.tamu.edu
www: http://www.math.tamu.edu/~bangerth/

Ehsan

unread,
Sep 17, 2014, 7:46:41 AM9/17/14
to dea...@googlegroups.com
Hi,
I get libdeal_II.g.so.8.1.0

It is really strange !!
I checked whole code. when I write for example:

const double AAA = 1.2;
right_hand_side.vector_value_list(fe_values.get_quadrature_points(), rhs_values);
const double BBB = 1.2;

the debugger shows the value of AAA but it returns <optimized out> for  BBB.

What happens inside right_hand_side.vector_value_list that causes this problem?

Best regards.
Ehsan

Wolfgang Bangerth

unread,
Sep 17, 2014, 7:51:03 AM9/17/14
to dea...@googlegroups.com

> I get libdeal_II.g.so.8.1.0
>
> It is really strange !!
> I checked whole code. when I write for example:
>
> const double AAA = 1.2;
> right_hand_side.vector_value_list(fe_values.get_quadrature_points(), rhs_values);
> const double BBB = 1.2;
>
> the debugger shows the value of AAA but it returns <optimized out> for BBB.

Do you ever reference BBB? And at what point do you stop the debugger when you
try to print BBB?


> What happens inside right_hand_side.vector_value_list that causes this problem?

I don't know. This is the wrong forum for your question. We can help you with
questions about deal.II, but you are asking a question of why your compiler
does not communicate information to the debugger (we don't even know which
compiler or debugger). This is a question for the compiler/debugger people.

Ehsan

unread,
Sep 17, 2014, 8:03:30 AM9/17/14
to dea...@googlegroups.com
Dear bangerth,

I use last version of eclipse and gdb.
yes, you are right, may be this problem is not related to deal ii.
I will try to install eclipse and gdb again maybe this solve the problem.

So many thanks for everyone's reply.

Best regards.
Ehsan

Mark McClure

unread,
Apr 4, 2020, 1:56:18 PM4/4/20
to deal.II User Group
If you are inside an openmp loop, even if the number of threads is 1, then variables declared locally inside the loop may appear as 'optimized out' it in the debugger. Temporary solution during debugging is to remove the openmp pragma in front of the for loop.
Reply all
Reply to author
Forward
0 new messages